.MCALL .MODULE .MODULE GFA,RELEASE=V00,VERSION=30,COMMENT= .ENABLE LC,LSB .NLIST CND .LIST MEB ;* ;************************************************************************ ;*.PAGE * ;*.ST FILL AREA * ;*.X FILL AREA * ;*.X GFA * ;*.LIT * ;************************************************************************ ;* * ;* FORTRAN calling sequence: * ;* SUBROUTINE GFA (N, PX, PY) * ;* * ;* Input parameters: * ;* INTEGER N number of points * ;* REAL PX(N), PY(N) coordinates of points in world * ;* coordinates * ;* * ;************************************************************************ ;*.ELI * ;************************************************************************ ;- .LIBRARY /GKS.MLB/ .MCALL $GKS $GKS .LIBRARY /CGI.MLB/ .MCALL $CGI $CGI .LIBRARY /UTL.MLB/ .MCALL $UTL $UTL .NLIST .INCLUDE /GOPSTA.INC/ .INCLUDE /GKSSL.INC/ .INCLUDE /CGIVTD.INC/ .INCLUDE /GERROR.INC/ .LIST .PSECT G$$COD,RW,I,LCL,REL,CON GFA:: MOV @2(R5),R1 ; Get the number of points to draw. MOV 4(R5),XADR ; Get the X array address. MOV 6(R5),YADR ; Get the Y array address. MOV R1,-(SP) ; Save the count. MOV #-1,FLAG ; Set to begin a new polygon. GFA10: TST (SP) ; Done yet? BNE 10$ ; Branch if not. JMP GFA100 .PAGE .SBTTL Copy Points to Local Storage 10$: CMP (SP),#32. ; Check to see if there are less than 33 BGE 30$ ; points left to do. 20$: MOV (SP),R1 ; Do how ever many points are left. CLR (SP) ; Indicate no points left. BR 40$ 30$: SUB #31.,(SP) ; Decrease the counter by 31 (# of segments). MOV #32.,R1 ; Now do exactly 32 points. 40$: MOV XADR,R2 ; Get the X address. MOV YADR,R3 ; Get the Y address. MOV R1,-(SP) ; Save the current count. MOV #PNTS,R4 ; Address of the first point. 50$: MOVFLT (R2)+,(R4)+ ; Get the X value. MOVFLT (R3)+,(R4)+ ; Get the Y value. SOB R1,50$ ; Continue until the count is exhausted. SUB #FLTSIZ,R2 ; Backup one point for next time around. SUB #FLTSIZ,R3 MOV R2,XADR ; Save the current X address. MOV R3,YADR ; Save the current Y address. .PAGE .SBTTL Set the Attributes for this Fill Area 60$: $FORALLWS PUSH R2 $VFAC R2,#GS.FCI ; Set the Fill Area Colour Index. MOV (SP),R2 $VFAI R2,#GS.FAS ; Set the Fill Area Interior Style. POP R2 $ENDFOR .PAGE .SBTTL Select the right Normalization Transform MOV GS.LNT,R4 MOV GS.CNT,R3 70$: TST R3 ; Is this the right N.T.? BLE 80$ ; Branch if it is. ADD #NTSIZE,R4 ; Skip over this N.T. DEC R3 BR 70$ ; Keep looking. .PAGE .SBTTL Perform the Normalization Transform 80$: ADD #INTSIZ,R4 ; Skip over the N.T. number. MOV (SP),R1 ; Get the count of points. MOV #PNTS,R2 ; R2 points to untransformed points. MOV #NPNTS,R3 ; R3 points to transformed points. 90$: PUSH R1,R2,R3,R4 ; Save the active registers. CALL NTRANS,R4,R2,R3 ; Transform one point. POP R4,R3,R2,R1 ; Restore the active registers. ADD #<2*FLTSIZ>,R2 ; Bump the untransformed pointer. ADD #<2*FLTSIZ>,R3 ; Bump the transformed pointer. SOB R1,90$ ; Count points. .PAGE .SBTTL Clip Points as Necessary CMP GS.CI,#GCLIP ; Is CLIP on? BNE 130$ ; Branch if not. MOV (SP),R5 ; R5 <-- Number of points. PUSH R5 ; DEC (SP) ; One less line segment than points. MOV #1,NMBPTS ; Number of points to render (May be ; less than the number to clip). MOV #NPNTS,R1 ; R1 points to normalized point 1. MOV #NPNTS+<2*FLTSIZ>,R2 ; R2 points to normalized point 2. MOV #CPNTS,R3 ; R3 points to clipped point 1. MOV #CPNTS+<2*FLTSIZ>,R4 ; R4 points to clipped point 2. 100$: PUSH R1,R2,R3,R4 ; Save the active registers. CALL CLIPPR,R1,R2,R3,R4,GS.CR TST R0 ; Render now? BNE 110$ ; Branch if there is more. EXECUT SPW, ; Render whats there. CLR NMBPTS ; Start over. MOV #-1,FLAG ; Set to start a new polygon. POP R4,R3,R2,R1 MOV #CPNTS,R3 ; R3 points to clipped point 1. MOV #CPNTS+<2*FLTSIZ>,R4 ; R4 points to clipped point 2. BR 120$ 110$: POP R4,R3,R2,R1 120$: INC NMBPTS ; Increment the number of clipped points. MOV #<2*FLTSIZ>,-(SP) ADD (SP),R1 ; Bump the untransformed pointer. ADD (SP),R2 ; Bump the transformed pointer. ADD (SP),R3 ; Bump the untransformed pointer. ADD (SP)+,R4 ; Bump the transformed pointer. DEC (SP) ; Decrement the counter. BGT 100$ ; Branch if not done. 130$: EXECUT SPW, ; Render the line. CLR FLAG ; Set FLAG to 'continue' this polygon. TST (SP)+ ; Clean up the stack. TST (SP)+ JMP GFA10 ; Continue GFA100: TST (SP)+ ; Clean up the stack. MOV #1,FLAG ; Set FLAG to close the polygon. $FORALLWS $VP R2,R3,#CPNTS,FLAG ; Execute the final CALL. $ENDFOR RTS PC ; Return. .PAGE .SBTTL Send the Points to the Workstations SPW: MOV 2(R5),R3 ; Get the pointer to the number of points. $FORALLWS PUSH R3 ; Save the count pointer. $VP R2,R3,#CPNTS,FLAG ; Draw the line segment. POP R3 ; Restore the count pointer. $ENDFOR RTS PC ; Return. .PAGE .SBTTL Coordinate Transformation Work Area .PSECT G$$TRN,RW,D,GBL,REL,OVR CPNTS: PNTS: .BLKW 32.*<2*> NPNTS: .BLKW 32.*<2*> NMBPTS: .WORD 0 ; Counter for number of points. XADR: .WORD 0 YADR: .WORD 0 FLAG: .WORD 0 ; Fill Area Interior Style Flag. .END