M EQU Byte Ptr 0[BX] TITLE 'MAP CLIPPED CHRACTER CELL TO BITMAP BASE ON SIZE AND ROTATION' DGROUP GROUP DATA ;****************************************************************************** ; * ; TEXTIT : Map clipped character cell to bitmap base on size and * ; rotation * ; * ;****************************************************************************** ; * ; REVISION : Dec. 21, 1983 FILE "TEXTIT.A86" Version 1.0 * ; * ;****************************************************************************** PUBLIC TEXTIT, CLIPTX EXTRN NEGHL:near EXTRN FILTER:near, GETADR:near, SBIT:near, ADDRXY:near, SETBIT:near DSEG ;;;;;; EXTRN BITMAP:word Extrn NBYT:word, NBIT:byte, XW:word EXTRN TOPY:word, BOTY:word, xmax:word EXTRN X1:word, Y1:word, X0:word, Y0:word, Y2:word EXTRN XDIR:word, YDIR:word, FLG1:word, FLG2:word EXTRN CHRPTR:word, CBUF:word, CHROFF:word, FLGS:word PUBLIC CSIZE CSIZE RS 01 ;Character Cell Size factor (1-12) cseg ;----------------------------------------------------------------------------+ ; Draw (raster scan) character cell to bitmap + ;----------------------------------------------------------------------------+ TEXTIT: ;----------------------------------------------------------------------------+ ; Get X1, Y1 + ;----------------------------------------------------------------------------+ MOV BX,Word Ptr Y1 MOV Word Ptr Y0,BX MOV BX,Word Ptr X1 ; = x MOV Word Ptr X0,BX ;----------------------------------------------------------------------------+ ; Get current byte from Character Buffer = CBUF(chrptr) + ;----------------------------------------------------------------------------+ MOV BX,Word Ptr CHRPTR ;CBUF pointer to First character row ;----------------------------------------------------------------------------+ ; For each Character, scan i-row of bytes (0-7) + ; Do i = 0, 7 + ;----------------------------------------------------------------------------+ TXTI00: MOV AL,07 ;Character Row Loop Counter (0-7) TXTI01: PUSH AX PUSH BX ;Current Character byte pointer MOV CH,M ;Get the byte from Character Buffer MOV AL,Byte Ptr CSIZE ;Get Current Size Factor ;----------------------------------------------------------------------------+ ; Repeat each row for size + ; Do i-repeat = 1, size + ;----------------------------------------------------------------------------+ TXTIR1: ;Stack Repeat Row count PUSH AX PUSH CX ;Save Current byte ;----------------------------------------------------------------------------+ ; for each byte, scan the bit pattern (j-column : 0 - 6) + ; Do j = 0, 6 + ;----------------------------------------------------------------------------+ TXTJ01: MOV AL,06 ;Column loop counter ;Stack j PUSH AX TXTJ02: MOV AL,CH ;Put Current byte in MOV CH,0 ;Setflg = 0 ROR AL,1 JNB TXTJR0 INC CH ; = Setflg, if setflg = 1, Set the bit ;----------------------------------------------------------------------------+ ; Repeat each column for size + ; Do j-repeat = 1, size + ;----------------------------------------------------------------------------+ TXTJR0: XCHG AL,AH ;Stack Current byte PUSH AX MOV AL,Byte Ptr CSIZE ;Column repeat loop count TXTJR1: ;Stack j-repeat loop count PUSH AX XOR AL,AL ;Check Setflg OR AL,CH PUSH CX ;Stack Setflg ;----------------------------------------------------------------------------+ ; If Setflg = 1, Set bit at X, Y + ;----------------------------------------------------------------------------+ JZ L@1 CALL SBIT L@1: ;----------------------------------------------------------------------------+ ; Update x,y coordinate for next pixel, based on rotation + ;----------------------------------------------------------------------------+ MOV AL,Byte Ptr FLGS ROR AL,1 JNB TXTJR2 ; Rotation = 0,180 : Move y-coord. to next pixel CALL MOVEY JMPS TXTJR3 ; Rotation = 90, 270 : move x-coord. to next pixel TXTJR2: CALL MOVEX TXTJR3: POP CX ;Unstack Setflg POP AX ;Unstack j-repeat count DEC AL ;Decrement J-repeat count JNZ TXTJR1 ; Done one bit, Repeat until all bits in i-row (current byte) mapped POP CX ;Unstack current byte POP AX ;Unstack column loop count j DEC AL JS TXTJ09 ;Stack j PUSH AX JMPS TXTJ02 ;----------------------------------------------------------------------------+ ; Update x,y coord. for next row of pixels + ;----------------------------------------------------------------------------+ TXTJ09: MOV AL,Byte Ptr FLGS ;Check chgxy flag ROR AL,1 ;carry set = 0, 180 rotation JNB TXTIR2 ; 0, 180 rotation, Move x-coord. for next row of pixels CALL MOVEX ; Reset y-coord. to beginning of row MOV BX,Word Ptr Y1 MOV Word Ptr Y0,BX JMPS TXTIR3 ; 90, 270 rotation, Move y-corrd. for next row of pixels TXTIR2: CALL MOVEY ; Reset x-coord. to beginning of row MOV BX,Word Ptr X1 MOV Word Ptr X0,BX ; Done one row, repeat same row for size TXTIR3: POP CX ;Unstack current byte POP AX ;Unstack i-repeat count DEC AL JZ L@2 JMP TXTIR1 L@2: ;----------------------------------------------------------------------------+ ; Repeat until all bytes in character cell mapped + ;----------------------------------------------------------------------------+ POP DX ;Unstack current byte address pointer POP AX ;Unstack i loop count DEC AL ;Done ? JS TXTI09 ;----------------------------------------------------------------------------+ ; Get next byte from Chracter Buffer + ;----------------------------------------------------------------------------+ XCHG BX,DX ;Next row (byte) address pointer INC BX JMP TXTI01 TXTI09: RET EJECT ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ; ; MOVEX : MOVE X-COORD. IN THE DIRECTION OF XDIR ; ; ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; Movex (xdir,nbyt,nbit) ; ; ; ; Function : Move x coordinate pixel by +-1 ; ; ; ; Input : ; ; X - X coordinate ; ; XDIR - Direction of move (-1, +1) ; ; ; ; Output : ; ; NEWX - Newx = x +/- xdir ; ; ; ; Calls : NEGHL - Complement HL register pair ; ; ABSHL - Absolute HL ; ; ; ;----------------------------------------------------------------------------; ; ; CALL MOVEX ; X0 Passed in memory ; RET ; Updated X stored in memory ; MOVEX: ; Get Xdir, X MOV BX,Word Ptr X0 ; Check XDIR the move direction flag MOV AL,Byte Ptr XDIR AND AL,AL JS MOVX01 ;Xdir = -1,Decrement X ; If Xdir = 1 then X = X + 1 ;X = X + 1 INC BX JMPS MOVX02 ; else Xdir = -1 MOVX01: ;X = X - 1 DEC BX MOVX02: MOV Word Ptr X0,BX ;Store NEWX RET ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ; ; MOVEY : MOVE Y IN THE DIRECTION OF YDIR ; ; ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; Movey (Ydir, Y) ; ; ; ; Function : Move y coordinate pixel by +-1 ; ; ; ; Input : ; ; Y - Y Coordinate (byte position : y coordinate) ; ; YDIR - Direction of move (-1, 0 +1) ; ; ; ; Output : ; ; NEWY - New Y Coordinate ; ; ; ; Calls : NEGHL - Complement HL register pair ; ; ; ;----------------------------------------------------------------------------; ; CALL MOVEY ; ydir, y passed in memory ; RET ; newy Stored MOVEY: ; Get ydir, y0 MOV BX,Word Ptr Y0 ; Check YDIR : the move direction flag MOV AL,Byte Ptr YDIR AND AL,AL JS MOVY01 ; If Ydir = 1 then Y = Y + 1 ;Y = Y + 1 INC BX JMPS MOVY02 ; else Xdir = -1 MOVY01: ;Y = Y - 1 DEC BX MOVY02: MOV Word Ptr Y0,BX ;Store NEWY RET ; **************************************************************************** ; * * ; * CLIPTX : Filter the Chracter Cell to the current Plot Strip edge * ; * * ; **************************************************************************** ; * ; Revision : JAN. 05, 1983 File "CLIPTX.A86" * ; * ; Clipit ( y1, y2, Flag, topy, boty) * ; * ; Function : * ; * ; Clip the endpoints of a line to the current Plot Strip window * ; * ; Input : * ; * ; TOPY, BOTY : Y Coord. of the Top and Bottom edges of current Strip * ; X1, Y1 : The endpoints of the Cell to be clipped * ; * ; Output : * ; * ; ZERO Set : Flag indicating that the Cell lies entirely * ; outside of the plot strip window (REJECTED) * ; * ; Process : * ; * ; FILTER (y1,flag1) ;Determine the position of the first end point * ; FILTER (y2,flag2) ;and the second point relative to the edges * ; * ; REJECT (flag1,flag2) ;Test to see if the Char can be trivially * ; rejected * ; if not rejected * ; ACCEPT (flag1,flag2) ;Test to see if the Char can be trivially * ; accepted * ; * ; FILTER returns * ; position flag bit 2 | 1 | * ; ------------ * ; point above 1 | 0 | * ; ------------ top y edge of strip * ; point inside 0 | 0 | * ; ------------ bottom y edge of strip * ; point below 0 | 1 | * ; * ;----------------------------------------------------------------------------* ; CALL CLIPTX ; Y1, Y2 TOPY,BOTY passed in meory ; RET ; Carry = on, Cell inside strip ; = off,Cell rejected (lies outside window) ;----------------------------------------------------------------------------- ; PUBLIC CLIPTX ; EXTRN NEGHL ; EXTRN TOPY, BOTY, FILTER ; EXTRN FLGS, X1, Y1, Y2, YSTRT, XDIR, YDIR ; EXTRN I0, I7, J0, J7, LOOP0, LOOP7 ; EXTRN FLG1, FLG2 ; Filter y-coordinate of the first endpoint y1 against strip CLIPTX: mov bx, word ptr X1 or bh, bh js ctxj99 cmp bx, word ptr xmax jg ctxj99 MOV BX,Word Ptr Y1 CALL FILTER ;Returns position flag flg1 MOV AL,CH ;flg1 : 0 = boty < y1 < topy MOV Byte Ptr FLG1,AL ; >0 = y1 above or below strip ; Filter second endpoint MOV BX,Word Ptr Y2 CALL FILTER ;flg2 : 0 = boty < y2 < topy MOV AL,CH ; >0 = y2 above or below strip MOV Byte Ptr FLG2,AL ; Test : Cell lies entirely outside strip & can be trivially rejected ? MOV AL,Byte Ptr FLG1 ;reject line if (fg1 .and. flg2) NOT= 0 AND AL,CH ; = flg2, = flg1 ; TRIVIALLY REJECT CHARACTER CELL IF RESULT NOT ZERO JNZ CTXJ99 ;Zero flag off indicating line rejected OR AL,AL ;Clear carry flag : charcter not rejected CTXJ09: RET ;Carry off : indicating Cell not rejected CTXJ99: STC RET END