3) Communication between two controllers
· mc1 check the RXC (UCSRA.7) bit at the end of each TV line. If RXC is set, a byte is read from UDR and append into a string. This is repeated until 0xff is received, which will terminate the string and define a full command string sent from mc2. At the end of each frame, the mc1 interpret this command string and execute the requested instruction. There are about 7 different types of instruction that mc1 can send to mc2.
i) CMD_CURSOR - This command is sent with another 6 bytes of data. row1,col1,icon1, row2,col2 and icon2. Upon receiving of these data, mc1 call video_icon(row1,col1,icon1) and video_icon(row2,col2,icon2) to draw two icons in the screen array. This command is used for cursor emulation. The first call to video_icon( ) restore the previous cursor location and the second call draw the new cursor location. These two sets of data are sent together to make sure the screen is updated at the same time.
ii) CMD_DRAW_ONE_ICON - This command is sent with another 3 bytes of data. row,col,icon. mc1 call video_icon(row,col,icon) to draw one icon in the screen array. This is a similar command as CMD_CURSOR except it only asked to draw one icon instead of two. This command is used when only one icon need to be updated at a time. This command is used extensively at the end of the game for uncovering all cells in the board.
iii) CMD_GAMES_START - Use to tell mc1 to start the timer when the games is started. mc1 is responsible for the games timer.
iv) CMD_GAMES_STOP - Use to tell mc1 to stop the timer when the games is stopped. This is often sent when games is over or won.
v) CMD_GAMES_REMAINING_MINES - This command has one more byte of data that contain the remaining number of mines in the games. mc1 use this to display the correct remaining mines on the screen.
vi) CMD_GAMES_RESTART - Use to tell mc1 to restart the games. This is usually called after user want to restart the games after games is ended.
vii) CMD_GAMES_WIN - Use to tell mc1
that the player has won the games. mc1
display a winning message on the screen