Demonstrates a pair of machine code routines that copy a rectangular block of the screen into memory (GET) and print it back anywhere (PUT). The demo draws a starburst with a single DRAW 57,10,4000 arc, grabs a 10×10 character block containing it, and bounces the block around the screen, beeping at each wall. The routines read their parameters from a PRINT statement that follows the call on the same line, RANDOMIZE USR get: PRINT AT row,col;width,height,address, so a call reads like ordinary BASIC. Here the block is stored at 50000.
The REM in line 1 reads “program “GETPUT” by michael DiRienzo”. Michael DiRienzo also wrote the graphics program Pix-Fx.
Program Analysis
Structure
- Lines 5–45: set the colours, give the two entry points (
get=60000,put=60006), draw the starburst, GET it, then show a flashing title and wait for a key. - Lines 50–100: the bounce loop.
d=-1is used to reversedxanddy, and a PUT aty,xruns each pass. - Lines 9800–9900: loader. It does
CLEAR 49999, POKEs 397 bytes into 60000–60396, checks they total 47831, and thenRUNs the demo.
Machine Code
Both entry points set a flag at 60299 (0 for GET, 1 for PUT) and share the same code. It reads the rest of the BASIC line itself: it checks for :, the PRINT token and AT, evaluates the numbers through the ROM, and increments the statement counter (SUBPPC, INC (IY+13)) so BASIC skips the PRINT. It checks that the block fits on the screen and reports an error otherwise. It also appears to save the print-position and colour system variables along with the block, and to convert display-file addresses to attribute addresses, so colours seem to be copied as well as pixels.
Notable Techniques
- The machine code takes its parameters from a dummy
PRINT ATstatement rather than from POKEs orDEF FN. - The loader checks the DATA against a checksum before running the demo. The 397 values in the listing do total 47831.
- Because the program was saved with
LINE 9000and there is no line 9000, it starts at the first line after it, the loader at 9800. - Because the grabbed block includes a blank margin, moving it one character at a time wipes out its own trail.
- Lines 49 and 89 are earlier versions left in as REMs.
This copy comes from a Larken disk. For tape, the RANDOMIZE USR 100 calls were removed from the save line, the Larken load line was emptied to a REM, and the program now autostarts at the loader. It was tested in ZEsarUX.
Source Code
1 REM program "GETPUT"by michael DiRienzo
5 INK 9: PAPER 7: BORDER 7: CLS
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; INK 9;"Press a key to start...": PAUSE 0
49 REM RANDOMIZE USR get: PRINT AT 0,0;10,10,50000
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,y
80 IF NOT y OR y=14 THEN LET dy=dy*d: BEEP .01,x
89 REM PAUSE 10
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,201
9992 RANDOMIZE USR 100: SAVE "GETPUT.B1" LINE 9000
9998 RANDOMIZE USR 100: LOAD "L.B1"Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

