/* ###################################################################
**     Filename  : LCD.h
**     Date/Time : 10.23.2007, 13:07
**     Abstract  :
**          This implements an LCD screen to take character inputs and
**          print them to screen.
**
** ###################################################################
*/

#ifndef _LCD_H
#define _LCD_H

/* ###################################################################
**
**  Constant Definitions
**
** ###################################################################
*/

#define COMMAND                   'c'       // Character to denote COMMAND
#define DATA                      'd'	    // Character to denote DATA
#define RS_LINE                   BIT0HI    // Of Port M
#define ENABLE_LINE		            BIT1HI    // Of Port M
#define INPUT_LINE                BIT2HI    // Of Port M
#define CLOCK_LINE                BIT3HI    // Of Port M
#define PLAYER_ONE_ADDRESS        0x80      // First address to start writing  RED:
#define PLAYER_TWO_ADDRESS        0x8B      // First address to start writing BLUE:
#define TIMER_ADDRESS             0xC9      // First address to start writing the time left
#define PLAYER_ONE_SCORE_ADDRESS  0x87      // First address to start writing Red Score
#define PLAYER_TWO_SCORE_ADDRESS  0x92      // First address to start writing Blue Score
#define WINNER_ADDRESS            0xC4      // First address to start writing who won
#define INSERTCOIN_ADDRESS        0xC4      // First address to start writing "Insert Coin" after game
#define LAST_ADDRESS              0x93	  // The Hex value of the last address on the LCD
#define DISPLAY_COMMAND           0x18      // The Hex value for the command to shift display left
#define WAIT_LONG                 10        // The long wait period
#define WAIT_SHORT                2         // The short wait period
#define WAIT_MIDDLE               4         // The middle wait period
#define CLOCK_WAIT                50        // The number of assignments to wait for a clock cycle

/* ###################################################################
**
**  Function Prototypes
**
** ###################################################################
*/

/******************************************
Function:       LCDInit(void);
Description:    It will initialize the LCD to take character inputs. If
                done correctly the blinker will be one character off-
                screen. This function must be run before using the LCD.
Input:          None
Output:         None
Revised:        PY          11/13/07
*********************************************/
void LCDInit(void);

/******************************************
Function:       LCDputchar(void)
Description:    It will take the character passed as the input and place
                it in the current position of the blinker. It will then
                scroll the entire display one character to the left.
Input:          char: character to be output
Output:         None
Revised:        PY          11/13/07
*********************************************/
void LCDputchar(char character);

/******************************************
Function:       LCDWriteString(char stringToWrite [], unsigned int address)
Description:    Will write the string to the specified address
Input:          char stringToWrite [], unsigned int address
Output:         None
Revised:        PY          11/14/07
*********************************************/ 
void LCDWriteString(char stringToWrite[], unsigned int address);

/******************************************
Function:       WriteScore(int p1_score, int p2_score)
Description:    Writes Player's score in the appropriate address
Input:          int score
Output:         None
Revised:        PY          11/14/07
*********************************************/ 
void WriteScore(int p1_score, int p2_score);

/******************************************
Function:       WritePlayerOneScore(int score)
Description:    Writes Player One's score in the appropriate address
Input:          int score
Output:         None
Revised:        PY          11/14/07
*********************************************/ 
void WritePlayerOneScore(int score);

/******************************************
Function:       WritePlayerTwoScore(int score)
Description:    Writes Player Two's score in the appropriate address
Input:          int score
Output:         None
Revised:        PY          11/14/07
*********************************************/
void WritePlayerTwoScore(int score);

/******************************************
Function:       WriteTime(int time)
Description:    Writes the current time to the appropriate address
Input:          int time
Output:         None
Revised:        PY          11/14/07
*********************************************/
void WriteTime(int time);

/******************************************
Function:       LCDGameSetUp(void)
Description:    Sets up the LCD screen for starting the game
Input:          None
Output:         None
Revised:        PY          11/14/07
*********************************************/
void LCDGameSetUp(void);

/******************************************
Function:       LCDGameEnd(int player1_score, int player2_score)
Description:    Prints out the correct score
Input:          None
Output:         None
Revised:        PY          11/14/07
*********************************************/
void LCDGameEnd(int red_score, int blue_score, int win_threshold);

/*********************************************
Function:     LCDResetGame(void)
Description:  Prints out "Insert Coin"
Input:        None
Output:       None
Revised:      CH        11/16/07
*********************************************/
void LCDResetGame(void);

/*********************************************
Function:     LCDWaitTrigger(void)
Description:  Prints out "Press Trigger To Begin"
Input:        None
Output:       None
Revised:      CH        11/16/07
*********************************************/
void LCDWaitTrigger(void);

#endif