Windows (BASIC Demo)

Type
Utility
Category
Screen-window routines with demo
Author
Jerry White and Dave Culbertson
Published in
Antic, November 1984 (Vol. 3, No. 7), "The Toolbox: Windows" (part 1 of 2)
Year
1984
Language
Atari BASIC
Requirements
Any Atari 8-bit, Atari BASIC
A GRAPHICS 0 screen filled with dots, with a title box 'Windows by Jerry White and Dave Culbertson' and a slanted window of asterisks containing 'Windows can show WHAT you want WHERE you want'

About the program

In 1984 "windows", several display areas on one screen, were the computer world's latest buzzword. Jerry White and Dave Culbertson showed Antic readers how to do it on an Atari in a two-part series. This first part gives two short machine-language routines and a BASIC demonstration. Assembly source for the routines was printed too, but you don't need it, because both routines are in the BASIC listing as DATA. It runs on any Atari.

The idea is simple. Put the text for a window into a string. Convert it once to screen codes. Then a single USR call swaps the string with a block of screen memory. The window appears, and the text that was underneath is now in the string. Call it again and the old screen comes back. The authors pointed out that this works in any graphics mode and frees you from the Atari screen editor.

What you need

Atari BASIC. That's all.

Typing it in

The routines are DATA in lines 420–670: 116 bytes for W$ (the window swapper) and 61 for C$ (the converter). Check every number. The text strings use inverse video ({inv}…{/inv}, Atari key), and each window string must end with a heart, {CTRL-,} (CTRL and comma), which the routines use as an end marker. Note how lines 140 and 190 fill the big strings with the A$(2)=A$ copying trick.

How to use it

RUN it. After a moment of setup, windows of different shapes are swapped in and out, with the speed set by a timer (location 540). Partway through, the program LISTs its own DATA lines, so you can watch the windows open over a program listing. After a few rounds it ends with the message "BASIC IS".

To use the routines yourself:

  • X=USR(ADR(C$),ADR(DATA$)) converts your string from ATASCII to screen codes. Do it once.
  • X=USR(ADR(W$),ADR(DATA$),SOF,LIN,WID,LOF) swaps it with the screen. SOF is the offset of the window's top-left corner from the start of the screen (in characters), LIN the number of lines, WID the width and LOF the distance from one line to the next. In GRAPHICS 0 a LOF of 40 gives a rectangle. 39 or 41 gives a window that slants left or right, as lines 340–360 show.

How it works

W$ reads the screen address from SAVMSC (locations 88–89), adds SOF, and then exchanges bytes between the string and the screen one line at a time, moving on by LOF after each line of WID bytes. It stops when it reaches the heart that marks the end of the string. Because it swaps rather than copies, no extra buffer is needed to restore the screen. C$ exists because screen memory holds internal character codes, not ATASCII.

Listing

1 REM WINDOWS BASIC DEMO
2 REM BY JERRY WHITE & DAVE CULBERTSON
3 REM ANTIC MAGAZINE
100 GRAPHICS 0:POKE 752,1:JIF=120
110 DIM A$(961),D$(97),B$(241),W$(116),C$(61)
120 ? :? "CREATING W$":FOR ME=1 TO 116:READ IT:W$(ME,ME)=CHR$(IT):NEXT ME
130 ? :? "CREATING C$":FOR ME=1 TO 61:READ IT:C$(ME,ME)=CHR$(IT):NEXT ME
140 A$=".":A$(960)=".":A$(2)=A$:A$(961)="{CTRL-,}"
150 A$(131,154)=" Windows by Jerry White "
160 A$(171,191)=" and Dave Culbertson "
170 D$="************* Windows  ** can show ** {inv}WHAT{/inv} you **  "
180 D$(52,97)=" Want   ** {inv} WHERE {/inv}  ** you want *************{CTRL-,}"
190 B$="{inv} {/inv}":B$(240)="{inv} {/inv}":B$(2)=B$:B$(241)="{CTRL-,}"
200 B$(35,55)="   All sizes / kinds   "
210 B$(92,119)=" Work in ANY graphics mode "
220 B$(157,178)="{inv}You are FREE from the {/inv}"
230 B$(188,201)="{inv} ATARI Editor!{/inv}"
240 GRAPHICS 0:POKE 752,1:?
250 X=USR(ADR(C$),ADR(A$))
260 X=USR(ADR(C$),ADR(D$))
270 X=USR(ADR(C$),ADR(B$))
280 SOUND 0,0,2,2:GOSUB 370:GOSUB 340
290 SOUND 0,2,2,2:GOSUB 340:GOSUB 370
300 IF LFLG=0 THEN LIST 470,670:LFLG=1
310 COUNT=COUNT+1:IF COUNT>=4 THEN GOSUB 380:GOSUB 390:GOSUB 380:JIF=10
320 IF COUNT>=7 THEN GRAPHICS 0:? :? "BASIC":? "IS";:END
330 GOTO 280
340 IF JIF=10 THEN LOF=41
350 IF JIF=120 THEN LOF=39
360 X=USR(ADR(W$),ADR(D$),412,8,12,LOF):GOSUB 390:RETURN
370 X=USR(ADR(W$),ADR(A$),0,24,40,40):GOSUB 390:RETURN
380 X=USR(ADR(W$),ADR(B$),285,8,30,40):GOSUB 390:RETURN
390 POKE 540,JIF:SOUND 0,0,0,0
400 IF PEEK(540) THEN 400
410 RETURN
420 DATA 104,104,133,206,104,133,205
430 DATA 104,141,1,6,104,141,0
440 DATA 6,104,133,208,104,133,207
450 DATA 104,104,133,209,104,141,3
460 DATA 6,104,141,2,6,165,88
470 DATA 133,203,165,89,133,204,24
480 DATA 165,203,109,0,6,133,203
490 DATA 165,204,109,1,6,133,204
500 DATA 160,0,177,203,170,177,205
510 DATA 145,203,138,145,205,200,196
520 DATA 209,208,241,169,0,198,207
530 DATA 197,207,208,6,197,208,240
540 DATA 30,198,208,24,152,101,205
550 DATA 133,205,144,3,230,206,24
560 DATA 165,203,109,2,6,133,203
570 DATA 165,204,109,3,6,133,204
580 DATA 24,144,197,96
590 DATA 104,104,133,204,104,133,203
600 DATA 160,0,177,203,170,201,0
610 DATA 240,44,41,96,201,0,208
620 DATA 6,138,9,64,24,144,22
630 DATA 201,96,240,20,138,41,64
640 DATA 201,0,208,6,138,73,32
650 DATA 24,144,5,138,9,32,73
660 DATA 64,145,203,200,208,210,230
670 DATA 204,24,144,203,96

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: WINDOWS.BAS.

Credits