D36RETRY
The task
Poll with each host byte; poll again after 30 quiet ticks, and give up after 3 polls.
The control room polls the pump stations over a radio that sometimes loses a poll or an answer. A station that hears its poll answers with one status byte within a few ticks.
Each host message is one station number. Transmit it as the poll. If no answer arrives within 30 ticks, transmit the poll again. Deliver the answer to the host. After 3 polls with no answer, deliver $FF instead.
IN A, LOST goes to LOST if the timer runs out before a byte arrives. A station never answers late: after 30 ticks, its answer is lost for good.
The board
Key idea
Start the timer again for every poll. After a timeout the timer is off until the next TMR.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Keep the number of polls left in C. Each poll goes out, then TMR 30 starts the wait, then IN A, LOST.
Hint 2Show
At LOST, DJN C, POLL sends the poll again while polls remain. When C runs out, deliver $FF.
Hint 3Show
TOP: HIN B, JEQ B, -1, TOP, MOV C, 3. POLL: OUT B, TMR 30, IN A, LOST, HOUT A, JMP TOP. LOST: DJN C, POLL, HOUT $FF.
Solution
Reveal the Full SolutionThe complete program for RETRY. Open it only when you want the answer.
The reference program
The game's own solution to this ticket. It passes every test and scores exactly par on every benchmark.
TOP: HIN B
JEQ B, -1, TOP
MOV C, 3
POLL: OUT B
TMR 30
IN A, LOST
HOUT A
JMP TOP
LOST: DJN C, POLL
HOUT $FF- TICKS
- 512
- at par
- LINES
- 10
- at par
Another way: Slow
A second program that also passes, by a different road, at a cost on LINES.
TOP: HIN B
JEQ B, -1, TOP
HIN A
MOV C, 0
POLL: NOP
NOP
OUT B
TMR 30
IN A, LOST
HOUT A
JMP TOP
LOST: ADD C, 1
JNE C, 3, POLL
HOUT $FF- TICKS
- 512
- at par
- LINES
- 14
- over par