Page: 8

See all articles from T-S Horizons n3

This article will give you a very useful utilities program, and will demonstrate and explain its use.

INFORMATION IS BROUGHT INSTANTLY ONTO THE SCREEN

A PAGE-FLIPPER is a program which will store information from the TV screen into the memory of your computer, and then allow you to bring it back onto the screen instantly! This information may be either text or graphics, or a combination of both. A PAGE refers to a full screen of information, and “PAGE: 8” (see LISTING 1) is a page-flipping program which gives you control of eight pages of information.

“PAGE: 8” IS SIMPLE TO USE AND EASY TO UNDERSTAND

Beginners and others can easily use “PAGE: 8” within their own programs. Menus can be projected onto the screen in any order, and fairly simple animation may be done. Before discussing how the program is used, we will look at what it does and how it works.

Start by entering LISTINGS 1 and 2 into your TS/ZX. LISTING 1 is the page-flipper program, and LISTING 2 is a program designed to demonstrate the abilities of “PAGE: 8”.

After entering the LISTINGS, ENTER the command GOTO 1000. The program begins by creating eight individual pages. As you view them, “PAGE: 8” copies these images into the storage area. Because the programs are written in BASIC, the storage time is long, about 100 seconds per PAGE. It is worth it, however. The pages recall instantly onto the screen with only two lines of BASIC, and all of your PRINT statements, which originally set up your page, may be deleted!

While the pages are being stored, read through the rest of the article. You will be notified when the demonstration is ready.

PROGRAM THEORY AND ANALYSIS

The TV screen obtains its information from the “DISPLAY FILE”, an area within the computer’s RAM. To store a page, the page-flipper copies the DISPLAY FILE into a storage area. To recall the page to the screen, the program copies the stored page back into the DISPLAY FILE.

“PAGE: 8” uses the string A$ for the page storage. In the TS1000, a page is 22 lines of 32 characters each. This means that 32×22 (704)characters per page must be stored. Each character occupies one space within the storage area A$, so that eight pages require 8×704 (5632)spaces available. This explains the top line of LISTING 1: DIM A$ (5632). This command should not be entered after any pages are stored since they would be erased. This is the reason for entering the DIM command with no line number: you will not accidently erase your pages.

LISTING 1

     DIM A$(5632)
5 REM █ "PAGE:8" █ 12/83 TUB
10 LET A=(PAGE-1)*704
20 LET B=PEEK 16396+256*PEEK 16397
30 LET C=0
40 FOR D=1 TO 726
50 LET E=PEEK (B+D)
60 IF E=118 THEN GOTO 90
70 LET A$(A+C+D)=CHR$ E
80 NEXT D
90 LET C=C-1
100 NEXT D
110 RETURN
115 REM █ PRINT SUBROUTINE █
120 LET F=(PAGE-1)*704+1
130 PRINT AT 0,0;A$(F TO F+703)
140 RETURN
999 REM █ DEMO █
1000 DIM A$(5632)
1005 LET Z$="█"
1010 LET PAGE=1
1020 FOR N=1 TO 704

LISTING 2

 999 REM █ DEMO █
1000 DIM A$(5632)
1005 LET Z$="█"
1010 LET PAGE=1
1020 FOR N=1 TO 704
1030 PRINT "▒";
1040 NEXT N
1050 PRINT AT 19,11;"PAGE : ";PAGE
1060 GOSUB 10
1070 LET PAGE=PAGE+1
1080 IF PAGE=9 THEN GOTO 2000
1090 LET X=10-PAGE*2
1100 PRINT AT PAGE*2,X;Z$
1110 LET Z$=Z$+Z$
1120 GOTO 1050
2000 CLS
2010 PRINT "DEMO READY : PRESS A KEY"
2020 IF INKEY$="" THEN GOTO 2020
2030 LET PAGE=1
2040 GOSUB 120
2050 LET PAGE=PAGE+1
2060 IF PAGE<9 THEN GOTO 2040
2070 LET PAGE=PAGE-1
2075 CLS
2080 GOSUB 120
2090 IF PAGE=2 THEN GOTO 2030
2100 GOTO 2070

Lines 10 through 110 form the subroutine which stores the pages. Lines 20, 40, and 50 locate the DISPLAY FILE and find the 704 characters to be stored. In the TS, each line of display ends with an end-of-line marker, 118. This is why, in line 50, D runs from 1 to 726, and not 704. There are 22 end-of-line markers to account for. Lines 30, 60, 90, 100, and 110 cause the program to skip these markers. Line 10 finds the start of the page within the storage area, A$. The variable PAGE is set by the user before entering the subroutine, and must have a value of 1 to 8. Later when the pages are ready to be recalled, PAGE is assigned to tell the program which page to print. Line 70 places the characters in their correct position within A$.

Lines 120, 130 and 140 form the subroutine which prints the pages. Once your pages are stored, lines 10 through 110 may be deleted. Of course you may not use RUN or CLEAR without losing A$.

USING “PAGE: 8” IN YOUR PROGRAMS

Study LISTING 2 and notice that the image to be stored is first printed on the screen. Next, PAGE is assigned, and then GOSUB 10 is used. Do not forget to DIM A$ first. When the demonstration is ready and running, PAGE is again assigned and GOSUB 120 is used. If a display is stored with PAGE = 5, then assigning PAGE = 5 followed by GOSUB 120 will recall that same page. These guidelines should make it easy for you to use PAGE: 8 within your own programs:

1. Enter PAGE: 8 into your computer along with your accompanying program.

2. STORING THE PAGES Use standard PRINT and PLOT commands to display the pages to be stored. Assign a number 1 to 8 for each page. AT THE POINT IN YOUR BASIC PROGRAM WHERE THE PAGE IS COMPLETELY ON THE SCREEN, ENTER THESE THREE LINES: 1) LET PAGE = the number assigned to this page. 2) GOSUB 10 (See LISTING 1). 3) STOP This line is for convenience only. When the STOP is reached, the Page is stored and you then repeat this procedure for each page.

When you have completed this procedure, you delete all of your print statements and the lines which stored them. I recommend that you test the results first though.

3. RECALLING THE PAGES Each page recall requires two BASIC lines: 1) LET PAGE = the number assigned to this page 2) GOSUB 200 (See LISTING 1)

FURTHER SUGGESTIONS

1. To speed up the page storage, add lines 5 FAST and 105 SLOW to LISTING 1.

2. You may use fewer or more pages by changing the initial DIM A$ statement.

3. It is possible to store a page using print statements as demonstrated, but without the pages being displayed on the screen while they are being stored. (Hint: the system variable DF-CC would be used.)

This concludes the PAGE: 8 article. Write to me with any suggestions or discoveries that you make with PAGE: 8. I have a tape available with three machine language versions of a page-flipper. Each version uses a different area of memory depending upon your needs. Inquire if interested.

Goodbye for now!
Lien Chii
c/o THE ULTIMATE BLACKWOOD
P.O. BOX 7427
Santa Cruz, CA 95061

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.