50. Screen opcode 2 draws a bitmap, and that is not what fills the region¶
Section 49 named opcode 2 as the only referent of the region that holds most of a config, and left what it points at as a conjecture. The firmware settles the conjecture and refuses the conclusion that was hoped for: opcode 2 draws a picture, the picture states its own size, and the size is far too small to be what the region holds.
The route through the firmware¶
On the Harmony 700 2.8 image, base 0x9000. The screen dispatcher is at 0x1879C and its opcode
chain at 0x187A8, section 40. Decoded with harmony/pic18/chains.py, because an XORLW chain's
literals are not its case values, case 2 lands at 0x187D6, which is an RCALL to 0x183EA and a
branch back to the dispatcher. The same shape is at 0x16E44 on the complete Harmony 600 0.2 image.
0x183EA is the instruction's own handler and it does four things: read the two position bytes,
read a three byte address, seek the config stream to that address, and call 0x0E3EC with the
position in 0x2A1 and 0x2A2. It saves TBLPTR before the seek and restores it after, which is
what makes the picture a separate object rather than something inline in the program.
0x0E3EC is the renderer. It reads one byte, the kind, and switches on it through the chain at
0x0E3F6:
| kind | handler | what it is |
|---|---|---|
| 0 | 0x0E404, body at 0x0E44E |
raw rows |
| 1 | 0x0E426, body at 0x0E530 |
the skip and literal encoding a glyph uses |
| 2 | 0x0E44C |
a bare RETURN: valid, draws nothing |
| anything else | falls through | returns without reading the header |
The object¶
+0x00 u8 kind
+0x01 u16 stride, in bytes per row
+0x03 u16 rows
+0x05 the pixels
The kind 0 body reads those two u16 and then loops: while row < rows, put stride in 0x29E,
the position plus the row in 0x299 and 0x29A, call the row writer at 0x0E292, then set
0x6DE/0x6DF to stride and call 0x10BAC to advance the stream.
strideis in pixels, not bytes, and this section said bytes. A pixel is two bytes here as it is in a glyph, so a raw picture is5 + 2 * stride * rows. Corrected in section 54, where the corpus settles it: consecutive pictures then sit exactly that far apart, and 14 of the Harmony 600's 15 gaps are exact. Two claims below rest on the halved figure and are wrong because of it, both marked where they appear.
Kind 1 reads and discards the same four header bytes, then runs a byte at a time: 0x00 ends,
0x80 advances a row, bit 7 set skips that many, and a value below 0x80 introduces that many
literal pixels. That is the base slot 7 glyph encoding of section 46, byte for byte, which is why
stride is recorded in bytes rather than pixels: a pixel is two bytes on both paths. 0x00 and
0x80 are separate cases in the code ahead of the generic bit 7 path, so the row break is read
rather than charitably interpreted as a skip of zero.
The encoded extent has a closure, which is why it is claimed. This section said on the day it
landed that kind 1's extent was not established and that the readers would return no length rather
than guess one. That was resolved within the hour and is corrected here rather than rewritten: the
terminator makes the extent walkable, and the check that it is walked correctly is that the body
discards the header and then breaks rows exactly rows - 1 times anyway. Two independent
statements of one number, and a walk one control byte out of step would agree with neither. It
holds for all 51 encoded pictures in the corpus, on arch 8, arch 12 and arch 14.
Two rails for a writer, both from the code rather than from the data. The firmware loads only
the low byte of each u16, so a stride or a row count above 255 is taken modulo 256 with no
error. And the row loop stops drawing above row 128 but keeps advancing the stream, so a picture
taller than that is read in full and partly discarded. Neither is visible in the corpus, where the
largest stride is 88 and the largest row count 18.
What the corpus holds¶
gspm.Container.bitmaps() walks every reachable screen program, collects every opcode 2 address
and decodes each header. Every one of them decodes, in every container:
| sample | pictures | kinds | strides | rows | raw bytes |
|---|---|---|---|---|---|
| Harmony 700, both | 4 | 0 and 1 | 12 | 10 | 536 |
| Harmony 600 | 3 | 0 and 1 | 12 | 10 | 411 |
| Harmony One, both | 16 | 0 and 1 | 20, 22, 88 | 10, 11, 18 | 6795 |
| 880, arch 8 | 10 | 0 and 1 | 16 to 19 | 10 | 2423 |
| 525, arch 9 | 0 | 0 | |||
| the three safe mode | 0 | 0 |
These counts are the ones reachable at the time, before sections 53 and 54 made a mode record's own screen program a root. The corpus holds 16 to 29 pictures per config, not 3 to 16, and the byte totals are an order of magnitude larger. The conclusion this section drew from the small numbers is reversed there.
No kind outside 0 and 1 appears, no header runs past the end of its container, and the strides are per model rather than per config, which is what a layout resource looks like rather than user data. The two container kinds that emit no opcode 2 have no pictures, the same negative case as section 49's.
The negative, which is the point¶
6795 bytes of pictures against a 1374394 byte region on the Harmony One. Opcode 2 accounts for about one part in two hundred of what it points into, counting both kinds at their full extent.
Reversed by sections 53 and 54. Opcode 2 accounts for 98% of the Harmony 600's region, 93% of the 700's, 97% of arch 8's and 48% of the Harmony One's, once the programs inside mode records are reachable and the raw extent is not halved. The negative below was a measurement of what could be reached, not of what exists. Three measurements were made to find the rest, and all three came back negative. They are recorded here so nobody repeats them:
- ~~The pictures do not tile.~~ Wrong, and wrong because of the halved extent above. They
tile exactly, once a raw picture is
5 + 2 * stride * rows: 14 of the Harmony 600's 15 gaps are precisely the extent of the picture before them. Corrected in section 54 and the test now asserts the tiling. - There is no pointer table into the region. The two longest ascending runs of three byte values landing in the region, 231 and 157 entries with near constant strides, both turned out to be base slot 10's own pointer array read one byte out of alignment. A misaligned read of an ascending table is itself ascending, which is worth knowing before trusting the next one.
- The bytes look like pixels and that is not a decode. On the Harmony 600, which has a monochrome screen, the region holds 1119 distinct sixteen bit words and 40% of the non zero ones are exact RGB565 greys when read big endian, against roughly 0.05% for random data; long runs read as monotone gradients only in that byte order. The Harmony One, which has a colour screen, holds 31056 distinct words. Suggestive, consistent with the two panels, and not sufficient: no image width fits, nothing frames the data, and a hypothesis that cannot say where one picture ends is not a reading.
So section 49's ranking stands and its explanation does not. The region is still the largest single unknown in the format, and the next move is no longer "read opcode 2's handler", because that is done. It is to find the second referent, which means sweeping addresses out of the sections that are decoded but whose record fields are not all named.
Where it lands¶
docs/config-format.md, under the screen language.src/harmony/gspm.py:Bitmap,Container.bitmap_at,Container.bitmap_reference,Container.bitmaps, andContainer.reachable_screen_programs, whichtools/screen_dump.pynow calls instead of keeping its own copy of the walk.packages/codec/src/screen.ts: the same four, and aslot-11-bitmapclaim in the byte accounting, for both kinds.tests/test_interpreter.pyTestTheBitmapandpackages/codec/test/screen.test.ts.
Section 49 | the archive | section 51. Section 50 of the findings archive, which is frozen; the reference holds the current answer. The archive on GitHub.