Page 1 of 1

Interrupts on ZX81

Posted: Wed May 30, 2018 4:13 pm
by mrtinb
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?

Re: Interrupts on ZX81

Posted: Wed May 30, 2018 5:02 pm
by Andy Rea
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

Re: Interrupts on ZX81

Posted: Wed May 30, 2018 10:17 pm
by Moggy
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)

Re: Interrupts on ZX81

Posted: Thu May 31, 2018 7:38 am
by olofsen
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 ;)).

Re: Interrupts on ZX81

Posted: Thu May 31, 2018 11:26 am
by Paul
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.

Re: Interrupts on ZX81

Posted: Thu May 31, 2018 4:05 pm
by siggi
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

Re: Interrupts on ZX81

Posted: Thu May 31, 2018 5:36 pm
by mrtinb
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.

Re: Interrupts on ZX81

Posted: Thu May 31, 2018 6:07 pm
by siggi
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