home *** CD-ROM | disk | FTP | other *** search
- ;--------------------------------------------------------------------
- ; Author : Kevin Dahl :
- ; Last Revised : June 7, 1986 :
- ; :
- ; FILENAME - V3.ENH :
- ; :
- ; COLORMSG :
- ; This routine displays any string to the display screen. :
- ; ENTRY :
- ; [bp+6] = Length of string :
- ; [bp+7] = Starting address of string to be displayed :
- ; [bp+262] = Color to use for the attribute byte :
- ; [bp+264] = Row the string is to be displayed on :
- ; [bp+266] = Column the string is to start in :
- ; :
- ; EXIT :
- ; Nothing is returned :
- ;--------------------------------------------------------------------
- colormsg proc near
- push ds
- push bp ; save stack
- mov bp,sp
- mov ah,0fh ; get current video mode
- int 10h ; using BIOS services
- xor dx,dx
- mov dl,ah ; save number columns per line
- cmp al,7 ; check for monochrome monitor
- je v4
- cmp al,3 ; check if text modes
- ja v8 ; graphics mode - no write
- mov cx,7 ; set for 40 col text modes
- cmp dl,80 ; check for num of cols
- jb v3 ; 40 cols if jmp
- inc cx ; if get here then 80 cols
- v3:
- xor ax,ax ; zero out ax
- mov al,bh ; active display page for CGA
- shl ax,cl ; calc address for display page
- mov cx,0B800h ; address for CGA
- add ax,cx ; calc address to display string
- jmp v5
- v4:
- mov ax,0B000h ; monochrome monitor address
- v5:
- mov es,ax ; video address into es
- mov ax,[bp+264] ; row coordinate
- mov bx,[bp+266] ; col coordinate
- dec ax ; (row - 1)
- mul dx ; (row - 1) * number of columns
- add ax,bx ; (row - 1) * # cols + col offset
- dec ax ; (row - 1) * # cols + col offset - 1
- shl ax,1 ; ((row-1)* #cols + col offset - 1)*2
- mov di,ax ; offset in display scrn for string
-
- mov cx,[bp+6] ; length of string
- xor ch,ch ; remove first character from ch
- cmp cx,1
- jb v8 ; no string to display
- mov ax,bp ; address of base page into ax
- add ax,7 ; calc offset of string in stack
- mov si,ax ; move offset of string into si
- mov ax,ss
- mov ds,ax ; stack segment into data segment
- mov bl,[bp+262] ; attribute byte into bl
- mov dx,03DAh ; status port
- cld ; clear direction flag
- cli ; clear interrupts
- v6:
- in al,dx ; get status
- test al,1 ; is it low?
- jnz v6 ; wait until it is
- v7:
- in al,dx ; get status
- test al,1 ; is it high?
- jz v7 ; wait until it is
- movsb ; display character
- mov es:byte ptr[di],bl ; display attribute byte
- inc di ; skip attribute byte
- loop v6 ; repeat until all characters displayed
- sti ; turn interrupts back on
- v8:
- mov sp,bp ; restore stack
- pop bp ; restore base pointer
- pop ds ; restore data segment
- ret 262 ; remove parameters and return
- colormsg endp
-