Notes about the non-V6 screen display ------------------------------------- The window contents are stored as two, overlapping windows. The upper window lies on top of the lower window. The upper window is in a fixed-space font, and the cursor may be freely moved within it. If the upper window recedes, any text below the new boundary stays put, but will now scroll up and away with the lower window. The upper window contents are stored as arrays: upper_text[24][80] - the Unicode code of each character. 0 signifies the end of the line. upper_col[24][80] - the foreground and background colour (0xBF) of each character. The special code 0xFF indicates no colour - make it transparent. upper_font[24][80] - lower nibble indicates font (currently 1, 3 or 4) (0 indicates blank) upper nibble are flag bits: 0=Reversed 1=Bold 2=Italic Right, that was easy. It will be slightly slow on redraws, as we will need to take it one char at a time. One can speed it up a bit by, for example taking one character, finding out how many more characters have the same attributes, temporarily plonking a null byte after that character, then doing the appropriate string print routine. The character-by-character flexibility is required for quick drawing, though. We will refresh the window using Wimp_UpdateWindow every time the cursor is sent back to the lower window, moved backwards, or a keypress is waited for. The arrays are not actually static - height and width are variable. Further, for quick scrolling, we need to shuffle row pointers. Now, the lower window is totally different. The cursor position can never be set within it, except when it is totally cleared. It is a continuous text stream, except for the input of text, which we can handle slightly differently. It can, however scroll, and is normally in a proportional font. We will create a fast redraw storage system for the lower window. Each line contains a series of segments of text, preceded by n bytes of header. The header contains: Word 0: Offset to next segment. 0 signifies end of line Byte 4: Colour (0xBF) Byte 5: Font + Attribute (as above - Attr bits 0=Reverse 1=Bold 2=Italic 3=Fixed ) Byte 6: Length of text (in characters) Byte 7: ??? Bytes 8-11: Left-coordinate of segment, in millipoints Halfwords 12-: Unicode text (null terminated - next segment word aligned). We redraw a line by 1) Examining x coords to find the first+last segment to draw 2) Drawing background (special case - font 3 doesn't need background) 3) Drawing text segments. 4) Overlaying with upper window contents. When byte 0 = 0, it is the last segment, and contains no text. It does, however contain the necessary background colour. Hacky bit - the last segment is fixed at the end of the line buffer so it never needs to be shifted when the last real segment is printed to. Note that byte 2 is intended to look up directly the required font. The Fixed attribute is the combination of the bit in the header, and the actual attribute. Font 4 will simply be treated as font 1 with the fixed bit always set. There is, of course, a maximum limit to the amount that can be fitted on a lower window line. 4xscreen_width bytes will be allocated per line. Writing to the lower window will keep track of all the current attributes, so will know when to insert a new header, and when to continue to write to the last one. It will optimise out attribute/colour/font changes with no printing between them. Refresh will occur on a keyread, a window switch or a scroll. Scrolling will be performed with Wimp_CopyBlock followed by Wimp_UpdateWindow.