Graphics Generator
Matthias M. Giwer
Create graphics characters, SAVE them to disk, and use them in other programs.
Recently my son has shown a distinct interest in learning to program a computer. Although I do not expect much to come of this interest at six years of age, I began working up some simple illustrative programs on programming concepts. The first was a race track for a number to go around to demonstrate a loop. The second was a Y-shaped branch for a number to go through. After the second tedious construction of the branch using line numbers, POSITION statements, and PRINT statements, it was apparent that there had to be a better way. Here is my approach to that better way.
This program permits graphics characters – or any characters – on a Graphics 0 screen. The finished screen is written to a disk file of line numbers which can then be merged with a master program by means of the ENTER command.
After running the program and giving a filename to save the results, you must not do anything to scroll the screen. This means that what you draw must be done with the cursor and you must never hit RETURN. It is recommended that the first thing you do is erase the STOPPED AT message. Do not erase or move the CONT on line 22. You may use the cursor keys and any other screen editing functions of the Atari. When finished, move the cursor down to the line containing the CONT and hit RETURN. The program will execute. When the disk drive stops, the program has finished.
There are many options available within the program. The one option you do not have is to move CONT to the last line, for if you do, the screen will scroll when you hit RETURN. Otherwise, it is rather flexible. If you wish to compose several graphics screens, run the program once for each screen. You will use a different file specification and change the value of 30000 in line 2020. Since exactly 40 lines are required to save a screen, increase 30000 in blocks of 50 so you will have free lines for RETURN statements and so forth. When putting together your finished program graphics, simply ENTER all of the file specifications you have used and LIST them under one new file specification.
The program itself simply constructs R$ to look like a line of BASIC. It concatenates (adds together) a line number (30000 + 1), a print command in the form of a question mark, and then adds a quotation mark in the form of CHR$(34). (Otherwise it would be interpreted by the computer as a closing quotation mark.) Note that a quotation mark is not permitted on your graphics screen. Using the LOCATE instruction, each position of the screen is examined and added to R$ by the CHR$(X) instruction. In line 2030 J starts at 2 to coincide with the default values of the screen. If you intend to use the resulting lines with different screen widths, then this value should be changed to coincide with them. R$ is completed with a closing CHR$(34), a semicolon to prevent scrolling CHR$(59), and a carriage return CHR$(155).
Upon ENTERing these lines you will need to do a bit of editing. First you must remove the word CONT from the next to the last line and the cursor from the last line. After this you may change blank lines to simple PRINT or ? statements. Leaving the lines in this form takes up only a few bytes and gives you what might be called relocatable graphics.
To obtain fixed location graphics, make the changes in Program 2. These will result in absolute positioning of your graphics. The POSITION statements generated by these lines will place the graphics exactly where you drew them.
PROGRAM 1. Graphics Generator.
100 GRAPHICS 0 : DIM R$(80), F$(17) 120 ? "ENTER DISK NAME TO SAVE UNDER{10 SPACES} (Dn : filespec.ext)"; : INPUT F$ 140 GRAPHICS 0 : POSITION 4, 22 : ? "CONT{5 UP}" : STOP 1900 OPEN #1, 8, 0, F$ : J = 0 2010 FOR I = 0 TO 23 2020 R$ = STR$(30000 + I) 2026 R$(LEN(R$) + 1) = "?" 2028 R$(LEN(R$) + 1) = CHR$(34) 2030 FOR J = 2 TO 39 2050 LOCATE J, I, X 2060 R$(LEN(R$) + 1) = CHR$(X) 2070 NEXT J 2080 R$(LEN(R$) + 1) = CHR$(34) 2082 R$(LEN(R$) + 1) = CHR$(59) 2090 R$(LEN(R$) + 1) = CHR$(155) 2100 ? #1; R$ 2110 R$ = " " 2120 NEXT I 2190 CLOSE #1 2200 REM 2201 GOTO 2200
PROGRAM 2. Graphics Genereator.
2022 R$(LEN(R$) + 1) = "POSITION 3," 2030 R$(LEN(R$) + 1) = STR$(I) 2040 R$(LEN(R$) + 1) = " : "
Return to Table of Contents | Previous Section | Next Section