Low Level Design
The flow chart for the codes running in mc1 is
The codes used in mc1 is the same code in  with some additional codes to handle the communication between mc1 and mc2. A byte is read at the end of each TV lines and append to a command string. When it received 0xFF, the command string is complete and process at line 231. The screen array is being updated according to the content in the command string.
The flowchart for mc2 is
Commands are sent from mc2 to mc1 throughout the whole program in mc2 whenever it is necessary.
The program on both microcontrollers can be roughly broken down in to a
few parts based on their functionality.
Codes that handle
1) Interfacing with mouse.
2) TV image generation.
3) Communication between two controllers
4) Cursor's movement emulation and refresh of board status on TV screen..
5) Games computation
The codes for some functions are scattered on
both microcontrollers. The diagram above gives a brief idea on where the codes
with different functions are physically located.
We have given explanation for functions of these 5 categories in the rest of this report.
Parts tricky to write
1) The mouse interface is the hardest part in this project. Mainly due to difficulty in debugging. Timing is very critical when reading data bit by bit.
2) Communication between the two microcontrollers were unexpectedly hard. It turned out that the TV controller is too busy that it miss data frequently. We thought of many ways to solve this problem, and we end up using the same scheme that we used in lab4 plus some timing adjustment on the mouse controller.
3) Cursor emulation also took us a lot of time due the slow communication between two controllers. We need to make sure that both the old cursor icon and the new cursor icon is updated on the screen at the same time.
4) The game itself is actually more complex, but it did not take us as much time as the mentioned tasks. The reason is it is easier to debug the program using hyperterminal. Since time is not a constraint on the second controller, the game does not have to be highly optimized. Of course, we still tried to optimized the codes as much as possible.