home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TUR6_101.ZIP / V19.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-06-07  |  9.2 KB  |  165 lines

  1. ;--------------------------------------------------------------------
  2. ; Author       : Kevin Dahl                                         :
  3. ; Last Revised : June 7, 1986                                       :
  4. ;                                                                   :
  5. ; FILENAME - V19.ENH                                                :
  6. ;                                                                   :
  7. ; SCROLLRIGHT                                                       :
  8. ;        Moves a block of characters right on the screen            :
  9. ;                                                                   :
  10. ; ENTRY                                                             :
  11. ;        [bp+6]  = Bottom row of screen area to be scrolled.        :
  12. ;        [bp+8]  = Right column of screen area to be scrolled.      :
  13. ;        [bp+10] = Top row of screen are to be scrolled.            :
  14. ;        [bp+12] = Left column of screen area to be scrolled.       :
  15. ;        [bp+14] = Attribute color to be used on blank line.        :
  16. ;        [bp+16] = Number of columns to scroll                      :
  17. ;                                                                   :
  18. ; EXIT                                                              :
  19. ;        Nothing -- the screen is modified.                         :
  20. ;--------------------------------------------------------------------
  21. scrollright   proc      near
  22.               push      ds
  23.               push      bp                       ; save stack
  24.               mov       bp,sp
  25.               mov       ah,0fh                   ; get current video mode
  26.               int       10h                      ; using BIOS services
  27.               xor       dx,dx                    ; zero out dx register
  28.               mov       dl,ah                    ; save number columns per line
  29.               cmp       al,7                     ; check for monochrome monitor
  30.               je        v67
  31.               cmp       al,4                     ; check if text modes
  32.               jb        v65                      ; graphics mode - no write
  33.               jmp       v75
  34. v65:
  35.               mov       cx,7                     ; set for 40 col text modes
  36.               cmp       dl,80                    ; check for num of cols
  37.               jb        v66                      ; 40 cols if jmp
  38.               inc       cx                       ; if get here then 80 cols
  39. v66:
  40.               xor       ax,ax                    ; zero out ax
  41.               mov       al,bh                    ; active display page for CGA
  42.               shl       ax,cl                    ; calc address for display page
  43.               mov       cx,0B800h                ; address for CGA
  44.               add       ax,cx                    ; calc starting address
  45.               jmp       v68
  46. v67:
  47.               mov       ax,0B000h                ; monochrome monitor address
  48. v68:
  49.               mov       es,ax                    ; video address into es
  50.               mov       ds,ax                    ; video address into ds
  51.               xor       ax,ax                    ; zero out ax
  52.               mov       bx,ax                    ; zero out bx
  53.               push      dx                       ; save # cols on screen
  54.  
  55.               mov       al,[bp+10]               ; top row parameter
  56.               dec       ax                       ; (row - 1)
  57.               mul       dx                       ; (row - 1) * number of columns
  58.               add       ax,[bp+8]                ; (row - 1) * # cols + col offset
  59.               dec       ax                       ; (row - 1) * # cols + col offset - 1
  60.               shl       ax,1                     ; ((row-1)* #cols + col offset - 1)*2
  61.               inc       ax                       ; start at attribute byte
  62.               mov       di,ax                    ; left col starting point
  63.               pop       dx                       ; get # cols/screen
  64.               push      ax                       ; save left col start pt
  65.               dec       ax
  66.  
  67.               mov       bx,[bp+16]               ; # cols to scroll
  68.               shl       bx,1                     ; mult by 2
  69.               sub       ax,bx                    ; sub # cols to scroll
  70.               inc       ax                       ; start at attribute byte
  71.               mov       si,ax                    ; move into source index
  72.               push      ax                       ; save start pt
  73.               dec       ax
  74.  
  75.               shl       dx,1                     ; for offset information
  76.               push      dx                       ; save for later use
  77.  
  78.               mov       cx,[bp+8]                ; right column
  79.               sub       cx,[bp+12]               ; left column
  80.               sub       cx,[bp+16]               ; rc - lc - #cols to scroll
  81.               inc       cx                       ; add one
  82.               shl       cx,1                     ; mult by 2
  83.               cmp       cx,1                     ; if < 1 then clear window
  84.               jb        v75                      ; no characters to display
  85.  
  86.               push      cx                       ; save # cols to adjust
  87.               mov       cx,[bp+6]                ; bottom row
  88.               sub       cx,[bp+10]               ; bottom row - top row
  89.               inc       cx                       ; add one
  90.               pop       ax                       ; # cols to scroll
  91.               std                                ; set direction flag
  92.               cli                                ; clear interrupts
  93.  
  94. v69:          push      ax                       ; # cols to scroll on 1 line
  95.               push      cx                       ; # rows to be scrolled
  96.               mov       cx,ax                    ; set for inner loop
  97.  
  98.               mov       dx,03DAh                 ; status port
  99. v70:
  100.               in        al,dx                    ; get status
  101.               test      al,1                     ; is it low?
  102.               jnz       v70                      ; wait until it is
  103. v71:
  104.               in        al,dx                    ; get status
  105.               test      al,1                     ; is it high?
  106.               jz        v71                      ; wait until it is
  107.               movsb                              ; put char & attribute byte
  108.               loop      v70                      ; repeat until done
  109.  
  110.               dec       di
  111.               mov       bh,[bp+14]               ; attribute color
  112.               mov       bl,32                    ; blank space
  113.               mov       cx,[bp+16]               ; # cols to scroll
  114. v72:
  115.               in        al,dx                    ; get status
  116.               test      al,1                     ; is it low?
  117.               jnz       v72                      ; wait until it is
  118. v73:
  119.               in        al,dx                    ; get status
  120.               test      al,1                     ; is it high?
  121.               jz        v73                      ; wait until it is
  122.               mov       ax,bx                    ; char & attribute to display
  123.               stosw                              ; put char & attribute byte
  124.               loop      v72                      ; repeat until done
  125.  
  126.               pop       cx                       ; # rows to be scrolled
  127.               pop       ax                       ; # cols to scroll on 1 line
  128.               pop       dx                       ; # cols per screen
  129.               pop       si                       ; start pt of col to move left
  130.               pop       di                       ; start pt of col for si
  131.               add       di,dx                    ; add for next row
  132.               add       si,dx                    ; add for next row
  133.               push      di                       ; save start pt
  134.               push      si                       ; save start pt of col to move left
  135.               push      dx                       ; save # cols per screen
  136.  
  137.               loop      v69
  138.               sti
  139.               jmp       v75
  140. v74:
  141.               mov       dh,[bp+6]                ; bottom row
  142.               mov       dl,[bp+8]                ; right column
  143.               mov       ch,[bp+10]               ; top row
  144.               mov       cl,[bp+12]               ; left column
  145.               dec       dh
  146.               dec       dl
  147.               dec       ch
  148.               dec       cl
  149.               mov       bh,[bp+14]               ; color for blank rows
  150.               mov       al,[bp+16]               ; number of lines to scroll
  151.               mov       ah,7                     ; scroll down service
  152.               push      bp                       ; save base pointer
  153.               int       10h                      ; let BIOS do scroll
  154.               pop       bp
  155. v75:
  156.               pop       ax                       ; clean up stack
  157.               pop       ax
  158.               pop       ax
  159.  
  160.               mov       sp,bp                    ; restore stack
  161.               pop       bp                       ; restore base pointer
  162.               pop       ds                       ; restore data segment
  163.               ret       12                       ; remove parameters and return
  164. scrollright   endp
  165.