home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / pcw_c.zip / MSTSCRN.ASM < prev    next >
Assembly Source File  |  1991-12-16  |  29KB  |  580 lines

  1.               Title Tscrn.Asm
  2.               Page ,120
  3. ;****************************************************************
  4. ;* File Id.                       Mstscrn.Asm                   *
  5. ;* Author.                        Stan Milam.                   *
  6. ;* Date Written.                  11/03/88.                     *
  7. ;* Date Last Modified.            03/12/89.                     *
  8. ;*                                                              *
  9. ;*           (c) Copyright 1989, 1990 by Stan Milam             *
  10. ;*                                                              *
  11. ;* Comments: This file is represents a group of Assembler       *
  12. ;* routines designed to make screen handling in C more powerful.*
  13. ;* Featured routines for screen save & restore, quick screen    *
  14. ;* writes with color.                                           *
  15. ;*                                                              *
  16. ;* NOTE: This version of Tscrn.Asm is used for Turbo C & MSC and*
  17. ;* was compiled with MASM 5.1, but can be compiled with         *
  18. ;* Borland's Turbo Assembler also.                              *
  19. ;****************************************************************
  20. ;
  21. SyncCntl      Equ       200
  22. True          Equ       1
  23. False         Equ       0
  24. MaxMove       Equ       2000
  25.  
  26.               Dosseg                       ;Use standard segmentation
  27.               .Model    Huge,C
  28.               Extrn     Vbump:Word
  29.               Extrn     CheckSnow:Word
  30.               .Data
  31.               .Code
  32.               Page
  33. ;
  34. ;****************************************************************
  35. ;*                            Tputchar                          *
  36. ;*                                                              *
  37. ;* This routine will write a character to the screen with a     *
  38. ;* color attribute at the specified row, col                    *
  39. ;*                                                              *
  40. ;* Uses:    Sync_Wait                                           *
  41. ;* Prototype:                                                   *
  42. ;*  void Tputchar(int far *scrnptr, int attrchar);              *
  43. ;****************************************************************
  44. ;
  45.               Public    Tputchar
  46. Tputchar      Proc      scrnptr:far ptr,attrchar:word
  47.               Push      Di
  48.               Push      Es
  49.               Push      Ax
  50.               Push      Bx
  51.               Mov       Ax,Seg CheckSnow
  52.               Mov       Es,Ax
  53.               Mov       Bx,Es:Word Ptr CheckSnow
  54.               Mov       Ax,attrchar         ;Put attribut & character in Ax
  55.               Les       Di,scrnptr          ;Get Screen pointer
  56.               Cmp       Bx,True
  57.               Jne       Putchar
  58.               Call      Sync_Wait
  59. Putchar:
  60.               Stosw                         ;Put the attr & char in video
  61.               Pop       Bx
  62.               Pop       Ax
  63.               Pop       Es
  64.               Pop       Di
  65.               Ret
  66. Tputchar      Endp
  67.               Page
  68. ;
  69. ;****************************************************************
  70. ;*                             Tputs                            *
  71. ;*                                                              *
  72. ;* This routine will be used to write character strings into    *
  73. ;* video memory with color attribute.  It will return the number*
  74. ;* characters written.                                          *
  75. ;*                                                              *
  76. ;* Prototype:                                                   *
  77. ;* int Tputs(far *Sptr, char *strptr, int attr)                 *
  78. ;****************************************************************
  79. ;
  80.               Public    Tputs               ;Make function global
  81. Tputs         Proc      Sptr:Far Ptr, Strptr:Far Ptr, Attr:Word
  82.               Push      Si
  83.               Push      Di
  84.               Push      Ds
  85.               Push      Es                  ;Save Es
  86.               Push      Bx
  87.               Push      Cx                  ;Save Cx
  88.               Mov       Bx,Seg CheckSnow    ;Save CheckSnow
  89.               Mov       Es,Bx
  90.               Mov       Bx,Es:Word Ptr CheckSnow
  91.               Xor       Cx,Cx               ;Clear Cx
  92.               Mov       Ax,attr             ;Get color attribute
  93.               Lds       Si,strptr           ;Get string pointer
  94.               Les       Di,sptr             ;point to screen memory ES:DI
  95.               Cmp       Bx,True             ;Need to wait for vertical sync?
  96.               Jne       Twrite              ;No - proceed
  97.               Call      Sync_Wait           ;Yes - so wait
  98. Twrite:       Lodsb                         ;Get character from string
  99.               Or        Al,Al               ;Is it a '\0'?
  100.               Jz        Exit                ;Yes - we are done
  101.               Stosw                         ;Else put attr & char in video
  102.               Inc       Cx                  ;Add 1 to our count
  103.               Jmp       Twrite              ;And do it all again
  104. Exit:
  105.               Mov       Ax,Cx               ;Return the count
  106.               Pop       Cx                  ;Restore Cx
  107.               Pop       Bx
  108.               Pop       Es                  ;Restore Es
  109.               Pop       Ds
  110.               Pop       Di
  111.               Pop       Si
  112.               Ret
  113. Tputs         Endp
  114.               Page
  115. ;
  116. ;****************************************************************
  117. ;*                            Tvputs                            *
  118. ;*                                                              *
  119. ;* This routine will write a string vertically on the screen.   *
  120. ;*                                                              *
  121. ;* Prototype:                                                   *
  122. ;*  Tvputs((int far *) ScrnSeg, (char far *) str, int attr);    *
  123. ;****************************************************************
  124. ;
  125.               Public    Tvputs
  126. Tvputs        Proc  Scrnptr:Far Ptr, Strptr:Far Ptr, Attr:Word
  127.               Push      Es                  ;
  128.               Push      Ds                  ;
  129.               Push      Si                  ;
  130.               Push      Di                  ;
  131.               Push      Ax                  ;
  132.               Push      Bx                  ;
  133.               Push      Dx                  ;
  134.               Mov       Bx,Seg CheckSnow
  135.               Mov       Es,Bx
  136.               Mov       Bx,Es:Word Ptr CheckSnow
  137.               Mov       Dx,Es:Word Ptr Vbump
  138.               Mov       Ax,Attr             ;Get Color Attribute
  139.               Lds       Si,Strptr           ;Get address of String
  140.               Les       Di,Scrnptr          ;Point to video Memory
  141.               Cmp       Bx,True             ;Need to call Sync_Wait?
  142.               Jne       Tvwrite             ;No - proceed
  143.               Call      Sync_Wait           ;Wait for vertical retrace
  144. Tvwrite:
  145.               Lodsb                         ;Get Char & Attribute in Ax
  146.               Or        Al,Al               ;Is Char '\0'
  147.               Jz        Tvend               ;Yes - We are done
  148.               Push      Di                  ;Save the current column
  149.               Stosw                         ;Write to Screen Memory
  150.               Pop       Di                  ;Restore Column
  151.               Add       Di,Dx               ;Next Column
  152.               Jmp       Tvwrite             ;Go back to do it again
  153. Tvend:
  154.               Pop       Dx                  ;
  155.               Pop       Bx                  ;
  156.               Pop       Ax                  ;
  157.               Pop       Di                  ;
  158.               Pop       Si                  ;
  159.               Pop       Ds                  ;
  160.               Pop       Es                  ;
  161.               Ret                           ;Return to C program
  162. Tvputs        Endp
  163.               Page
  164. ;
  165. ;****************************************************************
  166. ;*                          SaveScrn                            *
  167. ;*                                                              *
  168. ;* This module will be used to save a specified block of a      *
  169. ;* screen in a character buffer.                                *
  170. ;*                                                              *
  171. ;* Uses Sync_Wait                                               *
  172. ;* Prototype:                                                   *
  173. ;*  int SaveScrn(int rows, int cols, int far *scrnptr, char *ptr*
  174. ;*                                                              *
  175. ;****************************************************************
  176.               Public    SaveScrn
  177. SaveScrn      Proc      Rows:Word,Cols:Word,Sptr:Far Ptr,Chr:Far Ptr
  178.               Push      Si                  ;
  179.               Push      Di                  ;
  180.               Push      Ds                  ;Save the Regs!
  181.               Push      Es                  ;
  182.               Push      Ax                  ;
  183.               Push      Bx                  ;
  184.               Push      Cx                  ;
  185.               Push      Dx                  ;
  186.               Mov       Ax,Seg Vbump        ;
  187.               Mov       Es,Ax
  188.               Mov       Dx,Es:Word Ptr Vbump
  189.               Mov       Bx,Es:Word Ptr CheckSnow
  190.               Xor       Ax,Ax               ;Clear Ax              
  191.               Lds       Si,Sptr             ;get pointer to screen
  192.               Les       Di,Chr              ;pointer to save buffer
  193.               Mov       Cx,Rows             ;get number of rows
  194.               Cmp       Bx,1                ;Check for CGA monitor
  195.               Jne       SaveRow             ;Not a CGA so go ahead
  196.               Call      Sync_Wait           ;Otherwise wait for vert sync
  197. SaveRow:
  198.               Push      Cx                  ;Save the Number of rows to go
  199.               Push      Si                  ;Save screen offset
  200.               Mov       Cx,Cols             ;get # of cols
  201.               Cmp       Bx,True             ;Cga monitor?
  202.               Jne       Save                ;No - do not wait
  203.               Cmp       Ax,SyncCntl         ;Ax > SyncCntl?
  204.               Jl        Save                ;No - Go Ahead
  205.               Xor       Ax,Ax               ;Else clear Ax
  206.               Call      Sync_Wait           ;and wait for vert sync
  207. Save:
  208.               Add       Ax,Cx               ;Accumulate number of words
  209.               Rep       Movsw               ;Save quickly
  210.               Pop       Si                  ;Pop screen offset
  211.               Add       Si,Dx               ;Bump offset to next screen row
  212.               Pop       Cx                  ;Pop number of rows to go
  213.               Loop      SaveRow             ;Do again if Cx != zero
  214.               Pop       Dx                  ;
  215.               Pop       Cx                  ;
  216.               Pop       Bx                  ;
  217.               Pop       Ax                  ;
  218.               Pop       Es                  ;Restore the Regs!
  219.               Pop       Ds                  ;
  220.               Pop       Di                  ;
  221.               Pop       Si                  ;
  222.               Xor       Ax,Ax               ;Send back zero return code
  223.               Ret
  224. SaveScrn      Endp
  225.               Page
  226. ;
  227. ;****************************************************************
  228. ;*                          RestoreScrn                         *
  229. ;*                                                              *
  230. ;* This routine will restore a previously saved screen.         *
  231. ;*                                                              *
  232. ;* Uses:   Sync_Wait                                            *
  233. ;* ProtoType:                                                   *
  234. ;*   int RestoreScrn(int rows, int cols, int far *sptr, char ch *
  235. ;****************************************************************
  236. ;
  237.               Public    RestoreScrn
  238. RestoreScrn   Proc      Rows:Word,Cols:Word,Scrnptr:Far Ptr,Chr:Far Ptr
  239.               Push      Ds                  ;
  240.               Push      Es                  ;
  241.               Push      Di                  ;
  242.               Push      Si                  ;Save the Regs
  243.               Push      Ax                  ;
  244.               Push      Bx                  ;
  245.               Push      Cx                  ;
  246.               Push      Dx                  ;
  247.               Mov       Ax,Seg CheckSnow
  248.               Mov       Es,Ax
  249.               Mov       Bx,Es:Word Ptr CheckSnow
  250.               Mov       Dx,Es:Word Ptr Vbump
  251.               Xor       Ax,Ax               ;Clear Ax 
  252.               Les       Di,Scrnptr          ;Get screen pointer
  253.               Lds       Si,Chr              ;Get pointer to buffer
  254.               Mov       Cx,Rows             ;Get number of Rows
  255.               Cmp       Bx,1                ;Check for CGA
  256.               Jne       RestoreRow
  257.               Call      Sync_Wait           ;Call sync_wait if CGA
  258. RestoreRow:
  259.               Push      Cx                  ;Save the rows to go
  260.               Push      Di                  ;Save screen offset
  261.               Mov       Cx,Cols             ;Get number of columns
  262.               Cmp       Bx,1                ;Check for CGA
  263.               Jne       Restore             ;Go around if not
  264.               Cmp       Ax,SyncCntl         ;Is Ax > SyncCntl
  265.               Jl        ReStore             ;Yes: Go Ahead
  266.               Xor       Ax,Ax               ;Zero Ax
  267.               Call      Sync_Wait           ;And Call Sync_Wait
  268. Restore:
  269.               Add       Ax,Cx               ;Add number of cols to Ax
  270.               Rep       Movsw               ;Restore a row on screen
  271.               Pop       Di                  ;Pop screen offset
  272.               Add       Di,Dx               ;Bump offset 1 row
  273.               Pop       Cx                  ;Pop # of rows to go
  274.               Loop      RestoreRow          ;Do again if Cx != 0
  275.               Pop       Dx                  ;
  276.               Pop       Cx                  ;
  277.               Pop       Bx                  ;
  278.               Pop       Ax                  ;
  279.               Pop       Si                  ;Restore Regs!
  280.               Pop       Di                  ;
  281.               Pop       Es                  ;
  282.               Pop       Ds                  ;
  283.               Xor       Ax,Ax               ;Send 0 return code back
  284.               Ret
  285. RestoreScrn   Endp
  286.               Page
  287. ;
  288. ;****************************************************************
  289. ;*                          TextFill                            *
  290. ;*                                                              *
  291. ;* This routine will define the window by filling the rectan-   *
  292. ;* gular area with a color attribute and spaces.  Needless to   *
  293. ;* say, this is usualy done after the area has been saved away. *
  294. ;*                                                              *
  295. ;* Uses:    Sync_Wait.                                          *
  296. ;* Prototype:                                                   *
  297. ;* void TextFill(int rows, int cols, int far *sptr, int attrchr)*
  298. ;****************************************************************
  299. ;
  300.               Public    TextFill
  301. TextFill      Proc      Rows:Word,Cols:Word,Scrnptr:Far Ptr,Attrchr:Word
  302.               Push      Si
  303.               Push      Di
  304.               Push      Ds
  305.               Push      Es
  306.               Push      Ax
  307.               Push      Bx
  308.               Push      Cx
  309.               Push      Dx
  310.               Mov       Dx,Seg CheckSnow
  311.               Mov       Es,Dx
  312.               Mov       Bx,Es:Word Ptr CheckSnow
  313.               Mov       Si,Es:Word Ptr Vbump
  314.               Xor       Dx,Dx               ;Clear Dx
  315.               Mov       Cx,Rows             ;Get # of rows
  316.               Les       Di,scrnptr          ;Get pointer to screen
  317.               Mov       Ax,attrchr          ;Get color attr & space
  318.               Cmp       Bx,True             ;Is CGA active?
  319.               Jne       Fill                ;No, continue on
  320.               Call      Sync_Wait           ;Yes, wait for vert sync
  321. Fill:
  322.               Push      Cx                  ;Save number of rows to go
  323.               Push      Di                  ;Save screen offset
  324.               Mov       Cx,Cols             ;Move in number of columns
  325.               Cmp       Bx,True             ;CGA active?
  326.               Jne       Fill1               ;No so skip
  327.               Cmp       Dx,SyncCntl         ;Dx < SyncCntl?
  328.               Jl        Fill1               ;Yes so skip
  329.               Xor       Dx,Dx               ;Clear Dx
  330.               Call      Sync_Wait           ;Wait for vertical sync
  331. Fill1:
  332.               Add       Dx,Cx               ;Add to count control
  333.               Rep       Stosw               ;Store attr & character in Ax
  334.               Pop       Di                  ;Get offset back
  335.               Add       Di,Si               ;Bump it by 1 screen row
  336.               Pop       Cx                  ;Get number of rows back
  337.               Loop      Fill                ;and repeat until finished
  338.               Pop       Dx                  ;
  339.               Pop       Cx                  ;
  340.               Pop       Bx                  ;
  341.               Pop       Ax                  ;Restore Regs!
  342.               Pop       Es                  ;
  343.               Pop       Ds                  ;
  344.               Pop       Di                  ;
  345.               Pop       Si                  ;
  346.               Xor       Ax,Ax               ;Return zero return code
  347.               Ret
  348. TextFill      Endp
  349.               Page
  350. ;
  351. ;****************************************************************
  352. ;*                           TvertChar                          *
  353. ;*                                                              *
  354. ;* This function will write a character to the screen repeatedly*
  355. ;* The number of time the character will be written is          *
  356. ;* spcecified by 'count'.                                       *
  357. ;*                                                              *
  358. ;* Prototype:                                                   *
  359. ;*  void Tvertchar(int count, int charattr, int far *scrnptr);  *
  360. ;****************************************************************
  361. ;
  362.               Public    Tvertchar
  363. Tvertchar     Proc      cnt:word, chrattr:word, scrnptr:far ptr
  364.               Push      Ax                  ;
  365.               Push      Bx
  366.               Push      Cx                  ;Save Regs
  367.               Push      Dx
  368.               Push      Es                  ;
  369.               Push      Di                  ;
  370.               Mov       Bx,Seg CheckSnow
  371.               Mov       Es,Bx
  372.               Mov       Bx,Es:Word Ptr CheckSnow
  373.               Mov       Dx,Es:Word Ptr Vbump
  374.               Mov       Cx,cnt              ;Get the count
  375.               Mov       Ax,chrattr          ;Get char & attribute
  376.               Les       Di,scrnptr          ;Pointer to screen memory
  377.               Cmp       Bx,True             ;Is CheckSnow True?
  378.               Jne       VertLoop            ;No - go right to it
  379.               Call      Sync_Wait           ;Wait for Vert Sync
  380. VertLoop:
  381.               Push      Di                  ;Save screen offset
  382.               Stosw                         ;Put the character to memory
  383.               Pop       Di                  ;Return the segment
  384.               Add       Di,Dx               ;Bump to next row
  385.               Loop      VertLoop
  386.               Pop       Di
  387.               Pop       Es
  388.               Pop       Dx
  389.               Pop       Cx
  390.               Pop       Bx
  391.               Pop       Ax
  392.               Ret
  393. Tvertchar     Endp
  394.               Page
  395. ;
  396. ;****************************************************************
  397. ;*                          Thorzchar                           *
  398. ;*                                                              *
  399. ;* This routine will repeatedly write a character horizontally  *
  400. ;* across the screen.  The number of times the character is     *
  401. ;* is written is determined by the count in Cx.                 *
  402. ;* Prototype:                                                   *
  403. ;*   void Thorzchar(int count, int chrattr, int far *scrnptr)   * 
  404. ;****************************************************************
  405. ;
  406.               Public    Thorzchar
  407. Thorzchar     Proc      cnt:word,chrattr:word,scrnptr:far ptr
  408.               Push      Ax                  ;Save Registers
  409.               Push      Bx                  ;
  410.               Push      Cx                  ;
  411.               Push      Di                  ;
  412.               Push      Es                  ;
  413.               Mov       Bx,Seg CheckSnow
  414.               Mov       Es,Bx
  415.               Mov       Bx,Es:Word Ptr CheckSnow
  416.               Mov       Cx,cnt              ;Get Count into Cx
  417.               Mov       Ax,chrattr          ;Get Char & Attr in Ax
  418.               Les       Di,scrnptr          ;Get Segment/Offset of Scrn Mem
  419.               Cmp       Bx,True             ;Is it CGA?
  420.               Jne       HorzLoop            ;No!
  421.               Call      Sync_Wait           ;Yes - Wait for Vertical Sync
  422. HorzLoop:
  423.               Rep       Stosw               ;Continually put char in mem
  424.               Pop       Es                  ;Restore Regs
  425.               Pop       Di                  ;
  426.               Pop       Cx                  ;
  427.               Pop       Bx                  ;
  428.               Pop       Ax                  ;
  429.               Ret                           ;Return to Calling C Pgm
  430. Thorzchar     Endp
  431.               Page
  432. ;
  433. ;****************************************************************
  434. ;*                           Tchg_Attr                          *
  435. ;*                                                              *
  436. ;* This function will change the screen attributes of a speci-  *
  437. ;* fied number of columns.                                      *
  438. ;*                                                              *
  439. ;* C Prototype:                                                 *
  440. ;*  void Tchg_Attr(int far *scrnptr, int count, int attr);      *
  441. ;****************************************************************
  442. ;
  443.               Public    Tchg_Attr
  444. Tchg_Attr     Proc      ScrnPtr:Far Ptr,Count:Word,Attr:Word
  445.               Push      Ax                  ;Save the Registers
  446.               Push      Cx                  ;
  447.               Push      Dx                  ;
  448.               Push      Si                  ;
  449.               Push      Di                  ;
  450.               Push      Ds                  ;
  451.               Push      Es                  ;
  452.               Mov       Dx,Seg CheckSnow
  453.               Mov       Es,Dx
  454.               Mov       Dx,Es:Word Ptr CheckSnow
  455.               Lds       Si,ScrnPtr          ;Get Segment/Offset of screen
  456.               Les       Di,ScrnPtr          ;Get it again
  457.               Mov       Cx,Count            ;Get the count
  458.               Mov       Ax,Attr             ;Get attribute (in Ah)
  459.               Cmp       Dx,True             ;Is it a CGA?
  460.               Jne       Tchg                ;No!
  461.               Call      Sync_Wait           ;Yes - Wait for Vertical Sync
  462. Tchg:
  463.               Lodsb                         ;Read Char from scrn into Al
  464.               Inc       Si                  ;Bump past scrn attr
  465.               Stosw                         ;Store Ax into Screen Memory
  466.               Loop      Tchg                ;Do until Cx = 0
  467.               Pop       Es                  ;Restore Registers
  468.               Pop       Ds                  ;
  469.               Pop       Di                  ;
  470.               Pop       Si                  ;
  471.               Pop       Dx                  ;
  472.               Pop       Cx                  ;
  473.               Pop       Ax                  ;
  474.               Ret                           ;Return to calling C Pgm
  475. Tchg_Attr     Endp
  476.               Page
  477. ;*********************************************************************
  478. ;*                             Tscroll                               *
  479. ;*                                                                   *
  480. ;* Low level routine to scroll the video screen up & down.           *
  481. ;*                                                                   *
  482. ;* Tscroll(void far *srce, void far *dest, int row, int col, int dir)*
  483. ;*********************************************************************
  484. ;
  485.               Public    Tscroll
  486. Tscroll       Proc      Srce:Far Ptr,Dest:Far Ptr,Rows:Word,Cols:Word,Dir:Word
  487.               Push      Ax                  ;Save All Registers Used
  488.               Push      Bx
  489.               Push      Cx
  490.               Push      Dx
  491.               Push      Di
  492.               Push      Si
  493.               Push      Ds
  494.               Push      Es
  495.               Pushf                         ;Save flags - we change direction
  496.               Mov       Bx,Seg CheckSnow
  497.               Mov       Es,Bx
  498.               Mov       Bx,Es:Word Ptr CheckSnow
  499.               Mov       Ax,Es:Word Ptr Vbump
  500.               Xor       Dx,Dx               ;Clear Accumulator
  501.               Mov       Bh,Bl               ;Put in CheckSnow in Bh
  502.               Push      Ax                  ;Save Vbump
  503.               Mov       Ax,Dir              ;Get Direction Flag
  504.               Mov       Bl,Al               ;Save it in Bl
  505.               Pop       Ax                  ;Restore Vbump
  506.               Lds       Si,Srce             ;Get source pointer off of stack
  507.               Les       Di,Dest             ;Get Destination pointer
  508.               Mov       Cx,Rows             ;Get The number of Rows
  509.               Cld                           ;Set direction flag forward
  510.               Cmp       Bh,1                ;Is monitor a CGA?
  511.               Jne       Scroll_Line         ;No
  512.               Call      Sync_Wait           ;Yes wait for vertical sync
  513. Scroll_Line:
  514.               Push      Si                  ;Save pointers
  515.               Push      Di                  ;
  516.               Push      Cx                  ;Save Number of Rows to go
  517.               Mov       Cx,Cols             ;Get number of columns to save
  518.               Cmp       Bh,1                ;Do we have a CGA?
  519.               Jne       Moveit              ;No just save
  520.               Add       Dx,Cx               ;Accumulate number of bytes saved
  521.               Cmp       Dx,SyncCntl         ;Have we saved all we can?
  522.               Jng       Moveit              ;No continue onward and downward
  523.               Xor       Dx,Dx               ;Clear accumulator
  524.               Call      Sync_Wait           ;Wait for vertical retrace
  525. Moveit:       Rep       Movsw               ;Save a Row
  526.               Pop       Cx                  ;Restore row count
  527.               Pop       Di                  ;Restore Screen pointers
  528.               Pop       Si
  529.               Cmp       Bl,0                ;Going Down?
  530.               Jne       Adjust_Up           ;No 
  531.               Sub       Si,Ax               ;Mov Pointer up
  532.               Sub       Di,Ax               ;
  533.               Loop      Scroll_Line         ;Scroll one more line
  534.               Jmp       Scroll_Exit         ;Exit when done
  535. Adjust_Up:
  536.               Add       Si,Ax               ;Move pointers to next row
  537.               Add       Di,Ax               ;
  538.               Loop      Scroll_Line         ;Scroll one more line
  539. Scroll_Exit:  Popf                          ;Retore all saved registers
  540.               Pop       Es                  ;
  541.               Pop       Ds                  ;
  542.               Pop       Si                  ;
  543.               Pop       Di                  ;Restore Regs & Stack
  544.               Pop       Dx                  ;
  545.               Pop       Cx                  ;
  546.               Pop       Bx                  ;
  547.               Pop       Ax                  ;
  548.               Ret                           ;Return to caller
  549. Tscroll       Endp
  550.               Page
  551. ;
  552. ;
  553. ;****************************************************************
  554. ;*                           Sync_Wait                          *
  555. ;*                                                              *
  556. ;* A useful procedure to wait for the vertical sync of CGA      *
  557. ;* monitors.                                                    *
  558. ;****************************************************************
  559. ;
  560. Sync_Wait     Proc      Near
  561.               Push      Ax
  562.               Push      Dx
  563.               Cli
  564.               Mov       Dx,3DAh
  565. Not_Sync:
  566.               In        Al,Dx
  567.               And       Al,08h
  568.               Jnz       Not_Sync
  569. Sync:
  570.               In        Al,Dx
  571.               And       Al,08h
  572.               Jz        Sync
  573.               Pop       Dx
  574.               Pop       Ax
  575.               Sti
  576.               Ret
  577. Sync_Wait     Endp
  578.               End
  579.  
  580.