home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TUR6_101.ZIP / V21.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-06-07  |  8.0 KB  |  162 lines

  1. ;--------------------------------------------------------------------
  2. ; Author       : Kevin Dahl                                         :
  3. ; Last Revised : June 7, 1986                                       :
  4. ;                                                                   :
  5. ; FILENAME - V21.ENH                                                :
  6. ;                                                                   :
  7. ; WAITMSG                                                           :
  8. ;        This routine displays a message on the screen and will     :
  9. ;        wait until the specified key is pressed before returning.  :
  10. ; ENTRY                                                             :
  11. ;        [bp+10   = Set of terminating characters                   :
  12. ;        [bp+42]  = Length of string to be displayed                :
  13. ;        [bp+43]  = First character of string to be displayed       :
  14. ;        [bp+298] = Row the string is to be displayed on            :
  15. ;        [bp+300] = Column the string is to start in                :
  16. ;                                                                   :
  17. ; EXIT                                                              :
  18. ;        [bp+6]   = Terminating character (3 bytes)                 :
  19. ;--------------------------------------------------------------------
  20. waitmsg       proc      near
  21.               push      ds
  22.               push      bp                       ; save stack
  23.               mov       bp,sp
  24.               mov       ah,0fh                   ; get current video mode
  25.               int       10h                      ; using BIOS services
  26.               xor       dx,dx
  27.               mov       dl,ah                    ; save number columns per line
  28.               cmp       al,7                     ; check for monochrome monitor
  29.               je        v77
  30.               cmp       al,3                     ; check if text modes
  31.               ja        v81                      ; graphics mode - no write
  32.               mov       cx,7                     ; set for 40 col text modes
  33.               cmp       dl,80                    ; check for num of cols
  34.               jb        v76                      ; 40 cols if jmp
  35.               inc       cx                       ; if get here then 80 cols
  36. v76:
  37.               xor       ax,ax                    ; zero out ax
  38.               mov       al,bh                    ; active display page for CGA
  39.               shl       ax,cl                    ; calc address for display page
  40.               mov       cx,0B800h                ; address for CGA
  41.               add       ax,cx                    ; calc address to display string
  42.               jmp       v78
  43. v77:
  44.               mov       ax,0B000h                ; monochrome monitor address
  45. v78:
  46.               mov       es,ax                    ; video address into es
  47.               mov       ax,[bp+298]              ; row coordinate
  48.               mov       bx,[bp+300]              ; col coordinate
  49.               dec       ax                       ; (row - 1)
  50.               mul       dx                       ; (row - 1) * number of columns
  51.               add       ax,bx                    ; (row - 1) * # cols + col offset
  52.               dec       ax                       ; (row - 1) * # cols + col offset - 1
  53.               shl       ax,1                     ; ((row-1)* #cols + col offset - 1)*2
  54.               mov       di,ax                    ; offset in display scrn for string
  55.  
  56.               mov       cl,[bp+42]               ; length of string
  57.               xor       ch,ch                    ; zero out ch
  58.               cmp       cx,1
  59.               jb        v81                      ; no string to display
  60.               mov       ax,bp                    ; address of base page into ax
  61.               add       ax,43                    ; calc offset of string in stack
  62.               mov       si,ax                    ; move offset of string into si
  63.               mov       ax,ss
  64.               mov       ds,ax                    ; stack segment into data segment
  65.               mov       dx,03DAh                 ; status port
  66.               cld                                ; clear direction flag
  67.               cli                                ; clear interrupts
  68. v79:
  69.               in        al,dx                    ; get status
  70.               test      al,1                     ; is it low?
  71.               jnz       v79                      ; wait until it is
  72. v80:
  73.               in        al,dx                    ; get status
  74.               test      al,1                     ; is it high?
  75.               jz        v80                      ; wait until it is
  76.               movsb                              ; display character
  77.               inc       di                       ; skip attribute byte
  78.               loop      v79                      ; repeat until all characters displayed
  79.               sti                                ; turn interrupts back on
  80. v81:
  81.               mov       ah,0                     ; read keyboard char
  82.               int       16h                      ; using BIOS serives
  83.  
  84.               cmp       ax,011Bh                 ; esc pressed?
  85.               je        v82
  86.  
  87.               cmp       ax,0E7Fh                 ; ctrl-BS pressed?
  88.               je        v82
  89.  
  90.               cmp       al,0                     ; alt & other key comb?
  91.               jne       v84
  92. v82:
  93.               mov       al,ah
  94.               xor       ah,ah
  95.               jmp       v87
  96. v84:
  97.               cmp       ax,0E08h                 ; back space pressed?
  98.               je        v85
  99.  
  100.               cmp       ax,0F09h                 ; tab pressed?
  101.               je        v85
  102.  
  103.               cmp       ax,01C0Ah                ; ctrl-enter pressed?
  104.               je        v85
  105.  
  106.               cmp       ax,01C0Dh                ; Enter pressed?
  107.               jne       v86
  108. v85:
  109.               xor       ah,ah
  110.               jmp       v87
  111. v86:
  112.               xor       ah,ah
  113.               add       al,132
  114. v87:
  115.               push      ax                       ; save element number
  116.               mov       cx,8                     ; set up for division by 8
  117.               div       cl                       ;    remainder in ah
  118.                                                  ;    quotient  in al
  119.               mov       cl,ah                    ; bit number of element in byte
  120.               xor       ah,ah                    ; zero out ah
  121.               mov       di,ax                    ; byte element is in into di
  122.               xor       ax,ax                    ; zero out ax
  123.               mov       al,[bp+di+10]            ; move byte element is in into bx
  124.  
  125.               mov       bx,1                     ; set up for element check
  126.               rol       bl,cl                    ; by setting bit to check
  127.               and       al,bl                    ; is element in set?
  128.               jnz       v88                      ;    it is so exit
  129.               pop       ax                       ; element not in set so,
  130.               jmp       v81                      ; go read keyboard char
  131. v88:
  132.               pop       cx
  133.  
  134. ;
  135. ; sets up char code of element for moving into returning variable
  136. ;
  137.  
  138.               mov       ax,cx                    ; ah = ch[1] -- al = ch[2]
  139.               mov       bl,2                     ; bl = ch[0]
  140.               cmp       cx,133
  141.               jb        v89
  142.               sub       ax,132
  143.               cmp       ax,32
  144.               jb        v90
  145.               xchg      ah,al
  146.               dec       bl
  147.               jmp       v90
  148. v89:
  149.               mov       ah,27
  150. v90:
  151.               lds       di,[bp+6]
  152.               mov       [di],bl
  153.               xchg      al,ah
  154.               mov       [di+1],ax
  155.  
  156.               mov       sp,bp                    ; restore stack
  157.               pop       bp                       ; restore base pointer
  158.               pop       ds                       ; restore data segment
  159.               ret       296                      ; remove parameters and return
  160. waitmsg       endp
  161.  
  162.