Information on NMI's, INT's and timings...
Information on NMI's, INT's and timings...
Can somebody shed some light on how the ZX81 handles, and what can be done with, NMIs & interupts?
From what I've read, IM1 is used to handle the screen redraw, and so if I choose to do my own interupts I'd also have to code my own display update? And presumably if I use the DI instruction I'd lose redraw? Does that make sense? What does the HALT instruction to in these circumstances?
I also seem to remember reading that I can disable the NMI if I want via a port call. What effect would that have?
Siggi has mentioned that in another thread that USA (Timex) 81s' run at 60fps, and so I could use the MARGIN (16424) system variable to ensure a constant rate? I assume IM1 is involved in updating that value?
Any help much appreciated!
From what I've read, IM1 is used to handle the screen redraw, and so if I choose to do my own interupts I'd also have to code my own display update? And presumably if I use the DI instruction I'd lose redraw? Does that make sense? What does the HALT instruction to in these circumstances?
I also seem to remember reading that I can disable the NMI if I want via a port call. What effect would that have?
Siggi has mentioned that in another thread that USA (Timex) 81s' run at 60fps, and so I could use the MARGIN (16424) system variable to ensure a constant rate? I assume IM1 is involved in updating that value?
Any help much appreciated!
Re: Information on NMI's, INT's and timings...
Hi Bobs
forget to use /NMI or /INT with a ZX81!
Both /INT and /NMI are used to make the correct timing for the display. And the interrupt routines use the IX and IY registers, so you should not touch them in "normal" programs (IX is modified for HIRES).
For details of the display generation: Wilf wrote a tutorial with a lot of details ...
http://www.user.dccnet.com/wrigter/inde ... torial.htm
If you switch to FAST mode, the NMI-generator in the ULA is deactivated. That is necessary for time critical progams (like SAVE and LOAD from tape). But it disables the display
The HALT instruction is used during display (and enabled INT) to wait for the end-of-line-condition counted by the R register -> causes an INT
HTH Siggi
forget to use /NMI or /INT with a ZX81!
Both /INT and /NMI are used to make the correct timing for the display. And the interrupt routines use the IX and IY registers, so you should not touch them in "normal" programs (IX is modified for HIRES).
For details of the display generation: Wilf wrote a tutorial with a lot of details ...
http://www.user.dccnet.com/wrigter/inde ... torial.htm
If you switch to FAST mode, the NMI-generator in the ULA is deactivated. That is necessary for time critical progams (like SAVE and LOAD from tape). But it disables the display
The HALT instruction is used during display (and enabled INT) to wait for the end-of-line-condition counted by the R register -> causes an INT
HTH Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
http://zx81.ddns.net/ZxTeaM
Re: Information on NMI's, INT's and timings...
Yes and No.bobs wrote: From what I've read, IM1 is used to handle the screen redraw, and so if I choose to do my own interupts I'd also have to code my own display update?
No, because Wilf already did it: he wrote his own (LORES) display routine "NOVA", which allows to integrate own code (a user interrupt routine), which is called regularly during display. See:
http://www.user.dccnet.com/wrigter/inde ... va2005.htm
Yes, if NOVA does not help
Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
http://zx81.ddns.net/ZxTeaM
Re: Information on NMI's, INT's and timings...
Cheers for the input & links, will have a read of them today.
Re: Information on NMI's, INT's and timings...
For timing I'm currently calling a routine at the bottom of my main loop called timer_tick :-
My game would then run at 30Hz on a 60Hz machine -- 20% faster -- so is there a better way to deal with this?
Cheers,
Thunor
Code: Select all
; This ticks at 25Hz on a 50Hz ZX81.
timer_tick: ld a,(FRAMES)
and 1
jr nz,timer_tick
ret
Cheers,
Thunor
Re: Information on NMI's, INT's and timings...
Hi Thundor,
If you wanted more flexibility with the way the ZX81 generates it's display, have a look at the driver I've started developing. It allows adding Interrupt service routines and will eventually free up the IY register. Take a look at the end of the "Developing new ZX81 Video Driver" thread in this forum. Its aimed at games written in M/C.
If you wanted more flexibility with the way the ZX81 generates it's display, have a look at the driver I've started developing. It allows adding Interrupt service routines and will eventually free up the IY register. Take a look at the end of the "Developing new ZX81 Video Driver" thread in this forum. Its aimed at games written in M/C.
Memotech rules
Re: Information on NMI's, INT's and timings...
Thanks thewizthewiz wrote:Hi Thunor,
If you wanted more flexibility with the way the ZX81 generates it's display, have a look at the driver I've started developing. It allows adding Interrupt service routines and will eventually free up the IY register. Take a look at the end of the "Developing new ZX81 Video Driver" thread in this forum. Its aimed at games written in M/C.
Actually I found MARGIN which holds 31 for US machines and 55 for UK, so at least I can make allowances knowing that. I found it whilst researching how to identify more than one key being pressed, my next mountain to climb
Re: Information on NMI's, INT's and timings...
Personally I simply read the MARGINS variable, and if running on a 50Hz machine delay for a little while until it is roughly the speed of the 60Hz machine.
As for reading more than one key at once, you need to read from port 254.
As for reading more than one key at once, you need to read from port 254.
Re: Information on NMI's, INT's and timings...
Cheers bobs. I managed to figure out from the ROM the fefe, fdfe, fbfe etc. in regBC.bobs wrote:Personally I simply read the MARGINS variable, and if running on a 50Hz machine delay for a little while until it is roughly the speed of the 60Hz machine.
As for reading more than one key at once, you need to read from port 254.
So then since the ROM is creating the TV picture and it must create 20% more on a 60Hz machine, does this mean that 60Hz machines ran slower overall? Was BASIC even slower?
[EDIT] NTSC has a lower vertical resolution but a higher temporal resolution. I get the idea now.
Re: Information on NMI's, INT's and timings...
I found an awesome document here -> http://nocash.emubase.de/zxdocs.htm#displayoutputThunor wrote:So then since the ROM is creating the TV picture and it must create 20% more on a 60Hz machine, does this mean that 60Hz machines ran slower overall? Was BASIC even slower?
It's from the nocash emulator (I've never heard of this before; runs great in DOSBox; loads of debugging stuff).
It says:
Resulting User Available CPU Time
SLOW, 50Hz Effective Speed 0.820800 MHz (54*2*152 cycles, 50 frames)
SLOW, 60Hz Effective Speed 0.547200 MHz (30*2*152 cycles, 60 frames)
FAST, Total CPU Speed 3.250000 MHz (display disabled)