Skip to main content

Co-ordinates

Graphics mode uses a cursor position which is remembered from one graphics command to the next while in graphics mode. The graphics mode cursor is not the same one used by normal type-out: Graphics protocol commands have no effect on the normal type-out cursor, and normal type-out has no effect on the graphics mode cursor. In addition, the graphics cursor's position is measured in dots rather than in characters. The relationship between the two units (dots, and characters) is recorded by the %TQHGT and %TQWID fields of the SMARTS variable of the terminal, which contain the height and width in dots of the box occupied by a character. The size of the screen in either dimension is assumed to be the length of a character box times the number of characters in that direction on the screen. If the screen is actually bigger than that, the excess is may or may not be part of the visible area; the program will not know that it exists, in any case.

Each co-ordinate of the cursor position is a 14-bit signed number, where zero is at the center of the screen (if the screen dimension is an even number of dots, then the visible negative points extend one unit farther that the positive ones, in proper two's complement fashion). Excessively large values of the co-ordinates will be off the screen, but are still meaningful.

An alternate mode is defined, which some terminals may support, in which virtual co-ordinates are used. The specified co-ordinates are still 14-bit signed numbers, but instead of being in units of physical dots on the terminal, it is assumed that +4000 octal is the top of the screen or the right edge, while -4000 octal is the bottom of the screen or the left edge. The terminal is responsible for scaling these virtual co-ordinates into units of screen dots. Not all terminals need have this capability; the %TQVIR bit in the SMARTS variable indicates that it exists. To use virtual co-ordinates, the server should send a %GOVIR; to use physical co-ordinates again, it should send a %GOPHY. These should be repeated at intervals, such as when graphics mode is entered, even though the terminal must attempt to remember the state of the switch anyway. This repetition is so that a loss of some output will not cause unbounded confusion.

The virtual co-ordinates are based on a square. If the visible area on the terminal is not a square, then the standard virtual range should correspond to a square around the center of the screen, and the rest of the visible area should correspond to virtual co-ordinates just beyond the normally visible range.

Graphics protocol commands take two types of cursor position arguments, absolute ones and relative ones. Commands that take address arguments generally have two forms, one for each type of address. A relative address consists of two offsets, delta-X and delta-Y, from the old cursor position. Each offset is a 7-bit two's complement number occupying one character. An absolute address consists of two co-ordinates, each 14 bits long, occupying two characters, each of which conveys 7 bits. The X co-ordinate or offset precedes the Y. Both types of address set the running cursor position which will be used by the next address, if it is relative. It is perfectly legitimate for parts of objects to go off the screen. What happens to them is not terribly important, as long as it is not disastrous, does not interfere with the reckoning of the cursor position, and does not cause later objects, drawn after the cursor moves back onto the screen, to be misdrawn.

Whether a particular spot on the screen is specified with an absolute or a relative address is of no consequence. The sequence in which they are drawn is of no consequence. Each object is independent of all others, and exists at the place which was specified, in one way or other, by the command that created it. Relative addresses are provided for the sake of data compression. They are not an attempt to spare programs the need for the meagre intelligence required to convert between absolute and relative addresses; more intelligence than that will surely be required for other aspects of the graphics protocol. Nor are relative addresses intended to cause several objects to relocate together if one is "moved" or erased. Terminals are not expected to remember any relation between objects once they are drawn. Most will not be able to.

Although the cursor position on entry to graphics mode remains set from the last exit, it is wise to reinitialize it with a %GOMVA command before any long transfer, to limit the effects of lost output.