Atari Screen As Strip Chart Recorder

Helmut Schmidt

This program lets you simulate a two-pen strip chart recorder. There is information here on coarse scrolling, vertical blank interrupts, and even ESP!

I will describe a subroutine that gives a display like a strip chart recorder where two colored pens write on a moving roll of paper. We will make the screen scroll up, while at the bottom the coordinates X1 and X2 of the two pens are entered continuously. This display can be very useful to plot computer generated functions or to graph data provided from outside.

Using a 4K memory block as display area, the Atari allows us very easily to scroll this memory block as a closed loop past the screen display window. Remember that two bytes in the display list specify the current start address of the display memory. Using Graphics Mode 7 + 16 where each line holds 40 bytes, we get vertical scrolling if we regularly increment the start address in steps of 40. Beginning at the start address, the subsequent memory is displayed on the screen. But there is a hitch that comes in very handy. When the display memory reaches a 4K boundary, the display does not enter the next 4K block, but starts at the beginning of the initial 4K block. Thus, the memory block appears "wrapped around" in a continuous loop, provided that the start address stays within this block.

To display, for example, the lowest 4K memory block in this closed loop scroll fashion we can use the simple BASIC program:

10 GRAPHICS 7 + 16
20 LOC = PEEK(560) + 256 * PEEK(561) + 4
30 L = 0 : H = 0
40 L = L + 40
50 IF L > 255 THEN L = L - 256 : H = H + 1
60 IF H > 15 THEN H = H - 16
70 POKE LOC, L : POKE LOC + 1, H
80 GOTO 40

Unfortunately, this program needs two POKE steps to increment the display start address, so that an eye straining flicker may occur when a display interrupt falls between the two steps. This problem disappears if we advance the display window by a machine language program that is inserted in the Vertical Interrupt section at the end of each display cycle. Chapter 8 of De Re Atari tells specifically where to do this insertion. For reasons of economy and speed it is good to include into the machine language program the other housekeeping functions of the display – like entering the new coordinates at the bottom, and clearing the outdated entries (leaving the screen at the top).

Our machine program gets assembled (Program 1) into the second half of page six ($680-$6FF). The reader with an assembler cartridge can easily disassemble the program and study it in detail. For most practical purposes it is sufficient to know the location of a few parameters, so that by POKEing in new values we can set the pen coordinates, alter the scrolling speed, and stop and start the scrolling.

Here is a list of the useful POKE operations:

POKE1664, ASets the writing pens to positions
POKE1665, BA and B (Range 0 to 179)
POKE1677, 144Stops scrolling
POKE1677, 208Scrolling again
POKE1666, 80Extra fast scrolling
POKE1666, 40Back to normal scroll
POKE1665, ZNormal speed for Z = 0. Slower for Z = 1, 3, 7, 15, 31, 63, 127, 255

Program l gives the three basic subroutines to handle the strip chart display.

  1. GOSUB 800 has to be run first to enter the machine program into the lower half of page six.
  2. When we actually want the scrolling display we call GOSUB 700. This tells the machine program where the display memory is (depending on RAM size), and then switches the machine program into the Vertical Interrupt cycle.
  3. GOSUB 780 provides an orderly exit from the scrolling mode into Graphics 0.

To demonstrate the use of these subroutines in a most simple example, merge Program 2 with Program 1. The resulting program shows the traces of the two pens that are moved by Paddle 0 and 1. (If the paddles are not plugged in, or are set out of range, no trace is displayed.) To change parameters press RESET, POKE in the new values, and GOTO 100. Program 2 gives some more explanations.

Strip Chart Application: Man-Computer Interaction

The merger of Program 3 with Program 1 gives our next program. Again we have two pens writing on the scrolling screen. One pen is stationary to mark the center line, and the other pen performs a sine-wave motion with randomly varying amplitude. Whenever the pen crosses the center line, a random decision is made on whether to increase or decrease the amplitude for the next half cycle (with upper and lower bounds for the amplitude).

After a certain number of cycles the swinging stops and a score is displayed. A positive or negative value indicates that the average amplitude of the swinging pen in this run was higher or lower than chance expectancy. Thus, by the laws of chance, positive and negative scores are equally likely.

