ECAD and Architecture Practical Classes
In this final part of the lab, you need to implement the nextstate function whose outline was given in the assembler code on the previous page. This should take the current state of the game from the frame buffer, compute the next state, storing this in memory, and once this has been completed copy the contents of the memory back into the frame buffer. To load the base address of the temporary memory into a register, use
The rules for calculating the next state of a cell given its current state and the surrounding cells are:
The nextstate function should be called when KEY3 is pressed on the board. The code to do this will be the same style as for the mouse button handler. You might also like to have a "run" or "auto-repeat" mode, e.g. when SW0 is "on" the nextstate function is called at a reasonable rate.
Once this is working, you should be able to toggle squares on and off with the mouse, as well as advance the state by one generation by pressing the key. If you start with the initial pattern given to you, and simply keep advancing the state again and again, you should notice a stream of gliders moving diagonally down the screen. The initial pattern pattern gives a glider gun, whereby the pattern is in a loop, and continuously emits a stream of gliders from it.
The second lab is now finished :-)
You may find the program Game of Life program useful for debugging. This is a working version of the Game of Life designed to have the same size grid and semantics as the lab exercise. You can open .mif files that are in the correct format and it will display them on screen (try opening initial.mif from your project directory). You can toggle squares with the mouse and also save the current state of the grid on screen. This will enable you to create your own default pattern, simply save the file as initial.mif in your project directory, update the Memory Initialisation Files by selecting Processing | Update Memory Intialisation File, then run the assembler by selecting Processing | Start | Start Assembler. Finally, re-program the device and your new pattern should be displayed on the screen.