D43WINDOW
The task
Send the orders as house frames without waiting between them; pass on every ACK.
The new satellite link to the depot answers slowly: each ACK comes back 250 ticks after its frame. The depot wants every ACK of a batch passed to the terminal within 1200 ticks, and waiting for each ACK before the next frame cannot do that.
Send each order as a house frame, as in Stop and Wait: $C1 $67, the length, the flags byte $00, the order, and the CRC-16, high byte first. Send the next order without waiting, and pass every ACK ($06) to the terminal as it arrives.
Orders are at most 8 bytes, and this card has 16 cells of RAM. The receive buffer holds only 2 bytes, so the ACKs cannot pile up until the end.
The board
Key idea
The far end checks each frame on its own, so frames can follow each other with nothing in between. Only the CRC has to be right.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
While reading an order from the host, check RXN between bytes and pass on any ACK that is waiting. A frame takes only a few ticks to send.
Hint 2Show
After the last order the host has nothing more, and a plain HIN would wait forever with ACKs still to come. TMR 3, then HIN A, READ lets the card go back and check the line.
Hint 3Show
READ: JNE RXN, 0, ACK, TMR 3, HIN A, READ, JEQ A, -1, SEND, then store the byte and loop. ACK: IN A, HOUT A, JMP READ. SEND: the frame from Stop and Wait, then back to the start.
Solution
Reveal the Full SolutionThe complete program for WINDOW. 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.
START: MOV B, 0
READ: JNE RXN, 0, ACK
TMR 3
HIN A, READ
JEQ A, -1, SEND
MOV [B], A
ADD B, 1
JMP READ
ACK: IN A
HOUT A
JMP READ
SEND: MOV CRC, $FFFF
OUT $C1
CRC $C1
OUT $67
CRC $67
OUT B
CRC B
OUT 0
CRC 0
MOV C, 0
JEQ B, 0, FIN
BODY: MOV A, [C]
OUT A
CRC A
ADD C, 1
JNE C, B, BODY
FIN: MOV A, CRC
SHR A, 8
OUT A
OUT CRC- TICKS
- 904
- at par
- LINES
- 31
- at par
Another way: Slow loop
A second program that also passes, by a different road, at a cost on TICKS and LINES.
START: MOV B, 0
READ: JEQ RXN, 0, HOST
IN A
HOUT A
NOP
NOP
JMP READ
HOST: TMR 6
HIN A, READ
JEQ A, -1, SEND
MOV [B], A
ADD B, 1
NOP
JMP READ
SEND: MOV CRC, $FFFF
MOV [12], $C1
MOV [13], $67
MOV [14], B
MOV [15], 0
MOV C, 12
HEAD: MOV A, [C]
OUT A
CRC A
ADD C, 1
JNE C, 16, HEAD
MOV C, 0
JEQ B, 0, FIN
BODY: MOV A, [C]
OUT A
CRC A
ADD C, 1
JNE C, B, BODY
FIN: MOV A, CRC
SHR A, 8
OUT A
OUT CRC- TICKS
- 1055
- over par
- LINES
- 36
- over par