Page 1 of 1

Disable and Enable BREAK at will.

Posted: Sun Feb 28, 2016 10:33 pm
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

Re: Disable and Enable BREAK at will.

Posted: Wed Mar 09, 2016 3:01 pm
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

Re: Disable and Enable BREAK at will.

Posted: Wed Mar 09, 2016 6:34 pm
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. ;)

Re: Disable and Enable BREAK at will.

Posted: Sun Mar 13, 2016 7:28 am
by mrtinb
Greet job. I'll use this.
Martin

Re: Disable and Enable BREAK at will.

Posted: Sun Mar 13, 2016 10:28 am
by Paul
Please excuse my late answer,
are you aware of Powerbasic that was designed for exactly this job?
PowerBasic

Re: Disable and Enable BREAK at will.

Posted: Fri Mar 03, 2017 8:35 pm
by Shaun_B
Great, thanks for the tip!

Regards,

Shaun.

Re: Disable and Enable BREAK at will.

Posted: Thu Feb 04, 2021 8:50 am
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 24 times

Also a sample of the "simple word processor" idea
WORDPROC2K.p
(1 KiB) Downloaded 21 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 21 times
WORDPROC2K.ASM
(4.31 KiB) Downloaded 22 times

Re: Disable and Enable BREAK - INC file

Posted: Sun Feb 07, 2021 1:26 am
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 17 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

Re: Disable and Enable BREAK at will.

Posted: Fri Feb 26, 2021 1:13 am
by matalog
Nice. Thanks for that.

Re: Disable and Enable BREAK at will.

Posted: Sat Feb 27, 2021 12:47 am
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.