Draw and Store

Date: 1982
Type: Program
Platform(s): ZX81, TS 1000
Tags: Graphics

A drawing program that keeps the picture in a string array, to be saved on tape with the program and drawn again later.

Enter GOTO 1 to start and answer Y for a new picture or N for the stored one. Keys 5 to 8 move the pixel, and with SHIFT they leave a trail. ENTER stores the picture; then SAVE the program. The listing is marked 2K, but storing a picture works only with a full display file, so it needs 16K: on 2K the stored picture comes back as garbage. The second file is the shorter 1K version, which only draws. It sets no starting point, so enter LET X=0 and LET Y=0 before GOTO 1.

Reprinted from SYNC, November/December 1982.

Published in LISTing January 1989 (Just for Fun).

Related Articles

Mousetrap; Unvader; Draw and Store; Number Nine; Eliminator
In “Mousetrap” your objective is to trap the mouse which is represented by the O. Your position is shown by the $.

Image Gallery

Source Code

2K RAM

   1 REM JJH 1-31-82
   2 REM USE GOTO 1
   5 GOTO 600
  10 LET Y=0
  15 LET X=0
  20 PLOT X,Y
  25 PAUSE 40000
  30 POKE 16437,255
  35 LET A=CODE INKEY$
  40 IF A=118 THEN GOTO 500
  55 IF A<100 THEN UNPLOT X,Y
  60 LET X=X+1*(A=36 OR A=115)*(X<63)-1*(A=33 OR A=114)*(X>0)
  70 LET Y=Y+1*(A=35 OR A=112)*(Y<43)-1*(A=34 OR A=113)*(Y>0)
  80 GOTO 20
 505 FOR A=1 TO 22
 510 FOR B=1 TO 32
 520 LET A$(A,B)=CHR$ PEEK ((PEEK 16396)+256*(PEEK 16397)+33*(A-1)+B)
 530 NEXT B
 540 NEXT A
 550 STOP
 600 PRINT "8K ROM DRAW A PICTURE"
 610 PRINT "NEW PICTURE? Y OR N"
 620 INPUT D$
 630 CLS
 640 IF D$="N" THEN GOTO 700
 650 DIM A$(22,32)
 660 GOTO 10
 700 FOR A=1 TO 22
 710 FOR B=1 TO 32
 720 PRINT A$(A,B);
 730 NEXT B
 740 NEXT A
 750 GOTO 10

1K RAM

   1 PLOT X,Y
   2 PAUSE 40000
   3 LET A=CODE INKEY$
   4 IF A<100 THEN UNPLOT X,Y
   5 LET X=X+1*(A=36 OR A=115)*(X<47)-1*(A=33 OR A=114)*(X>0)
   6 LET Y=Y+1*(A=35 OR A=112)*(Y<37)-1*(A=34 OR A=113)*(Y>0)
   7 GOTO 1

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