MZ-800 course Chapter 5
5. Pokes, Peeks, tricks, tips and things like that

In this chapter you will see that a lot of funny stuff can be done with the computer and that you can figure out lots of this stuff for yourself in a simple way.

5.1 Pokes and Peeks

With the POKE-instruction the value of a certain address or a block of addresses can be altered. So in principle, you can poke every address, this means that in total 65,535 pokes are possible. Unfortunately 99% of those pokes have an effect that is not worth mentioning. For example, there are a few thousands of pokes that crash BASIC, but of what use is that? We can also disable all BASIC instructions by poking the value C9 to the right address, but why would we do that?

With the BASIC-monitor you can discover a few nice pokes for yourself, but you have to know where to look and what to look for. You could, for example, find out that output to the screen has to do with register B and DE amongst others. One line contains 40 ( 28 hexadecimal ) characters and that number is stored in DE. The corresponding memory will read 11 28 00. The exact memory location can be found with F ( Find ). Furthermore you need to know that the main part of the direct functions of the computer reside in the area from 0000H up to 1000H. So we will look for 11 28 00 in that area and that goes as follows:

BYE <cr> ( to enter the BASIC-MONITOR )
*F00001000112800

This results in:

```:05E5=11 28 00 /.(.
:071F=11 28 00 /.(.
:07C2=11 28 00 /.(.
:0829=11 28 00 /.(.
:0897=11 28 00 /.(.```

Now we can experiment a little by changing 28 with 50 for example and watching if something happens. If nothing happens then we undo our changes.

If we change 28 to 50 and type a few letters afterwards then we see that those letters appear on the screen in double size. So we have already found an interesting POKE. Now all we have to do is imbed this in a program and that could for example result in the following piece of code:

```10 INIT "CRT:M1"
20 PRINT "NORMAL SIZE."
30 POKE \$5E6,\$50
40 PRINT
50 PRINT "DOUBLE SIZE."
60 POKE \$5E6,\$28:CURSOR 0,6```

Of course you can find a lot more POKEs in a similar way, but this idea occurred to us, the writers of this book, also and we have already found most of the interesting Pokes On top of them all is the following:

With two Pokes it is possible to scroll the screen up in a similar way the hardware does this in VIDEO-RAM. To show the effect of these pokes, we have embedded them in a program.

```10 INIT "CRT:M1"
20 LIST:LIST
30 WAIT 2000
40 CURSOR 0,24
50 POKE \$898,\$5
60 POKE \$97E,\$01
70 FOR T=1 TO 2000:PRINT:NEXT T
80 POKE \$898,\$28
90 POKE \$97E,\$00
100 WAIT 2000:INIT "CRT:M1"```

