
SINCLAIR PROGRAMS
May/June 1982
ZX81_Other Contents

ADDING MACHINE
BOUNCE-A-PIC
CLOCK
CRICKET AVERAGES
DEMONSTRATION PLOTS
LINE DRAWER
OHM'S LAW
PROGSAVE AND PROGRETRIEVE (ZX-81)
QUADRATIC EQUATION
STAR MAP
SUBJECT INDEX
UNIVERSAL PATTERNER
ZX BANNERS
ZX81 SCREEN INVERT


BOUNCE-A-PIC

BOUNCE-A-PIC, written to run on a 1K ZX-81, draws pictures
with a difference as the cursor is already bouncing and
dancing over the screen before you input anything. Its
direction can be controlled using the cursor keys - 5, 6, 7, 8.

The cursor starts in the top left hand corner of the screen
but that can be changed easily by altering the zero in the
first line.

Bounce-a-Pic is from The Gateway Guide to the ZX-81 and
ZX-80 by Mark Charlton. Published by Interface, 44-46 Earls
Court Road, London W8 6EJ.


- - - - -
CLOCK

CLOCK uses a FOR and NEXT loop in which to keep the time
rather than the more conventional PAUSE statement, resulting
in a clearer screen display.

Running in slow mode, the program does not include seconds
and, because of zero suppression, the time entered as 10.09
will appear as 10.9.

According to author Chris Hutchin of Cirencester the clock
is accurate to a few seconds a day. To start, type the usual
RUN and, when prompted, put in the hour and then the
minutes. Use BREAK to get out of the program. It will run on
1K machines.


- - - - -
UNIVERSAL PATTERNER

UNIVERSAL PATTERNER is for 16K ZX-81 users and produces
patterns at random. Author W. S. Hearn, of Ilford, Essex,
states that more than two million designs can be printed on
the screen.

Each pattern has a number and string length printed at the
bottom, so can be recalled and adjusted using those numbers.
Answer N for No when asked if a random pattern is required
and then input the numbers.


- - - - -
STAR MAP

Star Map is another display program which draws pictures on
your screen, if left to run for long enough. It sets up a
black rectangle and proceeds to PRINT AT and unPRINT AT
stars into a black void.

The programs are from Getting Acquainted with your ZX-81 by
Tim Hartnell. It is published by Interface of 44-46 Earls
Court Road, London W8 6EJ, and costs #4.95.


- - - - -
LINE DRAWER

LINE DRAWER provides free-format drawing with any character
or characters you wish to select. Having entered your chosen
symbol, use the cursor controls - keys 5, 6, 7, 8 - to draw
pictures on a square slightly smaller than the screen. To
change characters, press key 1.

The program will run on 1K machines and was sent by
16-year-old Stephen Adams.


- - - - -
ADDING MACHINE

ADDING MACHINE allows you to keep a running total of your
expenditures and income - income is entered as a negative
figure. First enter the amount of money involved - press
NEWLINE and then enter a description of the item. As it
stands the program will off-load each item automatically to
a printer with a running total, though those lines can
easily be deleted and the same information is displayed
automatically on the screen.

Adding Machine is from Mike Salem of Hilderbay Ltd.


- - - - -
QUADRATIC EQUATION

FOR THOSE struggling with mathematics homework, Quadratic
Equation may provide a little relief. Both roots are printed
if there are two real roots, while one root is printed if
they are equal and both the real and imaginary parts of
imaginary roots. It is clear from the output which roots are
printed.

Quadratic Equation is from Getting Acquainted with your
ZX-81 by Tim Hartnell. Published by Interface, 44-46 Earls
Court Road, London W8 6EJ.


- - - - -
ZX BANNERS

IF YOU are wondering what to do with your printer why not
try ZX Banners which will print out banners of as many
letters as you want each three inches high. Letters are
printed sideways, so the length of a banner is restricted
only by the amount of paper in the printer.

While letters and graphics will work, functions will not.
The width of a letter can be changed by altering line 910 -
e.g., by inserting FOR F=1 TO 4 would double the width.

ZX Banners was sent by Christopher Holt, of Gravesend, Kent.


- - - - -
DEMONSTRATION PLOTS

DEMONSTRATION PLOTS uses some of the extra functions
available on the ZX-81. Using spirals and sines, the program
can create an effective demonstration program if you have
sufficient memory. Run it in slow mode.


- - - - -
OHM'S LAW

OHM'S LAW, by Ken North, allows you to use Ohm's law to work
out the value of volts, amps or ohms when you know two but
not the third. Enter the known values when prompted using
zero for the unknown value. The display is particularly
effective.


- - - - -
ZX81 SCREEN INVERT

FIFTEEN-year-old John Miller, of Farlington, Portsmouth, has
written a machine-code routine, Invert, to invert the whole
screen of the ZX81 with 3.5 or more K - or 1K, so long as 22
lines have been PRINTed to the screen. The routine takes
1/50 of a second in the FAST mode and 4/50 of a second in
SLOW.

