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

  1. ;--------------------------------------------------------------------
  2. ; Author       : Kevin Dahl                                         :
  3. ; Last Revised : June 7, 1986                                       :
  4. ;                                                                   :
  5. ; FILENAME - V3.ENH                                                 :
  6. ;                                                                   :
  7. ; COLORMSG                                                          :
  8. ;        This routine displays any string to the display screen.    :
  9. ; ENTRY                                                             :
  10. ;        [bp+6]   = Length of string                                :
  11. ;        [bp+7]   = Starting address of string to be displayed      :
  12. ;        [bp+262] = Color to use for the attribute byte             :
  13. ;        [bp+264] = Row the string is to be displayed on            :
  14. ;        [bp+266] = Column the string is to start in                :
  15. ;                                                                   :
  16. ; EXIT                                                              :
  17. ;        Nothing is returned                                        :
  18. ;--------------------------------------------------------------------
  19. colormsg      proc      near
  20.               push      ds
  21.               push      bp                       ; save stack
  22.               mov       bp,sp
  23.               mov       ah,0fh                   ; get current video mode
  24.               int       10h                      ; using BIOS services
  25.               xor       dx,dx
  26.               mov       dl,ah                    ; save number columns per line
  27.               cmp       al,7                     ; check for monochrome monitor
  28.               je        v4
  29.               cmp       al,3                     ; check if text modes
  30.               ja        v8                       ; graphics mode - no write
  31.               mov       cx,7                     ; set for 40 col text modes
  32.               cmp       dl,80                    ; check for num of cols
  33.               jb        v3                       ; 40 cols if jmp
  34.               inc       cx                       ; if get here then 80 cols
  35. v3:
  36.               xor       ax,ax                    ; zero out ax
  37.               mov       al,bh                    ; active display page for CGA
  38.               shl       ax,cl                    ; calc address for display page
  39.               mov       cx,0B800h                ; address for CGA
  40.               add       ax,cx                    ; calc address to display string
  41.               jmp       v5
  42. v4:
  43.               mov       ax,0B000h                ; monochrome monitor address
  44. v5:
  45.               mov       es,ax                    ; video address into es
  46.               mov       ax,[bp+264]              ; row coordinate
  47.               mov       bx,[bp+266]              ; col coordinate
  48.               dec       ax                       ; (row - 1)
  49.               mul       dx                       ; (row - 1) * number of columns
  50.               add       ax,bx                    ; (row - 1) * # cols + col offset
  51.               dec       ax                       ; (row - 1) * # cols + col offset - 1
  52.               shl       ax,1                     ; ((row-1)* #cols + col offset - 1)*2
  53.               mov       di,ax                    ; offset in display scrn for string
  54.  
  55.               mov       cx,[bp+6]                ; length of string
  56.               xor       ch,ch                    ; remove first character from ch
  57.               cmp       cx,1
  58.               jb        v8                       ; no string to display
  59.               mov       ax,bp                    ; address of base page into ax
  60.               add       ax,7                     ; calc offset of string in stack
  61.               mov       si,ax                    ; move offset of string into si
  62.               mov       ax,ss
  63.               mov       ds,ax                    ; stack segment into data segment
  64.               mov       bl,[bp+262]              ; attribute byte into bl
  65.               mov       dx,03DAh                 ; status port
  66.               cld                                ; clear direction flag
  67.               cli                                ; clear interrupts
  68. v6:
  69.               in        al,dx                    ; get status
  70.               test      al,1                     ; is it low?
  71.               jnz       v6                       ; wait until it is
  72. v7:
  73.               in        al,dx                    ; get status
  74.               test      al,1                     ; is it high?
  75.               jz        v7                       ; wait until it is
  76.               movsb                              ; display character
  77.               mov       es:byte ptr[di],bl       ; display attribute byte
  78.               inc       di                       ; skip attribute byte
  79.               loop      v6                       ; repeat until all characters displayed
  80.               sti                                ; turn interrupts back on
  81. v8:
  82.               mov       sp,bp                    ; restore stack
  83.               pop       bp                       ; restore base pointer
  84.               pop       ds                       ; restore data segment
  85.               ret       262                      ; remove parameters and return
  86. colormsg      endp
  87.  
  88.