Letters

See all articles from SYNC v2 n5

ROMs and RAMs

Dear Editor:

Could you please put more programs for the ZX80 with the 8K ROM in SYNC? All I notice is programs mainly for the ZX80 with the original 4K ROM and the ZX81.

Cris Bottjer
[address omitted]

Ed.—See “ROMs and RAMs” in SYNC Notes in this issue.


Memory Saving Tips

Dear Editor:

I want to call the attention of SYNC readers to the second paragraph on p. 129 of the 8K ROM manual: “A numerical constant in the program is followed by its binary form, using the character CHR$ 126 followed by five bytes for the number itself.” This is a very inefficient way to store numbers.

Dr. Ian Logan in SYNC 2:2 showed some good ways to get around this inefficiency by using SGN PI and NOT PI for 1 and 0. He also used VAL “number” which saves three bytes. I suggest using one letter variables to hold numerical constants if you use the same constants more than once, or, if you use numbers that are more than four digits long. Declare these variables from the command mode so that they do not occupy program space.

Another way to save memory is to use GOTO CODE “C” instead of GOTO VAL “40”. A byte saved is a byte earned. This same technique could be used for any number between 10 and 255 even though not all these characters can be accessed from the keyboard. Consider the following line:

500 LET N=N/100

You can accomplish the same thing with:

1 LET N=N/CODE “N”
POKE 16520,100

After these lines are entered, line 1 will look like:

1 LET N=N/CODE “?”

Now all you have to do is EDIT and renumber the line to 500. If you want to do several lines this way, type your program from the highest line number to the lowest so that the line you just typed will always be the first line in memory.

John Coffey
[address omitted]


Dear Editor:

Concerning Gary Chandler’s “Alien Treasure” in SYNC 2:4, there are several ways to increase the efficiency and speed of the program.

First, the four lines which check the bounds (132-135) can be deleted if logic is used:

  89 LET I$=INKEY$
90 IF NOT I$="" THEN PRINT AT
A,B;"█"
91 IF I$="" THEN GOTO 89
95 IF I$="0" THEN LET A=INT (R
ND*22)
98 IF I$="5" THEN LET B=B-(B>0
)
100 IF I$="8" THEN LET B=B+(B<3
1)
110 IF I$="6" THEN LET A=A+(A<2
1)
120 IF I$="7" THEN LET A=A-(A>1
)

If the expression in parentheses is true, it has a value of one; otherwise the variable is not changed. Also, INKEY$ could change between lines; therefore it is always best to assign INKEY$ to a variable and then check it as in the example above.

Second, lines 81-84 indicate which direction the monster is to move. This can best be done by using SGN. Delete lines 81 and 83, and then enter:

82 LET X=X+SGN(A-X)
84 LET Y=Y+SGN(B-Y)

SGN returns -1 if the expression in parentheses is negative, 1, if positive, and 0 otherwise. Then the variables X1 and Y1 can be deleted by deleting lines 7, 8, 86, and 87.

Third, if the inspiration is great enough, the array can be deleted and a PEEK can be done to the screen location desired. Use

LET S$=CHR$ PEEK (PEEK 16396+256 * PEEK 16397+33* R+C+1)

where R is the row and C is the column. The character at that position is returned in S$.

Michael Williams
[address omitted]


The SAVE Signal

Dear Editor:

A friend recently purchased Sinclair’s 16K RAM pack, but found that the SAVE signal was drowned out by the extra noise it caused. After trying several types of filtering, I found two large foil tabs on the underside, one by the edge connector and the other next to the regulator. Connecting these with wire and rosin core solder reduced the resistance and the noise.

Raymond Fowkes
[address omitted]

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