int main() { ConcreteSubject *cs = new ConcreteSubject; Observer *obs[COUNT_OBS]; State s; for (int i = 0; i < COUNT_OBS; i++) obs[i] = new ConcreteObserver(cs); s._state = 1; cs->SetState(s); printstate(obs); cs->Detach(obs[5]); s._state = 4; cs->SetState(s); printstate(obs); cs->Attache(obs[5]); s._state = 2; cs->SetState(s); printstate(obs); return 0; }
static void pickup(unsigned int k) { pth_mutex_acquire(&(tab->mutex), FALSE, NULL); (tab->status)[k] = hungry; printstate(); if (!test(k)) pth_cond_await(&((tab->condition)[k]), &(tab->mutex), NULL); printstate(); pth_mutex_release(&(tab->mutex)); return; }
void fsm_print(void) { State *b; int cnt1, cnt2=0; extern void put_uform(void); if (tl_clutter) clutter(); b = findstate("T0_init"); if (Max_Red == 0) b->accepting = 1; mergestates(0); b = findstate("T0_init"); fprintf(tl_out, "never { /* "); put_uform(); fprintf(tl_out, " */\n"); do { clr_reach(); Dfs(b); cnt1 = mergetrans(); cnt2 = mergestates(1); if (tl_verbose) printf("/* >>%d,%d<< */\n", cnt1, cnt2); } while (cnt2 > 0); #ifdef BUCKY buckyballs(); clr_reach(); Dfs(b); #endif if (b && b->accepting) fprintf(tl_out, "accept_init:\n"); if (!b && !never) { fprintf(tl_out, " 0 /* false */;\n"); } else { printstate(b); /* init state must be first */ for (b = never; b; b = b->nxt) printstate(b); } if (hitsall) fprintf(tl_out, "accept_all:\n skip\n"); fprintf(tl_out, "}\n"); }
/* print complete solution */ void plotsolution(int kmax) { int k; char* one = (e) ? printemission(WP) : printstate(HPM); char* two = (e) ? printemission(DP) : printstate(LPM); printf("%s/%s Probabilities:\n",one,two); for (k = 1; k <= kmax; k++) { printf("Time: %6.2f - %s-Prob.: %7.5le - %s-Prob.: %7.5le\n", k*dt, one, y[0][k], two, y[2][k]); } printf("\n"); if (e) { printf("Sequence Probabilities:\n"); for (k = 1; k <= kmax; k++) { printf("Time: %6.2f - %s-Prob.: %7.5le\n", k*dt, printemission(emsequence[k]), emsum[emsequence[k]][k]); } printf("\n"); } }
static void putdown(unsigned int k) { pth_mutex_acquire(&(tab->mutex), FALSE, NULL); (tab->status)[k] = thinking; printstate(); test((k + 1) % PHILNUM); test((k - 1 + PHILNUM) % PHILNUM); pth_mutex_release(&(tab->mutex)); return; }
/* print a proxel */ void printproxel(proxel *c) { int left = 0; int right = 0; if (c->left != NULL) { left = c->left->id; } if (c->right != NULL) { right = c->right->id; } int leaf = (c->left == NULL && c->right == NULL); printf("ID: %6i - %s - Age: %3d - Prob.: %7.5le - Leaf: %i (%i,%i)\n", c->id, printstate(c->s), c->tau1k, c->val, leaf, left, right); }
// do file access using c++ objects. The file contains lines with // space separated values(ssv) // // int main(int argc, char** argv) { if (argc != 2) { printf("Usage: %s <file>\n", argv[0]); return -1; } std::ifstream f(argv[1]); if (f.is_open()) { do { std::string tok; f >> tok; std::cout << "'" << tok << "'" << std::endl; printstate(f); std::cout << "peek: 0x" << std::hex << f.peek() << std::endl; } while (f.good()); } return 0; }
/* Release the resources in request for process i */ void resource_release(int i, int *request) { int j; pthread_mutex_lock(&state_mutex); printf("Process %d release vector: ", i); for(j = 0; j < n; j++) { printf("%d ", request[j]); } printf("\n"); for(j = 0; j < n; j++) { // check if release request is less than the allocated resources if(request[j] <= s->allocation[i][j]) { continue; } else { printf("Release request is more than the allocated!\n"); pthread_mutex_unlock(&state_mutex); return; } } for(j = 0; j < n; j++) { // release the resources s->allocation[i][j] = s->allocation[i][j] - request[j]; s->need[i][j] = s->max[i][j] - s->allocation[i][j]; s->available[j] = s->available[j] + request[j]; } printf("Released resources\n"); printstate(); pthread_mutex_unlock(&state_mutex); }
int *checkifvalid(chess *q, int *locinput, int *prloc, int chk) {/* Checks for match and barrier */ int valid, i, counter = 0, counter1 = 0; char *str; switch(locinput[0]) { case PAWN://Done if(prloc[0] == CONF) {// mvprintw(27, 110, "Ambiguity!"); mvprintw(29, 110, "Please enter the previous location"); while(1) { printstate(stdscr, q); str = getuserinput(stdscr); prloc = getinputlocationpr(q, str, locinput); if(prloc != NULL) { break; } else { mvprintw(27, 110, "Please enter correct input\n"); } } } else if(prloc[0] == NOTFOUND) { //Location not found return NULL; } return prloc; break; case ROOK: case BISHOP: case QUEEN://Using list datastructure Done if(prloc[0] == NOTFOUND) { //printf("Location not found"); return NULL; } else {//prloc found valid = match(q, prloc, locinput); if(valid == 1) {//valid valid = barrier(q, prloc, locinput, chk);//Check if there is any coin in between if(valid == 0) {//0 indicates no barrier counter++; counter1 = 1; } } if(prloc[4] != NOTFOUND) { valid = match(q, &prloc[4], locinput); if(valid == 1) {//valid valid = barrier(q, &prloc[4], locinput, chk); if(valid == 0) { counter++; counter1 = 2; } } } if(counter == 0) {//Location found but not matched or there is a barrier return NULL; } if(counter == 2) { while(1) { mvprintw(27, 110, "Ambiguity!"); mvprintw(29, 110, "Please enter the previous location"); printstate(stdscr, q); str = getuserinput(stdscr); prloc = getinputlocationpr(q, str, locinput); if(prloc != NULL) { return prloc; } } } else if(counter == 1 && counter1 == 1) {//If only first is valid return prloc; } else {//Second is valid return &prloc[4]; } } break; case KNIGHT: prloc = search(q, locinput[0], q->state, NULL, NULL); if(prloc[0] == NOTFOUND) { //printf("Not found\n"); return NULL; } else { valid = match(q, prloc, locinput); if(valid == 1) {//valid valid = barrier(q, prloc, locinput, chk);//Check if there is any coin in between if(valid == 0) {//0 indicates no barrier counter++; counter1 = 1; } } if(prloc[4] != NOTFOUND) { valid = match(q, &prloc[4], locinput); if(valid == 1) {//valid valid = barrier(q, &prloc[4], locinput, chk); if(valid == 0) { counter++; counter1 = 2; } } } if(counter == 0) { return NULL; } if(counter == 2) { while(1) { mvprintw(27, 110, "Ambiguity!"); mvprintw(29, 110, "Please enter the previous location"); printstate(stdscr, q); str = getuserinput(stdscr); prloc = getinputlocationpr(q, str, locinput); if(prloc != NULL) return prloc; } } else if(counter == 1 && counter1 == 1) { return prloc; } else { return &prloc[4]; } } break; case KING: valid = match(q, prloc, locinput); if(valid == 1) { return prloc; } return NULL; } }
main(void) { struct lstnode n = {0}; int b; puts("List test program"); puts("Zadejte pismeno 0-A pro jednu z nasledujicich cinnosti:"); puts("0: Init,"); puts("1: Actualize,"); puts("2: Insert_First,"); puts("3: First,"); puts("4: Copy_First,"); puts("5: Delete_First,"); puts("6: Post_Delete,"); puts("7: Post_Insert,"); puts("8: Copy,"); puts("9: Succ,"); puts("A: Is_Active,"); puts("M: Vypis menu"); puts("CTRL+Z (Win) nebo CTRL+D (Unix): Konec programu"); menu: if(!gets(t)) goto out; printf("Vase volba=%c\n", t[0]); switch(t[0]) { case '0': puts("Init - inicializace seznamu"); break; case '1': puts("Actualize - prepis dat aktivni polozky"); /* read but discard if no active */ read(ls.active ? ls.active : &n); break; case '2': puts("Insert_First - vlozeni nove polozky na 1. misto seznamu"); read(&n); check(lstinsfirst(&ls, n)); break; case '3': puts("First - nastaveni aktivni polozky na 1.prvek"); ls.active = ls.first; break; case '4': puts("Copy_First - Vypis 1.prvku seznamu"); if(!ls.first) error("Chyba v List_Copy_First - first=NULL"); printlstnode(*ls.first); break; case '5': puts("Delete_First - vymaz 1.prvek"); b = ls.first; lstrmfirst(&ls); if(b) printf("myFree: uvolnuji 288 bajtu, celkove prideleno %d bajtu\n", 288*lstlen(ls)); break; case '6': puts("Post_Delete - vymaz prvek za aktivnim prvkem"); b = ls.first && ls.first->next; lstrmafter(&ls); if(b) printf("myFree: uvolnuji 288 bajtu, celkove prideleno %d bajtu\n", 288*lstlen(ls)); break; case '7': puts("Post_Insert - vloz novy prvek za aktivni prvek"); read(&n); if(ls.active) check(lstinsafter(ls, n)); break; case '8': puts("Copy - ziskani hodnoty aktivniho prvku "); if(!ls.active) error("List_Copy error"); printlstnode(*ls.active); break; case '9': puts("Succ - posuv ukazatel aktivniho prvku na dalsi prvek"); if(ls.active) ls.active = ls.active->next; break; case 'A': case 'a': puts("Is_Active - zjisteni, zda je seznam aktivni"); printf("Is_Active=%s\n", ls.active == ls.first && ls.first ? "true" : "false"); break; default: goto out; } printstate(); puts(""); puts("Zadejte znak 0-A, EOF(tj. CTRL+Z nebo CTRL+D)=Konec, M=Menu:"); puts("************************************************************"); goto menu; out: puts("Konec souboru, koncime."); lstfree(ls); return 0; }
void imcsplay(int argc, char **argv) { setlinebuf(stdout); if (argc < 5 || argc > 7) usage(); char mecolor = '?'; int megame = 0; switch(argv[2][0]) { case 'O': switch(argv[2][1]) { case 'W': case 'B': case '?': mecolor = argv[2][1]; break; default: usage(); } break; case 'A': { char ch = argv[2][1]; if (isdigit(ch)) { megame = atoi(&argv[2][1]); } else if (ch == 'W' || ch == 'B') { mecolor = ch; megame = atoi(&argv[2][2]); } else { usage(); } if (megame <= 0) usage(); break; } default: usage(); } char *meuser = argv[3]; char *mepassword = argv[4]; char *host = "imcs.svcs.cs.pdx.edu"; if (argc > 5) host = argv[5]; int port = 3589; if (argc > 6) { port = atoi(argv[6]); if (port <= 0) usage(); } FILE *nf = netopen(host, port); setlinebuf(nf); startlog(); char *greeting = expectcmd(nf, 1, 100, 0); (void) strtok(greeting, " "); char *pgm = strtok(0, " "); assert(!strcmp(pgm, "imcs")); char *version = strtok(0, " \r\n"); if(strcmp(version, "2.5")) { fprintf(stderr, "got unexpected imcs version %s\n", version); exit(1); } sendcmd(nf, "me %s %s", meuser, mepassword); (void) expectcmd(nf, 1, 201, 0); if (megame != 0) { if (mecolor == '?') sendcmd(nf, "accept %d", megame); else sendcmd(nf, "accept %d %c", megame, mecolor); (void) expectcmd(nf, 1, 105, 106, 0); } else { if (mecolor == '?') sendcmd(nf, "offer"); else sendcmd(nf, "offer %c", mecolor); (void) expectcmd(nf, 1, 103, 0); logmsg("waiting for opponent"); (void) expectcmd(nf, 1, 105, 106, 0); logmsg("opponent found"); } struct state s = s0; s.cureval = eval(&s); if (nttable > 0) s.curzhash = zhash(&s); while (1) { int ch = fgetc(nf); int r = ungetc(ch, nf); assert(r != EOF); if (isdigit(ch)) { s = readstate(nf, 1); s.cureval = eval(&s); if (nttable > 0) s.curzhash = zhash(&s); continue; } switch (ch) { case '?': { char *r = getnet(nf, "?"); char *q = strtok(r, " "); assert(!strcmp(q, "?")); char *tl = strtok(0, " "); char *tr = strtok(0, " "); assert(tl && tr); int t = readtimems(tl); t = 95 * t / (100 * ((81 - s.ply) / 2)); struct move m = idnegamax(&s, t, 0); logmsg("value %d at time %d depth %d for %s\n\n", v0, t, d0, movestr(&m)); move(&s, &m, 0); sendcmd(nf, "%s", movestr(&m)); printstate(&s, 1); if (ponder) (void) idnegamax(&s, 0, nf); continue; } case '!': assert(fgetc(nf) == '!'); int ch; do ch = fgetc(nf); while (isspace(ch)); ungetc(ch, nf); struct move m = getmove(nf, &s); move(&s, &m, 0); continue; case '=': (void) getnet(nf, "="); break; case 'X': (void) getnet(nf, "X"); break; default: (void) getnet(nf, "..."); continue; } break; } fclose(nf); }
/* int main(int argc, char *argv[], char *environ[]) */ int main(int argc, char *argv[]) { char tmpbuf[MAX_OBJNAMELEN + 1]; obj_t *tobj; int i; char *p; char c; short intstatus = 0; short preload = 1; char *fn=NULL; setvbuf(stdout, NULL, _IONBF, 0); if (argc < 2) { do_banner(); do_help(argv[0]); return -1; } if ((N = nsp_newstate()) == NULL) return -1; setsigs(); N->debug = 0; //nspbase_register_all(N); /* add env */ tobj = nsp_settable(N, &N->g, "_ENV"); for (i = 0;environ[i] != NULL;i++) { strncpy(tmpbuf, environ[i], MAX_OBJNAMELEN); p = strchr(tmpbuf, '='); if (!p) continue; *p = '\0'; p = strchr(environ[i], '=') + 1; nsp_setstr(N, tobj, tmpbuf, p, -1); } /* add args */ tobj = nsp_settable(N, &N->g, "_ARGS"); for (i = 0;i < argc;i++) { n_ntoa(N, tmpbuf, i, 10, 0); nsp_setstr(N, tobj, tmpbuf, argv[i], -1); } tobj = nsp_settable(N, &N->g, "io"); nsp_setcfunc(N, tobj, "gets", (NSP_CFUNC)neslib_io_gets); for (i = 1;i < argc;i++) { if (argv[i] == NULL) break; if (argv[i][0] == '-') { c = argv[i][1]; if (!c) { break; } else if ((c == 'd') || (c == 'D')) { N->debug = 1; } else if ((c == 's') || (c == 'S')) { intstatus = 1; } else if ((c == 'b') || (c == 'B')) { preload = 0; } else if ((c == 'e') || (c == 'E')) { if (++i < argc) { if (preload) do_preload(N); nsp_exec(N, argv[i]); if (N->err) goto err; } } else if ((c == 'f') || (c == 'F')) { if (++i < argc) { preppath(N, argv[i]); set_console_title(N); if (preload) do_preload(N); fn=argv[i]; nsp_execfile(N, fn); if (N->err) goto err; } } else if ((c == 'v') || (c == 'V')) { printf(NSP_VERSION "\r\n"); return 0; } else { do_help(argv[0]); return -1; } } else { preppath(N, argv[i]); set_console_title(N); if (preload) do_preload(N); fn=argv[i]; nsp_execfile(N, fn); if (N->err) goto err; } } err: if (N->err) printf("%s\r\n", N->errbuf); nsp_freestate(N); if (intstatus || N->allocs != N->frees) printstate(N, fn); nsp_endstate(N); return 0; }
/* Allocate resources in request for process i, only if it results in a safe state and return 1, else return 0 */ int resource_request(int i, int *request) { int j, safe = 0, safeAvailable[n], safeNeed[m][n], safeAllocation[m][n]; pthread_mutex_lock(&state_mutex); printf("Process %d request vector: ", i); for(j = 0; j < n; j++) { printf("%d ", request[j]); } printf("\n"); // check if resource request is eligible for allocation for(j = 0; j < n; j++) { if(request[j] <= s->need[i][j]) { if(request[j] <= s->available[j]) { continue; } else { printf("Not enough available resources(%d) for request(%d) try again later...\n", s->available[j], request[j]); pthread_mutex_unlock(&state_mutex); return 0; } } else { printf("Request greater than need!\n"); pthread_mutex_unlock(&state_mutex); return 0; } } // allocate resources for(j = 0; j < n; j++) { // backup of current resources safeAvailable[j] = s->available[j]; safeNeed[i][j] = s->need[i][j]; safeAllocation[i][j] = s->allocation[i][j]; s->available[j] = s->available[j] - request[j]; s->allocation[i][j] = s->allocation[i][j] + request[j]; s->need[i][j] = s->max[i][j] - s->allocation[i][j]; } //check state safe = checksafety(); if(safe != 1) { for(j = 0; j < n; j++) { s->available[j] = safeAvailable[j]; s->need[i][j] = safeNeed[i][j]; s->allocation[i][j] = safeAllocation[i][j]; } printf("Request leads to unsafe state. Request Denied!\n"); pthread_mutex_unlock(&state_mutex); return 0; } else { printf("Request leads to safe state. Request Granted!\n"); printf("Vector changed: "); printstate(); pthread_mutex_unlock(&state_mutex); return 1; } }
/* Dumps (almost) the entire game state on request. Called by * handle_keystroke_event() when the F10 key is pressed. */ void dump_state(nbstate *state) { int i; power *p; sprite *s; /* The letters symbolising each of the powers: */ char powers[NUMPOWERS] = "WSTPNF"; /* The names of the cheats: */ char *cheats[] = { "SolidFloor", "Teleport", "NoBounce", "NoPowerDown", "NoPowerUpTimeout" }; /* Print the title: */ debug_printf ("Printing NanoBreaker Game State\n" "-------------------------------\n"); /* Print the current game state: */ debug_printf ("state = "); printstate(state->state); /* Print the name of the game directory and the game file: */ debug_printf ("gamedir = \"%s\"\ngamefile = \"%s\"\n", fname(state->gamedir), fname(state->gamefile)); /* Print the name of the title screen background image and whether it * should be tiled or not: */ debug_printf ("titlebackground = \"%s\"\n", fname(state->titlebackground)); debug_printf ("titlebackgroundtiled = %s\n", state->titlebackgroundtiled ? "Yes" : "No"); /* Print the file names of the various splash graphics: */ debug_printf ("titlesplash = \"%s\"\n", fname(state->titlesplash)); debug_printf ("gamewonsplash = \"%s\"\n", fname(state->gamewonsplash)); debug_printf ("gamelostsplash = \"%s\"\n", fname(state->gamelostsplash)); /* Print the full list of sprites: */ debug_printf ("sprites = \n"); if(!state->spritelist) debug_printf ("\t<empty>\n"); else for(s = state->spritelist; s; s = s->next) debug_printf ("\t\"%s\" (%d * %d) is in use %d time%s\n", fname(s->fname), s->w, s->h, s->usage, s->usage > 1 ? "s" : ""); /* Print the name and dimensions of the current background image (or * "none" if there isn't one, and whether or not is tiled: */ debug_printf ("background = "); if(!state->background) debug_printf ("none\n"); else debug_printf ("\"%s\" (%d * %d), %stiled\n", fname(state->background->fname), state->background->w, state->background->h, state->backgroundtiled ? "" : "not "); /* Print the points gained in various different circumstances, the * balls given at the start of the game, and the balls given at the * start of each new level: */ debug_printf ("normalpoints = %d\nsmallbonuspoints = %d\nmediumbonuspoints = " "%d\nlargebonuspoints = %d\nhugebonuspoints = %d\n" "poweruppoints = %d\npowerdownpoints = %d\nstartballs = %d\n" "newlevelballs = %d\n", state->normalpoints, state->smallbonuspoints, state->mediumbonuspoints, state->largebonuspoints, state->hugebonuspoints, state->poweruppoints, state->powerdownpoints, state->startballs, state->newlevelballs); /* Print the dimensions of the brick area, the size of the bricks, * the ID of the brick drawing alpha channel, and the global brick * list: */ debug_printf ("width = %d\nheight = %d\nbrickwidth = %d\nbrickheight = %d\n" "brickalpha = %d\n", state->width, state->height, state->brickwidth, state->brickheight, state->brickalpha); debug_printf ("bricks =\n"); dump_bricks(state->bricks); /* Print the bat sizes, the names of all the various bat graphics, the * current bat, and the current bat X position: */ debug_printf ("batheight = %d\nsmall bat width = %d\nnormal bat width = %d\n" "large bat width = %d\n", state->batheight, state->batwidths[SMALLBAT], state->batwidths[NORMALBAT], state->batwidths[LARGEBAT]); debug_printf ("small bat = "); if(!state->bats[SMALLBAT]) debug_printf ("none\n"); else debug_printf ("\"%s\"\n", fname(state->bats[SMALLBAT]->fname)); debug_printf ("normal bat = "); if(!state->bats[NORMALBAT]) debug_printf ("none\n"); else debug_printf ("\"%s\"\n", fname(state->bats[NORMALBAT]->fname)); debug_printf ("large bat = "); if(!state->bats[SMALLBAT]) debug_printf ("none\n"); else debug_printf ("\"%s\"\n", fname(state->bats[LARGEBAT]->fname)); debug_printf ("current bat = "); switch(state->bat) { case NORMALBAT: debug_printf ("NORMALBAT\n"); break; case SMALLBAT: debug_printf ("SMALLBAT\n"); break; case LARGEBAT: debug_printf ("LARGEBAT\n"); break; default: debug_printf ("unknown (%d)\n", state->bat); } debug_printf ("batx = %d\nbatv = %d\n", state->batx, state->batv); /* Print the names of each of the power sprites: */ debug_printf ("Power sprites:\n"); for(i = 0; i < NUMPOWERS; i++) { debug_printf ("\t%c ", powers[i]); if(state->powersprites[i]) debug_printf ("\"%s\"\n", fname(state->powersprites[i]->fname)); else debug_printf ("<empty>\n"); } /* If there is a splash sprite, print its name and dimensions: */ debug_printf ("splash = "); if(!state->splash) debug_printf ("none\n"); else debug_printf ("\"%s\" (%d * %d)\n", fname(state->splash->fname), state->splash->w, state->splash->h); /* Print the times that power-ups and power-downs last for: */ debug_printf ("poweruptime = %d\npowerdowntime = %d\n", state->poweruptime, state->powerdowntime); /* Print the cheat sequences, the cheat status, and the cheat flags: */ debug_printf ("Cheat sequences:\n"); for(i = 0; i < NUMCHEATS; i++) { debug_printf ("\t%s = ", cheats[i]); if(state->cheats[i]) debug_printf ("\"%s\"\n", state->cheats[i]); else debug_printf ("disabled\n"); } debug_printf ("cheatstate = \"%s\"\n", state->cheatstate); debug_printf ("SolidFloor flag is %s\n", state->flags.sf ? "active" : "inactive"); debug_printf ("NoBounce flag is %s\n", state->flags.nb ? "active" : "inactive"); debug_printf ("NoPowerDown flag is %s\n", state->flags.npd ? "active" : "inactive"); debug_printf ("NoPowerUpTimeout flag is %s\n", state->flags.nputo ? "active" : "inactive"); /* Print the other various boolean flags: */ debug_printf ("Paused flag is %s\n", state->flags.paused ? "active" : "inactive"); debug_printf ("Left flag is %s\n", state->flags.left ? "active" : "inactive"); debug_printf ("Right flag is %s\n", state->flags.right ? "active" : "inactive"); /* Print the current level and the total number of levels: */ debug_printf ("level = %d\nnumlevels = %d\n", state->level, state->numlevels); /* Print the Nano-X IDs of the output window, the canvases, and the * one second periodic timer, as well as the absolute X position of * the output window and the dimensions of the canvas area: */ debug_printf ("wid = %d\nwinx = %d\ncanvas = %d\noldcanvas = %d\n" "newcanvas = %d\ntid = %d\ncanvaswidth = %d\n" "canvasheight = %d\n", state->wid, state->winx, state->canvas, state->oldcanvas, state->newcanvas, state->tid, state->canvaswidth, state->canvasheight); /* The current brick area: */ dump_grid(state, state->grid); /* The number of bricks remaining in the current level: */ debug_printf ("numbricks = %d\n", state->numbricks); /* Print the ball related data: */ debug_printf ("ball = "); if(!state->ball.s) debug_printf ("none\n"); else debug_printf ("\"%s\" (%d * %d)\n", fname(state->ball.s->fname), state->ball.s->w, state->ball.s->h); debug_printf ("ball x = %f\nball y = %f\nball d = %f\nball v = %d\n" "lx = %d\nly = %d\nparked = %s\nslow ball velocity = " "%d\nnormal ball velocity = %d\nfast ball velocity = " "%d\n", state->ball.x, state->ball.y, state->ball.d, state->ball.v, state->ball.lx, state->ball.ly, state->ball.parked ? "Yes" : "No", state->ball.sv, state->ball.nv, state->ball.fv); /* Print the current list of powers: */ debug_printf ("current powers:\n"); if(!state->powers) debug_printf ("\t<empty>\n"); else for(p = state->powers; p; p = p->next) debug_printf ("\t%c at (%d, %d)\n", powers[p->type], p->x, p->y); /* Print the score related data: */ debug_printf ("score = %d\nhiscore = %d\n file hiscore = %d\n" "score pixmap = %d\n", state->scores.s, state->scores.hi, state->scores.fhi, state->scores.p); /* Print out the power velocity and the animate period: */ debug_printf ("powerv = %d\nanimateperiod = %d\n", state->powerv, state->animateperiod); /* Print the time of the last animate() call: */ debug_printf ("lastanim = %ldS %lduS\n", state->lastanim.tv_sec, state->lastanim.tv_usec); /* Print the current power-up and power-down timer values: */ debug_printf ("powertimes:\n" "\twidebat = %d\n" "\tslowmotion = %d\n" "\tstickybat = %d\n" "\tpowerball = %d\n" "\tnarrowbat = %d\n" "\tfastmotion = %d\n", state->powertimes.widebat, state->powertimes.slowmotion, state->powertimes.stickybat, state->powertimes.powerball, state->powertimes.narrowbat, state->powertimes.fastmotion); /* Print the fade rate and current fade level: */ debug_printf ("faderate = %d\nfadelevel = %d\n", state->faderate, state->fadelevel); /* Print the next game state: */ debug_printf ("nextstate = "); printstate(state->nextstate); /* Print all of the level data: */ dump_levels(state); }