home *** CD-ROM | disk | FTP | other *** search
- code segment byte public
- assume cs:code
- public gtxtsol
- page 60,132
- ; val val val val VAR VAR
- ; procedure gtxtsol(gdx,gdy,color,fontlines,fontbase,instring);
-
- gdx equ [BP+22]
- gdy equ [BP+20]
- backgnd equ [BP+18]
- color equ [BP+16]
- fontlines equ [BP+14]
- fontbase equ [BP+10]
- instring equ [BP+6]
-
- gtxtsol proc far
-
- push bp
- mov bp,sp
- push ds
- ;
- ; Calculate byte address (segment & offset) and bit mask
-
- ;
- mov dx,040h ; bios data segment
- mov ds,dx
- mov si,062h
- mov al,[si] ; get active display page
-
- mov dx,0A000h ; base page of EGA/VGA memory
- ;
- or al,al ; set flags
- jz page0 ; if zero, skip ofset add
- add dh,8 ; ofset to second page base of A800h
-
- page0:
- mov ds,dx ; DS := EGA buffer segment address
- mov dx,3C4h ; Sequencer/Map Mode port address
- mov al,2
- out dx,al ; Select "Map Mask" register 2
- ; this is the only SEQ register we'll be using
- mov dx,3CEh
- mov al,8 ; point to graphics controller register
- out dx,al ; this is the only GR.Cont. register we'll use
-
-
- mov ax,gdx ; get X address from stack frame
- shr ax,1
- shr ax,1
- shr ax,1 ; compute memory address ofset AX := x/8
- mov gdx,ax ; save back on stack
- ;
- ;
- les SI,instring ; get doubleword base address of string
- xor ch,ch ; clear ch
- mov cl,byte ptr ES:[si] ; points to length of string
-
- ; loop for the number of characters in the string
-
- strloop: ; loop for number of characters in string
- push CX ; save string count for outer loop
- inc SI ; make si point to nextchar
- ;
- mov bl,byte ptr ES:[SI] ; SI points to next char - read into bx
- inc bl ; move to next char: we work from bottom to top
- mov ax,fontlines ; get number of lines/char in font
- mov cx,ax ; keep for use as loop counter
- mul bl ; ax := bl (character) * al (bytes/char)
- mov bx,ax ; leave font character ofset in BX
- ;
- push ES ; save char seg.
- push SI ; save char pointer
- ;
- ;
- charloop: ; loop through the font's scanlines bottom to top
- ;
- mov ax,gdy ; get Y address (a pixel row) from stack frame
- add ax,cx ; add scanline ofset to pixel row
- dec ax ; compensate for 1-based numbering on CX scanlines
- mov dx,80d
- mul dx ; AX := (y * 80) (80 bytes per row)
- ; AX now contains Y base address (y * 80)
- add ax,gdx ; AX := (y * 80) + x/8 (offset)
-
- mov di,ax ; save EGA memory ofset in DI
-
- dec bx ; move to next scanline in font
-
- les SI,fontbase ; get dblword base address of font
-
- ; clear all bit planes first
- ;
- mov dx,3C5h
- mov ax,0Fh ; AL := map mask (enable all bit planes here)
- out dx,al ; Load the map mask into Seq Map Mode reg 2.
-
- mov al,0
- mov [di],al ; clear all planes
-
- ; Set bits in the appropriate bit planes to '1' for background
- ;
- mov ax,backgnd ; AL := map mask (i.e., backgnd color value)
- or al,al ; set flags
- jz backOK ; skip the background write if black
-
- out dx,al ; Load the map mask into SMM reg 2.
- ; This enables the appropriate bit planes.
-
- mov al,ES:[BX][SI] ;get bit mask byte from font
- not al ; only set bits which are _not_ set in font
- mov [di],al ; Set bits to '1' in appropriate planes. for bkgnd
-
- ; now check to see if there are any common bit planes between the foreground
- ; and background. If there are, we have to use the graphics controller's
- ; bitmap register to "insert" the font. If not, skip this stuff and write
- ; faster!
-
- mov ax,color
- out dx,al ; write to mask register
- and ax,backgnd
- jz backOK ; if no bit planes in common, then skip around
-
- mov dx,3CFh
- mov al,ES:[BX][SI] ; get bit mask byte from font
- out dx,al ; write to bitmask register
-
- mov al,[di] ; read into bitplane latches
- mov al,0FFh
- mov [di],al ; write to bitplanes with bitmask
-
- jmp endchar
- ;
- ;
- backOK: ; now do actual foreground color
- mov ax,color ; AL := map mask (i.e., pixel color value)
- out dx,al ; Load the map mask into SMM reg 2.
- ; This enables the appropriate bit planes.
-
- mov al,ES:[BX][SI] ; get bit mask byte from font
- mov [di],al ; Set bits to '1' in appropriate planes.
-
-
- endchar:
-
-
- loop charloop ; decrement cx and do next scanline
-
- ;
- pop SI ; pop character pointer
- pop ES ; " " segement
- inc word ptr gdx ; move screen position 8 pixels, to next char
-
- pop CX ; get outer loop - counting chars in string
- loop strloop
-
- ; Restore default EGA graphics status
- mov dx,3C4h
- mov al,2 ; Again, select ...
- out dx,al ; ... Sequencer/Map Mask register 2.
-
- mov dx,3C5h
- mov al,0Fh ; Default map mask
- out dx,al ; Enable all 4 bit planes
-
- mov dx,3CEh
- mov al,8 ; Again, select ...
- out dx,al ; ... Graphics Controller register 8
-
- mov dx,3CFh
- mov al,0FFh ; Default bit mask
- out dx,al ; Restore default bit mask
-
- pop ds
- pop bp
- ret 18d
- gtxtsol endp
-
- code ends
-
- end