15. Draw and Save


General Description

This program was written for use in the classroom and laboratory, and is designed for the teaching and practice of electronics. Initially, it simply enables circuit diagrams to be drawn on the TV screen, more effectively than on a blackboard and just as fast. More usefully, however, once drawn, it allows the diagrams to be recorded on tape ready to be instantly recalled. Thus a library of teaching circuits is always readily available, and individual projects can be easily preserved.
   The program allows a 'blip' to be moved about the screen using the cursor keys, and this 'lays' the symbols as required - the procedures PROCRES, PROCAP etc. each drawing a different symbol and each being called by a different key (C, R, etc). The coordinates of the endpoints of the last symbol are chosen either (i) to be the endpoint of the last symbol and where the blip has been moved to before C, R or whatever has been pressed, or (ii) by pressing key B when the blip has been moved to one chosen point and C, R, etc when it is at the other.
   The procedures only permit horizontally or vertically aligned endpoints, with the exception of PROCLINE which connects in any direction. Lettering and numbering is done by first pressing key @. This calls up the appropriate procedure, so that keys simply print their face values until @ is pressed again.
   Each time a symbol or letter is 'laid', its type and coordinates are stored in an array, and when a circuit is completed it may be given a title and recorded on tape (or recalled) by the appropriate procedure. (BPUT# was used rather than PRINT# because the operating system had a bug which was very troublesome when handling this type of data.)
   The top six or seven lines on the screen are used for instructions (when requested), recording messages and so forth, and although they may be easily cleared, to do so also clears any drawing in that region (but not, of course, from memory). In fact there are sufficient descriptions and instructions included as part of the program to enable it to be used by someone who has not read these notes, which accounts for its considerable length.
   One capability not mentioned in the program is that the blip may be made just to draw lines on the screen as it is moved around. This is switched on by key D and off by B. These lines are not recorded. No provision has been included to enable the user to easily erase a wrongly drawn symbol, although this can somewhat laboriously be achieved by printing spaces all over it!
   The layout of the drawing procedures are similar enough to enable more symbols to be added to the program's capability.
   Note that the hash symbol (#) prints as £ with this printer. 'BPUT£' means 'BPUT#', etcetera.

Detailed Description

   Line 40 Sets up variables and arrays used.
LAT (300, 1) Coordinates of letters. LAB$ (300) Letters. COORD (50, 4) Type of symbol and its coordinates.
   50-60 Sets colours used.
   70-150 Description and instructions.
   180-220 Set up text window, flush key buffer, disable cursor editing keys (so they can be used to move the blip).
   230-350 Uses GET and IF-THEN statement to test keyboard and call appropriate procedures.
   360 Erase blip (at coordinate P, Q).
   370-400 Scan cursor keys to move blip (in steps of 30).
   420 Replace blip at same or new position (280 and 410 draw lines on the screen as blip moves).
   430 Return to 230 and scan keys again.

PROCRES - This procedure will be examined in detail

   320 If R is pressed (ASCII-82), then K=P: L=Q PROCRES (H, J, K, L) P & Q are the coordinates of the blip (drawn by 420) H & J - the coordinates of the other end were set earlier either by line 290 (if B was pressed earlier), or at the end of the last drawing procedure (see later).
   460 PROCRES(A, B, C, D) - Simply substitutes A=H, B=J, C=K, D=L.
   470 Local variables.
   490 COORD is a 50 x 5 array. It may be thought of as 50 rows corresponding to 50 symbols. Each row has 5 elements - the first identifies the symbol - 1 for a resistor, 2 for a capacitor and so on. The other 4 are the X, Y coordinates of the ends of that symbol. This line is therefore recording the coordinates in memory.
   500 N = N + 1 so the next symbol will occupy the next row.
   510 Necessary trap (in case a key is pressed for too long). This line would be better moved to 485 so as not to waste array space.
   530 In the actual drawing of a horizontal register it will be assumed that C>A. If it were not, this would result in an odd symbol. This line swops C and A if necessary, and 'remembers' that it has done so by setting flag F=1.
   540 As for 530 for vertical resistors.
   550 Vertical resistors.
   560 Horizontal resistors.
   570-580 Trap for others.
   600-680 Draws vertical symbols.
   690-710 Draws horizontal symbols.
   730 Sets the coordinates of the next symbol to the end of this one.
   740 Moves the blip to the correct end if misplaced by line 530.
   760-810 PROCLINE - as PROCRES but simpler (but lines).
   820-1060 PROCCAP - as PROCRES (but capacitors).
   1070-1240 PROCTRN - as PROCRES but (i) only draws vertical transistors and (ii) in order that the base should link neatly with the other components it must be centred on a possible line (the blip moves in steps of 30 - line 400).
   1250-1460 PROCDIO - Draws DIODES (called by I not D).
   1470 PROCLET - Lettering.
   1490 Print text at graphics cursor.
   1500-1570 REPEAT-UNTIL loop - Flushes keyboard buffer, waits until key is pressed, stores coordinates of the blip in the 300 × 2 array LAT and the actual key pressed in the 300 x 1 array LAB$ - Increments the X coordinate (P) by 30 and the array rows (LL) by 1. Line 1570 checks if the key pressed was the terminator.
   1580-1600 Sends text cursor back to text window and flushes the keyboard buffer.
   1610 PROCSAVE - Saves diagrams to tape.
   1640-1660 Opens channel to tape.
   1670 Sends the number of symbols.
   1680-1770 FOR-NEXT loop - Sends type and coordinates of each symbol. (These are in fact divided by 10 because BPUT# requires numbers below 255 (FF in Hex).
   1780-1880 REPEAT-UNTIL loop - Sends coordinates of each letter (again divided by 10) and its ASCII code, then closes the channel.
   1900 PROCBACK - Fetches diagrams from tape.
   1910-1950 Options title of required diagram - opens that channel.
   1960-2040 FOR-NEXT loop - accepts first of symbols (compare line 1670) then the type and coordinate of each which are stored in the same 50 x 5 array COORD (after being multiplied by 10).
   2050-2150 REPEAT-UNTIL loop - accepts coordinates of lettering and stores in LAT and LAB$.
   2160-2240 REPEAT-UNTIL loop - prints symbols.
   2250-2320 REPEAT-UNTIL loop - prints lettering.
   2340-2370 PROCMENU - Displays instructions.

Educational Notes

This program is largely a demonstration program for the teacher. Children have experimented with it but find that is command structure is difficult to use. It needs a large colour monitor.
   It can be used to generate and save a variety of simple line drawings and not just circuit diagrams. It loads the data quickly from tape and thus if you, as a teacher, can think far enough ahead to generate a data tape with all your different diagrams in sequence on the tape, as a classroom tool it will prove very useful.