M EQU Byte Ptr 0[BX] TITLE 'Output Text to Printer Bit Map' DGROUP GROUP DATA ;***************************************************************************** ; * ; DOTEXTC : Clip the Text String to the Current Printer Plot Strip and * ; Output the Character to the Printer BITMAP based on current * ; Character Size and Rotation * ; * ;***************************************************************************** ; * ; REVISION : Nov. 07, 1983 FILE "DOTEXTC.A86" Version 1.0 * ; * ;***** MODE NOTES : ********************************************************* ; Nov-14-82 * ; 1) Character Height (CHRHT) = NDTXSZ * 8 pixels * ; 2) Character width (CHRSZ) = NDTXSZ * 6 pixels * ; May-04-83 : Add Writing mode support * ; Nov-07-82 : Color Support * ;***** MODE NOTES : ********************************************************* ; * ; Input : * ; OBJLST - Object List Buffer Contains : * ; byte 1 : Opcode * ; 2 : Nchr * ; 3 : Rotation Flag * ; 4,5 : X * ; 6,7 : Y * ; 8... : Character String, 1 Char. / Byte * ; * ; x,y - starting point for text string * ; nchr - No. of characters in text string * ; chrstr - text string (in ADE) * ; ndtxsz - scale factor for character size (1-16) * ; ndtxrt - text rotation * ; 0 = no rotation 1 = 90 degrees * ; 2 = 180 degrees 3 = 270 degrees * ; * ; CBUF - ASCII CHARACTER BUFFER 32 - 127 * ; * ; Program Variables : * ; * ; OBJLST - Object List Buffer * ; NXTOBJ - Next OBJLST Buffer location pointer * ; * ; FLGS - Character Rotation Indicator * ; BIT 1=CHGXY, 2=CUP, 3=ROWINC, 4=COLINC * ; CHGXY = Change row, column flag due to character rotation * ; CUP = Character up flag, 90, 180 rotation * ; ROWINC= row increment flag, +/- 1 * ; COLINC= column increment flag * ; * ; FLGS - +-----------------------------+ * ; | rotate | 0 | 90 | 180 | 270 | * ; +--------+---+----+-----+-----+ * ; | chgxy | 1 | 0 | 1 | 0 | * ; +--------+---+----+-----+-----+ * ; | cup | 0 | 1 | 1 | 0 | * ; +--------+---+----+-----+-----+ * ; | rowinc | 1 | 1 | -1 | -1 | * ; +--------+---+----+-----+-----+ * ; | colinc |-1 | 1 | 1 | -1 | * ; +--------+---+----+-----+-----+ * ; * ; Calls : * ; GETXY : Get X,Y (4 bytes) from OBJLST * ; GETPT : Get Coordinate from OBJLST (2 bytes) * ; GETNXT : Get next byte from OBJLST buffer * ; MUL8 : = * 8 * ; CLIPTX : Clip a Chracter cell (8*size) to the current PLot Strip * ; based on rotation * ; TEXTIT : Output a Character to the BITMAP buffer * ; * ;***************************************************************************** PUBLIC DOTEXT EXTRN GETXY:near, GETNXT:near EXTRN CLIPTX:near, TEXTIT:near, ZSETCOR:near EXTRN MUL8:near, NEGHL:near dseg EXTRN CBUF:word EXTRN NDTXSZ:byte, CHRSZ:byte, CHRHT:byte, CSIZE:word EXTRN NBYT:word, NBIT:byte, NDTXCO:byte, COLOR:byte EXTRN X1:word, Y1:word, Y2:word, XDIR:word, YDIR:word extrn xmax:word extrn rflgt:byte, bmaskt:byte, ritflg:byte, bitmask:byte PUBLIC FLGS, CHROFF, CHRPTR, CCLIP FLGS RS 01 ;Character Rotation flag CCLIP DB 00 CHRPTR RS 02 ;Character Buffer byte pointer CHRSIZ RS 02 ;Chracter Size = 8 * Text size (ndtxsz) CHROFF RS 02 ;Offset to next character position based ;on character size and rotation YSTRT RS 02 ;Character y-coord. after clipping CSEG ;----------------------------------------------------------------------------+ ; Get NCHR, no. of characters + ;----------------------------------------------------------------------------+ DOTEXT: ; rflgt and bmaskt is set by the set color and set writing mode routines mov al,rflgt ; setbit routine uses ritflg to decide mov ritflg,al ; whether to OR, AND or to XOR the bit in mov al,bmaskt ; the bitmap with the bitmask to produce mov bitmask,al ; the new data bit mov bl, Byte Ptr NDTXCO mov Byte Ptr color, bl Call ZSETCOR ; Set up Color Parameter for TEXT CALL GETNXT ;Returns = Nchr ; STA NCHR ;Save no. of characters : nchr ;Stack it for loop counter PUSH AX ; Rotation Flags : bit 1=chgxy, 2=cup ; 0, 180 : chgxy = 1, 90, 270 : chgxy = 0 ; 0, 270 : cup = 0, 90, 180 : cup = 1 CALL GETNXT ;Returns = FLGS MOV Byte Ptr FLGS,AL ; Set up Size factor for Character Raster Routine XOR AL,AL MOV AL,Byte Ptr NDTXSZ MOV Byte Ptr CSIZE,AL ;----------------------------------------------------------------------------+ ; Get x1, y1 from OBJLST + ;----------------------------------------------------------------------------+ CALL GETXY ;Returns = x1, = y1 ;;;; XCHG BX,DX ;;;; MOV Word Ptr X1,BX ;;;; MOV BH,CH ;;;; MOV BL,CL mov word ptr x1, dx MOV Word Ptr Y1, cx MOV Word Ptr YSTRT, cx ; Set row, column direction flag for clipping MOV AL,Byte Ptr FLGS ;Check chgxy flag ROR AL,1 JB TXTJ04 ; 90, 270 rotation, xdir = +/- 1 column, ydir = +/- 1 row MOV AL,Byte Ptr FLGS ;bit 3 = row increment indicator AND AL,04H MOV AL,1 JNZ TXTJ05 ;row increment = 1 or -1 MOV AL,0FFH TXTJ05: MOV Byte Ptr YDIR,AL MOV AL,Byte Ptr FLGS ;bit 4 = column increment indicator AND AL,08H MOV AL,1 JNZ TXTJ06 MOV AL,0FFH TXTJ06: MOV Byte Ptr XDIR,AL JMPS TXTL01 ; 0, 180 Rotation, xdir = +/- 1 row, ydir = +/- 1 column TXTJ04: MOV AL,Byte Ptr FLGS AND AL,04H ;bit 3 = row increment MOV AL,1 JNZ TXTJ07 MOV AL,0FFH TXTJ07: MOV Byte Ptr XDIR,AL MOV AL,Byte Ptr FLGS AND AL,08H ;bit 4 = column increment MOV AL,1 JNZ TXTJ08 MOV AL,0FFH TXTJ08: MOV Byte Ptr YDIR,AL ;----------------------------------------------------------------------------+ ; Do k = 1, nchr + ;----------------------------------------------------------------------------+ TXTL01: POP AX ;Unstack character count DEC AL JNS L@1 JMP TXT099 ;Done ? L@1: PUSH AX ;----------------------------------------------------------------------------+ ; Get next character from OBJLST + ;----------------------------------------------------------------------------+ CALL GETNXT ;Returns Character in ; Valid Ascii ? SUB AL,01BH ;Lower bound JS txtL09 ;Invalid character CMP AL,065H ;Upper bound JNS txtL09 ;Invalid ascii character ; Get Character Buffer byte address = K * 8 + CBUF MOV BL,AL MOV BH,0 CALL MUL8 ;8 bytes per Character in CBUF MOV DX,(Offset CBUF) ;Character buffer base address ADD BX,DX MOV Word Ptr CHRPTR,BX ;Pointer to the 8 bytes character cell ;in CBUF ;----------------------------------------------------------------------------+ ; Clip Character cell based on Chracter rotaion and size + ;----------------------------------------------------------------------------+ ; Character Width Computed using Current text size : NDTXSZ * 6 ; Character Height Computed using NDTXSZ * 8 ; Get Y2, Character cell height extent : y1 to y2 ; If cup y2 = y1 + chrht (90, 180) ; else y2 = y1 - chrht (0, 270) txtj60: MOV BX,Word Ptr CHRSZ ;CHRSZ = 6 * NDTXSZ MOV AL,Byte Ptr FLGS ;Cup = flag bit # 2 AND AL,02H JNZ TXTJ02 ;Cup = 1, rotate = 90, 180 ; 0, 270 rotation CALL NEGHL MOV Word Ptr CHROFF,BX ;Offset to next character position MOV BX,Word Ptr CHRHT ;Character Height in Pixels CALL NEGHL INC BX JMPS TXTJ03 ; 90, 180 rotation TXTJ02: MOV Word Ptr CHROFF,BX MOV BX,Word Ptr CHRHT DEC BX TXTJ03: mov dx, word ptr y1 ADD BX,DX OR BH, BH JNS TXTJ50 MOV BX, 0 TXTJ50: MOV Word Ptr Y2,BX ;Y2 = Y1 +/- CHRHT +/- 1 ; Clip character to Current PLot Strip CALL CLIPTX ;----------------------------------------------------------------------------+ ; If Carry flag set, Trivial reject : Character outside current Strip + ;----------------------------------------------------------------------------+ TXTJ01: JNAE L@2 CALL TEXTIT ;Output the Character byte to BITMAP L@2: ;----------------------------------------------------------------------------+ ; Update x,y to next character position + ;----------------------------------------------------------------------------+ TXTL09: MOV BX,Word Ptr CHROFF ;Position offset based on size and rotation XCHG BX,DX MOV AL,Byte Ptr FLGS ;Check rotation flag ROR AL,1 JB TXTJ10 ; 90, 270 rotation MOV BX,Word Ptr X1 ADD BX,DX ; = Next character x-coord. MOV Word Ptr X1,BX XOR AL,AL MOV Byte Ptr CCLIP,AL ;Next character needs not be clipped, ;because y-coord. not changed JMP TXTL01 ; 0, 180 rotation : y = y +/- chroff TXTJ10: MOV BX,Word Ptr Y1 ADD BX,DX ; = next character y-coord. MOV Word Ptr Y1,BX MOV AL,01 MOV Byte Ptr CCLIP,AL ;Set Clip character flag ;because y-coord. changed for next character JMP TXTL01 TXT099: RET END