/**************************************************************************** * FUNCTION: main() - local routine * ****************************************************************************/ int main(int argc, char *argv[]) { int key_entered, Ch; intro(); /* Set all 16 buffers to 0 */ for (Ch = 0; Ch < 4; Ch++) OUTPORT(base + (Ch * 2), Cal(0x000, Ch)); inb(base+0xA); // set automatic update mode inb(base+0XF); // release zero latch do { CLRSCR(); write_DAC(); CPRINTF("\n\nWould you like to output another value (Y or N)?\n"); key_entered = GETCH(); } while((key_entered != 'N') && (key_entered != 'n')); /* Set all 16 buffers to 0 */ for (Ch = 0; Ch < 4; Ch++) OUTPORT(base + (Ch * 2), Cal(0x000, Ch)); CLRSCR(); PUTS("DA12-16 Sample1 complete."); } /* end main */
/** Ez a fuggveny a menut jeleniti meg, innen lehet valasztani, jatszani akarunk-e, * megnezni a dicsõsegtablat vagy egyszerûen csak kilepni. Ez a fuggveny is a fõfuggvenyekhez * tartozik, ami azt jelenti, hogy ez is a main.c-bõl hivodik meg, es oda ter vissza * megvaltoztatott ertekekkel. * @param aktualis status tipusu pointer az aktualis allapotot jelzi * @param quit a quit flag-et is cim szerint kell atadni, hogy valtoztatni tudja azt */ void bazis(status *aktualis, int*quit){ SDL_EnableUNICODE(1); SDL_Event event; SDL_Surface *menukep; int change=0; menukep = IMG_Load("cats_wait.png"); menukiir(menukep); SDL_Flip(screen); while (!*quit&&!change){ SDL_WaitEvent(&event); switch(event.type){ case SDL_KEYDOWN: switch(event.key.keysym.unicode){ case '1': *aktualis=game; CLRSCR(screen); change=1; break; case '2': *aktualis=hsdisplay; CLRSCR(screen); change=1; break; case '3': *quit=1; break; } break; case SDL_MOUSEBUTTONDOWN: switch (menu_number(event.button.x, event.button.y)){ case 1: TTF_KIIR(screen, KSZELESSEG/2+10, 100, "New Game-1", betutipus, YELLOW); SDL_Delay(500); *aktualis=game; CLRSCR(screen); change=1; break; case 2: TTF_KIIR(screen, KSZELESSEG/2+10, 140, "High score-2", betutipus, YELLOW); SDL_Delay(500); *aktualis=hsdisplay; CLRSCR(screen); change=1; break; case 3: TTF_KIIR(screen, KSZELESSEG/2+10, 180, "Kilepes-3", betutipus, YELLOW); SDL_Delay(500); *quit=1; break; } break; case SDL_QUIT: *quit=1; break; } } SDL_FreeSurface(menukep); }
void staff() { int choice = 0; while (1) { if (choice >= 0 && choice <= 7) { CLRSCR(); //clears window up until this point puts("-------------------------------------------------------"); puts("1. Make a booking"); puts("2. Complete a booking"); puts("3. Search for available tables by no. of seats"); puts("4. Display menu and take order"); puts("5. Display receipt"); puts("6. Show information on tables"); puts("7. Show future bookings"); puts("0. Exit"); printf("-------------------------------------------------------"); } choice = onlyInt(1); switch (choice){ case 0: return; case 1: staffAddBooking(); break; //make a booking case 2: completeBooking(); break; //complete booking case 3: showAvailableTables(); break; case 4: selectTable(1); break; //display menu function case 5: selectTable(2); break; //display receipt function case 6: showAllTables(); break; case 7: showFutureBookings(); break; default: printf("That is not one of the options!\nPlease enter again: "); } } }
/*************************************************************************** * FUNCTION: intro * * PURPOSE: Present user with introductory screen. Get base address. * **************************************************************************/ void intro(void) { CLRSCR(); CPRINTF( " C SAMPLE #1: SAMPLE1.C \n\n" " This sample will prompt the user for a voltage between 0 and 10 volts, \n" " then calculate the actual voltage based on the resolution of the DAC and\n" " output the voltage to the desired DAC channel. \n\n" " The following setup of the board is expected: \n\n" " þ All DAC voltage ranges should be set to 0v-10v unipolar. \n\n"); PUTS("\n"); PUTS("Press any key to continue ... "); GETCH(); CLRSCR(); base = AskForBaseAddress(0x350, ""); CLRSCR(); EBase = AskForBaseAddress(0x350, "Calibration "); } /* end of intro */
/** A menu kiirasa, a fuggveny a kod atlathatosaga erdekeben jott letre. * @param menukep A menukepre mutato feluletpointer */ void menukiir(SDL_Surface *menukep){ CLRSCR(screen); SDL_Rect mkpos; mkpos.x=KSZELESSEG/80; mkpos.y=KMAGASSAG/40; SDL_BlitSurface(menukep, NULL, screen, &mkpos); TTF_KIIR(screen, KSZELESSEG/2+10, 50, "MOUSE KILLER", betutipus2, WHITE); TTF_KIIR(screen, KSZELESSEG/2+10, 100, "New Game-1", betutipus, WHITE); TTF_KIIR(screen, KSZELESSEG/2+10, 140, "High score-2", betutipus, WHITE); TTF_KIIR(screen, KSZELESSEG/2+10, 180, "Kilepes-3", betutipus, WHITE); SDL_Flip(screen); }
void printtutorial(SDL_Surface *hova, char** texts, char *kepnev){ CLRSCR(hova); int i; SDL_Surface *tkep = IMG_Load(kepnev); SDL_Rect tkeppos; tkeppos.x=KSZELESSEG/2-120; tkeppos.y=FONTSIZE*2.5; SDL_BlitSurface(tkep, NULL, hova, &tkeppos); for (i=0; texts[i]!=NULL; i++) TTF_KIIR(hova, KSZELESSEG/80, FONTSIZE*(i+1), texts[i], betutipus4, WHITE); SDL_FreeSurface(tkep); TTF_KIIR(screen, KSZELESSEG/80, KMAGASSAG-FONTSIZE*2, "PRESS ESC TO QUIT", betutipus, WHITE); }
/** A dicsosegtabla kirajzolasat vegzo fuggveny. A fuggveny valtoztatni tudja a neki adott * parametereket. * @param aktualis status tipusu pointer, amely az aktualis allapotat mutatja a jateknak * @param quit a kilepes flag-je */ void tabla_r(status *aktualis, int *quit){ CLRSCR(screen); /*letisztitja a kepernyot*/ FILE *fp; SDL_Surface *cats_sit=IMG_Load("cats_sit.png"); /*Megnyitja az almenu kepet*/ SDL_Rect catdest; catdest.x=KSZELESSEG/8-50; catdest.y=KMAGASSAG/4-70; SDL_Event event; int i; char sor[50]; /*ide lesznek irva a sorok*/ int enough=0; SDL_BlitSurface(cats_sit, NULL, screen, &catdest); /*kirajzolja a kepernyore a kepet*/ TTF_KIIR(screen, KSZELESSEG/2, 300, "PRESS ESC TO QUIT", betutipus, WHITE); /*Egy kis instrukció*/ fp=fopen("highscore.txt", "rt"); /*megnyitja az adatokat tartalmazo szovegfajlt*/ jatekos *head=(jatekos*)malloc(sizeof(jatekos)); /*A tabla fuggvenyben levo esemenyek ujra megtortennek, ezuttal nem vizsgalunk semmit, csak beolvassuk a lancolt listaba a sorokat, majd kiirjuk oket TTF_KIIR-el*/ jatekos *mozgo=head; fscanf(fp, " %s%d\n", head->nev, &head->point); sprintf(sor, "%s....%d", mozgo->nev, mozgo->point); TTF_KIIR(screen, KSZELESSEG/2, 50, sor, betutipus2, WHITE); for(i=0; i<4; i++){ mozgo->kov=(jatekos*)malloc(sizeof(jatekos)); mozgo=mozgo->kov; mozgo->kov=NULL; fscanf(fp, " %s%d\n", mozgo->nev, &mozgo->point); char sor[50]; sprintf(sor, "%s....%d", mozgo->nev, mozgo->point); printf("%s....%d\n", mozgo->nev, mozgo->point); TTF_KIIR(screen, KSZELESSEG/2, (90+(FONTSIZE+10)*i), sor, betutipus2, WHITE); } SDL_Flip(screen); /*Kepernyore flippelunk es varunk*/ while (!(*quit)&&!enough){ /*enough es quit flag*/ SDL_WaitEvent(&event); switch(event.type){ case SDL_KEYDOWN: switch(event.key.keysym.unicode) case SDLK_ESCAPE: enough=1; break; case SDL_QUIT: *quit=1; break; } } /*kotelezo felszabaditas*/ fclose(fp); SDL_FreeSurface(cats_sit); freelistaj(head); *aktualis=menu; /*a menube ugrunk*/ }
void administrator() { int choice = 0; int password; //check to see if password entered correctly, 0 for incorrect, 1 for correct //Password: Password1! //key: 1234 puts("Please enter the administrator password. 3 attempts remaining:"); password = checkPassword(); if (password == 0) { puts("Password and Key combination incorrectly entered 3 times.\nProgram is exiting..."); return; } while (1) { if (choice >= 0 && choice <= 11) { CLRSCR(); //clears window up until this point puts("-------------------------------------------------------"); puts("1. Make/Edit/Delete a booking"); puts("2. Complete a booking"); puts("3. Search for available tables by no. of seats"); puts("4. Display menu and take order"); puts("5. Display receipt"); puts("6. Show information on tables"); puts("7. Show future bookings"); puts("8. Edit Tables"); puts("9. Edit Menu"); puts("10. Change Administrator password"); puts("0. Exit"); printf("-------------------------------------------------------"); } choice = onlyInt(2); switch (choice){ case 0: return; case 1: editBooking(); break; //make a booking case 2: completeBooking(); break; //complete booking case 3: showAvailableTables(); break; case 4: selectTable(1); break; //display menu function case 5: selectTable(2); break; //display receipt function case 6: showAllTables(); break; case 7: showFutureBookings(); break; case 8: editTables(); break; case 9: editMenu(); break; //edit menu.dat file case 10: changePassword(); return; //program logs user out after changing password default: printf("That is not one of the options!\nPlease enter again: "); } } }
credits(status *aktualis, int *quit){ int enough = 0; /*a jol ismert enough flag*/ SDL_Event cev; /*esemény*/ CLRSCR(screen); SDL_Surface *mancs=IMG_Load("specialthanks.png"); SDL_Rect mancsdest; mancsdest.x=0; mancsdest.y=50; SDL_BlitSurface(mancs, NULL, screen, &mancsdest); SDL_FreeSurface(mancs); TTF_KIIR(screen, KSZELESSEG/2, 80, "Special thanks to:", betutipus3, WHITE); TTF_KIIR(screen, KSZELESSEG/2, 130, "Sarkadics", betutipus3, WHITE); TTF_KIIR(screen, KSZELESSEG/2, 160, "Shido Tousaka", betutipus3, WHITE); TTF_KIIR(screen, KSZELESSEG/2, 190, "\"Andi\"", betutipus3, WHITE); TTF_KIIR(screen, KSZELESSEG/2, 220, "bandrasi & dienes", betutipus3, WHITE); TTF_KIIR(screen, KSZELESSEG/2, 250, "Code: Kyle Brandson", betutipus3, WHITE); TTF_KIIR(screen, KSZELESSEG/2, 280, "Music: Mendel", betutipus3, WHITE); TTF_KIIR(screen, KSZELESSEG/2, 310, "2014", betutipus3, WHITE); SDL_Flip(screen); while (!(*quit)&&!enough){ SDL_WaitEvent(&cev); switch (cev.type) { case SDL_KEYDOWN: switch (cev.key.keysym.unicode){ case SDLK_ESCAPE: enough=1; break; } break; case SDL_QUIT: *quit=1; break; } } *aktualis=menu; }
void tutorial(status *aktualis, int *quit){ int enough = 0; /*a jol ismert enough flag*/ int mc = 0; SDL_Event tev; /*esemény*/ fgvargs tomb[]={ {screen, texts1, "jatek.png"}, {screen, texts2, "mouse.png"}, {screen, texts3, "end.png"}, }; CLRSCR(screen); printtutorial(tomb[mc].hova, tomb[mc].texts, tomb[mc].kepnev); SDL_Flip(screen); while (!(*quit)&&!enough){ SDL_WaitEvent(&tev); switch (tev.type) { case SDL_KEYDOWN: switch (tev.key.keysym.unicode){ case SDLK_ESCAPE: enough=1; break; case SDLK_SPACE: tomb[mc].kepnev=="end.png" ? mc=0:mc++; printtutorial(tomb[mc].hova, tomb[mc].texts, tomb[mc].kepnev); SDL_Flip(screen); break; } break; case SDL_QUIT: *quit=1; break; } } *aktualis=menu; }
int main(int argc, char *argv[]) { unsigned freq=0; float time = 0; unsigned BASE = 0xFCA0; unsigned count = 0; CLRSCR(); BASE=AskForBaseAddress(BASE); CLRSCR(); count=AskForCountAddress(); //get counter offset BASE+=count; //add counter offset to base address DELAY(100); PUTS("8254 Counter Sample"); PUTS("--This program measures frequency and pulse width and generates frequency."); PUTS("--To measure frequency, connect a source to Clk IN on Pin 33."); PUTS(""); PUTS("Press any key to continue."); getch(); while(!kbhit()){ freq = freq; time = frequency_measure(BASE); printf("\nThe frequency is %10.3f\n\n", time); PUTS("Press any key to continue to pulse width test."); GOTOXY(1,WHEREY()-4); } getch(); CLRSCR(); //is this correct??? PUTS("--To measure pulse width, connect a source to Gate 1 on Pin 34."); PUTS("--Without a source, pulse width will read zero."); PUTS("--Ground Pin 37."); PUTS(""); PUTS("Press any key to continue."); getch(); while(!kbhit()){ time = pulse_width(BASE); printf(" Pulse1 %g \n", time); DELAY(1000); time = pulse_width(BASE); printf(" Pulse2 %g \n", time); DELAY(397); time = pulse_width(BASE); printf(" Pulse3 %g \n", time); time = pulse_width(BASE); printf(" Pulse4 %g \n", time); DELAY(300); time = pulse_width(BASE); printf(" Pulse5 %g \n", time); DELAY(10); time = pulse_width(BASE); printf(" Pulse6 %g \n\n", time); PUTS("Press any key to continue to next test."); GOTOXY(1,WHEREY()-8); } getch(); CLRSCR(); while(!kbhit()){ PUTS("Generating frequency..."); PUTS("Verify signal by connecting a frequency meter to Out 2 on Pin 35."); PUTS("Press any key to continue."); generatefrequency(BASE, 25000); GOTOXY(1,WHEREY()-3); } getch(); //DELAY(2000); }