tomaz / zx-next-dev-guide

Guide for ZX Spectrum Next assembler developer. Available as free to download PDF from releases page, or printed coil bound book at https://bit.ly/zx-next-assembler-dev-guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add hardware IM2 mode description

tomaz opened this issue · comments

commented

There is also a hardware im2 mode on the Next (nextreg 0xc0 and up https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/nextreg.txt#L1004 ). The z80 can be placed in im2 mode, in which case the Next behaves like a traditional spectrum, and in addition the Next itself can be placed in a hardware im2 mode. In this mode, all the Next's interrupters including the ula behave like im2 peripherals with each generating their own im2 vector. In this mode, it is also possible to program interrupters to interrupt dma operations. Interrupting a dma operation comes with a new caveat since the z80 cannot see an interrupt until the end of an instruction. So if the dma gives up the bus temporarily for an interrupt, then the z80 will execute one instruction in the main program until the interrupt is seen. The isr will execute and reti will return control to the dma. Anyway there is another rabbit hole here :slight_smile:

from Discord

commented

This should ideally be tested with program and included as sample code... Though maybe for start just mention HW IM2 mode exists and describe it briefly?

Couple interrupt related resources that may be useful:

http://jgmalcolm.com/z80/advanced/im2i
https://luckyredfish.com/interrupts-on-the-zx-spectrum/

Next interrupts chapter should be restructured anyway, at present it's not very useful or much Next-only...

commented

Restructured Next interrupts chapter completely, added 3 sample projects and mentioned hardware IM2 mode (but no full description; it seemed like WIP and anyway the book is not meant to cover everything). May refine in the future.