<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.specnext.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Johnnyo</id>
	<title>SpecNext Wiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.specnext.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Johnnyo"/>
	<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/Special:Contributions/Johnnyo"/>
	<updated>2026-06-01T17:17:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41949</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41949"/>
		<updated>2026-05-31T10:18:15Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Spectrum Books and Documentation */  ZX Spectrum BASIC Programming&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
The Next project is continuously improved, so it&#039;s a good practice to check for the most recent updates of the manuals, documents and Next-specific books.&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
(The Next specific books are typically written under assumption that the reader is already familiar enough with the low-level hardware programming aspects relevant to the original ZX Spectrum, so the readers who aren&#039;t should also check the books about the &amp;quot;classic&amp;quot; ZX Spectrum too)&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
Many books were written since 1982, this is just a selection.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;Sinclair ZX Spectrum BASIC Programming&#039;&#039; by Steven Vickers (1982) ==&lt;br /&gt;
&lt;br /&gt;
* https://worldofspectrum.net/ZXBasicManual/ The book included in the original package of ZX Spectrum 48K. Wealth of information in a single book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;Step-by-Step Programming ZX Spectrum&#039;&#039; Series ==&lt;br /&gt;
* Book One, by Ian Graham (1984) https://worldofspectrum.net/item/2001330/&lt;br /&gt;
* Book Two, by Ian Graham (1984) https://worldofspectrum.net/item/2001331/&lt;br /&gt;
* Book Three, by Piers Letcher (1985) https://worldofspectrum.net/item/2000385/&lt;br /&gt;
* Book Four, by Piers Letcher (1985) https://worldofspectrum.net/item/2000460/&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games (Since 2006, updated recently)&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan (2020) ==&lt;br /&gt;
* The motivation for writing this book in 2020 was the release of the Sinclair ZX Spectrum Next, even if it (mostly?) covers the assembly which would work on the original ZX Spectrum: http://ped.7gods.org/z80.pdf&lt;br /&gt;
== &#039;&#039;Understanding Your Spectrum&#039;&#039; by Dr. Ian Logan (1982) ==&lt;br /&gt;
* https://spectrumcomputing.co.uk/entry/2000400/Book/Understanding_Your_Spectrum&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41948</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41948"/>
		<updated>2026-05-23T13:39:29Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* Step-by-Step Programming ZX Spectrum Series */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
The Next project is continuously improved, so it&#039;s a good practice to check for the most recent updates of the manuals, documents and Next-specific books.&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
(The Next specific books are typically written under assumption that the reader is already familiar enough with the low-level hardware programming aspects relevant to the original ZX Spectrum, so the readers who aren&#039;t should also check the books about the &amp;quot;classic&amp;quot; ZX Spectrum too)&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
Many books were written since 1982, this is just a selection.&lt;br /&gt;
== Step-by-Step Programming ZX Spectrum Series ==&lt;br /&gt;
* Book One, by Ian Graham (1984) https://worldofspectrum.net/item/2001330/&lt;br /&gt;
* Book Two, by Ian Graham (1984) https://worldofspectrum.net/item/2001331/&lt;br /&gt;
* Book Three, by Piers Letcher (1985) https://worldofspectrum.net/item/2000385/&lt;br /&gt;
* Book Four, by Piers Letcher (1985) https://worldofspectrum.net/item/2000460/&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games (Since 2006, updated recently)&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan (2020) ==&lt;br /&gt;
* The motivation for writing this book in 2020 was the release of the Sinclair ZX Spectrum Next, even if it (mostly?) covers the assembly which would work on the original ZX Spectrum: http://ped.7gods.org/z80.pdf&lt;br /&gt;
== &#039;&#039;Understanding Your Spectrum&#039;&#039; by Dr. Ian Logan (1982) ==&lt;br /&gt;
* https://spectrumcomputing.co.uk/entry/2000400/Book/Understanding_Your_Spectrum&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41947</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41947"/>
		<updated>2026-05-23T13:35:04Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* Step-by-Step Programming ZX Spectrum Series */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
The Next project is continuously improved, so it&#039;s a good practice to check for the most recent updates of the manuals, documents and Next-specific books.&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
(The Next specific books are typically written under assumption that the reader is already familiar enough with the low-level hardware programming aspects relevant to the original ZX Spectrum, so the readers who aren&#039;t should also check the books about the &amp;quot;classic&amp;quot; ZX Spectrum too)&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
Many books were written since 1982, this is just a selection.&lt;br /&gt;
== Step-by-Step Programming ZX Spectrum Series ==&lt;br /&gt;
* Book One, by Ian Graham https://worldofspectrum.net/item/2001330/&lt;br /&gt;
* Book Two, by Ian Graham  https://worldofspectrum.net/item/2001331/&lt;br /&gt;
* Book Three, by Piers Letcher   https://worldofspectrum.net/item/2000385/&lt;br /&gt;
* Book Four, by Piers Letcher  https://worldofspectrum.net/item/2000460/&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games (Since 2006, updated recently)&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan (2020) ==&lt;br /&gt;
* The motivation for writing this book in 2020 was the release of the Sinclair ZX Spectrum Next, even if it (mostly?) covers the assembly which would work on the original ZX Spectrum: http://ped.7gods.org/z80.pdf&lt;br /&gt;
== &#039;&#039;Understanding Your Spectrum&#039;&#039; by Dr. Ian Logan (1982) ==&lt;br /&gt;
* https://spectrumcomputing.co.uk/entry/2000400/Book/Understanding_Your_Spectrum&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41946</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41946"/>
		<updated>2026-05-23T13:34:49Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Spectrum Books and Documentation */ Step-by-Step Programming ZX Spectrum Series&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
The Next project is continuously improved, so it&#039;s a good practice to check for the most recent updates of the manuals, documents and Next-specific books.&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
(The Next specific books are typically written under assumption that the reader is already familiar enough with the low-level hardware programming aspects relevant to the original ZX Spectrum, so the readers who aren&#039;t should also check the books about the &amp;quot;classic&amp;quot; ZX Spectrum too)&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
Many books were written since 1982, this is just a selection.&lt;br /&gt;
== Step-by-Step Programming ZX Spectrum Series ==&lt;br /&gt;
* Book One, by Ian Graham https://worldofspectrum.net/item/2001330/&lt;br /&gt;
* Book Two, by Ian Graham  https://worldofspectrum.net/item/2001331/&lt;br /&gt;
* Book Three, by Piers Letcher   https://worldofspectrum.net/item/2000385/&lt;br /&gt;
* Book Four, by Piers Letcher  https://worldofspectrum.net/item/2000460/&lt;br /&gt;
&lt;br /&gt;
https://worldofspectrum.net/item/2001330/&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games (Since 2006, updated recently)&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan (2020) ==&lt;br /&gt;
* The motivation for writing this book in 2020 was the release of the Sinclair ZX Spectrum Next, even if it (mostly?) covers the assembly which would work on the original ZX Spectrum: http://ped.7gods.org/z80.pdf&lt;br /&gt;
== &#039;&#039;Understanding Your Spectrum&#039;&#039; by Dr. Ian Logan (1982) ==&lt;br /&gt;
* https://spectrumcomputing.co.uk/entry/2000400/Book/Understanding_Your_Spectrum&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41945</id>
		<title>Layer 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41945"/>
		<updated>2026-05-20T00:39:10Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: rewording&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Layer 2 provides an additional screen layer at 256x192 256 colours, 320x256 256 colours or 640x256 16 colours in which every pixel is individually coloured. Layer 2 may appear in place of, behind, or above the ULA-generated/Tilemap layer.&lt;br /&gt;
&lt;br /&gt;
The palette used to show the Layer 2 is selected by the bit 2 of the {{NextRegNo|$43}}.&lt;br /&gt;
&lt;br /&gt;
The Layer 2 screen occupies 48kiB or 80kiB, spreading over 3, or 5, consecutive 16K [[Memory map|banks]]. By the NextZXOS/NextBASIC default, the same banks 9-11 are used for both the visible and the &amp;quot;shadow&amp;quot; Layer 2 screen (the core, after power-on but before the NextZXOS boots set its defaults to 8-10 for the displayed Layer 2 screen and 11-13 for the shadow screen, but these settings are modified during the boot of NextZXOS). The starting bank of the main Layer 2 screen can be changed using {{NextRegNo|$12}} and and the starting bank for the shadow Layer 2 screen can be changed using {{NextRegNo|$13}} (avoid using banks 5, 7 and 8 for the Layer 2 screen, unless you are familiar with SRAM and BRAM of the board and how the ULA screen memory has special treatment in Next&#039;s FPGA).&lt;br /&gt;
&lt;br /&gt;
Each pixel of Layer 2 takes one byte of video memory in 8bpp modes or half a byte in 4bpp mode, so the Layer 2 needs 48kiB for 256x192 mode or 80kiB for 320x256-8bit or 640x256-4bit mode. The Layer 2 256x192 mode is divided &#039;&#039;&#039;horizontally&#039;&#039;&#039; into 3 16kiB banks of 64 &#039;&#039;&#039;lines&#039;&#039;&#039; each. The modes 320x256 and 640x256 are divided &#039;&#039;&#039;vertically&#039;&#039;&#039; into 5 16kiB  banks of 64 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 320x256 mode or 128 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 640x256 mode.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is controlled via {{PortNo|$123B}} and {{NextRegNo|$70}}, the port is bit mapped as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bit !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 7-6 || Video RAM bank select (write/read paging)&lt;br /&gt;
|-&lt;br /&gt;
| 5-4 || Reserved, write 0&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Use Shadow Layer 2 for paging - {{NextRegNo|$13}}&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Enable Layer 2 read-only paging&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Layer 2 visible - {{NextRegNo|$12}}&lt;br /&gt;
Since core 3.0 this bit has mirror in {{NextRegNo|$69}}&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Enable Layer 2 write-only paging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When bit 0 of $123B is set to 1, the appropriate area of Layer 2 video memory (as set by bits 6-7) is accessed by &#039;&#039;&#039;writes&#039;&#039;&#039; into slot 1, ie memory area $0000-$3fff (see [[Memory map]]). This prevents any conflict since this area would normally be ROM and thus useless to write to. However, you &#039;&#039;&#039;cannot READ the contents of Layer 2 via this mapping!&#039;&#039;&#039; Reading addresses in this range will read the values from the ROM page (or RAM bank if in AllRam mode) that would be mapped there normally if Layer 2 paging was disabled.&lt;br /&gt;
&lt;br /&gt;
When bit 2 of $123B is set to 1 (new feature of core 3.0), the same area $0000-$3fff is remapped for read, allowing read access into Layer 2 bank selected by bits 3,6 and 7 (while write will still go into the regular ROM/RAM page).&lt;br /&gt;
&lt;br /&gt;
With both bits 0 and 2 set you are creating alternative read+write mapping of RAM (technically identical to mapping done by MM0+MMU1 registers).&lt;br /&gt;
&lt;br /&gt;
Bank 5 and first half of Bank 7, when being accessed by regular means (MMU paging, default memory mapping, DMA), are overshadowed by fast BRAM memory inside the FPGA chip, which is then used to generate ULA screen and [[Tilemap]] graphics (aka &amp;quot;Layer 3&amp;quot;) - not using the SRAM memory chip in that particular area. This Layer 2 (mapping and visible data) is the only exception, circumventing this mechanism and accessing the Bank 5 and Bank 7 in the main memory SRAM chip (giving you extra 16+8kiB of &amp;quot;secret&amp;quot; memory and further headache to emulators&#039; authors). If you are not sure what this means, just avoid using bank 5 and 7 for Layer 2, use values greater/equal to 8 (and avoid also Bank 8, unless you want to destroy NextBASIC warm-restart/soft-reset variables).&lt;br /&gt;
&lt;br /&gt;
Bits 6 and 7 contain the number which third of Layer 2 should be mapped (0..2), or (new feature of core 3.0) when value 3 is set, whole 48kiB of Layer 2 is mapped into area $0000-$bfff (make sure your code, stack and interrupts will cope well with such new mapping).&lt;br /&gt;
&lt;br /&gt;
There is one more new functionality in latest 3.x cores, allowing to set bank-offset variable from 0 to 7. This offset is further applied to the bank selected for write/read (by writing value 0..7 to the port with bit4 set (so it&#039;s value 16..23). If you did set for example 16kiB write mapping of first bank, the first bank is 9, and use value 21 for bank-offset setup (+5 offset), the bank mapped into $0000..$3FFF address area will be 14 (9+5). This way you can map full 80kiB of pixel data into the bottom 16kiB window (or bottom 48kiB window), using different offsets.&lt;br /&gt;
&lt;br /&gt;
Use {{NextRegNo|$70}} to select particular Layer2 mode, and to modify palette offset (added to top four bits of each pixel). Don&#039;t forget to set up Layer 2 clip window correctly for each mode ({{NextRegNo|$18}}).&lt;br /&gt;
&lt;br /&gt;
You can still use also the regular [[Memory map|banking]] ports to switch in one of the Layer 2 banks in slot for at $C000 (or use the ZX Next MMU registers to map that RAM in other regions). This will allow you to read and write the memory as usual. The ability to write to Layer 2 via writes into slot 1 is provided for convenience and to allow graphics data to be easily copied from extended RAM banks.&lt;br /&gt;
&lt;br /&gt;
Pixels are drawn to Layer 2 by writing to the appropriate area of RAM. Layer 2 pixels in 256x192 mode are in English reading order with no ULA-style interlacing. Since there are 256 pixels per line, and when using access via slot 1 the memory port starts at $0000, the upper byte of the address exactly equals the Y coordinate (within the selected third of the screen) and the lower byte exactly equals the X coordinate.&lt;br /&gt;
&lt;br /&gt;
In mode 320x256 (8bpp) the pixels are stored in memory going from top to bottom and left to right (second byte is first pixel on second line, 256th byte is second pixel on first line). Since there are 256 pixels per column, the upper byte of address could represent the X coordinate (only specific range of them, as whole 0..319 range does not fit into 8 bits), and the lower byte of address is Y coordinate. The total pixel memory is 80kiB (five 16kiB banks), and could be mapped into memory either by MMU or by bank-offset feature of {{PortNo|$123B}}.&lt;br /&gt;
&lt;br /&gt;
In mode 640x256 (4bpp) the pixels are stored identically to 320x256 mode, but every byte contains two pixels. The top nibble (top four bits) form &amp;quot;left&amp;quot; pixel, and the bottom nibble form &amp;quot;right&amp;quot; pixel, so first 256 bytes will display as two columns on screen, not one.&lt;br /&gt;
&lt;br /&gt;
Note that you will need to manually clear the Layer 2 screen before drawing on it, as it may contain random data when the machine starts up.&lt;br /&gt;
&lt;br /&gt;
System registers {{NextRegNo|$16}}, {{NextRegNo|$71}} and {{NextRegNo|$17}} apply a pixel shift to all content in Layer &lt;br /&gt;
2, allowing scrolling effects to be created.&lt;br /&gt;
&lt;br /&gt;
Since core 3.0 the visibility of Layer 2 is not affected by usage of ZX128 ULA-shadow (Bank 7) screen.&lt;br /&gt;
&lt;br /&gt;
Obsolete info for core 2.x (limitation was lifted in core 3.0): &amp;lt;del&amp;gt;the visible Layer 2 will cause the slow down of CPU to 7MHz.&amp;lt;/del&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use double-buffered scheme for Layer 2, think about {{NextRegNo|$12}} being display related (i.e. has to be changed to display new Layer 2, when the new image is already prepared) (or it may be modified also during frame to compose final image from various memory areas), while {{NextRegNo|$13}} is related only to write-over-ROM paging functionality ({{PortNo|$123B}}).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41944</id>
		<title>Layer 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41944"/>
		<updated>2026-05-20T00:37:52Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: rewording starting REG 12 / 13&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Layer 2 provides an additional screen layer at 256x192 256 colours, 320x256 256 colours or 640x256 16 colours in which every pixel is individually coloured. Layer 2 may appear in place of, behind, or above the ULA-generated/Tilemap layer.&lt;br /&gt;
&lt;br /&gt;
The palette used to show the Layer 2 is selected by the bit 2 of the {{NextRegNo|$43}}.&lt;br /&gt;
&lt;br /&gt;
The Layer 2 screen occupies 48kiB or 80kiB, which is stored in 3 (or 5) consecutive 16K [[Memory map|banks]]. By NextZXOS/NextBASIC default, the same banks 9-11 are used for both the visible and &amp;quot;shadow&amp;quot; Layer 2 screen (the core, after power-on but before the NextZXOS boots set its defaults to 8-10 for the displayed Layer 2 screen and 11-13 for the shadow screen, but these settings are modified during the boot of NextZXOS). The starting bank of the main Layer 2 screen can be changed using {{NextRegNo|$12}} and and the starting bank for the shadow Layer 2 screen can be changed using {{NextRegNo|$13}} (avoid using banks 5, 7 and 8 for the Layer 2 screen, unless you are familiar with SRAM and BRAM of the board and how the ULA screen memory has special treatment in Next&#039;s FPGA).&lt;br /&gt;
&lt;br /&gt;
Each pixel of Layer 2 takes one byte of video memory in 8bpp modes or half a byte in 4bpp mode, so the Layer 2 needs 48kiB for 256x192 mode or 80kiB for 320x256-8bit or 640x256-4bit mode. The Layer 2 256x192 mode is divided &#039;&#039;&#039;horizontally&#039;&#039;&#039; into 3 16kiB banks of 64 &#039;&#039;&#039;lines&#039;&#039;&#039; each. The modes 320x256 and 640x256 are divided &#039;&#039;&#039;vertically&#039;&#039;&#039; into 5 16kiB  banks of 64 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 320x256 mode or 128 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 640x256 mode.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is controlled via {{PortNo|$123B}} and {{NextRegNo|$70}}, the port is bit mapped as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bit !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 7-6 || Video RAM bank select (write/read paging)&lt;br /&gt;
|-&lt;br /&gt;
| 5-4 || Reserved, write 0&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Use Shadow Layer 2 for paging - {{NextRegNo|$13}}&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Enable Layer 2 read-only paging&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Layer 2 visible - {{NextRegNo|$12}}&lt;br /&gt;
Since core 3.0 this bit has mirror in {{NextRegNo|$69}}&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Enable Layer 2 write-only paging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When bit 0 of $123B is set to 1, the appropriate area of Layer 2 video memory (as set by bits 6-7) is accessed by &#039;&#039;&#039;writes&#039;&#039;&#039; into slot 1, ie memory area $0000-$3fff (see [[Memory map]]). This prevents any conflict since this area would normally be ROM and thus useless to write to. However, you &#039;&#039;&#039;cannot READ the contents of Layer 2 via this mapping!&#039;&#039;&#039; Reading addresses in this range will read the values from the ROM page (or RAM bank if in AllRam mode) that would be mapped there normally if Layer 2 paging was disabled.&lt;br /&gt;
&lt;br /&gt;
When bit 2 of $123B is set to 1 (new feature of core 3.0), the same area $0000-$3fff is remapped for read, allowing read access into Layer 2 bank selected by bits 3,6 and 7 (while write will still go into the regular ROM/RAM page).&lt;br /&gt;
&lt;br /&gt;
With both bits 0 and 2 set you are creating alternative read+write mapping of RAM (technically identical to mapping done by MM0+MMU1 registers).&lt;br /&gt;
&lt;br /&gt;
Bank 5 and first half of Bank 7, when being accessed by regular means (MMU paging, default memory mapping, DMA), are overshadowed by fast BRAM memory inside the FPGA chip, which is then used to generate ULA screen and [[Tilemap]] graphics (aka &amp;quot;Layer 3&amp;quot;) - not using the SRAM memory chip in that particular area. This Layer 2 (mapping and visible data) is the only exception, circumventing this mechanism and accessing the Bank 5 and Bank 7 in the main memory SRAM chip (giving you extra 16+8kiB of &amp;quot;secret&amp;quot; memory and further headache to emulators&#039; authors). If you are not sure what this means, just avoid using bank 5 and 7 for Layer 2, use values greater/equal to 8 (and avoid also Bank 8, unless you want to destroy NextBASIC warm-restart/soft-reset variables).&lt;br /&gt;
&lt;br /&gt;
Bits 6 and 7 contain the number which third of Layer 2 should be mapped (0..2), or (new feature of core 3.0) when value 3 is set, whole 48kiB of Layer 2 is mapped into area $0000-$bfff (make sure your code, stack and interrupts will cope well with such new mapping).&lt;br /&gt;
&lt;br /&gt;
There is one more new functionality in latest 3.x cores, allowing to set bank-offset variable from 0 to 7. This offset is further applied to the bank selected for write/read (by writing value 0..7 to the port with bit4 set (so it&#039;s value 16..23). If you did set for example 16kiB write mapping of first bank, the first bank is 9, and use value 21 for bank-offset setup (+5 offset), the bank mapped into $0000..$3FFF address area will be 14 (9+5). This way you can map full 80kiB of pixel data into the bottom 16kiB window (or bottom 48kiB window), using different offsets.&lt;br /&gt;
&lt;br /&gt;
Use {{NextRegNo|$70}} to select particular Layer2 mode, and to modify palette offset (added to top four bits of each pixel). Don&#039;t forget to set up Layer 2 clip window correctly for each mode ({{NextRegNo|$18}}).&lt;br /&gt;
&lt;br /&gt;
You can still use also the regular [[Memory map|banking]] ports to switch in one of the Layer 2 banks in slot for at $C000 (or use the ZX Next MMU registers to map that RAM in other regions). This will allow you to read and write the memory as usual. The ability to write to Layer 2 via writes into slot 1 is provided for convenience and to allow graphics data to be easily copied from extended RAM banks.&lt;br /&gt;
&lt;br /&gt;
Pixels are drawn to Layer 2 by writing to the appropriate area of RAM. Layer 2 pixels in 256x192 mode are in English reading order with no ULA-style interlacing. Since there are 256 pixels per line, and when using access via slot 1 the memory port starts at $0000, the upper byte of the address exactly equals the Y coordinate (within the selected third of the screen) and the lower byte exactly equals the X coordinate.&lt;br /&gt;
&lt;br /&gt;
In mode 320x256 (8bpp) the pixels are stored in memory going from top to bottom and left to right (second byte is first pixel on second line, 256th byte is second pixel on first line). Since there are 256 pixels per column, the upper byte of address could represent the X coordinate (only specific range of them, as whole 0..319 range does not fit into 8 bits), and the lower byte of address is Y coordinate. The total pixel memory is 80kiB (five 16kiB banks), and could be mapped into memory either by MMU or by bank-offset feature of {{PortNo|$123B}}.&lt;br /&gt;
&lt;br /&gt;
In mode 640x256 (4bpp) the pixels are stored identically to 320x256 mode, but every byte contains two pixels. The top nibble (top four bits) form &amp;quot;left&amp;quot; pixel, and the bottom nibble form &amp;quot;right&amp;quot; pixel, so first 256 bytes will display as two columns on screen, not one.&lt;br /&gt;
&lt;br /&gt;
Note that you will need to manually clear the Layer 2 screen before drawing on it, as it may contain random data when the machine starts up.&lt;br /&gt;
&lt;br /&gt;
System registers {{NextRegNo|$16}}, {{NextRegNo|$71}} and {{NextRegNo|$17}} apply a pixel shift to all content in Layer &lt;br /&gt;
2, allowing scrolling effects to be created.&lt;br /&gt;
&lt;br /&gt;
Since core 3.0 the visibility of Layer 2 is not affected by usage of ZX128 ULA-shadow (Bank 7) screen.&lt;br /&gt;
&lt;br /&gt;
Obsolete info for core 2.x (limitation was lifted in core 3.0): &amp;lt;del&amp;gt;the visible Layer 2 will cause the slow down of CPU to 7MHz.&amp;lt;/del&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use double-buffered scheme for Layer 2, think about {{NextRegNo|$12}} being display related (i.e. has to be changed to display new Layer 2, when the new image is already prepared) (or it may be modified also during frame to compose final image from various memory areas), while {{NextRegNo|$13}} is related only to write-over-ROM paging functionality ({{PortNo|$123B}}).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41943</id>
		<title>Layer 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41943"/>
		<updated>2026-05-20T00:32:54Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: wording re starting banks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Layer 2 provides an additional screen layer at 256x192 256 colours, 320x256 256 colours or 640x256 16 colours in which every pixel is individually coloured. Layer 2 may appear in place of, behind, or above the ULA-generated/Tilemap layer.&lt;br /&gt;
&lt;br /&gt;
The palette used to show the Layer 2 is selected by the bit 2 of the {{NextRegNo|$43}}.&lt;br /&gt;
&lt;br /&gt;
The Layer 2 screen occupies 48kiB or 80kiB, which is stored in 3 (or 5) consecutive 16K [[Memory map|banks]]. By NextZXOS/NextBASIC default, banks 9-11 are used for the visible and &amp;quot;shadow&amp;quot; Layer 2 screen (the HW after power-on defaults to 8-10 for displayed and 11-13 for shadow screen, but that gets modified by NextZXOS booting up). The starting bank of the main Layer 2 screen can be changed using {{NextRegNo|$12}} and and the starting bank for the shadow Layer 2 screen can be changed using {{NextRegNo|$13}} (avoid using banks 5, 7 and 8 for the Layer 2 screen, unless you are familiar with SRAM and BRAM of the board and how the ULA screen memory has special treatment in Next&#039;s FPGA).&lt;br /&gt;
&lt;br /&gt;
Each pixel of Layer 2 takes one byte of video memory in 8bpp modes or half a byte in 4bpp mode, so the Layer 2 needs 48kiB for 256x192 mode or 80kiB for 320x256-8bit or 640x256-4bit mode. The Layer 2 256x192 mode is divided &#039;&#039;&#039;horizontally&#039;&#039;&#039; into 3 16kiB banks of 64 &#039;&#039;&#039;lines&#039;&#039;&#039; each. The modes 320x256 and 640x256 are divided &#039;&#039;&#039;vertically&#039;&#039;&#039; into 5 16kiB  banks of 64 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 320x256 mode or 128 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 640x256 mode.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is controlled via {{PortNo|$123B}} and {{NextRegNo|$70}}, the port is bit mapped as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bit !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 7-6 || Video RAM bank select (write/read paging)&lt;br /&gt;
|-&lt;br /&gt;
| 5-4 || Reserved, write 0&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Use Shadow Layer 2 for paging - {{NextRegNo|$13}}&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Enable Layer 2 read-only paging&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Layer 2 visible - {{NextRegNo|$12}}&lt;br /&gt;
Since core 3.0 this bit has mirror in {{NextRegNo|$69}}&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Enable Layer 2 write-only paging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When bit 0 of $123B is set to 1, the appropriate area of Layer 2 video memory (as set by bits 6-7) is accessed by &#039;&#039;&#039;writes&#039;&#039;&#039; into slot 1, ie memory area $0000-$3fff (see [[Memory map]]). This prevents any conflict since this area would normally be ROM and thus useless to write to. However, you &#039;&#039;&#039;cannot READ the contents of Layer 2 via this mapping!&#039;&#039;&#039; Reading addresses in this range will read the values from the ROM page (or RAM bank if in AllRam mode) that would be mapped there normally if Layer 2 paging was disabled.&lt;br /&gt;
&lt;br /&gt;
When bit 2 of $123B is set to 1 (new feature of core 3.0), the same area $0000-$3fff is remapped for read, allowing read access into Layer 2 bank selected by bits 3,6 and 7 (while write will still go into the regular ROM/RAM page).&lt;br /&gt;
&lt;br /&gt;
With both bits 0 and 2 set you are creating alternative read+write mapping of RAM (technically identical to mapping done by MM0+MMU1 registers).&lt;br /&gt;
&lt;br /&gt;
Bank 5 and first half of Bank 7, when being accessed by regular means (MMU paging, default memory mapping, DMA), are overshadowed by fast BRAM memory inside the FPGA chip, which is then used to generate ULA screen and [[Tilemap]] graphics (aka &amp;quot;Layer 3&amp;quot;) - not using the SRAM memory chip in that particular area. This Layer 2 (mapping and visible data) is the only exception, circumventing this mechanism and accessing the Bank 5 and Bank 7 in the main memory SRAM chip (giving you extra 16+8kiB of &amp;quot;secret&amp;quot; memory and further headache to emulators&#039; authors). If you are not sure what this means, just avoid using bank 5 and 7 for Layer 2, use values greater/equal to 8 (and avoid also Bank 8, unless you want to destroy NextBASIC warm-restart/soft-reset variables).&lt;br /&gt;
&lt;br /&gt;
Bits 6 and 7 contain the number which third of Layer 2 should be mapped (0..2), or (new feature of core 3.0) when value 3 is set, whole 48kiB of Layer 2 is mapped into area $0000-$bfff (make sure your code, stack and interrupts will cope well with such new mapping).&lt;br /&gt;
&lt;br /&gt;
There is one more new functionality in latest 3.x cores, allowing to set bank-offset variable from 0 to 7. This offset is further applied to the bank selected for write/read (by writing value 0..7 to the port with bit4 set (so it&#039;s value 16..23). If you did set for example 16kiB write mapping of first bank, the first bank is 9, and use value 21 for bank-offset setup (+5 offset), the bank mapped into $0000..$3FFF address area will be 14 (9+5). This way you can map full 80kiB of pixel data into the bottom 16kiB window (or bottom 48kiB window), using different offsets.&lt;br /&gt;
&lt;br /&gt;
Use {{NextRegNo|$70}} to select particular Layer2 mode, and to modify palette offset (added to top four bits of each pixel). Don&#039;t forget to set up Layer 2 clip window correctly for each mode ({{NextRegNo|$18}}).&lt;br /&gt;
&lt;br /&gt;
You can still use also the regular [[Memory map|banking]] ports to switch in one of the Layer 2 banks in slot for at $C000 (or use the ZX Next MMU registers to map that RAM in other regions). This will allow you to read and write the memory as usual. The ability to write to Layer 2 via writes into slot 1 is provided for convenience and to allow graphics data to be easily copied from extended RAM banks.&lt;br /&gt;
&lt;br /&gt;
Pixels are drawn to Layer 2 by writing to the appropriate area of RAM. Layer 2 pixels in 256x192 mode are in English reading order with no ULA-style interlacing. Since there are 256 pixels per line, and when using access via slot 1 the memory port starts at $0000, the upper byte of the address exactly equals the Y coordinate (within the selected third of the screen) and the lower byte exactly equals the X coordinate.&lt;br /&gt;
&lt;br /&gt;
In mode 320x256 (8bpp) the pixels are stored in memory going from top to bottom and left to right (second byte is first pixel on second line, 256th byte is second pixel on first line). Since there are 256 pixels per column, the upper byte of address could represent the X coordinate (only specific range of them, as whole 0..319 range does not fit into 8 bits), and the lower byte of address is Y coordinate. The total pixel memory is 80kiB (five 16kiB banks), and could be mapped into memory either by MMU or by bank-offset feature of {{PortNo|$123B}}.&lt;br /&gt;
&lt;br /&gt;
In mode 640x256 (4bpp) the pixels are stored identically to 320x256 mode, but every byte contains two pixels. The top nibble (top four bits) form &amp;quot;left&amp;quot; pixel, and the bottom nibble form &amp;quot;right&amp;quot; pixel, so first 256 bytes will display as two columns on screen, not one.&lt;br /&gt;
&lt;br /&gt;
Note that you will need to manually clear the Layer 2 screen before drawing on it, as it may contain random data when the machine starts up.&lt;br /&gt;
&lt;br /&gt;
System registers {{NextRegNo|$16}}, {{NextRegNo|$71}} and {{NextRegNo|$17}} apply a pixel shift to all content in Layer &lt;br /&gt;
2, allowing scrolling effects to be created.&lt;br /&gt;
&lt;br /&gt;
Since core 3.0 the visibility of Layer 2 is not affected by usage of ZX128 ULA-shadow (Bank 7) screen.&lt;br /&gt;
&lt;br /&gt;
Obsolete info for core 2.x (limitation was lifted in core 3.0): &amp;lt;del&amp;gt;the visible Layer 2 will cause the slow down of CPU to 7MHz.&amp;lt;/del&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use double-buffered scheme for Layer 2, think about {{NextRegNo|$12}} being display related (i.e. has to be changed to display new Layer 2, when the new image is already prepared) (or it may be modified also during frame to compose final image from various memory areas), while {{NextRegNo|$13}} is related only to write-over-ROM paging functionality ({{PortNo|$123B}}).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41942</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41942"/>
		<updated>2026-05-19T23:40:18Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Spectrum Next Documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
The Next project is continuously improved, so it&#039;s a good practice to check for the most recent updates of the manuals, documents and Next-specific books.&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
(The Next specific books are typically written under assumption that the reader is already familiar enough with the low-level hardware programming aspects relevant to the original ZX Spectrum, so the readers who aren&#039;t should also check the books about the &amp;quot;classic&amp;quot; ZX Spectrum too)&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
Many books were written since 1982, this is just a selection.&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games (Since 2006, updated recently)&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan (2020) ==&lt;br /&gt;
* The motivation for writing this book in 2020 was the release of the Sinclair ZX Spectrum Next, even if it (mostly?) covers the assembly which would work on the original ZX Spectrum: http://ped.7gods.org/z80.pdf&lt;br /&gt;
== &#039;&#039;Understanding Your Spectrum&#039;&#039; by Dr. Ian Logan (1982) ==&lt;br /&gt;
* https://spectrumcomputing.co.uk/entry/2000400/Book/Understanding_Your_Spectrum&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41941</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41941"/>
		<updated>2026-05-19T23:38:20Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Spectrum Books and Documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
(The Next specific books are typically written under assumption that the reader is already familiar enough with the low-level hardware programming aspects relevant to the original ZX Spectrum, so the readers who aren&#039;t should also check the books about the &amp;quot;classic&amp;quot; ZX Spectrum too)&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
Many books were written since 1982, this is just a selection.&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games (Since 2006, updated recently)&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan (2020) ==&lt;br /&gt;
* The motivation for writing this book in 2020 was the release of the Sinclair ZX Spectrum Next, even if it (mostly?) covers the assembly which would work on the original ZX Spectrum: http://ped.7gods.org/z80.pdf&lt;br /&gt;
== &#039;&#039;Understanding Your Spectrum&#039;&#039; by Dr. Ian Logan (1982) ==&lt;br /&gt;
* https://spectrumcomputing.co.uk/entry/2000400/Book/Understanding_Your_Spectrum&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41940</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41940"/>
		<updated>2026-05-19T23:31:13Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* First Steps in Z80 Assembly Language (for ZX Spectrum) by Darryl Sloan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
(The Next specific books are typically written under assumption that the reader is already familiar enough with the low-level hardware programming aspects relevant to the original ZX Spectrum, so the readers who aren&#039;t should also check the books about the &amp;quot;classic&amp;quot; ZX Spectrum too)&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan ==&lt;br /&gt;
* Listed here as the motivation for writing this book in 2020 was the release of the Sinclair ZX Spectrum Next, even if it (mostly?) covers the assembly which would work on the original ZX Spectrum: http://ped.7gods.org/z80.pdf&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41939</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41939"/>
		<updated>2026-05-19T23:29:15Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* Next-specific Books */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
(The Next specific books are typically written under assumption that the reader is already familiar enough with the low-level hardware programming aspects relevant to the original ZX Spectrum, so the readers who aren&#039;t should also check the books about the &amp;quot;classic&amp;quot; ZX Spectrum too)&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan ==&lt;br /&gt;
* http://ped.7gods.org/z80.pdf&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41938</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41938"/>
		<updated>2026-05-19T23:24:23Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Spectrum Books and Documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;br /&gt;
== &#039;&#039;First Steps in Z80 Assembly Language&#039;&#039; (for ZX Spectrum) by Darryl Sloan ==&lt;br /&gt;
* http://ped.7gods.org/z80.pdf&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41937</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41937"/>
		<updated>2026-05-19T20:32:41Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Spectrum Next Assembly Developer Guide by Tomaž Kragelj */ &amp;quot;or as a&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or as a printed coil bound book.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41936</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41936"/>
		<updated>2026-05-18T09:06:07Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* docs Directory of the Distribution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder written and kept up to date by the author of NextZXOS and NextBASIC.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or a printed coil bound book.&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41935</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41935"/>
		<updated>2026-05-14T11:13:20Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Basic Studio */ link to a text&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ Boriel Basic (ZX Basic)]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/boriel-basic/ZXBasicStudio/releases ZX Basic Studio]&#039;&#039; ===&lt;br /&gt;
: A multiplatform IDE for Boriel BASIC, with itegration with emulators for ZX Spectrum Next (CSpect, ZEsarUX and MAME), GDU and font editor, Sprite editor with import from external images, Colour palette editor for ZX Spectrum Next. Its [https://boriel-basic.net/page/preparing-the-development-environment installer] allows an easy start on Windows, Linux and MacOS.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World] &lt;br /&gt;
: The selection of the CRT is by startup=n number.  The crts are in the range 0-31, some mentioned in the above Hello World text, and some in the sources like [https://github.com/z88dk/z88dk/tree/master/libsrc/newlib/target/zxn/startup newlib zxn startup]. (internally: The factors of 256 are added by subtype=? on the compile line: base 0 numbers have no assumptions about the output type, i.e. for binaries that will be tap/nex/.. Base 256 is for dot commands, base 512 is for dotx command (not appropriate for the Next), base 768 is dotn).&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41934</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41934"/>
		<updated>2026-05-14T11:12:07Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* BASIC */ zx basic studio&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ Boriel Basic (ZX Basic)]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/boriel-basic/ZXBasicStudio/releases ZX Basic Studio]&#039;&#039; ===&lt;br /&gt;
: A multiplatform IDE for Boriel BASIC, with itegration with emulators for ZX Spectrum Next (CSpect, ZEsarUX and MAME), GDU and font editor, Sprite editor with import from external images, Colour palette editor for ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World] &lt;br /&gt;
: The selection of the CRT is by startup=n number.  The crts are in the range 0-31, some mentioned in the above Hello World text, and some in the sources like [https://github.com/z88dk/z88dk/tree/master/libsrc/newlib/target/zxn/startup newlib zxn startup]. (internally: The factors of 256 are added by subtype=? on the compile line: base 0 numbers have no assumptions about the output type, i.e. for binaries that will be tap/nex/.. Base 256 is for dot commands, base 512 is for dotx command (not appropriate for the Next), base 768 is dotn).&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41933</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41933"/>
		<updated>2026-05-14T11:08:35Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Basic */ Boriel&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ Boriel Basic (ZX Basic)]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World] &lt;br /&gt;
: The selection of the CRT is by startup=n number.  The crts are in the range 0-31, some mentioned in the above Hello World text, and some in the sources like [https://github.com/z88dk/z88dk/tree/master/libsrc/newlib/target/zxn/startup newlib zxn startup]. (internally: The factors of 256 are added by subtype=? on the compile line: base 0 numbers have no assumptions about the output type, i.e. for binaries that will be tap/nex/.. Base 256 is for dot commands, base 512 is for dotx command (not appropriate for the Next), base 768 is dotn).&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41932</id>
		<title>Hw im2 mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41932"/>
		<updated>2026-05-12T19:25:38Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: bit 0&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;hw im2 mode is enabled by the bit 0 of {{NextRegNo|$C0}}.&lt;br /&gt;
&lt;br /&gt;
If not in hw im2 mode, i.e. normal Spectrum behaviour, then all devices that generate an interrupt do it by asserting /int low for around 30 cycles and that&#039;s it.&lt;br /&gt;
&lt;br /&gt;
If you are in hw im2 mode, then all interrupting devices including the ULA have an im2 state machine attached.  If an interrupt is generated, the state machine remembers this as it moves to an assert /int state.  Recognition of RETI for the specific device moves the state machine to a place where another /int from the device can be accepted. &lt;br /&gt;
&lt;br /&gt;
For recognition of RETI:&lt;br /&gt;
&lt;br /&gt;
reti instruction has been detected active in T3 for rising edge of T4 &lt;br /&gt;
&lt;br /&gt;
so on rising edge of T4, the hw will move to a state where it will see a new int event from the device.  /int events are edge detected so you can&#039;t hold /int low forever and keep generating interrupts.&lt;br /&gt;
&lt;br /&gt;
That does mean, e.g., that if multiple events occur while the isr still hasn&#039;t executed RETI then you&#039;re not going to see more than the one current interrupt.  If the DMA is taking a long time, multiple CTC interrupts on a channel only generate one channel interrupt when the dma ultimately gives up the bus.  If you have the CTC interrupting DMA op, then you&#039;ll see them all most likely.&lt;br /&gt;
&lt;br /&gt;
= The background =&lt;br /&gt;
&lt;br /&gt;
Zilog defines what IM2 mode is.. the hardware is in a physically ordered daisy chain with each interrupting device using that chain to know which has highest priority.  The devices put vectors on the bus during int ack so that the z80 can jump directly to a specific device&#039;s ISR.&lt;br /&gt;
&lt;br /&gt;
Sinclair does not support that and instead the ula is a like a traditional 8080 device with one int signal going to one ISR in im1 mode.  There is no intelligence in the ula for interrupts, just a notion of asserting the int line low for about 30 cycles.&lt;br /&gt;
&lt;br /&gt;
Even when you put the z80 in im2 mode, the devices don&#039;t obey Zilog&#039;s im2 scheme.  That&#039;s why you need 257 bytes in the vector table that are all the same.  The ula does not provide a vector.&lt;br /&gt;
&lt;br /&gt;
For backwards compatibility, the Next&#039;s devices normally work in the spectrum mode where they know nothing about interrupts other than pulling into low for about 30 cycles.&lt;br /&gt;
&lt;br /&gt;
You can choose to operate in hw im2 mode where the hw switches to implementing Zilog&#039;s im2 scheme via the bit 0 in {{NextRegNo|$C0}}.  That&#039;s when you have prioritized interrupts and unique vectors/ISRs for each interrupting device.  What&#039;s new in the Next is that these interrupts can also be set to interrupt a dma operation via nextreg in the CC range (see e.g. {{NextRegNo|$CC}})  AFAIK (says AA) that&#039;s not been done anywhere else.&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41931</id>
		<title>Hw im2 mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41931"/>
		<updated>2026-05-12T19:24:20Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: nextreg CC&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;hw im2 mode is enabled by the bit 0 of {{NextRegNo|$C0}}.&lt;br /&gt;
&lt;br /&gt;
If not in hw im2 mode, i.e. normal Spectrum behaviour, then all devices that generate an interrupt do it by asserting /int low for around 30 cycles and that&#039;s it.&lt;br /&gt;
&lt;br /&gt;
If you are in hw im2 mode, then all interrupting devices including the ULA have an im2 state machine attached.  If an interrupt is generated, the state machine remembers this as it moves to an assert /int state.  Recognition of RETI for the specific device moves the state machine to a place where another /int from the device can be accepted. &lt;br /&gt;
&lt;br /&gt;
For recognition of RETI:&lt;br /&gt;
&lt;br /&gt;
reti instruction has been detected active in T3 for rising edge of T4 &lt;br /&gt;
&lt;br /&gt;
so on rising edge of T4, the hw will move to a state where it will see a new int event from the device.  /int events are edge detected so you can&#039;t hold /int low forever and keep generating interrupts.&lt;br /&gt;
&lt;br /&gt;
That does mean, e.g., that if multiple events occur while the isr still hasn&#039;t executed RETI then you&#039;re not going to see more than the one current interrupt.  If the DMA is taking a long time, multiple CTC interrupts on a channel only generate one channel interrupt when the dma ultimately gives up the bus.  If you have the CTC interrupting DMA op, then you&#039;ll see them all most likely.&lt;br /&gt;
&lt;br /&gt;
= The background =&lt;br /&gt;
&lt;br /&gt;
Zilog defines what IM2 mode is.. the hardware is in a physically ordered daisy chain with each interrupting device using that chain to know which has highest priority.  The devices put vectors on the bus during int ack so that the z80 can jump directly to a specific device&#039;s ISR.&lt;br /&gt;
&lt;br /&gt;
Sinclair does not support that and instead the ula is a like a traditional 8080 device with one int signal going to one ISR in im1 mode.  There is no intelligence in the ula for interrupts, just a notion of asserting the int line low for about 30 cycles.&lt;br /&gt;
&lt;br /&gt;
Even when you put the z80 in im2 mode, the devices don&#039;t obey Zilog&#039;s im2 scheme.  That&#039;s why you need 257 bytes in the vector table that are all the same.  The ula does not provide a vector.&lt;br /&gt;
&lt;br /&gt;
For backwards compatibility, the Next&#039;s devices normally work in the spectrum mode where they know nothing about interrupts other than pulling into low for about 30 cycles.&lt;br /&gt;
&lt;br /&gt;
You can choose to operate in hw im2 mode where the hw switches to implementing Zilog&#039;s im2 scheme via the bit in nextreg 0xc0.  That&#039;s when you have prioritized interrupts and unique vectors/ISRs for each interrupting device.  What&#039;s new in the Next is that these interrupts can also be set to interrupt a dma operation via nextreg in the CC range (see e.g. {{NextRegNo|$CC}})  AFAIK (says AA) that&#039;s not been done anywhere else.&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41930</id>
		<title>Hw im2 mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41930"/>
		<updated>2026-05-12T19:22:23Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: The background&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;hw im2 mode is enabled by the bit 0 of {{NextRegNo|$C0}}.&lt;br /&gt;
&lt;br /&gt;
If not in hw im2 mode, i.e. normal Spectrum behaviour, then all devices that generate an interrupt do it by asserting /int low for around 30 cycles and that&#039;s it.&lt;br /&gt;
&lt;br /&gt;
If you are in hw im2 mode, then all interrupting devices including the ULA have an im2 state machine attached.  If an interrupt is generated, the state machine remembers this as it moves to an assert /int state.  Recognition of RETI for the specific device moves the state machine to a place where another /int from the device can be accepted. &lt;br /&gt;
&lt;br /&gt;
For recognition of RETI:&lt;br /&gt;
&lt;br /&gt;
reti instruction has been detected active in T3 for rising edge of T4 &lt;br /&gt;
&lt;br /&gt;
so on rising edge of T4, the hw will move to a state where it will see a new int event from the device.  /int events are edge detected so you can&#039;t hold /int low forever and keep generating interrupts.&lt;br /&gt;
&lt;br /&gt;
That does mean, e.g., that if multiple events occur while the isr still hasn&#039;t executed RETI then you&#039;re not going to see more than the one current interrupt.  If the DMA is taking a long time, multiple CTC interrupts on a channel only generate one channel interrupt when the dma ultimately gives up the bus.  If you have the CTC interrupting DMA op, then you&#039;ll see them all most likely.&lt;br /&gt;
&lt;br /&gt;
= The background =&lt;br /&gt;
&lt;br /&gt;
Zilog defines what IM2 mode is.. the hardware is in a physically ordered daisy chain with each interrupting device using that chain to know which has highest priority.  The devices put vectors on the bus during int ack so that the z80 can jump directly to a specific device&#039;s ISR.&lt;br /&gt;
&lt;br /&gt;
Sinclair does not support that and instead the ula is a like a traditional 8080 device with one int signal going to one ISR in im1 mode.  There is no intelligence in the ula for interrupts, just a notion of asserting the int line low for about 30 cycles.&lt;br /&gt;
&lt;br /&gt;
Even when you put the z80 in im2 mode, the devices don&#039;t obey Zilog&#039;s im2 scheme.  That&#039;s why you need 257 bytes in the vector table that are all the same.  The ula does not provide a vector.&lt;br /&gt;
&lt;br /&gt;
For backwards compatibility, the Next&#039;s devices normally work in the spectrum mode where they know nothing about interrupts other than pulling into low for about 30 cycles.&lt;br /&gt;
&lt;br /&gt;
You can choose to operate in hw im2 mode where the hw switches to implementing Zilog&#039;s im2 scheme via the bit in nextreg 0xc0.  That&#039;s when you have prioritized interrupts and unique vectors/ISRs for each interrupting device.  What&#039;s new in the Next is that these interrupts can also be set to interrupt a dma operation via nextreg in the CC range.  AFAIK (says AA) that&#039;s not been done anywhere else.&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41929</id>
		<title>Hw im2 mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41929"/>
		<updated>2026-05-12T18:28:20Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: wording&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;hw im2 mode is enabled by the bit 0 of {{NextRegNo|$C0}}.&lt;br /&gt;
&lt;br /&gt;
If not in hw im2 mode, i.e. normal Spectrum behaviour, then all devices that generate an interrupt do it by asserting /int low for around 30 cycles and that&#039;s it.&lt;br /&gt;
&lt;br /&gt;
If you are in hw im2 mode, then all interrupting devices including the ULA have an im2 state machine attached.  If an interrupt is generated, the state machine remembers this as it moves to an assert /int state.  Recognition of RETI for the specific device moves the state machine to a place where another /int from the device can be accepted. &lt;br /&gt;
&lt;br /&gt;
For recognition of RETI:&lt;br /&gt;
&lt;br /&gt;
reti instruction has been detected active in T3 for rising edge of T4 &lt;br /&gt;
&lt;br /&gt;
so on rising edge of T4, the hw will move to a state where it will see a new int event from the device.  /int events are edge detected so you can&#039;t hold /int low forever and keep generating interrupts.&lt;br /&gt;
&lt;br /&gt;
That does mean, e.g., that if multiple events occur while the isr still hasn&#039;t executed RETI then you&#039;re not going to see more than the one current interrupt.  If the DMA is taking a long time, multiple CTC interrupts on a channel only generate one channel interrupt when the dma ultimately gives up the bus.  If you have the CTC interrupting DMA op, then you&#039;ll see them all most likely.&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41926</id>
		<title>Layer 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41926"/>
		<updated>2026-05-07T15:46:33Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: half a byte&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Layer 2 provides an additional screen layer at 256x192 256 colours, 320x256 256 colours or 640x256 16 colours in which every pixel is individually coloured. Layer 2 may appear in place of, behind, or above the ULA-generated/Tilemap layer.&lt;br /&gt;
&lt;br /&gt;
The palette used to show the Layer 2 is selected by the bit 2 of the {{NextRegNo|$43}}.&lt;br /&gt;
&lt;br /&gt;
The Layer 2 screen occupies 48kiB or 80kiB, which is stored in 3 (or 5) consecutive [[Memory map|banks]]. By NextZXOS/NextBASIC default, banks 9-11 are used for the visible and &amp;quot;shadow&amp;quot; Layer 2 screen (the HW after power-on defaults to 8-10 for displayed and 11-13 for shadow screen, but that gets modified by NextZXOS booting up). These can be set using {{NextRegNo|$12}} and {{NextRegNo|$13}} (avoid banks 5, 7 and 8 to be used as Layer 2 screen, unless you are familiar with SRAM and BRAM of the board and how the ULA screen memory has special treatment in Next&#039;s FPGA).&lt;br /&gt;
&lt;br /&gt;
Each pixel of Layer 2 takes one byte of video memory in 8bpp modes or half a byte in 4bpp mode, so the Layer 2 needs 48kiB for 256x192 mode or 80kiB for 320x256-8bit or 640x256-4bit mode. The Layer 2 256x192 mode is divided &#039;&#039;&#039;horizontally&#039;&#039;&#039; into 3 16kiB banks of 64 &#039;&#039;&#039;lines&#039;&#039;&#039; each. The modes 320x256 and 640x256 are divided &#039;&#039;&#039;vertically&#039;&#039;&#039; into 5 16kiB  banks of 64 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 320x256 mode or 128 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 640x256 mode.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is controlled via {{PortNo|$123B}} and {{NextRegNo|$70}}, the port is bit mapped as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bit !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 7-6 || Video RAM bank select (write/read paging)&lt;br /&gt;
|-&lt;br /&gt;
| 5-4 || Reserved, write 0&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Use Shadow Layer 2 for paging - {{NextRegNo|$13}}&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Enable Layer 2 read-only paging&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Layer 2 visible - {{NextRegNo|$12}}&lt;br /&gt;
Since core 3.0 this bit has mirror in {{NextRegNo|$69}}&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Enable Layer 2 write-only paging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When bit 0 of $123B is set to 1, the appropriate area of Layer 2 video memory (as set by bits 6-7) is accessed by &#039;&#039;&#039;writes&#039;&#039;&#039; into slot 1, ie memory area $0000-$3fff (see [[Memory map]]). This prevents any conflict since this area would normally be ROM and thus useless to write to. However, you &#039;&#039;&#039;cannot READ the contents of Layer 2 via this mapping!&#039;&#039;&#039; Reading addresses in this range will read the values from the ROM page (or RAM bank if in AllRam mode) that would be mapped there normally if Layer 2 paging was disabled.&lt;br /&gt;
&lt;br /&gt;
When bit 2 of $123B is set to 1 (new feature of core 3.0), the same area $0000-$3fff is remapped for read, allowing read access into Layer 2 bank selected by bits 3,6 and 7 (while write will still go into the regular ROM/RAM page).&lt;br /&gt;
&lt;br /&gt;
With both bits 0 and 2 set you are creating alternative read+write mapping of RAM (technically identical to mapping done by MM0+MMU1 registers).&lt;br /&gt;
&lt;br /&gt;
Bank 5 and first half of Bank 7, when being accessed by regular means (MMU paging, default memory mapping, DMA), are overshadowed by fast BRAM memory inside the FPGA chip, which is then used to generate ULA screen and [[Tilemap]] graphics (aka &amp;quot;Layer 3&amp;quot;) - not using the SRAM memory chip in that particular area. This Layer 2 (mapping and visible data) is the only exception, circumventing this mechanism and accessing the Bank 5 and Bank 7 in the main memory SRAM chip (giving you extra 16+8kiB of &amp;quot;secret&amp;quot; memory and further headache to emulators&#039; authors). If you are not sure what this means, just avoid using bank 5 and 7 for Layer 2, use values greater/equal to 8 (and avoid also Bank 8, unless you want to destroy NextBASIC warm-restart/soft-reset variables).&lt;br /&gt;
&lt;br /&gt;
Bits 6 and 7 contain the number which third of Layer 2 should be mapped (0..2), or (new feature of core 3.0) when value 3 is set, whole 48kiB of Layer 2 is mapped into area $0000-$bfff (make sure your code, stack and interrupts will cope well with such new mapping).&lt;br /&gt;
&lt;br /&gt;
There is one more new functionality in latest 3.x cores, allowing to set bank-offset variable from 0 to 7. This offset is further applied to the bank selected for write/read (by writing value 0..7 to the port with bit4 set (so it&#039;s value 16..23). If you did set for example 16kiB write mapping of first bank, the first bank is 9, and use value 21 for bank-offset setup (+5 offset), the bank mapped into $0000..$3FFF address area will be 14 (9+5). This way you can map full 80kiB of pixel data into the bottom 16kiB window (or bottom 48kiB window), using different offsets.&lt;br /&gt;
&lt;br /&gt;
Use {{NextRegNo|$70}} to select particular Layer2 mode, and to modify palette offset (added to top four bits of each pixel). Don&#039;t forget to set up Layer 2 clip window correctly for each mode ({{NextRegNo|$18}}).&lt;br /&gt;
&lt;br /&gt;
You can still use also the regular [[Memory map|banking]] ports to switch in one of the Layer 2 banks in slot for at $C000 (or use the ZX Next MMU registers to map that RAM in other regions). This will allow you to read and write the memory as usual. The ability to write to Layer 2 via writes into slot 1 is provided for convenience and to allow graphics data to be easily copied from extended RAM banks.&lt;br /&gt;
&lt;br /&gt;
Pixels are drawn to Layer 2 by writing to the appropriate area of RAM. Layer 2 pixels in 256x192 mode are in English reading order with no ULA-style interlacing. Since there are 256 pixels per line, and when using access via slot 1 the memory port starts at $0000, the upper byte of the address exactly equals the Y coordinate (within the selected third of the screen) and the lower byte exactly equals the X coordinate.&lt;br /&gt;
&lt;br /&gt;
In mode 320x256 (8bpp) the pixels are stored in memory going from top to bottom and left to right (second byte is first pixel on second line, 256th byte is second pixel on first line). Since there are 256 pixels per column, the upper byte of address could represent the X coordinate (only specific range of them, as whole 0..319 range does not fit into 8 bits), and the lower byte of address is Y coordinate. The total pixel memory is 80kiB (five 16kiB banks), and could be mapped into memory either by MMU or by bank-offset feature of {{PortNo|$123B}}.&lt;br /&gt;
&lt;br /&gt;
In mode 640x256 (4bpp) the pixels are stored identically to 320x256 mode, but every byte contains two pixels. The top nibble (top four bits) form &amp;quot;left&amp;quot; pixel, and the bottom nibble form &amp;quot;right&amp;quot; pixel, so first 256 bytes will display as two columns on screen, not one.&lt;br /&gt;
&lt;br /&gt;
Note that you will need to manually clear the Layer 2 screen before drawing on it, as it may contain random data when the machine starts up.&lt;br /&gt;
&lt;br /&gt;
System registers {{NextRegNo|$16}}, {{NextRegNo|$71}} and {{NextRegNo|$17}} apply a pixel shift to all content in Layer &lt;br /&gt;
2, allowing scrolling effects to be created.&lt;br /&gt;
&lt;br /&gt;
Since core 3.0 the visibility of Layer 2 is not affected by usage of ZX128 ULA-shadow (Bank 7) screen.&lt;br /&gt;
&lt;br /&gt;
Obsolete info for core 2.x (limitation was lifted in core 3.0): &amp;lt;del&amp;gt;the visible Layer 2 will cause the slow down of CPU to 7MHz.&amp;lt;/del&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use double-buffered scheme for Layer 2, think about {{NextRegNo|$12}} being display related (i.e. has to be changed to display new Layer 2, when the new image is already prepared) (or it may be modified also during frame to compose final image from various memory areas), while {{NextRegNo|$13}} is related only to write-over-ROM paging functionality ({{PortNo|$123B}}).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41925</id>
		<title>Layer 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41925"/>
		<updated>2026-05-06T13:38:24Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: rewording&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Layer 2 provides an additional screen layer at 256x192 256 colours, 320x256 256 colours or 640x256 16 colours in which every pixel is individually coloured. Layer 2 may appear in place of, behind, or above the ULA-generated/Tilemap layer.&lt;br /&gt;
&lt;br /&gt;
The palette used to show the Layer 2 is selected by the bit 2 of the {{NextRegNo|$43}}.&lt;br /&gt;
&lt;br /&gt;
The Layer 2 screen occupies 48kiB or 80kiB, which is stored in 3 (or 5) consecutive [[Memory map|banks]]. By NextZXOS/NextBASIC default, banks 9-11 are used for the visible and &amp;quot;shadow&amp;quot; Layer 2 screen (the HW after power-on defaults to 8-10 for displayed and 11-13 for shadow screen, but that gets modified by NextZXOS booting up). These can be set using {{NextRegNo|$12}} and {{NextRegNo|$13}} (avoid banks 5, 7 and 8 to be used as Layer 2 screen, unless you are familiar with SRAM and BRAM of the board and how the ULA screen memory has special treatment in Next&#039;s FPGA).&lt;br /&gt;
&lt;br /&gt;
Each pixel of Layer 2 takes one byte of video memory in 8bpp modes or a half byte in 4bpp mode, so the Layer 2 needs 48kiB for 256x192 mode or 80kiB for 320x256-8bit or 640x256-4bit mode. The Layer 2 256x192 mode is divided &#039;&#039;&#039;horizontally&#039;&#039;&#039; into 3 16kiB banks of 64 &#039;&#039;&#039;lines&#039;&#039;&#039; each. The modes 320x256 and 640x256 are divided &#039;&#039;&#039;vertically&#039;&#039;&#039; into 5 16kiB  banks of 64 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 320x256 mode or 128 &#039;&#039;&#039;columns&#039;&#039;&#039; each for 640x256 mode.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is controlled via {{PortNo|$123B}} and {{NextRegNo|$70}}, the port is bit mapped as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bit !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 7-6 || Video RAM bank select (write/read paging)&lt;br /&gt;
|-&lt;br /&gt;
| 5-4 || Reserved, write 0&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Use Shadow Layer 2 for paging - {{NextRegNo|$13}}&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Enable Layer 2 read-only paging&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Layer 2 visible - {{NextRegNo|$12}}&lt;br /&gt;
Since core 3.0 this bit has mirror in {{NextRegNo|$69}}&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Enable Layer 2 write-only paging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When bit 0 of $123B is set to 1, the appropriate area of Layer 2 video memory (as set by bits 6-7) is accessed by &#039;&#039;&#039;writes&#039;&#039;&#039; into slot 1, ie memory area $0000-$3fff (see [[Memory map]]). This prevents any conflict since this area would normally be ROM and thus useless to write to. However, you &#039;&#039;&#039;cannot READ the contents of Layer 2 via this mapping!&#039;&#039;&#039; Reading addresses in this range will read the values from the ROM page (or RAM bank if in AllRam mode) that would be mapped there normally if Layer 2 paging was disabled.&lt;br /&gt;
&lt;br /&gt;
When bit 2 of $123B is set to 1 (new feature of core 3.0), the same area $0000-$3fff is remapped for read, allowing read access into Layer 2 bank selected by bits 3,6 and 7 (while write will still go into the regular ROM/RAM page).&lt;br /&gt;
&lt;br /&gt;
With both bits 0 and 2 set you are creating alternative read+write mapping of RAM (technically identical to mapping done by MM0+MMU1 registers).&lt;br /&gt;
&lt;br /&gt;
Bank 5 and first half of Bank 7, when being accessed by regular means (MMU paging, default memory mapping, DMA), are overshadowed by fast BRAM memory inside the FPGA chip, which is then used to generate ULA screen and [[Tilemap]] graphics (aka &amp;quot;Layer 3&amp;quot;) - not using the SRAM memory chip in that particular area. This Layer 2 (mapping and visible data) is the only exception, circumventing this mechanism and accessing the Bank 5 and Bank 7 in the main memory SRAM chip (giving you extra 16+8kiB of &amp;quot;secret&amp;quot; memory and further headache to emulators&#039; authors). If you are not sure what this means, just avoid using bank 5 and 7 for Layer 2, use values greater/equal to 8 (and avoid also Bank 8, unless you want to destroy NextBASIC warm-restart/soft-reset variables).&lt;br /&gt;
&lt;br /&gt;
Bits 6 and 7 contain the number which third of Layer 2 should be mapped (0..2), or (new feature of core 3.0) when value 3 is set, whole 48kiB of Layer 2 is mapped into area $0000-$bfff (make sure your code, stack and interrupts will cope well with such new mapping).&lt;br /&gt;
&lt;br /&gt;
There is one more new functionality in latest 3.x cores, allowing to set bank-offset variable from 0 to 7. This offset is further applied to the bank selected for write/read (by writing value 0..7 to the port with bit4 set (so it&#039;s value 16..23). If you did set for example 16kiB write mapping of first bank, the first bank is 9, and use value 21 for bank-offset setup (+5 offset), the bank mapped into $0000..$3FFF address area will be 14 (9+5). This way you can map full 80kiB of pixel data into the bottom 16kiB window (or bottom 48kiB window), using different offsets.&lt;br /&gt;
&lt;br /&gt;
Use {{NextRegNo|$70}} to select particular Layer2 mode, and to modify palette offset (added to top four bits of each pixel). Don&#039;t forget to set up Layer 2 clip window correctly for each mode ({{NextRegNo|$18}}).&lt;br /&gt;
&lt;br /&gt;
You can still use also the regular [[Memory map|banking]] ports to switch in one of the Layer 2 banks in slot for at $C000 (or use the ZX Next MMU registers to map that RAM in other regions). This will allow you to read and write the memory as usual. The ability to write to Layer 2 via writes into slot 1 is provided for convenience and to allow graphics data to be easily copied from extended RAM banks.&lt;br /&gt;
&lt;br /&gt;
Pixels are drawn to Layer 2 by writing to the appropriate area of RAM. Layer 2 pixels in 256x192 mode are in English reading order with no ULA-style interlacing. Since there are 256 pixels per line, and when using access via slot 1 the memory port starts at $0000, the upper byte of the address exactly equals the Y coordinate (within the selected third of the screen) and the lower byte exactly equals the X coordinate.&lt;br /&gt;
&lt;br /&gt;
In mode 320x256 (8bpp) the pixels are stored in memory going from top to bottom and left to right (second byte is first pixel on second line, 256th byte is second pixel on first line). Since there are 256 pixels per column, the upper byte of address could represent the X coordinate (only specific range of them, as whole 0..319 range does not fit into 8 bits), and the lower byte of address is Y coordinate. The total pixel memory is 80kiB (five 16kiB banks), and could be mapped into memory either by MMU or by bank-offset feature of {{PortNo|$123B}}.&lt;br /&gt;
&lt;br /&gt;
In mode 640x256 (4bpp) the pixels are stored identically to 320x256 mode, but every byte contains two pixels. The top nibble (top four bits) form &amp;quot;left&amp;quot; pixel, and the bottom nibble form &amp;quot;right&amp;quot; pixel, so first 256 bytes will display as two columns on screen, not one.&lt;br /&gt;
&lt;br /&gt;
Note that you will need to manually clear the Layer 2 screen before drawing on it, as it may contain random data when the machine starts up.&lt;br /&gt;
&lt;br /&gt;
System registers {{NextRegNo|$16}}, {{NextRegNo|$71}} and {{NextRegNo|$17}} apply a pixel shift to all content in Layer &lt;br /&gt;
2, allowing scrolling effects to be created.&lt;br /&gt;
&lt;br /&gt;
Since core 3.0 the visibility of Layer 2 is not affected by usage of ZX128 ULA-shadow (Bank 7) screen.&lt;br /&gt;
&lt;br /&gt;
Obsolete info for core 2.x (limitation was lifted in core 3.0): &amp;lt;del&amp;gt;the visible Layer 2 will cause the slow down of CPU to 7MHz.&amp;lt;/del&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use double-buffered scheme for Layer 2, think about {{NextRegNo|$12}} being display related (i.e. has to be changed to display new Layer 2, when the new image is already prepared) (or it may be modified also during frame to compose final image from various memory areas), while {{NextRegNo|$13}} is related only to write-over-ROM paging functionality ({{PortNo|$123B}}).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Assemblers&amp;diff=41918</id>
		<title>Assemblers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Assemblers&amp;diff=41918"/>
		<updated>2026-05-05T08:03:44Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* Native tools (running on Next) */ specasm&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Any Z80 assembler can produce code suitable for the Next. However the raw blocks of Z80 code may be not as convenient to use with Next or emulators, so a Next specific tools may be useful for creating one of the supported [[File Formats]].&lt;br /&gt;
&lt;br /&gt;
== Cross-platform tools (running on PC) ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[http://www.desdes.com/products/oldfiles/zeus.htm Zeus-ish]&#039;&#039; ===&lt;br /&gt;
: Provides a complete Z80 IDE and Macro assembler, scripted disassember plus an integrated Z80 emulator for a range of machines including partial Next support&lt;br /&gt;
: Supports the Next opcodes directly&lt;br /&gt;
: Supports remote debugging on the Next using ParaSys across a serial link&lt;br /&gt;
: Supports MMU paging in the integrated emulator&lt;br /&gt;
: Supports sprites (core versions prior to 2.00.26) in the integrated emulator&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[http://pasmo.speccy.org/ Pasmo]&#039;&#039; ===&lt;br /&gt;
: A long established Z80 assembler, but has been mostly out of development for a long time (0.5.4-beta2 released in 2008, 0.5.5 in 2022)&lt;br /&gt;
: Supports all currently known Next extension opcodes in the 0.5.4-beta2-based 2018 version of [https://github.com/spec-chum/pasmo Pasmo modified by Russ McNulty and Tony Thompson] (also producing .sna files which were at that time used by CSpect).&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SNasm&#039;&#039; ===&lt;br /&gt;
: Included with the [https://mdf200.itch.io/cspect #CSpect] emulator&lt;br /&gt;
: Full macro assembler&lt;br /&gt;
: Full bank control via Segment management&lt;br /&gt;
: Supports the Next extension opcodes directly&lt;br /&gt;
: Generates full 24bit map files for use in CSpect&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z80asm&#039;&#039; ===&lt;br /&gt;
: Part of [https://github.com/z88dk/z88dk Z88dk]&#039;&#039;&lt;br /&gt;
: Supports the Next extension opcodes directly, linking assembler with large z80 library, targets any memory configuration&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/z00m128/sjasmplus z00m&#039;s fork of sjasmplus]&#039;&#039; ===&lt;br /&gt;
: Supports all (core2.00.28) Next extension opcodes, ZXN memory model (8 memory slots with 8ki pages and 1.75MiB virtual device memory), SAVENEX to build NEX files directly from ASM source (NEX version V1.2 (and experimental extension &amp;quot;V1.3&amp;quot;)), MAP files for [https://mdf200.itch.io/cspect #CSpect] emulator, SLD tracing files for [https://github.com/maziac/DeZog DeZog] and [https://github.com/Ckirby101/NDS-NextDevSystem NDS-NextDevSystem] and it is under active development (feedback is welcome).&lt;br /&gt;
: Open source project (&amp;quot;BSD-3-Clause&amp;quot; license), &#039;&#039;&#039;windows executables available at [https://github.com/z00m128/sjasmplus/releases/latest releases]&#039;&#039;&#039;, mac and linux users are expected to simply build from source (both make and CMake are supported).&lt;br /&gt;
: [http://z00m128.github.io/sjasmplus/documentation.html Documentation], latest stable release v1.23.0 2026-04-23&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;zmac&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [http://48k.ca/zmac.html zmac - Z-80 Macro Cross Assembler]&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/CatpainBlack/FantASM FantASM]&#039;&#039; ===&lt;br /&gt;
: FantASM is a two pass non optimising assembler for the Z80 processor by [https://github.com/CatpainBlack Guy &#039;CatpainBlack&#039; Black].&lt;br /&gt;
&lt;br /&gt;
:It supports all undocumented op-codes and the extended instruction set of the ZX Next and additional pseudo opcodes used by the CSpect emulator to control debugging.&lt;br /&gt;
&lt;br /&gt;
== Native tools (running on Next) ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://gitlab.com/next-tools/odin Odin]&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
Work-in-progress Next-specific assembler written by Matt Davies, used also in video tutorials presented by Jim Bagley, the best way to acquire the binary is to join the official ZX Next discord server and check channel &amp;lt;code&amp;gt;#odin&amp;lt;/code&amp;gt; - pinned messages, where you can also discuss any issues and get how-to hints.&lt;br /&gt;
&lt;br /&gt;
: supports most of the undocumented opcodes, all official Z80 and Next-extended instructions&lt;br /&gt;
: supports nested includes and binary includes&lt;br /&gt;
: source is stored in tokenised form (smaller file), up to 48kiB of source in single file&lt;br /&gt;
: assembling can produce 32kiB of machine code (enough to produce simpler dot command)&lt;br /&gt;
: includes also editor and console modules (debugger is planned)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://www.solarisite.com/spectrumnext.html Sol]&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
Sol is an assembler and editor written by Solaris, that runs natively on the Next. Manual, assembler binary and assembler source can be downloaded [https://www.solarisite.com/spectrumnext.html here].&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://gitlab.com/thesmog358/tbblue/-/tree/master/tools/dev/Zeus ZEUS]&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
Classic ZEUS native assembler by Simon Brattel, extended and included directly in the ZX Next distro.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://gitlab.com/thesmog358/tbblue/-/tree/master/tools/dev/SPED SPED]&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
Classic SPED assembler by César Hernández Bañó, included directly in the ZX Next distro, see [https://gitlab.com/thesmog358/tbblue/-/raw/master/docs/apps/dev/SPED53readme.txt README].&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/markdryan/specasm specasm]&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
Mark Ryan&#039;s specasm assembler suite which includes an editor, an assembler, a linker and a tap file generator.&lt;br /&gt;
.specasm command launches an integrated editor/assembler.&lt;br /&gt;
Supports all the Z80n instructions.  All mnemonics are entered in lower case. The edited files are .x files, which are annotated object files, with the instructions pre-assembled.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/nextbasic-inline-assembler NextBASIC Inline Assembler]&#039;&#039;===&lt;br /&gt;
Enables you to write inline assembly code in your NextBASIC application. The assembler can be downloaded from [https://taylorza.itch.io/nextbasic-inline-assembler HERE] with documentation available [https://github.com/taylorza/zxn-inlineasm-doc/blob/main/README.md HERE]&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41917</id>
		<title>Layer 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=41917"/>
		<updated>2026-05-04T13:40:39Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: palette detail&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Layer 2 provides an additional screen layer at 256x192 256 colours, 320x256 256 colours or 640x256 16 colours in which every pixel is individually coloured. Layer 2 may appear in place of, behind, or above the ULA-generated/Tilemap layer.&lt;br /&gt;
&lt;br /&gt;
The palette used to show the Layer 2 is selected by the bit 2 of the {{NextRegNo|$43}}.&lt;br /&gt;
&lt;br /&gt;
The Layer 2 screen occupies 48kiB or 80kiB, which is stored in 3 (or 5) consecutive [[Memory map|banks]]. By NextZXOS/NextBASIC default, banks 9-11 are used for the visible and &amp;quot;shadow&amp;quot; Layer 2 screen (the HW after power-on defaults to 8-10 for displayed and 11-13 for shadow screen, but that gets modified by NextZXOS booting up). These can be set using {{NextRegNo|$12}} and {{NextRegNo|$13}} (avoid banks 5, 7 and 8 to be used as Layer 2 screen, unless you are familiar with SRAM and BRAM of the board and how the ULA screen memory has special treatment in Next&#039;s FPGA).&lt;br /&gt;
&lt;br /&gt;
Each pixel of Layer 2 is assigned 1 byte of video memory (in 8bpp modes). This means Layer 2 consumes a total of 48kiB (256x192) or 80kiB (320x256). Since the Spectrum banks are 16kiB, Layer 2 256x192 mode is divided horizontally into 3 banks of 64 lines each, each of which is exactly 16kiB. The mode 320x256 (and 640x256) is divided vertically into 5 banks of 64 (128) columns each.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is controlled via {{PortNo|$123B}} and {{NextRegNo|$70}}, the port is bit mapped as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bit !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 7-6 || Video RAM bank select (write/read paging)&lt;br /&gt;
|-&lt;br /&gt;
| 5-4 || Reserved, write 0&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Use Shadow Layer 2 for paging - {{NextRegNo|$13}}&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Enable Layer 2 read-only paging&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Layer 2 visible - {{NextRegNo|$12}}&lt;br /&gt;
Since core 3.0 this bit has mirror in {{NextRegNo|$69}}&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Enable Layer 2 write-only paging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When bit 0 of $123B is set to 1, the appropriate area of Layer 2 video memory (as set by bits 6-7) is accessed by &#039;&#039;&#039;writes&#039;&#039;&#039; into slot 1, ie memory area $0000-$3fff (see [[Memory map]]). This prevents any conflict since this area would normally be ROM and thus useless to write to. However, you &#039;&#039;&#039;cannot READ the contents of Layer 2 via this mapping!&#039;&#039;&#039; Reading addresses in this range will read the values from the ROM page (or RAM bank if in AllRam mode) that would be mapped there normally if Layer 2 paging was disabled.&lt;br /&gt;
&lt;br /&gt;
When bit 2 of $123B is set to 1 (new feature of core 3.0), the same area $0000-$3fff is remapped for read, allowing read access into Layer 2 bank selected by bits 3,6 and 7 (while write will still go into the regular ROM/RAM page).&lt;br /&gt;
&lt;br /&gt;
With both bits 0 and 2 set you are creating alternative read+write mapping of RAM (technically identical to mapping done by MM0+MMU1 registers).&lt;br /&gt;
&lt;br /&gt;
Bank 5 and first half of Bank 7, when being accessed by regular means (MMU paging, default memory mapping, DMA), are overshadowed by fast BRAM memory inside the FPGA chip, which is then used to generate ULA screen and [[Tilemap]] graphics (aka &amp;quot;Layer 3&amp;quot;) - not using the SRAM memory chip in that particular area. This Layer 2 (mapping and visible data) is the only exception, circumventing this mechanism and accessing the Bank 5 and Bank 7 in the main memory SRAM chip (giving you extra 16+8kiB of &amp;quot;secret&amp;quot; memory and further headache to emulators&#039; authors). If you are not sure what this means, just avoid using bank 5 and 7 for Layer 2, use values greater/equal to 8 (and avoid also Bank 8, unless you want to destroy NextBASIC warm-restart/soft-reset variables).&lt;br /&gt;
&lt;br /&gt;
Bits 6 and 7 contain the number which third of Layer 2 should be mapped (0..2), or (new feature of core 3.0) when value 3 is set, whole 48kiB of Layer 2 is mapped into area $0000-$bfff (make sure your code, stack and interrupts will cope well with such new mapping).&lt;br /&gt;
&lt;br /&gt;
There is one more new functionality in latest 3.x cores, allowing to set bank-offset variable from 0 to 7. This offset is further applied to the bank selected for write/read (by writing value 0..7 to the port with bit4 set (so it&#039;s value 16..23). If you did set for example 16kiB write mapping of first bank, the first bank is 9, and use value 21 for bank-offset setup (+5 offset), the bank mapped into $0000..$3FFF address area will be 14 (9+5). This way you can map full 80kiB of pixel data into the bottom 16kiB window (or bottom 48kiB window), using different offsets.&lt;br /&gt;
&lt;br /&gt;
Use {{NextRegNo|$70}} to select particular Layer2 mode, and to modify palette offset (added to top four bits of each pixel). Don&#039;t forget to set up Layer 2 clip window correctly for each mode ({{NextRegNo|$18}}).&lt;br /&gt;
&lt;br /&gt;
You can still use also the regular [[Memory map|banking]] ports to switch in one of the Layer 2 banks in slot for at $C000 (or use the ZX Next MMU registers to map that RAM in other regions). This will allow you to read and write the memory as usual. The ability to write to Layer 2 via writes into slot 1 is provided for convenience and to allow graphics data to be easily copied from extended RAM banks.&lt;br /&gt;
&lt;br /&gt;
Pixels are drawn to Layer 2 by writing to the appropriate area of RAM. Layer 2 pixels in 256x192 mode are in English reading order with no ULA-style interlacing. Since there are 256 pixels per line, and when using access via slot 1 the memory port starts at $0000, the upper byte of the address exactly equals the Y coordinate (within the selected third of the screen) and the lower byte exactly equals the X coordinate.&lt;br /&gt;
&lt;br /&gt;
In mode 320x256 (8bpp) the pixels are stored in memory going from top to bottom and left to right (second byte is first pixel on second line, 256th byte is second pixel on first line). Since there are 256 pixels per column, the upper byte of address could represent the X coordinate (only specific range of them, as whole 0..319 range does not fit into 8 bits), and the lower byte of address is Y coordinate. The total pixel memory is 80kiB (five 16kiB banks), and could be mapped into memory either by MMU or by bank-offset feature of {{PortNo|$123B}}.&lt;br /&gt;
&lt;br /&gt;
In mode 640x256 (4bpp) the pixels are stored identically to 320x256 mode, but every byte contains two pixels. The top nibble (top four bits) form &amp;quot;left&amp;quot; pixel, and the bottom nibble form &amp;quot;right&amp;quot; pixel, so first 256 bytes will display as two columns on screen, not one.&lt;br /&gt;
&lt;br /&gt;
Note that you will need to manually clear the Layer 2 screen before drawing on it, as it may contain random data when the machine starts up.&lt;br /&gt;
&lt;br /&gt;
System registers {{NextRegNo|$16}}, {{NextRegNo|$71}} and {{NextRegNo|$17}} apply a pixel shift to all content in Layer &lt;br /&gt;
2, allowing scrolling effects to be created.&lt;br /&gt;
&lt;br /&gt;
Since core 3.0 the visibility of Layer 2 is not affected by usage of ZX128 ULA-shadow (Bank 7) screen.&lt;br /&gt;
&lt;br /&gt;
Obsolete info for core 2.x (limitation was lifted in core 3.0): &amp;lt;del&amp;gt;the visible Layer 2 will cause the slow down of CPU to 7MHz.&amp;lt;/del&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use double-buffered scheme for Layer 2, think about {{NextRegNo|$12}} being display related (i.e. has to be changed to display new Layer 2, when the new image is already prepared) (or it may be modified also during frame to compose final image from various memory areas), while {{NextRegNo|$13}} is related only to write-over-ROM paging functionality ({{PortNo|$123B}}).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=ZENext:Installing&amp;diff=41916</id>
		<title>ZENext:Installing</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=ZENext:Installing&amp;diff=41916"/>
		<updated>2026-05-02T16:15:16Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* Run */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Installation =&lt;br /&gt;
&lt;br /&gt;
The simplest procedure is building it for Linux:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install libsdl1.2-dev xorg-dev&lt;br /&gt;
./configure&lt;br /&gt;
make clean&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As of March 2026: it&#039;s possible to build it for other platforms, even a cross build on Linux for Windows 64, but additional work is then needed, among others, a modification of the configure script and a few source files and a suitable building of the SDL 1.&lt;br /&gt;
&lt;br /&gt;
= Run =&lt;br /&gt;
&lt;br /&gt;
To run, the following command line worked with the SD image containing NextZXOS 2.09.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./zesarux  --noconfigfile --nosplash --quickexit --def-f-function f4 reset \&lt;br /&gt;
     --disablerealjoystick --no-native-linux-realjoy \&lt;br /&gt;
    --joystickemulated kempston \&lt;br /&gt;
    --frameskip 1 \&lt;br /&gt;
    --zoom 1 \&lt;br /&gt;
    --enable-divmmc-ports --enable-mmc \&lt;br /&gt;
    --mmc-file FULL_PATH_TO_SD_IMAGE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Read how to download or create the SD card image on the: [[MAME:Installing#Creating_and_manipulating_NextZXOS_SD_card_image]] page&lt;br /&gt;
&lt;br /&gt;
Notes: The upstream zesarux can&#039;t use big images because it loads them into RAM - but zenext doesn&#039;t do/suffer that. zenext does non-exclusive file locking, so you can mount from OS and emulator at same time (also note: using such mounting increases chances for accidental corruption of the image or inconsistent views).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=ZENext:Installing&amp;diff=41915</id>
		<title>ZENext:Installing</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=ZENext:Installing&amp;diff=41915"/>
		<updated>2026-05-02T16:15:04Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* Run */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Installation =&lt;br /&gt;
&lt;br /&gt;
The simplest procedure is building it for Linux:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt install libsdl1.2-dev xorg-dev&lt;br /&gt;
./configure&lt;br /&gt;
make clean&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As of March 2026: it&#039;s possible to build it for other platforms, even a cross build on Linux for Windows 64, but additional work is then needed, among others, a modification of the configure script and a few source files and a suitable building of the SDL 1.&lt;br /&gt;
&lt;br /&gt;
= Run =&lt;br /&gt;
&lt;br /&gt;
To run, the following command line worked with the SD image containing NextZXOS 2.09.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./zesarux  --noconfigfile --nosplash --quickexit --def-f-function f4 reset \&lt;br /&gt;
     --disablerealjoystick --no-native-linux-realjoy \&lt;br /&gt;
    --joystickemulated kempston \&lt;br /&gt;
    --frameskip 1 \&lt;br /&gt;
    --zoom 1 \&lt;br /&gt;
    --enable-divmmc-ports --enable-mmc \&lt;br /&gt;
    --mmc-file FULL_PATH_TO_SD_IMAGE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Read how to download or create the SD card image on the: [[MAME:Installing#Creating_and_manipulating_NextZXOS_SD_card_image]] page&lt;br /&gt;
&lt;br /&gt;
Notes: The upstream zesarux can&#039;t use big images because it loads them into RAM - but zenext doesn&#039;t do/suffer that. zenext does non-exclusive file locking, so you can mount from OS and emulator at same time (alsonote: using such mounting increases chances for accidental corruption of the image or inconsistent views).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41909</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41909"/>
		<updated>2026-04-29T15:43:05Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* ZX Spectrum Next Manual */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
* Available online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or a printed coil bound book.&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41908</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41908"/>
		<updated>2026-04-29T15:41:24Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Manual == &lt;br /&gt;
&lt;br /&gt;
Online: [[FAQ#Where_can_I_download_a_copy_of_the_manual?]]&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or a printed coil bound book.&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41907</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41907"/>
		<updated>2026-04-28T11:27:25Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;docs&#039;&#039; Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Assembly Developer Guide&#039;&#039; by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or a printed coil bound book.&lt;br /&gt;
== &#039;&#039;ZX Spectrum Next Programming Notes&#039;&#039; by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== &#039;&#039;How to Write Spectrum Games&#039;&#039; by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== &#039;&#039;comp.sys.sinclair FAQ&#039;&#039; ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41906</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41906"/>
		<updated>2026-04-28T11:25:22Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: added link to the repo docs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ZX Spectrum Next Documentation =&lt;br /&gt;
&lt;br /&gt;
== docs Directory of the Distribution == &lt;br /&gt;
* https://gitlab.com/thesmog358/tbblue/-/tree/master/docs , especially note the [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos nextzxos] folder.&lt;br /&gt;
&lt;br /&gt;
= Next-specific Books =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Assembly Developer Guide by Tomaž Kragelj ==&lt;br /&gt;
* Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or a printed coil bound book.&lt;br /&gt;
== ZX Spectrum Next Programming Notes by Theodore (Alex) Evans ==&lt;br /&gt;
* https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum Books and Documentation =&lt;br /&gt;
== How to Write Spectrum Games by Jonathan Cauldwell ==&lt;br /&gt;
* https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== comp.sys.sinclair FAQ ==&lt;br /&gt;
* https://worldofspectrum.org/faq/reference/reference.htm&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41905</id>
		<title>Bibliography</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Bibliography&amp;diff=41905"/>
		<updated>2026-04-28T11:20:27Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: creating page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Next-specific =&lt;br /&gt;
&lt;br /&gt;
== ZX Spectrum Next Assembly Developer Guide by Tomaž Kragelj ==&lt;br /&gt;
** Available as a free to download PDF  https://github.com/tomaz/zx-next-dev-guide/ or a printed coil bound book.&lt;br /&gt;
== ZX Spectrum Next Programming Notes by Theodore (Alex) Evans ==&lt;br /&gt;
** https://github.com/varmfskii/zxnext_code/tree/master/zx_next_notes&lt;br /&gt;
&lt;br /&gt;
= ZX Spectrum =&lt;br /&gt;
== How to Write Spectrum Games by Jonathan Cauldwell ==&lt;br /&gt;
** https://jonathan-cauldwell.itch.io/how-to-write-spectrum-games&lt;br /&gt;
== comp.sys.sinclair FAQ ==&lt;br /&gt;
** https://worldofspectrum.org/faq/reference/reference.htm&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=MAME:Installing&amp;diff=41902</id>
		<title>MAME:Installing</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=MAME:Installing&amp;diff=41902"/>
		<updated>2026-04-23T09:36:46Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* Continuous Integration MAME Builds */ an attempt for the better text &amp;quot;flow&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://www.mamedev.org/ MAME] (formerly an acronym of Multiple Arcade Machine Emulator) is a free and open-source emulator designed to emulate the hardware of arcade games, later expanded to include video game consoles, old computers and other systems in software on modern personal computers and other platforms.&lt;br /&gt;
&lt;br /&gt;
MAME has supported the ZX Spectrum Next since version 0.267. The existing implementation is based on the v3.02.01 core and implements most of the features.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
You will need to install MAME, provide it with the Next firmware (&#039;ROM&#039;), and get the NextZXOS image:&lt;br /&gt;
&lt;br /&gt;
=== 1. Get MAME ===&lt;br /&gt;
Start with these official MAME releases. If you encounter crashes or other bugs, try replacing the MAME executable with holub&#039;s latest Continuous Integration (CI) builds as described at the end of this article.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Windows:&#039;&#039;&#039; Download [https://www.mamedev.org/release.html MAME for Windows].&lt;br /&gt;
* &#039;&#039;&#039;macOS:&#039;&#039;&#039; Download [https://sdlmame.lngn.net/ MAME for macOS].&lt;br /&gt;
* &#039;&#039;&#039;Linux:&#039;&#039;&#039; Install MAME from the flatpak repositories by running:&lt;br /&gt;
&amp;lt;pre&amp;gt;sudo flatpak install org.mamedev.MAME&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that Windows and macOS will likely prevent you from launching MAME directly for security reasons. See below on how to solve this.&lt;br /&gt;
&lt;br /&gt;
Alternatively, for the MAME platform as a whole, you can also check your package manager, or [https://docs.mamedev.org/initialsetup/compilingmame.html build from sources].&lt;br /&gt;
&lt;br /&gt;
Git of official MAME: [https://github.com/mamedev/mame/ https://github.com/mamedev/mame/] [https://github.com/mamedev/mame/blob/master/src/mame/sinclair/next/specnext.cpp specnext.cpp]&lt;br /&gt;
&lt;br /&gt;
Git of holub&#039;s fork: [https://github.com/holub/mame https://github.com/holub/mame] [https://github.com/holub/mame/blob/master/src/mame/sinclair/next/specnext.cpp specnext.cpp] (may contain extra fixes and features before they are merged to official repository)&lt;br /&gt;
&lt;br /&gt;
=== 2. Get TBBLUE (the Next &#039;boot ROM&#039;) ===&lt;br /&gt;
Put the file  [https://github.com/Threetwosevensixseven/NexCreator/raw/master/bootroms/tbblue.zip tbblue.zip] into MAME&#039;s &amp;lt;code&amp;gt;roms&amp;lt;/code&amp;gt; folder. Don&#039;t extract it; MAME will look for the zip file when the &amp;quot;tbblue&amp;quot; machine is selected.&lt;br /&gt;
&lt;br /&gt;
Note: The ROMs in this zip are what is embedded inside the FPGA core on real Next hardware. They&#039;re different from any ZX Spectrum machine ROMs you may be used to using, that are on the distro, SD card or SD image file.&lt;br /&gt;
&lt;br /&gt;
=== 3. Get the NextZXOS Image ===&lt;br /&gt;
Get an SD card image file of [https://www.specnext.com/latestdistro/ NextZXOS]. Note that &#039;&#039;&#039;some disk images published  on the official SpecNext.com site do not work with some emulators currently&#039;&#039;&#039; (the &amp;lt;code&amp;gt;latestdistro&amp;lt;/code&amp;gt; link points to the official location where the latest distribution can be found), but &#039;&#039;&#039;all images from &amp;lt;code&amp;gt;https://zxnext.uk/hosted/&amp;lt;/code&amp;gt; work with both MAME and CSpect&#039;&#039;&#039;, like [https://zxnext.uk/hosted/index_files/hdfimages/cspect-next-2gb.zip this SD card image in the zip archive]. Extract the image &amp;lt;code&amp;gt;cspect-next-2gb.img&amp;lt;/code&amp;gt; from the archive to use it, then point MAME to this SD card image with the &amp;lt;code&amp;gt;-hard1&amp;lt;/code&amp;gt; option (or select that file from the menu inside MAME).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
MAME looks for its configuration and helper files in specific (configurable) folders. By default, these are relative to the current working directory (cwd), i.e., from where you launched the executable. The &amp;lt;code&amp;gt;mame.ini&amp;lt;/code&amp;gt; file and folders like &amp;lt;code&amp;gt;roms, bgfx, plugins, language, ...&amp;lt;/code&amp;gt; are expected there, unless the &amp;lt;code&amp;gt;mame.ini&amp;lt;/code&amp;gt; file specifies other paths. When launching through a desktop icon or menu, depending on the OS, the working directory is often defined by the properties of that launch shortcut. When launching MAME from the command line, the current directory is &amp;quot;cwd&amp;quot; (doh). On Linux, MAME will look for &amp;lt;code&amp;gt;mame.ini&amp;lt;/code&amp;gt; first in the &amp;lt;code&amp;gt;~/.mame&amp;lt;/code&amp;gt; folder. You can use the option &amp;lt;code&amp;gt;-inipath&amp;lt;/code&amp;gt; to point MAME to a different path for the &amp;lt;code&amp;gt;mame.ini&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
However, the fastest way to run a machine with a desired configuration is from the command prompt, without requiring a &amp;lt;code&amp;gt;mame.ini&amp;lt;/code&amp;gt; file. Most of the features are also available through MAME&#039;s UI, although that takes more time to configure.&lt;br /&gt;
&lt;br /&gt;
As an example, this invocation enables the UI, uses &amp;quot;crisp pixels&amp;quot;, starts in a window, doesn&#039;t display the starting gameinfo window (it can still be displayed interactively from the UI), disables the mouse, confirms before exiting MAME, and specifies the disk image (remember to adjust the path to it):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;mame -ui_active -nounevenstretch -aspect 2:1 -video bgfx  -bgfx_screen_chains unfiltered -window -skip_gameinfo -mouse_device none -confirm_quit tbblue -hard1 /path/to/cspect-next-2gb.img&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s cover some useful options:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run inside a window and with no mouse support, until you get familiar with the UI keys:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; mame tbblue -window -mouse_device none -hard1 /path/to/next-distribution.img&amp;lt;/pre&amp;gt;&lt;br /&gt;
To launch the Linux flatpak version using the same options:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; flatpak run org.mamedev.MAME tbblue -window -mouse_device none -hard1 /path/to/next-distribution.img&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Activate UI keys on startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; ... -ui_active&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Don&#039;t show the info popup on startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; ... -skip_gameinfo&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Run with debugger. If you don&#039;t request this on startup, you won&#039;t have access to it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; ... -debug&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Use &amp;quot;crisp&amp;quot; pixels:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; ... -nounevenstretch -aspect 2:1 -video bgfx -bgfx_screen_chains unfiltered&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;No joystick connected to PC (having this may slightly speed up MAME&#039;s startup, but &#039;&#039;remember to remove this part from the command line and the corresponding setting in the ini file if you do want to use a joystick&#039;&#039;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; ... -joystickprovider none&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Ask for confirmation when exiting MAME (otherwise it&#039;s easy to exit MAME accidentally by hitting ESC, especially when playing games or navigating menus):&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; ... -confirm_quit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check the [https://docs.mamedev.org/commandline/commandline-all.html#mame-commandline-universal official MAME documentation] for more advanced usage.&lt;br /&gt;
&lt;br /&gt;
= Security: Allowing MAME to Run on Windows and macOS =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;On Windows,&#039;&#039;&#039; you will need to confirm that you want to launch MAME by clicking &amp;quot;Run Anyway&amp;quot; on first launch. &#039;&#039;(More details needed here.)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;On macOS,&#039;&#039;&#039; MAME will not open at first. Instead, a dialog will appear saying:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;“mame” Not Opened. Apple could not verify “mame” is free of malware that may harm your Mac or compromise your privacy.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click “Done”. Then open &#039;&#039;&#039;System Settings -&amp;gt; Privacy &amp;amp; Security&#039;&#039;&#039;, and scroll down to the message &#039;&#039;mame was blocked to protect your Mac.&#039;&#039; Click “Allow Anyway”.&lt;br /&gt;
&lt;br /&gt;
Now launch MAME again. A dialog will ask once more if you want to open “mame”. Click “Open Anyway”, and enter your password or use Touch ID when prompted by macOS.&lt;br /&gt;
&lt;br /&gt;
From now on, you can launch this version of MAME without warnings. However, you &#039;&#039;&#039;will&#039;&#039;&#039; need to repeat this each time you update MAME.&lt;br /&gt;
&lt;br /&gt;
= Keys =&lt;br /&gt;
&lt;br /&gt;
Keys are emulated in two modes: either to control the MAME emulator or completely dedicated to the emulated system (the Next). You can toggle between these two keyboard modes with ScrLk (on Win and Linux) or fn+delete (on Mac).&lt;br /&gt;
&lt;br /&gt;
Some UI keys:&lt;br /&gt;
* F3 - soft reset&lt;br /&gt;
* Shift+F3 - hard reset&lt;br /&gt;
* F4 - sprites/tiles/font viewer (Enter, ], [)&lt;br /&gt;
* F5 - pause emulation&lt;br /&gt;
* F6 - save state&lt;br /&gt;
* F7 - load state&lt;br /&gt;
* Tab - emulator settings&lt;br /&gt;
* ~ - menu&lt;br /&gt;
* ` (backtick) - debugger (when enabled by starting MAME with &amp;lt;code&amp;gt;-debug&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-d&amp;lt;/code&amp;gt; on the command line)&lt;br /&gt;
* PgDwn (Linux/Mac), fn-Downarrow (MacBooks) or Insert (Win) - hold down to fast-forward emulation at maximum speed, e.g., to speed up booting the Next&lt;br /&gt;
* Esc - exit (exits menus but also the entire emulator - see &amp;lt;code&amp;gt;-confirm_quit&amp;lt;/code&amp;gt; option above)&lt;br /&gt;
* F11 - DivMMC NMI&lt;br /&gt;
* F12 - Multiface NMI&lt;br /&gt;
&lt;br /&gt;
Check [https://docs.mamedev.org/usingmame/defaultkeys.html default keys documentation] for more.&lt;br /&gt;
&lt;br /&gt;
= Changing the UI toggle key =&lt;br /&gt;
&lt;br /&gt;
Some laptops don&#039;t have a Scroll Lock key, so you may not be able to exit MAME if you run it in full-screen mode. In these cases, you can change the UI toggle key as follows:&lt;br /&gt;
&lt;br /&gt;
* Run MAME without any command line arguments (except maybe -window) to open its GUI.&lt;br /&gt;
* Push TAB and enter the General Settings menu.&lt;br /&gt;
* Go to Input Assignments -&amp;gt; User Interface -&amp;gt; Toggle UI controls and select a new key. I use Right Alt / Alt GR.&lt;br /&gt;
* Return to the previous menu twice, then choose Save Settings&lt;br /&gt;
&lt;br /&gt;
= Creating and manipulating NextZXOS SD card image =&lt;br /&gt;
&lt;br /&gt;
Most users wanting to emulate the Next using MAME will be fine using a pre-built SD card image downloaded from the site hosting best pre-made images (currently, [https://zxnext.uk/hosted zxnext.uk/hosted] ) website. The following guide is provided for anyone wanting to create a NextZXOS SD card image from scratch.&lt;br /&gt;
&lt;br /&gt;
Download the [https://www.specnext.com/latestdistro/ latest NextZXOS distribution zip file] (named something like sn-complete-WX.YZ.zip) and extract it into a new, empty directory.&lt;br /&gt;
&lt;br /&gt;
== Creating and populating a SD card image using hdfmonkey jjjs build ==&lt;br /&gt;
&lt;br /&gt;
The [https://www.specnext.com/forum/viewtopic.php?t=2604 hdfmonkey &amp;quot;jjjs build&amp;quot;] is a variant of hdfmonkey tool which includes some unique features and its main archive (at the previously given link) also contains pre-built binaries for Windows x64, MacOS x64, MacOS Apple Silicon and Linux x64. (Alternatively, the process to build a local Linux version of the executable is described [[Development_Tools:Linux_setup#hdfmonkey_tool | here]] )&lt;br /&gt;
&lt;br /&gt;
If you extracted sn-complete-WX.YZ.zip into a subdirectory named &amp;lt;code&amp;gt;snWXYZ&amp;lt;/code&amp;gt;, and you want to create a 1GB image called &amp;lt;code&amp;gt;NextZXOS.img&amp;lt;/code&amp;gt; and you have a jjjs build&amp;quot; of hdfmonkey, then it&#039;s enough to do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hdfmonkey create NextZXOS.img 1G&lt;br /&gt;
hdfmonkey putdir NextZXOS.img snWXYZ /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first line creates an empty 1GB image and formats it with the best FAT parameters suited to the size of the image.&lt;br /&gt;
&lt;br /&gt;
The second line recursively copies all the content of the directory &amp;lt;code&amp;gt;snWXYZ&amp;lt;/code&amp;gt; to the image, preserving the directory structure inside, starting from the &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; in the image.&lt;br /&gt;
&lt;br /&gt;
One of the advantages of this method is that even if the image has a capacity of 1GB, it will use much less space on your hard drive until you fill up the image. On Linux or MacOS, a command &amp;lt;code&amp;gt;du -h NextZXOS.img&amp;lt;/code&amp;gt; shows the actual amount of disk space used by the image. On Windows the same information can be seen in the File Properties dialog.&lt;br /&gt;
&lt;br /&gt;
The fastest way to transfer a file or a directory (including its content, recursively) into an image is by using a single &amp;lt;code&amp;gt;put&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;putdir&amp;lt;/code&amp;gt;, if it&#039;s to transfer the directory file content to an existing directory) command of hdfmonkey.&lt;br /&gt;
&lt;br /&gt;
The most convenient tool to copy of all the content from the image to a folder outside of the image is 7-zip. On Windows, just use the 7-zip GUI. On MacOS and Linux, see: [[Development_Tools:Linux_setup#Extracting_all_files_from_the_sd-card_image]].&lt;br /&gt;
&lt;br /&gt;
=MAME Plugins and Scripts=&lt;br /&gt;
&lt;br /&gt;
Some MAME plugins and scripts that may be useful for Next developers and end users are listed [[MAME:Plugins_and_Scripts|here]]. They let you speed up the Next boot time, profile your NextBASIC or assembler code, and more.&lt;br /&gt;
&lt;br /&gt;
=Continuous Integration MAME Builds=&lt;br /&gt;
&lt;br /&gt;
MAME is updated on a release schedule, but due to the ongoing nature of development, including for the MAME Next machine, it can sometimes be useful to install a more recent build if it contains a new feature or bugfix you are interested in. Sometimes, this ongoing work is discussed on social media, such as the [https://discordapp.com/channels/556228195767156758/752197165891321886 Next Developer Discord].&lt;br /&gt;
&lt;br /&gt;
Continuous Integration (CI) builds are available from both the [https://github.com/mamedev/mame/actions primary MAME repo] and [https://github.com/holub/mame/actions holub&#039;s GitHub repo]. Both are considered bleeding-edge, with the primary MAME repo slightly less so. MAME CI builds are available for Windows, Linux, and macOS and are updated automatically whenever code is committed by a maintainer or pushed to the primary repo.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You need to be logged in to github&#039;&#039;&#039; to download CI artifacts, so [https://github.com/login sign in] or [https://github.com/signup sign up].&lt;br /&gt;
&lt;br /&gt;
To try out a CI build (more precisely, the resulting binary executable, which is a produced &amp;quot;artifact&amp;quot; of the build process) , first do a full MAME install from the [https://www.mamedev.org/release.html latest release] if you have not already done so. Then back up your main binary from its installation location - these are called something like &amp;lt;code&amp;gt;mame.exe&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;mame&amp;lt;/code&amp;gt;. You&#039;re backing it up to be able to restore it if the CI build doesn&#039;t work, or if you don&#039;t like how the CI build behaves.&lt;br /&gt;
&lt;br /&gt;
Then visit one of the links above and find a workflow run item for your platform. Workflow items are the things in the list. The tags are flagged as &amp;lt;code&amp;gt;CI (Windows)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CI (Linux)&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;CI (macOS)&amp;lt;/code&amp;gt; in the second row of each workflow item in the list (not the filter in the left hand nav menu). Click on a completed workfow item (only items with green checkmarks will have created downloadable binaries yet), find the Artifacts section at the bottom (note again: you need to be signed up to see that section and/or download the artifact), then click the Download button. Unzip the downloaded file and find the main binary (with the same name as above). Copy the main binary to the install location, overwriting the original one, and run MAME the same way you were running it before. On Windows and macOS, you need to repeat the security steps above to trust the new MAME executable.&lt;br /&gt;
&lt;br /&gt;
= More MAME related links =&lt;br /&gt;
&lt;br /&gt;
MAME [https://docs.mamedev.org/ documentation].&lt;br /&gt;
&lt;br /&gt;
Report any issues with MAME on the [https://mametesters.org/ bugtracker].&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;&#039;Linux&#039;&#039;&#039; users there are more tips (how to compile MAME from source, how to configure it to not use CWD as starting path for resource directories, how to mount or create image file) at [[Development_Tools:Linux_setup]] page.&lt;br /&gt;
&lt;br /&gt;
[https://docs.mamedev.org/advanced/devicemap.html MAMEDEV.ORG MAME Stable Controller IDs].&lt;br /&gt;
By default, MAME does not assign stable numbers to input devices. For instance, a game pad controller may be assigned to “Joy 1” initially, but after restarting, the same game pad may be reassigned to “Joy 3”.&lt;br /&gt;
Here a some hints how to fixate MAME´s Joystick-Detection to specific Controllers: [https://www.youtube.com/watch?v=YmjfwLuZ_X0 Youtube - Mapping your controllers for stable IDs]&lt;br /&gt;
and: [https://forums.launchbox-app.com/topic/89296-stable-controller-ids-for-mame/ Stable Controller IDs for MAME]&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41899</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41899"/>
		<updated>2026-04-21T16:17:20Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* z88dk-scc80 and z88dk-zsdcc */ minor edit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ ZX Basic]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World] &lt;br /&gt;
: The selection of the CRT is by startup=n number.  The crts are in the range 0-31, some mentioned in the above Hello World text, and some in the sources like [https://github.com/z88dk/z88dk/tree/master/libsrc/newlib/target/zxn/startup newlib zxn startup]. (internally: The factors of 256 are added by subtype=? on the compile line: base 0 numbers have no assumptions about the output type, i.e. for binaries that will be tap/nex/.. Base 256 is for dot commands, base 512 is for dotx command (not appropriate for the Next), base 768 is dotn).&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41898</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41898"/>
		<updated>2026-04-21T16:16:14Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* z88dk-scc80 and z88dk-zsdcc */ minor edit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ ZX Basic]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World] &lt;br /&gt;
: The selection of the CRT is by startup=n number.  The crts are in the range 0-31, some mentioned in the above Hello World text, and some in the sources like [https://github.com/z88dk/z88dk/tree/master/libsrc/newlib/target/zxn/startup newlib zxn startup]. (internally: The factors of 256 are added by subtype=? on the compile line: base 0 numbers have no assumptions about the output type, ie they are destined for binaries which can be turned into tap/nex/.. Base 256 is for dot commands, base 512 is for dotx command (not appropriate for the Next), base 768 is dotn).&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41897</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41897"/>
		<updated>2026-04-21T16:15:21Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* z88dk-scc80 and z88dk-zsdcc */ better order&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ ZX Basic]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World] &lt;br /&gt;
: The selection of the CRT is by startup=n number.  The crts are in the range 0-31, some mentioned in the above Hello World text, and some in the sources like [https://github.com/z88dk/z88dk/tree/master/libsrc/newlib/target/zxn/startup newlib zxn startup]. (internally: The factors of 256 are added by subtype=? on the compile line: base 0 numbers have no assumptions about the output type, ie they are destined for binaries which can be turned into tap/nex/.. Base 256 is for dot commands, base 512 is for dotx command (which is  not appropriate for the Next), base 768 is dotn).&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41896</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41896"/>
		<updated>2026-04-21T16:08:37Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* z88dk-scc80 and z88dk-zsdcc */ numbers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ ZX Basic]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World] &lt;br /&gt;
: The selection of the CRT is by startup=n number.  The crts are in the range 0-31, some mentioned in the above Hello World text, and some in the sources like [https://github.com/z88dk/z88dk/tree/master/libsrc/newlib/target/zxn/startup newlib zxn startup]. (internally: base 0 numbers have no assumptions about the output type, ie they are destined for binaries which can be turned into tap/nex/.. Base 256 is for dot commands, base 512 is for dotx command (which is  not appropriate for the Next), base 768 is dotn. The factors of 256 are added by subtype=? on the compile line).&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41895</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41895"/>
		<updated>2026-04-21T16:05:26Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* z88dk-scc80 and z88dk-zsdcc */ startup numbers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ ZX Basic]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World] &lt;br /&gt;
: The selection of the CRT is by startup=n number.  The crts are in the range 0-31, some mentioned in the above Hello World text, and some in the sources like [https://github.com/z88dk/z88dk/tree/master/libsrc/newlib/target/zxn/startup newlib zxn startup]. Base 256 is for dot commands, base 512 is for dotx command (which is  not appropriate for the Next), base 768 is dotn. The factors of 256 are added by subtype=? on the compile line.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41894</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41894"/>
		<updated>2026-04-21T16:00:21Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* z88dk-scc80 and z88dk-zsdcc */ nicer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ ZX Basic]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
: The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World]&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41893</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=41893"/>
		<updated>2026-04-21T15:59:56Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* z88dk-scc80 and z88dk-zsdcc */ Hello World&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BASIC ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://zxbasic.readthedocs.io/ ZX Basic]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/em00k/NextBuild NextBuild v7]&#039;&#039; ===&lt;br /&gt;
: NextBuild is a suite of tools for Windows which uses Boriel&#039;s ZX Basic Compiler. It comes with a Next library of routines to take advantage of the Nexts hardware. Examples included.&lt;br /&gt;
: See [[NextBuild:Main Page| NextBuild dedicated Wiki section]].&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;z88dk-scc80&#039;&#039; and &#039;&#039;z88dk-zsdcc&#039;&#039; === &lt;br /&gt;
: Via the &amp;quot;zcc&amp;quot;, the [https://github.com/z88dk/z88dk Z88dk] toolchain&#039;s front end, two compilers could be invoked &amp;lt;ref&amp;gt; [https://github.com/z88dk/z88dk/wiki z88dk wiki] &amp;lt;/ref&amp;gt;:&lt;br /&gt;
: &amp;quot;z88dk-scc80&amp;quot;, a small C derived C compiler that is nearly C90 compliant with a few notable exceptions.  Emphasis is on small code.&lt;br /&gt;
: &amp;quot;z88dk-zsdcc&amp;quot;, a fork of [[#SDCC]].&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
: [[Calling convention notes]]&lt;br /&gt;
&lt;br /&gt;
The tutorial for the &amp;quot;newlib&amp;quot; for ZX Spectrum mentions some important details about the possibilities of programs written for Next too: [https://github.com/z88dk/z88dk/blob/master/doc/target/zx/02_HelloWorld.md  ZX Hello World]&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;SDCC&#039;&#039; === &lt;br /&gt;
&lt;br /&gt;
: [https://sdcc.sourceforge.net/ Small Device C Compiler, SDCC] is an open-source retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets a lot of mostly 8-bit microprocessors &amp;lt;ref&amp;gt;[https://sdcc.sourceforge.net/ SDCC targets as of February 2026]: the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Rabbit 4000, 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained.  SDCC can be retargeted for other microprocessors.&amp;lt;/ref&amp;gt; including a Z80N target.&lt;br /&gt;
&lt;br /&gt;
: The compiler, assembler and linker are GNU GPL &amp;lt;ref&amp;gt;[https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU GPL 2] , [https://www.gnu.org/licenses/gpl-3.0.html GNU GPL 3]&amp;lt;/ref&amp;gt; licensed and the compiler&#039;s libraries are GNU GPL licensed with a special exception.&lt;br /&gt;
&lt;br /&gt;
: Developed as separate projects there are: a development kit for SDCC for creating small NextZXOS DOT programs and a [https://github.com/retro-vault/libcpm3-z80 library for CP/M 3]&lt;br /&gt;
&lt;br /&gt;
: Firmware and loader sources in the tbblue repository were made to be compiled with SDCC.&lt;br /&gt;
&lt;br /&gt;
== C-like ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://taylorza.itch.io/znc-compiler ZNC Native compiler]&#039;&#039; ===&lt;br /&gt;
: ZNC is a language and compiler for the ZX Spectrum Next. The language is closely modeled after the C programming language.&lt;br /&gt;
: The language suite includes the compiler, an optimizer, assembler and text editor to support native development on the Next. It also include a frontend that makes managing source files and building your projects easier.&lt;br /&gt;
&lt;br /&gt;
== Forth ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;VForth Next&#039;&#039; ===&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/mattsteeldue/vforth-next VForth Next] is a Z80N Forth system suitable to run on the ZX Spectrum Next&lt;br /&gt;
&lt;br /&gt;
== Pascal ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;Pasta80&#039;&#039; ===&lt;br /&gt;
: [https://github.com/pleumann/pasta80 Pasta80] is a Turbo Pascal 3.0-compatible compiler that generates machine code for classic and modern Z80 machines (currently ZX Spectrum 48K/128K/Next and CP/M). &lt;br /&gt;
: GNU GPL 3 license with a linking exception.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;OmniPas&#039;&#039; ===&lt;br /&gt;
: [https://syntaxerrorsoftware.itch.io/omnipas OmniPas] is a Windows‑based Pascal cross‑compiler that targets multiple platforms, including the ZX Spectrum and ZX Spectrum Next.&lt;br /&gt;
&lt;br /&gt;
== Utilities ==&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/speccyorg/bas2tap bas2tap CLI]&#039;&#039; ===&lt;br /&gt;
: The utility to convert `BASIC in an ASCII file&#039; to a TAP tape image file (can be loaded by emulator or Next as regular BASIC program).&lt;br /&gt;
: Comes complete with portable C source. With full BASIC syntax checking!&lt;br /&gt;
: (does not support NextBASIC extensions)&lt;br /&gt;
: (for NextBASIC you can use the NextZXOS dot commands .txt2bas and .bas2txt directly on the Next)&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[https://github.com/remy/txt2bas txt2bas &amp;amp; bas2txt CLI]&#039;&#039; ===&lt;br /&gt;
: Cross platform command line tool to convert NextBASIC to +3dos .bas file and convert .bas files to plain text.&lt;br /&gt;
: The tool also includes verbose validation, tap and 3dos, BANK compatible and headerless export and import support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=DMA_interrupt_enable_0&amp;diff=41892</id>
		<title>DMA interrupt enable 0</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=DMA_interrupt_enable_0&amp;diff=41892"/>
		<updated>2026-04-12T15:19:29Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: added content from the AA&amp;#039;s explanation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NextRegister&lt;br /&gt;
|Number=$CC&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=Yes&lt;br /&gt;
|ShortDesc=Interrupts that can override DMA&lt;br /&gt;
}}&lt;br /&gt;
  bit 7 = NMI&lt;br /&gt;
  bit 1 = Line&lt;br /&gt;
  bit 0 = ULA&lt;br /&gt;
* Set bits indicate the corresponding interrupt will interrupt a dma operation when in [[hw im2 mode]]&lt;br /&gt;
&lt;br /&gt;
Soft reset = 0x00&lt;br /&gt;
&lt;br /&gt;
Because interrupts are only sampled at the end of an instruction by the Z80, each time the dma is interrupted one instruction of progress is made in the main program.&lt;br /&gt;
&lt;br /&gt;
A signal will force the dma to pause by giving up the bus and wait in a reacquire bus state while the cpu takes back control. There are some vagaries in the behaviour due to how the z80 works: the z80 does not check for an interrupt until the last T state of an instruction so it&#039;s possible the z80 executes one instruction before the isr is entered.  This is mentioned here as a caution to programmers because normally you start the dma with an OUT and when the next instruction executes, the dma op has already finished.  Not so with this arrangement as you could be executing one instruction following that OUT each time the dma is interrupted. &lt;br /&gt;
&lt;br /&gt;
There is also a kind of priority inversion that can happen.  If only a ctc channel can interrupt a dma operation, there could be higher priority interrupts pending.  When the ctc channel interrupts the dma, the z80 services the higher priority interrupts first and then only returns control to the dma when the reti for the ctc channel isr executes.  The dma is also prevented from reacquring the bus until after reti pops its return address to avoid stack overflow.&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=DMA_interrupt_enable_2&amp;diff=41891</id>
		<title>DMA interrupt enable 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=DMA_interrupt_enable_2&amp;diff=41891"/>
		<updated>2026-04-11T19:57:30Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NextRegister&lt;br /&gt;
|Number=$CE&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=Yes&lt;br /&gt;
|ShortDesc=UART Interrupts that can override DMA&lt;br /&gt;
}}&lt;br /&gt;
  bit 7 = Reserved must be zero&lt;br /&gt;
  bit 6 = UART1 Tx empty&lt;br /&gt;
  bit 5 = UART1 Rx half full     \ shared&lt;br /&gt;
  bit 4 = UART1 Rx available     / interrupt&lt;br /&gt;
  bit 3 = Reserved must be zero&lt;br /&gt;
  bit 2 = UART0 Tx empty&lt;br /&gt;
  bit 1 = UART0 Rx half full     \ shared&lt;br /&gt;
  bit 0 = UART0 Rx available     / interrupt&lt;br /&gt;
* Set bits indicate the corresponding interrupt will interrupt a dma operation when in [[hw im2 mode]]&lt;br /&gt;
&lt;br /&gt;
soft reset = 0x00&lt;br /&gt;
&lt;br /&gt;
Because interrupts are only sampled at the end of an instruction by the Z80, each time the dma is interrupted one instruction of progress is made in the main program.&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=DMA_interrupt_enable_1&amp;diff=41890</id>
		<title>DMA interrupt enable 1</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=DMA_interrupt_enable_1&amp;diff=41890"/>
		<updated>2026-04-11T19:57:15Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: linking hw im2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NextRegister&lt;br /&gt;
|Number=$CD&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=Yes&lt;br /&gt;
|ShortDesc=CTC Interrupts that can override DMA&lt;br /&gt;
}}&lt;br /&gt;
  bit 7 = ctc channel 7 zc/to&lt;br /&gt;
  bit 6 = ctc channel 6 zc/to&lt;br /&gt;
  bit 5 = ctc channel 5 zc/to&lt;br /&gt;
  bit 4 = ctc channel 4 zc/to&lt;br /&gt;
  bit 3 = ctc channel 3 zc/to&lt;br /&gt;
  bit 2 = ctc channel 2 zc/to&lt;br /&gt;
  bit 1 = ctc channel 1 zc/to&lt;br /&gt;
  bit 0 = ctc channel 0 zc/to&lt;br /&gt;
* Set bits indicate the corresponding interrupt will interrupt a dma operation when in [[hw im2 mode]]&lt;br /&gt;
&lt;br /&gt;
soft reset = 0x00&lt;br /&gt;
&lt;br /&gt;
Because interrupts are only sampled at the end of an instruction by the Z80, each time the dma is interrupted one instruction of progress is made in the main program.&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=DMA&amp;diff=41889</id>
		<title>DMA</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=DMA&amp;diff=41889"/>
		<updated>2026-04-11T19:56:38Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: /* The DMA and Interrupts */ link to hw im2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The ZX Spectrum Next DMA (zxnDMA) is a single channel DMA device that implements a subset of the Z80 DMA functionality. The subset is large enough to be compatible with common uses of the similar Datagear interface available for standard ZX Spectrum computers and compatibles. It also adds a burst mode capability that can deliver audio at programmable sample rates to the DAC device.&lt;br /&gt;
&lt;br /&gt;
== Accessing the zxnDMA ==&lt;br /&gt;
&amp;lt;del&amp;gt;The zxnDMA is mapped to a single Read/Write IO Port 0x6B which is the same one used by the Datagear but unlike the Datagear it doesn&#039;t also map itself to a second port 0x0B similar to the MB-02 interface.&amp;lt;/del&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since core 3.1.2 the zxnDMA is mapped to {{PortNo|$xx6B}}, and Zilog-DMA mode is mapped to {{PortNo|$xx0B}}.&lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
The normal Z80 DMA (Z8410) chip is a pipelined device and because of that it has numerous off-by-one idiosyncrasies and requirements on the order that certain commands should be carried out. These issues are not duplicated in the zxnDMA. You can continue to program the zxnDMA as if it is were a Z8410 DMA device but it can also be programmed in a simpler manner.&lt;br /&gt;
&lt;br /&gt;
The single channel of the zxnDMA chip consists of two ports named A and B. Transfers can occur in either direction between ports A and B, each port can describe a target in memory or IO, and each can be configured to autoincrement, autodecrement or stay fixed after a byte is transferred.&lt;br /&gt;
&lt;br /&gt;
A special feature of the zxnDMA can force each byte transfer to take a fixed amount of time so that the zxnDMA can be used to deliver sampled audio.&lt;br /&gt;
&lt;br /&gt;
== Modes of Operation ==&lt;br /&gt;
The zxnDMA can operate in a z80-DMA compatibility mode.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;REMOVED in core 3.1.2:&#039;&#039;&#039; &amp;lt;del&amp;gt;The z80-DMA compatibility mode is selected by setting bit 6 of nextreg 0x06. In this mode, all transfers involve length+1 bytes which is the same behaviour as the z80-DMA chip. In zxn-DMA mode, the transfer length is exactly the number of bytes programmed. This mode is mainly present to accommodate existing spectrum software that uses the z80-DMA and for cp/m programs that may have a z80-DMA option.&amp;lt;/del&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since core 3.1.2:&#039;&#039;&#039; the DMA mode is selected by port number, the {{PortNo|$xx6B}} works in zxnDMA mode, {{PortNo|$xx0B}} works in Zilog mode. The bit 6 in {{NextRegNo|$06}} is not DMA related any more and will be reused for something different.&lt;br /&gt;
&lt;br /&gt;
The zxnDMA can also operate in either burst or continuous modes.&lt;br /&gt;
&lt;br /&gt;
Continuous mode means the DMA chip runs to completion without allowing the CPU to run. When the CPU starts the DMA, the DMA operation will complete before the CPU executes its next instruction.&lt;br /&gt;
&lt;br /&gt;
Burst mode nominally means the DMA lets the CPU run if either port is not ready. This condition can&#039;t happen in the zxnDMA chip except when operated in the special fixed time transfer mode. In this mode, the zxnDMA will let the CPU run while it waits for the fixed time to expire between bytes transferred.&lt;br /&gt;
&lt;br /&gt;
Note that there is no byte transfer mode as in the Z80 DMA.&lt;br /&gt;
&lt;br /&gt;
== Programming the zxnDMA ==&lt;br /&gt;
Like the Z80 DMA chip, the zxnDMA has seven write registers named WR0-WR6 that control the device. Each register WR0-WR6 can have zero or more parameters associated with it.&lt;br /&gt;
&lt;br /&gt;
In a first write to the zxnDMA port, the write value is compared against a bitmask to determine which of the WR0-WR6 is the target. Remaining bits in the written value can contain data as well as a list of associated parameter bits. The parameter bits determine if further writes are expected to deliver parameter values. If there are multiple parameter bits set, the expected order of parameter values written is determined by parameter bit position from right to left (bit 0 through bit 7). Once all parameters are written, the zxnDMA again expects a regular register write selecting WR0-WR6.&lt;br /&gt;
&lt;br /&gt;
The table below describes the registers and the bitmask required to select them on the zxnDMA.&lt;br /&gt;
&lt;br /&gt;
{| &lt;br /&gt;
! Register Group&lt;br /&gt;
! Register Function Description&lt;br /&gt;
! Bitmask&lt;br /&gt;
! Notes&lt;br /&gt;
|- &lt;br /&gt;
| WR0&lt;br /&gt;
| Direction, Operation and Port A configuration&lt;br /&gt;
| &amp;lt;pre&amp;gt;0XXXXXAA&amp;lt;/pre&amp;gt;&lt;br /&gt;
| AA must NOT be 00&lt;br /&gt;
|- &lt;br /&gt;
| WR1&lt;br /&gt;
| Port A configuration&lt;br /&gt;
| &amp;lt;pre&amp;gt;0XXXX100&amp;lt;/pre&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
|- &lt;br /&gt;
| WR2&lt;br /&gt;
| Port B configuration&lt;br /&gt;
| &amp;lt;pre&amp;gt;0XXXX000&amp;lt;/pre&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
|- &lt;br /&gt;
| WR3&lt;br /&gt;
| Activation&lt;br /&gt;
| &amp;lt;pre&amp;gt;1XXXXX00&amp;lt;/pre&amp;gt;&lt;br /&gt;
| It’s best to use WR6&lt;br /&gt;
|- &lt;br /&gt;
| WR4&lt;br /&gt;
| Port B, Timing and Interrupt configuration&lt;br /&gt;
| &amp;lt;pre&amp;gt;1XXXXX01&amp;lt;/pre&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
|- &lt;br /&gt;
| WR5&lt;br /&gt;
| Ready and Stop configuration&lt;br /&gt;
| &amp;lt;pre&amp;gt;10XXX010&amp;lt;/pre&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
|- &lt;br /&gt;
| WR6&lt;br /&gt;
| Command Register&lt;br /&gt;
| &amp;lt;pre&amp;gt;1XXXXX11&amp;lt;/pre&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== zxnDMA Registers ==&lt;br /&gt;
These are described below following the same convention used by Zilog for its DMA chip:&lt;br /&gt;
&lt;br /&gt;
=== WR0 – Write Register Group 0 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;D7  D6  D5  D4  D3  D2  D1  D0  BASE REGISTER BYTE&lt;br /&gt;
 0   |   |   |   |   |   |   |&lt;br /&gt;
     |   |   |   |   |   0   0  Do not use&lt;br /&gt;
     |   |   |   |   |   0   1  Transfer (Prefer this for Z80 DMA compatibility)&lt;br /&gt;
     |   |   |   |   |   1   0  Do not use (Behaves like Transfer, Search on Z80 DMA)&lt;br /&gt;
     |   |   |   |   |                       &lt;br /&gt;
     |   |   |   |   |   1   1  Do not use (Behaves like Transfer, Search/Transfer on Z80 DMA)&lt;br /&gt;
     |   |   |   |   |                      &lt;br /&gt;
     |   |   |   |   0 = Port B -&amp;amp;gt; Port A (Byte transfer direction)&lt;br /&gt;
     |   |   |   |   1 = Port A -&amp;amp;gt; Port B&lt;br /&gt;
     |   |   |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  PORT A STARTING ADDRESS (LOW BYTE)&lt;br /&gt;
     |   |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  PORT A STARTING ADDRESS (HIGH BYTE)&lt;br /&gt;
     |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  BLOCK LENGTH (LOW BYTE)&lt;br /&gt;
     V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  BLOCK LENGTH (HIGH BYTE)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Several registers are accessible from WR0. The first write to WR0 is to the base register byte. Bits D6:D3 are optionally set to indicate that associated registers in this group will be written next. The order the writes come in are from D3 to D6 (right to left). For example, if bits D6 and D3 are set, the next two writes will be directed to PORT A STARTING ADDRESS LOW followed by BLOCK LENGTH HIGH.&lt;br /&gt;
&lt;br /&gt;
=== WR1 – Write Register Group 1 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;D7  D6  D5  D4  D3  D2  D1  D0  BASE REGISTER BYTE&lt;br /&gt;
 0   |   |   |   |   1   0   0&lt;br /&gt;
     |   |   |   |&lt;br /&gt;
     |   |   |   0 = Port A is memory&lt;br /&gt;
     |   |   |   1 = Port A is IO&lt;br /&gt;
     |   |   |&lt;br /&gt;
     |   0   0 = Port A address decrements&lt;br /&gt;
     |   0   1 = Port A address increments&lt;br /&gt;
     |   1   0 = Port A address is fixed&lt;br /&gt;
     |   1   1 = Port A address is fixed&lt;br /&gt;
     |&lt;br /&gt;
     V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  PORT A VARIABLE TIMING BYTE&lt;br /&gt;
 0   0   0   0   0   0   |   |&lt;br /&gt;
                         0   0 = Cycle Length = 4&lt;br /&gt;
                         0   1 = Cycle Length = 3&lt;br /&gt;
                         1   0 = Cycle Length = 2&lt;br /&gt;
                         1   1 = Do not use&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cycle length is the number of cycles used in a read or write operation. The first cycle asserts signals and the last cycle releases them. There is no half cycle timing for the control signals.&lt;br /&gt;
&lt;br /&gt;
=== WR2 – Write Register Group 2 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;D7  D6  D5  D4  D3  D2  D1  D0  BASE REGISTER BYTE&lt;br /&gt;
 0   |   |   |   |   0   0   0&lt;br /&gt;
     |   |   |   |&lt;br /&gt;
     |   |   |   0 = Port B is memory&lt;br /&gt;
     |   |   |   1 = Port B is IO&lt;br /&gt;
     |   |   |&lt;br /&gt;
     |   0   0 = Port B address decrements&lt;br /&gt;
     |   0   1 = Port B address increments&lt;br /&gt;
     |   1   0 = Port B address is fixed&lt;br /&gt;
     |   1   1 = Port B address is fixed&lt;br /&gt;
     |&lt;br /&gt;
     V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  PORT B VARIABLE TIMING BYTE&lt;br /&gt;
 0   0   |   0   0   0   |   |&lt;br /&gt;
         |               0   0 = Cycle Length = 4&lt;br /&gt;
         |               0   1 = Cycle Length = 3&lt;br /&gt;
         |               1   0 = Cycle Length = 2&lt;br /&gt;
         |               1   1 = Do not use&lt;br /&gt;
         |&lt;br /&gt;
         V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  ZXN PRESCALAR (FIXED TIME TRANSFER)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The ZXN PRESCALAR is a feature of the zxnDMA implementation. If non-zero, a delay will be inserted after each byte is transferred such that the total time needed for each transfer is determined by the prescalar. This works in both the continuous mode and the burst mode. If the DMA is operated in burst mode, the DMA will give up any waiting time to the CPU so that the CPU can run while the DMA is idle.&lt;br /&gt;
&lt;br /&gt;
The rate of transfer is given by the formula “Frate = 875kHz / prescalar” or, rearranged, “prescalar = 875kHz / Frate”. The formula is framed in terms of a sample rate (Frate) but Frate can be inverted to set a transfer time for each byte instead. The 875kHz constant is a nominal value assuming a 28MHz system clock; the system clock actually varies from this depending on the video timing selected by the user (HDMI, VGA0-6) so for complete accuracy the constant should be prorated according to documentation for nextreg 0x11.&lt;br /&gt;
&lt;br /&gt;
In a DMA audio setting, selecting a sample rate of 16kHz would mean setting the prescalar value to 55. This sample period is constant across changes in CPU speed.&lt;br /&gt;
&lt;br /&gt;
=== WR3 – Write Register Group 3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;D7  D6  D5  D4  D3  D2  D1  D0  BASE REGISTER BYTE&lt;br /&gt;
 1   |   0   0   0   0   0   0&lt;br /&gt;
     |&lt;br /&gt;
     1 = DMA Enable&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The Z80 DMA defines more fields but they are ignored by the zxnDMA. The two other registers defined by the Z80 DMA in this group on D4 and D3 are implemented by the zxnDMA but they do nothing.&lt;br /&gt;
&lt;br /&gt;
It is preferred to start the DMA by writing an &#039;Enable DMA&#039; command to WR6.&lt;br /&gt;
&lt;br /&gt;
=== WR4 – Write Register Group 4 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;D7  D6  D5  D4  D3  D2  D1  D0  BASE REGISTER BYTE&lt;br /&gt;
 1   |   |   0   |   |   0   1&lt;br /&gt;
     |   |       |   |&lt;br /&gt;
     0   0 = Do not use (Behaves like Continuous mode, Byte mode on Z80 DMA)&lt;br /&gt;
     0   1 = Continuous mode&lt;br /&gt;
     1   0 = Burst mode&lt;br /&gt;
     1   1 = Do not use&lt;br /&gt;
                 |   |&lt;br /&gt;
                 |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  PORT B STARTING ADDRESS (LOW BYTE)&lt;br /&gt;
                 |&lt;br /&gt;
                 V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  PORT B STARTING ADDRESS (HIGH BYTE)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The Z80 DMA defines three more registers in this group through D4 that define interrupt behaviour. Interrups and pulse generation are not implemented in the zxnDMA nor are these registers available for writing.&lt;br /&gt;
&lt;br /&gt;
=== WR5 – Write Register Group 5 ===&lt;br /&gt;
&amp;lt;pre&amp;gt;D7  D6  D5  D4  D3  D2  D1  D0  BASE REGISTER BYTE&lt;br /&gt;
 1   0   |   |   0   0   1   0&lt;br /&gt;
         |   |&lt;br /&gt;
         |   0 = /ce only&lt;br /&gt;
         |   1 = /ce &amp;amp; /wait multiplexed&lt;br /&gt;
         |&lt;br /&gt;
         0 = Stop on end of block&lt;br /&gt;
         1 = Auto restart on end of block&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The /ce &amp;amp; /wait mode is implemented in the zxnDMA but is not currently used. This mode has an external device using the DMA&#039;s /ce pin to insert wait states during the DMA&#039;s transfer.&lt;br /&gt;
&lt;br /&gt;
The auto restart feature causes the DMA to automatically reload its source and destination addresses and reset its byte counter to zero to repeat the last transfer when a previous one is finished.&lt;br /&gt;
&lt;br /&gt;
=== WR6 – Command Register ===&lt;br /&gt;
&amp;lt;pre&amp;gt;D7  D6  D5  D4  D3  D2  D1  D0  BASE REGISTER BYTE&lt;br /&gt;
 1   ?   ?   ?   ?   ?   1   1&lt;br /&gt;
     |   |   |   |   |&lt;br /&gt;
     1   0   0   0   0 = 0xC3 = Reset&lt;br /&gt;
     1   0   0   0   1 = 0xC7 = Reset Port A Timing&lt;br /&gt;
     1   0   0   1   0 = 0xCB = Reset Port B Timing&lt;br /&gt;
     0   1   1   0   0 = 0xB3 = Force Ready (irrelevant for zxnDMA)&lt;br /&gt;
     0   1   1   1   1 = 0xBF = Read Status Byte&lt;br /&gt;
     0   0   0   1   0 = 0x8B = Reinitialize Status Byte&lt;br /&gt;
     0   1   0   0   1 = 0xA7 = Initialize Read Sequence&lt;br /&gt;
     1   0   0   1   1 = 0xCF = Load&lt;br /&gt;
     1   0   1   0   0 = 0xD3 = Continue&lt;br /&gt;
     0   0   0   0   1 = 0x87 = Enable DMA&lt;br /&gt;
     0   0   0   0   0 = 0x83 = Disable DMA&lt;br /&gt;
 +-- 0   1   1   1   0 = 0xBB = Read Mask Follows&lt;br /&gt;
 |&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  READ MASK&lt;br /&gt;
 0   |   |   |   |   |   |   |&lt;br /&gt;
     |   |   |   |   |   |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  Status Byte&lt;br /&gt;
     |   |   |   |   |   |&lt;br /&gt;
     |   |   |   |   |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  Byte Counter Low (&amp;quot;High&amp;quot; with core 3.0.5 = bug in core)&lt;br /&gt;
     |   |   |   |   |&lt;br /&gt;
     |   |   |   |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  Byte Counter High (&amp;quot;Low&amp;quot; with core 3.0.5 = bug in core)&lt;br /&gt;
     |   |   |   |&lt;br /&gt;
     |   |   |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  Port A Address Low&lt;br /&gt;
     |   |   |&lt;br /&gt;
     |   |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  Port A Address High&lt;br /&gt;
     |   |&lt;br /&gt;
     |   V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  Port B Address Low&lt;br /&gt;
     |&lt;br /&gt;
     V&lt;br /&gt;
D7  D6  D5  D4  D3  D2  D1  D0  Port B Address High&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Unimplemented Z80 DMA commands are ignored.&lt;br /&gt;
&lt;br /&gt;
Prior to starting the DMA transfer, a LOAD command must be issued to copy the Port A and Port B addresses into the DMA&#039;s internal pointers. Then an &#039;Enable DMA&#039; command is issued to start the DMA. The last LOAD command before ENABLE must be done with correct transfer direction set.&lt;br /&gt;
&lt;br /&gt;
The &#039;Continue&#039; command resets the DMA&#039;s byte counter so that a following &#039;Enable DMA&#039; allows the DMA to repeat the last transfer but using the current internal address pointers. I.e. it continues from where the last copy operation left off.&lt;br /&gt;
&lt;br /&gt;
Reset and Reset Port A/B Timing commands on zxnDMA do reset also prescalar value.&lt;br /&gt;
&lt;br /&gt;
Registers can be read via an IO read from the DMA port after setting the read mask. (At power up the read mask is set to 0x7f). Register values are the current internal DMA counter values. So &#039;Port Address A Low&#039; is the lower 8-bits of Port A’s next transfer address. Once the end of the read mask is reached, further reads loop around to the first one.&lt;br /&gt;
&lt;br /&gt;
The format of the DMA status byte is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;00E1101T&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
E is set to 0 if the total block length has been transferred at least once.&lt;br /&gt;
&lt;br /&gt;
T is set to 1 if at least one byte has been transferred.&lt;br /&gt;
&lt;br /&gt;
== Operating speed ==&lt;br /&gt;
The zxnDMA operates at the same speed as the CPU, that is 3.5MHz, 7MHz, 14MHz or 28Mhz. This is a contended clock that is modified by the ULA and the auto-slowdown by [[Layer 2|Layer2]] (which only occurred in Next core&#039;s 1 and 2, the limitation was lifted in core 3.0).&lt;br /&gt;
&lt;br /&gt;
The (pre-core 3.0) auto-slowdown occurs without user intervention if speed exceeds 7Mhz and the active Layer2 display is being generated (higher speed operation resumes when the active Layer2 display is not generated). Programmers do NOT need to account for speed differences regarding DMA transfers as this happens automatically.&lt;br /&gt;
&lt;br /&gt;
Because of this, the cycle lengths for Ports A and B can be set to their minimum values without ill effects. The cycle lengths specified for Ports A and B are intended to selectively slow down read or write cycles for hardware that cannot operate at the DMA&#039;s full speed.&lt;br /&gt;
&lt;br /&gt;
== The DMA and Interrupts ==&lt;br /&gt;
The zxnDMA cannot currently generate [[Interrupts|interrupts]].&lt;br /&gt;
&lt;br /&gt;
The other side of this is that while the DMA controls the bus, the Z80 cannot respond to interrupts. On the Z80, the NMI interrupt is edge triggered so if an NMI occurs the fact that it occurred is stored internally in the Z80 so that it will respond when it is woken up. On the other hand, maskable interrupts are level triggered. That is, the Z80 must be active to regularly sample the /INT line to determine if a maskable interrupt is occurring. On the Spectrum and the ZX Next, the ULA (and line interrupt) are only asserted for a fixed amount of time ~30 cycles at 3.5MHz. If the DMA is executing a transfer while the interrupt is asserted, the CPU will not be able to see this and it will most likely miss the interrupt. In burst mode, with large-enough prescalar value, the CPU will never miss these interrupts, although this may change if multiple channels are implemented.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since core 3.1.8:&#039;&#039;&#039; the ability to interrupt DMA transfers was added, this is opt-in mechanism and must be configured through {{NextRegNo|$CC}}, {{NextRegNo|$CD}} and {{NextRegNo|$CE}} and requires [[hw im2 mode]] interrupts being set. Because interrupts are only sampled at the end of an instruction by the Z80, each time the dma is interrupted one instruction of progress is made in the main program (before the interrupt handler code is entered).&lt;br /&gt;
&lt;br /&gt;
This means after starting the DMA transfer with last `out` instruction you must follow it by N instructions which don&#039;t affect the transfer (don&#039;t remap source data memory, select different sprite/copper/... index if that&#039;s target of transfer, don&#039;t write anything to zxnDMA port), either doing different kind of work with CPU or adding block of `nop` instructions, to have non-interfering block of code available to fire N interrupts during transfer. Chose N to accommodate for worst case scenario of how many times you will interrupt the running DMA transfer. Or you can read state of zxnDMA to see if transfer did finish, but (IMHO by ped7g) in most cases it will be performance-cheaper to just add block of nop instructions or do other work on CPU not interfering with transfer.&lt;br /&gt;
&lt;br /&gt;
== Programming examples ==&lt;br /&gt;
A simple way to program the DMA is to walk down the list of registers WR0-WR5, sending desired settings to each. Then start the DMA by sending a LOAD command followed by an ENABLE_DMA command to WR6. Once more familiar with the DMA, you will discover that the amount of information sent can be reduced to what changes between transfers.&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
Short example program to DMA memory to the screen, then DMA a sprite image from memory to sprite RAM, and then showing said sprite scrolling across the screen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;;------------------------------------------------------------------------------&lt;br /&gt;
    ; sjasmplus extra options to enable Z80N, stricter syntax and Next device&lt;br /&gt;
    opt --zxnext --syntax=abf : device zxspectrumnext&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
;     DEFINE testing        ; uncomment to produce NEX file (instead of DOT)&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
; DMA (Register 6)&lt;br /&gt;
;&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
;zxnDMA programming example&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
;(c) Jim Bagley&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
DMA_RESET                      equ $c3&lt;br /&gt;
DMA_RESET_PORT_A_TIMING        equ $c7&lt;br /&gt;
DMA_RESET_PORT_B_TIMING        equ $cb&lt;br /&gt;
DMA_LOAD                       equ $cf ; %11001111&lt;br /&gt;
DMA_CONTINUE                   equ $d3&lt;br /&gt;
DMA_DISABLE_INTERUPTS          equ $af&lt;br /&gt;
DMA_ENABLE_INTERUPTS           equ $ab&lt;br /&gt;
DMA_RESET_DISABLE_INTERUPTS    equ $a3&lt;br /&gt;
DMA_ENABLE_AFTER_RETI          equ $b7&lt;br /&gt;
DMA_READ_STATUS_BYTE           equ $bf&lt;br /&gt;
DMA_REINIT_STATUS_BYTE         equ $8b&lt;br /&gt;
DMA_START_READ_SEQUENCE        equ $a7&lt;br /&gt;
DMA_FORCE_READY                equ $b3&lt;br /&gt;
DMA_DISABLE                    equ $83&lt;br /&gt;
DMA_ENABLE                     equ $87&lt;br /&gt;
DMA_WRITE_REGISTER_COMMAND     equ $bb&lt;br /&gt;
DMA_BURST                      equ %11001101&lt;br /&gt;
DMA_CONTINUOUS                 equ %10101101&lt;br /&gt;
ZXN_DMA_PORT                   equ $6b&lt;br /&gt;
SPRITE_STATUS_SLOT_SELECT      equ $303B&lt;br /&gt;
SPRITE_IMAGE_PORT              equ $5b&lt;br /&gt;
SPRITE_INFO_PORT               equ $57&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    IFDEF testing&lt;br /&gt;
        org $5800&lt;br /&gt;
        block 32*24, $38              ; default ULA attributes&lt;br /&gt;
        org $6000&lt;br /&gt;
    ELSE&lt;br /&gt;
        org $2000&lt;br /&gt;
    ENDIF&lt;br /&gt;
&lt;br /&gt;
start&lt;br /&gt;
    ld   hl,$0000&lt;br /&gt;
    ld   de,$4000&lt;br /&gt;
    ld   bc,$800&lt;br /&gt;
    call TransferDMA                  ; copy some random data to the screen pointing&lt;br /&gt;
                                      ; to ROM for now, for the purpose of showing &lt;br /&gt;
                                      ; how to do a DMA copy.&lt;br /&gt;
    ld   a,0                          ; sprite image number we want to update&lt;br /&gt;
    ld   bc,SPRITE_STATUS_SLOT_SELECT&lt;br /&gt;
    out  (c),a                        ; set the sprite image number&lt;br /&gt;
    ld   bc,1*256                     ; number to transfer (1)&lt;br /&gt;
    ld   hl,testsprite                ; from &lt;br /&gt;
    call TransferDMASprite            ; transfer to sprite ram&lt;br /&gt;
&lt;br /&gt;
    nextreg 21,1                      ; turn sprite on. for more info on this check &lt;br /&gt;
                                      ; out https://www.specnext.com/tbblue-io-port-system/&lt;br /&gt;
    ld   de,0&lt;br /&gt;
    ld   (xpos),de                    ; set initial X position ( doesn&#039;t need it for&lt;br /&gt;
                                      ; this demo, but if you run the .loop again it&lt;br /&gt;
                                      ; will continue from where it was&lt;br /&gt;
    ld   a,$20&lt;br /&gt;
    ld   (ypos),a                     ; set initial Y position&lt;br /&gt;
&lt;br /&gt;
.loop&lt;br /&gt;
    ld   a,0                          ; sprite number we want to position&lt;br /&gt;
    ld   bc,SPRITE_STATUS_SLOT_SELECT&lt;br /&gt;
    out  (c),a&lt;br /&gt;
    ld   de,(xpos)&lt;br /&gt;
    ld   hl,(ypos)                    ; ignores H so doing this rather than &lt;br /&gt;
                                      ; ld a,(ypos):ld l,a&lt;br /&gt;
    ld   bc,(image)                   ; not flipped or palette shifted&lt;br /&gt;
    call SetSprite&lt;br /&gt;
&lt;br /&gt;
    halt&lt;br /&gt;
&lt;br /&gt;
    ld   de,(xpos)&lt;br /&gt;
    inc  de&lt;br /&gt;
    ld   (xpos),de&lt;br /&gt;
    ld   a,d&lt;br /&gt;
    cp   $01&lt;br /&gt;
    jr   nz,.loop                     ; if high byte of xpos is not 1 (right of &lt;br /&gt;
                                      ; screen )&lt;br /&gt;
    ld   a,e&lt;br /&gt;
    cp   $20+1&lt;br /&gt;
    jr   nz,.loop                     ; if low byte is not $21 just off the right of&lt;br /&gt;
                                      ; the screen, $20 is off screen but as the &lt;br /&gt;
                                      ; INC DE is just above and not updated sprite&lt;br /&gt;
                                      ; after it, it needs to be $21&lt;br /&gt;
    xor  a&lt;br /&gt;
    ret                               ; return back to basic with OK&lt;br /&gt;
&lt;br /&gt;
xpos dw 0                             ; x position&lt;br /&gt;
ypos db 0                             ; y position&lt;br /&gt;
                                      ; these next two BITS and IMAGE are swapped &lt;br /&gt;
                                      ; as bits needs to go into B register&lt;br /&gt;
image db 0+$80                        ; use image 0 (for the image we transfered)&lt;br /&gt;
                                      ; +$80 to set the sprite to active&lt;br /&gt;
bits db 0                             ; not flipped or palette shifted&lt;br /&gt;
&lt;br /&gt;
c1 = %11100000&lt;br /&gt;
c2 = %11000000&lt;br /&gt;
c3 = %10100000&lt;br /&gt;
c4 = %10000000&lt;br /&gt;
c5 = %01100000&lt;br /&gt;
c6 = %01000000&lt;br /&gt;
c7 = %00100000&lt;br /&gt;
c8 = %00000000&lt;br /&gt;
&lt;br /&gt;
testsprite&lt;br /&gt;
    db c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1&lt;br /&gt;
    db c1,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c1&lt;br /&gt;
    db c1,c2,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c4,c4,c4,c4,c4,c4,c4,c4,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c5,c5,c5,c5,c5,c5,c5,c5,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c5,c6,c6,c6,c6,c6,c6,c5,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c5,c6,c7,c7,c7,c7,c6,c5,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c5,c6,c7,c8,c8,c7,c6,c5,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c5,c6,c7,c8,c8,c7,c6,c5,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c5,c6,c7,c7,c7,c7,c6,c5,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c5,c6,c6,c6,c6,c6,c6,c5,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c5,c5,c5,c5,c5,c5,c5,c5,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c4,c4,c4,c4,c4,c4,c4,c4,c4,c4,c3,c2,c1&lt;br /&gt;
    db c1,c2,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c2,c1&lt;br /&gt;
    db c1,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c1&lt;br /&gt;
    db c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1&lt;br /&gt;
&lt;br /&gt;
;-------------------------------------------------&lt;br /&gt;
; de = X&lt;br /&gt;
; l = Y&lt;br /&gt;
; b = bits&lt;br /&gt;
; c = sprite image&lt;br /&gt;
SetSprite&lt;br /&gt;
    push bc&lt;br /&gt;
    ld bc,SPRITE_INFO_PORT&lt;br /&gt;
    out (c),e ; Xpos&lt;br /&gt;
    out (c),l ; Ypos&lt;br /&gt;
    pop hl&lt;br /&gt;
    ld a,d&lt;br /&gt;
    and 1&lt;br /&gt;
    or h&lt;br /&gt;
    out (c),a&lt;br /&gt;
    ld a,l:or $80&lt;br /&gt;
    out (c),a ; image&lt;br /&gt;
    ret&lt;br /&gt;
&lt;br /&gt;
;--------------------------------&lt;br /&gt;
; hl = source&lt;br /&gt;
; de = destination&lt;br /&gt;
; bc = length&lt;br /&gt;
;--------------------------------&lt;br /&gt;
TransferDMA&lt;br /&gt;
    di&lt;br /&gt;
    ld (DMASource),hl&lt;br /&gt;
    ld (DMADest),de&lt;br /&gt;
    ld (DMALength),bc&lt;br /&gt;
    ld hl,DMACode&lt;br /&gt;
    ld b,DMACode_Len&lt;br /&gt;
    ld c,ZXN_DMA_PORT&lt;br /&gt;
    otir&lt;br /&gt;
    ei&lt;br /&gt;
    ret&lt;br /&gt;
&lt;br /&gt;
DMACode db DMA_DISABLE&lt;br /&gt;
        db %01111101                  ; R0-Transfer mode, A -&amp;gt; B, write adress &lt;br /&gt;
                                      ; + block length&lt;br /&gt;
DMASource dw 0                        ; R0-Port A, Start address &lt;br /&gt;
                                      ; (source address)&lt;br /&gt;
DMALength dw 0                        ; R0-Block length (length in bytes)&lt;br /&gt;
        db %01010100                  ; R1-write A time byte, increment, to &lt;br /&gt;
                                      ; memory, bitmask&lt;br /&gt;
        db %00000010                  ; 2t&lt;br /&gt;
        db %01010000                  ; R2-write B time byte, increment, to &lt;br /&gt;
                                      ; memory, bitmask&lt;br /&gt;
        db %00000010                  ; R2-Cycle length port B&lt;br /&gt;
        db DMA_CONTINUOUS             ; R4-Continuous mode (use this for block &lt;br /&gt;
                                      ; transfer), write dest adress&lt;br /&gt;
DMADest dw 0                          ; R4-Dest address (destination address)&lt;br /&gt;
        db %10000010                  ; R5-Restart on end of block, RDY active &lt;br /&gt;
                                      ; LOW&lt;br /&gt;
        db DMA_LOAD                   ; R6-Load&lt;br /&gt;
        db DMA_ENABLE                 ; R6-Enable DMA&lt;br /&gt;
        &lt;br /&gt;
DMACode_Len                    equ $-DMACode&lt;br /&gt;
&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
; hl = source&lt;br /&gt;
; bc = length&lt;br /&gt;
; set port to write to with TBBLUE_REGISTER_SELECT&lt;br /&gt;
; prior to call&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
TransferDMAPort&lt;br /&gt;
    di&lt;br /&gt;
    ld (DMASourceP),hl&lt;br /&gt;
    ld (DMALengthP),bc&lt;br /&gt;
    ld hl,DMACodeP&lt;br /&gt;
    ld b,DMACode_LenP&lt;br /&gt;
    ld c,ZXN_DMA_PORT&lt;br /&gt;
    otir&lt;br /&gt;
    ei&lt;br /&gt;
    ret&lt;br /&gt;
&lt;br /&gt;
DMACodeP db DMA_DISABLE&lt;br /&gt;
        db %01111101                  ; R0-Transfer mode, A -&amp;gt; B, write adress &lt;br /&gt;
                                      ; + block length&lt;br /&gt;
DMASourceP dw 0                       ; R0-Port A, Start address (source address)&lt;br /&gt;
DMALengthP dw 0                       ; R0-Block length (length in bytes)&lt;br /&gt;
        db %01010100                  ; R1-read A time byte, increment, to &lt;br /&gt;
                                      ; memory, bitmask&lt;br /&gt;
        db %00000010                  ; R1-Cycle length port A&lt;br /&gt;
        db %01101000                  ; R2-write B time byte, increment, to &lt;br /&gt;
                                      ; memory, bitmask&lt;br /&gt;
        db %00000010                  ; R2-Cycle length port B&lt;br /&gt;
        db %10101101                  ; R4-Continuous mode (use this for block &lt;br /&gt;
                                      ; transfer), write dest adress&lt;br /&gt;
        dw $253b                      ; R4-Dest address (destination address)&lt;br /&gt;
        db %10000010                  ; R5-Restart on end of block, RDY active&lt;br /&gt;
                                      ; LOW&lt;br /&gt;
        db DMA_LOAD                   ; R6-Load&lt;br /&gt;
        db DMA_ENABLE                 ; R6-Enable DMA&lt;br /&gt;
        &lt;br /&gt;
DMACode_LenP                   equ $-DMACodeP&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
; hl = source&lt;br /&gt;
; bc = length&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
TransferDMASprite&lt;br /&gt;
    di&lt;br /&gt;
    ld (DMASourceS),hl&lt;br /&gt;
    ld (DMALengthS),bc&lt;br /&gt;
    ld hl,DMACodeS&lt;br /&gt;
    ld b,DMACode_LenS&lt;br /&gt;
    ld c,ZXN_DMA_PORT&lt;br /&gt;
    otir&lt;br /&gt;
    ei&lt;br /&gt;
    ret&lt;br /&gt;
&lt;br /&gt;
DMACodeS db DMA_DISABLE&lt;br /&gt;
        db %01111101                   ; R0-Transfer mode, A -&amp;gt; B, write adress &lt;br /&gt;
                                       ; + block length&lt;br /&gt;
DMASourceS dw 0                        ; R0-Port A, Start address (source address)&lt;br /&gt;
DMALengthS dw 0                        ; R0-Block length (length in bytes)&lt;br /&gt;
        db %01010100                   ; R1-read A time byte, increment, to &lt;br /&gt;
                                       ; memory, bitmask&lt;br /&gt;
        db %00000010                   ; R1-Cycle length port A&lt;br /&gt;
        db %01101000                   ; R2-write B time byte, increment, to &lt;br /&gt;
                                       ; memory, bitmask&lt;br /&gt;
        db %00000010                   ; R2-Cycle length port B&lt;br /&gt;
        db %10101101                   ; R4-Continuous mode (use this for block&lt;br /&gt;
                                       ; transfer), write dest adress&lt;br /&gt;
        dw SPRITE_IMAGE_PORT           ; R4-Dest address (destination address)&lt;br /&gt;
        db %10000010                   ; R5-Restart on end of block, RDY active&lt;br /&gt;
                                       ; LOW&lt;br /&gt;
        db DMA_LOAD                    ; R6-Load&lt;br /&gt;
        db DMA_ENABLE                  ; R6-Enable DMA&lt;br /&gt;
DMACode_LenS                   equ $-DMACodeS&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
; de = dest, a = fill value, bc = lenth&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
DMAFill&lt;br /&gt;
    di&lt;br /&gt;
    ld (FillValue),a&lt;br /&gt;
    ld (DMACDest),de&lt;br /&gt;
    ld (DMACLength),bc&lt;br /&gt;
    ld hl,DMACCode&lt;br /&gt;
    ld b,DMACCode_Len&lt;br /&gt;
    ld c,ZXN_DMA_PORT&lt;br /&gt;
    otir&lt;br /&gt;
    ei&lt;br /&gt;
    ret&lt;br /&gt;
&lt;br /&gt;
FillValue db 22&lt;br /&gt;
DMACCode db DMA_DISABLE&lt;br /&gt;
        db %01111101&lt;br /&gt;
DMACSource dw FillValue&lt;br /&gt;
DMACLength dw 0&lt;br /&gt;
        db %00100100,%00010000,%10101101&lt;br /&gt;
DMACDest dw 0&lt;br /&gt;
        db DMA_LOAD,DMA_ENABLE&lt;br /&gt;
DMACCode_Len equ $-DMACCode&lt;br /&gt;
&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
; End of file&lt;br /&gt;
;------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    IFDEF testing&lt;br /&gt;
        savenex open &amp;quot;DMAtest.nex&amp;quot;, start, $FF00&lt;br /&gt;
        savenex bank 5&lt;br /&gt;
    ELSE&lt;br /&gt;
fin&lt;br /&gt;
        savebin &amp;quot;DMATEST&amp;quot;,start,fin-start&lt;br /&gt;
    ENDIF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Based on original text by: Allen Albright &amp;amp; Mike Dailly with input by Jim Bagley, Lyndon J Sharp and Phoebus R. Dokos&lt;br /&gt;
&lt;br /&gt;
== Technical details (core 3.1.3+)  ==&lt;br /&gt;
&lt;br /&gt;
The Zilog/zxnDMA mode is now selected by using the particular I/O port number ({{PortNo|$xx6B}} for zxnDMA mode, {{PortNo|$xx0B}} for Zilog mode). The bit 6 in {{NextRegNo|$06}} is not DMA related any more and will be reused for something different.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;counter&amp;quot; RR1-RR2 read back after transfer has correct byte order since core 3.1.4.&lt;br /&gt;
&lt;br /&gt;
Other differences described below in &amp;quot;3.0.5&amp;quot; remains (but from practical point of view the Zilog DMA emulation in 3.1.4 is near-perfect, all the remaining differences are very minor).&lt;br /&gt;
&lt;br /&gt;
== Technical details (core 3.0.5)  ==&lt;br /&gt;
&lt;br /&gt;
=== Zilog DMA compatibility mode ===&lt;br /&gt;
In Zilog DMA compatibility mode (bit 6 of {{NextRegNo|$06}}) the zxnDMA will mostly work as expected, but there are few differences in behaviour which may eventually throw off some rare SW, here is the list of the known differences (most of them describe also how the zxnDMA mode works):&lt;br /&gt;
&lt;br /&gt;
The LOAD command must be issued with correct transfer direction, loading addresses in opposite direction and flipping direction afterward will mismatch the source/destination address data (Zilog/UA858D DMA chips are also sensitive to direction flip after LOAD, but the resulting transfer quirks in different way, reading source data byte after write, offsetting whole transfer by one and damaging start/end of sequence).&lt;br /&gt;
(does apply also to zxnDMA mode)&lt;br /&gt;
&lt;br /&gt;
The LOAD command will NOT destroy the already issued &amp;quot;Initialize Read Sequence&amp;quot; - this is how even the original Zilog documentation describes the DMA chip operation, but the real Zilog DMA and UA858D (clone chip) both destroy read sequence upon LOAD command (zxnDMA is better).&lt;br /&gt;
(does apply also to zxnDMA mode)&lt;br /&gt;
&lt;br /&gt;
The content of registers read back after finished transfer differs: the counter has swapped LSB with MSB byte, and both addresses will be adjusted length+1 times (Zilog/UA858D will return destination address adjusted only length-many times).&lt;br /&gt;
(does apply also to zxnDMA mode, except addresses are adjusted only &amp;quot;length&amp;quot; times of course, counter has still swapped bytes)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;del&amp;gt;Any read of zxnDMA port without pending read request (commands &amp;quot;Read Status Byte&amp;quot; or &amp;quot;Initialize Read Sequence&amp;quot;) will return status byte (Zilog will return random value vaguely similar to status byte, but incorrect, UA858D will return zero).&lt;br /&gt;
(does apply also to zxnDMA mode)&amp;lt;/del&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
2026-03-30: any read of zxnDMA port without pending read request will return next byte in read sequence, the default read mask is 0x7F after power on (based on reading the VHDL, needs to verify with HW).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;del&amp;gt;Status byte doesn&#039;t have bit 0 set (the &amp;quot;T&amp;quot; bit in description above).&lt;br /&gt;
(does apply also to zxnDMA mode)&amp;lt;/del&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
2026-03-30: going by [https://gitlab.com/SpectrumNext/ZX%20Spectrum%20Next%20FPGA/-/blob/master/cores/zxnext/src/device/dma.vhd?ref%20type=heads VHDL source] this seems to be now fixed, needs to verify with HW and guess in which version of core this was fixed&lt;br /&gt;
&lt;br /&gt;
The command 0xBB setting read mask will cause implicit 0xA7 Initialize Read Sequence.&lt;br /&gt;
(does apply also to zxnDMA mode)&lt;br /&gt;
&lt;br /&gt;
The command 0xA7 does initialize read sequence even when the previous sequence was only partially read (ZX Next FPGA implementation for both zxnDMA and Zilog-DMA) and there were more bytes pending. According to Zilog documentation the original Zilog DMA is claimed to ignore 0xA7 command in such case. Needs verification on HW to be fully confirmed, especially the original Zilog chip, this looks a bit unlikely, it would make lot more sense to abort current sequence and reset it.&lt;br /&gt;
&lt;br /&gt;
Be aware that both custom timing cycles count, and prescalar values are preserved in zxnDMA even when future write to WR1/WR2 does skip these particular bytes. To reset prescalar or cycles timing, write explicitly zero into prescalar register or use commands reset/reset-port-timing.&lt;br /&gt;
(does apply also to zxnDMA mode, the prescalar works only in zxnDMA mode)&lt;br /&gt;
&lt;br /&gt;
The destination port address is LOAD-ed even when it is &amp;quot;fixed&amp;quot; type (Contrary to Zilog DMA, which requires you to load such port as &amp;quot;source&amp;quot;, flip the direction after and re-LOAD again with correct direction. UA858D chip does also load destination port address in any case, just like zxnDMA).&lt;br /&gt;
(does apply also to zxnDMA mode)&lt;br /&gt;
&lt;br /&gt;
=== zxnDMA mode vs Zilog mode ===&lt;br /&gt;
&lt;br /&gt;
In zxnDMA mode length of transfer is equal to the length written to WR0 register, port addresses are adjusted also only length-times.&lt;br /&gt;
&lt;br /&gt;
Prescalar value will affect speed of transfer (use zero to switch prescalar off) (in burst mode during the extra idle time the CPU receives control back and can execute further instructions, in continuous mode the transfer will keep blocking CPU even when &amp;quot;slow&amp;quot; transfer is being done).&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Interrupt_Status_1_Register&amp;diff=41888</id>
		<title>Interrupt Status 1 Register</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Interrupt_Status_1_Register&amp;diff=41888"/>
		<updated>2026-04-11T19:18:44Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: linking hw im2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NextRegister&lt;br /&gt;
|Number=$C9&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=Yes&lt;br /&gt;
|ShortDesc=has ctc interrupt occurred?&lt;br /&gt;
}}&lt;br /&gt;
  bit 7 = ctc channel 7 zc/to&lt;br /&gt;
  bit 6 = ctc channel 6 zc/to&lt;br /&gt;
  bit 5 = ctc channel 5 zc/to&lt;br /&gt;
  bit 4 = ctc channel 4 zc/to&lt;br /&gt;
  bit 3 = ctc channel 3 zc/to&lt;br /&gt;
  bit 2 = ctc channel 2 zc/to&lt;br /&gt;
  bit 1 = ctc channel 1 zc/to&lt;br /&gt;
  bit 0 = ctc channel 0 zc/to&lt;br /&gt;
* (R) Set bits indicate the device generated an interrupt in the past or an interrupt is pending&lt;br /&gt;
* (W) Set bits clear the status.  In [[hw im2 mode]] the status will continue to read as set until the interrupt pending condition is cleared&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Interrupt_Status_2_Register&amp;diff=41887</id>
		<title>Interrupt Status 2 Register</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Interrupt_Status_2_Register&amp;diff=41887"/>
		<updated>2026-04-11T19:18:16Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: linking hw im2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NextRegister&lt;br /&gt;
|Number=$CA&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=Yes&lt;br /&gt;
|ShortDesc=Has UART interrupt happened?&lt;br /&gt;
}}&lt;br /&gt;
 bit 7 = Reserved must be zero&lt;br /&gt;
  bit 6 = UART1 Tx empty&lt;br /&gt;
  bit 5 = UART1 Rx half full    \ shared&lt;br /&gt;
  bit 4 = UART1 Rx available    / interrupt&lt;br /&gt;
  bit 3 = Reserved must be zero&lt;br /&gt;
  bit 2 = UART0 Tx empty&lt;br /&gt;
  bit 1 = UART0 Rx half full    \ shared&lt;br /&gt;
  bit 0 = UART0 Rx available    / interrupt&lt;br /&gt;
* (R) Set bits indicate the device generated an interrupt in the past or an interrupt is pending&lt;br /&gt;
* (W) Set bits clear the status.  In [[hw im2 mode]] the status will continue to read as set until the interrupt pending condition is cleared&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41886</id>
		<title>Hw im2 mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41886"/>
		<updated>2026-04-11T19:17:36Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: how to enable&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;hw im2 mode is enabled by the bit 0 of {{NextRegNo|$C0}}.&lt;br /&gt;
&lt;br /&gt;
If not in hw im2 mode, ie normal spectrum behaviour, then all devices that generate an interrupt do it by asserting /int low for around 30 cycles and that&#039;s it.&lt;br /&gt;
&lt;br /&gt;
If you are in hw im2 mode, then all interrupting devices including the ula has an im2 state machine attached.  If an interrupt is generated, the state machine remembers this as it moves to an assert /int state.   Recognition of RETI for the specific device moves the state machine to a place where another /int from the device can be accepted. &lt;br /&gt;
&lt;br /&gt;
For recognition of RETI:  &lt;br /&gt;
&lt;br /&gt;
reti instruction has been detected active in T3 for rising edge of T4 &lt;br /&gt;
&lt;br /&gt;
so on rising edge of T4, the hw will move to a state where it will see a new int event from the device.  /int events are edge detected so you can&#039;t hold /int low forever and keep generating interrupts.&lt;br /&gt;
&lt;br /&gt;
That does mean, eg, that if multiple events occur while the isr still hasn&#039;t executed RETI then you&#039;re not going to see more than the one current int.  If the dma is taking a long time, multiple ctc ints on a channel only generates one channel interrupt when the dma ultimately gives up the bus.  If you have the ctc interrupting  dma op, then you&#039;ll see them all most likely&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Interrupt_Status_0_Register&amp;diff=41885</id>
		<title>Interrupt Status 0 Register</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Interrupt_Status_0_Register&amp;diff=41885"/>
		<updated>2026-04-11T19:15:23Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: linking hw im2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NextRegister&lt;br /&gt;
|Number=$C8&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=Yes&lt;br /&gt;
|ShortDesc=has interrupt occurred?&lt;br /&gt;
}}&lt;br /&gt;
  bits 7:2 = Reserved must be 0&lt;br /&gt;
  bit 1 = Line&lt;br /&gt;
  bit 0 = ULA&lt;br /&gt;
* (R) Set bits indicate the device generated an interrupt in the past or an interrupt is pending&lt;br /&gt;
* (W) Set bits clear the status.  In [[hw im2 mode]] the status will continue to read as set until the interrupt pending condition is cleared&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=DMA_interrupt_enable_0&amp;diff=41884</id>
		<title>DMA interrupt enable 0</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=DMA_interrupt_enable_0&amp;diff=41884"/>
		<updated>2026-04-11T19:14:43Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: linking hw im2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NextRegister&lt;br /&gt;
|Number=$CC&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=Yes&lt;br /&gt;
|ShortDesc=Interrupts that can override DMA&lt;br /&gt;
}}&lt;br /&gt;
  bit 7 = NMI&lt;br /&gt;
  bit 1 = Line&lt;br /&gt;
  bit 0 = ULA&lt;br /&gt;
* Set bits indicate the corresponding interrupt will interrupt a dma operation when in [[hw im2 mode]]&lt;br /&gt;
&lt;br /&gt;
Soft reset = 0x00&lt;br /&gt;
&lt;br /&gt;
Because interrupts are only sampled at the end of an instruction by the Z80, each time the dma is interrupted one instruction of progress is made in the main program.&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41883</id>
		<title>Hw im2 mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Hw_im2_mode&amp;diff=41883"/>
		<updated>2026-04-11T19:12:47Z</updated>

		<summary type="html">&lt;p&gt;Johnnyo: added page, content from the AA&amp;#039;s explanation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If not in hw im2 mode, ie normal spectrum behaviour, then all devices that generate an interrupt do it by asserting /int low for around 30 cycles and that&#039;s it.&lt;br /&gt;
&lt;br /&gt;
If you are in hw im2 mode, then all interrupting devices including the ula has an im2 state machine attached.  If an interrupt is generated, the state machine remembers this as it moves to an assert /int state.   Recognition of RETI for the specific device moves the state machine to a place where another /int from the device can be accepted. &lt;br /&gt;
&lt;br /&gt;
For recognition of RETI:  &lt;br /&gt;
&lt;br /&gt;
reti instruction has been detected active in T3 for rising edge of T4 &lt;br /&gt;
&lt;br /&gt;
so on rising edge of T4, the hw will move to a state where it will see a new int event from the device.  /int events are edge detected so you can&#039;t hold /int low forever and keep generating interrupts.&lt;br /&gt;
&lt;br /&gt;
That does mean, eg, that if multiple events occur while the isr still hasn&#039;t executed RETI then you&#039;re not going to see more than the one current int.  If the dma is taking a long time, multiple ctc ints on a channel only generates one channel interrupt when the dma ultimately gives up the bus.  If you have the ctc interrupting  dma op, then you&#039;ll see them all most likely&lt;/div&gt;</summary>
		<author><name>Johnnyo</name></author>
	</entry>
</feed>