Disable and Enable BREAK at will.

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
Bean
Posts: 65
Joined: Fri Aug 01, 2014 8:40 pm

Disable and Enable BREAK at will.

Post by Bean »

Enable and Disable BREAK at will.

One of the most annoying things about the ZX81 is that when you BASIC program is running anytime you press the SPACE key
it will cause a BREAK your BASIC program.

I've been working on this for awhile and I've come up with a method to be able to disable or enable the BREAK key at will.

When the BREAK key is disabled you can actually read the SPACE and "£" keys with INKEY$ !!!

The method consists of copying a small portion of the ROM, and making some of POKEs.

Creating the machine code is pretty painless since most of it is just a copy of the ROM.

Code: Select all

1 REM [70 characters]
10 FOR A=1644 TO 1709
20 POKE 14870+A,PEEK A
30 NEXT A

RUN
DELETE Lines 10 thru 30

enter as direct commands

POKE 16510,0
POKE 16569,24
POKE 16580,195
POKE 16581,174
POKE 16582,6

To use the routine.

Code: Select all

10 RAND USR 16521 ' start (use again after any INPUT command)
20 POKE 16569,24 ' to disable BREAK key
1000 POKE 16569,56 ' to enable BREAK key
You don't have to call the USR when changing from enabled to disabled only the POKE is needed.

However, you WILL need to call the USR again after any INPUT command.

Here is a demo program

Code: Select all

0 REM machine code from above
10 RAND USR 16521
20 POKE 16569,24
30 PRINT "BREAK KEY IS DISABLED."
40 PAUSE 120
50 FOR A=1 TO 300
60 PRINT "A";
70 NEXT A
80 POKE 16569,56
90 PRINT "BREAK KEY IS ENABLED."
100 PAUSE 120
110 FOR A=1 TO 300
120 PRINT "X";
130 NEXT A
Simple word processor demo showing ability to use SPACE key.
Press SHIFT-Q to stop.
NOTE line 30 is a SHIFT-Q inside quotes.

Code: Select all

0 REM machine code from above
10 RAND USR 16521
20 LET A$=INKEY$
30 IF A$="" THEN GOTO 20
40 IF INKEY$ = """" THEN STOP
50 PRINT A$;
60 IF INKEY$<>"" THEN GOTO 60
70 GOTO 20
I have tried this on a real TS1500 and on the eightyone emulator.
Please let me know if you try this and if it works or doesn't work.

Bean
Bean
Posts: 65
Joined: Fri Aug 01, 2014 8:40 pm

Re: Disable and Enable BREAK at will.

Post by Bean »

I was wondering if anyone has tried this ?

Also does anyone have an ideas about how to make it so that you don't have to call the USR after using the BASIC INPUT command ?

Thanks.
Bean
User avatar
PokeMon
Posts: 2253
Joined: Sat Sep 17, 2011 6:48 pm

Re: Disable and Enable BREAK at will.

Post by PokeMon »

Actually I don't need it.
It is a bit hard to use.
Maybe using the ZX-IDE you could write an include file loading the driver automatically and this would be less painful as it allows to compile ZX Basic and Z80 assembly in one engine. Just an idea. ;)
User avatar
mrtinb
Posts: 1320
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Disable and Enable BREAK at will.

Post by mrtinb »

Greet job. I'll use this.
Martin
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
Paul
Posts: 1128
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Disable and Enable BREAK at will.

Post by Paul »

Please excuse my late answer,
are you aware of Powerbasic that was designed for exactly this job?
PowerBasic
In theory, there is no difference between theory and practice. But, in practice, there is.
Shaun_B
Posts: 471
Joined: Wed Apr 22, 2009 10:22 am

Re: Disable and Enable BREAK at will.

Post by Shaun_B »

Great, thanks for the tip!

Regards,

Shaun.
David G
Posts: 90
Joined: Thu Jul 17, 2014 7:58 am
Location: 20 North

Re: Disable and Enable BREAK at will.

Post by David G »

Interesting. A user runs a program, presses the space key and to their surprise the program stops, causing confusion and disappointment. How to prevent this?

Next problem. As a BASIC programmer, INKEY$ doesn't let you detect a space keypress (nor SHIFT-space, the UK Pound symbol). Ways around this include writing your own INKEY$ -like routine in machine language, or installing the PowerBasic add-on. But for BASIC programs you provide to others, Bean's solution appears to work as advertised

Here is a ready-to-run demo program
BREAK_DISABLE_DEMO_1K.p
(561 Bytes) Downloaded 23 times

Also a sample of the "simple word processor" idea
WORDPROC2K.p
(1 KiB) Downloaded 20 times

If you wish to use the machine language REM in your own BASIC programs, here are the listings in ZX-IDE format. All the BASIC lines are included for one-click to generate either a tape signal to feed into your ZX81, or create a P file
BREAK_DISABLE_DEMO_1K.ASM
(3.44 KiB) Downloaded 20 times
WORDPROC2K.ASM
(4.31 KiB) Downloaded 21 times
David G
Posts: 90
Joined: Thu Jul 17, 2014 7:58 am
Location: 20 North

Re: Disable and Enable BREAK - INC file

Post by David G »

PokeMon wrote: Wed Mar 09, 2016 6:34 pmMaybe using the ZX-IDE you could write an include file loading the driver automatically and this would be less painful as it allows to compile ZX Basic and Z80 assembly in one engine. Just an idea. ;)
BREAK_DISABLE_INC.zip
INC file for ZX-IDE with test program
(1.93 KiB) Downloaded 16 times
This INC file can be used in any BASIC program instead of the code for the REM 1 [machine code]

Updated to run on OLD ROM (ZX81 Version 1 ROM) as well as the new ROM. Before it would crash as all ROM entry points after 0F02h differ between the three ROM revisions
matalog
Posts: 5
Joined: Thu Feb 18, 2021 5:13 pm

Re: Disable and Enable BREAK at will.

Post by matalog »

Nice. Thanks for that.
User avatar
XavSnap
Posts: 1258
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Disable and Enable BREAK at will.

Post by XavSnap »

Hi,

I ever seen this kind of rerouted display process.

To slow down the display, as a typewriter display type, to speedup the ZxPrinter and to speedup the screen display… the famous «NIPPERROUTINE».

The display interrupt (IY) is relocated in a homemade routine originally based in the ROM.
Xavier
Post Reply