#define EXTERN extern #include "mpd.h" fraction zcrossingpoint ( a , b , c ) integer a ; integer b ; integer c ; {/* 10 */ register fraction Result; integer d ; integer x, xx, x0, x1, x2 ; if ( a < 0 ) { Result = 0 ; goto lab10 ; } if ( c >= 0 ) { if ( b >= 0 ) if ( c > 0 ) { Result = 268435457L ; goto lab10 ; } else if ( ( a == 0 ) && ( b == 0 ) ) { Result = 268435457L ; goto lab10 ; } else { Result = 268435456L ; goto lab10 ; } if ( a == 0 ) { Result = 0 ; goto lab10 ; } } else if ( a == 0 ) if ( b <= 0 ) { Result = 0 ; goto lab10 ; } d = 1 ; x0 = a ; x1 = a - b ; x2 = b - c ; do { x = ( x1 + x2 ) / 2 ; if ( x1 - x0 > x0 ) { x2 = x ; x0 = x0 + x0 ; d = d + d ; } else { xx = x1 + x - x0 ; if ( xx > x0 ) { x2 = x ; x0 = x0 + x0 ; d = d + d ; } else { x0 = x0 - xx ; if ( x <= x0 ) if ( x + x2 <= x0 ) { Result = 268435457L ; goto lab10 ; } x1 = x ; d = d + d + 1 ; } } } while ( ! ( d >= 268435456L ) ) ; Result = d - 268435456L ; lab10: ; return(Result) ; } scaled zevalcubic ( p , q , t ) halfword p ; halfword q ; fraction t ; {register scaled Result; scaled x1, x2, x3 ; x1 = mem [ p ] .cint - takefraction ( mem [ p ] .cint - mem [ p + 4 ] .cint , t ) ; x2 = mem [ p + 4 ] .cint - takefraction ( mem [ p + 4 ] .cint - mem [ q + 2 ] .cint , t ) ; x3 = mem [ q + 2 ] .cint - takefraction ( mem [ q + 2 ] .cint - mem [ q ] .cint , t ) ; x1 = x1 - takefraction ( x1 - x2 , t ) ; x2 = x2 - takefraction ( x2 - x3 , t ) ; Result = x1 - takefraction ( x1 - x2 , t ) ; return(Result) ; } void zboundcubic ( p , q , c ) halfword p ; halfword q ; smallnumber c ; {boolean wavy ; scaled del1, del2, del3, del, dmax ; fraction t, tt ; scaled x ; x = mem [ q ] .cint ; if ( x < bbmin [ c ] ) bbmin [ c ] = x ; if ( x > bbmax [ c ] ) bbmax [ c ] = x ; wavy = true ; if ( bbmin [ c ] <= mem [ p + 4 ] .cint ) if ( mem [ p + 4 ] .cint <= bbmax [ c ] ) if ( bbmin [ c ] <= mem [ q + 2 ] .cint ) if ( mem [ q + 2 ] .cint <= bbmax [ c ] ) wavy = false ; if ( wavy ) { del1 = mem [ p + 4 ] .cint - mem [ p ] .cint ; del2 = mem [ q + 2 ] .cint - mem [ p + 4 ] .cint ; del3 = mem [ q ] .cint - mem [ q + 2 ] .cint ; if ( del1 != 0 ) del = del1 ; else if ( del2 != 0 ) del = del2 ; else del = del3 ; if ( del != 0 ) { dmax = abs ( del1 ) ; if ( abs ( del2 ) > dmax ) dmax = abs ( del2 ) ; if ( abs ( del3 ) > dmax ) dmax = abs ( del3 ) ; while ( dmax < 134217728L ) { dmax = dmax + dmax ; del1 = del1 + del1 ; del2 = del2 + del2 ; del3 = del3 + del3 ; } } if ( del < 0 ) { del1 = - (integer) del1 ; del2 = - (integer) del2 ; del3 = - (integer) del3 ; } t = crossingpoint ( del1 , del2 , del3 ) ; if ( t < 268435456L ) { x = evalcubic ( p , q , t ) ; if ( x < bbmin [ c ] ) bbmin [ c ] = x ; if ( x > bbmax [ c ] ) bbmax [ c ] = x ; del2 = del2 - takefraction ( del2 - del3 , t ) ; if ( del2 > 0 ) del2 = 0 ; tt = crossingpoint ( 0 , - (integer) del2 , - (integer) del3 ) ; if ( tt < 268435456L ) { x = evalcubic ( p , q , tt - takefraction ( tt - 268435456L , t ) ) ; if ( x < bbmin [ c ] ) bbmin [ c ] = x ; if ( x > bbmax [ c ] ) bbmax [ c ] = x ; } } } } void zpathbbox ( h ) halfword h ; {/* 10 */ halfword p, q ; bbmin [ 0 ] = mem [ h + 1 ] .cint ; bbmin [ 1 ] = mem [ h + 2 ] .cint ; bbmax [ 0 ] = bbmin [ 0 ] ; bbmax [ 1 ] = bbmin [ 1 ] ; p = h ; do { if ( mem [ p ] .hhfield .b1 == 0 ) goto lab10 ; q = mem [ p ] .hhfield .v.RH ; boundcubic ( p + 1 , q + 1 , 0 ) ; boundcubic ( p + 2 , q + 2 , 1 ) ; p = q ; } while ( ! ( p == h ) ) ; lab10: ; } scaled zsolverisingcubic ( a , b , c , x ) scaled a ; scaled b ; scaled c ; scaled x ; {register scaled Result; scaled ab, bc, ac ; integer t ; integer xx ; if ( ( a < 0 ) || ( c < 0 ) ) confusion ( 547 ) ; if ( x <= 0 ) Result = 0 ; else if ( x >= a + b + c ) Result = 65536L ; else { t = 1 ; while ( ( a > 715827882L ) || ( b > 715827882L ) || ( c > 715827882L ) ) { a = halfp ( a ) ; b = ( b ) / 2 ; c = halfp ( c ) ; x = halfp ( x ) ; } do { t = t + t ; ab = ( a + b ) / 2 ; bc = ( b + c ) / 2 ; ac = ( ab + bc ) / 2 ; xx = x - a - ab - ac ; if ( xx < - (integer) x ) { x = x + x ; b = ab ; c = ac ; } else { x = x + xx ; a = ac ; b = bc ; t = t + 1 ; } } while ( ! ( t >= 65536L ) ) ; Result = t - 65536L ; } return(Result) ; } scaled zarctest ( dx0 , dy0 , dx1 , dy1 , dx2 , dy2 , v0 , v02 , v2 , agoal ,tol ) scaled dx0 ; scaled dy0 ; scaled dx1 ; scaled dy1 ; scaled dx2 ; scaled dy2 ; scaled v0 ; scaled v02 ; scaled v2 ; scaled agoal ; scaled tol ; {/* 10 */ register scaled Result; boolean simple ; scaled dx01, dy01, dx12, dy12, dx02, dy02 ; scaled v002, v022 ; scaled arc ; scaled a, b ; scaled anew, aaux ; scaled tmp, tmp2 ; scaled arc1 ; dx01 = ( dx0 + dx1 ) / 2 ; dx12 = ( dx1 + dx2 ) / 2 ; dx02 = ( dx01 + dx12 ) / 2 ; dy01 = ( dy0 + dy1 ) / 2 ; dy12 = ( dy1 + dy2 ) / 2 ; dy02 = ( dy01 + dy12 ) / 2 ; v002 = pythadd ( dx01 + ( dx0 + dx02 ) / 2 , dy01 + ( dy0 + dy02 ) / 2 ) ; v022 = pythadd ( dx12 + ( dx02 + dx2 ) / 2 , dy12 + ( dy02 + dy2 ) / 2 ) ; tmp = halfp ( v02 + 2 ) ; arc1 = v002 + ( halfp ( v0 + tmp ) - v002 ) / 2 ; arc = v022 + ( halfp ( v2 + tmp ) - v022 ) / 2 ; if ( ( arc < 2147483647L - arc1 ) ) arc = arc + arc1 ; else { aritherror = true ; if ( agoal == 2147483647L ) Result = 2147483647L ; else Result = -131072L ; goto lab10 ; } simple = ( dx0 >= 0 ) && ( dx1 >= 0 ) && ( dx2 >= 0 ) || ( dx0 <= 0 ) && ( dx1 <= 0 ) && ( dx2 <= 0 ) ; if ( simple ) simple = ( dy0 >= 0 ) && ( dy1 >= 0 ) && ( dy2 >= 0 ) || ( dy0 <= 0 ) && ( dy1 <= 0 ) && ( dy2 <= 0 ) ; if ( ! simple ) { simple = ( dx0 >= dy0 ) && ( dx1 >= dy1 ) && ( dx2 >= dy2 ) || ( dx0 <= dy0 ) && ( dx1 <= dy1 ) && ( dx2 <= dy2 ) ; if ( simple ) simple = ( - (integer) dx0 >= dy0 ) && ( - (integer) dx1 >= dy1 ) && ( - (integer) dx2 >= dy2 ) || ( - (integer) dx0 <= dy0 ) && ( - (integer) dx1 <= dy1 ) && ( - (integer) dx2 <= dy2 ) ; } if ( simple && ( abs ( arc - v02 - halfp ( v0 + v2 ) ) <= tol ) ) if ( arc < agoal ) Result = arc ; else { tmp = ( v02 + 2 ) / 4 ; if ( agoal <= arc1 ) { tmp2 = halfp ( v0 ) ; Result = halfp ( solverisingcubic ( tmp2 , arc1 - tmp2 - tmp , tmp , agoal ) ) - 131072L ; } else { tmp2 = halfp ( v2 ) ; Result = ( -98304L ) + halfp ( solverisingcubic ( tmp , arc - arc1 - tmp - tmp2 , tmp2 , agoal - arc1 ) ) ; } } else { aaux = 2147483647L - agoal ; if ( agoal > aaux ) { aaux = agoal - aaux ; anew = 2147483647L ; } else { anew = agoal + agoal ; aaux = 0 ; } tol = tol + halfp ( tol ) ; a = arctest ( dx0 , dy0 , dx01 , dy01 , dx02 , dy02 , v0 , v002 , halfp ( v02 ) , anew , tol ) ; if ( a < 0 ) Result = - (integer) halfp ( 131072L - a ) ; else { if ( a > aaux ) { aaux = aaux - a ; anew = anew + aaux ; } b = arctest ( dx02 , dy02 , dx12 , dy12 , dx2 , dy2 , halfp ( v02 ) , v022 , v2 , anew , tol ) ; if ( b < 0 ) Result = - (integer) halfp ( - (integer) b ) - 32768L ; else Result = a + ( b - a ) / 2 ; } } lab10: ; return(Result) ; } scaled zdoarctest ( dx0 , dy0 , dx1 , dy1 , dx2 , dy2 , agoal ) scaled dx0 ; scaled dy0 ; scaled dx1 ; scaled dy1 ; scaled dx2 ; scaled dy2 ; scaled agoal ; {register scaled Result; scaled v0, v1, v2 ; scaled v02 ; v0 = pythadd ( dx0 , dy0 ) ; v1 = pythadd ( dx1 , dy1 ) ; v2 = pythadd ( dx2 , dy2 ) ; if ( ( v0 >= 1073741824L ) || ( v1 >= 1073741824L ) || ( v2 >= 1073741824L ) ) { aritherror = true ; if ( agoal == 2147483647L ) Result = 2147483647L ; else Result = -131072L ; } else { v02 = pythadd ( dx1 + ( dx0 + dx2 ) / 2 , dy1 + ( dy0 + dy2 ) / 2 ) ; Result = arctest ( dx0 , dy0 , dx1 , dy1 , dx2 , dy2 , v0 , v02 , v2 , agoal , 16 ) ; } return(Result) ; } scaled zgetarclength ( h ) halfword h ; {/* 30 */ register scaled Result; halfword p, q ; scaled a, atot ; atot = 0 ; p = h ; while ( mem [ p ] .hhfield .b1 != 0 ) { q = mem [ p ] .hhfield .v.RH ; a = doarctest ( mem [ p + 5 ] .cint - mem [ p + 1 ] .cint , mem [ p + 6 ] .cint - mem [ p + 2 ] .cint , mem [ q + 3 ] .cint - mem [ p + 5 ] .cint , mem [ q + 4 ] .cint - mem [ p + 6 ] .cint , mem [ q + 1 ] .cint - mem [ q + 3 ] .cint , mem [ q + 2 ] .cint - mem [ q + 4 ] .cint , 2147483647L ) ; atot = slowadd ( a , atot ) ; if ( q == h ) goto lab30 ; else p = q ; } lab30: { if ( aritherror ) cleararith () ; } Result = atot ; return(Result) ; } scaled zgetarctime ( h , arc0 ) halfword h ; scaled arc0 ; {/* 30 */ register scaled Result; halfword p, q ; scaled ttot ; scaled t ; scaled arc ; integer n ; if ( arc0 < 0 ) { if ( mem [ h ] .hhfield .b0 == 0 ) ttot = 0 ; else { p = htapypoc ( h ) ; ttot = - (integer) getarctime ( p , - (integer) arc0 ) ; tossknotlist ( p ) ; } goto lab30 ; } if ( arc0 == 2147483647L ) decr ( arc0 ) ; ttot = 0 ; arc = arc0 ; p = h ; while ( ( mem [ p ] .hhfield .b1 != 0 ) && ( arc > 0 ) ) { q = mem [ p ] .hhfield .v.RH ; t = doarctest ( mem [ p + 5 ] .cint - mem [ p + 1 ] .cint , mem [ p + 6 ] .cint - mem [ p + 2 ] .cint , mem [ q + 3 ] .cint - mem [ p + 5 ] .cint , mem [ q + 4 ] .cint - mem [ p + 6 ] .cint , mem [ q + 1 ] .cint - mem [ q + 3 ] .cint , mem [ q + 2 ] .cint - mem [ q + 4 ] .cint , arc ) ; if ( t < 0 ) { ttot = ttot + t + 131072L ; arc = 0 ; } else { ttot = ttot + 65536L ; arc = arc - t ; } if ( q == h ) if ( arc > 0 ) { n = arc / ( arc0 - arc ) ; arc = arc - n * ( arc0 - arc ) ; if ( ttot > 2147483647L / ( n + 1 ) ) { aritherror = true ; ttot = 2147483647L ; goto lab30 ; } ttot = ( n + 1 ) * ttot ; } p = q ; } lab30: { if ( aritherror ) cleararith () ; } Result = ttot ; return(Result) ; } void zmoveknot ( p , q ) halfword p ; halfword q ; {mem [ mem [ p ] .hhfield .lhfield ] .hhfield .v.RH = mem [ p ] .hhfield .v.RH ; mem [ mem [ p ] .hhfield .v.RH ] .hhfield .lhfield = mem [ p ] .hhfield .lhfield ; mem [ p ] .hhfield .lhfield = q ; mem [ p ] .hhfield .v.RH = mem [ q ] .hhfield .v.RH ; mem [ q ] .hhfield .v.RH = p ; mem [ mem [ p ] .hhfield .v.RH ] .hhfield .lhfield = p ; } halfword zconvexhull ( h ) halfword h ; {/* 31 32 33 */ register halfword Result; halfword l, r ; halfword p, q ; halfword s ; scaled dx, dy ; if ( ( h == mem [ h ] .hhfield .v.RH ) ) Result = h ; else { l = h ; p = mem [ h ] .hhfield .v.RH ; while ( p != h ) { if ( mem [ p + 1 ] .cint <= mem [ l + 1 ] .cint ) if ( ( mem [ p + 1 ] .cint < mem [ l + 1 ] .cint ) || ( mem [ p + 2 ] .cint < mem [ l + 2 ] .cint ) ) l = p ; p = mem [ p ] .hhfield .v.RH ; } r = h ; p = mem [ h ] .hhfield .v.RH ; while ( p != h ) { if ( mem [ p + 1 ] .cint >= mem [ r + 1 ] .cint ) if ( ( mem [ p + 1 ] .cint > mem [ r + 1 ] .cint ) || ( mem [ p + 2 ] .cint > mem [ r + 2 ] .cint ) ) r = p ; p = mem [ p ] .hhfield .v.RH ; } if ( l != r ) { s = mem [ r ] .hhfield .v.RH ; dx = mem [ r + 1 ] .cint - mem [ l + 1 ] .cint ; dy = mem [ r + 2 ] .cint - mem [ l + 2 ] .cint ; p = mem [ l ] .hhfield .v.RH ; while ( p != r ) { q = mem [ p ] .hhfield .v.RH ; if ( abvscd ( dx , mem [ p + 2 ] .cint - mem [ l + 2 ] .cint , dy , mem [ p + 1 ] .cint - mem [ l + 1 ] .cint ) > 0 ) moveknot ( p , r ) ; p = q ; } p = s ; while ( p != l ) { q = mem [ p ] .hhfield .v.RH ; if ( abvscd ( dx , mem [ p + 2 ] .cint - mem [ l + 2 ] .cint , dy , mem [ p + 1 ] .cint - mem [ l + 1 ] .cint ) < 0 ) moveknot ( p , l ) ; p = q ; } p = mem [ l ] .hhfield .v.RH ; while ( p != r ) { q = mem [ p ] .hhfield .lhfield ; while ( mem [ q + 1 ] .cint > mem [ p + 1 ] .cint ) q = mem [ q ] .hhfield .lhfield ; while ( mem [ q + 1 ] .cint == mem [ p + 1 ] .cint ) if ( mem [ q + 2 ] .cint > mem [ p + 2 ] .cint ) q = mem [ q ] .hhfield .lhfield ; else goto lab31 ; lab31: if ( q == mem [ p ] .hhfield .lhfield ) p = mem [ p ] .hhfield .v.RH ; else { p = mem [ p ] .hhfield .v.RH ; moveknot ( mem [ p ] .hhfield .lhfield , q ) ; } } p = mem [ r ] .hhfield .v.RH ; while ( p != l ) { q = mem [ p ] .hhfield .lhfield ; while ( mem [ q + 1 ] .cint < mem [ p + 1 ] .cint ) q = mem [ q ] .hhfield .lhfield ; while ( mem [ q + 1 ] .cint == mem [ p + 1 ] .cint ) if ( mem [ q + 2 ] .cint < mem [ p + 2 ] .cint ) q = mem [ q ] .hhfield .lhfield ; else goto lab32 ; lab32: if ( q == mem [ p ] .hhfield .lhfield ) p = mem [ p ] .hhfield .v.RH ; else { p = mem [ p ] .hhfield .v.RH ; moveknot ( mem [ p ] .hhfield .lhfield , q ) ; } } } if ( l != mem [ l ] .hhfield .v.RH ) { p = l ; q = mem [ l ] .hhfield .v.RH ; while ( true ) { dx = mem [ q + 1 ] .cint - mem [ p + 1 ] .cint ; dy = mem [ q + 2 ] .cint - mem [ p + 2 ] .cint ; p = q ; q = mem [ q ] .hhfield .v.RH ; if ( p == l ) goto lab33 ; if ( p != r ) if ( abvscd ( dx , mem [ q + 2 ] .cint - mem [ p + 2 ] .cint , dy , mem [ q + 1 ] .cint - mem [ p + 1 ] .cint ) <= 0 ) { s = mem [ p ] .hhfield .lhfield ; freenode ( p , 7 ) ; mem [ s ] .hhfield .v.RH = q ; mem [ q ] .hhfield .lhfield = s ; if ( s == l ) p = s ; else { p = mem [ s ] .hhfield .lhfield ; q = s ; } } } lab33: ; } Result = l ; } return(Result) ; } halfword zmakepen ( h , needhull ) halfword h ; boolean needhull ; {register halfword Result; halfword p, q ; q = h ; do { p = q ; q = mem [ q ] .hhfield .v.RH ; mem [ q ] .hhfield .lhfield = p ; } while ( ! ( q == h ) ) ; if ( needhull ) { h = convexhull ( h ) ; if ( ( h == mem [ h ] .hhfield .v.RH ) ) { mem [ h + 3 ] .cint = mem [ h + 1 ] .cint ; mem [ h + 4 ] .cint = mem [ h + 2 ] .cint ; mem [ h + 5 ] .cint = mem [ h + 1 ] .cint ; mem [ h + 6 ] .cint = mem [ h + 2 ] .cint ; } } Result = h ; return(Result) ; } halfword zgetpencircle ( diam ) scaled diam ; {register halfword Result; halfword h ; h = getnode ( 7 ) ; mem [ h ] .hhfield .v.RH = h ; mem [ h ] .hhfield .lhfield = h ; mem [ h + 1 ] .cint = 0 ; mem [ h + 2 ] .cint = 0 ; mem [ h + 3 ] .cint = diam ; mem [ h + 4 ] .cint = 0 ; mem [ h + 5 ] .cint = 0 ; mem [ h + 6 ] .cint = diam ; Result = h ; return(Result) ; } void zmakepath ( h ) halfword h ; {halfword p ; smallnumber k ; scaled centerx, centery ; scaled widthx, widthy ; scaled heightx, heighty ; scaled dx, dy ; integer kk ; if ( ( h == mem [ h ] .hhfield .v.RH ) ) { centerx = mem [ h + 1 ] .cint ; centery = mem [ h + 2 ] .cint ; widthx = mem [ h + 3 ] .cint - centerx ; widthy = mem [ h + 4 ] .cint - centery ; heightx = mem [ h + 5 ] .cint - centerx ; heighty = mem [ h + 6 ] .cint - centery ; p = h ; {register integer for_end; k = 0 ; for_end = 7 ; if ( k <= for_end) do { kk = ( k + 6 ) % 8 ; mem [ p + 1 ] .cint = centerx + takefraction ( halfcos [ k ] , widthx ) + takefraction ( halfcos [ kk ] , heightx ) ; mem [ p + 2 ] .cint = centery + takefraction ( halfcos [ k ] , widthy ) + takefraction ( halfcos [ kk ] , heighty ) ; dx = - (integer) takefraction ( dcos [ kk ] , widthx ) + takefraction ( dcos [ k ] , heightx ) ; dy = - (integer) takefraction ( dcos [ kk ] , widthy ) + takefraction ( dcos [ k ] , heighty ) ; mem [ p + 5 ] .cint = mem [ p + 1 ] .cint + dx ; mem [ p + 6 ] .cint = mem [ p + 2 ] .cint + dy ; mem [ p + 3 ] .cint = mem [ p + 1 ] .cint - dx ; mem [ p + 4 ] .cint = mem [ p + 2 ] .cint - dy ; mem [ p ] .hhfield .b0 = 1 ; mem [ p ] .hhfield .b1 = 1 ; if ( k == 7 ) mem [ p ] .hhfield .v.RH = h ; else mem [ p ] .hhfield .v.RH = getnode ( 7 ) ; p = mem [ p ] .hhfield .v.RH ; } while ( k++ < for_end ) ; } } else { p = h ; do { mem [ p ] .hhfield .b0 = 1 ; mem [ p ] .hhfield .b1 = 1 ; mem [ p + 3 ] .cint = mem [ p + 1 ] .cint ; mem [ p + 4 ] .cint = mem [ p + 2 ] .cint ; mem [ p + 5 ] .cint = mem [ p + 1 ] .cint ; mem [ p + 6 ] .cint = mem [ p + 2 ] .cint ; p = mem [ p ] .hhfield .v.RH ; } while ( ! ( p == h ) ) ; } } void zfindoffset ( x , y , h ) scaled x ; scaled y ; halfword h ; {halfword p, q ; scaled wx, wy, hx, hy ; fraction xx, yy ; fraction d ; if ( ( h == mem [ h ] .hhfield .v.RH ) ) if ( ( x == 0 ) && ( y == 0 ) ) { curx = mem [ h + 1 ] .cint ; cury = mem [ h + 2 ] .cint ; } else { wx = mem [ h + 3 ] .cint - mem [ h + 1 ] .cint ; wy = mem [ h + 4 ] .cint - mem [ h + 2 ] .cint ; hx = mem [ h + 5 ] .cint - mem [ h + 1 ] .cint ; hy = mem [ h + 6 ] .cint - mem [ h + 2 ] .cint ; while ( ( abs ( x ) < 134217728L ) && ( abs ( y ) < 134217728L ) ) { x = x + x ; y = y + y ; } yy = - (integer) ( takefraction ( x , hy ) + takefraction ( y , - (integer) hx ) ) ; xx = takefraction ( x , - (integer) wy ) + takefraction ( y , wx ) ; d = pythadd ( xx , yy ) ; if ( d > 0 ) { xx = ( makefraction ( xx , d ) ) / 2 ; yy = ( makefraction ( yy , d ) ) / 2 ; } curx = mem [ h + 1 ] .cint + takefraction ( xx , wx ) + takefraction ( yy , hx ) ; cury = mem [ h + 2 ] .cint + takefraction ( xx , wy ) + takefraction ( yy , hy ) ; } else { q = h ; do { p = q ; q = mem [ q ] .hhfield .v.RH ; } while ( ! ( abvscd ( mem [ q + 1 ] .cint - mem [ p + 1 ] .cint , y , mem [ q + 2 ] .cint - mem [ p + 2 ] .cint , x ) >= 0 ) ) ; do { p = q ; q = mem [ q ] .hhfield .v.RH ; } while ( ! ( abvscd ( mem [ q + 1 ] .cint - mem [ p + 1 ] .cint , y , mem [ q + 2 ] .cint - mem [ p + 2 ] .cint , x ) <= 0 ) ) ; curx = mem [ p + 1 ] .cint ; cury = mem [ p + 2 ] .cint ; } } void zpenbbox ( h ) halfword h ; {halfword p ; if ( ( h == mem [ h ] .hhfield .v.RH ) ) { findoffset ( 0 , 268435456L , h ) ; bbmax [ 0 ] = curx ; bbmin [ 0 ] = 2 * mem [ h + 1 ] .cint - curx ; findoffset ( -268435456L , 0 , h ) ; bbmax [ 1 ] = cury ; bbmin [ 1 ] = 2 * mem [ h + 2 ] .cint - cury ; } else { bbmin [ 0 ] = mem [ h + 1 ] .cint ; bbmax [ 0 ] = bbmin [ 0 ] ; bbmin [ 1 ] = mem [ h + 2 ] .cint ; bbmax [ 1 ] = bbmin [ 1 ] ; p = mem [ h ] .hhfield .v.RH ; while ( p != h ) { if ( mem [ p + 1 ] .cint < bbmin [ 0 ] ) bbmin [ 0 ] = mem [ p + 1 ] .cint ; if ( mem [ p + 2 ] .cint < bbmin [ 1 ] ) bbmin [ 1 ] = mem [ p + 2 ] .cint ; if ( mem [ p + 1 ] .cint > bbmax [ 0 ] ) bbmax [ 0 ] = mem [ p + 1 ] .cint ; if ( mem [ p + 2 ] .cint > bbmax [ 1 ] ) bbmax [ 1 ] = mem [ p + 2 ] .cint ; p = mem [ p ] .hhfield .v.RH ; } } } halfword znewfillnode ( p ) halfword p ; {register halfword Result; halfword t ; t = getnode ( 6 ) ; mem [ t ] .hhfield .b0 = 1 ; mem [ t + 1 ] .hhfield .v.RH = p ; mem [ t + 1 ] .hhfield .lhfield = 0 ; mem [ t + 2 ] .cint = 0 ; mem [ t + 3 ] .cint = 0 ; mem [ t + 4 ] .cint = 0 ; if ( internal [ 27 ] > 65536L ) mem [ t ] .hhfield .b1 = 2 ; else if ( internal [ 27 ] > 0 ) mem [ t ] .hhfield .b1 = 1 ; else mem [ t ] .hhfield .b1 = 0 ; if ( internal [ 29 ] < 65536L ) mem [ t + 5 ] .cint = 65536L ; else mem [ t + 5 ] .cint = internal [ 29 ] ; Result = t ; return(Result) ; } halfword znewstrokednode ( p ) halfword p ; {register halfword Result; halfword t ; t = getnode ( 8 ) ; mem [ t ] .hhfield .b0 = 2 ; mem [ t + 1 ] .hhfield .v.RH = p ; mem [ t + 1 ] .hhfield .lhfield = 0 ; mem [ t + 6 ] .hhfield .v.RH = 0 ; mem [ t + 7 ] .cint = 65536L ; mem [ t + 2 ] .cint = 0 ; mem [ t + 3 ] .cint = 0 ; mem [ t + 4 ] .cint = 0 ; if ( internal [ 27 ] > 65536L ) mem [ t ] .hhfield .b1 = 2 ; else if ( internal [ 27 ] > 0 ) mem [ t ] .hhfield .b1 = 1 ; else mem [ t ] .hhfield .b1 = 0 ; if ( internal [ 29 ] < 65536L ) mem [ t + 5 ] .cint = 65536L ; else mem [ t + 5 ] .cint = internal [ 29 ] ; if ( internal [ 28 ] > 65536L ) mem [ t + 6 ] .hhfield .b0 = 2 ; else if ( internal [ 28 ] > 0 ) mem [ t + 6 ] .hhfield .b0 = 1 ; else mem [ t + 6 ] .hhfield .b0 = 0 ; Result = t ; return(Result) ; } void beginname ( ) {{ if ( strref [ curname ] < 127 ) if ( strref [ curname ] > 1 ) decr ( strref [ curname ] ) ; else flushstring ( curname ) ; } { if ( strref [ curarea ] < 127 ) if ( strref [ curarea ] > 1 ) decr ( strref [ curarea ] ) ; else flushstring ( curarea ) ; } { if ( strref [ curext ] < 127 ) if ( strref [ curext ] > 1 ) decr ( strref [ curext ] ) ; else flushstring ( curext ) ; } areadelimiter = -1 ; extdelimiter = -1 ; } boolean zmorename ( c ) ASCIIcode c ; {register boolean Result; if ( ( c == 32 ) || ( c == 9 ) ) Result = false ; else { if ( ( c == 47 || c == 92 ) ) { areadelimiter = poolptr - strstart [ strptr ] ; extdelimiter = -1 ; } else if ( ( c == 46 ) && ( extdelimiter < 0 ) ) extdelimiter = poolptr - strstart [ strptr ] ; { if ( poolptr + 1 > maxpoolptr ) if ( poolptr + 1 > poolsize ) docompaction ( 1 ) ; else maxpoolptr = poolptr + 1 ; } { strpool [ poolptr ] = c ; incr ( poolptr ) ; } Result = true ; } return(Result) ; } void endname ( ) {strnumber s ; s = strptr ; if ( areadelimiter < 0 ) curarea = 285 ; else { curarea = makestring () ; choplaststring ( strstart [ s ] + areadelimiter + 1 ) ; } if ( extdelimiter < 0 ) { curext = 285 ; curname = makestring () ; } else { curname = makestring () ; choplaststring ( strstart [ s ] + extdelimiter ) ; curext = makestring () ; } } void zpackfilename ( n , a , e ) strnumber n ; strnumber a ; strnumber e ; {integer k ; ASCIIcode c ; poolpointer j ; k = 0 ; {register integer for_end; j = strstart [ a ] ; for_end = strstart [ nextstr [ a ] ] - 1 ; if ( j <= for_end) do { c = strpool [ j ] ; incr ( k ) ; if ( k <= filenamesize ) nameoffile [ k ] = xchr [ c ] ; } while ( j++ < for_end ) ; } {register integer for_end; j = strstart [ n ] ; for_end = strstart [ nextstr [ n ] ] - 1 ; if ( j <= for_end) do { c = strpool [ j ] ; incr ( k ) ; if ( k <= filenamesize ) nameoffile [ k ] = xchr [ c ] ; } while ( j++ < for_end ) ; } {register integer for_end; j = strstart [ e ] ; for_end = strstart [ nextstr [ e ] ] - 1 ; if ( j <= for_end) do { c = strpool [ j ] ; incr ( k ) ; if ( k <= filenamesize ) nameoffile [ k ] = xchr [ c ] ; } while ( j++ < for_end ) ; } if ( k <= filenamesize ) namelength = k ; else namelength = filenamesize ; {register integer for_end; k = namelength + 1 ; for_end = filenamesize ; if ( k <= for_end) do nameoffile [ k ] = ' ' ; while ( k++ < for_end ) ; } } void zstrscanfile ( s ) strnumber s ; {/* 30 */ poolpointer p, q ; beginname () ; p = strstart [ s ] ; q = strstart [ nextstr [ s ] ] ; while ( p < q ) { if ( ! morename ( strpool [ p ] ) ) goto lab30 ; incr ( p ) ; } lab30: endname () ; } fontnumber zreadfontinfo ( fname ) strnumber fname ; {/* 11 30 */ register fontnumber Result; boolean fileopened ; fontnumber n ; halfword lf, lh, bc, ec, nw, nh, nd ; integer whdsize ; integer i, ii ; integer jj ; scaled z ; fraction d ; eightbits handd ; n = 0 ; fileopened = false ; strscanfile ( fname ) ; if ( curext == 285 ) curext = 1092 ; packfilename ( curname , curarea , curext ) ; if ( ! bopenin ( tfminfile ) ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; fileopened = true ; { lf = tfmtemp ; if ( lf > 127 ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; lf = lf * 256 + tfmtemp ; } tfmtemp = getc ( tfminfile ) ; { lh = tfmtemp ; if ( lh > 127 ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; lh = lh * 256 + tfmtemp ; } tfmtemp = getc ( tfminfile ) ; { bc = tfmtemp ; if ( bc > 127 ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; bc = bc * 256 + tfmtemp ; } tfmtemp = getc ( tfminfile ) ; { ec = tfmtemp ; if ( ec > 127 ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; ec = ec * 256 + tfmtemp ; } if ( ( bc > 1 + ec ) || ( ec > 255 ) ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; { nw = tfmtemp ; if ( nw > 127 ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; nw = nw * 256 + tfmtemp ; } tfmtemp = getc ( tfminfile ) ; { nh = tfmtemp ; if ( nh > 127 ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; nh = nh * 256 + tfmtemp ; } tfmtemp = getc ( tfminfile ) ; { nd = tfmtemp ; if ( nd > 127 ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; nd = nd * 256 + tfmtemp ; } whdsize = ( ec + 1 - bc ) + nw + nh + nd ; if ( lf < 6 + lh + whdsize ) goto lab11 ; {register integer for_end; jj = 10 ; for_end = 1 ; if ( jj >= for_end) do tfmtemp = getc ( tfminfile ) ; while ( jj-- > for_end ) ; } if ( ( lastfnum == fontmax ) || ( nextfmem + whdsize >= fontmemsize ) ) { { if ( interaction == 3 ) ; printnl ( 263 ) ; print ( 1100 ) ; } print ( fname ) ; print ( 1107 ) ; { helpptr = 3 ; helpline [ 2 ] = 1108 ; helpline [ 1 ] = 1109 ; helpline [ 0 ] = 1110 ; } error () ; goto lab30 ; } incr ( lastfnum ) ; n = lastfnum ; fontbc [ n ] = bc ; fontec [ n ] = ec ; charbase [ n ] = nextfmem - bc + 0 ; widthbase [ n ] = nextfmem + ec - bc + 1 ; heightbase [ n ] = widthbase [ n ] + 0 + nw ; depthbase [ n ] = heightbase [ n ] + nh ; nextfmem = nextfmem + whdsize ; if ( lh < 2 ) goto lab11 ; {register integer for_end; jj = 4 ; for_end = 1 ; if ( jj >= for_end) do tfmtemp = getc ( tfminfile ) ; while ( jj-- > for_end ) ; } tfmtemp = getc ( tfminfile ) ; { z = tfmtemp ; if ( z > 127 ) goto lab11 ; tfmtemp = getc ( tfminfile ) ; z = z * 256 + tfmtemp ; } tfmtemp = getc ( tfminfile ) ; z = z * 256 + tfmtemp ; tfmtemp = getc ( tfminfile ) ; z = z * 256 + tfmtemp ; fontdsize [ n ] = takefraction ( z , 267432584L ) ; {register integer for_end; jj = 4 * ( lh - 2 ) ; for_end = 1 ; if ( jj >= for_end) do tfmtemp = getc ( tfminfile ) ; while ( jj-- > for_end ) ; } ii = widthbase [ n ] + 0 ; i = charbase [ n ] + 0 + bc ; while ( i < ii ) { tfmtemp = getc ( tfminfile ) ; fontinfo [ i ] .qqqq .b0 = tfmtemp ; tfmtemp = getc ( tfminfile ) ; handd = tfmtemp ; fontinfo [ i ] .qqqq .b1 = handd / 16 ; fontinfo [ i ] .qqqq .b2 = handd % 16 ; tfmtemp = getc ( tfminfile ) ; tfmtemp = getc ( tfminfile ) ; incr ( i ) ; } while ( i < nextfmem ) { tfmtemp = getc ( tfminfile ) ; d = tfmtemp ; if ( d >= 128 ) d = d - 256 ; tfmtemp = getc ( tfminfile ) ; d = d * 256 + tfmtemp ; tfmtemp = getc ( tfminfile ) ; d = d * 256 + tfmtemp ; tfmtemp = getc ( tfminfile ) ; d = d * 256 + tfmtemp ; fontinfo [ i ] .cint = takefraction ( d * 16 , fontdsize [ n ] ) ; incr ( i ) ; } if ( eof ( tfminfile ) ) goto lab11 ; goto lab30 ; lab11: { if ( interaction == 3 ) ; printnl ( 263 ) ; print ( 1100 ) ; } print ( fname ) ; if ( fileopened ) print ( 1101 ) ; else print ( 1102 ) ; { helpptr = 3 ; helpline [ 2 ] = 1103 ; helpline [ 1 ] = 1104 ; helpline [ 0 ] = 1105 ; } if ( fileopened ) helpline [ 0 ] = 1106 ; error () ; lab30: if ( fileopened ) bclose ( tfminfile ) ; if ( n != 0 ) { fontpsname [ n ] = fname ; fontname [ n ] = fname ; strref [ fname ] = 127 ; } Result = n ; return(Result) ; } fontnumber zfindfont ( f ) strnumber f ; {/* 10 40 */ register fontnumber Result; fontnumber n ; {register integer for_end; n = 0 ; for_end = lastfnum ; if ( n <= for_end) do if ( strvsstr ( f , fontname [ n ] ) == 0 ) goto lab40 ; while ( n++ < for_end ) ; } Result = readfontinfo ( f ) ; goto lab10 ; lab40: Result = n ; lab10: ; return(Result) ; } void zlostwarning ( f , k ) fontnumber f ; poolpointer k ; {if ( internal [ 11 ] > 0 ) { begindiagnostic () ; printnl ( 1111 ) ; print ( strpool [ k ] ) ; print ( 1112 ) ; print ( fontname [ f ] ) ; printchar ( 33 ) ; enddiagnostic ( false ) ; } } void zsettextbox ( p ) halfword p ; {fontnumber f ; poolASCIIcode bc, ec ; poolpointer k, kk ; fourquarters cc ; scaled h, d ; mem [ p + 5 ] .cint = 0 ; mem [ p + 6 ] .cint = -2147483647L ; mem [ p + 7 ] .cint = -2147483647L ; f = mem [ p + 1 ] .hhfield .lhfield ; bc = fontbc [ f ] ; ec = fontec [ f ] ; kk = strstart [ nextstr [ mem [ p + 1 ] .hhfield .v.RH ] ] ; k = strstart [ mem [ p + 1 ] .hhfield .v.RH ] ; while ( k < kk ) { if ( ( strpool [ k ] < bc ) || ( strpool [ k ] > ec ) ) lostwarning ( f , k ) ; else { cc = fontinfo [ charbase [ f ] + strpool [ k ] ] .qqqq ; if ( ! ( cc .b0 > 0 ) ) lostwarning ( f , k ) ; else { mem [ p + 5 ] .cint = mem [ p + 5 ] .cint + fontinfo [ widthbase [ f ] + cc .b0 ] .cint ; h = fontinfo [ heightbase [ f ] + cc .b1 ] .cint ; d = fontinfo [ depthbase [ f ] + cc .b2 ] .cint ; if ( h > mem [ p + 6 ] .cint ) mem [ p + 6 ] .cint = h ; if ( d > mem [ p + 7 ] .cint ) mem [ p + 7 ] .cint = d ; } } incr ( k ) ; } if ( mem [ p + 6 ] .cint < - (integer) mem [ p + 7 ] .cint ) { mem [ p + 6 ] .cint = 0 ; mem [ p + 7 ] .cint = 0 ; } } halfword znewtextnode ( f , s ) strnumber f ; strnumber s ; {register halfword Result; halfword t ; t = getnode ( 14 ) ; mem [ t ] .hhfield .b0 = 3 ; mem [ t + 1 ] .hhfield .v.RH = s ; mem [ t + 1 ] .hhfield .lhfield = findfont ( f ) ; mem [ t + 2 ] .cint = 0 ; mem [ t + 3 ] .cint = 0 ; mem [ t + 4 ] .cint = 0 ; mem [ t + 8 ] .cint = 0 ; mem [ t + 9 ] .cint = 0 ; mem [ t + 10 ] .cint = 65536L ; mem [ t + 11 ] .cint = 0 ; mem [ t + 12 ] .cint = 0 ; mem [ t + 13 ] .cint = 65536L ; settextbox ( t ) ; Result = t ; return(Result) ; } halfword znewboundsnode ( p , c ) halfword p ; smallnumber c ; {register halfword Result; halfword t ; t = getnode ( grobjectsize [ c ] ) ; mem [ t ] .hhfield .b0 = c ; mem [ t + 1 ] .hhfield .v.RH = p ; Result = t ; return(Result) ; } void zinitbbox ( h ) halfword h ; {mem [ h + 6 ] .hhfield .v.RH = h + 7 ; mem [ h + 6 ] .hhfield .lhfield = 0 ; mem [ h + 2 ] .cint = 2147483647L ; mem [ h + 3 ] .cint = 2147483647L ; mem [ h + 4 ] .cint = -2147483647L ; mem [ h + 5 ] .cint = -2147483647L ; } void zinitedges ( h ) halfword h ; {mem [ h ] .hhfield .v.RH = 2 ; mem [ h + 7 ] .hhfield .lhfield = h + 7 ; mem [ h + 7 ] .hhfield .v.RH = 0 ; mem [ h ] .hhfield .lhfield = 0 ; initbbox ( h ) ; } halfword zcopyobjects ( p , q ) halfword p ; halfword q ; {register halfword Result; halfword hh ; halfword pp ; smallnumber k ; hh = getnode ( 8 ) ; mem [ hh ] .hhfield .v.RH = 2 ; mem [ hh ] .hhfield .lhfield = 0 ; pp = hh + 7 ; while ( ( p != q ) ) { k = grobjectsize [ mem [ p ] .hhfield .b0 ] ; mem [ pp ] .hhfield .v.RH = getnode ( k ) ; pp = mem [ pp ] .hhfield .v.RH ; while ( ( k > 0 ) ) { decr ( k ) ; mem [ pp + k ] = mem [ p + k ] ; } switch ( mem [ p ] .hhfield .b0 ) {case 4 : case 5 : mem [ pp + 1 ] .hhfield .v.RH = copypath ( mem [ p + 1 ] .hhfield .v.RH ) ; break ; case 1 : { mem [ pp + 1 ] .hhfield .v.RH = copypath ( mem [ p + 1 ] .hhfield .v.RH ) ; if ( mem [ p + 1 ] .hhfield .lhfield != 0 ) mem [ pp + 1 ] .hhfield .lhfield = makepen ( copypath ( mem [ p + 1 ] .hhfield .lhfield ) , false ) ; } break ; case 2 : { mem [ pp + 1 ] .hhfield .v.RH = copypath ( mem [ p + 1 ] .hhfield .v.RH ) ; mem [ pp + 1 ] .hhfield .lhfield = makepen ( copypath ( mem [ p + 1 ] .hhfield .lhfield ) , false ) ; if ( mem [ p + 6 ] .hhfield .v.RH != 0 ) incr ( mem [ mem [ pp + 6 ] .hhfield .v.RH ] .hhfield .lhfield ) ; } break ; case 3 : { if ( strref [ mem [ pp + 1 ] .hhfield .v.RH ] < 127 ) incr ( strref [ mem [ pp + 1 ] .hhfield .v.RH ] ) ; } break ; case 6 : case 7 : ; break ; } p = mem [ p ] .hhfield .v.RH ; } mem [ hh + 7 ] .hhfield .lhfield = pp ; mem [ pp ] .hhfield .v.RH = 0 ; Result = hh ; return(Result) ; } halfword zprivateedges ( h ) halfword h ; {register halfword Result; halfword hh ; halfword p, pp ; if ( mem [ h ] .hhfield .lhfield == 0 ) Result = h ; else { decr ( mem [ h ] .hhfield .lhfield ) ; hh = copyobjects ( mem [ h + 7 ] .hhfield .v.RH , 0 ) ; pp = hh ; p = mem [ h ] .hhfield .v.RH ; while ( ( p != 2 ) ) { mem [ pp ] .hhfield .v.RH = getnode ( 3 ) ; pp = mem [ pp ] .hhfield .v.RH ; mem [ pp + 1 ] .cint = mem [ p + 1 ] .cint ; mem [ pp + 2 ] .cint = mem [ p + 2 ] .cint ; p = mem [ p ] .hhfield .v.RH ; } mem [ pp ] .hhfield .v.RH = 2 ; mem [ hh + 1 ] .cint = mem [ h + 1 ] .cint ; mem [ hh + 2 ] .cint = mem [ h + 2 ] .cint ; mem [ hh + 3 ] .cint = mem [ h + 3 ] .cint ; mem [ hh + 4 ] .cint = mem [ h + 4 ] .cint ; mem [ hh + 5 ] .cint = mem [ h + 5 ] .cint ; mem [ hh + 6 ] .hhfield .lhfield = mem [ h + 6 ] .hhfield .lhfield ; p = h + 7 ; pp = hh + 7 ; while ( ( p != mem [ h + 6 ] .hhfield .v.RH ) ) { if ( p == 0 ) confusion ( 551 ) ; p = mem [ p ] .hhfield .v.RH ; pp = mem [ pp ] .hhfield .v.RH ; } mem [ hh + 6 ] .hhfield .v.RH = pp ; Result = hh ; } return(Result) ; } halfword zskip1component ( p ) halfword p ; {register halfword Result; integer lev ; lev = 0 ; do { if ( ( mem [ p ] .hhfield .b0 >= 4 ) ) if ( ( mem [ p ] .hhfield .b0 >= 6 ) ) decr ( lev ) ; else incr ( lev ) ; p = mem [ p ] .hhfield .v.RH ; } while ( ! ( lev == 0 ) ) ; Result = p ; return(Result) ; } void xretraceerror ( ) {{ if ( interaction == 3 ) ; printnl ( 263 ) ; print ( 580 ) ; } { helpptr = 3 ; helpline [ 2 ] = 584 ; helpline [ 1 ] = 585 ; helpline [ 0 ] = 583 ; } putgeterror () ; } halfword zmakedashes ( h ) halfword h ; {/* 10 40 45 */ register halfword Result; halfword p ; scaled y0 ; halfword p0 ; halfword pp, qq, rr ; halfword d, dd ; scaled x0, x1, x2, x3 ; halfword dln ; halfword hh ; scaled xoff ; if ( mem [ h ] .hhfield .v.RH != 2 ) goto lab40 ; p0 = 0 ; p = mem [ h + 7 ] .hhfield .v.RH ; while ( p != 0 ) { if ( mem [ p ] .hhfield .b0 != 2 ) { { if ( interaction == 3 ) ; printnl ( 263 ) ; print ( 580 ) ; } { helpptr = 3 ; helpline [ 2 ] = 581 ; helpline [ 1 ] = 582 ; helpline [ 0 ] = 583 ; } putgeterror () ; goto lab45 ; } pp = mem [ p + 1 ] .hhfield .v.RH ; if ( p0 == 0 ) { p0 = p ; y0 = mem [ pp + 2 ] .cint ; } if ( ( mem [ p + 2 ] .cint != mem [ p0 + 2 ] .cint ) || ( mem [ p + 3 ] .cint != mem [ p0 + 3 ] .cint ) || ( mem [ p + 4 ] .cint != mem [ p0 + 4 ] .cint ) ) { { if ( interaction == 3 ) ; printnl ( 263 ) ; print ( 580 ) ; } { helpptr = 3 ; helpline [ 2 ] = 586 ; helpline [ 1 ] = 587 ; helpline [ 0 ] = 583 ; } putgeterror () ; goto lab45 ; } rr = pp ; if ( mem [ pp ] .hhfield .v.RH != pp ) do { qq = rr ; rr = mem [ rr ] .hhfield .v.RH ; x0 = mem [ qq + 1 ] .cint ; x1 = mem [ qq + 5 ] .cint ; x2 = mem [ rr + 3 ] .cint ; x3 = mem [ rr + 1 ] .cint ; if ( ( x0 > x1 ) || ( x1 > x2 ) || ( x2 > x3 ) ) if ( ( x0 < x1 ) || ( x1 < x2 ) || ( x2 < x3 ) ) if ( abvscd ( x2 - x1 , x2 - x1 , x1 - x0 , x3 - x2 ) > 0 ) { xretraceerror () ; goto lab45 ; } if ( ( mem [ pp + 1 ] .cint > x0 ) || ( x0 > x3 ) ) if ( ( mem [ pp + 1 ] .cint < x0 ) || ( x0 < x3 ) ) { xretraceerror () ; goto lab45 ; } } while ( ! ( mem [ rr ] .hhfield .b1 == 0 ) ) ; d = getnode ( 3 ) ; mem [ d ] .hhfield .lhfield = mem [ p + 6 ] .hhfield .v.RH ; if ( mem [ pp + 1 ] .cint < mem [ rr + 1 ] .cint ) { mem [ d + 1 ] .cint = mem [ pp + 1 ] .cint ; mem [ d + 2 ] .cint = mem [ rr + 1 ] .cint ; } else { mem [ d + 1 ] .cint = mem [ rr + 1 ] .cint ; mem [ d + 2 ] .cint = mem [ pp + 1 ] .cint ; } mem [ 3 ] .cint = mem [ d + 2 ] .cint ; dd = h ; while ( mem [ mem [ dd ] .hhfield .v.RH + 1 ] .cint < mem [ d + 2 ] .cint ) dd = mem [ dd ] .hhfield .v.RH ; if ( dd != h ) if ( ( mem [ dd + 2 ] .cint > mem [ d + 1 ] .cint ) ) { xretraceerror () ; goto lab45 ; } mem [ d ] .hhfield .v.RH = mem [ dd ] .hhfield .v.RH ; mem [ dd ] .hhfield .v.RH = d ; p = mem [ p ] .hhfield .v.RH ; } if ( mem [ h ] .hhfield .v.RH == 2 ) goto lab45 ; d = h ; while ( mem [ d ] .hhfield .v.RH != 2 ) { hh = mem [ mem [ d ] .hhfield .v.RH ] .hhfield .lhfield ; if ( hh == 0 ) d = mem [ d ] .hhfield .v.RH ; else if ( mem [ hh + 1 ] .cint == 0 ) d = mem [ d ] .hhfield .v.RH ; else { if ( mem [ hh ] .hhfield .v.RH == 0 ) confusion ( 588 ) ; dln = mem [ d ] .hhfield .v.RH ; dd = mem [ hh ] .hhfield .v.RH ; xoff = mem [ dln + 1 ] .cint - mem [ dd + 1 ] .cint - dashoffset ( hh ) ; mem [ 3 ] .cint = mem [ dd + 1 ] .cint + mem [ hh + 1 ] .cint ; mem [ 4 ] .cint = mem [ 3 ] .cint ; while ( xoff + mem [ dd + 2 ] .cint < mem [ dln + 1 ] .cint ) dd = mem [ dd ] .hhfield .v.RH ; while ( mem [ dln + 1 ] .cint <= mem [ dln + 2 ] .cint ) { if ( dd == 2 ) { dd = mem [ hh ] .hhfield .v.RH ; xoff = xoff + mem [ hh + 1 ] .cint ; } if ( xoff + mem [ dd + 1 ] .cint <= mem [ dln + 2 ] .cint ) { mem [ d ] .hhfield .v.RH = getnode ( 3 ) ; d = mem [ d ] .hhfield .v.RH ; mem [ d ] .hhfield .v.RH = dln ; if ( mem [ dln + 1 ] .cint > xoff + mem [ dd + 1 ] .cint ) mem [ d + 1 ] .cint = mem [ dln + 1 ] .cint ; else mem [ d + 1 ] .cint = xoff + mem [ dd + 1 ] .cint ; if ( mem [ dln + 2 ] .cint < xoff + mem [ dd + 2 ] .cint ) mem [ d + 2 ] .cint = mem [ dln + 2 ] .cint ; else mem [ d + 2 ] .cint = xoff + mem [ dd + 2 ] .cint ; } dd = mem [ dd ] .hhfield .v.RH ; mem [ dln + 1 ] .cint = xoff + mem [ dd + 1 ] .cint ; } mem [ d ] .hhfield .v.RH = mem [ dln ] .hhfield .v.RH ; freenode ( dln , 3 ) ; } } d = mem [ h ] .hhfield .v.RH ; while ( ( mem [ d ] .hhfield .v.RH != 2 ) ) d = mem [ d ] .hhfield .v.RH ; dd = mem [ h ] .hhfield .v.RH ; mem [ h + 1 ] .cint = mem [ d + 2 ] .cint - mem [ dd + 1 ] .cint ; if ( abs ( y0 ) > mem [ h + 1 ] .cint ) mem [ h + 1 ] .cint = abs ( y0 ) ; else if ( d != dd ) { mem [ h ] .hhfield .v.RH = mem [ dd ] .hhfield .v.RH ; mem [ d + 2 ] .cint = mem [ dd + 2 ] .cint + mem [ h + 1 ] .cint ; freenode ( dd , 3 ) ; } lab40: Result = h ; goto lab10 ; lab45: flushdashlist ( h ) ; if ( mem [ h ] .hhfield .lhfield == 0 ) tossedges ( h ) ; else decr ( mem [ h ] .hhfield .lhfield ) ; Result = 0 ; lab10: ; return(Result) ; } void zadjustbbox ( h ) halfword h ; {if ( bbmin [ 0 ] < mem [ h + 2 ] .cint ) mem [ h + 2 ] .cint = bbmin [ 0 ] ; if ( bbmin [ 1 ] < mem [ h + 3 ] .cint ) mem [ h + 3 ] .cint = bbmin [ 1 ] ; if ( bbmax [ 0 ] > mem [ h + 4 ] .cint ) mem [ h + 4 ] .cint = bbmax [ 0 ] ; if ( bbmax [ 1 ] > mem [ h + 5 ] .cint ) mem [ h + 5 ] .cint = bbmax [ 1 ] ; } void zboxends ( p , pp , h ) halfword p ; halfword pp ; halfword h ; {/* 10 */ halfword q ; fraction dx, dy ; scaled d ; scaled z ; scaled xx, yy ; integer i ; if ( mem [ p ] .hhfield .b1 != 0 ) { q = mem [ p ] .hhfield .v.RH ; while ( true ) { if ( q == mem [ p ] .hhfield .v.RH ) { dx = mem [ p + 1 ] .cint - mem [ p + 5 ] .cint ; dy = mem [ p + 2 ] .cint - mem [ p + 6 ] .cint ; if ( ( dx == 0 ) && ( dy == 0 ) ) { dx = mem [ p + 1 ] .cint - mem [ q + 3 ] .cint ; dy = mem [ p + 2 ] .cint - mem [ q + 4 ] .cint ; } } else { dx = mem [ p + 1 ] .cint - mem [ p + 3 ] .cint ; dy = mem [ p + 2 ] .cint - mem [ p + 4 ] .cint ; if ( ( dx == 0 ) && ( dy == 0 ) ) { dx = mem [ p + 1 ] .cint - mem [ q + 5 ] .cint ; dy = mem [ p + 2 ] .cint - mem [ q + 6 ] .cint ; } } dx = mem [ p + 1 ] .cint - mem [ q + 1 ] .cint ; dy = mem [ p + 2 ] .cint - mem [ q + 2 ] .cint ; d = pythadd ( dx , dy ) ; if ( d > 0 ) { dx = makefraction ( dx , d ) ; dy = makefraction ( dy , d ) ; findoffset ( - (integer) dy , dx , pp ) ; xx = curx ; yy = cury ; {register integer for_end; i = 1 ; for_end = 2 ; if ( i <= for_end) do { findoffset ( dx , dy , pp ) ; d = takefraction ( xx - curx , dx ) + takefraction ( yy - cury , dy ) ; if ( ( d < 0 ) && ( i == 1 ) || ( d > 0 ) && ( i == 2 ) ) confusion ( 589 ) ; z = mem [ p + 1 ] .cint + curx + takefraction ( d , dx ) ; if ( z < mem [ h + 2 ] .cint ) mem [ h + 2 ] .cint = z ; if ( z > mem [ h + 4 ] .cint ) mem [ h + 4 ] .cint = z ; z = mem [ p + 2 ] .cint + cury + takefraction ( d , dy ) ; if ( z < mem [ h + 3 ] .cint ) mem [ h + 3 ] .cint = z ; if ( z > mem [ h + 5 ] .cint ) mem [ h + 5 ] .cint = z ; dx = - (integer) dx ; dy = - (integer) dy ; } while ( i++ < for_end ) ; } } if ( mem [ p ] .hhfield .b1 == 0 ) goto lab10 ; else do { q = p ; p = mem [ p ] .hhfield .v.RH ; } while ( ! ( mem [ p ] .hhfield .b1 == 0 ) ) ; } } lab10: ; } void zsetbbox ( h , toplevel ) halfword h ; boolean toplevel ; {/* 10 */ halfword p ; scaled sminx, sminy, smaxx, smaxy ; scaled x0, x1, y0, y1 ; integer lev ; switch ( mem [ h + 6 ] .hhfield .lhfield ) {case 0 : ; break ; case 1 : if ( internal [ 33 ] > 0 ) initbbox ( h ) ; break ; case 2 : if ( internal [ 33 ] <= 0 ) initbbox ( h ) ; break ; } while ( mem [ mem [ h + 6 ] .hhfield .v.RH ] .hhfield .v.RH != 0 ) { p = mem [ mem [ h + 6 ] .hhfield .v.RH ] .hhfield .v.RH ; mem [ h + 6 ] .hhfield .v.RH = p ; switch ( mem [ p ] .hhfield .b0 ) {case 6 : if ( toplevel ) confusion ( 590 ) ; else goto lab10 ; break ; case 1 : { pathbbox ( mem [ p + 1 ] .hhfield .v.RH ) ; adjustbbox ( h ) ; } break ; case 5 : if ( internal [ 33 ] > 0 ) mem [ h + 6 ] .hhfield .lhfield = 2 ; else { mem [ h + 6 ] .hhfield .lhfield = 1 ; pathbbox ( mem [ p + 1 ] .hhfield .v.RH ) ; adjustbbox ( h ) ; lev = 1 ; while ( lev != 0 ) { if ( mem [ p ] .hhfield .v.RH == 0 ) confusion ( 591 ) ; p = mem [ p ] .hhfield .v.RH ; if ( mem [ p ] .hhfield .b0 == 5 ) incr ( lev ) ; else if ( mem [ p ] .hhfield .b0 == 7 ) decr ( lev ) ; } mem [ h + 6 ] .hhfield .v.RH = p ; } break ; case 7 : if ( internal [ 33 ] <= 0 ) confusion ( 591 ) ; break ; case 2 : { pathbbox ( mem [ p + 1 ] .hhfield .v.RH ) ; x0 = bbmin [ 0 ] ; y0 = bbmin [ 1 ] ; x1 = bbmax [ 0 ] ; y1 = bbmax [ 1 ] ; penbbox ( mem [ p + 1 ] .hhfield .lhfield ) ; bbmin [ 0 ] = bbmin [ 0 ] + x0 ; bbmin [ 1 ] = bbmin [ 1 ] + y0 ; bbmax [ 0 ] = bbmax [ 0 ] + x1 ; bbmax [ 1 ] = bbmax [ 1 ] + y1 ; adjustbbox ( h ) ; if ( ( mem [ mem [ p + 1 ] .hhfield .v.RH ] .hhfield .b0 == 0 ) && ( mem [ p + 6 ] .hhfield .b0 == 2 ) ) boxends ( mem [ p + 1 ] .hhfield .v.RH , mem [ p + 1 ] .hhfield .lhfield , h ) ; } break ; case 3 : { x1 = takescaled ( mem [ p + 10 ] .cint , mem [ p + 5 ] .cint ) ; y0 = takescaled ( mem [ p + 11 ] .cint , - (integer) mem [ p + 7 ] .cint ) ; y1 = takescaled ( mem [ p + 11 ] .cint , mem [ p + 6 ] .cint ) ; bbmin [ 0 ] = mem [ p + 8 ] .cint ; bbmax [ 0 ] = bbmin [ 0 ] ; if ( y0 < y1 ) { bbmin [ 0 ] = bbmin [ 0 ] + y0 ; bbmax [ 0 ] = bbmax [ 0 ] + y1 ; } else { bbmin [ 0 ] = bbmin [ 0 ] + y1 ; bbmax [ 0 ] = bbmax [ 0 ] + y0 ; } if ( x1 < 0 ) bbmin [ 0 ] = bbmin [ 0 ] + x1 ; else bbmax [ 0 ] = bbmax [ 0 ] + x1 ; x1 = takescaled ( mem [ p + 12 ] .cint , mem [ p + 5 ] .cint ) ; y0 = takescaled ( mem [ p + 13 ] .cint , - (integer) mem [ p + 7 ] .cint ) ; y1 = takescaled ( mem [ p + 13 ] .cint , mem [ p + 6 ] .cint ) ; bbmin [ 1 ] = mem [ p + 9 ] .cint ; bbmax [ 1 ] = bbmin [ 1 ] ; if ( y0 < y1 ) { bbmin [ 1 ] = bbmin [ 1 ] + y0 ; bbmax [ 1 ] = bbmax [ 1 ] + y1 ; } else { bbmin [ 1 ] = bbmin [ 1 ] + y1 ; bbmax [ 1 ] = bbmax [ 1 ] + y0 ; } if ( x1 < 0 ) bbmin [ 1 ] = bbmin [ 1 ] + x1 ; else bbmax [ 1 ] = bbmax [ 1 ] + x1 ; adjustbbox ( h ) ; } break ; case 4 : { pathbbox ( mem [ p + 1 ] .hhfield .v.RH ) ; x0 = bbmin [ 0 ] ; y0 = bbmin [ 1 ] ; x1 = bbmax [ 0 ] ; y1 = bbmax [ 1 ] ; sminx = mem [ h + 2 ] .cint ; sminy = mem [ h + 3 ] .cint ; smaxx = mem [ h + 4 ] .cint ; smaxy = mem [ h + 5 ] .cint ; mem [ h + 2 ] .cint = 2147483647L ; mem [ h + 3 ] .cint = 2147483647L ; mem [ h + 4 ] .cint = -2147483647L ; mem [ h + 5 ] .cint = -2147483647L ; setbbox ( h , false ) ; if ( mem [ h + 2 ] .cint < x0 ) mem [ h + 2 ] .cint = x0 ; if ( mem [ h + 3 ] .cint < y0 ) mem [ h + 3 ] .cint = y0 ; if ( mem [ h + 4 ] .cint > x1 ) mem [ h + 4 ] .cint = x1 ; if ( mem [ h + 5 ] .cint > y1 ) mem [ h + 5 ] .cint = y1 ; bbmin [ 0 ] = sminx ; bbmin [ 1 ] = sminy ; bbmax [ 0 ] = smaxx ; bbmax [ 1 ] = smaxy ; adjustbbox ( h ) ; } break ; } } if ( ! toplevel ) confusion ( 590 ) ; lab10: ; } void zsplitcubic ( p , t ) halfword p ; fraction t ; {scaled v ; halfword q, r ; q = mem [ p ] .hhfield .v.RH ; r = getnode ( 7 ) ; mem [ p ] .hhfield .v.RH = r ; mem [ r ] .hhfield .v.RH = q ; mem [ r ] .hhfield .b0 = 1 ; mem [ r ] .hhfield .b1 = 1 ; v = mem [ p + 5 ] .cint - takefraction ( mem [ p + 5 ] .cint - mem [ q + 3 ] .cint , t ) ; mem [ p + 5 ] .cint = mem [ p + 1 ] .cint - takefraction ( mem [ p + 1 ] .cint - mem [ p + 5 ] .cint , t ) ; mem [ q + 3 ] .cint = mem [ q + 3 ] .cint - takefraction ( mem [ q + 3 ] .cint - mem [ q + 1 ] .cint , t ) ; mem [ r + 3 ] .cint = mem [ p + 5 ] .cint - takefraction ( mem [ p + 5 ] .cint - v , t ) ; mem [ r + 5 ] .cint = v - takefraction ( v - mem [ q + 3 ] .cint , t ) ; mem [ r + 1 ] .cint = mem [ r + 3 ] .cint - takefraction ( mem [ r + 3 ] .cint - mem [ r + 5 ] .cint , t ) ; v = mem [ p + 6 ] .cint - takefraction ( mem [ p + 6 ] .cint - mem [ q + 4 ] .cint , t ) ; mem [ p + 6 ] .cint = mem [ p + 2 ] .cint - takefraction ( mem [ p + 2 ] .cint - mem [ p + 6 ] .cint , t ) ; mem [ q + 4 ] .cint = mem [ q + 4 ] .cint - takefraction ( mem [ q + 4 ] .cint - mem [ q + 2 ] .cint , t ) ; mem [ r + 4 ] .cint = mem [ p + 6 ] .cint - takefraction ( mem [ p + 6 ] .cint - v , t ) ; mem [ r + 6 ] .cint = v - takefraction ( v - mem [ q + 4 ] .cint , t ) ; mem [ r + 2 ] .cint = mem [ r + 4 ] .cint - takefraction ( mem [ r + 4 ] .cint - mem [ r + 6 ] .cint , t ) ; } void zremovecubic ( p ) halfword p ; {halfword q ; q = mem [ p ] .hhfield .v.RH ; mem [ p ] .hhfield .v.RH = mem [ q ] .hhfield .v.RH ; mem [ p + 5 ] .cint = mem [ q + 5 ] .cint ; mem [ p + 6 ] .cint = mem [ q + 6 ] .cint ; freenode ( q , 7 ) ; } halfword zpenwalk ( w , k ) halfword w ; integer k ; {register halfword Result; while ( k > 0 ) { w = mem [ w ] .hhfield .v.RH ; decr ( k ) ; } while ( k < 0 ) { w = mem [ w ] .hhfield .lhfield ; incr ( k ) ; } Result = w ; return(Result) ; } void zfinoffsetprep ( p , w , x0 , x1 , x2 , y0 , y1 , y2 , rise , turnamt ) halfword p ; halfword w ; integer x0 ; integer x1 ; integer x2 ; integer y0 ; integer y1 ; integer y2 ; integer rise ; integer turnamt ; {/* 10 */ halfword ww ; scaled du, dv ; integer t0, t1, t2 ; fraction t ; fraction s ; integer v ; halfword q ; q = mem [ p ] .hhfield .v.RH ; while ( true ) { if ( rise > 0 ) ww = mem [ w ] .hhfield .v.RH ; else ww = mem [ w ] .hhfield .lhfield ; du = mem [ ww + 1 ] .cint - mem [ w + 1 ] .cint ; dv = mem [ ww + 2 ] .cint - mem [ w + 2 ] .cint ; if ( abs ( du ) >= abs ( dv ) ) { s = makefraction ( dv , du ) ; t0 = takefraction ( x0 , s ) - y0 ; t1 = takefraction ( x1 , s ) - y1 ; t2 = takefraction ( x2 , s ) - y2 ; if ( du < 0 ) { t0 = - (integer) t0 ; t1 = - (integer) t1 ; t2 = - (integer) t2 ; } } else { s = makefraction ( du , dv ) ; t0 = x0 - takefraction ( y0 , s ) ; t1 = x1 - takefraction ( y1 , s ) ; t2 = x2 - takefraction ( y2 , s ) ; if ( dv < 0 ) { t0 = - (integer) t0 ; t1 = - (integer) t1 ; t2 = - (integer) t2 ; } } if ( t0 < 0 ) t0 = 0 ; t = crossingpoint ( t0 , t1 , t2 ) ; if ( t >= 268435456L ) if ( turnamt > 0 ) t = 268435456L ; else goto lab10 ; { splitcubic ( p , t ) ; p = mem [ p ] .hhfield .v.RH ; mem [ p ] .hhfield .lhfield = 16384 + rise ; decr ( turnamt ) ; v = x0 - takefraction ( x0 - x1 , t ) ; x1 = x1 - takefraction ( x1 - x2 , t ) ; x0 = v - takefraction ( v - x1 , t ) ; v = y0 - takefraction ( y0 - y1 , t ) ; y1 = y1 - takefraction ( y1 - y2 , t ) ; y0 = v - takefraction ( v - y1 , t ) ; if ( turnamt < 0 ) { t1 = t1 - takefraction ( t1 - t2 , t ) ; if ( t1 > 0 ) t1 = 0 ; t = crossingpoint ( 0 , - (integer) t1 , - (integer) t2 ) ; if ( t > 268435456L ) t = 268435456L ; incr ( turnamt ) ; if ( ( t == 268435456L ) && ( mem [ p ] .hhfield .v.RH != q ) ) mem [ mem [ p ] .hhfield .v.RH ] .hhfield .lhfield = mem [ mem [ p ] .hhfield .v.RH ] .hhfield .lhfield - rise ; else { splitcubic ( p , t ) ; mem [ mem [ p ] .hhfield .v.RH ] .hhfield .lhfield = 16384 - rise ; v = x1 - takefraction ( x1 - x2 , t ) ; x1 = x0 - takefraction ( x0 - x1 , t ) ; x2 = x1 - takefraction ( x1 - v , t ) ; v = y1 - takefraction ( y1 - y2 , t ) ; y1 = y0 - takefraction ( y0 - y1 , t ) ; y2 = y1 - takefraction ( y1 - v , t ) ; } } } w = ww ; } lab10: ; } integer zgetturnamt ( w , dx , dy , ccw ) halfword w ; scaled dx ; scaled dy ; boolean ccw ; {/* 30 */ register integer Result; halfword ww ; integer s ; integer t ; s = 0 ; if ( ccw ) { ww = mem [ w ] .hhfield .v.RH ; do { t = abvscd ( dy , mem [ ww + 1 ] .cint - mem [ w + 1 ] .cint , dx , mem [ ww + 2 ] .cint - mem [ w + 2 ] .cint ) ; if ( t < 0 ) goto lab30 ; incr ( s ) ; w = ww ; ww = mem [ ww ] .hhfield .v.RH ; } while ( ! ( t <= 0 ) ) ; lab30: ; } else { ww = mem [ w ] .hhfield .lhfield ; while ( abvscd ( dy , mem [ w + 1 ] .cint - mem [ ww + 1 ] .cint , dx , mem [ w + 2 ] .cint - mem [ ww + 2 ] .cint ) < 0 ) { decr ( s ) ; w = ww ; ww = mem [ ww ] .hhfield .lhfield ; } } Result = s ; return(Result) ; } halfword zoffsetprep ( c , h ) halfword c ; halfword h ; {/* 45 */ register halfword Result; halfword n ; halfword p, q, r, w, ww ; integer kneeded ; halfword w0 ; scaled dxin, dyin ; integer turnamt ; integer x0, x1, x2, y0, y1, y2 ; integer t0, t1, t2 ; integer du, dv, dx, dy ; integer dx0, dy0 ; integer lmaxcoef ; integer x0a, x1a, x2a, y0a, y1a, y2a ; fraction t ; fraction s ; integer u0, u1, v0, v1 ; integer ss ; schar dsign ; n = 0 ; p = h ; do { incr ( n ) ; p = mem [ p ] .hhfield .v.RH ; } while ( ! ( p == h ) ) ; dxin = mem [ mem [ h ] .hhfield .v.RH + 1 ] .cint - mem [ mem [ h ] .hhfield .lhfield + 1 ] .cint ; dyin = mem [ mem [ h ] .hhfield .v.RH + 2 ] .cint - mem [ mem [ h ] .hhfield .lhfield + 2 ] .cint ; if ( ( dxin == 0 ) && ( dyin == 0 ) ) { dxin = mem [ mem [ h ] .hhfield .lhfield + 2 ] .cint - mem [ h + 2 ] .cint ; dyin = mem [ h + 1 ] .cint - mem [ mem [ h ] .hhfield .lhfield + 1 ] .cint ; } w0 = h ; p = c ; kneeded = 0 ; do { q = mem [ p ] .hhfield .v.RH ; mem [ p ] .hhfield .lhfield = 16384 + kneeded ; kneeded = 0 ; x0 = mem [ p + 5 ] .cint - mem [ p + 1 ] .cint ; x2 = mem [ q + 1 ] .cint - mem [ q + 3 ] .cint ; x1 = mem [ q + 3 ] .cint - mem [ p + 5 ] .cint ; y0 = mem [ p + 6 ] .cint - mem [ p + 2 ] .cint ; y2 = mem [ q + 2 ] .cint - mem [ q + 4 ] .cint ; y1 = mem [ q + 4 ] .cint - mem [ p + 6 ] .cint ; lmaxcoef = abs ( x0 ) ; if ( abs ( x1 ) > lmaxcoef ) lmaxcoef = abs ( x1 ) ; if ( abs ( x2 ) > lmaxcoef ) lmaxcoef = abs ( x2 ) ; if ( abs ( y0 ) > lmaxcoef ) lmaxcoef = abs ( y0 ) ; if ( abs ( y1 ) > lmaxcoef ) lmaxcoef = abs ( y1 ) ; if ( abs ( y2 ) > lmaxcoef ) lmaxcoef = abs ( y2 ) ; if ( lmaxcoef == 0 ) goto lab45 ; while ( lmaxcoef < 134217728L ) { lmaxcoef = lmaxcoef + lmaxcoef ; x0 = x0 + x0 ; x1 = x1 + x1 ; x2 = x2 + x2 ; y0 = y0 + y0 ; y1 = y1 + y1 ; y2 = y2 + y2 ; } dx = x0 ; dy = y0 ; if ( dx == 0 ) if ( dy == 0 ) { dx = x1 ; dy = y1 ; if ( dx == 0 ) if ( dy == 0 ) { dx = x2 ; dy = y2 ; } } if ( p == c ) { dx0 = dx ; dy0 = dy ; } turnamt = getturnamt ( w0 , dx , dy , abvscd ( dy , dxin , dx , dyin ) >= 0 ) ; w = penwalk ( w0 , turnamt ) ; w0 = w ; mem [ p ] .hhfield .lhfield = mem [ p ] .hhfield .lhfield + turnamt ; dxin = x2 ; dyin = y2 ; if ( dxin == 0 ) if ( dyin == 0 ) { dxin = x1 ; dyin = y1 ; if ( dxin == 0 ) if ( dyin == 0 ) { dxin = x0 ; dyin = y0 ; } } dsign = abvscd ( dx , dyin , dxin , dy ) ; if ( dsign == 0 ) if ( dx == 0 ) if ( dy > 0 ) dsign = 1 ; else dsign = -1 ; else if ( dx > 0 ) dsign = 1 ; else dsign = -1 ; t0 = ( takefraction ( x0 , y2 ) ) / 2 - ( takefraction ( x2 , y0 ) ) / 2 ; t1 = ( takefraction ( x1 , y0 + y2 ) ) / 2 - ( takefraction ( y1 , x0 + x2 ) ) / 2 ; if ( t0 == 0 ) t0 = dsign ; if ( t0 > 0 ) { t = crossingpoint ( t0 , t1 , - (integer) t0 ) ; u0 = x0 - takefraction ( x0 - x1 , t ) ; u1 = x1 - takefraction ( x1 - x2 , t ) ; v0 = y0 - takefraction ( y0 - y1 , t ) ; v1 = y1 - takefraction ( y1 - y2 , t ) ; } else { t = crossingpoint ( - (integer) t0 , t1 , t0 ) ; u0 = x2 - takefraction ( x2 - x1 , t ) ; u1 = x1 - takefraction ( x1 - x0 , t ) ; v0 = y2 - takefraction ( y2 - y1 , t ) ; v1 = y1 - takefraction ( y1 - y0 , t ) ; } ss = takefraction ( x0 + x2 , u0 - takefraction ( u0 - u1 , t ) ) + takefraction ( y0 + y2 , v0 - takefraction ( v0 - v1 , t ) ) ; turnamt = getturnamt ( w , dxin , dyin , dsign > 0 ) ; if ( ss < 0 ) turnamt = turnamt - dsign * n ; ww = mem [ w ] .hhfield .lhfield ; du = mem [ ww + 1 ] .cint - mem [ w + 1 ] .cint ; dv = mem [ ww + 2 ] .cint - mem [ w + 2 ] .cint ; if ( abs ( du ) >= abs ( dv ) ) { s = makefraction ( dv , du ) ; t0 = takefraction ( x0 , s ) - y0 ; t1 = takefraction ( x1 , s ) - y1 ; t2 = takefraction ( x2 , s ) - y2 ; if ( du < 0 ) { t0 = - (integer) t0 ; t1 = - (integer) t1 ; t2 = - (integer) t2 ; } } else { s = makefraction ( du , dv ) ; t0 = x0 - takefraction ( y0 , s ) ; t1 = x1 - takefraction ( y1 , s ) ; t2 = x2 - takefraction ( y2 , s ) ; if ( dv < 0 ) { t0 = - (integer) t0 ; t1 = - (integer) t1 ; t2 = - (integer) t2 ; } } if ( t0 < 0 ) t0 = 0 ; t = crossingpoint ( t0 , t1 , t2 ) ; if ( turnamt >= 0 ) if ( t2 < 0 ) t = 268435457L ; else { u0 = x0 - takefraction ( x0 - x1 , t ) ; u1 = x1 - takefraction ( x1 - x2 , t ) ; ss = takefraction ( - (integer) du , u0 - takefraction ( u0 - u1 , t ) ) ; v0 = y0 - takefraction ( y0 - y1 , t ) ; v1 = y1 - takefraction ( y1 - y2 , t ) ; ss = ss + takefraction ( - (integer) dv , v0 - takefraction ( v0 - v1 , t ) ) ; if ( ss < 0 ) t = 268435457L ; } else if ( t > 268435456L ) t = 268435456L ; if ( t > 268435456L ) finoffsetprep ( p , w , x0 , x1 , x2 , y0 , y1 , y2 , 1 , turnamt ) ; else { splitcubic ( p , t ) ; r = mem [ p ] .hhfield .v.RH ; x1a = x0 - takefraction ( x0 - x1 , t ) ; x1 = x1 - takefraction ( x1 - x2 , t ) ; x2a = x1a - takefraction ( x1a - x1 , t ) ; y1a = y0 - takefraction ( y0 - y1 , t ) ; y1 = y1 - takefraction ( y1 - y2 , t ) ; y2a = y1a - takefraction ( y1a - y1 , t ) ; finoffsetprep ( p , w , x0 , x1a , x2a , y0 , y1a , y2a , 1 , 0 ) ; x0 = x2a ; y0 = y2a ; mem [ r ] .hhfield .lhfield = 16383 ; if ( turnamt >= 0 ) { t1 = t1 - takefraction ( t1 - t2 , t ) ; if ( t1 > 0 ) t1 = 0 ; t = crossingpoint ( 0 , - (integer) t1 , - (integer) t2 ) ; if ( t > 268435456L ) t = 268435456L ; splitcubic ( r , t ) ; mem [ mem [ r ] .hhfield .v.RH ] .hhfield .lhfield = 16385 ; x1a = x1 - takefraction ( x1 - x2 , t ) ; x1 = x0 - takefraction ( x0 - x1 , t ) ; x0a = x1 - takefraction ( x1 - x1a , t ) ; y1a = y1 - takefraction ( y1 - y2 , t ) ; y1 = y0 - takefraction ( y0 - y1 , t ) ; y0a = y1 - takefraction ( y1 - y1a , t ) ; finoffsetprep ( mem [ r ] .hhfield .v.RH , w , x0a , x1a , x2 , y0a , y1a , y2 , 1 , turnamt ) ; x2 = x0a ; y2 = y0a ; finoffsetprep ( r , ww , x0 , x1 , x2 , y0 , y1 , y2 , -1 , 0 ) ; } else finoffsetprep ( r , ww , x0 , x1 , x2 , y0 , y1 , y2 , -1 , -1 - turnamt ) ; } w0 = penwalk ( w0 , turnamt ) ; lab45: ; do { r = mem [ p ] .hhfield .v.RH ; if ( mem [ p + 1 ] .cint == mem [ p + 5 ] .cint ) if ( mem [ p + 2 ] .cint == mem [ p + 6 ] .cint ) if ( mem [ p + 1 ] .cint == mem [ r + 3 ] .cint ) if ( mem [ p + 2 ] .cint == mem [ r + 4 ] .cint ) if ( mem [ p + 1 ] .cint == mem [ r + 1 ] .cint ) if ( mem [ p + 2 ] .cint == mem [ r + 2 ] .cint ) if ( r != p ) { kneeded = mem [ p ] .hhfield .lhfield - 16384 ; if ( r == q ) q = p ; else { mem [ p ] .hhfield .lhfield = kneeded + mem [ r ] .hhfield .lhfield ; kneeded = 0 ; } if ( r == c ) { mem [ p ] .hhfield .lhfield = mem [ c ] .hhfield .lhfield ; c = p ; } if ( r == specp1 ) specp1 = p ; if ( r == specp2 ) specp2 = p ; r = p ; removecubic ( p ) ; } p = r ; } while ( ! ( p == q ) ) ; } while ( ! ( q == c ) ) ; specoffset = mem [ c ] .hhfield .lhfield - 16384 ; if ( mem [ c ] .hhfield .v.RH == c ) mem [ c ] .hhfield .lhfield = 16384 + n ; else { mem [ c ] .hhfield .lhfield = mem [ c ] .hhfield .lhfield + kneeded ; while ( w0 != h ) { mem [ c ] .hhfield .lhfield = mem [ c ] .hhfield .lhfield + 1 ; w0 = mem [ w0 ] .hhfield .v.RH ; } while ( mem [ c ] .hhfield .lhfield <= 16384 - n ) mem [ c ] .hhfield .lhfield = mem [ c ] .hhfield .lhfield + n ; while ( mem [ c ] .hhfield .lhfield > 16384 ) mem [ c ] .hhfield .lhfield = mem [ c ] .hhfield .lhfield - n ; if ( ( mem [ c ] .hhfield .lhfield != 16384 ) && ( abvscd ( dy0 , dxin , dx0 , dyin ) >= 0 ) ) mem [ c ] .hhfield .lhfield = mem [ c ] .hhfield .lhfield + n ; } Result = c ; return(Result) ; }