Reflex Game Specification
We want to program the following reflex game machine.
The player controls the machine with the three buttons on
the ZDS-II:
- putting a coin in a COIN slot, to start the game via
SW1 (PD3).
- pressing a READY button to start a reflex measure via
SW2 (PF6).
- pressing a STOP button to end a measure via SW3
(PF7).
The machine reacts to these commands by operating the
following devices, which use the ZDS-II MODEM LED's connected
to J3:
- a numerical display DISPLAY that displays reflex
times
- a GO lamp that signals the beginning of a measure via
DCD LED
- a GAME_OVER lamp that signals the end of a game via RX
LED
- a TILT lamp that signals that the player has tried to
cheat or has abandoned the game via DTR LED
- a RING_BELL that rings when the player hits the wrong
button via TX LED
When the machine is turned on the display shows the digit
zero, the GAME_OVER lamp is on the GO and TILT lamps are off.
The player then starts a game by inserting a coin. The normal
behavior is as follows:
Each game is composed of a fixed number MEASUREUMBER of
reflex measures, five in our sample program. A measure starts when the player presses the
READY button; then after a random time the GO lamp turns on
and the player must press the STOP button as fast as he can.
When he does so the GO lamp turns of and the reflex time
measured in milliseconds is displayed on the numerical
display. A new measure starts when the player presses READY
again. When the cycle of MEASUREUMBER measures is completed
the average reflex time is displayed after a pause of
PAUSE_LENGTH milliseconds and the GAME_OVER lamp is turned
on.
There are five exception cases. Two of them are simple
mistakes and make the bell ring:
- the player presses STOP instead of READY to start a
measure
- the player presses READY during a measure
In the next three cases the TILT and GAME_OVER lamps are
turned on the GO lamp is turned on and the game ends:
- when he is supposed to press the READY button the
player does not press it within LIMIT_TIME milliseconds
(one considers that the player has abandoned the game)
- when he is supposed to press the STOP button (that is
after the GO light turns on) the player does not press it
within LIMIT_TIME milliseconds (this is also considered as
an abandon)
- after he has pressed the READY button, the player
presses the STOP button before the machine turns the GO
lamp on, or at the same time this happens (the player tried
to cheat).
A last anomaly appears if the player inserts a coin during
a game. Then a new game is started afresh at once.
- as there is no built-in time in Esterel, we must
explicitly declare a MS signal for milliseconds. We use
one of the Z8 Enhanced! timer's to produced this system 'tick'.
- we make some choices for relations between input
signals: e.g., we notice that the specification does not
tell what should happen if both buttons are pressed
simultaneously, so we assume they never are.