Each of the binary decisions (increase or decrease) results from a combination of human decision and computer decision. The Atari provides in Location 53770 a rapidly changing sequence of quasi random numbers in the range from 0 to 255. At each crossing of the center line, the computer decides to increase or decrease the pen amplitude depending on whether or not the current random number is larger than 127. This determines the course of events as long as the human operator does not press the OPTION button on the console. If, however, the OPTION button is held down at the time of the crossing, then the computer's internal decision for increase or decrease is inverted.

To explore the program further, let us first run it without using the OPTION button. What determines the history of the pen oscillations is the internal state of the computer's quasi random number generator at the time when the START button is pushed. And because this internal state changes at a very rapid rate (in the megacycle range), the timing of the START button push has a decisive effect on the outcome. Pressing the START button only one-tenth of a second later would lead to a completely different history of the pen oscillations.

It is interesting to know that a "favorable" timing of the START button push can produce high scores. But we cannot use this knowledge for actually obtaining high scores. This is because we have no way of knowing the internal state of the computer's random generator. And even if we knew, we could not do the fast mental arithmetic to calculate the resulting pen movements. And even if we could, our fingers would not be fast enough to press the start button at precisely the right time.

Having the OPTION button available doesn't help either. Now we can change the history of a run while it is in progress. But since we do not know the computer's internal choice for the next amplitude, we cannot tell whether we should or should not invert the computer's decision by pushing the OPTION button. Thus, the arrangement provides a "fair game of chance" with no room for a systematic winning strategy.

Now we come to our main question: suppose you concentrate intensely on the swinging pen, trying to make it swing widely or to keep it still at the center, and you push the OPTION button whenever you feel it is right. Could you then by some "psychic" mechanism succeed more often than not? Here success means a positive or negative score when the aim was a high or a low swing amplitude, respectively.

The most recent report on the existence of such psychic effects can be found in the Proceedings of the IEEE (Vol. 70, No. 2, Feb. 1982, pp. 136-170). Its author, Robert Jahn, is the Dean of the Princeton Engineering Department. Thus, you don't have to feel too foolish in trying such an experiment.

The aim of a high or low swing amplitude is a rather plain and simple one. This may be important so that you can pay undivided one-pointed attention to the task and can get some feeling for the best mental approach. Keep the test sessions short and don't expect miracles. If, after some time, you could reach an average success rate of 65% or more of the runs in the desired direction, then your skill would be in high demand at several research laboratories.

PROGRAM 1. Atari Screen As Strip Chart Recorder.

697 REM
698 REM ***** GOSUB 700 STARTS SCROLLING *****
699 REM
700 GRAPHICS 7 + 16 : POKE 559, 0 : REM ..... TV OFF
709 REM ...SET COLOR FOR BACKGROUND, TRACE X1, TRACE X2
710 SETCOLOR 4, 0, 0 : SETCOLOR 2, 1, 8 : SETCOLOR 0, 8, 4
720 PG = PEEK(106) : REM ................. NUMBER OF RAM PAGES
727 REM ........SCREEN DISPLAY STARTS AT 256 * PG - 4000
728 REM ........START WRITE 95 LINES(3800 WDS) FURTHER, I.E.
729 REM ........WRITESTART = 256 * (PG - 1) + 56
730 POKE 203, 56 : POKE 204, PG - 1 : REM ....SET WRITESTART
740 POKE 205, PEEK(560) : POKE 206, PEEK(561)
750 KEEPL = PEEK(546) : KEEPH = PEEK(547) : REM ...SAVE PARAMETERS
760 POKE 546, 135 : POKE 547, 6 : REM ......MACHINE PROGRAM START
770 POKE 559, 34 : RETURN : REM ..........TV ON AGAIN
771 REM
772 REM ***** GOSUB 780 EXITS FROM SCROLLING *****
773 REM
780 POKE 559, 0 : GRAPHICS 7 + 16 : POKE 546, KEEPL : POKE 547, KEEPH
790 GRAPHICS 0 : RETURN
797 REM
798 REM ***** GOSUB 800 LOADS MACHINE PROGRAM *****
799 REM
800 X1 = 1664 : X2 = 1665 : REM ..............PEN COORDINATES
810 DATA 200, 200, 40, 192, 48, 12, 3, 216, 165, 20, 41, 0, 24, 208, 66, 165
811 DATA 203, 109, 130, 6, 133, 203, 144, 26, 165, 204, 105, 0, 41, 15, 72, 13
812 DATA 175, 6, 133, 204, 104, 208, 11, 174, 130, 6, 169, 0, 202, 157, 0, 112
813 DATA 208, 250, 172, 130, 6, 169, 0, 136, 145, 203, 208, 251, 160, 4, 177, 205
814 DATA 109, 130, 6, 145, 205, 200, 177, 205, 105, 0, 41, 15, 109, 175, 6, 145
815 DATA 205, 169, 255, 141, 250, 6, 173, 128, 6, 32, 234, 6, 169, 85, 141, 250
816 DATA 6, 173, 129, 6, 32, 234, 6, 76, 95, 228, 201, 180, 176, 17, 72, 74
817 DATA 74, 168, 104, 41, 3, 170, 189, 131, 6, 41, 25 5, 17, 203, 145, 203, 96
820 POKE 559, 0
830 FOR N = 1664 TO 1791
840 READ DAT : POKE N, DAT : NEXT N
850 POKE 1711, PEEK(106) - 16
860 POKE 559, 34 : RETURN