These Pokes work in QD-BASIC as well as in tape BASIC, the same goes for the previous POKE. To avoid confusion, we shall give the QDBASIC variant as well as the tape BASIC one for all subsequent Pokes, even if they are equal.

 POKE No. 1 QD-BASIC POKE \$109B,x ( 0 =< x =< 255 ) Tape BASIC POKE \$109B,x Description Equals COLOR x. Original POKE \$109B,\$3 ( \$F in mode M2 ) POKE No. 2 QD-BASIC POKE \$5E6,\$D8,\$FF Tape BASIC POKE \$5E6,\$D8,\$FF Description Inverting the text. Original POKE \$5E5,\$28,\$0 Application ```10 INIT "CRT:M1" 20 PRINT "THIS TEXT LOOKS LIKE THIS WHEN WRITTEN UPSIDE-DOWN:" 30 PRINT:PRINT 40 POKE \$5E6,\$D8,\$FF 50 PRINT "THIS TEXT LOOKS LIKE THIS WHEN WRITTEN UPSIDE-DOWN:" 60 POKE \$5E6,\$28,\$0``` POKE No. 3 QD-BASIC POKE \$5E4,x (1 = x = 8) Tape BASIC POKE \$5E4,x Description Show part of the text. Original POKE \$5E4,\$8 Application ```10 INIT "CRT:M1" 20 FOR G=1 TO 8 30 CURSOR 0,0:POKE \$5E4,G 40 PRINT "THIS IS AN EXAMPLE" 50 PRINT "FROM NEPTUNES SOFTWARE." 60 WAIT 1000 70 NEXT G``` POKE No. 4 QD-BASIC POKE \$3919,\$1 Tape BASIC POKE \$3919,\$1 Description The program is saved only once, which makes the saving faster. ( Note by www.sharpmz.org: but you'll get problems some years later!! ) Original POKE \$3919,\$2 POKE No. 5 QD-BASIC POKE \$5D4,\$1 Tape BASIC POKE \$5D4,\$1 Description Switch to second character set. Original POKE \$5D4,\$0 POKE No. 6 QD-BASIC POKE \$4DD0,\$1 Tape BASIC POKE \$4DCF,\$1 Description Switch to second character set on SYMBOL. Original POKE \$4DD0,\$0 / POKE \$4DCF,\$0 Application POKE \$4DD0,\$1 :SYMBOL 0,99, "NEPTUNES",3,3 :POKE 4DD0,\$0 :POKE \$4DCF,\$1 :SYMBOL 0,99, "NEPTUNES",3,3 :POKE 4DCF,\$0 POKE No. 7 QD-BASIC POKE \$55B0,\$CD,\$3E,\$0,\$11,\$F0,\$63, \$C9 :POKE \$587A,\$CD,\$B0,\$55 Tape BASIC POKE \$55B0,\$CD,\$3E,\$0,\$11,\$F0,\$63, \$C9 :POKE \$587A,\$CD,\$B0,\$55 Description Beep on Ready message. Original POKE \$55B0,\$0,\$0,\$0,\$0,\$0,\$0,\$0 :POKE \$587A,\$11,\$F0,\$63 POKE No. 8 QD-BASIC POKE \$B34,x ( 0 <= x <= 100 ) Tape BASIC POKE \$B34,x Description Change the cursor speed. Original POKE \$B34,\$10 POKE No. 9 QD-BASIC POKE \$6E35,\$0,0 Tape BASIC POKE \$6E35,0,0 Description INPUT without question mark. Original POKE \$6E35,\$3F,\$20 Application POKE \$6E35,0,0 :INPUT A :POKE \$6E35,\$3F,\$20 POKE No. 10 QD-BASIC POKE \$1099,\$1 Tape BASIC POKE \$1099,\$1 Description If you do not have the expansion ICs, you now can execute the commands INIT "CRT:M2" and INIT "CRT:M4". If you do have the ICs, this POKE has no effect. Original POKE \$1099,0 - If you do not have the ICs. POKE \$1099,1 - If you have the ICs. POKE No. 11 QD-BASIC POKE \$6879,\$0 :POKE \$688E,\$0 Tape BASIC POKE \$6879,\$0 :POKE \$688E,\$0 Description Read repeatedly with GET. Original POKE \$6879,\$FF :POKE \$688E,\$FF Application ```10 POKE \$6879,\$0:POKE \$688E,\$0 20 GET A\$:PRINT A\$:GOTO 20``` POKE No. 12 QD-BASIC POKE \$4678,\$80 Tape BASIC POKE \$4678,\$80 Description Do not clear the background on SYMBOL. Original POKE \$4678,\$C0 Application ```10 INIT "CRT:M1" 20 A\$="NEPTUNES SOFTWARE." 30 POKE \$4678,\$80 :FOR A=319 TO -1130 STEP -8 :SYMBOL [2]A,92,A\$,8,2 40 WAIT 25:NEXT A 50 POKE \$4678,\$C0``` POKE No. 13 QD-BASIC POKE \$6F29,\$89 Tape BASIC POKE \$6F29,\$89 Description PRINT becomes PRINT/P. Original POKE \$6F29,\$88 POKE No. 14 QD-BASIC POKE \$6079,\$0,\$0,\$0 Tape BASIC POKE \$6079,\$0,\$0,\$0 Description Variables are not cleared on RUN anymore. Original POKE \$6079,\$D,\$93,\$61 POKE No. 15 QD-BASIC POKE \$4E9,\$0,\$0,\$0 Tape BASIC POKE \$4E9,\$0,\$0,\$0 Description No CLS on CONSOLE. Original POKE \$4E9,\$CD,\$52,\$6 POKE No. 16 QD-BASIC POKE \$5592,\$3A,\$83,\$6B,\$CD,\$6,\$0,\$C9 :POKE \$6B20,\$CD,\$92,\$55 Tape BASIC POKE \$55BA,\$3A,\$83,\$6B,\$CD,\$6,\$0,\$C9 :POKE \$6B20,\$CD,\$BA,\$55 Description SEARCH and LIST with an empty line in between. Original POKE \$5592,\$0,\$0,\$0,\$0,\$0,\$0,\$0 :POKE \$6B20,\$3A,\$83,\$6B POKE \$55BA,\$0,\$0,\$0,\$0,\$0,\$0,\$0 :POKE \$6B20,\$3A,\$83,\$6B

And there are lots and lots of POKES. A few will follow below and on the next couple of pages. After that a list of useless POKES will be given. The pokes discussed here are more or less the most interesting and useful POKES known at this time. Of course there are many more, but not all of them are known or not worth mentioning. There are for example anti-BREAK pokes that are nice, but useless because a BASIC-program can not be secured for the full 100%. ( Unless the program resides on QD. In that case it can be secured against copying, but it will be rather expensive ).

POKES to speed up the saving and loading process of the tape recorder:
( These POKES work in QD- as well as in tape BASIC ).

`POKE \$3B91,\$23:POKE \$3B97,\$B:POKE \$3B9B,\$31`
```Original:
POKE \$3B91,\$4C:POKE \$3B97,\$18:POKE \$3B9B,\$69```

POKES for CURSOR X,Y:

The POKES below work in QD- as well as in tape BASIC and show that we can use two POKES instead of CURSOR X,Y.

```10 INIT "CRT:M1"
20 FOR B=0 TO 23
30 FOR A=0 TO 39
40 WAIT 25
50 POKE 4226,A:POKE 4227,B:PRINT " NEPTUNES,":NEXT A,B```

POKES to change the cursor sign:
( Applies to both BASICS ).

`POKE \$1391,\$FF,\$81,\$81,\$81,\$81,\$81,\$81,\$FF`
```Original:
POKE \$1391,\$FF,\$FF,\$FF,\$FF,\$FF,\$FF,\$FF,\$FF```

POKES to change the tabstop:
(Applies to both BASICS).

```10 INIT "CRT:M1"
20 INPUT "WHAT SHOULD THE NEW TABSTOP BE (1-39)";A
30 IF A<1 OR A>39 THEN 20
40 POKE \$A2D,A:POKE \$A32,A:POKE \$A49,A:POKE \$A5F,A:POKE \$A63,A
50 PRINT:PRINT "NOW PRESS THE TAB KEY!"```

A couple of useless POKES ANTI-BREAK POKES:
(Applies to both BASICS).

`POKE \$F4C,\$6E,\$60:POKE \$6403,\$C3,\$0,\$0`
```Original:
POKE \$F4C,\$DA,\$0:POKE \$6403,\$ED,\$7B,\$64```

Other useless pokes for both BASICS:

 POKE \$6A9D,\$C9 Disable LIST. Normal: POKE \$6A9D,\$3E POKE \$6A5C,\$C9 Disable BYE. Normal: POKE \$6A5C,\$DF POKE \$A24,\$C9 Disable the TAB-key. Normal: POKE \$A24,\$06 POKE \$6BE,\$C9 Disable the DEL-key. Normal: POKE \$6BE,\$D9 POKE \$A1E,\$C9 Disable the GRAPH-key. Normal: POKE \$A1E,\$3E POKE \$D28,\$C9 Disable the BREAK-key. Normal: POKE \$D28,\$D1

And there are many more POKES that are as useless as these ones. That is the reason we do not publish them.

After having given a whole list of POKES, we have now arrived at the PEEKS. The PEEK instruction is to read the contents of a certain address.

So like POKE, the same applies to PEEK, all addresses are PEEK-able. There are only a few really useful PEEKS and the important ones can be found on this page.

PEEKS to see which DEVICE you use:
( These PEEKS are actually only of importance if you also have a QD connected to your SHARP ).

```10 IF PEEK(\$106A)=\$5A AND PEEK(\$106B)=\$37 THEN
PRINT "YOU ARE CURRENTLY WORKING WITH THE CASSETTE."
20 IF PEEK(\$106A)=\$D0 AND PEEK(\$106B)=\$2F
THEN PRINT "YOU ARE CURRENTLY WORKING WITH THE QD."```

PEEKS to see if the expansion ICs are present in your computer:
(Applies to both BASICS).

PRINT PEEK(\$1099)

1 if the ICs are present.
0 if the ICs are not present.

PEEKS to read what is displayed on the screen:
( Applies to both BASICS and only works if there is normal text or characters on the screen ).

From address \$2000 on the contents of the screen is stored. If you for example would like to know if there is something on the first column of the second row, you enter: PRINT PEEK(\$2000+1*40+0) and if something is present, the corresponding ASCII code of the character will be shown.

PEEKS to see how many BYTES a program occupies on QD and how many BYTES are left:
( Only of importance for owners of a QD ).

```10 DIR:NO=\$27D0:P=0:CLS:PRINT "DIR QD:":PRINT "_______"
30 N=NO+1:IF PEEK(NO)=0
THEN PRINT TAB(23);CHR\$(17);65454-P;" Bytes free":END
40 IF PEEK(NO)=1 THEN PRINT "OBJ ";:ELSE PRINT "BTX ";
50 IF PEEK(N)<>13 THEN PRINT CHR\$(PEEK(N));:N=N+1:GOTO 50
60 B=PEEK(N0+21)*256+PEEK(NO+20)
:PRINT TAB(23);B;" Bytes":NO=NP+32:P=P+B:GOTO 30```

last updated July 8, 2004
Arjan Habing, Mark de Rover, Jeroen F. J. Laros, sharpmz@sharpmz.org