Tetris for MIPS / SPIM
You SPIM me right round, baby
right round like a record, baby
Right round round round
If these lyrics are conjuring up unpleasant images in your head, you really need to disconnect yourself from the internets.
Andrew Lloyd Webber, 1992
For the second semester of the 2006/2007 academic year, I was stationed at the University of Nottingham Nottingham, England’s other other campus: the University of Nottingham Ningbo, China, where I taught the G51CSA course.
Partly to make a point to the students that the SPIM simulator / assembler is capable of much more than just the trivial programs they’ve been asked to write, but mostly to alleviate boredom, I wrote this implementation of tetris during a handful of afternoon lab sessions.
Feel free to improve on it. Idea include:
- Implement the next piece display; the logic is already there.
- Use a timer interrupt rather than looping for more consistent timing.
- Use keyboard interrupts instead of polling.