ZX ideas - Adding a Message to a Loader and Protecting a BASIC Program from MERGE

ZX Revija #02

ZX Ideas

  1. Inserting Messages into the Loader
  2. Deleting Routines from BASIC
  3. RENUMBER

Inserting Messages into the Loader

This time, the letters are one character larger, and they are bolded using double pixels. I use this program not only to insert a message, but also to protect it effectively!

Once you type in the program, it is immediately protected against MERGE. The POKE that blocks the MERGE command is 23757,-1, or some other number. But when you enter it, if you POKE it into BASIC around the second line, your computer prints a strange line that you can no longer restore to the listing once you edit it!

POKE 23757,-1 controls the length of the bytes in the lines. So, for example, if our first line has 30 bytes and we set 23757,40, we get some strange signals. How can this block be prevented? Do it as follows: enter 51 bytes in the first line (just make sure you don't need the last byte in the program), then insert POKE 23757,50.

So, what is the conclusion?

The conclusion is that we prevent blocking by entering POKEs with values smaller than the length of that line. Before you type in the machine code, enter 125 letter A's in line one (after the REM command in the first listing). After you type in the machine code from listing 2, enter POKE 23756,0! Once you have typed it in, delete lines 2, 3, 4 and 5. Save the resulting program to cassette and enter POKE 23757,124. Line 1 may appear with the letter A in it. Delete that line and, if everything is okay, type in listing 3.

WARNING! Do not delete line 0.

Listing 1:

1 REM
2 FOR F=23760 TO 23879
3 INPUT I:POKE F,I:PRINT F,I
4 POKE 23609,150
5 NEXT F

Listing 2

Listing 3:

1 BORDER 0:PAPER 0:INK 0:CLS:PRINT#0; MODIFYED by DADO Telefon:078 /49-953 LOADING :RANDOMIZE USR 23760:LOAD

Of course! This is just an example. You can put in whatever message you like! Once you have entered listing 3, enter POKE 23884,0 and your listing will be hidden behind the machine code. Now you have properly protected both the machine code and BASIC from being listed.

If you want to protect the program against the BREAK command (interrupt), enter POKE 23613,0 in listing 3.

CONTRIBUTION PREPARED BY:

Keser Mladen-DADO
Beogradska 11
78000 Banja Luka
Telefon:078/49-953

Deleting Routines from BASIC

If we want to delete the last, larger part of a BASIC program and don't have a serious TOOLKIT program in the computer's memory, or the same routine in machine code, the same job can be done with a single BASIC line. The simplicity of this solution also has one drawback: it can only delete a block from the end of the program. In most cases, this need not be a drawback. Note that all three commands in this routine must be written on one line.

You must not leave any of them out. This line must be the last one that will not be deleted. Here is the routine and an example:

10 REM
20 REM
30 REM
40 POKE 23627,PEEK 23637:POKE 23628,PEEK 23638:CLEAR
70 REM
80 REM
90 REM

RUN/ENTER

After this program runs, lines 70 to 90 disappear from the program forever. Be careful, because the routine will also erase the space allocated for variables.

Therefore, after using the routine, you must initialize them again.

B.J.

Inserting Messages into a Loader and Protecting Programs from MERGE on the ZX Spectrum

RENUMBER

You probably know what this routine is for if you need to renumber a long BASIC program but didn’t load a toolkit containing this routine before writing or modifying it. Or perhaps the program is too long, so there’s no room in memory for a toolkit. Try this little program; it may solve your problem. Start it with RUN 9986/ENTER.

The program will ask you to enter the starting (new) line number and the step between line numbers. It will then renumber the entire BASIC program up to line 9985. There is a safeguard to prevent RENUMBER from renumbering itself. One drawback is that the program cannot renumber expressions after GO TO, GO SUB, and RESTORE.

Some RENUMBER routines can’t do that even in machine code!

10 REM
14 REM
16 REM
100 REM
123 REM
9986 DEF FN p()=PEEK 23635+256*PEEK 23636
9987 DEF FN l(a)=256*PEEK a+PEEK(a+1)
9988 LET p=FN p()
9989 INPUT "first line:";so
9990 INPUT "step:";io
9991 PRINT "old";TAB(10);"new"
9992 LET l=FN l(p)
9993 IF l>9985 THEN STOP
9994 PRINT l;TAB(10);so
9995 POKE p,INT(so/256)
9996 POKE p+1,so-INT(so/256)*256
9997 LET so=so+io
9998 LET p=p+4+PEEK(p+2)+256*PEEK(p+3)
9999 GO TO 9992

B.J.

Share your thoughts about the article