Machine Problem 5, due Dec 6

Part of the assignments for 22C:60, Fall 2004
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

All assignments will be due at the start of class on the day indicated, and unless there is what insurance companies call "an act of God" - something outside your control; the only exceptions to this rule will be by advance arrangement.

  1. Conway's Game of Life, part III

    Start with any solution to Machine Problem 4, and modify it so that tapping on the space bar during the running of the modified game of life will start or stop the game. Initially, the game is stopped, but when you tap the space bar, it should start. When you tap the space bar again, it should stop. As a rule, the game should stop after it completes a screen update, before computing the next generation. It should not stop in the middle of an update. Keys other than space should be ignored.

    Hint: The code to stop the game will involve your own direct access to the keyboard status register, while the code to restart the game can be written using a direct call to kbgetc() in the Hawk monitor.

  2. Interpret Commands

    When you stop the game, a cursor should appear on the screen at the current location (initially, this location should be the center of the screen). If the current location contains an X, the cursor should be displayed as a O (capital O). If the current location contains a space, the cursor should display as a plus sign.

    When the user enters the letters h, k, u or m, the cursor should move left, right, up or down (these letters are to the left, right, top and bottom of the J key on the keyboard -- we are using them as if they were arrow keys).

    The cursor should never go off the edges of the game board. It should hitting a key that would move it off should have no effect.

    Hitting the j key should change the current location on the board from X to space or space to X (but of course, the location is displayed as O or +.

    Your command interpreter should be in a separate source file from your main program. It can share a .h file with the main program in order to get info about the board dimensions and whatnot.

  3. Submit

    Your solution must be contained in a directory called mp5, not MP5, not Mp5, not machineproblem5, and not as a series of separately submitted source files. This directory should contain exactly 4 SMAL Hawk source files, main.a, rules.a, init.a, and command.a, plus any auxiliary .h files.

  4. Grading

    We will assemble your code and try it, focusing on the editor functions, and then we will look at main.a focusing on how you handle the keyboard and the communication with command.a, and we will look at command.a focusing on everything there. The actual game of life must work!

    Given that your solution works, grading will be based on the clarity of your code and correctness of your modularization.