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

  1. ;--------------------------------------------------------------------
  2. ; Author       : Kevin Dahl                                         :
  3. ; Last Revised : June 7, 1986                                       :
  4. ;                                                                   :
  5. ; FILENAME - V10.ENH                                                :
  6. ;                                                                   :
  7. ; GETSCRN                                                           :
  8. ;        Read the character and its attribute byte into the         :
  9. ;        character buffer passed.                                   :
  10. ; ENTRY                                                             :
  11. ;        [bp+6]  = Segment of character array parameter             :
  12. ;        [bp+8]  = Starting address within segment of the character :
  13. ;                  array parameter.                                 :
  14. ;        [bp+10] = Number of characters to retrieve from the screen.:
  15. ;        [bp+12] = The row of the first character to retrieve.      :
  16. ;        [bp+14] = The column of the first character to retrieve.   :
  17. ;                                                                   :
  18. ; EXIT                                                              :
  19. ;        [bp+6]:[bp+8] = Screen contents starting at [bp+12],[bp+14]:
  20. ;                        for [bp+10] words.                         :
  21. ;--------------------------------------------------------------------
  22. getscrn       proc      near
  23.               push      ds
  24.               push      bp                       ; save stack
  25.               mov       bp,sp
  26.               mov       ah,0fh                   ; get current video mode
  27.               int       10h                      ; using BIOS services
  28.               xor       dx,dx                    ; zero out dx register
  29.               mov       dl,ah                    ; save number columns per line
  30.               cmp       al,7                     ; check for monochrome monitor
  31.               je        v43
  32.               cmp       al,3                     ; check if text modes
  33.               ja        v47                      ; graphics mode - no write
  34.               mov       cx,7                     ; set for 40 col text modes
  35.               cmp       dl,80                    ; check for num of cols
  36.               jb        v42                      ; 40 cols if jmp
  37.               inc       cx                       ; if get here then 80 cols
  38. v42:
  39.               xor       ax,ax                    ; zero out ax
  40.               mov       al,bh                    ; active display page for CGA
  41.               shl       ax,cl                    ; calc address for display page
  42.               mov       cx,0B800h                ; address for CGA
  43.               add       ax,cx                    ; calc starting address
  44.               jmp       v44
  45. v43:
  46.               mov       ax,0B000h                ; monochrome monitor address
  47. v44:
  48.               mov       ds,ax                    ; video address into ds
  49.               les       di,[bp+6]                ; point es to char array
  50.               mov       ax,[bp+12]               ; row coordinate
  51.               mov       bx,[bp+14]               ; col coordinate
  52.               dec       ax                       ; (row - 1)
  53.               mul       dx                       ; (row - 1) * number of columns
  54.               add       ax,bx                    ; (row - 1) * # cols + col offset
  55.               dec       ax                       ; (row - 1) * # cols + col offset - 1
  56.               shl       ax,1                     ; ((row-1)* #cols + col offset - 1)*2
  57.               mov       si,ax                    ; offset in display scrn for string
  58.               mov       cx,[bp+10]               ; number of character to retrieve
  59.               cmp       cx,1
  60.               jb        v47                      ; no characters to display
  61.               mov       dx,03DAh                 ; status port
  62.               cld                                ; clear direction flag
  63.               cli                                ; clear interrupts
  64. v45:
  65.               in        al,dx                    ; get status
  66.               test      al,1                     ; is it low?
  67.               jnz       v45                      ; wait until it is
  68. v46:
  69.               in        al,dx                    ; get status
  70.               test      al,1                     ; is it high?
  71.               jz        v46                      ; wait until it is
  72.               movsw                              ; get char & attribute byte
  73.               loop      v45                      ; repeat until column is filled
  74.               sti                                ; turn interrupts back on
  75. v47:
  76.               mov       sp,bp                    ; restore stack
  77.               pop       bp                       ; restore base pointer
  78.               pop       ds                       ; restore data segment
  79.               ret       10                       ; remove parameters and return
  80. getscrn       endp
  81.