Interrupts on ZX81

Discussion about ZX80 / ZX81 Software
Post Reply
User avatar
mrtinb
Posts: 728
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Interrupts on ZX81

Post by mrtinb » Wed May 30, 2018 4:13 pm

Is the interrupt on the Z80 hardwired to the ULA, so only the ULA can make interrupts?

It would have been nice, to have an interrupt when a certain port had data e.g. a key was hit. But then again the signal to hit the key is sent through software in the ROM.

What about other hardware? Is there an interrupt possibility?

The software in the ROM is highly busy painting the screen, reading the keyboard and running your program. Wouldn’t it be nice to have an interrupt from external hardware?

I’m talking a little to myself here, but what are the options?
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube

User avatar
Andy Rea
Posts: 1468
Joined: Fri May 09, 2008 2:48 pm
Location: notts UK

Re: Interrupts on ZX81

Post by Andy Rea » Wed May 30, 2018 5:02 pm

Well both NMI ( non mask-able interrupt ) and INT ( mask-able ) are use for video generation so whilst maintaining a display polling is your only choice.

so what are the options without display running ? INT would be difficult to use but perhaps technically possible first problem is int is hardwired to A6 so you will need to control the R register to prevent self triggering. second problem is we would have to set aside almost all the registers to ensure the the jump made by the interrupt routine ( $0038 ) in the rom would jump to where we want again some trickery will be needed there also as it will jump with A15 high...

that leaves us with NMI. This looks more promising, within our software we can set a' to $FF and IX to the address of our service routine, so that when an NMI occurs a jump to address IX will be made, we should reset a' to $FF within the service routine.

as for a practical use i'll leave that up to somebody else :lol:

Regards Andy
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

Moggy
Posts: 1654
Joined: Wed Jun 18, 2008 2:00 pm

Re: Interrupts on ZX81

Post by Moggy » Wed May 30, 2018 10:17 pm

Andy Rea wrote:
Wed May 30, 2018 5:02 pm
Well both NMI ( non mask-able interrupt ) and INT ( mask-able ) are use for video generation so whilst maintaining a display polling is your only choice.

so what are the options without display running ? INT would be difficult to use but perhaps technically possible first problem is int is hardwired to A6 so you will need to control the R register to prevent self triggering. second problem is we would have to set aside almost all the registers to ensure the the jump made by the interrupt routine ( $0038 ) in the rom would jump to where we want again some trickery will be needed there also as it will jump with A15 high...

that leaves us with NMI. This looks more promising, within our software we can set a' to $FF and IX to the address of our service routine, so that when an NMI occurs a jump to address IX will be made, we should reset a' to $FF within the service routine.

as for a practical use i'll leave that up to somebody else :lol:

Regards Andy
....Now here's Tom with the weather. :lol: (apologies I'm having a funny turn at the moment)

olofsen
Posts: 141
Joined: Wed Jan 08, 2014 12:29 pm

Re: Interrupts on ZX81

Post by olofsen » Thu May 31, 2018 7:38 am

Another idea could be to use BUSREQ, because it is not used. It may be used by another machine to alter ZX81's memory, so that it thinks a key is pressed (I'm not sure if this causes good or bad weather ;)).

User avatar
Paul
Posts: 952
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Interrupts on ZX81

Post by Paul » Thu May 31, 2018 11:26 am

Isn't the usual approach to do polling in a custom display routine?
One option is to use PowerBasic by swatosch if you want to use it easily from Basic.

Busreq will also stop the display.
In theory, there is no difference between theory and practice. But, in practice, there is.

User avatar
siggi
Posts: 840
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Interrupts on ZX81

Post by siggi » Thu May 31, 2018 4:05 pm

The options are:
Hook a small m/c-routine into the display-routine, which polls your hardware for interrupt condition.
But since a picture is generated 50/60 times per second, the hardware is polled by that rate (which makes only sense for low speed actions)
And it works only in SLOW mode!

Since the /INT and the /NMI input of the Z80 are driven by the Z80/ULA, you have to do some hardware-modifications to decouple this hardware from your external hardware, which wants to use also this signals (use AND gates or diodes to allow both the Z80/ULA and your hardware to drive them LOW).
But then you could use your own INT/NMI only in FAST mode (in SLOW mode the display would be distorted).

But be careful: I played around 20 years ago with hardware, which allowed to enable/disable the /INT coming from Z80 to use it for my own hardware. But that hardware caused a little delay and thus the display generated during FAST mode (waiting for input) was distorted (first line on screen).

Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
mrtinb
Posts: 728
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Interrupts on ZX81

Post by mrtinb » Thu May 31, 2018 5:36 pm

I get what you're all saying:
  • The way the ZX81 hardware is built, interrupts are not for you. They are for the display.
  • Use polling in the display routine like everyone else.
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube

User avatar
siggi
Posts: 840
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Interrupts on ZX81

Post by siggi » Thu May 31, 2018 6:07 pm

Indeed :mrgreen:

But nevertheless: it depends on your application! In my Midi-player I use the ULA's NMI-interrupt to generate the timing, need for playing the Midi song at correct speed. Since the the output of the player is intended to by used by your ears, the output for your eyes (display routine) is not necessary (display is disabled) :mrgreen:

So if you don't need display, you could use the ULA NMI generator to generate NMIs as usual and the NMI routine to poll your hardware at high speed (approx. every 64 usec).
That would work also during a runnnig BASIC program in FAST mode without hardware modifications!

Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

Post Reply