void DarkGDK() { //Window title dbSetWindowTitle("Color The Box!"); //Introduction dbPrint(); dbPrint("Please enter a color to view the box."); dbPrint(); //Variables int Red, Green, Blue; DWORD black = dbRGB(0, 0, 0); //Statement/set color Red = atoi( dbInput() ); Green = atoi( dbInput() ); Blue = atoi( dbInput() ); DWORD usercolor = dbRGB(Red, Green, Blue); //Declare color dbInk(usercolor, black); //Draw the box dbBox(150, 100, 450, 500); //Wait for user to press a key dbWaitKey(); }
void play() { //Set variables int randomX = 0; int randomY = 0; int circleX = 0; int circleY = 0; //Continue game until win do { //Clear screen dbCLS(); // Generate a random center point randomX = WIDTH / 2 + dbRND(S_WIDTH - WIDTH); randomY = HEIGHT / 2 + dbRND(S_HEIGHT - HEIGHT); //Draw square drawSquare(randomX, randomY); //Explain game to user dbPrint("Guess the X and Y values of the square's center point."); //Ask user for X coordinate dbPrint("Enter your guess for the X value."); circleX = atoi(dbInput()); //Ask user for Y coordinate dbPrint("Enter your guess for the Y value:"); circleY = atoi(dbInput()); //Draw circle drawCircle(circleX, circleY); //Wait for the user to press a key dbWaitKey(); } while (circleX != randomX && circleY != randomY); }
void DarkGDK() { //Set variables int X; int Y; //Window title dbSetWindowTitle("Treasure Map"); //Set key color dbSetImageColorKey(0, 255, 0); //Load image dbLoadImage("treasure map.bmp", 1); //Display image dbPasteImage(1, 0, 0); //Enter X coordinate dbPrint("Please enter the X coordinate for treasure!"); X = atoi( dbInput() ); //Enter Y coordinate dbPrint("Please enter the Y coordinate for treasure!"); Y = atoi( dbInput() ); DWORD red = dbRGB(255, 0, 0); DWORD black = dbRGB(0, 0, 0); dbInk(red, black); //Draw the X dbLine(X-10, Y-10, X+10, Y+10); dbLine(X-10, Y+10, X+10, Y-10); //Wait for user to press a key dbWaitKey(); }
void DarkGDK() { //Declare variables int centerX; int centerY; //Set the window's title dbSetWindowTitle("Octagon Pattern"); //Ask user for X coordinate dbPrint("Please enter the X coordinate of the Octagon"); centerX = atoi( dbInput() ); //Ask user for Y coordinate dbPrint("Please enter the Y coordinate of the Octagon"); centerY = atoi( dbInput() ); //Draw an Octagon using the user's coordinates drawOctagon(centerX, centerY); //Wait for the user to press a key dbWaitKey(); }
void showFPS ( void ) { char szFPS [ 256 ] = ""; strcpy ( szFPS, "fps = " ); strcat ( szFPS, dbStr ( dbScreenFPS ( ) ) ); dbSetCursor ( 0, 0 ); dbPrint ( szFPS ); dbPrint ( "" ); //strcpy ( szFPS, dbStr ( dbObjectAngleY ( 6000 ) ) ); //dbPrint ( szFPS ); strcpy ( szFPS, dbStr ( dbCameraPositionX ( ) ) ); dbPrint ( szFPS ); strcpy ( szFPS, dbStr ( dbCameraPositionY ( ) ) ); dbPrint ( szFPS ); strcpy ( szFPS, dbStr ( dbCameraPositionZ ( ) ) ); dbPrint ( szFPS ); /* dbPrint ( "" ); strcpy ( szFPS, dbStr ( dbCameraAngleX ( ) ) ); dbPrint ( szFPS ); strcpy ( szFPS, dbStr ( dbCameraAngleY ( ) ) ); dbPrint ( szFPS ); strcpy ( szFPS, dbStr ( dbCameraAngleZ ( ) ) ); dbPrint ( szFPS ); */ dbPrint ( "" ); strcpy ( szFPS, dbStr ( dbStatistic ( 1 ) ) ); dbPrint ( szFPS ); //dbPrint ( "" ); //dbPrint ( dbStr ( dbKeyState ( ) ) ); }
/* * Process the record. * 1. Check for breakpoints. * 2. Check the process active flag (PACT). * 3. Check the disable link. * 4. Check the RSET (record support entry table) exists. * 5. Run the process routine specific to the record type. * 6. Check to see if record contents should be automatically printed. */ long dbProcess(dbCommon *precord) { struct rset *prset = precord->rset; dbRecordType *pdbRecordType = precord->rdes; unsigned char tpro = precord->tpro; char context[40] = ""; long status = 0; int *ptrace; int set_trace = FALSE; dbFldDes *pdbFldDes; int callNotifyCompletion = FALSE; ptrace = dbLockSetAddrTrace(precord); /* * Note that it is likely that if any changes are made * to dbProcess() corresponding changes will have to * be made in the breakpoint handler. */ /* see if there are any stopped records or breakpoints */ if (lset_stack_count != 0) { /* * Check to see if the record should be processed * and activate breakpoint accordingly. If this * function call returns non-zero, skip record * support and fall out of dbProcess(). This is * done so that a dbContTask() can be spawned to * take over record processing for the lock set * containing a breakpoint. */ if (dbBkpt(precord)) goto all_done; } /* check for trace processing*/ if (tpro) { if (!*ptrace) { *ptrace = 1; set_trace = TRUE; } } if (*ptrace) { /* Identify this thread's client from server layer */ if (dbServerClient(context, sizeof(context))) { /* No client, use thread name */ strncpy(context, epicsThreadGetNameSelf(), sizeof(context)); context[sizeof(context) - 1] = 0; } } /* If already active dont process */ if (precord->pact) { unsigned short monitor_mask; if (*ptrace) printf("%s: Active %s\n", context, precord->name); /* raise scan alarm after MAX_LOCK times */ if ((precord->stat == SCAN_ALARM) || (precord->lcnt++ < MAX_LOCK) || (precord->sevr >= INVALID_ALARM)) goto all_done; recGblSetSevr(precord, SCAN_ALARM, INVALID_ALARM); monitor_mask = recGblResetAlarms(precord); monitor_mask |= DBE_VALUE|DBE_LOG; pdbFldDes = pdbRecordType->papFldDes[pdbRecordType->indvalFlddes]; db_post_events(precord, (void *)(((char *)precord) + pdbFldDes->offset), monitor_mask); goto all_done; } else precord->lcnt = 0; /* * Check the record disable link. A record will not be * processed if the value retrieved through this link * is equal to constant set in the record's disv field. */ status = dbGetLink(&precord->sdis, DBR_SHORT, &precord->disa, 0, 0); /* if disabled check disable alarm severity and return success */ if (precord->disa == precord->disv) { if (*ptrace) printf("%s: Disabled %s\n", context, precord->name); /*take care of caching and notifyCompletion*/ precord->rpro = FALSE; precord->putf = FALSE; callNotifyCompletion = TRUE; /* raise disable alarm */ if (precord->stat == DISABLE_ALARM) goto all_done; precord->sevr = precord->diss; precord->stat = DISABLE_ALARM; precord->nsev = 0; precord->nsta = 0; db_post_events(precord, &precord->stat, DBE_VALUE); db_post_events(precord, &precord->sevr, DBE_VALUE); pdbFldDes = pdbRecordType->papFldDes[pdbRecordType->indvalFlddes]; db_post_events(precord, (void *)(((char *)precord) + pdbFldDes->offset), DBE_VALUE|DBE_ALARM); goto all_done; } /* locate record processing routine */ /* FIXME: put this in iocInit() !!! */ if (!prset || !prset->process) { callNotifyCompletion = TRUE; precord->pact = 1;/*set pact so error is issued only once*/ recGblRecordError(S_db_noRSET, (void *)precord, "dbProcess"); status = S_db_noRSET; if (*ptrace) printf("%s: No RSET for %s\n", context, precord->name); goto all_done; } if (*ptrace) printf("%s: Process %s\n", context, precord->name); /* process record */ status = prset->process(precord); /* Print record's fields if PRINT_MASK set in breakpoint field */ if (lset_stack_count != 0) { dbPrint(precord); } all_done: if (set_trace) *ptrace = 0; if (callNotifyCompletion && precord->ppn) dbNotifyCompletion(precord); return status; }
int executeCommand(connection *con) { tableInfo *tbl = con->tbl; command *cmd = con->cmd; response *res = con->res; error *err = con->err; int dataBytes = con->dataBytes; void *data = con->data; printf("Received command: '%s'\n", CMD_NAMES[cmd->cmd]); int result = 0; // Check that table is in use if needed if (!tbl->isValid && cmdNeedsTable(cmd)) { ERROR(err, E_USETBL); return 1; } switch (cmd->cmd) { case CMD_USE: result = dbUseTable(tbl, (char *) cmd->args, res, err); break; case CMD_CREATE_TABLE: result = dbCreateTable((char *) cmd->args, res, err); break; case CMD_REMOVE_TABLE: result = dbRemoveTable((char *) cmd->args, res, err); break; case CMD_PRINT_VAR: result = dbPrintVar((char *) cmd->args, res, err); break; case CMD_CREATE: result = dbCreateColumn(tbl, (createColArgs *) cmd->args, res, err); break; case CMD_REMOVE: result = dbRemoveColumn(tbl, (char *) cmd->args, res, err); break; case CMD_INSERT: result = dbInsert(tbl, (insertArgs *) cmd->args, res, err); break; case CMD_SELECT: result = dbSelect(tbl, (selectArgs *) cmd->args, res, err); break; case CMD_FETCH: result = dbFetch(tbl, (fetchArgs *) cmd->args, res, err); break; case CMD_LOAD: result = dbLoad(tbl, (loadArgs *) cmd->args, dataBytes, data, res, err); break; case CMD_PRINT: result = dbPrint(tbl, (char *) cmd->args, res, err); break; case CMD_MIN: result = dbMinimum((char *) cmd->args, res, err); break; case CMD_MAX: result = dbMaximum((char *) cmd->args, res, err); break; case CMD_SUM: result = dbSum((char *) cmd->args, res, err); break; case CMD_AVG: result = dbAverage((char *) cmd->args, res, err); break; case CMD_CNT: result = dbCount((char *) cmd->args, res, err); break; case CMD_ADD: result = dbAdd((mathArgs *) cmd->args, res, err); break; case CMD_SUB: result = dbSubtract((mathArgs *) cmd->args, res, err); break; case CMD_MUL: result = dbMultiply((mathArgs *) cmd->args, res, err); break; case CMD_DIV: result = dbDivide((mathArgs *) cmd->args, res, err); break; case CMD_LOOPJOIN: result = dbLoopJoin((joinArgs *) cmd->args, res, err); break; case CMD_EXIT: ERROR(err, E_EXIT); result = 1; break; default: ERROR(err, E_INTERN); result = 1; break; } return result; }