It is a very useful routine for game explosions, advertising
displays and the like. The listing shows an Assembly
listing, a hexadecimal dump and the Basic loader program.

Use RAND USR 32700 to call the routine. The routine returns
the value of the remainder of the result of dividing the
address where the routine starts. If loaded to 32700, the
routine returns the remainder of 32700/256 - that is 188.
Therefore, RAND USR 32700 will, as well as inverting the
screen, set the RANDOM seed to 188 - i.e., RAND 188.

The routine uses only 20 bytes. Miller tried loading the
routine to the last 20 bytes of RAM but that crashed the
system, even though RAMTOP is set below those bytes. That
should not cause the system to crash by a corruption of the
Stack. We would be interested in hearing from anyone who can
explain why the system crashes in that circumstance.


- - - - -
CRICKET AVERAGES

A PROGRAM designed to be useful with other cricket games,
e.g., the Video Software Test Match and the Emvee Software
Mini Cricket is Cricket Averages, submitted by G Evans of
Dartford, Kent.

The program is far too long to input - about three hours -
and the description may or may not need to include the
listing of variables included by the writer. So it is
completely untested.


- - - - -
PROGSAVE AND PROGRETRIEVE (ZX-81)
by John Hardman
from Sinclair Programs 1 (May/June 1982), page 36

For the more technically-minded, here are two useful machine code routines
for the ZX-81. If you have ever been annoyed at having to lose a program in
memory when wanting to load another from tape, even though both could fit
easily, then Progsave and Progretrieve could be the answer.

The routine copies the program presently in RAM to above RAMTOP. Though
RAMTOP is relocated to make room, nothing already above RAMTOP is changed. If
there is not sufficient memory, the program will return to Basic.

Using the routine, any program can be disassembled - many disassemblers
needing to be in RAM, not above RAMTOP. To load programs from tape without
losing the program already in RAM, Progsave must be used in conjunction with
Progretrieve. That routine will restore a program from above RAMTOP to
address 16509 and thus any program already in memory will be moved up in
memory; you may need to re-number after user. The copy above RAMTOP is erased
and RAMTOP is re-set to the value it had before running Progsave.

To use the routines the following instructions may help: Write main section
of program; run Progsave; load subroutines needed from tape; run
Progretrieve; re-number if necessary.

After completing that the program will be the main program followed by the
subroutines. If any line numbers clash, the only method of re-numbering is to
use a re-number routine - using the EDIT key will not work.

Progsave and Progretrieve were sent by John Hardman, of Welling, Kent.

[The routines as described will not work because although RAMTOP is changed,
the CPU stack is not and will be overwritten. This prevents Progsave
returning to BASIC. A work around solution is to manually modify RAMTOP
beforehand to preserve the stack. The process then becomes:

- Load Progsave
- Type in the first part of the BASIC program (line numbers 2 to 4999 only)
- Lower RAMTOP by typing:
    POKE 16389,PEEK 16389-1
- Run Progsave by typing:
    RAND USR 16514
- Load Progretrieve
- Type in the second part of the BASIC program (line numbers 5001 to 9999
only)
- Run Progretrieve by typing:
    RAND USR 16514
- Restore RAMTOP by typing:
    POKE 16389,PEEK 16389+1
- Delete lines 1 and 5000 (the REM lines containing Progsave and
Progretrieve respectively)

Note that the above procedure requires 256 bytes are reserved for the stack
space. This could be reduced by also POKEing the low RAMTOP address byte,
e.g. 192 would reserve stack space of 64 bytes instead.]


- - - - -
SUBJECT INDEX

SUBJECT INDEX sets up a Mini ZX-81 database designed to keep
an index of magazine and book articles but it can be changed
easily for other applications. The options available are to
add a record, delete the last entry, list the records,
search for a record and exit from the program.

On running the program, the screen displays a menu of
commands, after having asked for a title for the index to be
created. Using the Add option allows an item of information
to be added to the index and prompts individually for
article title, publication name, date and page reference.

To return to the menu, enter an empty string for the title.
When using List to display the contents of a file, the CONT
instruction is required each time the screen is full and
report code 5 occurs.

Using Exit offers the option of saving the file to cassette
or ending the program. The Search option requests a keyword
which in this version of the program is the article title.
Search will also work on the first character or characters
of the title.

The number of items which may be stored is governed by the
value of N in line 15. A value of 350 is about the maximum
which can be accommodated in 16K of memory but if a smaller
number is used saving and loading time will be reduced.

Names of publications are limited to eight characters, so an
abbreviation is required for longer names. Titles may be of
any length but the array is dimensioned for an average of 25
characters per item.

Subject Index was sent in by Julian Moss of London.


- - - - -