void BlockObj::logBlock(ExpandedModel* emrow,ExpandedModel* emcol) { ostringstream oss; oss<<GV(logdir)<<emrow->qualifiedName()<<"_"<<emcol->qualifiedName()<<".objblk"; ofstream out(oss.str().c_str()); string objname = emrow->model->obj_comp==NULL? "null":emrow->model->obj_comp->name; out<<"Objective Block - (Assume to be Partial)"<<endl; out<<"Objective Declared/Row Model: "<<emrow->name<<"\t\t Name:"<<objname<<endl; out<<"Variables Declared/Col Model: "<<emrow->name<<"\t\t Size:"<<emrow->numLocalVars<<endl; out<<endl; out<<endl<<"Local Variables:"<<endl; vector<string> conNames, varNames; std::vector<VarComp*>::iterator varcomp=emrow->model->var_comps.begin(); for(;varcomp!=emrow->model->var_comps.end();varcomp++) { Var* var = static_cast<Var*>(emrow->ctx.getCompValue(*varcomp)); var_multi_map_by_order& var_by_order = var->varMultiMap.get<0>(); var_multi_map_by_order::iterator ivar = var_by_order.begin(); for(;ivar!=var_by_order.end();ivar++) { string name = emrow->name+"_"+var->name+"_"+(*ivar)->indicies; out<<"\t"<<name<<"\t\t"<<(*ivar)->toString()<<endl; } } out<<endl<<"Object Constraint"<<endl; string node_expr = this->objective==NULL?"NULL":texpr(this->objective); out<<"\t"<<objname<<"\t\t"<<node_expr<<endl; //printing dependent block information out<<endl; out.flush(); }
void SMove(void *p, int x, int y) { GXHEADER local; GV(&local, 160, 100); memcpy(local.vptr, p, 160 * 100); gxPutImage(&local, gxSET, x, y, 0); DV(&local); }
void OpenEmUp(void) { randomize(); seq_init(); GV(&vhptr, 320, 200); // Allocate only Virtual Buffer letter_dat = slurp_gamedat("letter.dat"); }
void LMove(void *p) { GXHEADER local; memset(screen, 0, 320 * 200); GV(&local, 160, 100); memcpy(local.vptr, p, 160 * 100); gxPutImage(&local, gxSET, 320 / 4, 200 / 4, 0); DV(&local); }
void PresPict(char poff) { GXHEADER local; SimpleHdr table; FILE *in; in = sOpen("PRESR.BUT", "rb", 0); fseek(in, poff * sizeof_SimpleHdr, SEEK_SET); fread_SimpleHdr(&table, 1, in); fseek(in, table.offset, SEEK_SET); fread(&pal[96], 672, 1, in); fread(buffer, table.size, 1, in); fclose(in); GV(&local, 126, 84); RLED_img(buffer, local.vptr, table.size, local.w, local.h); gxPutImage(&local, gxSET, 183, 33, 0); DV(&local); return; }
void Future(char plr) { /** \todo the whole Future()-function is 500 >lines and unreadable */ TRACE1("->Future(plr)"); int MisNum = 0, DuraType = 0, MaxDur = 6, i, ii; int setting = -1, prev_setting = -1; int Ok, NewType; GXHEADER local, local2; GV(&local, 166, 9); GV(&local2, 177, 197); GV(&vh,240,90); /* global variable */ begfut: MisNum = FutureCheck(plr, 0); if (MisNum == 5) { DV(&local); DV(&local2); DV(&vh); return; } F1 = F2 = F3 = F4 = FMen = F5 = 0; // memset(buffer, 0x00, 20000); for (i = 0; i < 5; i++) lck[i] = status[i] = 0; SetParameters(); strcpy(IDT, "i011"); Pad = MisNum; DuraType = FMen = MisType = 0; ClrFut(plr, MisNum); DrawFuture(plr, MisType, MisNum); begfut_noredraw: // for (i=0;i<5;i++) ClearRX(i+1); while (1) { GetMouse(); if (mousebuttons == 0) break; } while (1) { GetMouse(); prev_setting = setting; setting = -1; if (key == '-' && SEG > 1) SEG--; if (key == '+' && SEG < 500) SEG++; if (key >= 65 && key < Bub_Count + 65) setting = key - 65; for (ii = 0; ii < Bub_Count; ii++) { if (x >= StepBub[ii].x_cor && x <= StepBub[ii].x_cor + 7 && y >= StepBub[ii].y_cor && y <= StepBub[ii].y_cor + 7) setting = ii; } if (setting >= 0) { if (prev_setting < 0) gxGetImage(&local, 18, 186, 183, 194, 0); if (prev_setting != setting) { ShBox(18, 186, 183, 194); grSetColor(1); MisStep(21, 192, Mev[setting].loc); } } else if (setting < 0 && prev_setting >= 0) { gxPutImage(&local, gxSET, 18, 186, 0); } if (Mis.Dur <= V[MisType].E && ((x >= 244 && y >= 5 && x <= 313 && y <= 17 && mousebuttons > 0) || key == K_ENTER)) { InBox(244, 5, 313, 17); WaitForMouseUp(); if (key > 0) delay(300); key = 0; OutBox(244, 5, 313, 17); gxGetImage(&local2, 74, 3, 250, 199, 0); NewType = V[MisType].X; Data->P[plr].Future[MisNum].Duration = DuraType; Ok = HardCrewAssign(plr, Pad, MisType, NewType); gxPutImage(&local2, gxSET, 74, 3, 0); // DV(&local2); if (Ok == 1) { Data->P[plr].Future[MisNum].Duration = DuraType; goto begfut; // return to loop } else { ClrFut(plr, MisNum); // DuraType = FMen = MisType = 0; key = 0; goto begfut_noredraw; // DrawFuture(plr, MisType, MisNum); } key = 0; }; // continue if ((((x >= 5 && y >= 49 && x <= 53 && y <= 72) || (x >= 43 && y >= 74 && x <= 53 && y <= 82)) && mousebuttons > 0) || (key == '!' || key == '1')) { if ((x >= 43 && y >= 74 && x <= 53 && y <= 82) || key == '!') { lck[0] = abs(lck[0] - 1); if (lck[0] == 1) InBox(43, 74, 53, 82); else OutBox(43, 74, 53, 82); if (lck[0] == 1) F5 = (status[0] == 0) ? -1 : status[0]; if (lck[0] == 1) PlaceRX(1); else ClearRX(1); if (lck[0] == 0) { F5 = 0; status[0] = 0; } while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[0] != 1) { InBox(5, 49, 53, 72); if (DuraType == MaxDur) DuraType = 0; else DuraType++; Data->P[plr].Future[MisNum].Duration = DuraType; if (DuraType == 0) Toggle(5, 0); else if (DuraType == 1) Toggle(5, 1); if (DuraType != 0) draw_Pie(DuraType); status[0] = DuraType; while (1) { GetMouse(); if (mousebuttons == 0) break; } grSetColor(34); OutBox(5, 49, 53, 72); }; key = 0; /* Duration */ }; if ((x >= 5 && y >= 74 && x <= 41 && y <= 82 && mousebuttons > 0) || (key == K_ESCAPE)) { InBox(5, 74, 41, 82); while (1) { GetMouse(); if (mousebuttons == 0) break; } MisType = 0; if (DuraType != 0) Toggle(5, 0); FMen = DuraType = F1 = F2 = F3 = F4 = F5 = 0; for (i = 1; i < 4; i++) if (status[i] != 0) Toggle(i, 1); if (JointFlag == 0) { F4 = 2; lck[4] = 1; Toggle(4, 1); InBox(191, 74, 201, 82); PlaceRX(5); TogBox(166, 49, 1); } else { F4 = 0; lck[4] = 0; status[4] = 0; Toggle(4, 1); OutBox(191, 74, 201, 82); ClearRX(5); TogBox(166, 49, 0); }; for (i = 0; i < 4; i++) { lck[i] = status[i] = 0; } OutBox(5, 49, 53, 72); OutBox(43, 74, 53, 82); TogBox(55, 49, 0); OutBox(80, 74, 90, 82); TogBox(92, 49, 0); OutBox(117, 74, 127, 82); TogBox(129, 49, 0); OutBox(154, 74, 164, 82); ClrFut(plr, MisNum); Data->P[plr].Future[MisNum].Duration = 0; Missions(plr, 8, 37, MisType, 1); GetMinus(plr); OutBox(5, 74, 41, 82); key = 0; /* Reset */ }; if ((x >= 55 && y >= 49 && x <= 90 && y <= 82 && mousebuttons > 0) || (key == '2' || key == '@')) { if ((x >= 80 && y >= 74 && x <= 90 && y <= 82) || (key == '@')) { if (lck[1] == 0) InBox(80, 74, 90, 82); else OutBox(80, 74, 90, 82); lck[1] = abs(lck[1] - 1); if (lck[1] == 1) PlaceRX(2); else ClearRX(2); if ((status[1] == 0) && (lck[1] == 1)) F1 = 2; else if ((status[1] == 1) && (lck[1] == 1)) F1 = 1; else F1 = 0; while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[1] != 1) { TogBox(55, 49, 1); if (status[1] == 0) Toggle(1, 1); else Toggle(1, 0); status[1] = abs(status[1] - 1); while (1) { GetMouse(); if (mousebuttons == 0) break; } TogBox(55, 49, 0); }; /* Docking */ key = 0; }; if ((x >= 92 && y >= 49 && x <= 127 && y <= 82 && mousebuttons > 0) || (key == '3' || key == '#')) { if ((x >= 117 && y >= 74 && x <= 127 && y <= 82) || (key == '#')) { if (lck[2] == 0) InBox(117, 74, 127, 82); else OutBox(117, 74, 127, 82); lck[2] = abs(lck[2] - 1); if (lck[2] == 1) PlaceRX(3); else ClearRX(3); if ((status[2] == 0) && (lck[2] == 1)) F2 = 2; else if ((status[2] == 1) && (lck[2] == 1)) F2 = 1; else F2 = 0; while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[2] != 1) { TogBox(92, 49, 1); if (status[2] == 0) Toggle(2, 1); else { Toggle(2, 0); }; status[2] = abs(status[2] - 1); while (1) { GetMouse(); if (mousebuttons == 0) break; } TogBox(92, 49, 0); }; /* EVA */ key = 0; }; if ((x >= 129 && y >= 49 && x <= 164 && y <= 82 && mousebuttons > 0) || (key == '4' || key == '$')) { if ((x >= 154 && y >= 74 && x <= 164 && y <= 82) || (key == '$')) { if (lck[3] == 0) InBox(154, 74, 164, 82); else OutBox(154, 74, 164, 82); lck[3] = abs(lck[3] - 1); // F3=lck[3]; if (lck[3] == 1) PlaceRX(4); else ClearRX(4); if ((status[3] == 0) && (lck[3] == 1)) F3 = 2; else if ((status[3] == 1) && (lck[3] == 1)) F3 = 1; else F3 = 0; while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[3] != 1) { TogBox(129, 49, 1); if (status[3] == 0) Toggle(3, 1); else { Toggle(3, 0); }; status[3] = abs(status[3] - 1); while (1) { GetMouse(); if (mousebuttons == 0) break; } TogBox(129, 49, 0); }; /* LEM */ key = 0; }; if (((x >= 166 && y >= 49 && x <= 201 && y <= 82 && mousebuttons > 0) || (key == '5' || key == '%')) && (JointFlag == 1)) { if ((x > 191 && y >= 74 && x <= 201 && y <= 82) || (key == '%')) { if (lck[4] == 0) InBox(191, 74, 201, 82); else OutBox(191, 74, 201, 82); lck[4] = abs(lck[4] - 1); if (lck[4] == 1) PlaceRX(5); else ClearRX(5); if ((status[4] == 0) && (lck[4] == 1)) F4 = 2; else if ((status[4] == 1) && (lck[4] == 1)) F4 = 1; else F4 = 0; while (1) { GetMouse(); if (mousebuttons == 0) break; } } else if (lck[4] != 1) { TogBox(166, 49, 1); status[4] = abs(status[4] - 1); if (status[4] == 0) { Toggle(4, 1); } else { Toggle(4, 0); } while (1) { GetMouse(); if (mousebuttons == 0) break; } TogBox(166, 49, 0); }; /* Joint Launch */ key = 0; }; if ((x >= 5 && y >= 84 && x <= 16 && y <= 130 && mousebuttons > 0) || (key == UP_ARROW)) { InBox(5, 84, 16, 130); for (i = 0; i < 50; i++) { key = 0; GetMouse(); delay(10); if (mousebuttons == 0) { MisType = UpSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; i = 51; } } while (mousebuttons == 1 || key == UP_ARROW) { MisType = UpSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; delay(100); key = 0; GetMouse(); } Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; OutBox(5, 84, 16, 130); key = 0; /* Mission Type plus */ }; if ((x >= 5 && y >= 132 && x < 16 && y <= 146 && mousebuttons > 0) || (key == K_SPACE)) { InBox(5, 132, 16, 146); WaitForMouseUp(); delay(50); MisType = Data->P[plr].Future[MisNum].MissionCode; assert(0 <= MisType); if (MisType != 0){ Missions(plr, 8, 37, MisType, 1); } else{ Missions(plr, 8, 37, MisType, 3); } OutBox(5, 132, 16, 146); key = 0; } if ((x >= 5 && y >= 148 && x <= 16 && y <= 194 && mousebuttons > 0) || (key == DN_ARROW)) { InBox(5, 148, 16, 194); for (i = 0; i < 50; i++) { key = 0; GetMouse(); delay(10); if (mousebuttons == 0) { MisType = DownSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; i = 51; } key = 0; } while (mousebuttons == 1 || key == DN_ARROW) { MisType = DownSearchRout(MisType, plr); Data->P[plr].Future[MisNum].MissionCode = MisType; Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; delay(100); key = 0; GetMouse(); } Missions(plr, 8, 37, MisType, 3); DuraType = status[0]; OutBox(5, 148, 16, 194); key = 0; /* Mission Type minus */ }; } // while TRACE1("<-Future()"); }
double Controller::update(Angle angle, double speed, double inReward, vec inLmr, int color) { if(t%inv_sampling_rate == 0 && !SILENT){ pi_array = join_rows(pi_array, pin->get_output()); if(gvlearn_on){ gv_array = join_rows(gv_array, gvl->w(0)); } if(lvlearn_on){ for(int i = 0; i < lv_array.size(); i++) lv_array.at(i) = join_rows(lv_array.at(i), lvl->w(i)); ref_array = join_rows(ref_array, lvl->RefPI()); } } t++; /*** Check, if inward ***/ if(t > t_home || accum_reward(0) > 1.){ inward = 1.; //printf("t= %u > %u or sum(R)= %g\n", t, t_home, accum_reward(0)); } /*** Path Integration Mechanism ***/ if(pin_on) pin->update(angle, speed); if(gvlearn_on && gl_w > 0.) pi_w = HV().len() * (1. - expl_factor(0))*(1.-accu(lv_value)); else pi_w = 0.0; pi_m = ((HV().ang()).i() - angle).S(); //NEW PI COMMAND if(homing_on && inward!=0.){ //printf("this should not be! %g\n", inward); pi_w = 0.5; pi_m = ((HV().ang()).i() - angle).S(); rand_m = 0.0;//0.25; } if(pi_w < 0.) pi_w = 0.; output_hv = pi_w * pi_m; /*** Reward and value update ***/ if(lvlearn_on){ for(int i = 0; i < num_lv_units; i++) lv_value(i) = 1. - exp(-0.5*lvl->eligibility_value(i)); } delta_beta = mu_beta*((1./expl_beta) + lambda * value(0) * expl_factor(0)); if(beta_on) expl_beta += delta_beta; if(expl_factor(0) < 0.0001 && delta_beta < 0.01) beta_on = false; for(int i = 0; i < num_colors; i++){ if(i == color){ reward(i) = inReward; if(inward==0.){ value(i) = (reward(i) /*+ accu(lv_value)*/) + disc_factor * value(i); if(!const_expl) expl_factor(i) = exp(- expl_beta * value(i)); else expl_factor(i) += d_expl_factor(i); expl_factor.elem( find(expl_factor > 1.) ).ones(); //clip expl expl_factor.elem( find(expl_factor < 0.) ).zeros(); //clip expl } } else{ reward(i) = 0.0; } } accum_reward += reward; /*** Global Vector Learning Circuits TODO ***/ if(gvlearn_on){ for(int i = 0; i < num_colors; i++){ gvl->update(pin->get_output(), reward(i), expl_factor(i)); cGV.at(i) = (GV(i) - HV()); } gl_w = (1. - inward)*GV(0).len() * (1.-expl_factor(0)); gl_m = (GV(0).ang() - angle).S(); //NEW GV COMMAND } //stream << cGV.at(0).ang().deg() << endl; output_gv = gl_w * gl_m; /*** Local Vector Learning Circuits TODO ***/ if(lvlearn_on){ lvl->update(angle, speed, inReward, inLmr); rl_m = 0.0; rl_w = (1. - inward); for(int i = 0; i < num_lv_units; i++){ //cLV.at(i) = (LV(i) - HV()); if(inward == 0.){ gl_w = 0.0; pi_w = 0.0; rl_m += lv_value(i) * (LV().len()*(LV().ang() - angle).S() + RV().len()*(RV().ang().i() - angle).S()); } } //if(VERBOSE && t%100==0) //printf("t = %u\tHV = (%f, %f)\tLV = (%f, %f)\tRV = (%f, %f)\n", t, HV().ang().deg(), HV().len(), LV().ang().deg(), LV().len(), RV().ang().deg(), RV().len()); output_lv = rl_w * rl_m; } else output_lv = 0.; /*** Random foraging ***/ if(lvlearn_on){ rand_w = (1. - inward)*0.6*expl_factor(0)*(1.-accu(lv_value)); } else rand_w = (1. - inward)*0.6*expl_factor(0); rand_m = randn(0.0, 1.); if(inward == 1) rand_m = 0.; output_rand = rand_w * rand_m; /*** Navigation Control Output ***/ output = output_rand + output_hv + output_gv + output_lv; //output = output_rand + output_hv + 0.0 + output_lv; // Route formation return output; }
CVarRef GlobalVariables::getRefByIdx(ssize_t idx, Variant &k) { GlobalVariables *g __attribute__((__unused__)) = this; static const char *names[] = { "argc", "argv", "_SERVER", "_GET", "_POST", "_COOKIE", "_FILES", "_ENV", "_REQUEST", "_SESSION", "HTTP_RAW_POST_DATA", "http_response_header", }; if (idx >= 0 && idx < 12) { k = names[idx]; switch (idx) { case 0: return GV(argc); case 1: return GV(argv); case 2: return GV(_SERVER); case 3: return GV(_GET); case 4: return GV(_POST); case 5: return GV(_COOKIE); case 6: return GV(_FILES); case 7: return GV(_ENV); case 8: return GV(_REQUEST); case 9: return GV(_SESSION); case 10: return GV(HTTP_RAW_POST_DATA); case 11: return GV(http_response_header); } } return Globals::getRefByIdx(idx, k); }
/* * trace one stream line for 2-D u and v arrays. * Note that the input arrays ugrid & vgrid should be in * column-major (FORTRAN) order. * * Input: ugrid, vgrid - the 2-D wind arrays. * nr, nc - size of 2-D array in rows and columns. * vr, vc - arrays to put streamline vertices * dir - direction 1.0=forward, -1.0=backward * maxv - size of vx, vy arrays * numv - pointer to int to return number of vertices in vx, vy * markarrow - mark array for arrows * markstart - mark array for starting streamlines * markend - mark array for ending streamlines * nrarrow, ncarrow - size of markarrow * nrstart, ncstart - size of markstart * nrend, ncend - size of markend * row, col - start location for streamline * step - step size for streamline * rowlength, collength - scale constants for arrows * irend, icend - location of most recent end box * Return: 1 = ok * 0 = no more memory for streamlines */ int stream_trace( Context ctx, float ugrid[], float vgrid[], int nr, int nc, float dir, float vr[], float vc[], int maxv, int *numv, char *markarrow, char *markstart, char *markend, int nrarrow, int ncarrow, int nrstart, int ncstart, int nrend, int ncend, float row, float col, float step, float rowlength, float collength, int irend, int icend) { int ir, ic, ire, ice; int ira, ica, irs, ics; int nend, num; float prevrow, prevcol; float a, c, ac, ad, bc, bd; float u, v; num = *numv; nend = 0; while (1) { float ubd, ubc, uad, uac, vbd, vbc, vad, vac; /* interpolate velocity at row, col */ ir = row; ic = col; a = row - ir; c = col - ic; ac = a*c; ad = a*(1.0-c); bc = (1.0-a)*c; bd = (1.0-a)*(1.0-c); ubd = GU(ir, ic); ubc = GU(ir, ic+1); uad = GU(ir+1, ic); uac = GU(ir+1, ic+1); vbd = GV(ir, ic); vbc = GV(ir, ic+1); vad = GV(ir+1, ic); vac = GV(ir+1, ic+1); /* terminate stream if missing data */ if (IS_MISSING(ubd) || IS_MISSING(ubc) || IS_MISSING(uad) || IS_MISSING(uac) || IS_MISSING(vbd) || IS_MISSING(vbc) || IS_MISSING(vad) || IS_MISSING(vac)) break; u = bd * ubd + bc * ubc + ad * uad + ac * uac; v = bd * vbd + bc * vbc + ad * vad + ac * vac; /* WLH 5 July 96 u = bd * GU(ir, ic) + bc * GU(ir, ic+1) + ad * GU(ir+1, ic) + ac * GU(ir+1, ic+1); v = bd * GV(ir, ic) + bc * GV(ir, ic+1) + ad * GV(ir+1, ic) + ac * GV(ir+1, ic+1); */ /* scale velocity */ /* WLH 7-3-96 u = step * ctx->dpy_ctx->Uscale[ir][ic] * u; v = step * ctx->dpy_ctx->Vscale[ir][ic] * v; */ u = step * u; v = step * v; /* test for too many line segments */ if (num > maxv-2) { deallocate( ctx, markarrow, nrstart * ncstart * sizeof(char) ); deallocate( ctx, markstart, nrstart * ncstart * sizeof(char) ); deallocate( ctx, markend, nrend * ncend * sizeof(char) ); *numv = num; return 0; } /* propogate streamline */ prevrow = row; prevcol = col; row += dir * v; col += dir * u; /* terminate stream if out of grid */ if (row < 0 || col < 0 || row >= nr-1 || col >= nc-1) { break; } ire = ROW2END(row); ice = COL2END(col); /* terminate stream if enters marked end box */ if (ire != irend || ice != icend) { irend = ire; icend = ice; if (irend < 0 || irend >= nrend || icend < 0 || icend >= ncend) { printf("bad 2: irend = %d icend = %d\n", irend, icend); } if (MARKEND(irend, icend) == 1) { break; } MARKEND(irend, icend) = 1; nend = 0; } /* terminate stream if too many steps in one end box */ nend++; if (nend > MAXSTREAMSTEPS) { break; } /* make line segment */ vr[num] = prevrow; vc[num++] = prevcol; vr[num] = row; vc[num++] = col; /* mark start box */ irs = ROW2START(row); ics = COL2START(col); if (irs < 0 || irs >= nrstart || ics < 0 || ics >= ncstart) { printf("bad 3: irs = %d ics = %d\n", irs, ics); } if (MARKSTART(irs, ics) == 0) { MARKSTART(irs, ics) = 1; } /* check for need to draw arrow head */ ira = ROW2ARROW(row); ica = COL2ARROW(col); if (MARKARROW(ira, ica) == 0) { double rv, cv, v; /* test for too many line segments */ if (num > maxv-4) { deallocate( ctx, markarrow, nrstart * ncstart * sizeof(char) ); deallocate( ctx, markstart, nrstart * ncstart * sizeof(char) ); deallocate( ctx, markend, nrend * ncend * sizeof(char) ); *numv = num; return 0; } MARKARROW(ira, ica) = 1; rv = dir * (row - prevrow); cv = dir * (col - prevcol); v = sqrt(rv*rv + cv*cv); if (v > MINSTREAMVECTORLENGTH) { rv = rv / v; cv = cv / v; } vr[num] = row; vc[num++] = col; vr[num] = row - (rv + cv) * rowlength; vc[num++] = col + (rv - cv) * collength; vr[num] = row; vc[num++] = col; vr[num] = row + (cv - rv) * rowlength; vc[num++] = col - (cv + rv) * collength; } } /* end while (forward) */ *numv = num; return 1; }
void DrawStatistics(char Win) { GXHEADER local; char AImg[7] = {8, 9, 10, 11, 13, 14, 0}; char Digit[2]; int starty, qty, i; FILE *fin; strncpy(helptextIndex, "i145", 4); strncpy(keyhelpIndex, "k045", 4); FadeOut(2, pal, 10, 0, 0); PortPal(0); gxClearDisplay(0, 0); ShBox(35, 33, 288, 159); InBox(40, 69, 111, 109); InBox(116, 69, 283, 109); InBox(40, 114, 111, 154); InBox(116, 114, 283, 154); IOBox(191, 40, 280, 62); Flag(41, 70, Win); Flag(41, 115, other(Win)); DispBig(48, 44, "STATISTICS", 1, -1); DispBig(215, 45, "EXIT", 1, -1); grSetColor(6); PrintAt(122, 78, "WINNING DIRECTOR: "); grSetColor(8); if (AI[Win]) { PrintAt(0, 0, "COMPUTER"); sprintf(&Digit[0], "%d", Data->P[Win].Track[3]); PrintAt(0, 0, &Digit[0]); } else if (Win == 0) { PrintAt(0, 0, &Data->P[Data->Def.Plr1].Name[0]); } else { PrintAt(0, 0, &Data->P[ Data->Def.Plr2 ].Name[0]); } grSetColor(6); PrintAt(122, 125, "LOSING DIRECTOR: "); grSetColor(8); if (AI[other(Win)]) { PrintAt(0, 0, "COMPUTER"); sprintf(&Digit[0], "%d", Data->P[other(Win)].Track[3]); PrintAt(0, 0, &Digit[0]); } else if (Win == 0) { PrintAt(0, 0, &Data->P[Data->Def.Plr2].Name[0]); } else { PrintAt(0, 0, &Data->P[ Data->Def.Plr1 ].Name[0]); } qty = 6; starty = 118; GV(&local, 30, 19); fin = sOpen("PORTBUT.BUT", "rb", 0); OutBox(152, 41, 183, 61); //directors ranking for (i = 0; i < qty; i++) { if (i <= 4 && AI[Win] == 0) { OutBox(starty + (i * 33), 87, 31 + starty + (i * 33), 107); } if (i <= 4 && AI[other(Win)] == 0) { OutBox(starty + (i * 33), 132, 31 + starty + (i * 33), 152); } fseek(fin, AImg[i] * 570, SEEK_SET); fread((char *)local.vptr, 570, 1, fin); if (i == 0) { gxPutImage(&local, gxSET, 153, 42, 0); } else { if (AI[Win] == 0) { gxPutImage(&local, gxSET, starty + ((i - 1) * 33) + 1, 88, 0); } if (AI[other(Win)] == 0) { gxPutImage(&local, gxSET, starty + ((i - 1) * 33) + 1, 133, 0); } } } fclose(fin); DV(&local); FadeIn(2, pal, 10, 0, 0); return; }