Ejemplo n.º 1
0
/* display a list of AP on the screen, starting at "index", displaying
   only those specified in "flags" */
void display_list(int index, int flags)
{
	/* header */
	displayed = 1;

	clear_main();

	printf_xy(0, 0, "%d AP On:%s Tmot:%03d", numap, modes, timeout / 1000);
	printf_xy(0, 1, "OPN:%03d WEP:%03d WPA:%03d idx:%03d", num[OPN],
		  num[WEP], num[WPA], index);
	print_xy(0, 2, SCREEN_SEP);

	memset(cur_entries, 0, sizeof(cur_entries));

	if (flags & DISP_OPN)
		index = display_type(OPN, index, "OPN");

	if (flags & DISP_WEP)
		index = display_type(WEP, index, "WEP");

	if (flags & DISP_WPA)
		display_type(WPA, index, "WPA");

	return;
}
Ejemplo n.º 2
0
// prints the hi-score table
void printHiScores(void) {
    int i = 0;
    GraySetAMSPlane(DARK_PLANE);
    clrscr();
    GraySetAMSPlane(LIGHT_PLANE);
    clrscr();
    GraySetAMSPlane(DARK_PLANE);
    FontSetSys(F_8x10);
    DrawStr(36,0,"Jet Blaster",A_NORMAL);
    DrawStr(36,12,"High Scores",A_NORMAL);
    FontSetSys(F_4x6);
    DrawStr(53,95,"Jet Blaster v 1.0 by Ben Cherry",A_NORMAL);
    FontSetSys(F_6x8);
    for (i = 1; i <= 5; i++) {
        printf_xy(10,i*9 + 26,"%d. %s - %lu",i,hiScores[i].name,hiScores[i].score);
    }
    GraySetAMSPlane(LIGHT_PLANE);
    FontSetSys(F_8x10);
    printf_xy(36,0,"Jet Blaster");
    printf_xy(36,12,"High Scores");
    FontSetSys(F_4x6);
    printf_xy(53,95,"Jet Blaster v 1.0 by Ben Cherry");
    FontSetSys(F_6x8);
    for (i = 1; i <= 5; i++) {
        printf_xy(10,i*9 + 26,"%d. %s - %lu",i,hiScores[i].name,hiScores[i].score);
    }
    while (ngetchx() != KEY_ENTER);
    GraySetAMSPlane(DARK_PLANE);
    clrscr();
    GraySetAMSPlane(LIGHT_PLANE);
    clrscr();
}
Ejemplo n.º 3
0
// function to let the user type in a name for the hi-scores
void getName(unsigned long int score) {
    int key = 0;
    int x = 0;
    int y = 45;
    int back = 0;
    clrscr();
    GrayOff();
    FontSetSys(F_8x10);
    printf_xy(20,0,"New High Score!");
    printf_xy(60,12,"%lu", score);
    FontSetSys(F_4x6);
    printf_xy(53,95,"Jet Blaster v 1.0 by Ben Cherry");
    FontSetSys(F_6x8);
    printf_xy(11,25,"Please Enter Your Name:");
    while (key != KEY_ENTER) {
        key = ngetchx();
        if (key == KEY_BACKSPACE) {
            if (x>0) x--;
            key = (int)' ';
            back = 1;
        }
        if (x <= 9 && key != KEY_ENTER) {
            printf_xy(6*x+50,y,"%c",(char)key);
            hiScores[0].name[x] = key;
        }
        if (!back && x <= 9) x++;
        if (back) back--;
    }
    clrscr();
}
Ejemplo n.º 4
0
/* Display IP data for connected AP */
void display_ap(Wifi_AccessPoint * ap, int new_ap)
{
	static struct in_addr ip, gw, sn, dns1, dns2;
	int status;
	static struct hostent *google_addr = NULL;
	static struct in_addr g_ip;
	static int errno_cache;

	clear_main();

	status = Wifi_AssocStatus();

	print_xy(0, 0, "SSID :");
	print_xy(0, 1, ap->ssid);
	print_xy(0, 3, "State :");
	printf_xy(0, 4, "%s", ASSOCSTATUS_STRINGS[status]);
	if (status == ASSOCSTATUS_ASSOCIATED) {
		ip = Wifi_GetIPInfo(&gw, &sn, &dns1, &dns2);

		printf_xy(0, 6, "IP :        %s", inet_ntoa(ip));
		printf_xy(0, 7, "Subnet :    %s", inet_ntoa(sn));
		printf_xy(0, 8, "GW :        %s", inet_ntoa(gw));
		printf_xy(0, 9, "DNS1 :      %s", inet_ntoa(dns1));
		printf_xy(0, 10, "DNS2 :      %s", inet_ntoa(dns2));

		/* new association, try Google again */
		if (new_ap) {
			DEBUG_PRINT("new ap!");
			google_addr = gethostbyname("www.google.com");
			if (google_addr != NULL) {
				g_ip =
				    *(struct in_addr
				      *)(google_addr->h_addr_list[0]);
				if (try_google(&g_ip) == 0) {
					errno_cache = 0;
				} else {
					errno_cache = errno;
				}
			}
		} else {
			if (google_addr == NULL)
				printf_xy(0, 12, "DNS failed");
			else {
				printf_xy(0, 12, "Google IP : %s",
					  inet_ntoa(g_ip));
				if (errno_cache) {
					printf_xy(0, 13, "GET errno : %d",
						  errno_cache);
				} else {
					printf_xy(0, 13,
						  "GET : OK, see top screen");
				}
			}
		}
	}
}
Ejemplo n.º 5
0
/* Print "entry" on line "line" */
void display_entry(int line, struct AP_HT_Entry *entry, char *mode)
{

	if (line < DISPLAY_LINES)
		cur_entries[line] = entry;

	printf_xy(0, line * 3, "%s", entry->ap->ssid);
	printf_xy(0, line * 3 + 1,
		  "%02X%02X%02X%02X%02X%02X %s c%02d %3dp %ds",
		  entry->ap->macaddr[0], entry->ap->macaddr[1],
		  entry->ap->macaddr[2], entry->ap->macaddr[3],
		  entry->ap->macaddr[4], entry->ap->macaddr[5], mode,
		  entry->ap->channel, (entry->ap->rssi * 100) / 0xD0,
		  (curtick - entry->tick) / 1000);
	print_xy(0, line * 3 + 2, SCREEN_SEP);
}
Ejemplo n.º 6
0
void _main(void)
{
  OldInt5 = GetIntVec (AUTO_INT_5);
  SetIntVec (AUTO_INT_5, MyInt5);
  while (!kbhit()) printf_xy (50, 50, "Counter = %d  ", Counter);
  SetIntVec (AUTO_INT_5, OldInt5);
  GKeyFlush ();
}
Ejemplo n.º 7
0
// Main Function
void _main(void) {
	typedef struct {
		long int score;
		char * name;
	} hiscore;
	int i = 0;
	hiscore hiScoreArray[5] = {{20000,"ben cherry"},{20000,"ben cherry"},{20000,"ben cherry"},{20000,"ben cherry"},{20000,"ben cherry"}};
	clrscr();
	FontSetSys(F_8x10);
	printf_xy(36,0,"Jet Blaster");
	printf_xy(36,12,"High Scores");
	FontSetSys(F_4x6);
	printf_xy(53,95,"Jet Blaster v 1.0 by Ben Cherry");
	FontSetSys(F_6x8);
	for (i = 0; i <= 4; i++) {
		printf_xy(10,i*9 + 26,"%d. %s - %d",i+1,hiScoreArray[i].name,hiScoreArray[i].score);
	}
	ngetchx();
}
Ejemplo n.º 8
0
// drawHiScoreBoard - draws the hiscore board, and updates it with the hiscore from the latest game
void drawHiScoreBoard(unsigned long int newscore) {
	SCORE scores[MAX_HISCORES];
	short int loop, pos = -1;
	char name[10], str[50], *error = "File I/O Error";
	HANDLE dlg;

	// restore interrupt handlers
	OSSetSR(0x0000);

	if (!loadHiScores(scores)) {
		// cannot open hiscore file -- display error
		DlgMessage(error,"Unable to Load HiScore Data",BT_OK,BT_NONE);
		return;
	}

	// check if latest score is a highscore
	for (loop = (MAX_HISCORES - 1); loop >= 0; loop--) {
		if (newscore > scores[loop].score) {
			// new HiScore!!
			pos = loop;
		}
	}

	if (pos != -1) {
		// if we found a new hiscore
		if ((dlg = DialogNewSimple(DLGWIDTH,DLGHEIGHT)) == H_NULL) {
			DlgMessage("Memory Allocation Error","Not Enough Free Memory!",BT_OK,BT_NONE);
		} else {
			DialogAddTitle(dlg,"New Hiscore!",BT_OK,BT_NONE);
			DialogAddRequest(dlg,5,25,"Your Name:",0,9,11);

			sprintf(str,"You earned the #%hd hiscore position!",pos+1);
			DialogAddText(dlg,5,15,str);

			do {
				// truncate name variable
				name[0] = 0;
			} while (DialogDo(dlg,CENTER,CENTER,name,NULL) != KEY_ENTER);

			// free the dialog box memory
			HeapFree(dlg);

			// move the hiscore list down
			if (pos < (MAX_HISCORES - 1)) {
				for (loop = (MAX_HISCORES - 1); loop > pos; loop--) {
					scores[loop].score = scores[loop - 1].score;
					scores[loop].name[0] = 0;
					strcpy(scores[loop].name,scores[loop - 1].name);
				}
			}

			// fill in the new hiscore
			scores[pos].score = newscore;
			scores[pos].name[0] = 0;
			strcpy(scores[pos].name,name);

			if (!saveHiScores(scores)) {
				DlgMessage(error,"Unable to save HiScore Board",BT_OK,BT_NONE);
			}
		}
	}

	// display the hiscore board

	// clear the screen
	ClrScr();

	// draw the screen borders
	drawBorder();

	// draw the game logo
	drawLogo();

	FontSetSys(F_8x10);
	DrawStr(25,35,"Hiscore Board",A_NORMAL);
	FontSetSys(F_6x8);

	for (loop = 0; loop < 5; loop++) {
		printf_xy(20,50+loop*10,"#%hd %-9s %lu",loop+1,scores[loop].name,scores[loop].score);
	}

	ngetchx();

	// disable interrupts
	OSSetSR(0x0700);

	// wait for keypresses to dissipate
	delay(KEYDELAY);
}
Ejemplo n.º 9
0
// drawScore - draws the current player score at the lower-left
inline void drawScore(unsigned long int score) {
	printf_xy(SCOREX,SCOREY,"%lu",score);
}