P op_resizewindow(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else P width, height; P k; if (dvtdisplay == NULL) return NO_XWINDOWS; if (o_3 < FLOORopds) return OPDS_UNF; if (CLASS(o_3) != NUM) return OPD_CLA; if (!PVALUE(o_3,&wid)) return UNDF_VAL; if (CLASS(o_2) != NUM) return OPD_CLA; if (!PVALUE(o_2,&width)) return UNDF_VAL; if (CLASS(o_1) != NUM) return OPD_CLA; if (!PVALUE(o_1,&height)) return UNDF_VAL; for (k = 0; k < ndvtwindows; k++) if (dvtwindows[k] == wid) { resizewindow(width, height); break; } FREEopds = o_3; return OK; #endif }
// n k | (n/k) DM_INLINE_STATIC P combinations(void) { P n, k, i, j; if (o_2 < FLOORopds) return OPDS_UNF; if (CLASS(o_1) != NUM) return OPD_CLA; if (CLASS(o_2) != NUM) return OPD_CLA; if (! PVALUE(o_2, &n)) return UNDF_VAL; if (! PVALUE(o_1, &k)) return UNDF_VAL; if (n < 0 || k < 0 || n < k) return RNG_CHK; if (n > max_kn) return RNG_CHK; TAG(o_2) = (NUM | DOUBLETYPE); ATTR(o_2) = 0; FREEopds = o_1; if (n == k || k == 0) { *(D*) NUM_VAL(o_1) = 1; return OK; } if (n <= max_n) { *(D*) NUM_VAL(o_1) = binom[n][k]; return OK; } for (i = max_n+1; i <= n; ++i) { binom[i][0] = binom[i][i] = 1; for (j = 1; j < i; ++j) { binom[i][j] = binom[i-1][j-1] + binom[i-1][j]; } } max_n = n; *(D*) NUM_VAL(o_1) = binom[n][k]; return OK; }
// x l | Pl(x) DM_INLINE_STATIC P legendre(void) { P l, i; D x, Px, Px_1, Px_2; if (o_2 < FLOORopds) return OPDS_UNF; if (CLASS(o_1) != NUM) return OPD_CLA; if (! PVALUE(o_1, &l)) return UNDF_VAL; if (l < 0) return RNG_CHK; if (TAG(o_2) != (NUM | DOUBLETYPE)) return OPD_TYP; FREEopds = o_1; if (l == 0) { *(D*) NUM_VAL(o_1) = 1; return OK; } Px = x = *(D*) NUM_VAL(o_1); Px_1 = 1; for (i = 2; i <= l; ++i) { Px_2 = Px_1; Px_1 = Px; Px = ((D)(2*i-1))/i*x*Px_1 - ((D)(i-1))/i*Px_2; } *(D*) NUM_VAL(o_1) = Px; return OK; }
P op_drawline(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else B *xyf, *freevm; P retc, k; if (dvtdisplay == NULL) return NO_XWINDOWS; if (o_1 < FLOORopds) return OPDS_UNF; freevm = FREEvm; if ((retc = coloropd()) != OK) return retc; if ((retc = xy(&xyf,&freevm)) != OK) return retc; if (ARRAY_SIZE(xyf) < 4) return RNG_CHK; if (o_1 < FLOORopds) return (OPDS_UNF); if (CLASS(o_1) != NUM) return OPD_CLA; if (!PVALUE(o_1,&wid)) return UNDF_VAL; FREEopds = o_1; for (k = 0; k < ndvtwindows; k++) if (dvtwindows[k] == wid) break; if (k >= ndvtwindows) return OK; HXDrawLines(dvtdisplay,wid,dvtgc,(XPoint *)VALUE_BASE(xyf), ARRAY_SIZE(xyf)>>1, CoordModeOrigin); return OK; #endif }
P op_fillrectangle(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else B *xyf, *freevm; P retc, k; if (dvtdisplay == NULL) return NO_XWINDOWS; freevm = FREEvm; if ((retc = coloropd()) != OK) return retc; if ((retc = xy(&xyf,&freevm)) != OK) return retc; if (ARRAY_SIZE(xyf) != 4) return RNG_CHK; if (o_1 < FLOORopds) return (OPDS_UNF); if (CLASS(o_1) != NUM) return OPD_CLA; if (!PVALUE(o_1,&wid)) return UNDF_VAL; FREEopds = o_1; for (k = 0; k < ndvtwindows; k++) if (dvtwindows[k] == wid) break; if (k >= ndvtwindows) return OK; HXFillRectangles(dvtdisplay,wid,dvtgc,(XRectangle *)VALUE_BASE(xyf),1); return OK; #endif }
P op_mapwindow(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else P k; if (dvtdisplay == NULL) return NO_XWINDOWS; if (o_2 < FLOORopds) return OPDS_UNF; if (CLASS(o_1) != BOOL) return OPD_CLA; switch (CLASS(o_2)) { case NULLOBJ: for (k = 0; k < ndvtwindows; k++) if (BOOL_VAL(o_1)) mapraisewindow(dvtwindows[k]); else HXUnmapWindow(dvtdisplay, dvtwindows[k]); break; case NUM: if (!PVALUE(o_2,&wid)) return UNDF_VAL; for (k = 0; k < ndvtwindows && dvtwindows[k] != wid; k++); if (k == ndvtwindows) break; if (BOOL_VAL(o_1)) mapraisewindow(wid); else HXUnmapWindow(dvtdisplay,wid); break; default: return OPD_CLA; }; FREEopds = o_2; return OK; #endif }
/*------------------------------------------------ topwindow * * window# true | -- * * make window float above other iff true */ P op_makewindowtop(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else P k; XEvent event; if (dvtdisplay == NULL) return NO_XWINDOWS; if (o_2 < FLOORopds) return OPDS_UNF; if (CLASS(o_1) != BOOL || CLASS(o_2) != NUM) return OPD_CLA; if (!PVALUE(o_2, &wid)) return UNDF_VAL; FREEopds = o_2; for (k = 0; k < ndvtwindows && dvtwindows[k] != wid; k++); if (k == ndvtwindows) return OK; event.xclient.type = ClientMessage; event.xclient.display = dvtdisplay; event.xclient.window = wid; event.xclient.message_type = HXInternAtom(dvtdisplay, "_NET_WM_STATE", False); event.xclient.format = 32; event.xclient.data.l[0] = (BOOL_VAL(o2) ? 1 : 0); event.xclient.data.l[1] = HXInternAtom(dvtdisplay, "_NET_WM_STATE_ABOVE", False); event.xclient.data.l[2] = 0; event.xclient.data.l[3] = 2; event.xclient.data.l[4] = 0; HXSendEvent(dvtdisplay, XRootWindowOfScreen(dvtscreen), False, (SubstructureNotifyMask|SubstructureRedirectMask), &event); return OK; #endif }
P coloropd(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else if (o_1 < FLOORopds) return OPDS_UNF; if (CLASS(o_1) != NUM) return OPD_CLA; if (!PVALUE(o_1,&colidx)) return UNDF_VAL; HXSetForeground(dvtdisplay,dvtgc,colidx); FREEopds = o_1; return OK; #endif }
P op_deletewindow(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else P k; if (dvtdisplay == NULL) return NO_XWINDOWS; if (o_1 < FLOORopds) return OPDS_UNF; if (CLASS(o_1) != NUM) return OPD_CLA; if (!PVALUE(o_1,&wid)) return UNDF_VAL; k = 0; while (1) { if (k >= ndvtwindows) { FREEopds = o_1; return OK; } if (dvtwindows[k] == wid) break; k++; } --ndvtwindows; for ( ; k<ndvtwindows; k++) dvtwindows[k] = dvtwindows[k+1]; HXDestroyWindow(dvtdisplay,wid); FREEopds = o_1; return OK; #endif }
void HandleMBlare(LPMYOBJ lpOb){ LPMBLARESTATE State=lpOb->MBlare; int Status, N; static ActTime; if (GameFrozen||NowReplaying) return; lpD3DDevice->lpVtbl->GetMatrix(lpD3DDevice, CurrCameraM, &CameraMat); Status=State->Status; if (Status==MB_SLEEPING) { State->MBOK=FALSE; return; } if (Status==MB_STARTED) { GET_NEXT_POINT(State->LastPoints[0]); State->Status=MB_ONE_POINT_VALID; // lpOb->Flags=TRANSPARENTOBJ|lpOb->Flags; //OBROBRIOOOOO!!!!!!!! State->FirstVertex=0; State->CV1.x=PVALUE(0.); State->CV1.y=PVALUE(1.); State->CV1.z=PVALUE(0.); if (!(State->MBOK)) State->Status=MB_SLEEPING; State->MBOK=FALSE; } else if (Status==MB_ONE_POINT_VALID) { GET_NEXT_POINT(State->LastPoints[1]); State->Status=MB_TWO_POINTS_VALIDS; State->VertexDrawn=2; State->StripsDrawn=0; if (!(State->MBOK)) State->Status=MB_SLEEPING; State->MBOK=FALSE; } else if (Status==MB_TWO_POINTS_VALIDS) { State->PrevD=MyTime(); if ((State->CTime<=State->LTime)|| (!(State->MBOK))) { State->Status=MB_SLEEPING; RENDERSTRIP(); State->MBOK=FALSE; return; } if (State->CTime-State->LTime>=State->IncTime){ GET_CURR_POINT(); if (ComputeNewStrip(State)) { State->StripsDrawn++; State->VertexDrawn+=2; UpdateTextureCoordinates(State); State->LTime+=State->IncTime; PUSH_NEW_POINT(); } } RENDERSTRIP(); State->MBOK=FALSE; } else if (State->Status==MB_DISAPPEARING){ if (State->StripsDrawn>0){ State->DeltaD=DISAPPARITION_TIME/State->StripsDrawn; if (State->DeltaD<=1) State->DeltaD=1; ActTime=MyTime(); //ActTime=State->PrevD+State->DeltaD/10; N=(ActTime-State->PrevD)/State->DeltaD; if (N>0) State->PrevD+=N*State->DeltaD; State->StripsDrawn-=N; State->FirstVertex+=(N+N); } if (State->StripsDrawn<=0) { // lpOb->Flags=lpOb->Flags&(~TRANSPARENTOBJ); State->Status=MB_SLEEPING; return; } UpdateTextureCoordinates(State); RENDERSTRIP(); State->Status=MB_DISAPPEARING1; } else if (State->Status==MB_DISAPPEARING1){ //ActTime+=State->DeltaD/10; ActTime=MyTime(); N=(ActTime-State->PrevD)/State->DeltaD; if (N>0){ State->PrevD+=N*State->DeltaD; State->StripsDrawn-=N; State->FirstVertex+=(N+N); } if (State->StripsDrawn<=1) { //lpOb->Flags=lpOb->Flags&(~TRANSPARENTOBJ); State->Status=MB_SLEEPING; return; } UpdateTextureCoordinates(State); RENDERSTRIP(); } }