M EQU Byte Ptr 0[BX] TITLE 'ZFA : FILL AREA (POLYGON)' DGROUP GROUP DATA ;***************************************************************************** ; * ; POLYGON : Increment Object Count, Update XMAX and YMAX and * ; Store Opcode, Npt, Px ,Py and Polygon Minimum, Maximum * ; extents in the Object List Buffer * ; * ;***************************************************************************** ; * ; REVISION : May 01, 1983 File : "ZFA.A86" Version 1.0 * ; * ; ZFA (npt, px, py) * ; * ; Description : * ; * ; 1) Get Opcode and Npt from Contrl array and store in OBJLST Buffer * ; * ; 2) Increment OBJCNT * ; * ; 3) Get Points from PTSIN array, Update Max/Min Plot extent XMAX,YMAX * ; * ; 4) Store the Points in OBJLST Buffer, repeat the first point to close * ; * ; 5) Store the Max/Min Polygon extents in OBJLST Buffer * ; * ; * ; Input : * ; SS:BP -> Parameter block pointers * ; ES:DI -> CONTRL(1) * ; contrl(1) - opcode = 9 * ; contrl(2) - no. of vertices in polygon (npt) * ; ptsin - array of coordinates of polygon in pixel space * ; ptsin(1,2) = x1,y1 * ; ptsin(3,4) = x2,y2 * ; . * ; . * ; ptsin(2npt-1,2npt) = x,y of last point * ; * ; Output : * ; contrl(3) - 0 * ; * ; CALL ZFA * ; ES:DI= Address of Contrl array * ; * ; Program Variables : * ; XMAX - Maximum Plot extent x-axis * ; YMAX - Maximum Plot extent y-axis * ; XPMAX - Maximum Polygon extent * ; YPMAX - Maximum Polygon extent * ; XPMIN - Minimum Polygon extent * ; YPMIN - Minimum Polygon extent * ; OBJCNT - Count of Object in the Object List Buffer * ; OBJLST - Object List Buffer * ; BNEXT - Next OBJLST Buffer location pointer * ; * ;***************************************************************************** PUBLIC ZFA EXTRN CMPDH:near,PUTPT:near, PUTBYT:near EXTRN GETMAX:near, GETMIN:near dseg EXTRN XMAX:word, YMAX:word, OBJCNT:word, OBJLST:word, BNEXT:word extrn dfill:byte CSEG ;----------------------------------------------------------------------------+ ; EQUATES FOR ARGUMENTS ADDRESSING + ;----------------------------------------------------------------------------+ CONTRL EQU Dword ptr 2 ; Control Parameter Block INTIN EQU Dword ptr 6 ; Integer Input Parameter Block PTSIN EQU Dword ptr 10 ; Point Coordinates Input Array INTOUT EQU Dword ptr 14 ; Integer output Parameter Block PTSOUT EQU Dword ptr 18 ; Point Coordinates Output Array ;----------------------------------------------------------------------------+ ; Define Word Displacements to Successive Entries in a Word Array + ;----------------------------------------------------------------------------+ W_1 EQU Word ptr 0 W_2 EQU Word ptr 2 W_3 EQU Word ptr 4 W_4 EQU Word ptr 6 W_5 EQU Word ptr 8 W_6 EQU Word ptr 10 W_7 EQU Word ptr 12 W_8 EQU Word ptr 14 W_9 EQU Word ptr 16 W_10 EQU Word ptr 18 ;----------------------------------------------------------------------------+ ; Increment OBJCNT + ; Store Opcode and Npt in OBJLST + ;----------------------------------------------------------------------------+ ZFA: ; draw flag dfill is set by set color routine zfico ; if color = 0 and mode is not replace then drawing this object = nop ; so, no data is stored in the object list buffer for this object cmp dfill, 0 jne zfdo ; do nothing if draw flag = 0 ret zfdo: mov ypmax, 0 mov xpmax, 0 mov ypmin, 07fffh mov xpmin, 07fffh INC Word Ptr OBJCNT ;Increment OBJCNT ; Get Opcode, CONTRL = Address of Contrl array MOV AX,ES:W_1[DI] ; = Opcode CALL PUTBYT MOV AX,ES:W_2[DI] ; = Npt MOV Byte Ptr NPT,AL CALL PUTBYT ;----------------------------------------------------------------------------+ ; Get the vertices from PTSIN array + ; Update Maximum/Minimum extents and store the points in OBJLST + ;----------------------------------------------------------------------------+ ; Get the Address of PTSIN array ; = No. of points in PTSIN LES DI, PTSIN[BP] MOV Byte Ptr IST,0 MOV AL,Byte Ptr NPT ZFAL01: ;Save Npt on stack PUSH AX MOV DX,ES:W_1[DI] ADD DI,2 ; = X-coord. CMP Byte Ptr IST,0 JNZ ZFAJ10 MOV Word Ptr XP0,DX ZFAJ10: CMP DX,Word Ptr XMAX JLE ZFAJ01 MOV Word Ptr XMAX,DX ZFAJ01: CMP DX,Word Ptr XPMAX ;Maximum Polygon X extent JLE ZFAJ02 MOV Word Ptr XPMAX,DX ;XPMAX = new X-coord. ZFAJ02: CMP DX,Word Ptr XPMIN ;Minimum Polygon X extent JGE ZFAJ03 MOV Word Ptr XPMIN,DX ;XPMIN = new X-coord. ZFAJ03: CALL PUTPT ;Store x-coord. into OBJLST ; = Y-coord. MOV DX,ES:W_1[DI] ADD DI,2 CMP Byte Ptr IST,0 JNZ ZFAJ11 INC Byte Ptr IST MOV Word Ptr YP0,DX ZFAJ11: CMP DX,Word Ptr YMAX JLE ZFAJ04 MOV Word Ptr YMAX,DX ;YMAX = Y-coord. ZFAJ04: CMP DX,Word Ptr YPMAX ;Maximum Polygon Y extent JLE ZFAJ05 MOV Word Ptr YPMAX,DX ;YPMAX = new Y-coord. ZFAJ05: CMP DX,Word Ptr YPMIN ;Minimum Polygon Y extent JGE ZFAJ06 MOV Word Ptr YPMIN,DX ;YPMIN = new Y-coord. ZFAJ06: CALL PUTPT ;Store y-coord. into OBJLST POP AX DEC AL JZ L@1 JMP ZFAL01 ;There are more points in PTSIN L@1: ; Store the First point into the Polygon Point list, so the ; draw line routine will close the polygon outline MOV DX,Word Ptr XP0 CALL PUTPT MOV DX,Word Ptr YP0 CALL PUTPT ; Store Max/Min Polygon extent in OBJLST MOV DX,Word Ptr XPMIN CALL PUTPT MOV DX,Word Ptr YPMIN CALL PUTPT MOV DX,Word Ptr XPMAX CALL PUTPT MOV DX,Word Ptr YPMAX CALL PUTPT RET dseg ; Initialize Minimum and Maximum Polygon extents XPMIN DW 7FFFH YPMIN DW 7FFFH XPMAX DW 0 YPMAX DW 0 NPT RS 1 XP0 RS 2 YP0 RS 2 IST RS 1 cseg END