Here are two commands found in other computer BASICs which are missing from Sinclair BASIC. They are GET and PUT, and are used for transferring screen images.
This month’s utility will provide you with these two powerful BASIC keywords. By definition, GET obtains a specific array of bytes from the screen and stores them in a user specified area of RAM. PUT places the stored array of bytes back onto the screen. The array specifications are provided by you within a BASIC statement with the following syntax: RANDOMIZE USR (GET=60000) or (PUT=60006): PRINT AT line,column; height,width,address
The arguments include specifications of a rectangular area of the display screen. The first two numbers specify the upper left-hand corner of the rectangle. The next two numbers specify the height and width of the rectangle. The fifth number is the address in RAM where the array of bytes is stored. The proper range of values for the arguments are as follows:
- Column=0 to 31
- Line=0 to 23
- Height=1 to 24
- Width=1 to 32
When the code is called, the syntax of the PRINT AT statement is checked and error trapping is provided. There are many uses fort hese programming tools in your programs.
The demo given below employs a type of animation. You can also use it to print text or graphics on top of an existing screen then restoring the area that was covered up.
You can also prepare and save several rectangular screens using the GET command and storing them at different RAM addresses. SAVE them as CODE and calculate the CODE length by PEEK 60297+256*PEEK 60298.
You can PUT them anywhere on the screen using BASIC in your programs. In the demo given below, a star is drawn in line 30. Line 40 stores a 10×10 character rectangle starting at line 0, column 0, at address 50000. Line 45 prints a message over the top of thestar. Lines 60 to 100 cycle around infinitely PUTting the defined rectangle one character at a time up, down, left, or right until it bumps into a screen edge.
Don’t forget to RUN line 9800 first to poke in the CODE. The CODE is not relocatable as written. A checksum is provided to tell you if you made a typing error. The CODE is 397 bytes long.
Have fun!!
Source Code
10 LET get=60000
20 LET put=60006
30 PLOT 9,142: DRAW 57,10,4000
40 RANDOMIZE USR get: PRINT AT 0,0;10,10,50000
45 PRINT FLASH 1;AT 4,2; INK 2 ;"GETPUT"; INVERSE 1;AT 5,2; INK 1;"Demo!!": PRINT AT 10,5;"Press a key to start...": PAUSE 0
50 LET d=-1: LET dx=d: LET dy=d: LET x=-d:LET y=-d
60 LET x=x+dx: LET y=y+dy
70 IF NOT x OR x=22 THEN LET dx=dx*d:BEEP .01,x
80 IF NOT y OR y=14 THEN LET dy=dy*d: BEEP .01,x
90 RANDOMIZE USR put: PRINT AT y,x;10,10,50000
100 GO TO 60
9800 CLEAR 49999: LET t=0
9810 FOR n=60000 TO 60396
9820 READ a: POKE n,a: LET t=t+a
9830 NEXT n: IF t<>47831 THEN PRINT "Data Error! Recheck DATA lines": STOP
9840 RUN
9850 DATA 175,50,139,235,24,5,62,1,50,139,235,33,0,0,34,131,235,62,2,205,48,18,205,136,8,223,254,58,32,47,231,254,245,32,42,253,52,13,231,254,172,32,34,205,220,27,205,96,38,97,104,34,131,235,223,254,59,32,18,205,220,27,205,96,38,120,65,79,237,67,133,235,223,254,44,40,2,207,11,205,228,27,205,96,49,237,67,135,235,237,75,133,235,237,91,131,235
9860 DATA 58,143,92,245,120,130,56,12,254,25,48,8,121,131,56,4,254,33,56,2,207,4,197,213,17,9,0,98,104,205,182,46,89,205,182,46,30,13,25,34,137,235,68,77,42,135,235,113,35,112,35,237,91,132,92,115,35,114,35,237,91,136,92,115,35,114,35,237,91,141,92,115
9870 DATA 35,114,35,58,145,92,119,35,62,2,229,205,48,18,225,193,229,205,178,5,235,225,115,35,114,35,193,113,35,112,35,235,58,139,235,254,1,40,92,241,229,111,38,0,34,141,92,34,143,92,253,116,87,225,120,6,0,245,135,135,135,229,229,197
9880 DATA 237,176,193,225,205,112,235,61,32,244,225,205,102,235,241,197,229,237,176,225,1,32,0,9,193,61,32,243,201,124,230,56,31,31,31,246,88,103,201,245,36,124,230,7,32,10,125,198,32,111,56,4,124,214,8,103,241,201,0,0,0,0,0
9890 DATA 0,0,0,0,42,135,235,78,35,70,197,35,241,229,94,35,86,35,237,83,132,92,94,35,86,35,237,83,136,92,94,35,86,35,237,83,141,92,237,83,143,92,126,35,50,145,92,94,35,86,35,78,35,6,0,126,35,245,135
9900 DATA 135,135,213,213,197,237,176,193,209,235,205,112,235,235,61,32,242,209,235,205,102,235,235,241,197,213,237,176,227,1,32,0,9,235,225,193,61,32,241,225,193,201Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.