All pastes #983297 Raw Edit

ccfreak2k

public c v1 · immutable
·published 2008-04-13 06:51 UTC
rendered paste body
/* screens.c *//* this file contains the functions that handle the various subscreens a user might encounter in his ATM adventure. *//* (c) 2008 by ccfreak2k */welcomemessage() {	loli_clear();	loli_bgcolour(BACKGROUNDCOLOR);	loli_print("K E Y C A R D",8,5);	loli_print("E N A B L E D",8,6);	loli_print("   _ _____ __  __",5,7);	loli_print("  /_\\_   _|  \\/  |",5,8);	loli_print(" / _ \\| | | |\\/| |",5,9);	loli_print("/_/ \\_\\_| |_|  |_|",5,10);		loli_print("Insert keycard now.",5,12);	loli_print("Version: 1.0 Build: 4",0,17);}transactionMenu()  {	int menuChoice;	/* present the main transaction menu. */	loli_clear();	loli_bgcolour(BACKGROUNDCOLOR);	loli_print("------------------------------",0,0);	loli_print("WELCOME!",0,1);	loli_print("User ID confirmed - Hello!",2,2);	loli_print("Current card ID:",3,3);	loli_print("Transaction menu:",0,6);	loli_print("1. Withdraw",0,8);	loli_print("2. Deposit",0,9);	loli_print("3. View Funds",0,10);	loli_print("Use the buttons on the right",0,12);	loli_print("to choose.",0,14);	loli_print("WELCOME!",22,17);	loli_print("------------------------------",0,18);	/* Figure out which choice they made and return an appropriate value to the caller. */	while (true == true) {		if (inport(0) == 0) {			return 0;		}		switch (inport(2)) {			case 1: return 1;			case 2: return 2;			case 4: return 3;		}	}}withdrawScreen() {	/* Show the user the withdraw screen to allow them to withdraw funds */	char fundsString[25];	char fundsAmountString[6];	int fundsAmount;	int currentFunds;	fundsAmount = 0;	loli_clear();	loli_bgcolour(BACKGROUNDCOLOR);	loli_print("------------------------------",0,5);	loli_print("Withdraw Funds",8,6);	loli_print("------------------------------",0,7);	loli_print("Please choose the amount of",0,9);	loli_print("funds to withdraw by using the",0,10);	loli_print("arrow keys on the right, then",0,11);	loli_print("press enter to accept.",0,12);	loli_print ("Funds to withdraw:",0,14);	while (true == true) {		/* Main loop to process input and act on it. */		switch (inport(2)) {			case 8:				/* The user is trying to increase amount. */				if (fundsAmount >= currentFunds) {					loli_print("Can't withdraw any more funds!",0,14);					if (fundsAmount > currentFunds)						fundsAmount = currentFunds;				else					fundsAmount -= FUNDSINCAMOUNT;					itoa(fundsAmount,fundsAmountString);					strcpy(fundsString,"Funds to withdraw: ",0,14);					strcat(fundsString,fundsAmountString);					loli_print(fundsString);					loli_print("                              ",0,15);				}			case 16:				/* The user is trying to decrease amount. */				if (fundsAmount <= 0) {					loli_print("Can't withdraw negative funds!",0,15);					if (fundsAmount < 0)						fundsAmount = 0;				else					fundsAmount += FUNDSINCAMOUNT;					itoa(fundsAmount,fundsAmountString);					strcpy(fundsString,"Funds to withdraw: ",0,14);					strcat(fundsString,fundsAmountString);					loli_print(fundsString);					loli_print("                              ",0,15);				}			case 32: return fundsAmount;			case 64: return 0;		}	}}depositScreen() {	char fundsString[24];	char fundsAmountString[6];	int fundsAmount;	int currentFunds;	fundsAmount = 0;	loli_clear();	loli_bgcolour(BACKGROUNDCOLOR);	loli_print("------------------------------",0,5);	loli_print("Deposit Funds",8,6);	loli_print("------------------------------",0,7);	loli_print("Please choose the amount of",0,9);	loli_print("funds to deposit by using the",0,10);	loli_print("arrow keys on the right, then",0,11);	loli_print("press Enter to accept.",0,12);	loli_print ("Funds to deposit:",0,14);	while (true == true) {		switch (inport(2)) {			case 8:				/* User is increasing funds. */				if (fundsAmount >= 65535 - currentFunds) {					loli_print("Can't deposit any more funds!",0,15);					if (fundsAmount > 65535 - currentFunds)						fundsAmount = 65535 - currentFunds;				else					fundsAmount -= FUNDSINCAMOUNT;					itoa(fundsAmount,fundsAmountString);					strcpy(fundsString,"Funds to deposit: ",0,14);					strcat(fundsString,fundsAmountString);					loli_print(fundsString);					loli_print("                              ",0,15);				}			case 16:				/* User is decreasing funds. */				if (fundsAmount <= 0) {					loli_print("Can't deposit negative funds!",0,15);					if (fundsAmount < 0)						fundsAmount = 0;				else					fundsAmount += FUNDSINCAMOUNT;					itoa(fundsAmount,fundsAmountString);					strcpy(fundsString,"Funds to deposit: ",0,14);					strcat(fundsString,fundsAmountString);					loli_print(fundsString);					loli_print("                              ",0,15);				}			case 32: return fundsAmount;			case 64: return 0;		}	}}fundsScreen() {	char fundsString[26];	char currentFundsString[6];	int currentFunds;	loli_clear();	loli_bgcolour(BACKGROUNDCOLOR);	loli_print("------------------------------",0,5);	loli_print("Current Funds",8,6);	loli_print("------------------------------",0,7);	itoa(currentFunds, currentFundsString);	strcpy(fundsString, "You currently have: ",2,9);	strcat(fundsString, currentFundsString);	loli_print(fundsString);	loli_print("Press Enter to continue.",3,11);	while (true == true) {		if (inport(2) == 32) {			return; }	}}endgameScreen() {	char fundsString[32];	char currentFundsString[6];	int currentFunds;	loli_clear();	loli_bgcolour(BACKGROUNDCOLOR);	loli_print("------------------------------",0,0);	loli_print("THANK YOU!",0,1);	loli_print("Thank you for using the ATM!",1,7);	itoa(currentFunds,currentFundsString);	strcpy(fundsString,"Your funds amount is now: ");	strcat(fundsString,currentFundsString);	loli_print(fundsString,0,9);	loli_print("Please remove your keycard.",1,11);	loli_print("THANK YOU!",20,16);	loli_print("------------------------------",0,17);	while (true == true) {		if (inport(0) == 0) {			welcomemessage();			return;		}	}} errorScreen(a) int a; {	loli_clear();	loli_bgcolour(BACKGROUNDCOLOR);	loli_print("------------------------------",0,0);	loli_print("ERROR!",0,1);		loli_print("An error has occurred while",0,4);	loli_print("processing the transaction.",0,5);	switch (a) {		case 1:			loli_print("The transaction could not be",0,6);			loli_print("completed because of a",0,7);			loli_print("transmission error.",0,8);		case 2:			loli_print("Your account has been flagged",0,6);			loli_print("for review. While flagged,",0,7);			loli_print("your account funds will be",0,8);			loli_print("unavailable and inaccessable.",0,9);		default:			loli_print("An unknown error has occurred.",0,6);			loli_print("The transaction cannot be",0,7);			loli_print("completed.",0,8);	}	loli_print("We apologize for the",0,11);	loli_print("inconvenience.",0,12);	loli_print("Please remove your keycard.",0,14);	loli_print("ERROR!",24,16);	loli_print("------------------------------",0,17);		while (true == true) {		if (inport(0) == 0) {			welcomemessage();			return;		}	}}