PROGRAM 2. Atari Screen As Strip Chart Recorder.

0 REM ........***** MERGE WITH LISTING 1 *****
1 REM .......AT "RUN" WAITING PERIOD TO ENTER PROGRAM,
2 REM .......THEN DISPLAY OF 2 PENS FROM PADDLE INPUT.
3 REM .......NO TRACE IF INPUT OUT OF RANGE (0...179).
4 REM .......PUSH "SELECT"/"START" TO STOP/MOVE DISPLAY.
5 REM .......TO CHANGE PARAMETERS PRESS "SYSTEM RESET".
6 REM .......POKE 1675, Z WITH Z = 0, 1, 3, 7, 15, 31, 63, 127, 255.
7 REM .......Z = 0 GIVES FASTEST(NORMAL) SCROLL SPEED.
8 REM .......FOR DOUBLE SPEED (SKIPPING ODD LINES) POKE 1666, 80
9 REM .......NORMALLY POKE 1666, 40
10 REM ......AFTER "SYSTEM RESET" ENTER PROGRAM BY "GOTO START".
11 REM
80 GOSUB 800 : REM ....LOAD MACHINE PROGRAM FROM "DATA"
90 START = 100
100 GOSUB 700 : REM .......ENTER SCROLL ROUTINE
110 CONS = 53279 : REM .......READS CONSOLE SWITCHES
120 POKE X1, PADDLE(0) : POKE X2, PADDLE(1)
130 IF PEEK(CONS)< >5 THEN GOTO 120 : REM LOOP UNTIL "SELECT" IS PUSHED
140 POKE 1677, 144 : REM ....STOP SCROLL MOVEMENT
150 IF PEEK(CONS)< >6 THEN GOTO 150 : REM ..WAIT UNTIL "START" IS PUSHED
160 POKE 1677, 208 : REM ....CONTINUE SCROLLING
170 GOTO 120
697 REM
698 REM ***** GOSUB 700 STARTS SCROLLING *****
699 REM
700 GRAPHICS 7 + 16 : POKE 559, 0 : REM ......TV OFF
709 REM ...SET COLOR FOR BACKGROUND, TRACE X1, TRACE X2
710 SETCOLOR 4, 0, 0 : SETCOLOR 2, 1, 8 : SETCOLOR 0, 8, 4
720 PG = PEEK(106) : REM .................NUMBER OF RAM PAGES
727 REM ........SCREEN DISPLAY STARTS AT 256 * PG - 4000
728 REM ........START WRITE 95 LINES (3800 WDS) FURTHER, I. E.
729 REM ........WRITESTART = 256 * (PG - 1) + 56
730 POKE 203, 56 : POKE 204, PG - 1 : REM ....SET WRITESTART
740 POKE 205, PEEK(560) : POKE 206, PEEK(561)
750 KEEPL = PEEK(546) : KEEPH = PEEK(547) : REM ...SAVE PARAMETERS
760 POKE 546, 135 : POKE 547, 6 : REM ......MACHINE PROGRAM START
770 POKE 559, 34 : RETURN : REM ..........TV ON AGAIN
771 REM
772 REM ***** GOSUB 780 EXITS FROM SCROLLING *****
773 REM
780 POKE 559, 0 : GRAPHICS 7 + 16 : POKE 546, KEEPL : POKE 547, KEEPH
790 GRAPHICS 0 : RETURN
797 REM
798 REM ***** GOSUB 800 LOADS MACHINE PROGRAM *****
799 REM
800 X1 = 1664 : X2 = 1665 : REM ..............PEN COORDINATES
810 DATA 200, 200, 40, 192, 48, 12, 3, 216, 165, 20, 4 1, 0, 24, 208, 66, 165
811 DATA 203, 109, 130, 6, 133, 203, 144, 26, 165, 20 4, 105, 0, 41, 15, 72, 13
812 DATA 175, 6, 133, 204, 104, 208, 11, 174, 130, 6, 169, 0, 202, 157, 0, 112
813 DATA 208, 250, 172, 130, 6, 169, 0, 136, 145, 203, 208, 251, 160, 4, 177, 205
814 DATA 109, 130, 6, 145, 205, 200, 177, 205, 105, 0, 41, 15, 109, 175, 6, 145
815 DATA 205, 169, 255, 141, 250, 6, 173, 128, 6, 32, 234, 6, 169, 85, 141, 250
816 DATA 6, 173, 129, 6, 32, 234, 6, 76, 95, 228, 201, 180, 176, 17, 72, 74
817 DATA 74, 168, 104, 41, 3, 170, 189, 131, 6, 41, 25 5, 17, 203, 145, 203, 96
820 POKE 559, 0
830 FOR N = 1664 TO 1791
840 READ DAT : POKE N, DAT : NEXT N
850 POKE 1711, PEEK(106) - 16
860 POKE 559, 34 : RETURN

