BasketMC

Exposure Mask Viewer, Episode 11: TIS-100

  • Published on

Episode 11 opens Exposure Mask Viewer, a puzzle that asks for rectangles drawn from four numbers at a time. Basket borrows code from two puzzles already solved, runs out of room in a node, chases a stall with breakpoints, and gets every test to pass before the video ends.

Four numbers, one rectangle

The task panel reads: "Read an X value from IN. Read a Y value from IN. Read a width value from IN. Read a height value from IN. Draw a rectangle of that size at the specified location." The target image beside it is a scatter of white rectangles in different sizes. The commentary works out that it needs two loops, one across and one down, and that white is the value 3.

Rather than start from nothing, Basket opens Image Test Pattern 1 and brings back its drawing loop, with "MOV 30 ACC" and "LOOP1: MOV 3 DOWN". The first nodes simply pass the X and Y values along with "MOV UP RIGHT" and "MOV LEFT DOWN".

TIS-100 Exposure Mask Viewer puzzle with every node empty: the task panel lists reading an X, a Y, a width and a height value from IN and drawing a rectangle of that size, beside a target image of white rectangles and an empty image box.

A node to remember the width

The loop needs to know the width again for every row. The commentary goes looking for "the thing we already wrote before for storing a value", finds it in Signal Multiplier, and copies it over. On the recording it is described as a buffer: send it a positive number and it stores it, send it a negative one and it hands the stored value back. Basket labels that node "#WIDTH" and trims out the output part it does not need here.

TIS-100 editor in Exposure Mask Viewer: a node labeled #WIDTH holds pasted storage code with SWP, JLZ RET and SAV lines, while the node beside it shows a red UNDEFINED LABEL warning above two loops.

Out of room

The middle of the video is a long rework. The first attempt gets parked in the bottom left node, and a second storage node, "#X", goes in on the right so the X value can be sent again for each row. The top center node becomes the controller: it reads the four values, sends X and Y down, adds 1 to Y for the next row, asks #WIDTH for the width with "MOV -1 LEFT", and counts the height down.

The first run stops with nothing drawn. "So deadlock. Interesting." The #X node never got its "-1", and there is no line left to send it: the controller fills all fifteen. "So we are out of space." To make room, "JEZ S" and "JMP L1" become a single "JGZ L1", letting the loop fall through to the start when the height runs out, and "MOV -1 RIGHT" goes in.

TIS-100 Exposure Mask Viewer layout: storage nodes labeled #WIDTH and #X on either side of a top center node that starts with S: MOV UP RIGHT, a drawing loop below it, and an older program parked in the bottom left node.

A wrong direction

It stalls again. Basket sets a breakpoint and steps through, watching the values go back and forth between the nodes. Then the commentary spots it: the drawing loop is "moving three to the right which doesn't make any sense." The line "L1:MOV 3 RIGHT" becomes "L1:MOV 3 DOWN", toward the image.

This time the rectangles fill in one row at a time. "It's like a dot matrix printer."

TIS-100 running test 1 of Exposure Mask Viewer: the image box has filled in most of the white rectangles from the target, with one still being drawn at the left, and the drawing node reads L1:MOV 3 DOWN.

Where it ends

Test 1 passes in 1087 cycles, and the rest pass after the commentary speeds the run up. The result is 1087 cycles, 6 nodes and 38 instructions. A friend's score beside it has fewer cycles and only four nodes but more instructions. The commentary decides not to change it now, noting that the storage node is handy but costs a node. The segment map shows Exposure Mask Viewer as nominal, and the video cuts to the end card.