Acorn MOS - Text, Graphics, Printing

Text, Graphics, Printing

The MOS permits textual output intended for the screen to be directed instead to the printer, or both at once, allowing for very trivial printing support for plain text. Graphics printing is not supported and has to be written separately.

Graphics and in general all screen output is handled in a very unusual way. The ASCII control characters are almost entirely given new significance under MOS: known as the "VDU drivers", they are interpreted as video control characters. VDU 30 (i.e. ASCII 30) moves the cursor to (0, 0), VDU 4 and 5 select whether text should be drawn at the graphics or text cursor, VDU 12 clears the screen and VDU 14 and 15 turn scroll lock on and off. Thus, pressing ctrl-L will clear the screen and ctrl-N will enable scroll lock. VDU 2 and 3 toggle whether screen output is echoed to the printer.

Many more control characters take parameters: one or more characters that follow are used solely for their bit value as a parameter and not as a control code. VDU 19 handles palette remap; the following five bytes represent the palette entry, the desired colour and three reserve bytes. VDU 31 locates the text cursor to the location held in the following two bytes. VDU 17 sets the text colour and 18 the graphics colour. VDU 25 uses the succeeding five bytes to move the graphics cursor and plot solid and dashed lines, dots and filled triangles, the extent of graphics in MOS 0 and 1. The first byte is the command code, followed by the x and y co-ordinates as two byte pairs.

There is a single operating system command to write a character, OSWRCH, which is responsible for all text and graphics. For example, to move the cursor to (10, 15), you could write (in 6502 assembler):

LDA #31: JSR OSWRCH \ move text cursor LDA #10: JSR OSWRCH \ x-coordinate LDA #15: JSR OSWRCH \ y-coordinate

(LDA loads a value into the accumulator; JSR is "jump to subroutine".) On the third OS call, the cursor will move. The following code would draw a line from (0, 0) to (0, +100):

LDA #25: JSR OSWRCH \ begin "PLOT" (ASCII 25) command LDA #4: JSR OSWRCH \ command k=4, or move absolute LDA #0: JSR OSWRCH: JSR OSWRCH: JSR OSWRCH: JSR OSWRCH \ send (0, 0) as low, high byte pairs LDA #25: JSR OSWRCH \ begin PLOT LDA #1: JSR OSWRCH \ k=1 - draw relative LDA #0: JSR OSWRCH: JSR OSWRCH \ x = 0 LDA #100: JSR OSWRCH \ y = 100 (low byte) LDA #0: JSR OSWRCH \ high byte

In BBC BASIC you can perform the above as any of the following:

VDU 25, 4, 0; 0; 25, 4, 100; 0; PRINT CHR$(25); CHR$(4); CHR$(0); ... etc. PLOT 4, 0, 0: PLOT 1, 0, 100 MOVE 0, 0: DRAW 0, 100: REM absolute co-ords only!

Graphics in the Acorn MOS use a virtual graphics resolution of 1280×1024, with pixel positions mapped to the nearest equivalent pixel in the current graphics mode. Switching video resolution will not affect the shape, size or position of graphics drawn even with completely different pixel metrics in the new mode, because this is all accounted for by the OS.

Acorn MOS does provide two other OS calls that handle text output: OSNEWL and OSASCI. OSNEWL writes a line feed and carriage return to the current output stream. OSASCI forwards all characters directly to OSWRCH except for carriage return, which triggers a call to OSNEWL instead. The precise code for OSASCI and OSNEWL – five lines of 6502 assembler – is documented in the BBC Micro User Guide.

Acorn MOS implements character recognition so that text printed on screen in the system font can be selected with the arrow keys and input with the COPY key as though it was being typed. To activate screen editing the user moves the hardware cursor to the text to be read and the OS displays a second cursor in software at the original position. Pressing COPY copies one character from the hardware cursor to the software cursor and advances both, so that holding the key down copies a section of the text, the cursors wrapping around the vertical edges of the screen as necessary. If the screen scrolls during editing, the hardware cursor's position is adjusted to follow the text. The user can make changes to the text during the copy, and user-defined characters are recognised in graphics modes. Screen editing is terminated when RETURN or ESCAPE are pressed, which have their usual effects. Character recognition is made available to users in the API with a call to read the character at the current cursor position.

Read more about this topic:  Acorn MOS

Famous quotes containing the word printing:

    The printing press was at first mistaken for an engine of immortality by everybody except Shakespeare.
    Marshall McLuhan (1911–1980)