PROGRAM 3. Atari Screen As Strip Chart Recorder.

0 REM ..***** MERGE WITH LISTING 1 *****
1 REM ..AT "RUN" WAITING TIME WITH BLANKED SCREEN, WHILE DATA
2 REM ..ARE PREPARED. SUBSEQUENT RUNS BEGIN AT START = 100.
3 REM ..TO CHANGE PARAMETERS PRESS "SYSTEM RESET", POKE IN NEW
4 REM ..VALUES AND TYPE "GOTO START" [RET].
5 REM ..POKE 1675, SPEED WITH SPEED = 0, 1(PRESET), 3, 7
6 REM ..GIVES DIFFERENT SCROLL SPEEDS.
7 REM ..AT SPEED = 0 WE GET "MULTIPLE EXPOSURE" DISPLAYS BY
8 REM ..POKE 1666, SKIP WITH SKIP = 30, 50, OR 70. THE NORMAL
9 REM ..VALUE IS SKIP = 40 WITH DISPLAY WINDOW ADVANCE STEPS
10 REM ..OF 40 WORDS = 1 LINE.
11 REM
50 GOSUB 800 : REM .......LOAD MACHINE PROGRAM
60 GOSUB 900 : REM .......INITIAL SWING PROGRAM
70 POKE X2, 80 : REM ......SET CENTER LINE
80 POKE 1675, 1 : REM .....SET SPEED 1
90 START = 100
100 ? : ? : ? : ? : ? "PRESS START FOR NEXT RUN"
110 IF PEEK(53279)< >6 THEN GOTO 110
120 GOSUB 700 : REM ......INITIATE SCROLLING
130 W = INT(PEEK(53770) / 32) : REM ....GET RAND.NUMBER 0, .., 7
140 SCORE = W : PHI = T(W) : REM ..PHASE ANGLE GIVES AMPLITUDE
150 Q = -16 : TRIALS = 100 : REM ..TRIALS SETS RUN LENGTH
160 FOR TRY = 1 TO TRIALS - 1 : Q = -Q : S = Q + 16
170 R = PEEK(53770) : REM .....GET RANDOM NUMBER
180 IF PEEK(53279) = 3 THEN R = 256 - R : REM .INVERT IF "OPTION" PRESSED
190 IF R > 127 THEN GOTO 220
200 W = W + 1 : IF W = 8 THEN W = 7
210 GOTO 230
220 W = W - 1 : IF W = -1 THEN W = 0
230 SCORE = SCORE + W : PHI = T(W)
240 FOR Z = 32 + S TO 63 + S
250 POKE X1, PEEK(SB + Z - PHI) + PEEK(SB + Z + PHI - 1)
260 NEXT Z : NEXT TRY
270 GOSUB 780 : ? : ? : ? : ? : REM ..EXIT SCROLLING
280 PRINT "{3 SPACES} THE SCORE IS POSITIVE OR NEGATIVE"
290 PRINT "{3 SPACES} IF THE AVERAGE SWING AMPLITUDE WAS"
300 PRINT "{3 SPACES} ABOVE OR BELOW CHANCE EXPECTATION"
310 ? : ? : ? " SCORE = "; SCORE - TRIALS * 7 / 2
320 ? : ? : ? : GOTO START
697 REM
698 REM ***** GOSUB 700 STARTS SCROLLING *****
699 REM
700 GRAPHICS 7 + 16 : POKE 559, 0 : REM ..... TV OFF
709 REM ...SET COLOR FOR BACKGROUND, TRACE X1, TRACE X2
710 SETCOLOR 4, 0, 0 : SETCOLOR 2, 1, 8 : SETCOLOR 0, 8, 4
720 PG = PEEK(106) : REM .................NUMBER OF RAM PAGES
727 REM ........SCREEN DISPLAY STARTS AT 256 * PG - 4000
728 REM ........START WRITE 95 LINES(3800 WDS) FURTHER, I.E.
729 REM ........WRITESTART = 256 * (PG - 1) + 56
730 POKE 203, 56 : POKE 204, PG - 1 : REM ....SET WRITESTART
740 POKE 205, PEEK(560) : POKE 206, PEEK(561)
750 KEEPL = PEEK(546) : KEEPH = PEEK(547) : REM ...SAVE PARAMETERS
760 POKE 546, 135 : POKE 547, 6 : REM ......MACHINE PROGRAM START
770 POKE 559, 34 : RETURN : REM ..........TV ON AGAIN
771 REM
772 REM ***** GOSUB 780 EXITS FROM SCROLLING *****
773 REM
780 POKE 559, 0 : GRAPHICS 7 + 16 : POKE 546, KEEPL : POKE 547, KEEPH
790 GRAPHICS 0 : RETURN
797 REM
798 REM ***** GOSUB 800 LOADS MACHINE PROGRAM *****
799 REM
800 X1 = 1664 : X2 = 1665 : REM ..............PEN COORDINATES
810 DATA 200, 200, 40, 192, 48, 12, 3, 216, 165, 20, 41, 0, 24, 208, 66, 165
811 DATA 203, 109, 130, 6, 133, 203, 144, 26, 165, 204, 105, 0, 41, 15, 72, 13
812 DATA 175, 6, 133, 204, 104, 208, 11, 174, 130, 6, 169, 0, 202, 157, 0, 112
813 DATA 208, 250, 172, 130, 6, 169, 0, 136, 145, 203, 208, 251, 160, 4, 177, 205
814 DATA 109, 130, 6, 145, 205, 200, 177, 205, 105, 0, 41, 15, 109, 175, 6, 145
815 DATA 205, 169, 255, 141, 250, 6, 173, 128, 6, 32, 234, 6, 169, 85, 141, 250
816 DATA 6, 173, 129, 6, 32, 234, 6, 76, 95, 228, 201, 180, 176, 17, 72, 74
817 DATA 74, 168, 104, 41, 3, 170, 189, 131, 6, 41, 255, 17, 203, 145, 203, 96
820 POKE 559, 0
830 FOR N = 1664 TO 1791
840 READ DAT : POKE N, DAT : NEXT N
850 POKE 1711, PEEK(106) - 16
860 POKE 559, 34 : RETURN
900 DIM T(8) : REM ..GOSUB 900 INITIALS SWING PROGRAM
910 POKE 559, 0 : REM ......TV OFF
920 DEG : SB = 1536 : REM ....SINE TABLE STORE ON PAGE 6
930 FOR N = 0 TO 127
940 POKE SB + N, 40 * SIN(N * 45 / 8) + 40 : NEXT N
950 T(0) = 16 : T(1) = 15 : T(2) = 14 : T(3) = 13
960 T(4) = 11 : T(5) = 9 : T(6) = 6 : T(7) = 0
970 POKE 559, 34 : REM .....TV ON
980 RETURN

Return to Table of Contents | Previous Section | Next Section