Page Flipping
Rick Williams
By changing only two bytes in the display list, you can cause the screen to display any portion of memory. This permits many interesting effects: coarse scrolling, instant screen fill, and page flipping, or "screen switching."
Did you envy that article in COMPUTE!'s (November 1981, #18) Apple Gazette about page flipping? Well, relax. Atari can do it, too. Actually, there are two ways of doing it. The first way is a USR routine. I will get to the second way later.
I have written a machine language routine to transfer RAM to the screen. This routine (Program 1) will access BASIC through the USR function. To access this function, command "A = USR(1536, X)", 1536 being the start location of the machine program, and X being the location to start reading from RAM that will later be transferred to the screen. I have written the program only to work on graphics zero. Without this, strange effects will be seen on your TV.
Now on to the second way. This is the better way because it uses the horizontal scroll register. It scrolls into an entirely new frame. It works just as the machine routine. Write the high and low byte to the variables L and H. Here is the program:
PROGRAM 1. Page Flipping.
1 GOTO 50
5 REM THIS REQUIRES NO GRAPHICS 0 COMMAND
10 DLIST = PEEK(560) + 256 * PEEK(561) : POKE 82, 0 : REM SET LEFT MARGIN
20 L = DLIST + 4
25 H = DLIST + 5
30 A = ADR(A$) : B = INT(A / 256) : C = A - (256 * B)
31 D = ADR(B$) : E = INT(D / 256) : F = D - (256 * E)
32 POKE L, C : POKE H, B : FOR I = 1 TO 500 : NEXT I
33 POKE L, F : POKE H, E : FOR I = 1 TO 500 : NEXT I : IF PEEK(764) = 255 THEN 32
34 GRAPHICS 0 : END
50 DIM A$(960), B$(960)
55 A$ = CHR$(3) : A$(960) = CHR$(3) : A$(2) = A$ : REM FILL A$ WITH CHR$(3)
56 B$ = CHR$(4) : B$(960) = CHR$(4) : B$(2) = B$ : REM FILL B$ WITH CHR$(4)
60 GOTO 10
PROGRAM 2. Page Flipping.
10 REM *** PAGE FLIPPING BASIC ***
11 REM *** By Rick Williams
12 REM
15 DIM A$(50), B$(50)
20 FOR I = 1536 TO 1536 + 42 : READ A : POKE I, A : NEXT I : REM LOAD MACHINE CODE
21 GRAPHICS 0 : FOR I = 1 TO 50 : A$(I, I) = CHR$(RND(1) * 255) : NEXT I : REM LOAD STRINGS
22 FOR I = 1 TO 50 : B$(I, I) = CHR$(RND(1) * 255) : NEXT I
23 GRAPHICS 0 : A = USR(1536, ADR(A$)) : FOR I = 1 TO 500 : NEXT I
24 GRAPHICS 0 : A = USR(1536, ADR(B$)) : FOR I = 1 TO 500 : NEXT I : GOTO 23
25 REM *** YOU MUST HAVE THE GRAPHICS 0 COMMAND TO RESET THE DISPLAY LIST
26 REM *** DATA FOR MACHINE CODE ***
1000 DATA 104, 104, 133, 205, 104, 133, 204, 32, 20, 6, 32, 20, 6, 32, 20, 6, 32, 20, 6, 96, 160, 0, 162, 0, 169, 0, 177, 204, 145, 88, 200
1010 DATA 152, 240, 3, 76, 26, 6, 230, 89, 230, 205, 96, 16
Return to Table of Contents | Previous Section | Next Section