Missions
spacetetris: A Power of 10 Audit
A strictly compliant embedded C game engine with no dynamic memory.
The goal was not only to make Tetris. The goal was a deterministic and hardware-independent state machine. The machine obeys the NASA Power of 10 rules and MISRA C:2012.
The engine does not call malloc. It does not call free. All the game state
grids are global, or they are on the stack. The program uses the same quantity
of memory at the start and at the end.
The physics core and the state core stay separate from the I/O. tetris.h has
no standard library includes for input or output. The core does not know what
draws it. Therefore a new display does not change the core.
Finite state machines and counted ticks control the flow. The state logic does not call a sleep function. A sleep hides how long the program waits. It also makes a run difficult to repeat.
(This case study is not complete. More data follows when I correct the leaks in the I/O layer.)