D45WILL AND WONT
The task
Deliver the text between Telnet commands, and refuse every option.
Remote readers reach the catalog over Telnet. Commands come mixed in with their text, each starting with IAC, $FF. The catalog only wants the text, and this card refuses every option the far end proposes.
After IAC, $FB (WILL), $FC (WONT), $FD (DO), or $FE (DONT) is followed by an option byte. Answer DO x with IAC WONT x, and WILL x with IAC DONT x. Send nothing for WONT and DONT.
IAC IAC stands for one text byte, $FF. IAC followed by any other byte is a command of two bytes in all: drop it. Deliver every text byte to the host.
The board
Key idea
A refusal never needs an answer, so answering only DO and WILL can never start an endless exchange.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Most bytes are text and go straight to the host. Only $FF needs a second look at the byte after it.
Hint 2Show
After IAC: $FF is text. Below $FB the command is over. Otherwise read the option byte, then decide whether to answer.
Hint 3Show
IAC: IN A, JEQ A, $FF, TEXT, JLT A, $FB, TOP, IN B, JEQ A, $FD, DO, JEQ A, $FB, WILL, JMP TOP. DO: OUT $FF, OUT $FC, OUT B.
Solution
Reveal the Full SolutionThe complete program for WILL AND WONT. 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: IN A
JEQ A, $FF, IAC
TEXT: HOUT A
JMP TOP
IAC: IN A
JEQ A, $FF, TEXT
JLT A, $FB, TOP
IN B
JEQ A, $FD, DO
JEQ A, $FB, WILL
JMP TOP
DO: OUT $FF
OUT $FC
OUT B
JMP TOP
WILL: OUT $FF
OUT $FE
OUT B- TICKS
- 96
- at par
- LINES
- 18
- at par