<?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=Julian+S</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=Julian+S"/>
	<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/Special:Contributions/Julian_S"/>
	<updated>2026-05-23T06:57:45Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Palettes&amp;diff=1297</id>
		<title>Palettes</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Palettes&amp;diff=1297"/>
		<updated>2019-05-03T18:59:41Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To increase the number of available colours on screen, the Spectrum Next supports palletized colours. &lt;br /&gt;
&lt;br /&gt;
Colour IDs in [[Layer 2]], [[Tilemap]] and [[Sprites]] are always taken as palette indices. Colour values in the ULA are mapped to the palette as fixed indices, or can be taken as partial palette indices if Enhanced ULA mode is enabled. The palette entry numbers for standard ULA mode are: 0-7 for the standard ink colors, 8-15 for BRIGHT ink colors, 128-135 for standard paper and border colors, and 136-143 for BRIGHT paper colors.&lt;br /&gt;
&lt;br /&gt;
Palette configuration can be done through registers $40-$44 and $6B. {{NextRegNo|$43}} sets which palette is being set up. There are two palettes each for Layer 2, Sprites, Tilemap and ULA; which one of the two is used for each is selected using the lower bits of {{NextRegNo|$43}} and in {{NextRegNo|$6B}}.&lt;br /&gt;
&lt;br /&gt;
Once a palette is selected, {{NextRegNo|$40}} sets the palette entry number to set up; you can then send the color to set it to on {{NextRegNo|$41}} &#039;&#039;or&#039;&#039; {{NextRegNo|$44}} which then auto-increment. $41 is used for sending 8-bit colours in RRRGGGBB format; the &amp;quot;missing&amp;quot; third blue bit is set to an OR between the other two. $44 is used for sending 9-bit colours in two byte packets; the first byte sent should be RRRGGGBB as with $41, and the second byte&#039;s LSB fills in the third blue bit. For Layer 2 color the top bit in second byte signals &amp;quot;priority&amp;quot; colour, which makes particular Layer 2 pixel to be drawn on top of everything else, overriding current order of layers.&lt;br /&gt;
&lt;br /&gt;
With Enhanced ULA mode enabled, the {{NextRegNo|$42}} defines how particular ULA attribute breaks into INK and PAPER color. The INK colors are mapped from index 0 in palette, PAPER (and BORDER) colors are mapped from index 128, except when in &amp;quot;full ink&amp;quot; mode (ink mask = 255), then PAPER and BORDER color is taken from {{NextRegNo|$4A}}.&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Tilemap&amp;diff=1296</id>
		<title>Tilemap</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Tilemap&amp;diff=1296"/>
		<updated>2019-05-03T18:55:23Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Tilemap ==&lt;br /&gt;
&lt;br /&gt;
A screen mode similar to hardware text linked to the ULA modes which allows for either 40x32 or 80x32 16-colour 8x8 tiles.&lt;br /&gt;
&lt;br /&gt;
The tilemap is enabled using Nextreg $6B (107) Tilemap Control&lt;br /&gt;
&lt;br /&gt;
  bit 7: 0=disable tilemap, 1=enable tilemap&lt;br /&gt;
  bit 6: 0=40x32, 1=80x32&lt;br /&gt;
  bit 5: 0=attributes in tilemap, 1=no attributes in tilemap&lt;br /&gt;
  bit 4: 0=primary palette, 1=secondary palette&lt;br /&gt;
  bits 3-2: reserved (0)&lt;br /&gt;
  bit 1: 0=256 tile mode, 1=512 tile mode&lt;br /&gt;
  bit 0: 1=tilemap over ULA&lt;br /&gt;
&lt;br /&gt;
The tilemap consists of two data areas: tile descriptions and an actual tilemap; both of which are located in 16k page 5&lt;br /&gt;
&lt;br /&gt;
=== Tile Description ===&lt;br /&gt;
&lt;br /&gt;
The tile description area is a contiguous list of tile descriptions starting at the location indicated by bits 5-0 of the value in Nextreg $6F (111) Tile Definitions Base Address.&lt;br /&gt;
&lt;br /&gt;
Each tile description is a 32 byte block of 4-bit values describing the indices of each pixel of a tile in row major order.&lt;br /&gt;
&lt;br /&gt;
=== Tilemap ===&lt;br /&gt;
&lt;br /&gt;
The tilemap begins at the location stored in bits 5-0 of Nextreg $6E (110) Tilemap Base Address.&lt;br /&gt;
&lt;br /&gt;
This map either consists of either pairs of tile numbers and tile attributes, or a list of tile numbers. If no attributes are present (bit 5 of Nextreg $6B=1) then the attributes for all tiles come from Nextreg $6C (108) Default Tilemap Attribute.&lt;br /&gt;
&lt;br /&gt;
==== Tile Attribute ====&lt;br /&gt;
&lt;br /&gt;
  bits 7-4: palette offset&lt;br /&gt;
  bit 3: mirror X&lt;br /&gt;
  bit 2: mirror Y&lt;br /&gt;
  bit 1: Rotate&lt;br /&gt;
  bit 0: In 256-tile mode ULA over tilemap, in 512-tile mode bit 8 of tile number&lt;br /&gt;
&lt;br /&gt;
=== Additional Registers ===&lt;br /&gt;
&lt;br /&gt;
Nextreg $1B (27) Clip Window Tilemap&lt;br /&gt;
  bits 7-0: Coord. of the clip window&lt;br /&gt;
  1st write = X1 position&lt;br /&gt;
  2nd write = X2 position&lt;br /&gt;
  3rd write = Y1 position&lt;br /&gt;
  4rd write = Y2 position&lt;br /&gt;
  The values are 0,159,0,255 after a Reset&lt;br /&gt;
  Reads do not advance the clip position&lt;br /&gt;
&lt;br /&gt;
Nextreg $2F (47) Tilemap Offset X MSB&lt;br /&gt;
  bits 7-2: Reserved (0)&lt;br /&gt;
  bits 1-0: MSB X Offset&lt;br /&gt;
  Meaningful Range is 0-319 in 40 char mode, 0-639 in 80 char mode&lt;br /&gt;
&lt;br /&gt;
Nextreg $30 (48) Tilemap Offset X LSB&lt;br /&gt;
  bits 7-0: LSB X Offset&lt;br /&gt;
  Meaningful range is 0-319 in 40 char mode, 0-639 in 80 char mode&lt;br /&gt;
&lt;br /&gt;
Nextreg $31 (49) Tilemap Offset Y&lt;br /&gt;
  bits 7-0: Y Offset (0-191)&lt;br /&gt;
&lt;br /&gt;
Nextreg 43 (67) Palette Control&lt;br /&gt;
  bit 7: &#039;1&#039; to disable palette write auto-increment.&lt;br /&gt;
  bits 6-4: Select palette for reading or writing:&lt;br /&gt;
     000 = ULA first palette&lt;br /&gt;
     100 = ULA second palette&lt;br /&gt;
     001 = Layer 2 first palette&lt;br /&gt;
     101 = Layer 2 second palette&lt;br /&gt;
     010 = Sprites first palette &lt;br /&gt;
     110 = Sprites second palette&lt;br /&gt;
     011 = Tilemap first palette&lt;br /&gt;
     111 = Tilemap second palette&lt;br /&gt;
  bit 3: Select Sprites palette (0 = first palette, 1 = second palette)&lt;br /&gt;
  bit 2: Select Layer 2 palette (0 = first palette, 1 = second palette)&lt;br /&gt;
  bit 1: Select ULA palette (0 = first palette, 1 = second palette)&lt;br /&gt;
  bit 0: Enable Enhanced ULA mode if 1 (0 after a reset)&lt;br /&gt;
&lt;br /&gt;
Nextreg $68 (104) ULA Control&lt;br /&gt;
  bit 7: 1 to disable ULA output&lt;br /&gt;
  bit 6: 0=select the ULA colour for blending in SLU modes 6 &amp;amp; 7&lt;br /&gt;
         1=select the ULA/tilemap mix for blending in SLU modes 6 &amp;amp; 7&lt;br /&gt;
  bits 5-1: Reserved (0)&lt;br /&gt;
  bit 0: 1=enable stencil mode when both the ULA and tilemap are enabled&lt;br /&gt;
            (if either are transparent the result is transparent otherwise the&lt;br /&gt;
             result is a logical AND of both colours)&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Video_Modes&amp;diff=1295</id>
		<title>Video Modes</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Video_Modes&amp;diff=1295"/>
		<updated>2019-05-03T18:53:29Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The ULA is the Spectrum video and input chip. The Enhanced ULA adds extra video modes and features to the standard Spectrum.&lt;br /&gt;
&lt;br /&gt;
ULA stands for &amp;quot;Uncommitted Logic Array&amp;quot; and refers to the manufacturing process involved. It does not relate to the video behavior of the chip. The chip itself is a custom chip.&lt;br /&gt;
&lt;br /&gt;
= Spectrum Video Mode =&lt;br /&gt;
The standard Spectrum has only one video mode, with a resolution of 256x192 (not including the border) and 15 colours. This screen is further divided into 8x8 &amp;quot;attribute cells&amp;quot;, so the attribute cell resolution is 32x24.&lt;br /&gt;
&lt;br /&gt;
The ULA reads memory from [[Memory map|16k-Bank 5]] or [[Memory map|16k-Bank 7]] based on the setting at {{PortNo|$7FFD}}. If you haven&#039;t done any fancy messing about with the memory map, or you&#039;re using Spectrum 48k mode, then the screen memory will start at $4000.&lt;br /&gt;
&lt;br /&gt;
There is one bit per pixel, so each byte represents 8 pixels (ie, one line of an attribute cell). Each screen line is stored in straightforward left-to-right order, so the 32 bytes from $4000 onwards represent all the pixels on the first line of the screen. Each 1 bit means the pixel is drawn in the &amp;quot;ink&amp;quot; color; a 0 bit means it is drawn in the &amp;quot;paper&amp;quot; color. Which colors these are is specified in the attribute blocks described below.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, while the columns of the screen are in straightforward order, the &#039;&#039;lines&#039;&#039; are not. The 192 line screen is vertically divided into thirds, with each third containing 64 lines (or 8 attribute cells). These three thirds are stored sequentially in memory, but &#039;&#039;within&#039;&#039; each third, the order is not what you&#039;d expect. You&#039;d expect it&#039;d store the first line of the first cell, the second line of the first cell.. up to the eighth line of the first cell, then the first line of the second cell. Instead, the sorting is &#039;&#039;inverted&#039;&#039;. So it stores the first line of the first cell, then the &#039;&#039;first line of the second cell&#039;&#039;, then the first line of the third cell, and so on.. up to the first line of the eighth cell, which is then followed by the second line of the first cell!&lt;br /&gt;
&lt;br /&gt;
This means that getting the address of the start of a given line can be a tricky business. The Spectrum Next provides the [[Extended Z80 instruction set|PIXELAD]] opcode to automatically perform the necessary transition. It can be done manually by breaking the line number (0-191) into bits as described below. &lt;br /&gt;
&lt;br /&gt;
[[File:Ktclash.png|200px|thumb|left|Color clash in a classic spectrum game. The corners of the knight&#039;s helmet appear green and red because they are in the same attribute cell as the plant and table respectively.]]&lt;br /&gt;
Pixel data is stored with 1-bit color in the pixel data memory. However, it is possible for the color to vary across the screen. The snag is that you can set only two colours within a single &#039;&#039;attribute cell&#039;&#039; - that is, an 8x8 area. Because you can have only one color value per 8x8 cell, some older games exhibited &amp;quot;color clash&amp;quot; in which an object or part of an object would appear the wrong color because it needed to be drawn inside an 8x8 cell with another object of a different color.&lt;br /&gt;
&lt;br /&gt;
Color data is stored at $5800 onwards. Unlike the pixel data, it&#039;s stored in straightforward reading order, with one byte per attribute cell, for a total of 768 bytes. The byte represents:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bit !! Function&lt;br /&gt;
|-&lt;br /&gt;
| 0-2 || &amp;quot;Ink&amp;quot; color (color of 1 bits). From 0-7: black, blue, red, magenta, green, cyan, yellow, white. &lt;br /&gt;
|-&lt;br /&gt;
| 3-5 || &amp;quot;Paper&amp;quot; color (color of 0 bits).&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Bright flag (toggles brighter version of both colors). &lt;br /&gt;
|-&lt;br /&gt;
| 7 || Flash flag (toggles regular alternation of ink and paper colors)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If Enhanced ULA is enabled, then this no longer applies; see below.&lt;br /&gt;
&lt;br /&gt;
== Calculating line addresses in interleaved video modes ==&lt;br /&gt;
&lt;br /&gt;
The line number can be broken down into bits as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! 128 !! 64 !! 32 !! 16 !! 8 !! 4 !! 2 !! 1&lt;br /&gt;
|-&lt;br /&gt;
| 3rd || 3rd || V-Cell || V-Cell || V-Cell || Offset || Offset || Offset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each 3rd is 64 lines, so the top two bits of the line number indicate which 3rd we&#039;re in, with the highest being %10 for 128 (%11 would be 192, off the bottom of the screen). Then, each cell is 8 lines, so bits 3-5 of the line number give the cell address, and the remaining bits give the line within that cell.&lt;br /&gt;
&lt;br /&gt;
The thirds are stored in sequential order; each third contains 64 lines; and storing a line takes 32 bytes. This means each 3rd takes 2048 bytes, so the &amp;quot;which 3rd&amp;quot; number is multiplied by 2048. Add $4000 for the start of the screen and that&#039;ll give the address of the start of the target third. Now we need to get to the block for the correct line number. To store the top line of a single row of cells takes 32 bytes; but since all the top lines for 8 cells are stored together, there&#039;s actually 256 bytes (32*8) between lines. So the line number must be multiplied by 256 and added to the address. Then, to select the correct cell within that block, the cell number needs to be multiplied by 32 (because each line takes 32 bytes). So the final 16-bit address is:&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! 32768 !! 16384 !! 8192 !! 4096 !! 2048 !! 1024   !! 512    !! 256    !! 128 !! 64 !! 32 !! 16 !! 8 !! 4 !! 2 !! 1&lt;br /&gt;
|-&lt;br /&gt;
| 0     || 1     ||    0 || 3rd  || 3rd  || Offset || Offset || Offset || V-Cell || V-Cell || V-Cell || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The five lowest bits of this value are then used to select between the 32 horizontal cells on that line, which is simply done by dividing the pixel address by 8.&lt;br /&gt;
&lt;br /&gt;
= Enhanced video modes =&lt;br /&gt;
The Next adds a number of additional video modes to the standard ULA.&lt;br /&gt;
&lt;br /&gt;
== Timex Sinclair Double Buffering ==&lt;br /&gt;
Writing %001 to the lower 3 bits of {{PortNo|$xxFF}} will change the accessed base screen address to $6000 instead of $4000 (or otherwise add $2000 to the accessed true address, moving it into the second half of the appropriate 16k-bank or the next 8k-bank). Writing %000 restores the normal base screen address. This allows this area of memory to be used for a &amp;quot;double buffer&amp;quot; for smooth frame transitions. Note however that the Spectrum 128k&#039;s bank switching also allows double buffering (see [[Memory map]]) which can be combined with this - although the 128K modes CANNOT be used with Layer 2 due to sharing BRAM in the FPGA.&lt;br /&gt;
&lt;br /&gt;
== Timex Sinclair Hi-Res Mode ==&lt;br /&gt;
Writing %110 to the lower 3 bits of {{PortNo|$xxFF}} will change the screen resolution to 512x192, doubling the X resolution. This still uses the Double Buffer structure of one set of screen data at $4000 and another at $6000, but now columns (one column = one byte = 8 pixels) are alternately read from the two buffers to account for the higher resolution. In addition, attributes are disabled: this mode supports only two colors. Which they are can be set by writing bits 3-5 of {{PortNo|$xxFF}}.&lt;br /&gt;
&lt;br /&gt;
== Timex Sinclair Hi-Color Mode ==&lt;br /&gt;
Writing %010 to the lower 3 bits of {{PortNo|$xxFF}} will disable the standard attribute area. Instead, the attribute area is set to begin at $6000 and to have the same interleaved structure as the pixel data. Each attribute byte is now applied to only one &#039;&#039;line&#039;&#039; of each cell, rather than the whole cell. The storage structure matches that of the pixel data (including the weird interleaving). This means that the areas of color clash are now limited to 8x1 blocks instead of 8x8 blocks.&lt;br /&gt;
 &lt;br /&gt;
== LoRes Layer/Radasjimian Mode ==&lt;br /&gt;
LoRes Layer is a mode similar to the &amp;quot;Radastanian Mode&amp;quot; on the ZXUno, in that it offers reduced resolution in exchange for more colors. LoRes Layer allows any of 256 colors anywhere on the screen, but lowers the resolution in both dimensions to 128x96.&lt;br /&gt;
&lt;br /&gt;
LoRes layer is enabled by setting bit 7 in {{NextRegNo|$15}}. Each pixel is assigned one byte, in reading order (without interleaving). The first 48 lines are stored between $4000 and $5800, and the second 48 between $6000 and $7800. Each byte is an index into the ULA palette.&lt;br /&gt;
&lt;br /&gt;
== Enhanced ULA ==&lt;br /&gt;
&lt;br /&gt;
The Spectrum Next comes with Enhanced ULA which allows the standard Spectrum graphics to display 256 colours on the screen at once. It uses the system [[Palettes]] in the same way as [[Sprites]] and [[Layer 2]].&lt;br /&gt;
&lt;br /&gt;
Setting bit 0 of {{NextRegNo|$43}} enables the Enhanced ULA mode. In this mode, the breakdown of Ink/Paper/FLASH/BRIGHT bits in the attribute cells given above is ignored. Instead, the bit value written to {{NextRegNo|$42}} is used as a bitmask to determine which bits are used for the ink color palette index (it must mask off a number of bits on the LSB side, eg %00111111, so not %01010101 or anything silly like that!) and the remaining bits, with 128 added, are used for the paper color palette index. The mask %11111111, to treat &#039;&#039;all&#039;&#039; bits as ink, is legal; if used the paper color in every cell will be color 128. The mask %00000000 to treat all bits as paper is not legal.&lt;br /&gt;
&lt;br /&gt;
= Additional features =&lt;br /&gt;
In addition to the Enhanced ULA, the Spectrum Next adds [[Sprites]], [[Layer 2]] and a [[Tilemap]] which are not ULA controlled.&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Extended_Z80_instruction_set&amp;diff=1294</id>
		<title>Extended Z80 instruction set</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Extended_Z80_instruction_set&amp;diff=1294"/>
		<updated>2019-05-03T18:45:45Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This is a general list of Z80 instructions with descriptions. For summaries, you can view the [[Z80 Instruction Table]]. You can also [[Special:RunQuery/OpcodeQuery|search for opcodes]].&lt;br /&gt;
&lt;br /&gt;
=== Term references ===&lt;br /&gt;
* &#039;&#039;Any 8-bit register&#039;&#039; means A, B, C, D, E, H, and L. F, I and R do not count even though they are technically 8 bit registers. Also, the high and low bytes of IX and IY (IXH, IXL, IYH, IYL) can be used as 8-bit registers although this behavior was undocumented on the original Z80.&lt;br /&gt;
* IXY means IX or IY.&lt;br /&gt;
* For the status field:&lt;br /&gt;
** S means Standard. It&#039;s in the Z80 manual. Everything should support it.&lt;br /&gt;
** U means Undocumented. It works on Z80 chips, but it&#039;s not in the manual. These have been known for years and were acknowledged by Zilog, so they should work on everything, but some assemblers may vary the syntax.&lt;br /&gt;
** E means Extension. It &#039;&#039;only&#039;&#039; works on the Z80 core on the Next. It&#039;ll probably only be accepted by assemblers that have been updated specifically for the Next.&lt;br /&gt;
* Each of the flag effects is documented as follows:&lt;br /&gt;
** - means the flag is unchanged.&lt;br /&gt;
** 1 or 0 mean the flag is set or reset as appropriate.&lt;br /&gt;
** ? means we don&#039;t know what effect the instruction has on the flag.&lt;br /&gt;
** ! means the instruction has an unusual effect on the flag which is documented in the description.&lt;br /&gt;
** S means the effect on the flag is &amp;quot;standard&amp;quot;. C is set if a carry/borrow occurred beyond the MSB; Z is set if the result of the operation is zero; H is set if a carry/borrow occurred beyond bit 3.&lt;br /&gt;
** P, V, and L are used for the P/V flag which has several standard effects. P means it&#039;s parity. V means it&#039;s overflow. L means it checks BC as loop counter for some of the block copy and search instructions: P/V = (BC != 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Register and Data manipulation ===&lt;br /&gt;
;LD (LoaD)&lt;br /&gt;
&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=LD r, r&#039;&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=r := r&#039;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD r,n&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=r := n&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD r, (HL)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indirect&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=r := HL*&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD r, (IXY+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=r := (IXY+d)*&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD (HL),r&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=HL* := r&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD (IXY+d),r&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=(IXY+D)* := r&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD (HL), n&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=HL* := n&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD (IXY+d), n&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=(IXY+d)* := n&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD A, (BC/DE)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Indirect&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A := rr*&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD A, (nn)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Address&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=13&lt;br /&gt;
 |shortfx=A := (nn)*&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD (BC/DE), A&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=Accumulator&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=rr* := A&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD (nn), A&lt;br /&gt;
 |ad1=Address&lt;br /&gt;
 |ad2=Accumulator&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=13&lt;br /&gt;
 |shortfx=(nn)* := A&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD A, I&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=9&lt;br /&gt;
 |shortfx=A := I; P/V:=IFF2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD A, R&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=9&lt;br /&gt;
 |shortfx=A := R; P/V:=IFF2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD I, A&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Accumulator&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=9&lt;br /&gt;
 |shortfx=I := A&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD R, A&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Accumulator&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=9&lt;br /&gt;
 |shortfx=R := A&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD BC/DE/HL/SP, nn&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=rr := nn&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD IXY, nn&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=14&lt;br /&gt;
 |shortfx=rr := nn&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD HL, (nn)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Address&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=HL := (nn)*&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD BC/DE/SP/IXY, (nn)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Address&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=20&lt;br /&gt;
 |shortfx=rr := (nn)*&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD (nn), HL&lt;br /&gt;
 |ad1=Address&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=(nn)* := HL&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD (nn), BC/DE/SP/IXY&lt;br /&gt;
 |ad1=Address&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=20&lt;br /&gt;
 |shortfx=(nn)* := rr&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD SP, HL&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=6&lt;br /&gt;
 |shortfx=SP := HL&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Opcode|opdesc=LD SP, IXY&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=SP := IXY&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
:The basic data load/transfer instruction. Transfers data from the location specified by the second argument, to the location specified by the first. Available combinations are as follows:&lt;br /&gt;
:* Any 8-bit register can be:&lt;br /&gt;
:** loaded with an immediate value;&lt;br /&gt;
:** loaded with the contents of any other 8-bit register except I and R;&lt;br /&gt;
:** loaded with the contents of, or stored in, memory pointed to by HL;&lt;br /&gt;
:** loaded with the contents of, or stored in, memory offset-indexed by IX or IY.&lt;br /&gt;
:* Additionally, the accumulator A (only) can be:&lt;br /&gt;
:** loaded with the contents of, or stored in, memory pointed to by BC or DE;&lt;br /&gt;
:** loaded with the contents of, or stored in, memory pointed to by an immediate address;&lt;br /&gt;
:** loaded with the contents of I or R.&lt;br /&gt;
:* Any 16-bit register pair can be:&lt;br /&gt;
:** loaded with an immediate value;&lt;br /&gt;
:** loaded with the contents of, or stored in, memory pointed to by an immediate address.&lt;br /&gt;
:* Additionally, SP (only) can be:&lt;br /&gt;
:** loaded with the contents of HL, IX, or IY.&lt;br /&gt;
:** The planned &#039;&#039;&#039;ld hl, sp&#039;&#039;&#039; didn&#039;t make it to Next yet, one possible workaround is: &#039;&#039;&#039;ld hl,0&#039;&#039;&#039;; &#039;&#039;&#039;add hl,sp&#039;&#039;&#039;;&lt;br /&gt;
:* Memory referred to by HL or through IX can be assigned immediate values.&lt;br /&gt;
:Although 16-bit register pairs cannot be directly moved between each other, they can be moved by moving the two 8-bit registers. (SP gets a special case because it can&#039;t be addressed via 8-bit registers.) Some assemblers will provide built-in macro instructions allowing, for example, &#039;&#039;&#039;ld bc, de&#039;&#039;&#039;.&lt;br /&gt;
:LD instructions do not alter any flags unless I or R are loaded into A.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;EX (EXchange)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=EX DE, HL&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=swap(DE,HL)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=EX AF, AF&#039;&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=!&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=swap(AF,AF&#039;)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=EX (SP), HL&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=swap(SP*,HL)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=EX (SP), IXY&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=swap(SP*,IXY)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
:Exchanges the contents of two sources. The only permitted combinations are&lt;br /&gt;
:* Exchanging DE and HL;&lt;br /&gt;
:* Exchanging AF and AF&#039;;&lt;br /&gt;
:* Exchanging HL, IX, or IY with the contents of memory pointed to by SP.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;EXX (EXchange all)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=EXX&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=swap(BC,BC&#039;);swap(DE,DE&#039;);swap(HL,HL&#039;)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Exchanges BC, DE, and HL with their shadow registers. AF and AF&#039; are not exchanged. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;PUSH&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=PUSH BC/DE/HL/AF&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=SP-=2; SP*:=rr&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=PUSH IXY&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=SP-=2; SP*:=rr&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=PUSH nnnn&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=SP-=2; SP*:=nnnn&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
:Pushes the given argument on the stack. This can be any 16-bit register pair except SP. SP is reduced by 2 and then the argument is written to the new location SP points to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;POP&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=POP BC/DE/HL&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=rr:=SP*; SP+=2&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=POP AF&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=!&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=rr:=SP*; SP+=2&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=POP IXY&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=14&lt;br /&gt;
 |shortfx=rr:=SP*; SP+=2&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Pops the given argument from the stack. This can be any 16-bit register pair except SP. The current value at SP is copied to the register pair and then SP is raised by 2.&lt;br /&gt;
:Popping into AF does set value of flag register F directly to low 8 bits of value from stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Block Copy ===&lt;br /&gt;
;LDI (LoaD and Increment)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=LDI&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=L&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=DE*:=HL*; DE++; HL++; BC--&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Copies the byte pointed to by HL to the address pointed to by DE, then adds 1 to DE and HL and subtracts 1 from BC. P/V is set to (BC!=0), i.e. set when non zero.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;LDIR (LoaD and Increment Repeated)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=LDIR&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=L&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=21x+16&lt;br /&gt;
 |shortfx=do LDI while(BC&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Automatically loops LDI until BC reaches zero. Note the last iteration starts when BC=1 and ends with BC=0 (starting the LDIR with BC=0 will start 64kiB transfer, most likely overwriting vital parts of system memory and/or code itself).&lt;br /&gt;
:Flag effects are the same as LDI except that P/V will always be reset, because BC by definition reaches 0 before this instruction ends (normally - unless something overwrites LDIR opcode while BC&amp;gt;0).&lt;br /&gt;
:Interrupts may interrupt LDIR instruction while looping (after each single LDI sub-part finished) and LDIR will resume after and finish loop properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;LDD (LoaD and Decrement)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=LDD&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=L&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=DE*:=HL*; DE--; HL--; BC--&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as LDI, but subtracts 1 from DE and HL instead of adding.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;LDDR (LoaD and Decrement Repeated)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=LDDR&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=0&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=21x+16&lt;br /&gt;
 |shortfx=do LDD while(BC&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as LDIR but loops LDD instead of LDI.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;LDWS&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=LDWS&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=14&lt;br /&gt;
 |shortfx=DE*:=HL*; INC L; INC D;&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Next-only extended opcode. Copies the byte pointed to by HL to the address pointed to by DE and increments only L and D. This is used for vertically copying bytes to the Layer 2 display.&lt;br /&gt;
:The flags are identical to what the &#039;&#039;&#039;INC D&#039;&#039;&#039; instruction would produce.&lt;br /&gt;
:Note the source data are read only from single 256B (aligned) block of memory, because only L is incremented, not HL.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;LDIX, LDIRX, LDDX, LDDRX&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=LDIX&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx={if HL*!=A DE*:=HL*;} DE++; HL++; BC--&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=LDIRX&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=21/16&lt;br /&gt;
 |shortfx=do LDIX while(BC&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=LDDX&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx={if HL*!=A DE*:=HL*;} DE++; HL--; BC--&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=LDDRX&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=21/16&lt;br /&gt;
 |shortfx=do LDDX while(BC&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Next-only extended opcodes. Behave similarly as their non-X equivalents except the byte is not copied if it is equal to A and LDDX/LDDRX advance DE by incrementing it (like LDI), while HL is decremented (like LDD).&lt;br /&gt;
:Second difference to non-X instructions (as usual with next-only opcodes due to implementation), the extended ones don&#039;t modify any flags.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;LDPIRX &lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=LDPIRX&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=21/16&lt;br /&gt;
 |shortfx=do{t:=(HL&amp;amp;$FFF8+E&amp;amp;7)*; {if t!=A DE*:=t;} DE++; BC--}while(BC&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Similar to LDIRX except the source byte address is not just HL, but is obtained by using the top 13 bits of HL and the lower 3 bits of DE and HL does not increment during whole loop (HL works as base address of aligned 8 byte lookup table, DE works as destination and also wrapping index 0..7 into table). This is intended for &amp;quot;pattern fill&amp;quot; functionality.&lt;br /&gt;
&lt;br /&gt;
=== Block Search ===&lt;br /&gt;
;CPI (ComPare and Increment)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=CPI&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=L&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=HL*==A?; HL++; BC--&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Compares the byte pointed to by HL with the contents of A and sets Z if it matches or S if the comparison goes negative. Then adds 1 to HL and subtracts 1 from BC. P/V is set to (BC!=0), i.e. set when non zero.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;CPIR (ComPare and Increment Repeated)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=CPIR&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=L&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=21x+16&lt;br /&gt;
 |shortfx=do CPI while (!Z &amp;amp;&amp;amp; BC&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Automatically loops CPI until either Z is set (A is found in the byte pointed to by HL) or P/V is reset (BC reached 0).&lt;br /&gt;
:Flag effects are the same as CPI except that one of the two terminating flag conditions will always be true.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;CPD (ComPare and Decrement)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=CPD&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=L&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=HL*==A?; HL--; BC--&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as CPI, but subtracts 1 from HL instead of adding it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;CPDR (ComPare and Decrement Repeated)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=CPDR&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=L&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=21x+16&lt;br /&gt;
 |shortfx=do CPD while (!Z &amp;amp;&amp;amp; BC&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as CPIR but loops CPD instead of CPI. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
;ADD&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=ADD A, r&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A+=r&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADD A, n&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A+=n&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADD A, (HL)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Indirect&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A+=HL*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADD A, (IXY+d)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=A+=(IXY+d)*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADD HL, BC/DE/HL/SP&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=HL+=rr&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADD IXY, BC/DE/IXY/SP&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=IXY+=rr&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADD HL/DE/BC, A&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=rr+=unsigned A&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADD HL/DE/BC, nnnn&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=?&lt;br /&gt;
 |n=?&lt;br /&gt;
 |pv=?&lt;br /&gt;
 |h=?&lt;br /&gt;
 |z=?&lt;br /&gt;
 |s=?&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=rr+=nnnn&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Adds values together. Legal combinations are:&lt;br /&gt;
:* When adding 8-bit values the first parameter must be A and the second may be:&lt;br /&gt;
:** The contents of an 8-bit register;&lt;br /&gt;
:** An immediate value;&lt;br /&gt;
:** The contents of memory pointed to by HL or by indexing based on IX or IY.&lt;br /&gt;
:* When adding 16-bit values the first parameter must be HL, IX or IY and the second must be another 16-bit register pair. If the first parameter is IX or IY, the second cannot be HL or the other index register. &lt;br /&gt;
:* For 16 bit additions (regular Z80), H is set if a carry occurred in bit 11 (ie, a half carry in the high byte)&lt;br /&gt;
:* On the Spectrum Next the extended opcodes also allow the first parameter to be HL, DE, or BC and the second to be A (A will be zero extended to 16 bits) or an immediate value. It&#039;s not yet clear if the Next-extended ADD rr,nnnn will preserve or modify flags (the ADD rr,A keeps flags intact).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;ADC (ADd with Carry)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=ADC A, r&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A+=r+(CF?1:0)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADC A, n&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A+=n+(CF?1:0)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADC A, (HL)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Indirect&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A+=HL*+(CF?1:0)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADC A, (IXY+d)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=A+=(IXY+d)*+(CF?1:0)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=ADC HL, BC/DE/HL/SP&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=HL+=rr+(CF?1:0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Adds values together, adding an additional 1 if Carry is set. Legal combinations are the same as for ADD, although there are no extended opcode versions of ADC and in 16-bit values the first parameter can only be HL. For 16-bit values the H flag is set if carry from bit 11; otherwise, it is reset.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
;SUB&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SUB r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A -= r&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SUB n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A -= n&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SUB (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A -= HL*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SUB (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=A -= (IXY+d)*&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Subtracts a value from A. Legal combinations are the same as for ADD for 8-bit, except that A does not need to be specified as the first parameter because subtraction can only be done from A. SUB cannot be used for 16-bit numbers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SBC (SuBtract with Carry, er, borrow)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SBC A, r&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A-=(r+(CF?1:0))&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SBC A, n&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A-=(n+(CF?1:0))&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SBC A, (HL)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Indirect&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A-=(HL*+(CF?1:0))&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SBC A, (IXY+d)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=A-=((IXY+d)+(CF?1:0))&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SBC HL, BC/DE/HL/SP&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=HL-=(rr+(CF?1:0))&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Subtracts values, subtracting an additional 1 if Carry is set. Legal combinations are the same as for ADD, although there are no extended opcode versions of SBC and in 16-bit values the first parameter can only be HL. For 16-bit values the H flag is set if borrow from bit 12; otherwise, it is reset.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;AND, OR, XOR&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=AND r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=1&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A := A &amp;amp; r&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=AND n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=1&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A := A &amp;amp; n&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=AND (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=1&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A := A &amp;amp; HL*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=AND (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=1&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=A := A &amp;amp; (IXY+d)*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OR r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A := A OR r&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OR n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A := A OR n&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OR (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A := A OR HL*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OR (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=A := A OR (IXY+d)*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=XOR r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A := A ^ r&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=XOR n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A := A ^ n&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=XOR (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A := A ^ HL*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=XOR (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=0&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=A := A ^ (IXY+d)*&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Performs the appropriate bitwise operator on A. Legal combinations are the same as SUB. &lt;br /&gt;
&lt;br /&gt;
:XOR A is faster and shorter than LD A,0&lt;br /&gt;
&lt;br /&gt;
;MIRROR&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=MIRROR A&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=A[76543210]:=A[01234567]&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Next extended opcode. Mirrors (reverses the order) of bits in the accumulator. Older core versions supported MIRROR DE, but this was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;CP (ComPare)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=CP r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A-=r?&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=CP n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A-=n?&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=CP (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=7&lt;br /&gt;
 |shortfx=A-=HL*?&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=CP (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=19&lt;br /&gt;
 |shortfx=A-=(IXY+d)?&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Sets the flags as if a SUB was performed but does not perform it. Legal combinations are the same as SUB. This is commonly used to set the flags to perform an equality or greater/less test.&lt;br /&gt;
:* CP is &#039;&#039;not&#039;&#039; equivalent to &amp;quot;if&amp;quot; in high level languages. Flag based jumps can follow any instruction that sets the flags, not just CP.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;TEST&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=TEST n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=S&lt;br /&gt;
 |n=?&lt;br /&gt;
 |pv=V&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=A&amp;amp;n?&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
: Next extended opcode. Similar to CP, but performs an AND instead of a subtraction. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;INC (INCrement)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=INC r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=r++&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=INC (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=HL*++&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=INC (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IXY+d)*++&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=INC BC/DE/HL/SP&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=6&lt;br /&gt;
 |shortfx=rr++&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=INC IXY&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=rr++&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Increments the target by one. The argument can be any 8-bit register, any 16-bit register pair, or the address pointed to by HL or indexed via IX or IY. P/V is set if the target held $7F. N is reset.&lt;br /&gt;
:* INC A is faster than ADD 1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;DEC&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=DEC r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=r--&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=DEC (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=HL*--&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=DEC (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IXY+D)*--&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=DEC BC/DE/HL/SP&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=6&lt;br /&gt;
 |shortfx=rr--&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=DEC IXY&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=rr--&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Decrements the target by one. Allowed arguments are the same as INC. Flag effects are the same as INC except H refers to borrow, not carry; and P/V is set if the target held $80.&lt;br /&gt;
:* DEC A is faster than SUB 1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RLC (Rotate Left and Copy)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RLC r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=x:=r[7]; r:=r&amp;lt;&amp;lt;1; r[0]:=x; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RLC (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=x:=HL*[7]; HL*:=HL*&amp;lt;&amp;lt;1; HL*[0]:=x; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RLC (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=x:=(IXY+d)*[7]; (IXY+d)*:=(IXY+d)*&amp;lt;&amp;lt;1; (IXY+d)*[0]:=x; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RLC r,(IX+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=x:=(IX+d)*[7]; (IX+d)*:=(IX+d)*&amp;lt;&amp;lt;1; (IX+d)*[0]:=x; CF:=x; r:=(IX+d)*&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Rotates the target bitwise left by one position. The MSB is copied to bit 0, and also to Carry. Can be applied to any 8-bit register or to a location in memory pointed to by HL or indexed via IX or IY. The final alternative is undocumented, and stores the result in a register as well as performing the operation. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RL (Rotate Left)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RL r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=x:=r[7]; r:=r&amp;lt;&amp;lt;1; r[0]:=CF; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RL (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=x:=HL*[7]; HL*:=HL*&amp;lt;&amp;lt;1; HL*[0]:=CF; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RL (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=x:=(IXY+d)*[7]; (IXY+d)*:=(IXY+d)*&amp;lt;&amp;lt;1; (IXY+d)*[0]:=CF; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RL r,(IX+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=x:=(IX+d)*[7]; (IX+d)*:=(IX+d)*&amp;lt;&amp;lt;1; (IX+d)*[0]:=CF; CF:=x; r:=(IX+d)*&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
:Same as RLC, except the MSB is copied to Carry only, and the previous contents of Carry are copied to bit 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RRC, RR (Rotate Right and Copy, Rotate Right)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RRC r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=x:=r[0]; r:=r&amp;gt;&amp;gt;1; r[7]:=x; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RRC (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=x:=HL*[0]; HL*:=HL*&amp;gt;&amp;gt;1; HL*[7]:=x; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RRC (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=x:=(IXY+d)*[0]; (IXY+d)*:=(IXY+d)*&amp;gt;&amp;gt;1; (IXY+d)*[7]:=x; CF:=x&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RRC r,(IX+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=x:=(IX+d)*[0]; (IX+d)*:=(IX+d)*&amp;gt;&amp;gt;1; (IX+d)*[7]:=x; CF:=x; r:=(IX+d)*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RR r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=x:=r[0]; r:=r&amp;gt;&amp;gt;1; r[7]:=CF; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RR (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=x:=HL*[0]; HL*:=HL*&amp;gt;&amp;gt;1; HL*[7]:=CF; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RR (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=x:=(IXY+d)*[0]; (IXY+d)*:=(IXY+d)*&amp;gt;&amp;gt;1; (IXY+d)*[7]:=CF; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RR r,(IX+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=x:=(IX+d)*[0]; (IX+d)*:=(IX+d)*&amp;gt;&amp;gt;1; (IX+d)*[7]:=CF; CF:=x; r=(IX+d)*&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as RLC and RL except they rotate right instead of left.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SLA (Shift Left Arithmetic)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SLA r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=r:=r&amp;lt;&amp;lt;1&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SLA (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=HL*:=HL*&amp;lt;&amp;lt;1&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SLA (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IXY+d)*:=(IXY+d)*&amp;lt;&amp;lt;1&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SLA r,(IX+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IX+d)*:=(IX+d)*&amp;lt;&amp;lt;1; r=(IX+d)*&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as RL except bit 0 is set to zero, not the previous contents of Carry.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SRA (Shift Right Arithmetic)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SRA r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=r:=r&amp;gt;&amp;gt;1 OR r[7]&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SRA (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=HL*:=HL*&amp;gt;&amp;gt;1 OR HL*[7]&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SRA (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IXY+d)*:=(IXY+d)*&amp;gt;&amp;gt;1 OR (IXY+d)*[7]&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SRA r,(IX+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IX+d)*:=(IX+d)*&amp;gt;&amp;gt;1 OR (IX+d)*[7]; r:=(IX+d)*&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as RR except the MSB is left unchanged (on the assumption that it&#039;s the sign bit), not replaced with the previous contents of Carry. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SRL (Shift Right Logical)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SRL r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=0&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=r:=unsigned(r)&amp;gt;&amp;gt;1&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SRL (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=0&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=HL*:=unsigned(HL*)&amp;gt;&amp;gt;1&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SRL (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=0&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IXY+d)*:=unsigned((IXY+d)*)&amp;gt;&amp;gt;1&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SRL r,(IXY+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=0&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IXY+d)*:=unsigned((IXY+d)*)&amp;gt;&amp;gt;1; r:=(IXY+d)*&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as SLA except it shifts right instead of left.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RLCA, RLA, RRCA, RRA&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RLCA&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=x:=A[7]; A:=A&amp;lt;&amp;lt;1; A[0]:=x; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RLA&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=x:=A[7]; A:=A&amp;lt;&amp;lt;1; A[0]:=CF; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RRCA&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=x:=A[0]; A:=A&amp;gt;&amp;gt;1; A[7]:=x; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RRA&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=x:=A[0]; A:=A&amp;gt;&amp;gt;1; A[7]:=CF; CF:=x&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as their matching instruction except they work only on A, are faster, and do not alter S, Z or P/V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SLL (Shift Left Logical)&lt;br /&gt;
:This mnemonic has no associated opcode. There is no difference between a logical and arithmetic shift left, so both can use SLA, but some assemblers will allow SLL as an equivalent. Unfortunately, some will also assemble it as SL1. So it&#039;s probably worth just avoiding.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SL1 or SLI (Shift Left and Add 1) or (Shift Left and Increment)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SL1 r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SL1 (HL)&lt;br /&gt;
 |ad1=Indirect&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=15&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SL1 (IXY+d)&lt;br /&gt;
 |ad1=Indexed&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SL1 r,(IX+d)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=23&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Undocumented opcodes that behave like SLA, but set bit 0 to 1 instead of 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RLD&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RLD&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=18&lt;br /&gt;
 |shortfx=x=HL*; HL*[0123]:=A[0123]; HL*[7654]:=x[0123]; A[0123]:=x[7654]  &lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Rotates the lower nibble of the byte pointed to by HL, the upper nibble of that byte, and the lower nibble of A, in that order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RRD&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RRD&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=18&lt;br /&gt;
 |shortfx=x=HL*; HL*[7654]:=A[0123]; HL*[0123]:=x[7654]; A[0123]:=x[0123]&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Same as RLD, but the order is: the lower nibble pointed to by HL, the lower nibble of the A, and the upper nibble of the byte.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Barrel (variable amount) shift and rotate (cores v2+ only)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=BSLA DE,B&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |shortfx=DE:=DE&amp;lt;&amp;lt;(B&amp;amp;31)&lt;br /&gt;
 |tstates=8&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=BSRA DE,B&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |shortfx=DE:=signed(DE)&amp;gt;&amp;gt;(B&amp;amp;31)&lt;br /&gt;
 |tstates=8&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=BSRL DE,B&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |shortfx=DE:=unsigned(DE)&amp;gt;&amp;gt;(B&amp;amp;31)&lt;br /&gt;
 |tstates=8&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=BSRF DE,B&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |shortfx=DE:=~(unsigned(~DE)&amp;gt;&amp;gt;(B&amp;amp;31))&lt;br /&gt;
 |tstates=8&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=BRLC DE,B&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |shortfx=DE:=DE&amp;lt;&amp;lt;(B&amp;amp;15) OR DE&amp;gt;&amp;gt;(16-B&amp;amp;15)&lt;br /&gt;
 |tstates=8&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Shift instructions use only bits 4..0 of B, BSLA shifts DE left, BSRA/BSRL/BSRF shifts DE right in arithmetic/logical/fill-one way. BRLC rotates DE left by B places, uses only bits 3..0 of B (to rotate right, use B=16-places).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;CPL (ComPLement)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=CPL&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=1&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=A:=~A&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Inverts the contents of the accumulator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;NEG (NEGate)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=NEG&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=S&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=A:=0-A&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Subtracts the contents of the accumulator from zero, making it negative for the purpose of two&#039;s complement. P/V is set if A previously held $80. C is set if accumulator did not previously hold $00.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;CCF (Change Carry Flag)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=CCF&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=CF:=!CF&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Inverts the carry flag. (Does not, as might be assumed, clear it!) Also sets H to the previous value of the carry flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SCF (Set Carry Flag)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SCF&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=1&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=CF:=1&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Sets the carry flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;BIT&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=BIT b,r&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=?&lt;br /&gt;
 |h=1&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=?&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=r[b]==1?&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=BIT b,(HL)&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Indirect&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=?&lt;br /&gt;
 |h=1&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=?&lt;br /&gt;
 |tstates=12&lt;br /&gt;
 |shortfx=HL*[b]==1?&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=BIT b,(IXY+d)&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=?&lt;br /&gt;
 |h=1&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=?&lt;br /&gt;
 |tstates=20&lt;br /&gt;
 |shortfx=(IXY+d)*[b]==1?&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Tests if a bit is set on target value. The first parameter states which bit. The second can be any 8-bit register, or the location in memory pointed to by HL or indexed by IX or IY. Sets Z if specified bit was 0. S and P/V are destroyed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SET&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SET b,r&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=r:=r OR (1&amp;lt;&amp;lt;b)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SET b,(HL)&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=HL*:=HL* OR (1&amp;lt;&amp;lt;b)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SET b,(IXY+d)&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IXY+d)*:=(IXY+d)* OR (1&amp;lt;&amp;lt;b)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SET r,b,(IX+d)&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IX+d)*:=(IX+d)* OR (1&amp;lt;&amp;lt;b); r:=(IX+d)*&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=SETAE&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=A:=unsigned($80)&amp;gt;&amp;gt;(E&amp;amp;7)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Sets the numbered bit on target value. The possible targets are the same as BIT. The three parameter variant is undocumented and stores the result in a register as well as performing the SET.&lt;br /&gt;
:SETAE is a Next extended opcode which takes the bit number to set from E (only the low 3 bits) and sets whole A to value of that bit, but counted from top to bottom (E=0 will produce A:=$80, E=7 will produce A:=$01). This works as pixel mask for ULA bitmap modes, when E is 0..255 x-coordinate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RES (RESet)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RES b,r&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=r:=r &amp;amp; (~(1&amp;lt;&amp;lt;b))&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RES b,(HL)&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=15&lt;br /&gt;
 |shortfx=HL*:=HL* &amp;amp; (~(1&amp;lt;&amp;lt;b))&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RES b,(IXY+d)&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IXY+d)*:=(IXY+d)* &amp;amp; (~(1&amp;lt;&amp;lt;b))&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RES r,b,(IX+d)&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Indexed&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=23&lt;br /&gt;
 |shortfx=(IX+d)*:=(IX+d)* &amp;amp; (~(1&amp;lt;&amp;lt;b)); r:=(IX+d)*&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Resets the numbered bit on target value. The possible targets are the same as BIT.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;DAA (Decimal Adjust Accumulator)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=DAA&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=!&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=no &#039;&#039;short&#039;&#039; desc.&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Modifies the contents of the accumulator based on the flags and the previous operation to correct for binary coded decimal (BCD).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;MUL&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=MUL&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=DE:=D*E&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Next extended opcode. Multiplies D by E, storing 16 bit result into DE. Does not alter any flags.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;SWAPNIB&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=SWAPNIB&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=A:=A[3210]&amp;lt;&amp;lt;4 OR A[7654]&amp;gt;&amp;gt;4&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Next extended opcode. Swaps the high and low nibbles of the accumulator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;PIXELAD&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=PIXELAD&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=HL:=$4000+((D&amp;amp;$C0)&amp;lt;&amp;lt;5)+((D&amp;amp;$07)&amp;lt;&amp;lt;8)+((D&amp;amp;$38)&amp;lt;&amp;lt;2)+(E&amp;gt;&amp;gt;3)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Next extended opcode. Takes E and D as the X,Y coordinate of a point and calculates the address of the byte containing this pixel in the pixel area of standard ULA screen 0, storing it in HL.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;PIXELDN&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=PIXELDN&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=if(HL&amp;amp;$0700!=$0700) HL+=256;&amp;lt;br&amp;gt;&lt;br /&gt;
else if(HL&amp;amp;$e0!=$e0) HL:=HL&amp;amp;$F8FF+$20;&amp;lt;br&amp;gt;&lt;br /&gt;
else HL:=HL&amp;amp;$F81F+$0800&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Updates the address in HL to move down by one line of pixels.&lt;br /&gt;
&lt;br /&gt;
=== Control Flow ===&lt;br /&gt;
;JP (JumP)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=JP nn&lt;br /&gt;
 |ad1=Address&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=PC:=nn&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=JP (HL)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=PC:=HL (not PC:=HL*)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=JP (IXY)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=PC:=IXY (not PC:=IXY*)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=JP (C)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=?&lt;br /&gt;
 |n=?&lt;br /&gt;
 |pv=?&lt;br /&gt;
 |h=?&lt;br /&gt;
 |z=?&lt;br /&gt;
 |s=?&lt;br /&gt;
 |tstates=13&lt;br /&gt;
 |shortfx=PC:=PC&amp;amp;$C000+IN(C)&amp;lt;&amp;lt;6&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Jumps (sets the PC) to the given address. The address can be given immediately or read from HL, IX, or IY. Note that although the variants that use register pairs &#039;&#039;look&#039;&#039; like they are using indirect addressing, JP (HL) jumps to the address stored in the register HL, not the address stored at the address HL points to. The JP (C) sets bottom 14 bits of current PC&amp;lt;sup&amp;gt;*&amp;lt;/sup&amp;gt; to value read from I/O port: PC[13:0] = (IN (C) &amp;lt;&amp;lt; 6) (can be used to execute code block read from a disk stream) * &amp;quot;current PC&amp;quot; is address of next instruction after JP (C), as the PC is advanced by fetching op code from memory and is already advanced when execution happens - if the JP instruction resides at the very end of 16k memory block (..FE or ..FF address), then newly composed PC value will land into following 16k block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;JP cc &lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=JP Z/NZ/NC/C/PO/PE/P/M, nn&lt;br /&gt;
 |ad1=Address&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=if cc PC:=nn&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Conditionally jumps (sets the PC) to the given address. The condition is set in terms of the flags: Zero (Z, NZ), Carry (C, NC), Parity (PO, PE), and Sign (P/M). The address can only be given immediately for a conditional jump.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;JR (Jump Relative)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=JR nn&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=12&lt;br /&gt;
 |shortfx=PC+=nn&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=JR C/NC/Z/NZ, nn&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=12&lt;br /&gt;
 |shortfx=if cc PC+=nn&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Jumps to an alternate address by &#039;&#039;adding&#039;&#039; the parameter to the PC - in other words the parameter is an adjustment, not an absolute address. When used in an assembler with labels the syntax should be the same as JP. The JR address can only be given immediately. Conditions are legal, but only those based on carry and zero.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;DJNZ (Decrement and Jump if Not Zero)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=DJNZ n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=13&lt;br /&gt;
 |shortfx=B--; if B!=0 PC+=nn&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Decrements B then performs JR NZ.. to the given address. Used for encapsulating loops.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;CALL&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=CALL nn&lt;br /&gt;
 |ad1=Address&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=17&lt;br /&gt;
 |shortfx=SP-=2; SP*:=PC; PC:=nn&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=CALL Z/NZ/C/NC/PO/PE/P/M, n&lt;br /&gt;
 |ad1=Address&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=17&lt;br /&gt;
 |shortfx=if cc {SP-=2; SP*:=PC; PC:=nn}&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Like JP (including the ability to have conditions), but PUSHes the PC before jumping. Used for subroutine calls. &lt;br /&gt;
:* If a subroutine ends with a CALL to another subroutine immediately before the RET, it is more efficient to JP to the other subroutine and allow its RET to return from the whole combination. This might make high-level programmers queasy but your compiler already does it (tail call optimization)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RET&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RET&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=10&lt;br /&gt;
 |shortfx=PC:=SP*; SP+=2&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=RET Z/NZ/C/NC/PO/PE/P/M&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=if cc {PC:=SP*; SP+=2}&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:POPs the PC from the stack, returning from a previous CALL. This can also accept the same conditions as JP.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RETI&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RETI&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=14&lt;br /&gt;
 |shortfx=PC:=SP*; SP+=2&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Returns from an interrupt service routine (same as RET instruction, but also does signal to I/O device that the interrupt routine is completed).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RETN&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RETN&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=14&lt;br /&gt;
 |shortfx=IFF1:=IFF2; PC:=SP*; SP+=2&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Returns from a non-maskable interrupt service routine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;RST (ReSTart)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=RST n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=CALL n&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Performs a CALL to a routine located at one of eight fixed locations ($00, $08, ..., $38) in the zero page. This is located in ROM, and on the Spectrum only a limited number of values are useful to call built-in ROM routines. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;NOP (No OPeration)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=NOP&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=PC+=1&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Does &amp;quot;nothing&amp;quot; (just usual housekeeping like refreshing memory and advancing program counter to next instruction).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;HALT&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=HALT&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=waits for interrupt&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Suspends the CPU until an interrupt is received (maskable interrupts must be enabled to break the wait). While CPU is waiting for interrupt, the fake NOP instruction is being executed, to keep memory refresh going on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;DI (Disable Interrupts)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=DI&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=IFF1:=0; IFF2:=0&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Disables maskable interrupts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;EI (Enable Interrupts)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=EI&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=4&lt;br /&gt;
 |shortfx=IFF1:=1; IFF2:=1&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Enables maskable interrupts (after next instruction, i.e. for example &amp;quot;EI RET&amp;quot; - the interrupt may happen only after RET instruction is finished (or &amp;quot;EI DI&amp;quot; pair of instructions will not allow any maskable interrupt to happen).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;IM (Interrupt Mode)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=IM n&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=8&lt;br /&gt;
 |shortfx=Interrupt mode:=n&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Sets interrupt handling mode. The default for Next is 1. 2 is used for user defined interrupt service routines. IM 0 is useless on Next (and pretty much everything else, to be honest)&lt;br /&gt;
&lt;br /&gt;
=== Input and Output ===&lt;br /&gt;
;IN r, (c); OUT (c), r&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=IN r, (c)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=12&lt;br /&gt;
 |shortfx=r := in(BC)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OUT (c),r&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Register&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=12&lt;br /&gt;
 |shortfx=out(BC,r)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Inputs or outputs a byte value from the 16-bit port number given in BC. R can be any 8-bit register. Note that the port number is given in BC even though the instruction refers only to C. Some assemblers will allow the instruction to be written with &amp;quot;(bc)&amp;quot; instead of &amp;quot;(c)&amp;quot; as a reminder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;IN (c); OUT (c), 0&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=IN (c)&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=0&lt;br /&gt;
 |pv=P&lt;br /&gt;
 |h=0&lt;br /&gt;
 |z=S&lt;br /&gt;
 |s=S&lt;br /&gt;
 |tstates=12&lt;br /&gt;
 |shortfx=in(BC)?&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OUT (c),0&lt;br /&gt;
 |ad1=Register&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=U&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=12&lt;br /&gt;
 |shortfx=out(BC,0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Undocumented opcodes. The IN variation performs an input, but does not store the result, only setting the flags. The OUT variation outputs 0 on the port. This is the only number that can be output to a port in immediate mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;IN a, (n); OUT (n), a&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=IN A, (n)&lt;br /&gt;
 |ad1=Accumulator&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=A := in(An)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OUT (n),A&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Accumulator&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=11&lt;br /&gt;
 |shortfx=out(An,A)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Inputs or outputs the byte value in A from a 16-bit port number where the lower byte is N and the upper byte is A. This is only likely to be useful in cases where the upper byte of the port number is not relevant.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;INI (INput and Increment)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=INI&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=HL*:=in(BC); HL++; B--&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Inputs a value from port BC into memory at the address stored in HL, then increments HL and decrements B. Because B is decremented and is part of the port number, the port number for future INI instructions will change unless it is reset. Z is set if B reached 0; S, H, and P/V are destroyed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;INIR (INput and Increment Repeated)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=INIR&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=1&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=21x+16&lt;br /&gt;
 |shortfx=do INI while(B&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Loops INIR until B reaches 0. Because B is decremented during this process and is part of the port number, this is unlikely to be useful except when the upper byte of the port number is not relevant. Interrupts are recognized during execution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;IND, INDR (INput and Decrement, INput and Decrement Repeated)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=IND&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=HL*:=in(BC); HL--; B--&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=INDR&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=1&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=21x+16&lt;br /&gt;
 |shortfx=do IND while(B&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Behave like INI and INIR except that HL is decremented instead of incremented.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;OUTI (Out and Increment), OTIR (Out and Increment Repeated), OUTD (Out and Decrement), OTDR (Out and Decrement Repeated)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=OUTI&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=B--; out(BC,HL*); HL++&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OTIR&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=1&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=21x+16&lt;br /&gt;
 |shortfx=do OUTI while (B&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OUTD&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=!&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=B--; out(BC,HL*); HL--&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=OTDR&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=S&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=1&lt;br /&gt;
 |pv=!&lt;br /&gt;
 |h=!&lt;br /&gt;
 |z=1&lt;br /&gt;
 |s=!&lt;br /&gt;
 |tstates=21x+16&lt;br /&gt;
 |shortfx=do OUTD while (B&amp;gt;0)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Behave like INI, INIR, IND, INDR except that they output instead of input and B is decremented &#039;&#039;&#039;before&#039;&#039;&#039; the output instead of after.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;OUTINB (Out and Increment with No B)&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=OUTINB&lt;br /&gt;
 |ad1=-&lt;br /&gt;
 |ad2=-&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=?&lt;br /&gt;
 |n=?&lt;br /&gt;
 |pv=?&lt;br /&gt;
 |h=?&lt;br /&gt;
 |z=?&lt;br /&gt;
 |s=?&lt;br /&gt;
 |tstates=16&lt;br /&gt;
 |shortfx=out(BC,HL*); HL++&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Next extended opcode. Behaves like OUTI, but doesn&#039;t decrement B.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;NEXTREG&lt;br /&gt;
:{{Opcodelisttop}}&lt;br /&gt;
{{Opcode|opdesc=NEXTREG nn, nn&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Immediate&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=20&lt;br /&gt;
 |shortfx=out($243B,nn1); out($253B,nn2)&lt;br /&gt;
}}&lt;br /&gt;
{{Opcode|opdesc=NEXTREG nn, A&lt;br /&gt;
 |ad1=Immediate&lt;br /&gt;
 |ad2=Accumulator&lt;br /&gt;
 |status=E&lt;br /&gt;
 |c=-&lt;br /&gt;
 |n=-&lt;br /&gt;
 |pv=-&lt;br /&gt;
 |h=-&lt;br /&gt;
 |z=-&lt;br /&gt;
 |s=-&lt;br /&gt;
 |tstates=17&lt;br /&gt;
 |shortfx=out($243B,nn); out($253B,a)&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
:Next extended opcode. Directly sets the [[Board feature control|Next Feature Control Registers]] without going through ports {{PortNo|$243B}} and {{PortNo|$253B}}.&lt;br /&gt;
&lt;br /&gt;
=== Z80N instructions opcodes ===&lt;br /&gt;
&lt;br /&gt;
The Z80 on the Next has extra instructions that are unique to it.  Below is a table of the opcode bytes that are required to select&lt;br /&gt;
those instructions.  The timings are based on some partial testing.  These may not be accurate.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Instruction !! Byte 1 !! Byte 2 !! Byte 3 !! Byte 4 || T-States&lt;br /&gt;
|-&lt;br /&gt;
| LDIX || ED || A4 || || || 16&lt;br /&gt;
|-&lt;br /&gt;
| LDWS || ED || A5 || || || 14&lt;br /&gt;
|-&lt;br /&gt;
| LDIRX || ED || B4 || || || 21/16&lt;br /&gt;
|-&lt;br /&gt;
| LDDX || ED || AC || || || 16&lt;br /&gt;
|-&lt;br /&gt;
| LDDRX || ED || BC || || || 21/16&lt;br /&gt;
|-&lt;br /&gt;
| LDPIRX || ED  || B7 || || || 21/16&lt;br /&gt;
|-&lt;br /&gt;
| OUTINB || ED  || 90 || || || 16&lt;br /&gt;
|-&lt;br /&gt;
| MUL D,E || ED || 30 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| ADD HL,A || ED || 31 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| ADD DE,A || ED || 32 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| ADD BC,A || ED || 33 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| ADD HL,$nnnn || ED || 34 || low || high || 16&lt;br /&gt;
|-&lt;br /&gt;
| ADD DE,$nnnn || ED || 35 || low || high || 16&lt;br /&gt;
|-&lt;br /&gt;
| ADD BC,$nnnn || ED  || 36|| low || high || 16&lt;br /&gt;
|-&lt;br /&gt;
| SWAPNIB || ED || 23 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| MIRROR || ED || 24 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| PUSH $nnnn || ED || 8A || high || low || 23&lt;br /&gt;
|-&lt;br /&gt;
| NEXTREG $rr,$nn || ED || 91 || register || value || 20&lt;br /&gt;
|-&lt;br /&gt;
| NEXTREG $rr,A || ED  || 92 || register || || 17&lt;br /&gt;
|-&lt;br /&gt;
| PIXELDN || ED || 93 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| PIXELAD || ED || 94 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| SETAE || ED  || 95 ||  || || 8&lt;br /&gt;
|-&lt;br /&gt;
| TEST $nn || ED || 27 || value || || 11&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Also note that the &amp;quot;PUSH $nnnn&amp;quot; instruction is not a mistake.  The operand is in big-endian.&lt;br /&gt;
&lt;br /&gt;
The core version 2.00.22+ has these new instructions:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Instruction !! Byte 1 !! Byte 2 !! Byte 3 !! Byte 4 || T-States&lt;br /&gt;
|-&lt;br /&gt;
| BSLA DE,B || ED || 28 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| BSRA DE,B || ED || 29 || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| BSRL DE,B || ED || 2A || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| BSRF DE,B || ED || 2B || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| BRLC DE,B || ED || 2C || || || 8&lt;br /&gt;
|-&lt;br /&gt;
| JP (C) || ED || 98 || || || 13&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1293</id>
		<title>Memory map</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1293"/>
		<updated>2019-05-03T18:40:32Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Next supports two memory management models which operate in tandem. One is a unique memory management system for the Next. The other is an expanded version of the memory manager from the original Spectrum 128 and +2/+3 series.&lt;br /&gt;
&lt;br /&gt;
== Global Memory Map ==&lt;br /&gt;
&lt;br /&gt;
The total available RAM space of the Next is 768k on an unexpanded Next, or 1792k on a Next expanded to 2Mb. (The base Next has 1mb of memory but 256k of it is reserved for the ROMs and firmware.)&lt;br /&gt;
&lt;br /&gt;
The Z80 processor in the Next can access only 64k of memory at a time, and so the memory is divided into &#039;&#039;banks&#039;&#039; which are used in determining which memory it sees. Spectrum 128k memory management, and [[NextBASIC]], use 16k banks. Next memory management via machine code uses 8k banks.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-bank !! 8k-bank !! True Address !! Size !! Description&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $000000-$00ffff || 64K || ZX Spectrum ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $010000-$013fff || 16K || EsxDOS ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $014000-$017fff || 16K || Multiface ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $018000-$01bfff || 16K || Multiface Extra ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $01c000-$01ffff || 16K || Multiface RAM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $020000-$03ffff || 128K || DivMMC RAM&lt;br /&gt;
|-&lt;br /&gt;
| 0-7 || 0-15 || $040000-$05ffff || 128K || Standard 128K RAM&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 || 16-31 || $060000-$07ffff || 128K || Extra RAM&lt;br /&gt;
|-&lt;br /&gt;
| 16-47 || 32-95 || $080000-$0fffff || 512K || 1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 48-79 || 96-159 || $100000-$17ffff || 512K || 2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 80-111 || 160-223 || $180000-$1fffff || 512K || 3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally, the first few pages have certain uses and traits summarised below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-banks !! 8k-banks !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0-1 || Standard RAM, maybe used by EsxDOS.  Initially mapped to $c000-$ffff.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2-3 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-5 || Standard RAM.  Initially mapped to $8000-$bfff.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 6-7 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 8-9 || Standard RAM, contended on +2/+3, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 10-11 || ULA Screen, contended except on Pentagon, cannot be used by [[NextBASIC]] commands.  Initially mapped to $4000-$7fff.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 12-13 || Standard RAM, contended on +2/+3, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 14-15 || ULA Shadow Screen, contended except on Pentagon, NextZXOS Workspace, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 16-17 || Next RAM, Default Layer 2, NextZXOS screen and extra data, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 9-10 || 18-21 || Next RAM, Rest of default Layer 2&lt;br /&gt;
|-&lt;br /&gt;
| 11-13 || 22-27 || Next RAM, Default Layer 2 Shadow Screen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please note that NextZXOS moves the Layer 2 bank assignments. Therefore, Layer 2, after NextZXOS boots, is mapped to 16k-banks 9-11 (8k-banks 18-23). The Layer 2 shadow memory is also assigned to 16k-banks 9-11 (8k-banks 18-23).&lt;br /&gt;
&lt;br /&gt;
== Z80 Visible Memory map ==&lt;br /&gt;
&lt;br /&gt;
At start up, the 16-bit address space of the Z80 is mapped to memory as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! 16k-slot !! 8k-slot !! Default 16k-bank !! Default 8k-bank !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || rowspan=2 | 1 || 0 || rowspan=2 | ROM || ROM (255) || Normally ROM. Writes mappable by Layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2. &lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || rowspan=2 | 2 || 2 || rowspan=2 | 5 || 10 || Normally used for normal/shadow ULA screen. &lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || rowspan=2 | 3 || 4 || rowspan=2 | 2 || 4 || Free RAM. &lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || rowspan=2 | 4 || 6 || rowspan=2 | 0 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Paging techniques ==&lt;br /&gt;
&lt;br /&gt;
=== 128-style memory management ===&lt;br /&gt;
&lt;br /&gt;
128-style memory management can only alter the bank addressed at $c000 (16k-slot 4, or 8k-slot 7-8). The active 16k-bank at $c000 is selected by writing the 3 LSBs of the 16k-bank number to the bottom 3 bits of {{PortNo|$7FFD}}, and the 3 MSBs to the bottom 3 bits of {{PortNo|$DFFD}}. (The reason for the division is that the original Spectrum 128, having only 128k of memory, only needed 3 bits.)&lt;br /&gt;
&lt;br /&gt;
On an unexpanded Next, this allows any 16k-bank to be paged in at $c000. On an expanded Next, there are not enough bits available to access the banks at the bottom of the expanded memory, so Next memory management must be used to access these.&lt;br /&gt;
&lt;br /&gt;
If you are using the standard interrupt handler or OS routines, then any time you write to {{PortNo|$7FFD}} you should also store the value at $5B5C. Any time you write to {{PortNo|$1FFD}} you should also store the value at $5B67. There is no corresponding system variable for the Next-only {{PortNo|$DFFD}} and standard OS routines may not support the extended banks properly.&lt;br /&gt;
&lt;br /&gt;
=== 128 Special Paging Mode ===&lt;br /&gt;
&amp;quot;Special paging mode&amp;quot; (also called &amp;quot;AllRam mode&amp;quot; or &amp;quot;CP/M mode&amp;quot;) is enabled by writing a value with the LSB set to {{PortNo|$1FFD}}. Depending on the 3 low bits of this value a memory configuration is selected as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bits !! Slot 1 !! Slot 2 !! Slot 3 || Slot 4 &lt;br /&gt;
|-&lt;br /&gt;
| %001 || 0 || 1 || 2 || 3 &lt;br /&gt;
|-&lt;br /&gt;
| %011 || 4 || 5 || 6 || 7&lt;br /&gt;
|-&lt;br /&gt;
| %101 || 4 || 5 || 6 || 3&lt;br /&gt;
|-&lt;br /&gt;
| %111 || 4 || 7 || 6 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Switching ===&lt;br /&gt;
Layer 2 switching can allow one of the first sixteen (0-15) 16k-banks to be &#039;&#039;written to&#039;&#039; (but not read) in 16k-slot 1, by writing the 16k-bank number to {{NextRegNo|$12}} and then enabling Layer 2 paging by writing a value with the LSB set to {{PortNo|$123B}}. You can use also the {{NextRegNo|$13}} for the same purpose (change of register $12 is immediately visible at display, while register $13 is not related to display in any way, it works only as bank selector for writing into slot 1).&lt;br /&gt;
&lt;br /&gt;
Writing to this area will then write the appropriate area of memory, whereas &#039;&#039;reading&#039;&#039; from it will give the area mapped by other memory management.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is actually 3 banks big, so using Layer 2 controls to access different &amp;quot;sections&amp;quot; of Layer 2 can access the two following banks after the one selected in register $12/$13.&lt;br /&gt;
&lt;br /&gt;
=== Next Memory Management ===&lt;br /&gt;
The 8k-bank accessed in an 8k-slot is selected by writing the 8k-bank number to bits 7-0 of the 8 Next registers from {{NextRegNo|$50}} upwards. $50 addresses 8k-slot 0, $51 addresses 8k-slot 1, and so on.&lt;br /&gt;
&lt;br /&gt;
In addition, in 8k-slots 0 and 1 only, the ROM can be paged in by selecting the otherwise nonexistent 8k-page $FF. Whether the high or the low 8k of the ROM is mapped is determined by which 8k-slot is used.&lt;br /&gt;
&lt;br /&gt;
=== Interactions between paging methods ===&lt;br /&gt;
In normal mode, changes made in 128 style and Next style memory management are synchronized. The most recent change always has priority. This means that using 128-style memory management to select a new 16k-bank in 16k-slot 4 will update the MMU registers for the two 8k-slots with the corresponding 8k-bank numbers.&lt;br /&gt;
&lt;br /&gt;
However, enabling 128 special paging mode (AllRam mode) mode will &#039;&#039;&#039;override the Next MMU&#039;&#039;&#039;. The bank selections from the AllRam mode table will override the set pages in the Next registers. The MMU registers can still be changed, but they will have no effect until special paging mode is disabled.&lt;br /&gt;
&lt;br /&gt;
Since the 128-style memory management ports are not readable, there is no synchronization applicable in the other direction.&lt;br /&gt;
&lt;br /&gt;
== ROM paging and selection ==&lt;br /&gt;
$0000-$3fff is usually mapped to ROM. This area can only be fully remapped using Next memory management. ROM is not considered one of the numbered banks; it is mapped to the two 8k-banks by default, or by setting their 8k-bank numbers to 255. &lt;br /&gt;
&lt;br /&gt;
The 128k Spectrum has 2 ROM pages. Which of these is mapped is selected by altering Bit 4 of {{PortNo|$7FFD}}. The +2a/+3 has 4 ROM pages; the extra bit needed to select between these is bit 2 of {{PortNo|$1FFD}}. This maintains compatibility with the original machines&#039; ROM paging as long as the ROM is not paged out.&lt;br /&gt;
&lt;br /&gt;
=== Paging out ROM ===&lt;br /&gt;
ROM can be paged out by enabling AllRam mode, or by using Next memory management. Beware that some programs may assume that they can find ROM service routines at fixed addresses between $0000-$3fff. More importantly, if the default interrupt mode (IM 1) is set, the Z80 &#039;&#039;&#039;will&#039;&#039;&#039; jump the program counter to $0038 every frame expecting to find an interrupt handler there. If it does not, pain and suffering will likely result. [[Extended Z80 instruction set#DI|DI]] is your friend. On the plus side, this does allow you to write your own interrupt handler without the nuisance of using IM 2.&lt;br /&gt;
&lt;br /&gt;
Activating [[Layer 2]]&#039;s paging will not affect ROM operation, because it only remaps &#039;&#039;writes&#039;&#039;, not reads.&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
16k-Bank 5 is the bank read by the ULA to determine what to show on screen. The ULA connects directly to the larger memory space ignoring mapping; the screen is always 16k-Bank 5, no matter where in memory it is (or if it is switched in at all). Setting bit 3 of {{PortNo|$7FFD}} will have the ULA read from 16k-bank 7 (the &amp;quot;shadow screen&amp;quot;) instead, which can be used as an alternate screen. Beware that &#039;&#039;&#039;this does not map 16k-bank 7 into RAM&#039;&#039;&#039;; to alter 16k-bank 7 it must be mapped by other means. Also by selecting &amp;quot;shadow screen&amp;quot; the &#039;&#039;&#039;Layer 2 becomes automatically invisible&#039;&#039;&#039;, as the access of ULA to &amp;quot;shadow&amp;quot; bank 7 is slower than normal bank 5 and there&#039;s not enough time to read also Layer 2 for video signal generation (to use &amp;quot;double buffering&amp;quot; together with Layer 2, use Timex screen 0/1 by {{PortNo|$xxFF}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=File_Formats&amp;diff=1292</id>
		<title>File Formats</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=File_Formats&amp;diff=1292"/>
		<updated>2019-05-03T18:30:40Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The NextZXOS can read and load these kind of files: bas, tap, nex, z80, sna, snx, dot, o, p&lt;br /&gt;
&lt;br /&gt;
* .z80, .sna and .snx are Spectrum snapshots, more suitable as emulator compatibility than a real format&lt;br /&gt;
* .o is a ZX80 snapshot&lt;br /&gt;
* .p is a ZX81 snapshot&lt;br /&gt;
* [[NEX file format|.nex]] is good for a program that takes over the machine&lt;br /&gt;
* .dot is good for dot commands and programs that can coexist with BASIC/NextZXOS and can return to BASIC safely (i.e. counterpart to nex)&lt;br /&gt;
* [[TAP file format|.tap]] is a simple container format that can hold many files, is compatible with emulators and supported by many tools.&lt;br /&gt;
* .bas is the native SD-card format for BASIC programs (first 128 bytes of the file form standard +3DOS header).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1255</id>
		<title>NextBASIC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1255"/>
		<updated>2019-04-28T08:25:50Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.&lt;br /&gt;
&lt;br /&gt;
? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parentheses are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.&lt;br /&gt;
&lt;br /&gt;
== Basic Interaction Commands ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LIST x? || Lists source code in bank b (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b MERGE || Adds all basic lines in bank b to main program&lt;br /&gt;
|-&lt;br /&gt;
| CONTINUE || Repeats last command or restarts from error location&lt;br /&gt;
|-&lt;br /&gt;
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)&lt;br /&gt;
|-&lt;br /&gt;
| ERASE f, l || Deletes all program lines between f and l. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| LIST x? || Lists source code (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| LLIST x? || Lists source code to printer (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| NEW || Clear stored program&lt;br /&gt;
|-&lt;br /&gt;
| RUN x? || CLEAR then run program (from line x)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO TO x || Jump execution to line x stored in bank b. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO SUB x || Jump execution to line x stored in bank b, storing current location on gosub stack. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression. Will not work if moved into any bank other than the main program&lt;br /&gt;
|-&lt;br /&gt;
| DIM a(x[,y]..) || Defines a as an array of length x (and second dimension length y, etc..)&lt;br /&gt;
|-&lt;br /&gt;
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)&lt;br /&gt;
|-&lt;br /&gt;
| GO TO x || Jump execution to line X in the same bank&lt;br /&gt;
|-&lt;br /&gt;
| GO SUB x || Jump execution to line X in the same bank, storing current location (and bank) on gosub stack&lt;br /&gt;
|-&lt;br /&gt;
| IF c THEN statements.. || Run statements only if expression c is true &lt;br /&gt;
|-&lt;br /&gt;
| LET var = expr || Sets variable var to expr&lt;br /&gt;
|-&lt;br /&gt;
| NEXT var || Marks end of FOR loop regarding VAR&lt;br /&gt;
|-&lt;br /&gt;
| REM comment || Code comment, ignored&lt;br /&gt;
|-&lt;br /&gt;
| RETURN || Restore execution location (line and bank) from gosub stack&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Console I/O ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| COPY || Prints screen&lt;br /&gt;
|-&lt;br /&gt;
| INKEY$ || Returns currently pressed key&lt;br /&gt;
|-&lt;br /&gt;
| INPUT specifier [connector specifier].. || Output expression(s) and read a variable&lt;br /&gt;
|-&lt;br /&gt;
| INVERSE x || Enable or disable switching ink/paper color when printing (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LPRINT specifier [connector specifier].. || Output expression(s) to printer&lt;br /&gt;
|-&lt;br /&gt;
| OVER x || Enable or disable overprinting (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| PAUSE x || Waits x frames or until a key is pressed&lt;br /&gt;
|-&lt;br /&gt;
| PRINT specifier [connector specifier].. || Output expression(s)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible specifiers for PRINT and INPUT statements are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| var || In PRINT, shows contents of var; in INPUT, inputs into this var&lt;br /&gt;
|-&lt;br /&gt;
| (var) || Shows contents of var (in both PRINT and INPUT)&lt;br /&gt;
|-&lt;br /&gt;
| AT x,y || Moves text cursor to the given text cell &lt;br /&gt;
|-&lt;br /&gt;
| TAB x || Inserts spaces until text cursor is in column x&lt;br /&gt;
|-&lt;br /&gt;
| INK x, PAPER x || Changes the appropriate color for the duration of the print/input statement&lt;br /&gt;
|-&lt;br /&gt;
| LINE x$ || INPUT only, reads a string without the prompting quotes&lt;br /&gt;
|-&lt;br /&gt;
| #x || Selects input/output channel number&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And the connectors between these are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| , || Separate with a tab&lt;br /&gt;
|-&lt;br /&gt;
| &#039; || Separate with a newline&lt;br /&gt;
|-&lt;br /&gt;
| ; || Use no separator&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File I/O ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| CAT || Displays disk/tape catalogue&lt;br /&gt;
|-&lt;br /&gt;
| FORMAT || Prepares inserted disk for usage, erasing it&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn || Load BASIC program from file named fn&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn DATA x() || Load data from fn into array x()&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn CODE addr || Load data from fn into memory at address addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn SCREEN$ || Load data from fn onto standard ULA screen&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn BANK b,addr || Load data from fn into memory bank b at addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn LAYER || Load data from fn onto current layer&lt;br /&gt;
|-&lt;br /&gt;
| MERGE fn || Loads BASIC lines from file named fn and integrates them with current program&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (LINE l)? || Save BASIC program to file named fn (and set up autorun at line l)&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (DATA/CODE/SCREEN$/BANK/LAYER..) || Save data as specified; CODE and BANK have an extra &amp;quot;length&amp;quot; parameter&lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn || Checks loaded basic program matches fn &lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn (DATA/CODE/BANK) || Checks data in memory/array matches contents of fn; does not work with SCREEN$/LAYER because the screen is inevitably changed during the verify operation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Inline data ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b RESTORE x || Sets DATA read point to start of line x in bank b&lt;br /&gt;
|-&lt;br /&gt;
| DATA x[,y].. || Stores data in program for later READing&lt;br /&gt;
|-&lt;br /&gt;
| READ var || Read next value from DATA statement into variable&lt;br /&gt;
|-&lt;br /&gt;
| RESTORE x || Sets DATA read point to start of line x&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BORDER n || Set ULA border to color N&lt;br /&gt;
|-&lt;br /&gt;
| BRIGHT n || Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| CIRCLE x,y,r || Draw circle centered at x, y with radius r&lt;br /&gt;
|-&lt;br /&gt;
| CLS || Clears screen&lt;br /&gt;
|-&lt;br /&gt;
| DRAW [modifier or x,y].. || Draw line from plot cursor to given coordinate&lt;br /&gt;
|-&lt;br /&gt;
| FLASH n || Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| INK c || Set ink (foreground) color for print and graphics commands. If Enhanced ULA is enabled, this can use any legal palette value. On Layer 2, it can use any value 0-255.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER x || Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, [[Layer 2]].&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 1,x || Sets mode for Layer 1 based on x. 1 = Standard Spectrum, 2 = Timex hires, 3 = Timex hicolour, 0 = Lores layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 2,x || Selects [[Layer 2]] and determines if it is displayed or not (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER AT x, y || Sets the scroll display offset for the current layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER BANK f, b || Only when [[Layer 2]] is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER CLEAR || Resets all layer settings&lt;br /&gt;
|-&lt;br /&gt;
| LAYER DIM left, top, right, bottom || Sets visible area for current layer&lt;br /&gt;
|-&lt;br /&gt;
| LAYER ERASE x, y, w, h [,f]? || Fills a region at x,y, of size w,h, with palette index f (or the transparent value)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER OVER || Sets layer ordering&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE x || Choose which of the two palettes is used for the active layer (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n, i, v || Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n BANK b, offset || Loads current layer&#039;s palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE CLEAR || Resets all palettes and palette settings&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE DIM x || Sets number of color bits in the active palette; x must be 8 or 9&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE FORMAT x || Enables Enhanced ULA colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE OVER x || Sets the global transparency color to x&lt;br /&gt;
|-&lt;br /&gt;
| PAPER c || Set paper (background) color for print and graphics commands. Follows the same rules as INK.&lt;br /&gt;
|-&lt;br /&gt;
| PLOT [modifier or x,y].. || Plot listed points as single pixels on current layer&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y, var || Stores the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039; in variable var&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y || Returns the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK x || Populates all 64 sprite patterns from bank b, taking 256 bytes per sprite and thus using all data in bank b.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK b, o, p, n || Define n sprite patterns, starting with p, with data from bank b starting at offset o.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x || Choose the first or second palette for sprites. X must be 0 or 1.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x BANK b, o || Load sprite palette x (0 or 1) from bank b at offset o. Data is read as with LAYER PALETTE.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE n, i, v || Set sprite palette n, index i, to color v. V is always 9-bit, even if PALETTE DIM 8 is in effect.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PRINT x || Enable or disable sprites. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BORDER x || Enable or disable sprites crossing the border. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE s, x, y, i, f || Set sprite f to image i at position x,y with flags f. f is bitmapped as byte 3 of data packets sent to {{PortNo|$xx57}}.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE CLEAR || Reset all sprite attributes and global settings.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tilemap support ===&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| TILE [AT x,y]? || Draw the entire screen from the tilemap (from tile offset (x,y))&lt;br /&gt;
|-&lt;br /&gt;
| TILE w,h [AT x,y]? [TO x2,y2]? || Draw a section of the tilemap w,h wide (from tile offset x,y in the tilemap) (to tile offset x2,y2 on the screen)&lt;br /&gt;
|-&lt;br /&gt;
| TILE BANK n || Set bank n as the root of tile graphics (which may occupy up to 4 banks in the case of 16x16 tiles).&lt;br /&gt;
|-&lt;br /&gt;
| TILE DIM n, o, v, t || Set bank n offset o as the root of tilemap data, with tilemap width v and tile size t (t must be 8 or 16 for 8x8 or 16x16 tiles)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Memory and Port Access ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 FORMAT || Re-enable RAMdisk having been disabled by previous BANK 1346 USR&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 USR || Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY TO c || Copy entire bank b to bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY start, len TO c, start || Copy len bytes from start in bank b, to start in bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE x? || Erase all data in bank by overwriting with zeros (or x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE off, len, value || Overwrite len bytes of data at off in bank b with value&lt;br /&gt;
|-&lt;br /&gt;
| BANK b PEEK addr || Returns value at given address in bank b (address is from start of bank)&lt;br /&gt;
|- &lt;br /&gt;
| BANK b POKE addr, value || Sets address in bank b to value (address is from start of bank)&lt;br /&gt;
|-&lt;br /&gt;
| IN port || Returns current value at port&lt;br /&gt;
|-&lt;br /&gt;
| PEEK addr || Returns value at given address&lt;br /&gt;
|-&lt;br /&gt;
| POKE addr, value || Sets address to value&lt;br /&gt;
|-&lt;br /&gt;
| OUT port, value || Sends value to port&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Functions/Expressions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| + - * / ^ || Standard arithmetic operators&lt;br /&gt;
|-&lt;br /&gt;
| = &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= &amp;lt;&amp;gt; || Standard comparison operators (arithmetic for numbers, alphabetic for strings)&lt;br /&gt;
|-&lt;br /&gt;
| a(x) || Returns x&#039;th element of array/string a&lt;br /&gt;
|-&lt;br /&gt;
| s(x? TO y?) || Return substring of s; if x or y are omitted, start or end is assumed&lt;br /&gt;
|-&lt;br /&gt;
| AND OR NOT || Standard boolean conjunctives&lt;br /&gt;
|-&lt;br /&gt;
| ABS x || Gets unsigned magnitude of x&lt;br /&gt;
|-&lt;br /&gt;
| ASN x, ACS x, ATN x || Returns inverse trigonometric ratio (arcsin, arccos, arctan)&lt;br /&gt;
|-&lt;br /&gt;
| ATTR x,y || Returns attribute cell value at cell x,y &lt;br /&gt;
|-&lt;br /&gt;
| BIN x || Converts binary number x to decimal&lt;br /&gt;
|-&lt;br /&gt;
| CHR$ x || Gets character for an ASCII code&lt;br /&gt;
|-&lt;br /&gt;
| CODE x || Gets ASCII code for a character&lt;br /&gt;
|-&lt;br /&gt;
| INT x || Rounds x down to integer&lt;br /&gt;
|-&lt;br /&gt;
| LEN x || Gets length of string&lt;br /&gt;
|-&lt;br /&gt;
| PI || Returns approximation of pi&lt;br /&gt;
|-&lt;br /&gt;
| RND || Returns a random number between 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| SCREEN$ x,y || Returns text character in text cell x,y&lt;br /&gt;
|-&lt;br /&gt;
| SIGN x || Divides x by its magnitude&lt;br /&gt;
|-&lt;br /&gt;
| SIN x, COS x, TAN x || Returns standard trigonometric ratio&lt;br /&gt;
|-&lt;br /&gt;
| SQR x || Returns square of x&lt;br /&gt;
|-&lt;br /&gt;
| STR$ x || Converts number into a string&lt;br /&gt;
|-&lt;br /&gt;
| USR x || If x is a string, gets the address of the first byte of the user defined graphic for the character. If x is a number, runs a machine code routine at address x and returns the value of BC after it exits.&lt;br /&gt;
|-&lt;br /&gt;
| VAL x || Converts string number or expression into a number&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1254</id>
		<title>NextBASIC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1254"/>
		<updated>2019-04-28T08:22:11Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.&lt;br /&gt;
&lt;br /&gt;
? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parenthesis are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.&lt;br /&gt;
&lt;br /&gt;
== Basic Interaction Commands ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LIST x? || Lists source code in bank b (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b MERGE || Adds all basic lines in bank b to main program&lt;br /&gt;
|-&lt;br /&gt;
| CONTINUE || Repeats last command or restarts from error location&lt;br /&gt;
|-&lt;br /&gt;
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)&lt;br /&gt;
|-&lt;br /&gt;
| ERASE f, l || Deletes all program lines between f and l. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| LIST x? || Lists source code (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| LLIST x? || Lists source code to printer (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| NEW || Clear stored program&lt;br /&gt;
|-&lt;br /&gt;
| RUN x? || CLEAR then run program (from line x)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO TO x || Jump execution to line x stored in bank b. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO SUB x || Jump execution to line x stored in bank b, storing current location on gosub stack. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression. Will not work if moved into any bank other than the main program&lt;br /&gt;
|-&lt;br /&gt;
| DIM a(x[,y]..) || Defines a as an array of length x (and second dimension length y, etc..)&lt;br /&gt;
|-&lt;br /&gt;
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)&lt;br /&gt;
|-&lt;br /&gt;
| GO TO x || Jump execution to line X in the same bank&lt;br /&gt;
|-&lt;br /&gt;
| GO SUB x || Jump execution to line X in the same bank, storing current location (and bank) on gosub stack&lt;br /&gt;
|-&lt;br /&gt;
| IF c THEN statements.. || Run statements only if expression c is true &lt;br /&gt;
|-&lt;br /&gt;
| LET var = expr || Sets variable var to expr&lt;br /&gt;
|-&lt;br /&gt;
| NEXT var || Marks end of FOR loop regarding VAR&lt;br /&gt;
|-&lt;br /&gt;
| REM comment || Code comment, ignored&lt;br /&gt;
|-&lt;br /&gt;
| RETURN || Restore execution location (line and bank) from gosub stack&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Console I/O ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| COPY || Prints screen&lt;br /&gt;
|-&lt;br /&gt;
| INKEY$ || Returns currently pressed key&lt;br /&gt;
|-&lt;br /&gt;
| INPUT specifier [connector specifier].. || Output expression(s) and read a variable&lt;br /&gt;
|-&lt;br /&gt;
| INVERSE x || Enable or disable switching ink/paper color when printing (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LPRINT specifier [connector specifier].. || Output expression(s) to printer&lt;br /&gt;
|-&lt;br /&gt;
| OVER x || Enable or disable overprinting (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| PAUSE x || Waits x frames or until a key is pressed&lt;br /&gt;
|-&lt;br /&gt;
| PRINT specifier [connector specifier].. || Output expression(s)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible specifiers for PRINT and INPUT statements are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| var || In PRINT, shows contents of var; in INPUT, inputs into this var&lt;br /&gt;
|-&lt;br /&gt;
| (var) || Shows contents of var (in both PRINT and INPUT)&lt;br /&gt;
|-&lt;br /&gt;
| AT x,y || Moves text cursor to the given text cell &lt;br /&gt;
|-&lt;br /&gt;
| TAB x || Inserts spaces until text cursor is in column x&lt;br /&gt;
|-&lt;br /&gt;
| INK x, PAPER x || Changes the appropriate color for the duration of the print/input statement&lt;br /&gt;
|-&lt;br /&gt;
| LINE x$ || INPUT only, reads a string without the prompting quotes&lt;br /&gt;
|-&lt;br /&gt;
| #x || Selects input/output channel number&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And the connectors between these are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| , || Separate with a tab&lt;br /&gt;
|-&lt;br /&gt;
| &#039; || Separate with a newline&lt;br /&gt;
|-&lt;br /&gt;
| ; || Use no separator&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File I/O ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| CAT || Displays disk/tape catalogue&lt;br /&gt;
|-&lt;br /&gt;
| FORMAT || Prepares inserted disk for usage, erasing it&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn || Load BASIC program from file named fn&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn DATA x() || Load data from fn into array x()&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn CODE addr || Load data from fn into memory at address addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn SCREEN$ || Load data from fn onto standard ULA screen&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn BANK b,addr || Load data from fn into memory bank b at addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn LAYER || Load data from fn onto current layer&lt;br /&gt;
|-&lt;br /&gt;
| MERGE fn || Loads BASIC lines from file named fn and integrates them with current program&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (LINE l)? || Save BASIC program to file named fn (and set up autorun at line l)&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (DATA/CODE/SCREEN$/BANK/LAYER..) || Save data as specified; CODE and BANK have an extra &amp;quot;length&amp;quot; parameter&lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn || Checks loaded basic program matches fn &lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn (DATA/CODE/BANK) || Checks data in memory/array matches contents of fn; does not work with SCREEN$/LAYER because the screen is inevitably changed during the verify operation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Inline data ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b RESTORE x || Sets DATA read point to start of line x in bank b&lt;br /&gt;
|-&lt;br /&gt;
| DATA x[,y].. || Stores data in program for later READing&lt;br /&gt;
|-&lt;br /&gt;
| READ var || Read next value from DATA statement into variable&lt;br /&gt;
|-&lt;br /&gt;
| RESTORE x || Sets DATA read point to start of line x&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BORDER n || Set ULA border to color N&lt;br /&gt;
|-&lt;br /&gt;
| BRIGHT n || Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| CIRCLE x,y,r || Draw circle centered at x, y with radius r&lt;br /&gt;
|-&lt;br /&gt;
| CLS || Clears screen&lt;br /&gt;
|-&lt;br /&gt;
| DRAW [modifier or x,y].. || Draw line from plot cursor to given coordinate&lt;br /&gt;
|-&lt;br /&gt;
| FLASH n || Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| INK c || Set ink (foreground) color for print and graphics commands. If Enhanced ULA is enabled, this can use any legal palette value. On layer 2, it can use any value 0-255.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER x || Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, [[Layer 2]].&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 1,x || Sets mode for layer 1 based on x. 1 = Standard Spectrum, 2 = Timex hires, 3 = Timex hicolour, 0 = Lores Layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 2,x || Selects [[Layer 2]] and determines if it is displayed or not (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER AT x, y || Sets the scroll display offset for the current layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER BANK f, b || Only when [[Layer 2]] is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER CLEAR || Resets all layer settings&lt;br /&gt;
|-&lt;br /&gt;
| LAYER DIM left, top, right, bottom || Sets visible area for current layer&lt;br /&gt;
|-&lt;br /&gt;
| LAYER ERASE x, y, w, h [,f]? || Fills a region at x,y, of size w,h, with palette index f (or the transparent value)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER OVER || Sets layer ordering&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE x || Choose which of the two palettes is used for the active layer (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n, i, v || Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n BANK b, offset || Loads current layer&#039;s palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE CLEAR || Resets all palettes and palette settings&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE DIM x || Sets number of color bits in the active palette; x must be 8 or 9&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE FORMAT x || Enables Enhanced ULA colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE OVER x || Sets the global transparency color to x&lt;br /&gt;
|-&lt;br /&gt;
| PAPER c || Set paper (background) color for print and graphics commands. Follows the same rules as INK.&lt;br /&gt;
|-&lt;br /&gt;
| PLOT [modifier or x,y].. || Plot listed points as single pixels on current layer&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y, var || Stores the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039; in variable var&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y || Returns the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK x || Populates all 64 sprite patterns from bank b, taking 256 bytes per sprite and thus using all data in bank b.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK b, o, p, n || Define n sprite patterns, starting with p, with data from bank b starting at offset o.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x || Choose the first or second palette for sprites. X must be 0 or 1.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x BANK b, o || Load sprite palette x (0 or 1) from bank b at offset o. Data is read as with LAYER PALETTE.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE n, i, v || Set sprite palette n, index i, to color v. V is always 9-bit, even if PALETTE DIM 8 is in effect.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PRINT x || Enable or disable sprites. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BORDER x || Enable or disable sprites crossing the border. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE s, x, y, i, f || Set sprite f to image i at position x,y with flags f. f is bitmapped as byte 3 of data packets sent to {{PortNo|$xx57}}.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE CLEAR || Reset all sprite attributes and global settings.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tilemap support ===&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| TILE [AT x,y]? || Draw the entire screen from the tilemap (from tile offset (x,y))&lt;br /&gt;
|-&lt;br /&gt;
| TILE w,h [AT x,y]? [TO x2,y2]? || Draw a section of the tilemap w,h wide (from tile offset x,y in the tilemap) (to tile offset x2,y2 on the screen)&lt;br /&gt;
|-&lt;br /&gt;
| TILE BANK n || Set bank n as the root of tile graphics (which may occupy up to 4 banks in the case of 16x16 tiles).&lt;br /&gt;
|-&lt;br /&gt;
| TILE DIM n, o, v, t || Set bank n offset o as the root of tilemap data, with tilemap width v and tile size t (t must be 8 or 16 for 8x8 or 16x16 tiles)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Memory and Port Access ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 FORMAT || Re-enable RAMdisk having been disabled by previous BANK 1346 USR&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 USR || Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY TO c || Copy entire bank b to bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY start, len TO c, start || Copy len bytes from start in bank b, to start in bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE x? || Erase all data in bank by overwriting with zeros (or x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE off, len, value || Overwrite len bytes of data at off in bank b with value&lt;br /&gt;
|-&lt;br /&gt;
| BANK b PEEK addr || Returns value at given address in bank b (address is from start of bank)&lt;br /&gt;
|- &lt;br /&gt;
| BANK b POKE addr, value || Sets address in bank b to value (address is from start of bank)&lt;br /&gt;
|-&lt;br /&gt;
| IN port || Returns current value at port&lt;br /&gt;
|-&lt;br /&gt;
| PEEK addr || Returns value at given address&lt;br /&gt;
|-&lt;br /&gt;
| POKE addr, value || Sets address to value&lt;br /&gt;
|-&lt;br /&gt;
| OUT port, value || Sends value to port&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Functions/Expressions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| + - * / ^ || Standard arithmetic operators&lt;br /&gt;
|-&lt;br /&gt;
| = &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= &amp;lt;&amp;gt; || Standard comparison operators (arithmetic for numbers, alphabetic for strings)&lt;br /&gt;
|-&lt;br /&gt;
| a(x) || Returns x&#039;th element of array/string a&lt;br /&gt;
|-&lt;br /&gt;
| s(x? TO y?) || Return substring of s; if x or y are omitted, start or end is assumed&lt;br /&gt;
|-&lt;br /&gt;
| AND OR NOT || Standard boolean conjunctives&lt;br /&gt;
|-&lt;br /&gt;
| ABS x || Gets unsigned magnitude of x&lt;br /&gt;
|-&lt;br /&gt;
| ASN x, ACS x, ATN x || Returns inverse trigonometric ratio (arcsin, arccos, arctan)&lt;br /&gt;
|-&lt;br /&gt;
| ATTR x,y || Returns attribute cell value at cell x,y &lt;br /&gt;
|-&lt;br /&gt;
| BIN x || Converts binary number x to decimal&lt;br /&gt;
|-&lt;br /&gt;
| CHR$ x || Gets character for an ASCII code&lt;br /&gt;
|-&lt;br /&gt;
| CODE x || Gets ASCII code for a character&lt;br /&gt;
|-&lt;br /&gt;
| INT x || Rounds x down to integer&lt;br /&gt;
|-&lt;br /&gt;
| LEN x || Gets length of string&lt;br /&gt;
|-&lt;br /&gt;
| PI || Returns approximation of pi&lt;br /&gt;
|-&lt;br /&gt;
| RND || Returns a random number between 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| SCREEN$ x,y || Returns text character in text cell x,y&lt;br /&gt;
|-&lt;br /&gt;
| SIGN x || Divides x by its magnitude&lt;br /&gt;
|-&lt;br /&gt;
| SIN x, COS x, TAN x || Returns standard trigonometric ratio&lt;br /&gt;
|-&lt;br /&gt;
| SQR x || Returns square of x&lt;br /&gt;
|-&lt;br /&gt;
| STR$ x || Converts number into a string&lt;br /&gt;
|-&lt;br /&gt;
| USR x || If x is a string, gets the address of the first byte of the user defined graphic for the character. If x is a number, runs a machine code routine at address x and returns the value of BC after it exits.&lt;br /&gt;
|-&lt;br /&gt;
| VAL x || Converts string number or expression into a number&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1253</id>
		<title>NextBASIC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1253"/>
		<updated>2019-04-28T08:18:41Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.&lt;br /&gt;
&lt;br /&gt;
? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parenthesis are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.&lt;br /&gt;
&lt;br /&gt;
== Basic Interaction Commands ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LIST x? || Lists source code in bank b (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b MERGE || Adds all basic lines in bank b to main program&lt;br /&gt;
|-&lt;br /&gt;
| CONTINUE || Repeats last command or restarts from error location&lt;br /&gt;
|-&lt;br /&gt;
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)&lt;br /&gt;
|-&lt;br /&gt;
| ERASE f, l || Deletes all program lines between f and l. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| LIST x? || Lists source code (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| LLIST x? || Lists source code to printer (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| NEW || Clear stored program&lt;br /&gt;
|-&lt;br /&gt;
| RUN x? || CLEAR then run program (from line x)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO TO x || Jump execution to line x stored in bank b. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO SUB x || Jump execution to line x stored in bank b, storing current location on gosub stack. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression. Will not work if moved into any bank other than the main program&lt;br /&gt;
|-&lt;br /&gt;
| DIM a(x[,y]..) || Defines a as an array of length x (and second dimension length y, etc..)&lt;br /&gt;
|-&lt;br /&gt;
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)&lt;br /&gt;
|-&lt;br /&gt;
| GO TO x || Jump execution to line X in the same bank&lt;br /&gt;
|-&lt;br /&gt;
| GO SUB x || Jump execution to line X in the same bank, storing current location (and bank) on gosub stack&lt;br /&gt;
|-&lt;br /&gt;
| IF c THEN statements.. || Run statements only if expression c is true &lt;br /&gt;
|-&lt;br /&gt;
| LET var = expr || Sets variable var to expr&lt;br /&gt;
|-&lt;br /&gt;
| NEXT var || Marks end of FOR loop regarding VAR&lt;br /&gt;
|-&lt;br /&gt;
| REM comment || Code comment, ignored&lt;br /&gt;
|-&lt;br /&gt;
| RETURN || Restore execution location (line and bank) from gosub stack&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Console I/O ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| COPY || Prints screen&lt;br /&gt;
|-&lt;br /&gt;
| INKEY$ || Returns currently pressed key&lt;br /&gt;
|-&lt;br /&gt;
| INPUT specifier [connector specifier].. || Output expression(s) and read a variable&lt;br /&gt;
|-&lt;br /&gt;
| INVERSE x || Enable or disable switching ink/paper color when printing (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LPRINT specifier [connector specifier].. || Output expression(s) to printer&lt;br /&gt;
|-&lt;br /&gt;
| OVER x || Enable or disable overprinting (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| PAUSE x || Waits x frames or until a key is pressed&lt;br /&gt;
|-&lt;br /&gt;
| PRINT specifier [connector specifier].. || Output expression(s)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible specifiers for PRINT and INPUT statements are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| var || In PRINT, shows contents of var; in INPUT, inputs into this var&lt;br /&gt;
|-&lt;br /&gt;
| (var) || Shows contents of var (in both PRINT and INPUT)&lt;br /&gt;
|-&lt;br /&gt;
| AT x,y || Moves text cursor to the given text cell &lt;br /&gt;
|-&lt;br /&gt;
| TAB x || Inserts spaces until text cursor is in column x&lt;br /&gt;
|-&lt;br /&gt;
| INK x, PAPER x || Changes the appropriate color for the duration of the print/input statement&lt;br /&gt;
|-&lt;br /&gt;
| LINE x$ || INPUT only, reads a string without the prompting quotes&lt;br /&gt;
|-&lt;br /&gt;
| #x || Selects input/output channel number&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And the connectors between these are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| , || Separate with a tab&lt;br /&gt;
|-&lt;br /&gt;
| &#039; || Separate with a newline&lt;br /&gt;
|-&lt;br /&gt;
| ; || Use no separator&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File I/O ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| CAT || Displays disk/tape catalogue&lt;br /&gt;
|-&lt;br /&gt;
| FORMAT || Prepares inserted disk for usage, erasing it&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn || Load BASIC program from file named fn&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn DATA x() || Load data from fn into array x()&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn CODE addr || Load data from fn into memory at address addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn SCREEN$ || Load data from fn onto standard ULA screen&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn BANK b,addr || Load data from fn into memory bank b at addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn LAYER || Load data from fn onto current layer&lt;br /&gt;
|-&lt;br /&gt;
| MERGE fn || Loads BASIC lines from file named fn and integrates them with current program&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (LINE l)? || Save BASIC program to file named fn (and set up autorun at line l)&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (DATA/CODE/SCREEN$/BANK/LAYER..) || Save data as specified; CODE and BANK have an extra &amp;quot;length&amp;quot; parameter&lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn || Checks loaded basic program matches fn &lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn (DATA/CODE/BANK) || Checks data in memory/array matches contents of fn; does not work with SCREEN$/LAYER because the screen is inevitably changed during the verify operation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Inline data ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b RESTORE x || Sets DATA read point to start of line x in bank b&lt;br /&gt;
|-&lt;br /&gt;
| DATA x[,y].. || Stores data in program for later READing&lt;br /&gt;
|-&lt;br /&gt;
| READ var || Read next value from DATA statement into variable&lt;br /&gt;
|-&lt;br /&gt;
| RESTORE x || Sets DATA read point to start of line x&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BORDER n || Set ULA border to color N&lt;br /&gt;
|-&lt;br /&gt;
| BRIGHT n || Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| CIRCLE x,y,r || Draw circle centered at x, y with radius r&lt;br /&gt;
|-&lt;br /&gt;
| CLS || Clears screen&lt;br /&gt;
|-&lt;br /&gt;
| DRAW [modifier or x,y].. || Draw line from plot cursor to given coordinate&lt;br /&gt;
|-&lt;br /&gt;
| FLASH n || Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| INK c || Set ink (foreground) color for print and graphics commands. If Enhanced ULA is enabled, this can use any legal palette value. On layer 2, it can use any value 0-255.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER x || Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, [[Layer 2]].&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 1,x || Sets mode for layer 1 based on x. 1 = Standard Spectrum, 2 = Timex hires, 3 = Timex hicolour, 0 = Lores Layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 2,x || Selects [[Layer 2]] and determines if it is displayed or not (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER AT x, y || Sets the scroll display offset for the current layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER BANK f, b || Only when [[Layer 2]] is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER CLEAR || Resets all layer settings&lt;br /&gt;
|-&lt;br /&gt;
| LAYER DIM left, top, right, bottom || Sets visible area for current layer&lt;br /&gt;
|-&lt;br /&gt;
| LAYER ERASE x, y, w, h [,f]? || Fills a region at x,y, of size w,h, with palette index f (or the transparent value)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER OVER || Sets layer ordering&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE x || Choose which of the two palettes is used for the active layer (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n, i, v || Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n BANK b, offset || Loads current layer&#039;s palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE CLEAR || Resets all palettes and palette settings&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE DIM x || Sets number of color bits in the active palette; x must be 8 or 9&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE FORMAT x || Enables [[Enhanced ULA]] colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE OVER x || Sets the global transparency color to x&lt;br /&gt;
|-&lt;br /&gt;
| PAPER c || Set paper (background) color for print and graphics commands. Follows the same rules as INK.&lt;br /&gt;
|-&lt;br /&gt;
| PLOT [modifier or x,y].. || Plot listed points as single pixels on current layer&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y, var || Stores the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039; in variable var&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y || Returns the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK x || Populates all 64 sprite patterns from bank b, taking 256 bytes per sprite and thus using all data in bank b.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK b, o, p, n || Define n sprite patterns, starting with p, with data from bank b starting at offset o.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x || Choose the first or second palette for sprites. X must be 0 or 1.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x BANK b, o || Load sprite palette x (0 or 1) from bank b at offset o. Data is read as with LAYER PALETTE.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE n, i, v || Set sprite palette n, index i, to color v. V is always 9-bit, even if PALETTE DIM 8 is in effect.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PRINT x || Enable or disable sprites. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BORDER x || Enable or disable sprites crossing the border. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE s, x, y, i, f || Set sprite f to image i at position x,y with flags f. f is bitmapped as byte 3 of data packets sent to {{PortNo|$xx57}}.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE CLEAR || Reset all sprite attributes and global settings.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tilemap support ===&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| TILE [AT x,y]? || Draw the entire screen from the tilemap (from tile offset (x,y))&lt;br /&gt;
|-&lt;br /&gt;
| TILE w,h [AT x,y]? [TO x2,y2]? || Draw a section of the tilemap w,h wide (from tile offset x,y in the tilemap) (to tile offset x2,y2 on the screen)&lt;br /&gt;
|-&lt;br /&gt;
| TILE BANK n || Set bank n as the root of tile graphics (which may occupy up to 4 banks in the case of 16x16 tiles).&lt;br /&gt;
|-&lt;br /&gt;
| TILE DIM n, o, v, t || Set bank n offset o as the root of tilemap data, with tilemap width v and tile size t (t must be 8 or 16 for 8x8 or 16x16 tiles)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Memory and Port Access ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 FORMAT || Re-enable RAMdisk having been disabled by previous BANK 1346 USR&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 USR || Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY TO c || Copy entire bank b to bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY start, len TO c, start || Copy len bytes from start in bank b, to start in bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE x? || Erase all data in bank by overwriting with zeros (or x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE off, len, value || Overwrite len bytes of data at off in bank b with value&lt;br /&gt;
|-&lt;br /&gt;
| BANK b PEEK addr || Returns value at given address in bank b (address is from start of bank)&lt;br /&gt;
|- &lt;br /&gt;
| BANK b POKE addr, value || Sets address in bank b to value (address is from start of bank)&lt;br /&gt;
|-&lt;br /&gt;
| IN port || Returns current value at port&lt;br /&gt;
|-&lt;br /&gt;
| PEEK addr || Returns value at given address&lt;br /&gt;
|-&lt;br /&gt;
| POKE addr, value || Sets address to value&lt;br /&gt;
|-&lt;br /&gt;
| OUT port, value || Sends value to port&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Functions/Expressions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| + - * / ^ || Standard arithmetic operators&lt;br /&gt;
|-&lt;br /&gt;
| = &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= &amp;lt;&amp;gt; || Standard comparison operators (arithmetic for numbers, alphabetic for strings)&lt;br /&gt;
|-&lt;br /&gt;
| a(x) || Returns x&#039;th element of array/string a&lt;br /&gt;
|-&lt;br /&gt;
| s(x? TO y?) || Return substring of s; if x or y are omitted, start or end is assumed&lt;br /&gt;
|-&lt;br /&gt;
| AND OR NOT || Standard boolean conjunctives&lt;br /&gt;
|-&lt;br /&gt;
| ABS x || Gets unsigned magnitude of x&lt;br /&gt;
|-&lt;br /&gt;
| ASN x, ACS x, ATN x || Returns inverse trigonometric ratio (arcsin, arccos, arctan)&lt;br /&gt;
|-&lt;br /&gt;
| ATTR x,y || Returns attribute cell value at cell x,y &lt;br /&gt;
|-&lt;br /&gt;
| BIN x || Converts binary number x to decimal&lt;br /&gt;
|-&lt;br /&gt;
| CHR$ x || Gets character for an ASCII code&lt;br /&gt;
|-&lt;br /&gt;
| CODE x || Gets ASCII code for a character&lt;br /&gt;
|-&lt;br /&gt;
| INT x || Rounds x down to integer&lt;br /&gt;
|-&lt;br /&gt;
| LEN x || Gets length of string&lt;br /&gt;
|-&lt;br /&gt;
| PI || Returns approximation of pi&lt;br /&gt;
|-&lt;br /&gt;
| RND || Returns a random number between 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| SCREEN$ x,y || Returns text character in text cell x,y&lt;br /&gt;
|-&lt;br /&gt;
| SIGN x || Divides x by its magnitude&lt;br /&gt;
|-&lt;br /&gt;
| SIN x, COS x, TAN x || Returns standard trigonometric ratio&lt;br /&gt;
|-&lt;br /&gt;
| SQR x || Returns square of x&lt;br /&gt;
|-&lt;br /&gt;
| STR$ x || Converts number into a string&lt;br /&gt;
|-&lt;br /&gt;
| USR x || If x is a string, gets the address of the first byte of the user defined graphic for the character. If x is a number, runs a machine code routine at address x and returns the value of BC after it exits.&lt;br /&gt;
|-&lt;br /&gt;
| VAL x || Converts string number or expression into a number&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1252</id>
		<title>NextBASIC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1252"/>
		<updated>2019-04-28T08:16:04Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.&lt;br /&gt;
&lt;br /&gt;
? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parenthesis are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.&lt;br /&gt;
&lt;br /&gt;
== Basic Interaction Commands ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LIST x? || Lists source code in bank b (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b MERGE || Adds all basic lines in bank b to main program&lt;br /&gt;
|-&lt;br /&gt;
| CONTINUE || Repeats last command or restarts from error location&lt;br /&gt;
|-&lt;br /&gt;
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)&lt;br /&gt;
|-&lt;br /&gt;
| ERASE f, l || Deletes all program lines between f and l. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| LIST x? || Lists source code (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| LLIST x? || Lists source code to printer (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| NEW || Clear stored program&lt;br /&gt;
|-&lt;br /&gt;
| RUN x? || CLEAR then run program (from line x)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO TO x || Jump execution to line x stored in bank b. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO SUB x || Jump execution to line x stored in bank b, storing current location on gosub stack. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression. Will not work if moved into any bank other than the main program&lt;br /&gt;
|-&lt;br /&gt;
| DIM a(x[,y]..) || Defines a as an array of length x (and second dimension length y, etc..)&lt;br /&gt;
|-&lt;br /&gt;
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)&lt;br /&gt;
|-&lt;br /&gt;
| GO TO x || Jump execution to line X in the same bank&lt;br /&gt;
|-&lt;br /&gt;
| GO SUB x || Jump execution to line X in the same bank, storing current location (and bank) on gosub stack&lt;br /&gt;
|-&lt;br /&gt;
| IF c THEN statements.. || Run statements only if expression c is true &lt;br /&gt;
|-&lt;br /&gt;
| LET var = expr || Sets variable var to expr&lt;br /&gt;
|-&lt;br /&gt;
| NEXT var || Marks end of FOR loop regarding VAR&lt;br /&gt;
|-&lt;br /&gt;
| REM comment || Code comment, ignored&lt;br /&gt;
|-&lt;br /&gt;
| RETURN || Restore execution location (line and bank) from gosub stack&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Console I/O ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| COPY || Prints screen&lt;br /&gt;
|-&lt;br /&gt;
| INKEY$ || Returns currently pressed key&lt;br /&gt;
|-&lt;br /&gt;
| INPUT specifier [connector specifier].. || Output expression(s) and read a variable&lt;br /&gt;
|-&lt;br /&gt;
| INVERSE x || Enable or disable switching ink/paper color when printing (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LPRINT specifier [connector specifier].. || Output expression(s) to printer&lt;br /&gt;
|-&lt;br /&gt;
| OVER x || Enable or disable overprinting (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| PAUSE x || Waits x frames or until a key is pressed&lt;br /&gt;
|-&lt;br /&gt;
| PRINT specifier [connector specifier].. || Output expression(s)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible specifiers for PRINT and INPUT statements are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| var || In PRINT, shows contents of var; in INPUT, inputs into this var&lt;br /&gt;
|-&lt;br /&gt;
| (var) || Shows contents of var (in both PRINT and INPUT)&lt;br /&gt;
|-&lt;br /&gt;
| AT x,y || Moves text cursor to the given text cell &lt;br /&gt;
|-&lt;br /&gt;
| TAB x || Inserts spaces until text cursor is in column x&lt;br /&gt;
|-&lt;br /&gt;
| INK x, PAPER x || Changes the appropriate color for the duration of the print/input statement&lt;br /&gt;
|-&lt;br /&gt;
| LINE x$ || INPUT only, reads a string without the prompting quotes&lt;br /&gt;
|-&lt;br /&gt;
| #x || Selects input/output channel number&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And the connectors between these are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| , || Separate with a tab&lt;br /&gt;
|-&lt;br /&gt;
| &#039; || Separate with a newline&lt;br /&gt;
|-&lt;br /&gt;
| ; || Use no separator&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File I/O ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| CAT || Displays disk/tape catalogue&lt;br /&gt;
|-&lt;br /&gt;
| FORMAT || Prepares inserted disk for usage, erasing it&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn || Load BASIC program from file named fn&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn DATA x() || Load data from fn into array x()&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn CODE addr || Load data from fn into memory at address addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn SCREEN$ || Load data from fn onto standard ULA screen&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn BANK b,addr || Load data from fn into memory bank b at addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn LAYER || Load data from fn onto current layer&lt;br /&gt;
|-&lt;br /&gt;
| MERGE fn || Loads BASIC lines from file named fn and integrates them with current program&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (LINE l)? || Save BASIC program to file named fn (and set up autorun at line l)&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (DATA/CODE/SCREEN$/BANK/LAYER..) || Save data as specified; CODE and BANK have an extra &amp;quot;length&amp;quot; parameter&lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn || Checks loaded basic program matches fn &lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn (DATA/CODE/BANK) || Checks data in memory/array matches contents of fn; does not work with SCREEN$/LAYER because the screen is inevitably changed during the verify operation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Inline data ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b RESTORE x || Sets DATA read point to start of line x in bank b&lt;br /&gt;
|-&lt;br /&gt;
| DATA x[,y].. || Stores data in program for later READing&lt;br /&gt;
|-&lt;br /&gt;
| READ var || Read next value from DATA statement into variable&lt;br /&gt;
|-&lt;br /&gt;
| RESTORE x || Sets DATA read point to start of line x&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BORDER n || Set ULA border to color N&lt;br /&gt;
|-&lt;br /&gt;
| BRIGHT n || Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| CIRCLE x,y,r || Draw circle centered at x, y with radius r&lt;br /&gt;
|-&lt;br /&gt;
| CLS || Clears screen&lt;br /&gt;
|-&lt;br /&gt;
| DRAW [modifier or x,y].. || Draw line from plot cursor to given coordinate&lt;br /&gt;
|-&lt;br /&gt;
| FLASH n || Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| INK c || Set ink (foreground) color for print and graphics commands. If Enhanced ULA is enabled, this can use any legal palette value. On layer 2, it can use any value 0-255.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER x || Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, [[Layer 2]].&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 1,x || Sets mode for layer 1 based on x. 1 = Standard Spectrum, 2 = Timex hires, 3 = Timex hicolour, 0 = Lores Layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 2,x || Selects [[Layer 2]] and determines if it is displayed or not (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER AT x, y || Sets the scroll display offset for the current layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER BANK f, b || Only when [[Layer 2]] is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER CLEAR || Resets all layer settings&lt;br /&gt;
|-&lt;br /&gt;
| LAYER DIM left, top, right, bottom || Sets visible area for current layer&lt;br /&gt;
|-&lt;br /&gt;
| LAYER ERASE x, y, w, h [,f]? || Fills a region at x,y, of size w,h, with palette index f (or the transparent value)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER OVER || Sets layer ordering&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE x || Choose which of the two palettes is used for the active layer (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n, i, v || Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n BANK b, offset || Loads current layer&#039;s palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE CLEAR || Resets all palettes and palette settings&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE DIM x || Sets number of color bits in the active palette; x must be 8 or 9&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE FORMAT x || Enables [[Video Modes:Enhanced video modes:Enhanced ULA|Enhanced ULA]] colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE OVER x || Sets the global transparency color to x&lt;br /&gt;
|-&lt;br /&gt;
| PAPER c || Set paper (background) color for print and graphics commands. Follows the same rules as INK.&lt;br /&gt;
|-&lt;br /&gt;
| PLOT [modifier or x,y].. || Plot listed points as single pixels on current layer&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y, var || Stores the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039; in variable var&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y || Returns the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK x || Populates all 64 sprite patterns from bank b, taking 256 bytes per sprite and thus using all data in bank b.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK b, o, p, n || Define n sprite patterns, starting with p, with data from bank b starting at offset o.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x || Choose the first or second palette for sprites. X must be 0 or 1.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x BANK b, o || Load sprite palette x (0 or 1) from bank b at offset o. Data is read as with LAYER PALETTE.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE n, i, v || Set sprite palette n, index i, to color v. V is always 9-bit, even if PALETTE DIM 8 is in effect.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PRINT x || Enable or disable sprites. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BORDER x || Enable or disable sprites crossing the border. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE s, x, y, i, f || Set sprite f to image i at position x,y with flags f. f is bitmapped as byte 3 of data packets sent to {{PortNo|$xx57}}.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE CLEAR || Reset all sprite attributes and global settings.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tilemap support ===&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| TILE [AT x,y]? || Draw the entire screen from the tilemap (from tile offset (x,y))&lt;br /&gt;
|-&lt;br /&gt;
| TILE w,h [AT x,y]? [TO x2,y2]? || Draw a section of the tilemap w,h wide (from tile offset x,y in the tilemap) (to tile offset x2,y2 on the screen)&lt;br /&gt;
|-&lt;br /&gt;
| TILE BANK n || Set bank n as the root of tile graphics (which may occupy up to 4 banks in the case of 16x16 tiles).&lt;br /&gt;
|-&lt;br /&gt;
| TILE DIM n, o, v, t || Set bank n offset o as the root of tilemap data, with tilemap width v and tile size t (t must be 8 or 16 for 8x8 or 16x16 tiles)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Memory and Port Access ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 FORMAT || Re-enable RAMdisk having been disabled by previous BANK 1346 USR&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 USR || Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY TO c || Copy entire bank b to bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY start, len TO c, start || Copy len bytes from start in bank b, to start in bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE x? || Erase all data in bank by overwriting with zeros (or x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE off, len, value || Overwrite len bytes of data at off in bank b with value&lt;br /&gt;
|-&lt;br /&gt;
| BANK b PEEK addr || Returns value at given address in bank b (address is from start of bank)&lt;br /&gt;
|- &lt;br /&gt;
| BANK b POKE addr, value || Sets address in bank b to value (address is from start of bank)&lt;br /&gt;
|-&lt;br /&gt;
| IN port || Returns current value at port&lt;br /&gt;
|-&lt;br /&gt;
| PEEK addr || Returns value at given address&lt;br /&gt;
|-&lt;br /&gt;
| POKE addr, value || Sets address to value&lt;br /&gt;
|-&lt;br /&gt;
| OUT port, value || Sends value to port&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Functions/Expressions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| + - * / ^ || Standard arithmetic operators&lt;br /&gt;
|-&lt;br /&gt;
| = &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= &amp;lt;&amp;gt; || Standard comparison operators (arithmetic for numbers, alphabetic for strings)&lt;br /&gt;
|-&lt;br /&gt;
| a(x) || Returns x&#039;th element of array/string a&lt;br /&gt;
|-&lt;br /&gt;
| s(x? TO y?) || Return substring of s; if x or y are omitted, start or end is assumed&lt;br /&gt;
|-&lt;br /&gt;
| AND OR NOT || Standard boolean conjunctives&lt;br /&gt;
|-&lt;br /&gt;
| ABS x || Gets unsigned magnitude of x&lt;br /&gt;
|-&lt;br /&gt;
| ASN x, ACS x, ATN x || Returns inverse trigonometric ratio (arcsin, arccos, arctan)&lt;br /&gt;
|-&lt;br /&gt;
| ATTR x,y || Returns attribute cell value at cell x,y &lt;br /&gt;
|-&lt;br /&gt;
| BIN x || Converts binary number x to decimal&lt;br /&gt;
|-&lt;br /&gt;
| CHR$ x || Gets character for an ASCII code&lt;br /&gt;
|-&lt;br /&gt;
| CODE x || Gets ASCII code for a character&lt;br /&gt;
|-&lt;br /&gt;
| INT x || Rounds x down to integer&lt;br /&gt;
|-&lt;br /&gt;
| LEN x || Gets length of string&lt;br /&gt;
|-&lt;br /&gt;
| PI || Returns approximation of pi&lt;br /&gt;
|-&lt;br /&gt;
| RND || Returns a random number between 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| SCREEN$ x,y || Returns text character in text cell x,y&lt;br /&gt;
|-&lt;br /&gt;
| SIGN x || Divides x by its magnitude&lt;br /&gt;
|-&lt;br /&gt;
| SIN x, COS x, TAN x || Returns standard trigonometric ratio&lt;br /&gt;
|-&lt;br /&gt;
| SQR x || Returns square of x&lt;br /&gt;
|-&lt;br /&gt;
| STR$ x || Converts number into a string&lt;br /&gt;
|-&lt;br /&gt;
| USR x || If x is a string, gets the address of the first byte of the user defined graphic for the character. If x is a number, runs a machine code routine at address x and returns the value of BC after it exits.&lt;br /&gt;
|-&lt;br /&gt;
| VAL x || Converts string number or expression into a number&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1251</id>
		<title>NextBASIC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1251"/>
		<updated>2019-04-28T08:14:37Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.&lt;br /&gt;
&lt;br /&gt;
? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parenthesis are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.&lt;br /&gt;
&lt;br /&gt;
== Basic Interaction Commands ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LIST x? || Lists source code in bank b (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b MERGE || Adds all basic lines in bank b to main program&lt;br /&gt;
|-&lt;br /&gt;
| CONTINUE || Repeats last command or restarts from error location&lt;br /&gt;
|-&lt;br /&gt;
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)&lt;br /&gt;
|-&lt;br /&gt;
| ERASE f, l || Deletes all program lines between f and l. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| LIST x? || Lists source code (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| LLIST x? || Lists source code to printer (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| NEW || Clear stored program&lt;br /&gt;
|-&lt;br /&gt;
| RUN x? || CLEAR then run program (from line x)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO TO x || Jump execution to line x stored in bank b. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO SUB x || Jump execution to line x stored in bank b, storing current location on gosub stack. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression. Will not work if moved into any bank other than the main program&lt;br /&gt;
|-&lt;br /&gt;
| DIM a(x[,y]..) || Defines a as an array of length x (and second dimension length y, etc..)&lt;br /&gt;
|-&lt;br /&gt;
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)&lt;br /&gt;
|-&lt;br /&gt;
| GO TO x || Jump execution to line X in the same bank&lt;br /&gt;
|-&lt;br /&gt;
| GO SUB x || Jump execution to line X in the same bank, storing current location (and bank) on gosub stack&lt;br /&gt;
|-&lt;br /&gt;
| IF c THEN statements.. || Run statements only if expression c is true &lt;br /&gt;
|-&lt;br /&gt;
| LET var = expr || Sets variable var to expr&lt;br /&gt;
|-&lt;br /&gt;
| NEXT var || Marks end of FOR loop regarding VAR&lt;br /&gt;
|-&lt;br /&gt;
| REM comment || Code comment, ignored&lt;br /&gt;
|-&lt;br /&gt;
| RETURN || Restore execution location (line and bank) from gosub stack&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Console I/O ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| COPY || Prints screen&lt;br /&gt;
|-&lt;br /&gt;
| INKEY$ || Returns currently pressed key&lt;br /&gt;
|-&lt;br /&gt;
| INPUT specifier [connector specifier].. || Output expression(s) and read a variable&lt;br /&gt;
|-&lt;br /&gt;
| INVERSE x || Enable or disable switching ink/paper color when printing (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LPRINT specifier [connector specifier].. || Output expression(s) to printer&lt;br /&gt;
|-&lt;br /&gt;
| OVER x || Enable or disable overprinting (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| PAUSE x || Waits x frames or until a key is pressed&lt;br /&gt;
|-&lt;br /&gt;
| PRINT specifier [connector specifier].. || Output expression(s)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible specifiers for PRINT and INPUT statements are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| var || In PRINT, shows contents of var; in INPUT, inputs into this var&lt;br /&gt;
|-&lt;br /&gt;
| (var) || Shows contents of var (in both PRINT and INPUT)&lt;br /&gt;
|-&lt;br /&gt;
| AT x,y || Moves text cursor to the given text cell &lt;br /&gt;
|-&lt;br /&gt;
| TAB x || Inserts spaces until text cursor is in column x&lt;br /&gt;
|-&lt;br /&gt;
| INK x, PAPER x || Changes the appropriate color for the duration of the print/input statement&lt;br /&gt;
|-&lt;br /&gt;
| LINE x$ || INPUT only, reads a string without the prompting quotes&lt;br /&gt;
|-&lt;br /&gt;
| #x || Selects input/output channel number&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And the connectors between these are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| , || Separate with a tab&lt;br /&gt;
|-&lt;br /&gt;
| &#039; || Separate with a newline&lt;br /&gt;
|-&lt;br /&gt;
| ; || Use no separator&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File I/O ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| CAT || Displays disk/tape catalogue&lt;br /&gt;
|-&lt;br /&gt;
| FORMAT || Prepares inserted disk for usage, erasing it&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn || Load BASIC program from file named fn&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn DATA x() || Load data from fn into array x()&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn CODE addr || Load data from fn into memory at address addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn SCREEN$ || Load data from fn onto standard ULA screen&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn BANK b,addr || Load data from fn into memory bank b at addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn LAYER || Load data from fn onto current layer&lt;br /&gt;
|-&lt;br /&gt;
| MERGE fn || Loads BASIC lines from file named fn and integrates them with current program&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (LINE l)? || Save BASIC program to file named fn (and set up autorun at line l)&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (DATA/CODE/SCREEN$/BANK/LAYER..) || Save data as specified; CODE and BANK have an extra &amp;quot;length&amp;quot; parameter&lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn || Checks loaded basic program matches fn &lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn (DATA/CODE/BANK) || Checks data in memory/array matches contents of fn; does not work with SCREEN$/LAYER because the screen is inevitably changed during the verify operation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Inline data ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b RESTORE x || Sets DATA read point to start of line x in bank b&lt;br /&gt;
|-&lt;br /&gt;
| DATA x[,y].. || Stores data in program for later READing&lt;br /&gt;
|-&lt;br /&gt;
| READ var || Read next value from DATA statement into variable&lt;br /&gt;
|-&lt;br /&gt;
| RESTORE x || Sets DATA read point to start of line x&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BORDER n || Set ULA border to color N&lt;br /&gt;
|-&lt;br /&gt;
| BRIGHT n || Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| CIRCLE x,y,r || Draw circle centered at x, y with radius r&lt;br /&gt;
|-&lt;br /&gt;
| CLS || Clears screen&lt;br /&gt;
|-&lt;br /&gt;
| DRAW [modifier or x,y].. || Draw line from plot cursor to given coordinate&lt;br /&gt;
|-&lt;br /&gt;
| FLASH n || Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| INK c || Set ink (foreground) color for print and graphics commands. If Enhanced ULA is enabled, this can use any legal palette value. On layer 2, it can use any value 0-255.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER x || Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, [[Layer 2]].&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 1,x || Sets mode for layer 1 based on x. 1 = Standard Spectrum, 2 = Timex hires, 3 = Timex hicolour, 0 = Lores Layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 2,x || Selects [[Layer 2]] and determines if it is displayed or not (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER AT x, y || Sets the scroll display offset for the current layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER BANK f, b || Only when [[Layer 2]] is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER CLEAR || Resets all layer settings&lt;br /&gt;
|-&lt;br /&gt;
| LAYER DIM left, top, right, bottom || Sets visible area for current layer&lt;br /&gt;
|-&lt;br /&gt;
| LAYER ERASE x, y, w, h [,f]? || Fills a region at x,y, of size w,h, with palette index f (or the transparent value)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER OVER || Sets layer ordering&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE x || Choose which of the two palettes is used for the active layer (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n, i, v || Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n BANK b, offset || Loads current layer&#039;s palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE CLEAR || Resets all palettes and palette settings&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE DIM x || Sets number of color bits in the active palette; x must be 8 or 9&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE FORMAT x || Enables [[Video Modes:Enhanced Video Modes:Enhanced ULA|Enhanced ULA]] colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE OVER x || Sets the global transparency color to x&lt;br /&gt;
|-&lt;br /&gt;
| PAPER c || Set paper (background) color for print and graphics commands. Follows the same rules as INK.&lt;br /&gt;
|-&lt;br /&gt;
| PLOT [modifier or x,y].. || Plot listed points as single pixels on current layer&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y, var || Stores the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039; in variable var&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y || Returns the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK x || Populates all 64 sprite patterns from bank b, taking 256 bytes per sprite and thus using all data in bank b.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK b, o, p, n || Define n sprite patterns, starting with p, with data from bank b starting at offset o.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x || Choose the first or second palette for sprites. X must be 0 or 1.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x BANK b, o || Load sprite palette x (0 or 1) from bank b at offset o. Data is read as with LAYER PALETTE.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE n, i, v || Set sprite palette n, index i, to color v. V is always 9-bit, even if PALETTE DIM 8 is in effect.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PRINT x || Enable or disable sprites. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BORDER x || Enable or disable sprites crossing the border. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE s, x, y, i, f || Set sprite f to image i at position x,y with flags f. f is bitmapped as byte 3 of data packets sent to {{PortNo|$xx57}}.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE CLEAR || Reset all sprite attributes and global settings.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tilemap support ===&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| TILE [AT x,y]? || Draw the entire screen from the tilemap (from tile offset (x,y))&lt;br /&gt;
|-&lt;br /&gt;
| TILE w,h [AT x,y]? [TO x2,y2]? || Draw a section of the tilemap w,h wide (from tile offset x,y in the tilemap) (to tile offset x2,y2 on the screen)&lt;br /&gt;
|-&lt;br /&gt;
| TILE BANK n || Set bank n as the root of tile graphics (which may occupy up to 4 banks in the case of 16x16 tiles).&lt;br /&gt;
|-&lt;br /&gt;
| TILE DIM n, o, v, t || Set bank n offset o as the root of tilemap data, with tilemap width v and tile size t (t must be 8 or 16 for 8x8 or 16x16 tiles)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Memory and Port Access ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 FORMAT || Re-enable RAMdisk having been disabled by previous BANK 1346 USR&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 USR || Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY TO c || Copy entire bank b to bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY start, len TO c, start || Copy len bytes from start in bank b, to start in bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE x? || Erase all data in bank by overwriting with zeros (or x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE off, len, value || Overwrite len bytes of data at off in bank b with value&lt;br /&gt;
|-&lt;br /&gt;
| BANK b PEEK addr || Returns value at given address in bank b (address is from start of bank)&lt;br /&gt;
|- &lt;br /&gt;
| BANK b POKE addr, value || Sets address in bank b to value (address is from start of bank)&lt;br /&gt;
|-&lt;br /&gt;
| IN port || Returns current value at port&lt;br /&gt;
|-&lt;br /&gt;
| PEEK addr || Returns value at given address&lt;br /&gt;
|-&lt;br /&gt;
| POKE addr, value || Sets address to value&lt;br /&gt;
|-&lt;br /&gt;
| OUT port, value || Sends value to port&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Functions/Expressions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| + - * / ^ || Standard arithmetic operators&lt;br /&gt;
|-&lt;br /&gt;
| = &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= &amp;lt;&amp;gt; || Standard comparison operators (arithmetic for numbers, alphabetic for strings)&lt;br /&gt;
|-&lt;br /&gt;
| a(x) || Returns x&#039;th element of array/string a&lt;br /&gt;
|-&lt;br /&gt;
| s(x? TO y?) || Return substring of s; if x or y are omitted, start or end is assumed&lt;br /&gt;
|-&lt;br /&gt;
| AND OR NOT || Standard boolean conjunctives&lt;br /&gt;
|-&lt;br /&gt;
| ABS x || Gets unsigned magnitude of x&lt;br /&gt;
|-&lt;br /&gt;
| ASN x, ACS x, ATN x || Returns inverse trigonometric ratio (arcsin, arccos, arctan)&lt;br /&gt;
|-&lt;br /&gt;
| ATTR x,y || Returns attribute cell value at cell x,y &lt;br /&gt;
|-&lt;br /&gt;
| BIN x || Converts binary number x to decimal&lt;br /&gt;
|-&lt;br /&gt;
| CHR$ x || Gets character for an ASCII code&lt;br /&gt;
|-&lt;br /&gt;
| CODE x || Gets ASCII code for a character&lt;br /&gt;
|-&lt;br /&gt;
| INT x || Rounds x down to integer&lt;br /&gt;
|-&lt;br /&gt;
| LEN x || Gets length of string&lt;br /&gt;
|-&lt;br /&gt;
| PI || Returns approximation of pi&lt;br /&gt;
|-&lt;br /&gt;
| RND || Returns a random number between 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| SCREEN$ x,y || Returns text character in text cell x,y&lt;br /&gt;
|-&lt;br /&gt;
| SIGN x || Divides x by its magnitude&lt;br /&gt;
|-&lt;br /&gt;
| SIN x, COS x, TAN x || Returns standard trigonometric ratio&lt;br /&gt;
|-&lt;br /&gt;
| SQR x || Returns square of x&lt;br /&gt;
|-&lt;br /&gt;
| STR$ x || Converts number into a string&lt;br /&gt;
|-&lt;br /&gt;
| USR x || If x is a string, gets the address of the first byte of the user defined graphic for the character. If x is a number, runs a machine code routine at address x and returns the value of BC after it exits.&lt;br /&gt;
|-&lt;br /&gt;
| VAL x || Converts string number or expression into a number&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1250</id>
		<title>NextBASIC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1250"/>
		<updated>2019-04-28T07:44:52Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.&lt;br /&gt;
&lt;br /&gt;
? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parenthesis are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.&lt;br /&gt;
&lt;br /&gt;
== Basic Interaction Commands ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LIST x? || Lists source code in bank b (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b MERGE || Adds all basic lines in bank b to main program&lt;br /&gt;
|-&lt;br /&gt;
| CONTINUE || Repeats last command or restarts from error location&lt;br /&gt;
|-&lt;br /&gt;
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)&lt;br /&gt;
|-&lt;br /&gt;
| ERASE f, l || Deletes all program lines between f and l. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| LIST x? || Lists source code (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| LLIST x? || Lists source code to printer (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| NEW || Clear stored program&lt;br /&gt;
|-&lt;br /&gt;
| RUN x? || CLEAR then run program (from line x)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO TO x || Jump execution to line x stored in bank b. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO SUB x || Jump execution to line x stored in bank b, storing current location on gosub stack. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression. Will not work if moved into any bank other than the main program&lt;br /&gt;
|-&lt;br /&gt;
| DIM a(x[,y]..) || Defines a as an array of length x (and second dimension length y, etc..)&lt;br /&gt;
|-&lt;br /&gt;
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)&lt;br /&gt;
|-&lt;br /&gt;
| GO TO x || Jump execution to line X in the same bank&lt;br /&gt;
|-&lt;br /&gt;
| GO SUB x || Jump execution to line X in the same bank, storing current location (and bank) on gosub stack&lt;br /&gt;
|-&lt;br /&gt;
| IF c THEN statements.. || Run statements only if expression c is true &lt;br /&gt;
|-&lt;br /&gt;
| LET var = expr || Sets variable var to expr&lt;br /&gt;
|-&lt;br /&gt;
| NEXT var || Marks end of FOR loop regarding VAR&lt;br /&gt;
|-&lt;br /&gt;
| REM comment || Code comment, ignored&lt;br /&gt;
|-&lt;br /&gt;
| RETURN || Restore execution location (line and bank) from gosub stack&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Console I/O ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| COPY || Prints screen&lt;br /&gt;
|-&lt;br /&gt;
| INKEY$ || Returns currently pressed key&lt;br /&gt;
|-&lt;br /&gt;
| INPUT specifier [connector specifier].. || Output expression(s) and read a variable&lt;br /&gt;
|-&lt;br /&gt;
| INVERSE x || Enable or disable switching ink/paper color when printing (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LPRINT specifier [connector specifier].. || Output expression(s) to printer&lt;br /&gt;
|-&lt;br /&gt;
| OVER x || Enable or disable overprinting (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| PAUSE x || Waits x frames or until a key is pressed&lt;br /&gt;
|-&lt;br /&gt;
| PRINT specifier [connector specifier].. || Output expression(s)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible specifiers for PRINT and INPUT statements are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| var || In PRINT, shows contents of var; in INPUT, inputs into this var&lt;br /&gt;
|-&lt;br /&gt;
| (var) || Shows contents of var (in both PRINT and INPUT)&lt;br /&gt;
|-&lt;br /&gt;
| AT x,y || Moves text cursor to the given text cell &lt;br /&gt;
|-&lt;br /&gt;
| TAB x || Inserts spaces until text cursor is in column x&lt;br /&gt;
|-&lt;br /&gt;
| INK x, PAPER x || Changes the appropriate color for the duration of the print/input statement&lt;br /&gt;
|-&lt;br /&gt;
| LINE x$ || INPUT only, reads a string without the prompting quotes&lt;br /&gt;
|-&lt;br /&gt;
| #x || Selects input/output channel number&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And the connectors between these are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| , || Separate with a tab&lt;br /&gt;
|-&lt;br /&gt;
| &#039; || Separate with a newline&lt;br /&gt;
|-&lt;br /&gt;
| ; || Use no separator&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File I/O ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| CAT || Displays disk/tape catalogue&lt;br /&gt;
|-&lt;br /&gt;
| FORMAT || Prepares inserted disk for usage, erasing it&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn || Load BASIC program from file named fn&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn DATA x() || Load data from fn into array x()&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn CODE addr || Load data from fn into memory at address addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn SCREEN$ || Load data from fn onto standard ULA screen&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn BANK b,addr || Load data from fn into memory bank b at addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn LAYER || Load data from fn onto current layer&lt;br /&gt;
|-&lt;br /&gt;
| MERGE fn || Loads BASIC lines from file named fn and integrates them with current program&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (LINE l)? || Save BASIC program to file named fn (and set up autorun at line l)&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (DATA/CODE/SCREEN$/BANK/LAYER..) || Save data as specified; CODE and BANK have an extra &amp;quot;length&amp;quot; parameter&lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn || Checks loaded basic program matches fn &lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn (DATA/CODE/BANK) || Checks data in memory/array matches contents of fn; does not work with SCREEN$/LAYER because the screen is inevitably changed during the verify operation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Inline data ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b RESTORE x || Sets DATA read point to start of line x in bank b&lt;br /&gt;
|-&lt;br /&gt;
| DATA x[,y].. || Stores data in program for later READing&lt;br /&gt;
|-&lt;br /&gt;
| READ var || Read next value from DATA statement into variable&lt;br /&gt;
|-&lt;br /&gt;
| RESTORE x || Sets DATA read point to start of line x&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BORDER n || Set ULA border to color N&lt;br /&gt;
|-&lt;br /&gt;
| BRIGHT n || Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| CIRCLE x,y,r || Draw circle centered at x, y with radius r&lt;br /&gt;
|-&lt;br /&gt;
| CLS || Clears screen&lt;br /&gt;
|-&lt;br /&gt;
| DRAW [modifier or x,y].. || Draw line from plot cursor to given coordinate&lt;br /&gt;
|-&lt;br /&gt;
| FLASH n || Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| INK c || Set ink (foreground) color for print and graphics commands. If Enhanced ULA is enabled, this can use any legal palette value. On layer 2, it can use any value 0-255.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER x || Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, [[Layer 2]].&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 1,x || Sets mode for layer 1 based on x. 1 = Standard Spectrum, 2 = Timex hires, 3 = Timex hicolour, 0 = Lores Layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 2,x || Selects [[Layer 2]] and determines if it is displayed or not (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER AT x, y || Sets the scroll display offset for the current layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER BANK f, b || Only when [[Layer 2]] is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER CLEAR || Resets all layer settings&lt;br /&gt;
|-&lt;br /&gt;
| LAYER DIM left, top, right, bottom || Sets visible area for current layer&lt;br /&gt;
|-&lt;br /&gt;
| LAYER ERASE x, y, w, h [,f]? || Fills a region at x,y, of size w,h, with palette index f (or the transparent value)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER OVER || Sets layer ordering&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE x || Choose which of the two palettes is used for the active layer (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n, i, v || Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n BANK b, offset || Loads current layer&#039;s palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE CLEAR || Resets all palettes and palette settings&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE DIM x || Sets number of color bits in the active palette; x must be 8 or 9&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE FORMAT x || Enables [[Enhanced ULA|Enhanced ULA]] colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE OVER x || Sets the global transparency color to x&lt;br /&gt;
|-&lt;br /&gt;
| PAPER c || Set paper (background) color for print and graphics commands. Follows the same rules as INK.&lt;br /&gt;
|-&lt;br /&gt;
| PLOT [modifier or x,y].. || Plot listed points as single pixels on current layer&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y, var || Stores the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039; in variable var&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y || Returns the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK x || Populates all 64 sprite patterns from bank b, taking 256 bytes per sprite and thus using all data in bank b.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK b, o, p, n || Define n sprite patterns, starting with p, with data from bank b starting at offset o.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x || Choose the first or second palette for sprites. X must be 0 or 1.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x BANK b, o || Load sprite palette x (0 or 1) from bank b at offset o. Data is read as with LAYER PALETTE.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE n, i, v || Set sprite palette n, index i, to color v. V is always 9-bit, even if PALETTE DIM 8 is in effect.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PRINT x || Enable or disable sprites. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BORDER x || Enable or disable sprites crossing the border. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE s, x, y, i, f || Set sprite f to image i at position x,y with flags f. f is bitmapped as byte 3 of data packets sent to {{PortNo|$xx57}}.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE CLEAR || Reset all sprite attributes and global settings.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tilemap support ===&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| TILE [AT x,y]? || Draw the entire screen from the tilemap (from tile offset (x,y))&lt;br /&gt;
|-&lt;br /&gt;
| TILE w,h [AT x,y]? [TO x2,y2]? || Draw a section of the tilemap w,h wide (from tile offset x,y in the tilemap) (to tile offset x2,y2 on the screen)&lt;br /&gt;
|-&lt;br /&gt;
| TILE BANK n || Set bank n as the root of tile graphics (which may occupy up to 4 banks in the case of 16x16 tiles).&lt;br /&gt;
|-&lt;br /&gt;
| TILE DIM n, o, v, t || Set bank n offset o as the root of tilemap data, with tilemap width v and tile size t (t must be 8 or 16 for 8x8 or 16x16 tiles)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Memory and Port Access ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 FORMAT || Re-enable RAMdisk having been disabled by previous BANK 1346 USR&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 USR || Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY TO c || Copy entire bank b to bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY start, len TO c, start || Copy len bytes from start in bank b, to start in bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE x? || Erase all data in bank by overwriting with zeros (or x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE off, len, value || Overwrite len bytes of data at off in bank b with value&lt;br /&gt;
|-&lt;br /&gt;
| BANK b PEEK addr || Returns value at given address in bank b (address is from start of bank)&lt;br /&gt;
|- &lt;br /&gt;
| BANK b POKE addr, value || Sets address in bank b to value (address is from start of bank)&lt;br /&gt;
|-&lt;br /&gt;
| IN port || Returns current value at port&lt;br /&gt;
|-&lt;br /&gt;
| PEEK addr || Returns value at given address&lt;br /&gt;
|-&lt;br /&gt;
| POKE addr, value || Sets address to value&lt;br /&gt;
|-&lt;br /&gt;
| OUT port, value || Sends value to port&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Functions/Expressions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| + - * / ^ || Standard arithmetic operators&lt;br /&gt;
|-&lt;br /&gt;
| = &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= &amp;lt;&amp;gt; || Standard comparison operators (arithmetic for numbers, alphabetic for strings)&lt;br /&gt;
|-&lt;br /&gt;
| a(x) || Returns x&#039;th element of array/string a&lt;br /&gt;
|-&lt;br /&gt;
| s(x? TO y?) || Return substring of s; if x or y are omitted, start or end is assumed&lt;br /&gt;
|-&lt;br /&gt;
| AND OR NOT || Standard boolean conjunctives&lt;br /&gt;
|-&lt;br /&gt;
| ABS x || Gets unsigned magnitude of x&lt;br /&gt;
|-&lt;br /&gt;
| ASN x, ACS x, ATN x || Returns inverse trigonometric ratio (arcsin, arccos, arctan)&lt;br /&gt;
|-&lt;br /&gt;
| ATTR x,y || Returns attribute cell value at cell x,y &lt;br /&gt;
|-&lt;br /&gt;
| BIN x || Converts binary number x to decimal&lt;br /&gt;
|-&lt;br /&gt;
| CHR$ x || Gets character for an ASCII code&lt;br /&gt;
|-&lt;br /&gt;
| CODE x || Gets ASCII code for a character&lt;br /&gt;
|-&lt;br /&gt;
| INT x || Rounds x down to integer&lt;br /&gt;
|-&lt;br /&gt;
| LEN x || Gets length of string&lt;br /&gt;
|-&lt;br /&gt;
| PI || Returns approximation of pi&lt;br /&gt;
|-&lt;br /&gt;
| RND || Returns a random number between 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| SCREEN$ x,y || Returns text character in text cell x,y&lt;br /&gt;
|-&lt;br /&gt;
| SIGN x || Divides x by its magnitude&lt;br /&gt;
|-&lt;br /&gt;
| SIN x, COS x, TAN x || Returns standard trigonometric ratio&lt;br /&gt;
|-&lt;br /&gt;
| SQR x || Returns square of x&lt;br /&gt;
|-&lt;br /&gt;
| STR$ x || Converts number into a string&lt;br /&gt;
|-&lt;br /&gt;
| USR x || If x is a string, gets the address of the first byte of the user defined graphic for the character. If x is a number, runs a machine code routine at address x and returns the value of BC after it exits.&lt;br /&gt;
|-&lt;br /&gt;
| VAL x || Converts string number or expression into a number&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1249</id>
		<title>NextBASIC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1249"/>
		<updated>2019-04-28T07:38:16Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.&lt;br /&gt;
&lt;br /&gt;
? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parenthesis are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.&lt;br /&gt;
&lt;br /&gt;
== Basic Interaction Commands ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LIST x? || Lists source code in bank b (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b MERGE || Adds all basic lines in bank b to main program&lt;br /&gt;
|-&lt;br /&gt;
| CONTINUE || Repeats last command or restarts from error location&lt;br /&gt;
|-&lt;br /&gt;
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)&lt;br /&gt;
|-&lt;br /&gt;
| ERASE f, l || Deletes all program lines between f and l. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| LIST x? || Lists source code (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| LLIST x? || Lists source code to printer (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| NEW || Clear stored program&lt;br /&gt;
|-&lt;br /&gt;
| RUN x? || CLEAR then run program (from line x)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO TO x || Jump execution to line x stored in bank b. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO SUB x || Jump execution to line x stored in bank b, storing current location on gosub stack. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression. Will not work if moved into any bank other than the main program&lt;br /&gt;
|-&lt;br /&gt;
| DIM a(x[,y]..) || Defines a as an array of length x (and second dimension length y, etc..)&lt;br /&gt;
|-&lt;br /&gt;
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)&lt;br /&gt;
|-&lt;br /&gt;
| GO TO x || Jump execution to line X in the same bank&lt;br /&gt;
|-&lt;br /&gt;
| GO SUB x || Jump execution to line X in the same bank, storing current location (and bank) on gosub stack&lt;br /&gt;
|-&lt;br /&gt;
| IF c THEN statements.. || Run statements only if expression c is true &lt;br /&gt;
|-&lt;br /&gt;
| LET var = expr || Sets variable var to expr&lt;br /&gt;
|-&lt;br /&gt;
| NEXT var || Marks end of FOR loop regarding VAR&lt;br /&gt;
|-&lt;br /&gt;
| REM comment || Code comment, ignored&lt;br /&gt;
|-&lt;br /&gt;
| RETURN || Restore execution location (line and bank) from gosub stack&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Console I/O ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| COPY || Prints screen&lt;br /&gt;
|-&lt;br /&gt;
| INKEY$ || Returns currently pressed key&lt;br /&gt;
|-&lt;br /&gt;
| INPUT specifier [connector specifier].. || Output expression(s) and read a variable&lt;br /&gt;
|-&lt;br /&gt;
| INVERSE x || Enable or disable switching ink/paper color when printing (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LPRINT specifier [connector specifier].. || Output expression(s) to printer&lt;br /&gt;
|-&lt;br /&gt;
| OVER x || Enable or disable overprinting (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| PAUSE x || Waits x frames or until a key is pressed&lt;br /&gt;
|-&lt;br /&gt;
| PRINT specifier [connector specifier].. || Output expression(s)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible specifiers for PRINT and INPUT statements are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| var || In PRINT, shows contents of var; in INPUT, inputs into this var&lt;br /&gt;
|-&lt;br /&gt;
| (var) || Shows contents of var (in both PRINT and INPUT)&lt;br /&gt;
|-&lt;br /&gt;
| AT x,y || Moves text cursor to the given text cell &lt;br /&gt;
|-&lt;br /&gt;
| TAB x || Inserts spaces until text cursor is in column x&lt;br /&gt;
|-&lt;br /&gt;
| INK x, PAPER x || Changes the appropriate color for the duration of the print/input statement&lt;br /&gt;
|-&lt;br /&gt;
| LINE x$ || INPUT only, reads a string without the prompting quotes&lt;br /&gt;
|-&lt;br /&gt;
| #x || Selects input/output channel number&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And the connectors between these are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| , || Separate with a tab&lt;br /&gt;
|-&lt;br /&gt;
| &#039; || Separate with a newline&lt;br /&gt;
|-&lt;br /&gt;
| ; || Use no separator&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File I/O ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| CAT || Displays disk/tape catalogue&lt;br /&gt;
|-&lt;br /&gt;
| FORMAT || Prepares inserted disk for usage, erasing it&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn || Load BASIC program from file named fn&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn DATA x() || Load data from fn into array x()&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn CODE addr || Load data from fn into memory at address addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn SCREEN$ || Load data from fn onto standard ULA screen&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn BANK b,addr || Load data from fn into memory bank b at addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn LAYER || Load data from fn onto current layer&lt;br /&gt;
|-&lt;br /&gt;
| MERGE fn || Loads BASIC lines from file named fn and integrates them with current program&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (LINE l)? || Save BASIC program to file named fn (and set up autorun at line l)&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (DATA/CODE/SCREEN$/BANK/LAYER..) || Save data as specified; CODE and BANK have an extra &amp;quot;length&amp;quot; parameter&lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn || Checks loaded basic program matches fn &lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn (DATA/CODE/BANK) || Checks data in memory/array matches contents of fn; does not work with SCREEN$/LAYER because the screen is inevitably changed during the verify operation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Inline data ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b RESTORE x || Sets DATA read point to start of line x in bank b&lt;br /&gt;
|-&lt;br /&gt;
| DATA x[,y].. || Stores data in program for later READing&lt;br /&gt;
|-&lt;br /&gt;
| READ var || Read next value from DATA statement into variable&lt;br /&gt;
|-&lt;br /&gt;
| RESTORE x || Sets DATA read point to start of line x&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BORDER n || Set ULA border to color N&lt;br /&gt;
|-&lt;br /&gt;
| BRIGHT n || Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| CIRCLE x,y,r || Draw circle centered at x, y with radius r&lt;br /&gt;
|-&lt;br /&gt;
| CLS || Clears screen&lt;br /&gt;
|-&lt;br /&gt;
| DRAW [modifier or x,y].. || Draw line from plot cursor to given coordinate&lt;br /&gt;
|-&lt;br /&gt;
| FLASH n || Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| INK c || Set ink (foreground) color for print and graphics commands. If Enhanced ULA is enabled, this can use any legal palette value. On layer 2, it can use any value 0-255.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER x || Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, [[Layer 2]].&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 1,x || Sets mode for layer 1 based on x. 1 = Standard Spectrum, 2 = Timex hires, 3 = Timex hicolour, 0 = Lores Layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 2,x || Selects [[Layer 2]] and determines if it is displayed or not (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER AT x, y || Sets the scroll display offset for the current layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER BANK f, b || Only when [[Layer 2]] is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER CLEAR || Resets all layer settings&lt;br /&gt;
|-&lt;br /&gt;
| LAYER DIM left, top, right, bottom || Sets visible area for current layer&lt;br /&gt;
|-&lt;br /&gt;
| LAYER ERASE x, y, w, h [,f]? || Fills a region at x,y, of size w,h, with palette index f (or the transparent value)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER OVER || Sets layer ordering&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE x || Choose which of the two palettes is used for the active layer (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n, i, v || Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n BANK b, offset || Loads current layer&#039;s palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE CLEAR || Resets all palettes and palette settings&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE DIM x || Sets number of color bits in the active palette; x must be 8 or 9&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE FORMAT x || Enables [[Video Modes:Enhanced ULA|Enhanced ULA]] colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE OVER x || Sets the global transparency color to x&lt;br /&gt;
|-&lt;br /&gt;
| PAPER c || Set paper (background) color for print and graphics commands. Follows the same rules as INK.&lt;br /&gt;
|-&lt;br /&gt;
| PLOT [modifier or x,y].. || Plot listed points as single pixels on current layer&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y, var || Stores the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039; in variable var&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y || Returns the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK x || Populates all 64 sprite patterns from bank b, taking 256 bytes per sprite and thus using all data in bank b.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK b, o, p, n || Define n sprite patterns, starting with p, with data from bank b starting at offset o.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x || Choose the first or second palette for sprites. X must be 0 or 1.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x BANK b, o || Load sprite palette x (0 or 1) from bank b at offset o. Data is read as with LAYER PALETTE.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE n, i, v || Set sprite palette n, index i, to color v. V is always 9-bit, even if PALETTE DIM 8 is in effect.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PRINT x || Enable or disable sprites. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BORDER x || Enable or disable sprites crossing the border. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE s, x, y, i, f || Set sprite f to image i at position x,y with flags f. f is bitmapped as byte 3 of data packets sent to {{PortNo|$xx57}}.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE CLEAR || Reset all sprite attributes and global settings.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tilemap support ===&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| TILE [AT x,y]? || Draw the entire screen from the tilemap (from tile offset (x,y))&lt;br /&gt;
|-&lt;br /&gt;
| TILE w,h [AT x,y]? [TO x2,y2]? || Draw a section of the tilemap w,h wide (from tile offset x,y in the tilemap) (to tile offset x2,y2 on the screen)&lt;br /&gt;
|-&lt;br /&gt;
| TILE BANK n || Set bank n as the root of tile graphics (which may occupy up to 4 banks in the case of 16x16 tiles).&lt;br /&gt;
|-&lt;br /&gt;
| TILE DIM n, o, v, t || Set bank n offset o as the root of tilemap data, with tilemap width v and tile size t (t must be 8 or 16 for 8x8 or 16x16 tiles)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Memory and Port Access ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 FORMAT || Re-enable RAMdisk having been disabled by previous BANK 1346 USR&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 USR || Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY TO c || Copy entire bank b to bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY start, len TO c, start || Copy len bytes from start in bank b, to start in bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE x? || Erase all data in bank by overwriting with zeros (or x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE off, len, value || Overwrite len bytes of data at off in bank b with value&lt;br /&gt;
|-&lt;br /&gt;
| BANK b PEEK addr || Returns value at given address in bank b (address is from start of bank)&lt;br /&gt;
|- &lt;br /&gt;
| BANK b POKE addr, value || Sets address in bank b to value (address is from start of bank)&lt;br /&gt;
|-&lt;br /&gt;
| IN port || Returns current value at port&lt;br /&gt;
|-&lt;br /&gt;
| PEEK addr || Returns value at given address&lt;br /&gt;
|-&lt;br /&gt;
| POKE addr, value || Sets address to value&lt;br /&gt;
|-&lt;br /&gt;
| OUT port, value || Sends value to port&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Functions/Expressions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| + - * / ^ || Standard arithmetic operators&lt;br /&gt;
|-&lt;br /&gt;
| = &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= &amp;lt;&amp;gt; || Standard comparison operators (arithmetic for numbers, alphabetic for strings)&lt;br /&gt;
|-&lt;br /&gt;
| a(x) || Returns x&#039;th element of array/string a&lt;br /&gt;
|-&lt;br /&gt;
| s(x? TO y?) || Return substring of s; if x or y are omitted, start or end is assumed&lt;br /&gt;
|-&lt;br /&gt;
| AND OR NOT || Standard boolean conjunctives&lt;br /&gt;
|-&lt;br /&gt;
| ABS x || Gets unsigned magnitude of x&lt;br /&gt;
|-&lt;br /&gt;
| ASN x, ACS x, ATN x || Returns inverse trigonometric ratio (arcsin, arccos, arctan)&lt;br /&gt;
|-&lt;br /&gt;
| ATTR x,y || Returns attribute cell value at cell x,y &lt;br /&gt;
|-&lt;br /&gt;
| BIN x || Converts binary number x to decimal&lt;br /&gt;
|-&lt;br /&gt;
| CHR$ x || Gets character for an ASCII code&lt;br /&gt;
|-&lt;br /&gt;
| CODE x || Gets ASCII code for a character&lt;br /&gt;
|-&lt;br /&gt;
| INT x || Rounds x down to integer&lt;br /&gt;
|-&lt;br /&gt;
| LEN x || Gets length of string&lt;br /&gt;
|-&lt;br /&gt;
| PI || Returns approximation of pi&lt;br /&gt;
|-&lt;br /&gt;
| RND || Returns a random number between 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| SCREEN$ x,y || Returns text character in text cell x,y&lt;br /&gt;
|-&lt;br /&gt;
| SIGN x || Divides x by its magnitude&lt;br /&gt;
|-&lt;br /&gt;
| SIN x, COS x, TAN x || Returns standard trigonometric ratio&lt;br /&gt;
|-&lt;br /&gt;
| SQR x || Returns square of x&lt;br /&gt;
|-&lt;br /&gt;
| STR$ x || Converts number into a string&lt;br /&gt;
|-&lt;br /&gt;
| USR x || If x is a string, gets the address of the first byte of the user defined graphic for the character. If x is a number, runs a machine code routine at address x and returns the value of BC after it exits.&lt;br /&gt;
|-&lt;br /&gt;
| VAL x || Converts string number or expression into a number&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1248</id>
		<title>NextBASIC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBASIC&amp;diff=1248"/>
		<updated>2019-04-28T07:28:40Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.&lt;br /&gt;
&lt;br /&gt;
? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parenthesis are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.&lt;br /&gt;
&lt;br /&gt;
== Basic Interaction Commands ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| BANK b LIST x? || Lists source code in bank b (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b MERGE || Adds all basic lines in bank b to main program&lt;br /&gt;
|-&lt;br /&gt;
| CONTINUE || Repeats last command or restarts from error location&lt;br /&gt;
|-&lt;br /&gt;
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)&lt;br /&gt;
|-&lt;br /&gt;
| ERASE f, l || Deletes all program lines between f and l. Cannot be used in a program.&lt;br /&gt;
|-&lt;br /&gt;
| LIST x? || Lists source code (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| LLIST x? || Lists source code to printer (from line x)&lt;br /&gt;
|-&lt;br /&gt;
| NEW || Clear stored program&lt;br /&gt;
|-&lt;br /&gt;
| RUN x? || CLEAR then run program (from line x)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO TO x || Jump execution to line x stored in bank b. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| BANK b GO SUB x || Jump execution to line x stored in bank b, storing current location on gosub stack. b=-1 for main program&lt;br /&gt;
|-&lt;br /&gt;
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression. Will not work if moved into any bank other than the main program&lt;br /&gt;
|-&lt;br /&gt;
| DIM a(x[,y]..) || Defines a as an array of length x (and second dimension length y, etc..)&lt;br /&gt;
|-&lt;br /&gt;
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)&lt;br /&gt;
|-&lt;br /&gt;
| GO TO x || Jump execution to line X in the same bank&lt;br /&gt;
|-&lt;br /&gt;
| GO SUB x || Jump execution to line X in the same bank, storing current location (and bank) on gosub stack&lt;br /&gt;
|-&lt;br /&gt;
| IF c THEN statements.. || Run statements only if expression c is true &lt;br /&gt;
|-&lt;br /&gt;
| LET var = expr || Sets variable var to expr&lt;br /&gt;
|-&lt;br /&gt;
| NEXT var || Marks end of FOR loop regarding VAR&lt;br /&gt;
|-&lt;br /&gt;
| REM comment || Code comment, ignored&lt;br /&gt;
|-&lt;br /&gt;
| RETURN || Restore execution location (line and bank) from gosub stack&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Console I/O ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| COPY || Prints screen&lt;br /&gt;
|-&lt;br /&gt;
| INKEY$ || Returns currently pressed key&lt;br /&gt;
|-&lt;br /&gt;
| INPUT specifier [connector specifier].. || Output expression(s) and read a variable&lt;br /&gt;
|-&lt;br /&gt;
| INVERSE x || Enable or disable switching ink/paper color when printing (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LPRINT specifier [connector specifier].. || Output expression(s) to printer&lt;br /&gt;
|-&lt;br /&gt;
| OVER x || Enable or disable overprinting (x=0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| PAUSE x || Waits x frames or until a key is pressed&lt;br /&gt;
|-&lt;br /&gt;
| PRINT specifier [connector specifier].. || Output expression(s)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible specifiers for PRINT and INPUT statements are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| var || In PRINT, shows contents of var; in INPUT, inputs into this var&lt;br /&gt;
|-&lt;br /&gt;
| (var) || Shows contents of var (in both PRINT and INPUT)&lt;br /&gt;
|-&lt;br /&gt;
| AT x,y || Moves text cursor to the given text cell &lt;br /&gt;
|-&lt;br /&gt;
| TAB x || Inserts spaces until text cursor is in column x&lt;br /&gt;
|-&lt;br /&gt;
| INK x, PAPER x || Changes the appropriate color for the duration of the print/input statement&lt;br /&gt;
|-&lt;br /&gt;
| LINE x$ || INPUT only, reads a string without the prompting quotes&lt;br /&gt;
|-&lt;br /&gt;
| #x || Selects input/output channel number&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And the connectors between these are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Specifier !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| , || Separate with a tab&lt;br /&gt;
|-&lt;br /&gt;
| &#039; || Separate with a newline&lt;br /&gt;
|-&lt;br /&gt;
| ; || Use no separator&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File I/O ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| CAT || Displays disk/tape catalogue&lt;br /&gt;
|-&lt;br /&gt;
| FORMAT || Prepares inserted disk for usage, erasing it&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn || Load BASIC program from file named fn&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn DATA x() || Load data from fn into array x()&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn CODE addr || Load data from fn into memory at address addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn SCREEN$ || Load data from fn onto standard ULA screen&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn BANK b,addr || Load data from fn into memory bank b at addr&lt;br /&gt;
|-&lt;br /&gt;
| LOAD fn LAYER || Load data from fn onto current layer&lt;br /&gt;
|-&lt;br /&gt;
| MERGE fn || Loads BASIC lines from file named fn and integrates them with current program&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (LINE l)? || Save BASIC program to file named fn (and set up autorun at line l)&lt;br /&gt;
|-&lt;br /&gt;
| SAVE fn (DATA/CODE/SCREEN$/BANK/LAYER..) || Save data as specified; CODE and BANK have an extra &amp;quot;length&amp;quot; parameter&lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn || Checks loaded basic program matches fn &lt;br /&gt;
|-&lt;br /&gt;
| VERIFY fn (DATA/CODE/BANK) || Checks data in memory/array matches contents of fn; does not work with SCREEN$/LAYER because the screen is inevitably changed during the verify operation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Inline data ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK b RESTORE x || Sets DATA read point to start of line x in bank b&lt;br /&gt;
|-&lt;br /&gt;
| DATA x[,y].. || Stores data in program for later READing&lt;br /&gt;
|-&lt;br /&gt;
| READ var || Read next value from DATA statement into variable&lt;br /&gt;
|-&lt;br /&gt;
| RESTORE x || Sets DATA read point to start of line x&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BORDER n || Set ULA border to color N&lt;br /&gt;
|-&lt;br /&gt;
| BRIGHT n || Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| CIRCLE x,y,r || Draw circle centered at x, y with radius r&lt;br /&gt;
|-&lt;br /&gt;
| CLS || Clears screen&lt;br /&gt;
|-&lt;br /&gt;
| DRAW [modifier or x,y].. || Draw line from plot cursor to given coordinate&lt;br /&gt;
|-&lt;br /&gt;
| FLASH n || Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if Enhanced ULA is enabled.&lt;br /&gt;
|-&lt;br /&gt;
| INK c || Set ink (foreground) color for print and graphics commands. If Enhanced ULA is enabled, this can use any legal palette value. On layer 2, it can use any value 0-255.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER x || Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, [[Layer 2]].&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 1,x || Sets mode for layer 1 based on x. 1 = Standard Spectrum, 2 = Timex hires, 3 = Timex hicolour, 0 = Lores Layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER 2,x || Selects [[Layer 2]] and determines if it is displayed or not (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER AT x, y || Sets the scroll display offset for the current layer.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER BANK f, b || Only when [[Layer 2]] is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER CLEAR || Resets all layer settings&lt;br /&gt;
|-&lt;br /&gt;
| LAYER DIM left, top, right, bottom || Sets visible area for current layer&lt;br /&gt;
|-&lt;br /&gt;
| LAYER ERASE x, y, w, h [,f]? || Fills a region at x,y, of size w,h, with palette index f (or the transparent value)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER OVER || Sets layer ordering&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE x || Choose which of the two palettes is used for the active layer (x must be 0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n, i, v || Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.&lt;br /&gt;
|-&lt;br /&gt;
| LAYER PALETTE n BANK b, offset || Loads current layer&#039;s palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE CLEAR || Resets all palettes and palette settings&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE DIM x || Sets number of color bits in the active palette; x must be 8 or 9&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE FORMAT x || Enables [[Enhanced ULA|Enhanced ULA]] colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)&lt;br /&gt;
|-&lt;br /&gt;
| PALETTE OVER x || Sets the global transparency color to x&lt;br /&gt;
|-&lt;br /&gt;
| PAPER c || Set paper (background) color for print and graphics commands. Follows the same rules as INK.&lt;br /&gt;
|-&lt;br /&gt;
| PLOT [modifier or x,y].. || Plot listed points as single pixels on current layer&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y, var || Stores the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039; in variable var&lt;br /&gt;
|-&lt;br /&gt;
| POINT x, y || Returns the color at point x, y &#039;&#039;&#039;on the ULA screen&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK x || Populates all 64 sprite patterns from bank b, taking 256 bytes per sprite and thus using all data in bank b.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BANK b, o, p, n || Define n sprite patterns, starting with p, with data from bank b starting at offset o.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x || Choose the first or second palette for sprites. X must be 0 or 1.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE x BANK b, o || Load sprite palette x (0 or 1) from bank b at offset o. Data is read as with LAYER PALETTE.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PALETTE n, i, v || Set sprite palette n, index i, to color v. V is always 9-bit, even if PALETTE DIM 8 is in effect.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE PRINT x || Enable or disable sprites. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE BORDER x || Enable or disable sprites crossing the border. X must be 0 (disable) or 1 (enable).&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE s, x, y, i, f || Set sprite f to image i at position x,y with flags f. f is bitmapped as byte 3 of data packets sent to {{PortNo|$xx57}}.&lt;br /&gt;
|-&lt;br /&gt;
| SPRITE CLEAR || Reset all sprite attributes and global settings.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tilemap support ===&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| TILE [AT x,y]? || Draw the entire screen from the tilemap (from tile offset (x,y))&lt;br /&gt;
|-&lt;br /&gt;
| TILE w,h [AT x,y]? [TO x2,y2]? || Draw a section of the tilemap w,h wide (from tile offset x,y in the tilemap) (to tile offset x2,y2 on the screen)&lt;br /&gt;
|-&lt;br /&gt;
| TILE BANK n || Set bank n as the root of tile graphics (which may occupy up to 4 banks in the case of 16x16 tiles).&lt;br /&gt;
|-&lt;br /&gt;
| TILE DIM n, o, v, t || Set bank n offset o as the root of tilemap data, with tilemap width v and tile size t (t must be 8 or 16 for 8x8 or 16x16 tiles)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Memory and Port Access ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 FORMAT || Re-enable RAMdisk having been disabled by previous BANK 1346 USR&lt;br /&gt;
|-&lt;br /&gt;
| BANK 1346 USR || Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY TO c || Copy entire bank b to bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b COPY start, len TO c, start || Copy len bytes from start in bank b, to start in bank c&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE x? || Erase all data in bank by overwriting with zeros (or x)&lt;br /&gt;
|-&lt;br /&gt;
| BANK b ERASE off, len, value || Overwrite len bytes of data at off in bank b with value&lt;br /&gt;
|-&lt;br /&gt;
| BANK b PEEK addr || Returns value at given address in bank b (address is from start of bank)&lt;br /&gt;
|- &lt;br /&gt;
| BANK b POKE addr, value || Sets address in bank b to value (address is from start of bank)&lt;br /&gt;
|-&lt;br /&gt;
| IN port || Returns current value at port&lt;br /&gt;
|-&lt;br /&gt;
| PEEK addr || Returns value at given address&lt;br /&gt;
|-&lt;br /&gt;
| POKE addr, value || Sets address to value&lt;br /&gt;
|-&lt;br /&gt;
| OUT port, value || Sends value to port&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Functions/Expressions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| + - * / ^ || Standard arithmetic operators&lt;br /&gt;
|-&lt;br /&gt;
| = &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= &amp;lt;&amp;gt; || Standard comparison operators (arithmetic for numbers, alphabetic for strings)&lt;br /&gt;
|-&lt;br /&gt;
| a(x) || Returns x&#039;th element of array/string a&lt;br /&gt;
|-&lt;br /&gt;
| s(x? TO y?) || Return substring of s; if x or y are omitted, start or end is assumed&lt;br /&gt;
|-&lt;br /&gt;
| AND OR NOT || Standard boolean conjunctives&lt;br /&gt;
|-&lt;br /&gt;
| ABS x || Gets unsigned magnitude of x&lt;br /&gt;
|-&lt;br /&gt;
| ASN x, ACS x, ATN x || Returns inverse trigonometric ratio (arcsin, arccos, arctan)&lt;br /&gt;
|-&lt;br /&gt;
| ATTR x,y || Returns attribute cell value at cell x,y &lt;br /&gt;
|-&lt;br /&gt;
| BIN x || Converts binary number x to decimal&lt;br /&gt;
|-&lt;br /&gt;
| CHR$ x || Gets character for an ASCII code&lt;br /&gt;
|-&lt;br /&gt;
| CODE x || Gets ASCII code for a character&lt;br /&gt;
|-&lt;br /&gt;
| INT x || Rounds x down to integer&lt;br /&gt;
|-&lt;br /&gt;
| LEN x || Gets length of string&lt;br /&gt;
|-&lt;br /&gt;
| PI || Returns approximation of pi&lt;br /&gt;
|-&lt;br /&gt;
| RND || Returns a random number between 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| SCREEN$ x,y || Returns text character in text cell x,y&lt;br /&gt;
|-&lt;br /&gt;
| SIGN x || Divides x by its magnitude&lt;br /&gt;
|-&lt;br /&gt;
| SIN x, COS x, TAN x || Returns standard trigonometric ratio&lt;br /&gt;
|-&lt;br /&gt;
| SQR x || Returns square of x&lt;br /&gt;
|-&lt;br /&gt;
| STR$ x || Converts number into a string&lt;br /&gt;
|-&lt;br /&gt;
| USR x || If x is a string, gets the address of the first byte of the user defined graphic for the character. If x is a number, runs a machine code routine at address x and returns the value of BC after it exits.&lt;br /&gt;
|-&lt;br /&gt;
| VAL x || Converts string number or expression into a number&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1247</id>
		<title>Memory map</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1247"/>
		<updated>2019-04-28T07:20:48Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Next supports two memory management models which operate in tandem. One is a unique memory management system for the Next. The other is an expanded version of the memory manager from the original Spectrum 128 and +2/+3 series.&lt;br /&gt;
&lt;br /&gt;
== Global Memory Map ==&lt;br /&gt;
&lt;br /&gt;
The total available RAM space of the Next is 768k on an unexpanded Next, or 1792k on a Next expanded to 2Mb. (The base Next has 1mb of memory but 512k of it is reserved for the ROMs and firmware.)&lt;br /&gt;
&lt;br /&gt;
The Z80 processor in the Next can access only 64k of memory at a time, and so the memory is divided into &#039;&#039;banks&#039;&#039; which are used in determining which memory it sees. Spectrum 128k memory management, and [[NextBASIC]], use 16k banks. Next memory management via machine code uses 8k banks.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-bank !! 8k-bank !! True Address !! Size !! Description&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $000000-$00ffff || 64K || ZX Spectrum ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $010000-$013fff || 16K || EsxDOS ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $014000-$017fff || 16K || Multiface ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $018000-$01bfff || 16K || Multiface Extra ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $01c000-$01ffff || 16K || Multiface RAM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $020000-$03ffff || 128K || DivMMC RAM&lt;br /&gt;
|-&lt;br /&gt;
| 0-7 || 0-15 || $040000-$05ffff || 128K || Standard 128K RAM&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 || 16-31 || $060000-$07ffff || 128K || Extra RAM&lt;br /&gt;
|-&lt;br /&gt;
| 16-47 || 32-95 || $080000-$0fffff || 512K || 1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 48-79 || 96-159 || $100000-$17ffff || 512K || 2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 80-111 || 160-223 || $180000-$1fffff || 512K || 3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally, the first few pages have certain uses and traits summarised below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-banks !! 8k-banks !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0-1 || Standard RAM, maybe used by EsxDOS.  Initially mapped to $c000-$ffff.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2-3 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-5 || Standard RAM.  Initially mapped to $8000-$bfff.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 6-7 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 8-9 || Standard RAM, contended on +2/+3, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 10-11 || ULA Screen, contended except on Pentagon, cannot be used by [[NextBASIC]] commands.  Initially mapped to $4000-$7fff.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 12-13 || Standard RAM, contended on +2/+3, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 14-15 || ULA Shadow Screen, contended except on Pentagon, NextZXOS Workspace, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 16-17 || Next RAM, Default Layer 2, NextZXOS screen and extra data, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 9-10 || 18-21 || Next RAM, Rest of default Layer 2&lt;br /&gt;
|-&lt;br /&gt;
| 11-13 || 22-27 || Next RAM, Default Layer 2 Shadow Screen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please note that NextZXOS moves the Layer 2 bank assignments. Therefore, Layer 2, after NextZXOS boots, is mapped to 16k-banks 9-11 (8k-banks 18-23). The Layer 2 shadow memory is also assigned to 16k-banks 9-11 (8k-banks 18-23).&lt;br /&gt;
&lt;br /&gt;
== Z80 Visible Memory map ==&lt;br /&gt;
&lt;br /&gt;
At start up, the 16-bit address space of the Z80 is mapped to memory as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! 16k-slot !! 8k-slot !! Default 16k-bank !! Default 8k-bank !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || rowspan=2 | 1 || 0 || rowspan=2 | ROM || ROM (255) || Normally ROM. Writes mappable by Layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2. &lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || rowspan=2 | 2 || 2 || rowspan=2 | 5 || 10 || Normally used for normal/shadow ULA screen. &lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || rowspan=2 | 3 || 4 || rowspan=2 | 2 || 4 || Free RAM. &lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || rowspan=2 | 4 || 6 || rowspan=2 | 0 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Paging techniques ==&lt;br /&gt;
&lt;br /&gt;
=== 128-style memory management ===&lt;br /&gt;
&lt;br /&gt;
128-style memory management can only alter the bank addressed at $c000 (16k-slot 4, or 8k-slot 7-8). The active 16k-bank at $c000 is selected by writing the 3 LSBs of the 16k-bank number to the bottom 3 bits of {{PortNo|$7FFD}}, and the 3 MSBs to the bottom 3 bits of {{PortNo|$DFFD}}. (The reason for the division is that the original Spectrum 128, having only 128k of memory, only needed 3 bits.)&lt;br /&gt;
&lt;br /&gt;
On an unexpanded Next, this allows any 16k-bank to be paged in at $c000. On an expanded Next, there are not enough bits available to access the banks at the bottom of the expanded memory, so Next memory management must be used to access these.&lt;br /&gt;
&lt;br /&gt;
If you are using the standard interrupt handler or OS routines, then any time you write to {{PortNo|$7FFD}} you should also store the value at $5B5C. Any time you write to {{PortNo|$1FFD}} you should also store the value at $5B67. There is no corresponding system variable for the Next-only {{PortNo|$DFFD}} and standard OS routines may not support the extended banks properly.&lt;br /&gt;
&lt;br /&gt;
=== 128 Special Paging Mode ===&lt;br /&gt;
&amp;quot;Special paging mode&amp;quot; (also called &amp;quot;AllRam mode&amp;quot; or &amp;quot;CP/M mode&amp;quot;) is enabled by writing a value with the LSB set to {{PortNo|$1FFD}}. Depending on the 3 low bits of this value a memory configuration is selected as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bits !! Slot 1 !! Slot 2 !! Slot 3 || Slot 4 &lt;br /&gt;
|-&lt;br /&gt;
| %001 || 0 || 1 || 2 || 3 &lt;br /&gt;
|-&lt;br /&gt;
| %011 || 4 || 5 || 6 || 7&lt;br /&gt;
|-&lt;br /&gt;
| %101 || 4 || 5 || 6 || 3&lt;br /&gt;
|-&lt;br /&gt;
| %111 || 4 || 7 || 6 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Switching ===&lt;br /&gt;
Layer 2 switching can allow one of the first sixteen (0-15) 16k-banks to be &#039;&#039;written to&#039;&#039; (but not read) in 16k-slot 1, by writing the 16k-bank number to {{NextRegNo|$12}} and then enabling Layer 2 paging by writing a value with the LSB set to {{PortNo|$123B}}. You can use also the {{NextRegNo|$13}} for the same purpose (change of register $12 is immediately visible at display, while register $13 is not related to display in any way, it works only as bank selector for writing into slot 1).&lt;br /&gt;
&lt;br /&gt;
Writing to this area will then write the appropriate area of memory, whereas &#039;&#039;reading&#039;&#039; from it will give the area mapped by other memory management.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is actually 3 banks big, so using Layer 2 controls to access different &amp;quot;sections&amp;quot; of Layer 2 can access the two following banks after the one selected in register $12/$13.&lt;br /&gt;
&lt;br /&gt;
=== Next Memory Management ===&lt;br /&gt;
The 8k-bank accessed in an 8k-slot is selected by writing the 8k-bank number to bits 7-0 of the 8 Next registers from {{NextRegNo|$50}} upwards. $50 addresses 8k-slot 0, $51 addresses 8k-slot 1, and so on.&lt;br /&gt;
&lt;br /&gt;
In addition, in 8k-slots 0 and 1 only, the ROM can be paged in by selecting the otherwise nonexistent 8k-page $FF. Whether the high or the low 8k of the ROM is mapped is determined by which 8k-slot is used.&lt;br /&gt;
&lt;br /&gt;
=== Interactions between paging methods ===&lt;br /&gt;
In normal mode, changes made in 128 style and Next style memory management are synchronized. The most recent change always has priority. This means that using 128-style memory management to select a new 16k-bank in 16k-slot 4 will update the MMU registers for the two 8k-slots with the corresponding 8k-bank numbers.&lt;br /&gt;
&lt;br /&gt;
However, enabling 128 special paging mode (AllRam mode) mode will &#039;&#039;&#039;override the Next MMU&#039;&#039;&#039;. The bank selections from the AllRam mode table will override the set pages in the Next registers. The MMU registers can still be changed, but they will have no effect until special paging mode is disabled.&lt;br /&gt;
&lt;br /&gt;
Since the 128-style memory management ports are not readable, there is no synchronization applicable in the other direction.&lt;br /&gt;
&lt;br /&gt;
== ROM paging and selection ==&lt;br /&gt;
$0000-$3fff is usually mapped to ROM. This area can only be fully remapped using Next memory management. ROM is not considered one of the numbered banks; it is mapped to the two 8k-banks by default, or by setting their 8k-bank numbers to 255. &lt;br /&gt;
&lt;br /&gt;
The 128k Spectrum has 2 ROM pages. Which of these is mapped is selected by altering Bit 4 of {{PortNo|$7FFD}}. The +2a/+3 has 4 ROM pages; the extra bit needed to select between these is bit 2 of {{PortNo|$1FFD}}. This maintains compatibility with the original machines&#039; ROM paging as long as the ROM is not paged out.&lt;br /&gt;
&lt;br /&gt;
=== Paging out ROM ===&lt;br /&gt;
ROM can be paged out by enabling AllRam mode, or by using Next memory management. Beware that some programs may assume that they can find ROM service routines at fixed addresses between $0000-$3fff. More importantly, if the default interrupt mode (IM 1) is set, the Z80 &#039;&#039;&#039;will&#039;&#039;&#039; jump the program counter to $0038 every frame expecting to find an interrupt handler there. If it does not, pain and suffering will likely result. [[Extended Z80 instruction set#DI|DI]] is your friend. On the plus side, this does allow you to write your own interrupt handler without the nuisance of using IM 2.&lt;br /&gt;
&lt;br /&gt;
Activating [[Layer 2]]&#039;s paging will not affect ROM operation, because it only remaps &#039;&#039;writes&#039;&#039;, not reads.&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
16k-Bank 5 is the bank read by the ULA to determine what to show on screen. The ULA connects directly to the larger memory space ignoring mapping; the screen is always 16k-Bank 5, no matter where in memory it is (or if it is switched in at all). Setting bit 3 of {{PortNo|$7FFD}} will have the ULA read from 16k-bank 7 (the &amp;quot;shadow screen&amp;quot;) instead, which can be used as an alternate screen. Beware that &#039;&#039;&#039;this does not map 16k-bank 7 into RAM&#039;&#039;&#039;; to alter 16k-bank 7 it must be mapped by other means. Also by selecting &amp;quot;shadow screen&amp;quot; the &#039;&#039;&#039;Layer 2 becomes automatically invisible&#039;&#039;&#039;, as the access of ULA to &amp;quot;shadow&amp;quot; bank 7 is slower than normal bank 5 and there&#039;s not enough time to read also Layer 2 for video signal generation (to use &amp;quot;double buffering&amp;quot; together with Layer 2, use Timex screen 0/1 by {{PortNo|$xxFF}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Main_Page&amp;diff=1232</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Main_Page&amp;diff=1232"/>
		<updated>2019-04-26T16:08:38Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== References ==&lt;br /&gt;
&lt;br /&gt;
=== System architecture ===&lt;br /&gt;
* [[Extended Z80 instruction set]]&lt;br /&gt;
* [[Memory map]] and switching mechanics&lt;br /&gt;
* [[Reference machines]] and timing&lt;br /&gt;
* [[Boot Sequence]]&lt;br /&gt;
* [[Board feature control]] and port list&lt;br /&gt;
* [[Interrupts]]&lt;br /&gt;
* [[RPi0 Acceleration]]&lt;br /&gt;
* [[DMA]]&lt;br /&gt;
* [[Copper]]&lt;br /&gt;
* [[File Formats]]&lt;br /&gt;
* [[Z80 programming]]&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
* [[Video Modes]]&lt;br /&gt;
* [[Tilemap]]&lt;br /&gt;
* [[Sprites]]&lt;br /&gt;
* [[Layer 2]]&lt;br /&gt;
* [[Palettes]]&lt;br /&gt;
* [[Blend Modes]]&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* [[Turbo Sound Next]]&lt;br /&gt;
* [[SpecDrum/DAC]]&lt;br /&gt;
* [[Beeper (audio) | Beeper]]&lt;br /&gt;
&lt;br /&gt;
=== Firmware ===&lt;br /&gt;
* [[NextZXOS]]&lt;br /&gt;
* [[ESXDOS]]&lt;br /&gt;
* [[NextBASIC]]&lt;br /&gt;
* [[System Variables]]&lt;br /&gt;
&lt;br /&gt;
=== Electronics ===&lt;br /&gt;
* [[Circuit Diagrams]]&lt;br /&gt;
&lt;br /&gt;
=== Development Tools ===&lt;br /&gt;
* [[Emulators]]&lt;br /&gt;
* [[Assemblers]]&lt;br /&gt;
* [[Compilers]]&lt;br /&gt;
&lt;br /&gt;
=== Hardware Expansion ===&lt;br /&gt;
&lt;br /&gt;
Your next computer can be expanded internally to add additional functionality. &lt;br /&gt;
* [[RTC | RTC - Real Time Clock]] &lt;br /&gt;
* [[Raspberry Pi Zero | Accelerator - Raspberry Pi Zero]]&lt;br /&gt;
* [[ESP2866-01 | ESP8266-01 - Wifi Module]] &lt;br /&gt;
* [[Expansion | Expansion Slot]]&lt;br /&gt;
* [[GPIO Socket (J15)]]&lt;br /&gt;
* [[JTAG Socket]]&lt;br /&gt;
* [[2MB RAM Expansion]]&lt;br /&gt;
* [[Beeper (hardware) | Beeper]]&lt;br /&gt;
* &#039;&#039;[https://www.specnext.com/forum/viewtopic.php?f=6&amp;amp;t=544 Specnext Forums] &lt;br /&gt;
: A link to the forums discussing hardware additions&lt;br /&gt;
&lt;br /&gt;
= Community =&lt;br /&gt;
&lt;br /&gt;
* [https://www.specnext.com/forum/ Official forums]&lt;br /&gt;
* [https://www.facebook.com/groups/specnext Facebook group]&lt;br /&gt;
* [https://specnext.slack.com/ Slack chat] ([https://join.slack.com/t/specnext/shared_invite/enQtMjQ2ODgzNTI5MzAzLWE2NzhhNjUzZGZhNWIxZWIyMTY4N2JmNTY3MWM4ZTkxOWY2M2UwZDQzN2FhYTEzNjFiY2I5MDA1MTc3NjVmYTI sign up])&lt;br /&gt;
&lt;br /&gt;
= Sources =&lt;br /&gt;
* [[Bibliography]]&lt;br /&gt;
&lt;br /&gt;
= Wiki &amp;quot;to do&amp;quot; list =&lt;br /&gt;
* [[Wiki TODO list]] (can be used also as warning which pages may contain outdated information)&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1231</id>
		<title>Memory map</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1231"/>
		<updated>2019-04-26T16:02:35Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Next supports two memory management models which operate in tandem. One is a unique memory management system for the Next. The other is an expanded version of the memory manager from the original Spectrum 128 and +2/+3 series.&lt;br /&gt;
&lt;br /&gt;
== Global Memory Map ==&lt;br /&gt;
&lt;br /&gt;
The total available RAM space of the Next is 768k on an unexpanded Next, or 1792k on a Next expanded to 2Mb. (The base Next has 1mb of memory but 512k of it is reserved for the ROMs and firmware.)&lt;br /&gt;
&lt;br /&gt;
The Z80 processor in the Next can access only 64k of memory at a time, and so the memory is divided into &#039;&#039;banks&#039;&#039; which are used in determining which memory it sees. Spectrum 128k memory management, and [[NextBASIC]], use 16k banks. Next memory management via machine code uses 8k banks.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-bank !! 8k-bank !! True Address !! Size !! Description&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $000000-$00ffff || 64K || ZX Spectrum ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $010000-$013fff || 16K || EsxDOS ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $014000-$017fff || 16K || Multiface ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $018000-$01bfff || 16K || Multiface Extra ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $01c000-$01ffff || 16K || Multiface RAM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $020000-$03ffff || 128K || DivMMC RAM&lt;br /&gt;
|-&lt;br /&gt;
| 0-7 || 0-15 || $040000-$05ffff || 128K || Standard 128K RAM&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 || 16-31 || $060000-$07ffff || 128K || Extra RAM&lt;br /&gt;
|-&lt;br /&gt;
| 16-47 || 32-95 || $080000-$0fffff || 512K || 1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 48-79 || 96-159 || $100000-$17ffff || 512K || 2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 80-111 || 160-223 || $180000-$1fffff || 512K || 3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally, the first few pages have certain uses and traits summarised below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-banks !! 8k-banks !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0-1 || Standard RAM, maybe used by EsxDOS.  Initially mapped to $c000-$ffff.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2-3 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-5 || Standard RAM.  Initially mapped to $8000-$bfff.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 6-7 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 8-9 || Standard RAM, contended on +2/+3, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 10-11 || ULA Screen, contended except on Pentagon, cannot be used by [[NextBASIC]] commands.  Initially mapped to $4000-$7fff.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 12-13 || Standard RAM, contended on +2/+3, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 14-15 || ULA Shadow Screen, contended except on Pentagon, NextZXOS Workspace, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 16-17 || Next RAM, Default Layer 2, NextZXOS screen and extra data, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 9-10 || 18-21 || Next RAM, Rest of default Layer 2&lt;br /&gt;
|-&lt;br /&gt;
| 11-13 || 22-27 || Next RAM, Default Layer 2 Shadow Screen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please note that NextZXOS moves the Layer 2 bank assignments. Therefore, Layer 2, after NextZXOS boots, is mapped to 16k-banks 9-11 (8k-banks 18-23). The Layer 2 shadow memory is also assigned to 16k-banks 9-11 (8k-banks 18-23).&lt;br /&gt;
&lt;br /&gt;
== Z80 Visible Memory map ==&lt;br /&gt;
&lt;br /&gt;
At start up, the 16-bit address space of the Z80 is mapped to memory as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! 16k-slot !! 8k-slot !! Default 16k-bank !! Default 8k-bank !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || rowspan=2 | 1 || 0 || rowspan=2 | ROM || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2. &lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || rowspan=2 | 2 || 2 || rowspan=2 | 5 || 10 || Normally used for normal/shadow ULA screen. &lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || rowspan=2 | 3 || 4 || rowspan=2 | 2 || 4 || Free RAM. &lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || rowspan=2 | 4 || 6 || rowspan=2 | 0 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Paging techniques ==&lt;br /&gt;
&lt;br /&gt;
=== 128-style memory management ===&lt;br /&gt;
&lt;br /&gt;
128-style memory management can only alter the bank addressed at $c000 (16k-slot 4, or 8k-slot 7-8). The active 16k-bank at $c000 is selected by writing the 3 LSBs of the 16k-bank number to the bottom 3 bits of {{PortNo|$7FFD}}, and the 3 MSBs to the bottom 3 bits of {{PortNo|$DFFD}}. (The reason for the division is that the original Spectrum 128, having only 128k of memory, only needed 3 bits.)&lt;br /&gt;
&lt;br /&gt;
On an unexpanded Next, this allows any 16k-bank to be paged in at $c000. On an expanded Next, there are not enough bits available to access the banks at the bottom of the expanded memory, so Next memory management must be used to access these.&lt;br /&gt;
&lt;br /&gt;
If you are using the standard interrupt handler or OS routines, then any time you write to {{PortNo|$7FFD}} you should also store the value at $5B5C. Any time you write to {{PortNo|$1FFD}} you should also store the value at $5B67. There is no corresponding system variable for the Next-only {{PortNo|$DFFD}} and standard OS routines may not support the extended banks properly.&lt;br /&gt;
&lt;br /&gt;
=== 128 Special Paging Mode ===&lt;br /&gt;
&amp;quot;Special paging mode&amp;quot; (also called &amp;quot;AllRam mode&amp;quot; or &amp;quot;CP/M mode&amp;quot;) is enabled by writing a value with the LSB set to {{PortNo|$1FFD}}. Depending on the 3 low bits of this value a memory configuration is selected as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bits !! Slot 1 !! Slot 2 !! Slot 3 || Slot 4 &lt;br /&gt;
|-&lt;br /&gt;
| %001 || 0 || 1 || 2 || 3 &lt;br /&gt;
|-&lt;br /&gt;
| %011 || 4 || 5 || 6 || 7&lt;br /&gt;
|-&lt;br /&gt;
| %101 || 4 || 5 || 6 || 3&lt;br /&gt;
|-&lt;br /&gt;
| %111 || 4 || 7 || 6 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Switching ===&lt;br /&gt;
Layer 2 switching can allow one of the first sixteen (0-15) 16k-banks to be &#039;&#039;written to&#039;&#039; (but not read) in 16k-slot 1, by writing the 16k-bank number to {{NextRegNo|$12}} and then enabling Layer 2 paging by writing a value with the LSB set to {{PortNo|$123B}}. You can use also the {{NextRegNo|$13}} for the same purpose (change of register $12 is immediately visible at display, while register $13 is not related to display in any way, it works only as bank selector for writing into slot 1).&lt;br /&gt;
&lt;br /&gt;
Writing to this area will then write the appropriate area of memory, whereas &#039;&#039;reading&#039;&#039; from it will give the area mapped by other memory management.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is actually 3 banks big, so using Layer 2 controls to access different &amp;quot;sections&amp;quot; of Layer 2 can access the two following banks after the one selected in register $12/$13.&lt;br /&gt;
&lt;br /&gt;
=== Next Memory Management ===&lt;br /&gt;
The 8k-bank accessed in an 8k-slot is selected by writing the 8k-bank number to bits 7-0 of the 8 Next registers from {{NextRegNo|$50}} upwards. $50 addresses 8k-slot 0, $51 addresses 8k-slot 1, and so on.&lt;br /&gt;
&lt;br /&gt;
In addition, in 8k-slots 0 and 1 only, the ROM can be paged in by selecting the otherwise nonexistent 8k-page $FF. Whether the high or the low 8k of the ROM is mapped is determined by which 8k-slot is used.&lt;br /&gt;
&lt;br /&gt;
=== Interactions between paging methods ===&lt;br /&gt;
In normal mode, changes made in 128 style and Next style memory management are synchronized. The most recent change always has priority. This means that using 128-style memory management to select a new 16k-bank in 16k-slot 4 will update the MMU registers for the two 8k-slots with the corresponding 8k-bank numbers.&lt;br /&gt;
&lt;br /&gt;
However, enabling 128 special paging mode (AllRam mode) mode will &#039;&#039;&#039;override the Next MMU&#039;&#039;&#039;. The bank selections from the AllRam mode table will override the set pages in the Next registers. The MMU registers can still be changed, but they will have no effect until special paging mode is disabled.&lt;br /&gt;
&lt;br /&gt;
Since the 128-style memory management ports are not readable, there is no synchronization applicable in the other direction.&lt;br /&gt;
&lt;br /&gt;
== ROM paging and selection ==&lt;br /&gt;
$0000-$3fff is usually mapped to ROM. This area can only be fully remapped using Next memory management. ROM is not considered one of the numbered banks; it is mapped to the two 8k-banks by default, or by setting their 8k-bank numbers to 255. &lt;br /&gt;
&lt;br /&gt;
The 128k Spectrum has 2 ROM pages. Which of these is mapped is selected by altering Bit 4 of {{PortNo|$7FFD}}. The +2a/+3 has 4 ROM pages; the extra bit needed to select between these is bit 2 of {{PortNo|$1FFD}}. This maintains compatibility with the original machines&#039; ROM paging as long as the ROM is not paged out.&lt;br /&gt;
&lt;br /&gt;
=== Paging out ROM ===&lt;br /&gt;
ROM can be paged out by enabling AllRam mode, or by using Next memory management. Beware that some programs may assume that they can find ROM service routines at fixed addresses between $0000-$3fff. More importantly, if the default interrupt mode (IM 1) is set, the Z80 &#039;&#039;&#039;will&#039;&#039;&#039; jump the program counter to $0038 every frame expecting to find an interrupt handler there. If it does not, pain and suffering will likely result. [[Extended Z80 instruction set#DI|DI]] is your friend. On the plus side, this does allow you to write your own interrupt handler without the nuisance of using IM 2.&lt;br /&gt;
&lt;br /&gt;
Activating [[Layer 2]]&#039;s paging will not affect ROM operation, because it only remaps &#039;&#039;writes&#039;&#039;, not reads.&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
16k-Bank 5 is the bank read by the ULA to determine what to show on screen. The ULA connects directly to the larger memory space ignoring mapping; the screen is always 16k-Bank 5, no matter where in memory it is (or if it is switched in at all). Setting bit 3 of {{PortNo|$7FFD}} will have the ULA read from 16k-bank 7 (the &amp;quot;shadow screen&amp;quot;) instead, which can be used as an alternate screen. Beware that &#039;&#039;&#039;this does not map 16k-bank 7 into RAM&#039;&#039;&#039;; to alter 16k-bank 7 it must be mapped by other means. Also by selecting &amp;quot;shadow screen&amp;quot; the &#039;&#039;&#039;Layer 2 becomes automatically invisible&#039;&#039;&#039;, as the access of ULA to &amp;quot;shadow&amp;quot; bank 7 is slower than normal bank 5 and there&#039;s not enough time to read also Layer 2 for video signal generation (to use &amp;quot;double buffering&amp;quot; together with Layer 2, use Timex screen 0/1 by {{PortNo|$xxFF}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=RTC&amp;diff=1230</id>
		<title>RTC</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=RTC&amp;diff=1230"/>
		<updated>2019-04-26T15:44:09Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A Real Time Clock (RTC) and Wi-Fi module were optional additions to the full cased Spectrum Next at the time of the original Kickstarter. They can be added to development boards and units that don&#039;t already have them, although the RTC requires soldering components to the board (whilst the Wi-Fi module is push-fit).&lt;br /&gt;
&lt;br /&gt;
== Hardware Requirements ==&lt;br /&gt;
&lt;br /&gt;
Adding a RTC requires the following components:&lt;br /&gt;
&lt;br /&gt;
* 12pF Crystal   &lt;br /&gt;
* DS1307 IC&lt;br /&gt;
* 8 pin DIL Socket  &lt;br /&gt;
* CR2032 Holder  &lt;br /&gt;
* CR2032 Battery&lt;br /&gt;
&lt;br /&gt;
(6pF Crystals have been reported to work)&lt;br /&gt;
&lt;br /&gt;
This is the mounting position on the PCB:&lt;br /&gt;
&lt;br /&gt;
{| width=100%&lt;br /&gt;
|valign=top width=50%| [[Image:RTC_Port_Location.jpg]]&lt;br /&gt;
|valign=top| [[Image:RTC_Port.png]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Software Support ==&lt;br /&gt;
&lt;br /&gt;
The [https://www.specnext.com/latestdistro/ TBBlue SD Distribution] contains dot commands &amp;quot;DATE&amp;quot; and &amp;quot;TIME&amp;quot; for working with the RTC:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| .DATE &amp;quot;31/12/2017&amp;quot; || Set the date to new years eve&lt;br /&gt;
|-&lt;br /&gt;
| .DATE || Print the current date&lt;br /&gt;
|-&lt;br /&gt;
| .TIME &amp;quot;00:30:00:&amp;quot; || Set the time to 30 minutes after midnight&lt;br /&gt;
|-&lt;br /&gt;
| .TIME || Print the current time&lt;br /&gt;
|-&lt;br /&gt;
| .TIME -h || Print help message&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you use these without a RTC soldered to the board they will just give an error that no signature is found or No ACK received. You can however use the option TIME -d to get the contents of the chip which will be junk if the RTC is not fitted but, but may help to diagnose any problems getting it working.&lt;br /&gt;
&lt;br /&gt;
When the RTC is fitted, the date and time automatically appear in the NextZXOS menus. The &amp;quot;.ls&amp;quot; command will print a file listing with dates, and &amp;quot;cat exp&amp;quot; will show times as well.&lt;br /&gt;
&lt;br /&gt;
You can get the contents of a dot command into a string using this NextBASIC:&lt;br /&gt;
&lt;br /&gt;
 DIM a$(100):OPEN #2,&amp;quot;v&amp;gt;a$&amp;quot;:.TIME:CLOSE #2:PRINT a$&lt;br /&gt;
&lt;br /&gt;
You can effectively &amp;quot;touch&amp;quot; a file in BASIC to update its timestamp with:&lt;br /&gt;
&lt;br /&gt;
 OPEN #4,&amp;quot;u&amp;gt;filename&amp;quot;:CLOSE #4&lt;br /&gt;
&lt;br /&gt;
The RTC is connected to the I2C bus. Also supplied is a DOT command called I2CSCAN - this will search the I2C bus for any devices found which can help in seeing what is connected. You should see at least one device at 0x68 if the RTC chip is connected. If you see others when you have nothing on J15 then make sure you have the latest TBU, any capacitor mod etc - if so and you still have others detected then please contribute to the RTC posts on Facebook or the [https://www.specnext.com/forum Forum].&lt;br /&gt;
&lt;br /&gt;
Further information, including ESXDOS support, can be found on the TBBlue Distribution in the file \docs\extra-hw\rtc\RTCI2CTIMEDATEreadme.txt&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=1229</id>
		<title>Compilers</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Compilers&amp;diff=1229"/>
		<updated>2019-04-26T15:42:37Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== &#039;&#039;sccz80&#039;&#039; and &#039;&#039;zsdcc&#039;&#039; === &lt;br /&gt;
Part of [https://github.com/z88dk/z88dk Z88dk]&lt;br /&gt;
: &amp;quot;sccz80&amp;quot; is 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;zsdcc&amp;quot; is a fork of sdcc-z80 that is an open source optimizing C compiler with C90 and elements of C99 and C11 compliance.&lt;br /&gt;
: A Next target is present and under development.  Output file types include tap, sna, and esxdos dot commands.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;[http://www.boriel.com/forum/zx-basic-compiler/ ZX Basic]&#039;&#039; ===&lt;br /&gt;
: A Basic to Z80 compiler with extensions added to Sinclair Basic.&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=System_Variables&amp;diff=1228</id>
		<title>System Variables</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=System_Variables&amp;diff=1228"/>
		<updated>2019-04-26T15:39:55Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
&lt;br /&gt;
! Status/width !! Address !! Mnemonic !! Description&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5B52 || OLDHL || Temporary register store while switching ROMs.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5B54 || OLDBC || Temporary register store while switching ROMs.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5B56 || OLDAF || Temporary register store while switching ROMs.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N2 || $5B58 || TARGET || Subroutine address in ROM 3.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5B5A || RETADDR || Return address in ROM 1.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X1 || $5B5C || BANKM || Copy of last byte output to {{PortNo|$7FFD}}. This byte must be kept up to date with the last value output to the port if interrupts are enabled.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X1 || $5B5D || RAMRST || RST 8 instruction. Used by ROM 1 to report old errors to ROM 3.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || $5B5E || RAMERR || Error number passed from ROM 1 to ROM 3. Also used by SAVE/LOAD as temporary drive store.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B5F || BAUD || RS232 bit period in T states/26. Set by FORMAT LINE.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N2 || $5B61 || SERFL || Second-character-received-flag, and data.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || $5B63 || COL || Current column from 1 to WIDTH.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B64 || WIDTH || Paper column width. Defaults to 80.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B65 || TVPARS || Number of inline parameters expected by RS232.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B66 || FLAGS3 || Various flags. Bits 0, 1, 6 and 7 unlikely to be useful. Bit 2 is set when tokens are to be expanded on printing. Bit 3 is set if print output is RS232. The default (at reset) is Centronics. Bit 4 is set if a disk interface is present. Bit 5 is set if drive B: is present.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X1 || $5B67 || BANK678 || Copy of last byte output to {{PortNo|$1FFD}}. This byte must be kept up to date with the last value output to the port if interrupts are enabled.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| *N1 || $5B68 || FLAGN || Flags for the NextZXOS system.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| *N1 || $5B69 || MAXBNK || Maxmium available RAM bank number.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5B6A || OLDSP || Old SP (stack pointer) when TSTACK is in use.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5B6C || SYNRET || Return address for ONERR.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 5 || $5B6E || LASTV || Last value printed by calculator.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| *1 || $5B73 || TILEBNKL || Tiles bank for Lores.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| *1 || $5B74 || TILEML || Tilemap bank for Lores.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| *1 || $5B75 || TILEBNK2 || Tiles bank for Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| *X1 || $5B77 || NXTBNK || Bank containing NXTLIN.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| *1 || $5B78 || DATABNK || Bank containing DATADD.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B79 || LODDRV || Holds &#039;T&#039; if LOAD, VERIFY, MERGE are from tape, otherwise holds &#039;A&#039;, &#039;B&#039; or &#039;M&#039;.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B7A || SAVDRV || Holds &#039;T&#039; if SAVE is to tape, otherwise holds &#039;A&#039;, &#039;B&#039; or &#039;M&#039;.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B7B || L2SOFT || Soft copy of {{PortNo|$123B}}&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B7C || TILEWL || Width of Lo-res tilemap&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B7E || TILEW2 || Width of Layer 2 tilemap&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || 5B80H || TILEOFFL || Offset in bank for Lo-res tilemap&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B82 || TILEOFF2 || Offset in bank for Layer 2 tilemap&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B84 || COORDSL || x,y coords of last point plotted (lo-res)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B86 || COORDS2 || x,y coords of last point (layer 2)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B88 || COORDSULA || x,y coords of last point (standard)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B8A || COORDSHR || x,y coords of last point (hi-res)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5B8C || COORDSHC || x,y coords of last point (hi-colour)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B8E || INKL || INK colour for Lo-res mode&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B8F || INK2 || INK colour for Layer 2 mode&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || 5B90H || ATTRULA || Attributes for standard mode&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B91 || INKHR || INK colour for Hi-res mode&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B92 || ATTRHC || Attributes for Hi-colour mode&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5B93 || INKMASK || Softcopy of {{NextRegNo|$42}} (or 0)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N8 || $5B94 || STRIP1 || Stripe one bitmap &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N8 || $5B9C || STRIP2 || Stripe two bitmap &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X91 || $5BFF  || TSTACK || Temporary stack grows down from here. Used when RAM page 7 is switched in at top of memory (while executing the editor or calling +3DOS). It may safely go down to $5B9D (and across STRIP1 and STRIP2 if necessary). &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N8 || $5C00 || KSTATE || Used in reading the keyboard.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || $5C08 || LASTK || Stores newly pressed key.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C09 || REPDEL || Time (in 50ths of a second) that a key must be held down before it repeats. &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C0A || REPPER || Delay (in 50ths of a second) between successive repeats of a key held downs.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N2 || $5C0B || DEFADD || Address of arguments of user defined function (if one is being evaluated), otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Nl || $5C0D || K DATA || Stores 2nd byte of colour controls entered from keyboard. &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || $5C0E  || TVDATA || Stores bytes of colour, AT and TAB controls going to TV.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X38 || $5C10 || STRMS || Addresses of channels attached to streams.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C36 || CHARS || 256 less than address of character set (which starts with space and carries on to (C)). Normally in ROM, but you can set up your down in RAM and make CHARS point to it.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C38 || RASP || Length of warning buzz.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C39 || PIP || Length of keyboard click.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C3A || ERRNR || 1 less than the report code. Starts off at 255 (for -1) so &#039;PEEK 23610&#039; gives 255.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X1 || $5C3B  || FLAGS || Various flags to control the BASIC system.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X1 || $5C3C  || TVFLAG || Flags associated with the TV.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C3D  || ERRSP || Address of item on machine stack to be used as error return.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N2 || $5C3F  || LISTSP || Address of return address from automatic listing.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || $5C41  || MODE || Specifies &#039;K&#039;, &#039;L&#039;, &#039;C&#039;, &#039;E&#039; or &#039;G&#039; cursor.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C42  || NEWPPC || Line to be jumped to.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C44  || NSPPC || Statement number in line to be jumped to. Poking first NEWPPC and then NSPPC forces a jump to a specified statement in a line.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C45  || PPC || Line number of statement currently being executed.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C47  || SUBPPC || Number within line of statement currently being executed.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C48  || BORDCR || Border colour multiplied by 8; also contains the attributes normally used for the lower half of the screen.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C49  || E PPC || Number of current line (with program cursor).&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C4B  || VARS || Address of variables.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N2 || $5C4D  || DEST || Address of variable in assignment.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C4F  || CHANS || Address of channel data.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C51  || CURCHL || Address of information currently being used for input and output.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C53  || PROG || Address of BASIC program.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C57  || NXTLIN || Address of next line in program.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C57  || DATADD || Address of terminator of last DATA item.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C59  || E LINE || Address of command being typed in.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C5B  || K CUR || Address of cursor.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C5D  || CH ADD || Address of the next character to be interpreted - the character after the argument of PEEK, or the NEWLINE at the end of a POKE statement.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C5F  || X PTR || Address of the character after the [] marker.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C61  || WORKSP || Address of temporary work space.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C63  || STKBOT || Address of bottom of calculator stack.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C65  || STKEND || Address of start of spare space.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || $5C67  || BREG || Calculator&#039;s B register.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N2 || $5C68  || MEM || Address of area used for calculator&#039;s memory &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C6A  || FLAGS2 || More flags. (Bit 3 set when CAPS SHIFT or CAPS LOCK is on.)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X1 || $5C6B  || DF SZ || The number of lines (including one blank line) in the lower part of the screen.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C6C  || S TOP || The number of the top program line in automatic listings.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C6E  || OLDPPC || Line number to which CONTINUE jumps.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C70  || OSPPC || Number within line of statement to which CONTINUE jumps.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || $5C71  || FLAGX || Various flags.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N2 || $5C72  || STRLEN || Length of string type destination in assignment.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N2 || $5C74  || T ADDR || Address of next item in syntax table (very unlikely to be useful).&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C76  || SEED || The seed for RND. This is the variable that is set by RANDOMIZE.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 3 || $5C78  || FRAMES || 3 byte (least significant byte first), frame counter incremented every 20ms.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C7B  || UDG || Address of first user-defined graphic&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C7D  || COORDS || X-coordinate of last point plotted.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C7E  ||  || Y-coordinate of last point plotted.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| *1 || $5C7F  || GMODE || Graphical layer/mode flags.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2  || 5C80h || PRCC || Full address of next position for LPRINT to print at (in ZX printer buffer). Legal values 5B00 - 5B1F.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C82  || ECHO E || 33-column number and 24-line number (in lower half) of end of input buffer.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C84  || DF CC || Address in display file of PRINT position.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5C86  || DF CCL || Like DF CC for lower part of screen.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X1 || $5C88  || S POSN || 33-column number for PRINT position.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X1 || $5C89  ||  || 24-line number for PRINT position.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| X2 || $5C8A  || SPOSNL || Like S POSN for lower part.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C8C  || SCR CT || Counts scrolls - it is always 1 more than the number of scrolls that will be done before stopping with &#039;scroll&#039;?&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C8D  || ATTR P || Permanent current colours, etc., (as set up by colour statements).&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C8E  || MASK P || Used for transparent colours, etc. Any bit that is 1 shows that the corresponding attribute bit is taken not from ATTR P, but from what is already on the screen.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || $5C8F  || ATTR T || Temporary current colours, etc., (as set up by colour items).&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N1 || 5C90h  || MASK T || Like MASK P, but temporary.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || $5C91  || P FLAG || More flags.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| N30 || $5C92  || MEMBOT || Calculator&#039;s memory area - used to store numbers that cannot conveniently be put on the calculator stack.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5CB0  || NMIADD || Holds the address of the users NMI service routine.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5CB2  || RAMTOP || Address of last byte of BASIC system area.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 2 || $5CB4  || P RAMT || Address of last byte of physical RAM.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=ESXDOS&amp;diff=1227</id>
		<title>ESXDOS</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=ESXDOS&amp;diff=1227"/>
		<updated>2019-04-26T15:35:43Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= esxDos =&lt;br /&gt;
&lt;br /&gt;
esxDos is one of the operating systems that can be run on the Next.  It provides a posix-like api to access the sd card as disk and it provides a familiar basic interface to the disk from BASIC.  The current version of ESXDOS is 0.8.6 - which supports the Real Time Clock of the Next; a new version 0.9.x is being written with features like Long File Name (LFN) support. esxDos currently only supports the so-called USR0 mode in BASIC (single keyword/48K Basic) - there is an experimental .128 command to allow the editor to be started.&lt;br /&gt;
&lt;br /&gt;
You do not need to install esxDos if you just want to run software designed for it as NextZXOS implements the esxDos Application Programming Interface (API) so programs will work anyway...&lt;br /&gt;
&lt;br /&gt;
If you want to use its other features like BetaDisk support or just want to see what it is like you will need to follow the instructions to install it as another identity on the Next.&lt;br /&gt;
&lt;br /&gt;
Instructions to Install esxDos on the Next... [TODO]&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Palettes&amp;diff=1226</id>
		<title>Palettes</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Palettes&amp;diff=1226"/>
		<updated>2019-04-26T15:33:20Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To increase the number of available colours on screen, the Spectrum Next supports palletized colours. &lt;br /&gt;
&lt;br /&gt;
Colour IDs in [[Layer 2]], [[Tilemap]] and [[Sprites]] are always taken as palette indices. Colour values in the ULA are mapped to the palette as fixed indices, or can be taken as partial palette indices if [[Enhanced ULA|Enhanced ULA mode]] is enabled. The palette entry numbers for standard ULA mode are: 0-7 for the standard ink colors, 8-15 for BRIGHT ink colors, 128-135 for standard paper and border colors, and 136-143 for BRIGHT paper colors.&lt;br /&gt;
&lt;br /&gt;
Palette configuration can be done through registers $40-$44 and $6B. {{NextRegNo|$43}} sets which palette is being set up. There are two palettes each for Layer 2, Sprites, Tilemap and ULA; which one of the two is used for each is selected using the lower bits of {{NextRegNo|$43}} and in {{NextRegNo|$6B}}.&lt;br /&gt;
&lt;br /&gt;
Once a palette is selected, {{NextRegNo|$40}} sets the palette entry number to set up; you can then send the color to set it to on {{NextRegNo|$41}} &#039;&#039;or&#039;&#039; {{NextRegNo|$44}} which then auto-increment. $41 is used for sending 8-bit colours in RRRGGGBB format; the &amp;quot;missing&amp;quot; third blue bit is set to an OR between the other two. $44 is used for sending 9-bit colours in two byte packets; the first byte sent should be RRRGGGBB as with $41, and the second byte&#039;s LSB fills in the third blue bit. For Layer 2 color the top bit in second byte signals &amp;quot;priority&amp;quot; colour, which makes particular Layer 2 pixel to be drawn on top of everything else, overriding current order of layers.&lt;br /&gt;
&lt;br /&gt;
With Enhanced ULA mode enabled, the {{NextRegNo|$42}} defines how particular ULA attribute breaks into INK and PAPER color. The INK colors are mapped from index 0 in palette, PAPER (and BORDER) colors are mapped from index 128, except when in &amp;quot;full ink&amp;quot; mode (ink mask = 255), then PAPER and BORDER color is taken from {{NextRegNo|$4A}}.&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Palettes&amp;diff=1225</id>
		<title>Palettes</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Palettes&amp;diff=1225"/>
		<updated>2019-04-26T15:32:49Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To increase the number of available colours on screen, the Spectrum Next supports palletized colours. &lt;br /&gt;
&lt;br /&gt;
Colour IDs in [[Layer 2]], [[Tilemap]] and [[Sprites]] are always taken as palette indices. Colour values in the ULA are mapped to the palette as fixed indices, or can be taken as partial palette indices if [[Enhanced ULA|EnhancedULA mode]] is enabled. The palette entry numbers for standard ULA mode are: 0-7 for the standard ink colors, 8-15 for BRIGHT ink colors, 128-135 for standard paper and border colors, and 136-143 for BRIGHT paper colors.&lt;br /&gt;
&lt;br /&gt;
Palette configuration can be done through registers $40-$44 and $6B. {{NextRegNo|$43}} sets which palette is being set up. There are two palettes each for Layer 2, Sprites, Tilemap and ULA; which one of the two is used for each is selected using the lower bits of {{NextRegNo|$43}} and in {{NextRegNo|$6B}}.&lt;br /&gt;
&lt;br /&gt;
Once a palette is selected, {{NextRegNo|$40}} sets the palette entry number to set up; you can then send the color to set it to on {{NextRegNo|$41}} &#039;&#039;or&#039;&#039; {{NextRegNo|$44}} which then auto-increment. $41 is used for sending 8-bit colours in RRRGGGBB format; the &amp;quot;missing&amp;quot; third blue bit is set to an OR between the other two. $44 is used for sending 9-bit colours in two byte packets; the first byte sent should be RRRGGGBB as with $41, and the second byte&#039;s LSB fills in the third blue bit. For Layer 2 color the top bit in second byte signals &amp;quot;priority&amp;quot; colour, which makes particular Layer 2 pixel to be drawn on top of everything else, overriding current order of layers.&lt;br /&gt;
&lt;br /&gt;
With EnhancedULA mode enabled, the {{NextRegNo|$42}} defines how particular ULA attribute breaks into INK and PAPER color. The INK colors are mapped from index 0 in palette, PAPER (and BORDER) colors are mapped from index 128, except when in &amp;quot;full ink&amp;quot; mode (ink mask = 255), then PAPER and BORDER color is taken from {{NextRegNo|$4A}}.&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=1224</id>
		<title>Layer 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Layer_2&amp;diff=1224"/>
		<updated>2019-04-26T15:31:03Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Layer 2 is an additional graphics feature on the Next. It provides a 256-color screen at the full 256x192 resolution, in which every pixel is individually colored. Layer 2 may appear in place of, behind, or above the ULA-generated screen.&lt;br /&gt;
&lt;br /&gt;
At this moment the enabled Layer 2 prevents turbo mode 14MHz to be stable, the ZX Next will thus drop the speed to 7MHz automatically when video-out signal for the central 256x192 pixel area of screen is generated. For remaining areas of screen (border, and H/V-blanks) the CPU will operate at desired 14MHz speed even with Layer 2 enabled.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Documentation on Layer 2 is extremely sparse at the moment and could be subject to change.&#039;&#039;&#039; Information below has been taken from emulator documentation.&lt;br /&gt;
&lt;br /&gt;
The Layer 2 screen occupies 48k, which is stored in 3 consecutive [[Memory map|banks]]. By default, banks 8-10 are used for the main Layer 2 screen and banks 11-13 for the shadow Layer 2 screen. These can be changed using {{NextRegNo|$12}} and {{NextRegNo|$13}}.&lt;br /&gt;
&lt;br /&gt;
Each pixel of Layer 2 is assigned 1 byte of video memory. This means Layer 2 consumes a total of 48k. Since the Spectrum banks are 16k, Layer 2 is divided horizontally into 3 banks of 64 lines each, each of which is exactly 16k.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is controlled via {{PortNo|$123B}}, which 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;
| 6-7 || Video RAM bank select&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Shadow Layer 2 RAM select&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Layer 2 visible&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Enable Layer 2 write 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 were disabled.&lt;br /&gt;
&lt;br /&gt;
If you need to &#039;&#039;read&#039;&#039; from Layer 2 you will need to use the regular [[Memory map|banking]] ports to switch in one of the Layer 2 banks in slot for at $C000. 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 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;
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}} and {{NextRegNo|$17}} apply a pixel shift to all content in Layer 2, allowing scrolling effects to be created.&lt;br /&gt;
&lt;br /&gt;
When ZX Spectrum 128k {{PortNo|$7FFD}} is used to switch display to ULA &amp;quot;shadow&amp;quot; variant, the Layer 2 is automatically disabled, due to ULA screen data being read from other memory bank. For double-buffered ULA screen together with Layer 2 functionality, use the {{PortNo|$xxFF}} functionality.&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 functionality ({{PortNo|$123B}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1222</id>
		<title>Memory map</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1222"/>
		<updated>2019-04-26T15:13:47Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Next supports two memory management models which operate in tandem. One is a unique memory management system for the Next. The other is an expanded version of the memory manager from the original Spectrum 128 and +2/+3 series.&lt;br /&gt;
&lt;br /&gt;
== Global Memory Map ==&lt;br /&gt;
&lt;br /&gt;
The total available RAM space of the Next is 768k on an unexpanded Next, or 1792k on a Next expanded to 2Mb. (The base Next has 1mb of memory but 512k of it is reserved for the ROMs and firmware.)&lt;br /&gt;
&lt;br /&gt;
The Z80 processor in the Next can access only 64k of memory at a time, and so the memory is divided into &#039;&#039;banks&#039;&#039; which are used in determining which memory it sees. Spectrum 128k memory management, and [[NextBASIC]], use 16k banks. Next memory management via machine code uses 8k banks.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-bank !! 8k-bank !! True Address !! Size !! Description&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $000000-$00ffff || 64K || ZX Spectrum ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $010000-$013fff || 16K || EsxDOS ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $014000-$017fff || 16K || Multiface ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $018000-$01bfff || 16K || Multiface Extra ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $01c000-$01ffff || 16K || Multiface RAM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $020000-$03ffff || 128K || DivMMC RAM&lt;br /&gt;
|-&lt;br /&gt;
| 0-7 || 0-15 || $040000-$05ffff || 128K || Standard 128K RAM&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 || 16-31 || $060000-$07ffff || 128K || Extra RAM&lt;br /&gt;
|-&lt;br /&gt;
| 16-47 || 32-95 || $080000-$0fffff || 512K || 1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 48-79 || 96-159 || $100000-$17ffff || 512K || 2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 80-111 || 160-223 || $180000-$1fffff || 512K || 3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally, the first few pages have certain uses and traits summarised below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-banks !! 8k-banks !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0-1 || Standard RAM, maybe used by EsxDOS.  Initially mapped to $c000-$ffff.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2-3 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-5 || Standard RAM.  Initially mapped to $8000-$bfff.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 6-7 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 8-9 || Standard RAM, contended on +2/+3, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 10-11 || ULA Screen, contended except on Pentagon, cannot be used by [[NextBASIC]] commands.  Initially mapped to $4000-$7fff.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 12-13 || Standard RAM, contended on +2/+3, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 14-15 || ULA Shadow Screen, contended except on Pentagon, NextZXOS Workspace, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 16-17 || Next RAM, Default Layer 2, NextZXOS screen and extra data, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 9-10 || 18-21 || Next RAM, Rest of default Layer 2&lt;br /&gt;
|-&lt;br /&gt;
| 11-13 || 22-27 || Next RAM, Default Layer 2 Shadow Screen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please note that NextZXOS moves the Layer 2 bank assignments. Therefore, Layer 2, after NextZXOS boots, is mapped to 16k-banks 9-11 (8k-banks 18-23). The Layer 2 shadow memory is also assigned to 16k-banks 9-11 (8k-banks 18-23).&lt;br /&gt;
&lt;br /&gt;
== Z80 Visible Memory map ==&lt;br /&gt;
&lt;br /&gt;
At start up, the 16-bit address space of the Z80 is mapped to memory as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! 16k-slot !! 8k-slot !! Default 16k-bank !! Default 8k-bank !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || rowspan=2 | 1 || 0 || rowspan=2 | ROM || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2. &lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || rowspan=2 | 2 || 2 || rowspan=2 | 5 || 10 || Normally used for normal/shadow ULA screen. &lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || rowspan=2 | 3 || 4 || rowspan=2 | 2 || 4 || Free RAM. &lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || rowspan=2 | 4 || 6 || rowspan=2 | 0 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Paging techniques ==&lt;br /&gt;
&lt;br /&gt;
=== 128-style memory management ===&lt;br /&gt;
&lt;br /&gt;
128-style memory management can only alter the bank addressed at $c000 (16k-slot 4, or 8k-slot 7-8). The active 16k-bank at $c000 is selected by writing the 3 LSBs of the 16k-bank number to the bottom 3 bits of {{PortNo|$7FFD}}, and the 3 MSBs to the bottom 3 bits of {{PortNo|$DFFD}}. (The reason for the division is that the original Spectrum 128, having only 128k of memory, only needed 3 bits.)&lt;br /&gt;
&lt;br /&gt;
On an unexpanded Next, this allows any 16k-bank to be paged in at $c000. On an expanded Next, there are not enough bits available to access the banks at the bottom of the expanded memory, so Next memory management must be used to access these.&lt;br /&gt;
&lt;br /&gt;
If you are using the standard interrupt handler or OS routines, then any time you write to {{PortNo|$7FFD}} you should also store the value at $5B5C. Any time you write to {{PortNo|$1FFD}} you should also store the value at $5B67. There is no corresponding system variable for the Next-only {{PortNo|$DFFD}} and standard OS routines may not support the extended banks properly.&lt;br /&gt;
&lt;br /&gt;
=== 128 Special Paging Mode ===&lt;br /&gt;
&amp;quot;Special paging mode&amp;quot; (also called &amp;quot;AllRam mode&amp;quot; or &amp;quot;CP/M mode&amp;quot;) is enabled by writing a value with the LSB set to {{PortNo|$1FFD}}. Depending on the 3 low bits of this value a memory configuration is selected as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bits !! Slot 1 !! Slot 2 !! Slot 3 || Slot 4 &lt;br /&gt;
|-&lt;br /&gt;
| %001 || 0 || 1 || 2 || 3 &lt;br /&gt;
|-&lt;br /&gt;
| %011 || 4 || 5 || 6 || 7&lt;br /&gt;
|-&lt;br /&gt;
| %101 || 4 || 5 || 6 || 3&lt;br /&gt;
|-&lt;br /&gt;
| %111 || 4 || 7 || 6 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Switching ===&lt;br /&gt;
Layer 2 switching can allow one of the first sixteen (0-15) 16k-banks to be &#039;&#039;written to&#039;&#039; (but not read) in 16k-slot 1, by writing the 16k-bank number to {{NextRegNo|$12}} and then enabling Layer 2 paging by writing a value with the LSB set to {{PortNo|$123B}}. You can use also the {{NextRegNo|$13}} for the same purpose (change of register $12 is immediately visible at display, while register $13 is not related to display in any way, it works only as bank selector for writing into slot 1).&lt;br /&gt;
&lt;br /&gt;
Writing to this area will then write the appropriate area of memory, whereas &#039;&#039;reading&#039;&#039; from it will give the area mapped by other memory management.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is actually 3 banks big, so using Layer 2 controls to access different &amp;quot;sections&amp;quot; of Layer 2 can access the two following banks after the one selected in register $12/$13.&lt;br /&gt;
&lt;br /&gt;
=== Next Memory Management ===&lt;br /&gt;
The 8k-bank accessed in an 8k-slot is selected by writing the 8k-bank number to bits 7-0 of the 8 Next registers from {{NextRegNo|$50}} upwards. $50 addresses 8k-slot 0, $51 addresses 8k-slot 1, and so on.&lt;br /&gt;
&lt;br /&gt;
In addition, in 8k-slots 0 and 1 only, the ROM can be paged in by selecting the otherwise nonexistent 8k-page $FF. Whether the high or the low 8k of the ROM is mapped is determined by which 8k-slot is used.&lt;br /&gt;
&lt;br /&gt;
=== Interactions between paging methods ===&lt;br /&gt;
In normal mode, changes made in 128 style and Next style memory management are synchronized. The most recent change always has priority. This means that using 128-style memory management to select a new 16k-bank in 16k-slot 4 will update the MMU registers for the two 8k-slots with the corresponding 8k-bank numbers.&lt;br /&gt;
&lt;br /&gt;
However, enabling 128 special paging mode (AllRam mode) mode will &#039;&#039;&#039;override the Next MMU&#039;&#039;&#039;. The bank selections from the AllRam mode table will override the set pages in the Next registers. The MMU registers can still be changed, but they will have no effect until special paging mode is disabled.&lt;br /&gt;
&lt;br /&gt;
Since the 128-style memory management ports are not readable, there is no synchronization applicable in the other direction.&lt;br /&gt;
&lt;br /&gt;
== ROM paging and selection ==&lt;br /&gt;
$0000-$3fff is usually mapped to ROM. This area can only be fully remapped using Next memory management. ROM is not considered one of the numbered banks; it is mapped to the two 8k-banks by default, or by setting their 8k-bank numbers to 255. &lt;br /&gt;
&lt;br /&gt;
The 128k Spectrum has 2 ROM pages. Which of these is mapped is selected by altering Bit 4 of {{PortNo|$7FFD}}. The +2a/+3 has 4 ROM pages; the extra bit needed to select between these is bit 2 of {{PortNo|$1FFD}}. This maintains compatibility with the original machines&#039; ROM paging as long as the ROM is not paged out.&lt;br /&gt;
&lt;br /&gt;
=== Paging out ROM ===&lt;br /&gt;
ROM can be paged out by enabling AllRam mode, or by using Next memory management. Beware that some programs may assume that they can find ROM service routines at fixed addresses between $0000-$3fff. More importantly, if the default interrupt mode (IM 1) is set, the Z80 &#039;&#039;&#039;will&#039;&#039;&#039; jump the program counter to $0038 every frame expecting to find an interrupt handler there. If it does not, pain and suffering will likely result. [[Extended Z80 instruction set#DI|DI]] is your friend. On the plus side, this does allow you to write your own interrupt handler without the nuisance of using IM 2.&lt;br /&gt;
&lt;br /&gt;
Activating [[Layer 2]]&#039;s paging will not affect ROM operation, because it only remaps &#039;&#039;writes&#039;&#039;, not reads.&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
16k-Bank 5 is the bank read by the ULA to determine what to show on screen. The ULA connects directly to the larger memory space ignoring mapping; the screen is always 16k-Bank 5, no matter where in memory it is (or if it is switched in at all). Setting bit 3 of {{PortNo|$7FFD}} will have the ULA read from 16k-bank 7 (the &amp;quot;shadow screen&amp;quot;) instead, which can be used as an alternate screen. Beware that &#039;&#039;&#039;this does not map 16k-bank 7 into RAM&#039;&#039;&#039;; to alter 16k-bank 7 it must be mapped by other means. Also by selecting &amp;quot;shadow screen&amp;quot; the &#039;&#039;&#039;Layer 2 becomes automatically invisible&#039;&#039;&#039;, as the access of ULA to &amp;quot;shadow&amp;quot; bank 7 is slower than normal bank 5 and there&#039;s not enough time to read also Layer 2 for video signal generation (to use &amp;quot;double buffering&amp;quot; together with Layer 2, use Timex screen 0/1 by {{PortNo|$xxFF}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1221</id>
		<title>Memory map</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1221"/>
		<updated>2019-04-26T15:13:05Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Next supports two memory management models which operate in tandem. One is a unique memory management system for the Next. The other is an expanded version of the memory manager from the original Spectrum 128 and +2/+3 series.&lt;br /&gt;
&lt;br /&gt;
== Global Memory Map ==&lt;br /&gt;
&lt;br /&gt;
The total available RAM space of the Next is 768k on an unexpanded Next, or 1792k on a Next expanded to 2Mb. (The base Next has 1mb of memory but 512k of it is reserved for the ROMs and firmware.)&lt;br /&gt;
&lt;br /&gt;
The Z80 processor in the Next can access only 64k of memory at a time, and so the memory is divided into &#039;&#039;banks&#039;&#039; which are used in determining which memory it sees. Spectrum 128k memory management, and [[NextBASIC]], use 16k banks. Next memory management via machine code uses 8k banks.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-bank !! 8k-bank !! True Address !! Size !! Description&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $000000-$00ffff || 64K || ZX Spectrum ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $010000-$013fff || 16K || EsxDOS ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $014000-$017fff || 16K || Multiface ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $018000-$01bfff || 16K || Multiface Extra ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $01c000-$01ffff || 16K || Multiface RAM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $020000-$03ffff || 128K || DivMMC RAM&lt;br /&gt;
|-&lt;br /&gt;
| 0-7 || 0-15 || $040000-$05ffff || 128K || Standard 128K RAM&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 || 16-31 || $060000-$07ffff || 128K || Extra RAM&lt;br /&gt;
|-&lt;br /&gt;
| 16-47 || 32-95 || $080000-$0fffff || 512K || 1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 48-79 || 96-159 || $100000-$17ffff || 512K || 2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 80-111 || 160-223 || $180000-$1fffff || 512K || 3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally, the first few pages have certain uses and traits summarised below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-banks !! 8k-banks !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0-1 || Standard RAM, maybe used by EsxDOS.  Initially mapped to $c000-$ffff.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2-3 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-5 || Standard RAM.  Initially mapped to $8000-$bfff.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 6-7 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 8-9 || Standard RAM, contended on +2/+3, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 10-11 || ULA Screen, contended except on Pentagon, cannot be used by [[NextBASIC]] commands.  Initially mapped to $4000-$7fff.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 12-13 || Standard RAM, contended on +2/+3, RAMdisk on NextZXOS.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 14-15 || ULA Shadow Screen, contended except on Pentagon, NextOS Workspace, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 16-17 || Next RAM, Default Layer 2, NextOS screen and extra data, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 9-10 || 18-21 || Next RAM, Rest of default Layer 2&lt;br /&gt;
|-&lt;br /&gt;
| 11-13 || 22-27 || Next RAM, Default Layer 2 Shadow Screen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please note that NextZXOS moves the Layer 2 bank assignments. Therefore, Layer 2, after NextZXOS boots, is mapped to 16k-banks 9-11 (8k-banks 18-23). The Layer 2 shadow memory is also assigned to 16k-banks 9-11 (8k-banks 18-23).&lt;br /&gt;
&lt;br /&gt;
== Z80 Visible Memory map ==&lt;br /&gt;
&lt;br /&gt;
At start up, the 16-bit address space of the Z80 is mapped to memory as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! 16k-slot !! 8k-slot !! Default 16k-bank !! Default 8k-bank !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || rowspan=2 | 1 || 0 || rowspan=2 | ROM || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2. &lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || rowspan=2 | 2 || 2 || rowspan=2 | 5 || 10 || Normally used for normal/shadow ULA screen. &lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || rowspan=2 | 3 || 4 || rowspan=2 | 2 || 4 || Free RAM. &lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || rowspan=2 | 4 || 6 || rowspan=2 | 0 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Paging techniques ==&lt;br /&gt;
&lt;br /&gt;
=== 128-style memory management ===&lt;br /&gt;
&lt;br /&gt;
128-style memory management can only alter the bank addressed at $c000 (16k-slot 4, or 8k-slot 7-8). The active 16k-bank at $c000 is selected by writing the 3 LSBs of the 16k-bank number to the bottom 3 bits of {{PortNo|$7FFD}}, and the 3 MSBs to the bottom 3 bits of {{PortNo|$DFFD}}. (The reason for the division is that the original Spectrum 128, having only 128k of memory, only needed 3 bits.)&lt;br /&gt;
&lt;br /&gt;
On an unexpanded Next, this allows any 16k-bank to be paged in at $c000. On an expanded Next, there are not enough bits available to access the banks at the bottom of the expanded memory, so Next memory management must be used to access these.&lt;br /&gt;
&lt;br /&gt;
If you are using the standard interrupt handler or OS routines, then any time you write to {{PortNo|$7FFD}} you should also store the value at $5B5C. Any time you write to {{PortNo|$1FFD}} you should also store the value at $5B67. There is no corresponding system variable for the Next-only {{PortNo|$DFFD}} and standard OS routines may not support the extended banks properly.&lt;br /&gt;
&lt;br /&gt;
=== 128 Special Paging Mode ===&lt;br /&gt;
&amp;quot;Special paging mode&amp;quot; (also called &amp;quot;AllRam mode&amp;quot; or &amp;quot;CP/M mode&amp;quot;) is enabled by writing a value with the LSB set to {{PortNo|$1FFD}}. Depending on the 3 low bits of this value a memory configuration is selected as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bits !! Slot 1 !! Slot 2 !! Slot 3 || Slot 4 &lt;br /&gt;
|-&lt;br /&gt;
| %001 || 0 || 1 || 2 || 3 &lt;br /&gt;
|-&lt;br /&gt;
| %011 || 4 || 5 || 6 || 7&lt;br /&gt;
|-&lt;br /&gt;
| %101 || 4 || 5 || 6 || 3&lt;br /&gt;
|-&lt;br /&gt;
| %111 || 4 || 7 || 6 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Switching ===&lt;br /&gt;
Layer 2 switching can allow one of the first sixteen (0-15) 16k-banks to be &#039;&#039;written to&#039;&#039; (but not read) in 16k-slot 1, by writing the 16k-bank number to {{NextRegNo|$12}} and then enabling Layer 2 paging by writing a value with the LSB set to {{PortNo|$123B}}. You can use also the {{NextRegNo|$13}} for the same purpose (change of register $12 is immediately visible at display, while register $13 is not related to display in any way, it works only as bank selector for writing into slot 1).&lt;br /&gt;
&lt;br /&gt;
Writing to this area will then write the appropriate area of memory, whereas &#039;&#039;reading&#039;&#039; from it will give the area mapped by other memory management.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is actually 3 banks big, so using Layer 2 controls to access different &amp;quot;sections&amp;quot; of Layer 2 can access the two following banks after the one selected in register $12/$13.&lt;br /&gt;
&lt;br /&gt;
=== Next Memory Management ===&lt;br /&gt;
The 8k-bank accessed in an 8k-slot is selected by writing the 8k-bank number to bits 7-0 of the 8 Next registers from {{NextRegNo|$50}} upwards. $50 addresses 8k-slot 0, $51 addresses 8k-slot 1, and so on.&lt;br /&gt;
&lt;br /&gt;
In addition, in 8k-slots 0 and 1 only, the ROM can be paged in by selecting the otherwise nonexistent 8k-page $FF. Whether the high or the low 8k of the ROM is mapped is determined by which 8k-slot is used.&lt;br /&gt;
&lt;br /&gt;
=== Interactions between paging methods ===&lt;br /&gt;
In normal mode, changes made in 128 style and Next style memory management are synchronized. The most recent change always has priority. This means that using 128-style memory management to select a new 16k-bank in 16k-slot 4 will update the MMU registers for the two 8k-slots with the corresponding 8k-bank numbers.&lt;br /&gt;
&lt;br /&gt;
However, enabling 128 special paging mode (AllRam mode) mode will &#039;&#039;&#039;override the Next MMU&#039;&#039;&#039;. The bank selections from the AllRam mode table will override the set pages in the Next registers. The MMU registers can still be changed, but they will have no effect until special paging mode is disabled.&lt;br /&gt;
&lt;br /&gt;
Since the 128-style memory management ports are not readable, there is no synchronization applicable in the other direction.&lt;br /&gt;
&lt;br /&gt;
== ROM paging and selection ==&lt;br /&gt;
$0000-$3fff is usually mapped to ROM. This area can only be fully remapped using Next memory management. ROM is not considered one of the numbered banks; it is mapped to the two 8k-banks by default, or by setting their 8k-bank numbers to 255. &lt;br /&gt;
&lt;br /&gt;
The 128k Spectrum has 2 ROM pages. Which of these is mapped is selected by altering Bit 4 of {{PortNo|$7FFD}}. The +2a/+3 has 4 ROM pages; the extra bit needed to select between these is bit 2 of {{PortNo|$1FFD}}. This maintains compatibility with the original machines&#039; ROM paging as long as the ROM is not paged out.&lt;br /&gt;
&lt;br /&gt;
=== Paging out ROM ===&lt;br /&gt;
ROM can be paged out by enabling AllRam mode, or by using Next memory management. Beware that some programs may assume that they can find ROM service routines at fixed addresses between $0000-$3fff. More importantly, if the default interrupt mode (IM 1) is set, the Z80 &#039;&#039;&#039;will&#039;&#039;&#039; jump the program counter to $0038 every frame expecting to find an interrupt handler there. If it does not, pain and suffering will likely result. [[Extended Z80 instruction set#DI|DI]] is your friend. On the plus side, this does allow you to write your own interrupt handler without the nuisance of using IM 2.&lt;br /&gt;
&lt;br /&gt;
Activating [[Layer 2]]&#039;s paging will not affect ROM operation, because it only remaps &#039;&#039;writes&#039;&#039;, not reads.&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
16k-Bank 5 is the bank read by the ULA to determine what to show on screen. The ULA connects directly to the larger memory space ignoring mapping; the screen is always 16k-Bank 5, no matter where in memory it is (or if it is switched in at all). Setting bit 3 of {{PortNo|$7FFD}} will have the ULA read from 16k-bank 7 (the &amp;quot;shadow screen&amp;quot;) instead, which can be used as an alternate screen. Beware that &#039;&#039;&#039;this does not map 16k-bank 7 into RAM&#039;&#039;&#039;; to alter 16k-bank 7 it must be mapped by other means. Also by selecting &amp;quot;shadow screen&amp;quot; the &#039;&#039;&#039;Layer 2 becomes automatically invisible&#039;&#039;&#039;, as the access of ULA to &amp;quot;shadow&amp;quot; bank 7 is slower than normal bank 5 and there&#039;s not enough time to read also Layer 2 for video signal generation (to use &amp;quot;double buffering&amp;quot; together with Layer 2, use Timex screen 0/1 by {{PortNo|$xxFF}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1219</id>
		<title>Memory map</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1219"/>
		<updated>2019-04-26T15:12:05Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Next supports two memory management models which operate in tandem. One is a unique memory management system for the Next. The other is an expanded version of the memory manager from the original Spectrum 128 and +2/+3 series.&lt;br /&gt;
&lt;br /&gt;
== Global Memory Map ==&lt;br /&gt;
&lt;br /&gt;
The total available RAM space of the Next is 768k on an unexpanded Next, or 1792k on a Next expanded to 2Mb. (The base Next has 1mb of memory but 512k of it is reserved for the ROMs and firmware.)&lt;br /&gt;
&lt;br /&gt;
The Z80 processor in the Next can access only 64k of memory at a time, and so the memory is divided into &#039;&#039;banks&#039;&#039; which are used in determining which memory it sees. Spectrum 128k memory management, and [[NextBASIC]], use 16k banks. Next memory management via machine code uses 8k banks.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-bank !! 8k-bank !! True Address !! Size !! Description&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $000000-$00ffff || 64K || ZX Spectrum ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $010000-$013fff || 16K || EsxDOS ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $014000-$017fff || 16K || Multiface ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $018000-$01bfff || 16K || Multiface Extra ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $01c000-$01ffff || 16K || Multiface RAM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $020000-$03ffff || 128K || DivMMC RAM&lt;br /&gt;
|-&lt;br /&gt;
| 0-7 || 0-15 || $040000-$05ffff || 128K || Standard 128K RAM&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 || 16-31 || $060000-$07ffff || 128K || Extra RAM&lt;br /&gt;
|-&lt;br /&gt;
| 16-47 || 32-95 || $080000-$0fffff || 512K || 1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 48-79 || 96-159 || $100000-$17ffff || 512K || 2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 80-111 || 160-223 || $180000-$1fffff || 512K || 3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally, the first few pages have certain uses and traits summarised below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-banks !! 8k-banks !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0-1 || Standard RAM, maybe used by EsxDOS.  Initially mapped to $c000-$ffff.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2-3 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-5 || Standard RAM.  Initially mapped to $8000-$bfff.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 6-7 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 8-9 || Standard RAM, contended on +2/+3, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 10-11 || ULA Screen, contended except on Pentagon, cannot be used by [[NextBASIC]] commands.  Initially mapped to $4000-$7fff.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 12-13 || Standard RAM, contended on +2/+3, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 14-15 || ULA Shadow Screen, contended except on Pentagon, NextOS Workspace, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 16-17 || Next RAM, Default Layer 2, NextOS screen and extra data, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 9-10 || 18-21 || Next RAM, Rest of default Layer 2&lt;br /&gt;
|-&lt;br /&gt;
| 11-13 || 22-27 || Next RAM, Default Layer 2 Shadow Screen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please note that NextZXOS moves the Layer 2 bank assignments. Therefore, Layer 2, after NextZXOS boots, is mapped to 16k-banks 9-11 (8k-banks 18-23). The Layer 2 shadow memory is also assigned to 16k-banks 9-11 (8k-banks 18-23).&lt;br /&gt;
&lt;br /&gt;
== Z80 Visible Memory map ==&lt;br /&gt;
&lt;br /&gt;
At start up, the 16-bit address space of the Z80 is mapped to memory as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! 16k-slot !! 8k-slot !! Default 16k-bank !! Default 8k-bank !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || rowspan=2 | 1 || 0 || rowspan=2 | ROM || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2. &lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || rowspan=2 | 2 || 2 || rowspan=2 | 5 || 10 || Normally used for normal/shadow ULA screen. &lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || rowspan=2 | 3 || 4 || rowspan=2 | 2 || 4 || Free RAM. &lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || rowspan=2 | 4 || 6 || rowspan=2 | 0 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Paging techniques ==&lt;br /&gt;
&lt;br /&gt;
=== 128-style memory management ===&lt;br /&gt;
&lt;br /&gt;
128-style memory management can only alter the bank addressed at $c000 (16k-slot 4, or 8k-slot 7-8). The active 16k-bank at $c000 is selected by writing the 3 LSBs of the 16k-bank number to the bottom 3 bits of {{PortNo|$7FFD}}, and the 3 MSBs to the bottom 3 bits of {{PortNo|$DFFD}}. (The reason for the division is that the original Spectrum 128, having only 128k of memory, only needed 3 bits.)&lt;br /&gt;
&lt;br /&gt;
On an unexpanded Next, this allows any 16k-bank to be paged in at $c000. On an expanded Next, there are not enough bits available to access the banks at the bottom of the expanded memory, so Next memory management must be used to access these.&lt;br /&gt;
&lt;br /&gt;
If you are using the standard interrupt handler or OS routines, then any time you write to {{PortNo|$7FFD}} you should also store the value at $5B5C. Any time you write to {{PortNo|$1FFD}} you should also store the value at $5B67. There is no corresponding system variable for the Next-only {{PortNo|$DFFD}} and standard OS routines may not support the extended banks properly.&lt;br /&gt;
&lt;br /&gt;
=== 128 Special Paging Mode ===&lt;br /&gt;
&amp;quot;Special paging mode&amp;quot; (also called &amp;quot;AllRam mode&amp;quot; or &amp;quot;CP/M mode&amp;quot;) is enabled by writing a value with the LSB set to {{PortNo|$1FFD}}. Depending on the 3 low bits of this value a memory configuration is selected as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bits !! Slot 1 !! Slot 2 !! Slot 3 || Slot 4 &lt;br /&gt;
|-&lt;br /&gt;
| %001 || 0 || 1 || 2 || 3 &lt;br /&gt;
|-&lt;br /&gt;
| %011 || 4 || 5 || 6 || 7&lt;br /&gt;
|-&lt;br /&gt;
| %101 || 4 || 5 || 6 || 3&lt;br /&gt;
|-&lt;br /&gt;
| %111 || 4 || 7 || 6 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Switching ===&lt;br /&gt;
Layer 2 switching can allow one of the first sixteen (0-15) 16k-banks to be &#039;&#039;written to&#039;&#039; (but not read) in 16k-slot 1, by writing the 16k-bank number to {{NextRegNo|$12}} and then enabling Layer 2 paging by writing a value with the LSB set to {{PortNo|$123B}}. You can use also the {{NextRegNo|$13}} for the same purpose (change of register $12 is immediately visible at display, while register $13 is not related to display in any way, it works only as bank selector for writing into slot 1).&lt;br /&gt;
&lt;br /&gt;
Writing to this area will then write the appropriate area of memory, whereas &#039;&#039;reading&#039;&#039; from it will give the area mapped by other memory management.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is actually 3 banks big, so using Layer 2 controls to access different &amp;quot;sections&amp;quot; of Layer 2 can access the two following banks after the one selected in register $12/$13.&lt;br /&gt;
&lt;br /&gt;
=== Next Memory Management ===&lt;br /&gt;
The 8k-bank accessed in an 8k-slot is selected by writing the 8k-bank number to bits 7-0 of the 8 Next registers from {{NextRegNo|$50}} upwards. $50 addresses 8k-slot 0, $51 addresses 8k-slot 1, and so on.&lt;br /&gt;
&lt;br /&gt;
In addition, in 8k-slots 0 and 1 only, the ROM can be paged in by selecting the otherwise nonexistent 8k-page $FF. Whether the high or the low 8k of the ROM is mapped is determined by which 8k-slot is used.&lt;br /&gt;
&lt;br /&gt;
=== Interactions between paging methods ===&lt;br /&gt;
In normal mode, changes made in 128 style and Next style memory management are synchronized. The most recent change always has priority. This means that using 128-style memory management to select a new 16k-bank in 16k-slot 4 will update the MMU registers for the two 8k-slots with the corresponding 8k-bank numbers.&lt;br /&gt;
&lt;br /&gt;
However, enabling 128 special paging mode (AllRam mode) mode will &#039;&#039;&#039;override the Next MMU&#039;&#039;&#039;. The bank selections from the AllRam mode table will override the set pages in the Next registers. The MMU registers can still be changed, but they will have no effect until special paging mode is disabled.&lt;br /&gt;
&lt;br /&gt;
Since the 128-style memory management ports are not readable, there is no synchronization applicable in the other direction.&lt;br /&gt;
&lt;br /&gt;
== ROM paging and selection ==&lt;br /&gt;
$0000-$3fff is usually mapped to ROM. This area can only be fully remapped using Next memory management. ROM is not considered one of the numbered banks; it is mapped to the two 8k-banks by default, or by setting their 8k-bank numbers to 255. &lt;br /&gt;
&lt;br /&gt;
The 128k Spectrum has 2 ROM pages. Which of these is mapped is selected by altering Bit 4 of {{PortNo|$7FFD}}. The +2a/+3 has 4 ROM pages; the extra bit needed to select between these is bit 2 of {{PortNo|$1FFD}}. This maintains compatibility with the original machines&#039; ROM paging as long as the ROM is not paged out.&lt;br /&gt;
&lt;br /&gt;
=== Paging out ROM ===&lt;br /&gt;
ROM can be paged out by enabling AllRam mode, or by using Next memory management. Beware that some programs may assume that they can find ROM service routines at fixed addresses between $0000-$3fff. More importantly, if the default interrupt mode (IM 1) is set, the Z80 &#039;&#039;&#039;will&#039;&#039;&#039; jump the program counter to $0038 every frame expecting to find an interrupt handler there. If it does not, pain and suffering will likely result. [[Extended Z80 instruction set#DI|DI]] is your friend. On the plus side, this does allow you to write your own interrupt handler without the nuisance of using IM 2.&lt;br /&gt;
&lt;br /&gt;
Activating [[Layer 2]]&#039;s paging will not affect ROM operation, because it only remaps &#039;&#039;writes&#039;&#039;, not reads.&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
16k-Bank 5 is the bank read by the ULA to determine what to show on screen. The ULA connects directly to the larger memory space ignoring mapping; the screen is always 16k-Bank 5, no matter where in memory it is (or if it is switched in at all). Setting bit 3 of {{PortNo|$7FFD}} will have the ULA read from 16k-bank 7 (the &amp;quot;shadow screen&amp;quot;) instead, which can be used as an alternate screen. Beware that &#039;&#039;&#039;this does not map 16k-bank 7 into RAM&#039;&#039;&#039;; to alter 16k-bank 7 it must be mapped by other means. Also by selecting &amp;quot;shadow screen&amp;quot; the &#039;&#039;&#039;Layer 2 becomes automatically invisible&#039;&#039;&#039;, as the access of ULA to &amp;quot;shadow&amp;quot; bank 7 is slower than normal bank 5 and there&#039;s not enough time to read also Layer 2 for video signal generation (to use &amp;quot;double buffering&amp;quot; together with Layer 2, use Timex screen 0/1 by {{PortNo|$xxFF}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1218</id>
		<title>Memory map</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1218"/>
		<updated>2019-04-26T15:08:00Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Next supports two memory management models which operate in tandem. One is a unique memory management system for the Next. The other is an expanded version of the memory manager from the original Spectrum 128 and +2/+3 series.&lt;br /&gt;
&lt;br /&gt;
== Global Memory Map ==&lt;br /&gt;
&lt;br /&gt;
The total available RAM space of the Next is 768k on an unexpanded Next, or 1792k on a Next expanded to 2Mb. (The base Next has 1mb of memory but 512k of it is reserved for the ROMs and firmware.)&lt;br /&gt;
&lt;br /&gt;
The Z80 processor in the Next can access only 64k of memory at a time, and so the memory is divided into &#039;&#039;banks&#039;&#039; which are used in determining which memory it sees. Spectrum 128k memory management, and [[NextBASIC]], use 16k banks. Next memory management via machine code uses 8k banks.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-bank !! 8k-bank !! True Address !! Size !! Description&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $000000-$00ffff || 64K || ZX Spectrum ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $010000-$013fff || 16K || EsxDOS ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $014000-$017fff || 16K || Multiface ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $018000-$01bfff || 16K || Multiface Extra ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $01c000-$01ffff || 16K || Multiface RAM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $020000-$03ffff || 128K || DivMMC RAM&lt;br /&gt;
|-&lt;br /&gt;
| 0-7 || 0-15 || $040000-$05ffff || 128K || Standard 128K RAM&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 || 16-31 || $060000-$07ffff || 128K || Extra RAM&lt;br /&gt;
|-&lt;br /&gt;
| 16-47 || 32-95 || $080000-$0fffff || 512K || 1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 48-79 || 96-159 || $100000-$17ffff || 512K || 2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 80-111 || 160-223 || $180000-$1fffff || 512K || 3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally, the first few pages have certain uses and traits summarised below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-banks !! 8k-banks !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0-1 || Standard RAM, maybe used by EsxDOS.  Initially mapped to $c000-$ffff.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2-3 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-5 || Standard RAM.  Initially mapped to $8000-$bfff.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 6-7 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 8-9 || Standard RAM, contended on +2/+3, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 10-11 || ULA Screen, contended except on Pentagon, cannot be used by [[NextBASIC]] commands.  Initially mapped to $4000-$7fff.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 12-13 || Standard RAM, contended on +2/+3, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 14-15 || ULA Shadow Screen, contended except on Pentagon, NextOS Workspace, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 16-17 || Next RAM, Default Layer 2, NextOS screen and extra data, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 9-10 || 18-21 || Next RAM, Rest of default Layer 2&lt;br /&gt;
|-&lt;br /&gt;
| 11-13 || 22-27 || Next RAM, Default Layer 2 Shadow Screen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please note that NextOS moves the Layer 2 bank assignments. Therefore, Layer 2, after NextOS boots, is mapped to 16k-banks 9-11 (8k-banks 18-23). The layer 2 shadow memory is also assigned to 16k-banks 9-11 (8k-banks 18-23).&lt;br /&gt;
&lt;br /&gt;
== Z80 Visible Memory map ==&lt;br /&gt;
&lt;br /&gt;
At start up, the 16-bit address space of the Z80 is mapped to memory as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! 16k-slot !! 8k-slot !! Default 16k-bank !! Default 8k-bank !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || rowspan=2 | 1 || 0 || rowspan=2 | ROM || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2. &lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || rowspan=2 | 2 || 2 || rowspan=2 | 5 || 10 || Normally used for normal/shadow ULA screen. &lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || rowspan=2 | 3 || 4 || rowspan=2 | 2 || 4 || Free RAM. &lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || rowspan=2 | 4 || 6 || rowspan=2 | 0 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Paging techniques ==&lt;br /&gt;
&lt;br /&gt;
=== 128-style memory management ===&lt;br /&gt;
&lt;br /&gt;
128-style memory management can only alter the bank addressed at $c000 (16k-slot 4, or 8k-slot 7-8). The active 16k-bank at $c000 is selected by writing the 3 LSBs of the 16k-bank number to the bottom 3 bits of {{PortNo|$7FFD}}, and the 3 MSBs to the bottom 3 bits of {{PortNo|$DFFD}}. (The reason for the division is that the original Spectrum 128, having only 128k of memory, only needed 3 bits.)&lt;br /&gt;
&lt;br /&gt;
On an unexpanded Next, this allows any 16k-bank to be paged in at $c000. On an expanded Next, there are not enough bits available to access the banks at the bottom of the expanded memory, so Next memory management must be used to access these.&lt;br /&gt;
&lt;br /&gt;
If you are using the standard interrupt handler or OS routines, then any time you write to {{PortNo|$7FFD}} you should also store the value at $5B5C. Any time you write to {{PortNo|$1FFD}} you should also store the value at $5B67. There is no corresponding system variable for the Next-only {{PortNo|$DFFD}} and standard OS routines may not support the extended banks properly.&lt;br /&gt;
&lt;br /&gt;
=== 128 Special Paging Mode ===&lt;br /&gt;
&amp;quot;Special paging mode&amp;quot; (also called &amp;quot;AllRam mode&amp;quot; or &amp;quot;CP/M mode&amp;quot;) is enabled by writing a value with the LSB set to {{PortNo|$1FFD}}. Depending on the 3 low bits of this value a memory configuration is selected as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bits !! Slot 1 !! Slot 2 !! Slot 3 || Slot 4 &lt;br /&gt;
|-&lt;br /&gt;
| %001 || 0 || 1 || 2 || 3 &lt;br /&gt;
|-&lt;br /&gt;
| %011 || 4 || 5 || 6 || 7&lt;br /&gt;
|-&lt;br /&gt;
| %101 || 4 || 5 || 6 || 3&lt;br /&gt;
|-&lt;br /&gt;
| %111 || 4 || 7 || 6 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Switching ===&lt;br /&gt;
Layer 2 switching can allow one of the first sixteen (0-15) 16k-banks to be &#039;&#039;written to&#039;&#039; (but not read) in 16k-slot 1, by writing the 16k-bank number to {{NextRegNo|$12}} and then enabling Layer 2 paging by writing a value with the LSB set to {{PortNo|$123B}}. You can use also the {{NextRegNo|$13}} for the same purpose (change of register $12 is immediately visible at display, while register $13 is not related to display in any way, it works only as bank selector for writing into slot 1).&lt;br /&gt;
&lt;br /&gt;
Writing to this area will then write the appropriate area of memory, whereas &#039;&#039;reading&#039;&#039; from it will give the area mapped by other memory management.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is actually 3 banks big, so using Layer 2 controls to access different &amp;quot;sections&amp;quot; of Layer 2 can access the two following banks after the one selected in register $12/$13.&lt;br /&gt;
&lt;br /&gt;
=== Next Memory Management ===&lt;br /&gt;
The 8k-bank accessed in an 8k-slot is selected by writing the 8k-bank number to bits 7-0 of the 8 Next registers from {{NextRegNo|$50}} upwards. $50 addresses 8k-slot 0, $51 addresses 8k-slot 1, and so on.&lt;br /&gt;
&lt;br /&gt;
In addition, in 8k-slots 0 and 1 only, the ROM can be paged in by selecting the otherwise nonexistent 8k-page $FF. Whether the high or the low 8k of the ROM is mapped is determined by which 8k-slot is used.&lt;br /&gt;
&lt;br /&gt;
=== Interactions between paging methods ===&lt;br /&gt;
In normal mode, changes made in 128 style and Next style memory management are synchronized. The most recent change always has priority. This means that using 128-style memory management to select a new 16k-bank in 16k-slot 4 will update the MMU registers for the two 8k-slots with the corresponding 8k-bank numbers.&lt;br /&gt;
&lt;br /&gt;
However, enabling 128 special paging mode (AllRam mode) mode will &#039;&#039;&#039;override the Next MMU&#039;&#039;&#039;. The bank selections from the AllRam mode table will override the set pages in the Next registers. The MMU registers can still be changed, but they will have no effect until special paging mode is disabled.&lt;br /&gt;
&lt;br /&gt;
Since the 128-style memory management ports are not readable, there is no synchronization applicable in the other direction.&lt;br /&gt;
&lt;br /&gt;
== ROM paging and selection ==&lt;br /&gt;
$0000-$3fff is usually mapped to ROM. This area can only be fully remapped using Next memory management. ROM is not considered one of the numbered banks; it is mapped to the two 8k-banks by default, or by setting their 8k-bank numbers to 255. &lt;br /&gt;
&lt;br /&gt;
The 128k Spectrum has 2 ROM pages. Which of these is mapped is selected by altering Bit 4 of {{PortNo|$7FFD}}. The +2a/+3 has 4 ROM pages; the extra bit needed to select between these is bit 2 of {{PortNo|$1FFD}}. This maintains compatibility with the original machines&#039; ROM paging as long as the ROM is not paged out.&lt;br /&gt;
&lt;br /&gt;
=== Paging out ROM ===&lt;br /&gt;
ROM can be paged out by enabling AllRam mode, or by using Next memory management. Beware that some programs may assume that they can find ROM service routines at fixed addresses between $0000-$3fff. More importantly, if the default interrupt mode (IM 1) is set, the Z80 &#039;&#039;&#039;will&#039;&#039;&#039; jump the program counter to $0038 every frame expecting to find an interrupt handler there. If it does not, pain and suffering will likely result. [[Extended Z80 instruction set#DI|DI]] is your friend. On the plus side, this does allow you to write your own interrupt handler without the nuisance of using IM 2.&lt;br /&gt;
&lt;br /&gt;
Activating [[Layer 2]]&#039;s paging will not affect ROM operation, because it only remaps &#039;&#039;writes&#039;&#039;, not reads.&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
16k-Bank 5 is the bank read by the ULA to determine what to show on screen. The ULA connects directly to the larger memory space ignoring mapping; the screen is always 16k-Bank 5, no matter where in memory it is (or if it is switched in at all). Setting bit 3 of {{PortNo|$7FFD}} will have the ULA read from 16k-bank 7 (the &amp;quot;shadow screen&amp;quot;) instead, which can be used as an alternate screen. Beware that &#039;&#039;&#039;this does not map 16k-bank 7 into RAM&#039;&#039;&#039;; to alter 16k-bank 7 it must be mapped by other means. Also by selecting &amp;quot;shadow screen&amp;quot; the &#039;&#039;&#039;Layer 2 becomes automatically invisible&#039;&#039;&#039;, as the access of ULA to &amp;quot;shadow&amp;quot; bank 7 is slower than normal bank 5 and there&#039;s not enough time to read also Layer 2 for video signal generation (to use &amp;quot;double buffering&amp;quot; together with Layer 2, use Timex screen 0/1 by {{PortNo|$xxFF}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1217</id>
		<title>Memory map</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Memory_map&amp;diff=1217"/>
		<updated>2019-04-26T15:06:27Z</updated>

		<summary type="html">&lt;p&gt;Julian S: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Next supports two memory management models which operate in tandem. One is a unique memory management system for the Next. The other is an expanded version of the memory manager from the original Spectrum 128 and +2/+3 series.&lt;br /&gt;
&lt;br /&gt;
== Global Memory Map ==&lt;br /&gt;
&lt;br /&gt;
The total available RAM space of the Next is 768k on an unexpanded Next, or 1792k on a Next expanded to 2Mb. (The base Next has 1mb of memory but 512k of it is reserved for the ROMs and firmware.)&lt;br /&gt;
&lt;br /&gt;
The Z80 processor in the Next can access only 64k of memory at a time, and so the memory is divided into &#039;&#039;banks&#039;&#039; which are used in determining which memory it sees. Spectrum 128k memory management, and [[NextBASIC]], use 16k banks. Next memory management via machine code uses 8k banks.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-bank !! 8k-bank !! True Address !! Size !! Description&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $000000-$00ffff || 64K || ZX Spectrum ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $010000-$013fff || 16K || EsxDOS ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $014000-$017fff || 16K || Multiface ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $018000-$01bfff || 16K || Multiface Extra ROM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $01c000-$01ffff || 16K || Multiface RAM&lt;br /&gt;
|-&lt;br /&gt;
| - || - || $020000-$03ffff || 128K || DivMMC RAM&lt;br /&gt;
|-&lt;br /&gt;
| 0-7 || 0-15 || $040000-$05ffff || 128K || Standard 128K RAM&lt;br /&gt;
|-&lt;br /&gt;
| 8-15 || 16-31 || $060000-$07ffff || 128K || Extra RAM&lt;br /&gt;
|-&lt;br /&gt;
| 16-47 || 32-95 || $080000-$0fffff || 512K || 1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 48-79 || 96-159 || $100000-$17ffff || 512K || 2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|-&lt;br /&gt;
| 80-111 || 160-223 || $180000-$1fffff || 512K || 3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally, the first few pages have certain uses and traits summarised below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 16k-banks !! 8k-banks !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0-1 || Standard RAM, maybe used by EsxDOS.  Initially mapped to $c000-$ffff.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2-3 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-5 || Standard RAM.  Initially mapped to $8000-$bfff.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 6-7 || Standard RAM, contended on 128, may be used by EsxDOS, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 8-9 || Standard RAM, contended on +2/+3, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 10-11 || ULA Screen, contended except on Pentagon, cannot be used by [[NextBASIC]] commands.  Initially mapped to $4000-$7fff.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 12-13 || Standard RAM, contended on +2/+3, RAMdisk on NextOS.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 14-15 || ULA Shadow Screen, contended except on Pentagon, NextOS Workspace, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 16-17 || Next RAM, Default Layer 2, NextOS screen and extra data, cannot be used by [[NextBASIC]] commands&lt;br /&gt;
|-&lt;br /&gt;
| 9-10 || 18-21 || Next RAM, Rest of default Layer 2&lt;br /&gt;
|-&lt;br /&gt;
| 11-13 || 22-27 || Next RAM, Default Layer 2 Shadow Screen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please note that NextOS moves the Layer 2 bank assignments. Therefore, layer 2, after NextOS boots, is mapped to 16k-banks 9-11 (8k-banks 18-23). The layer 2 shadow memory is also assigned to 16k-banks 9-11 (8k-banks 18-23).&lt;br /&gt;
&lt;br /&gt;
== Z80 Visible Memory map ==&lt;br /&gt;
&lt;br /&gt;
At start up, the 16-bit address space of the Z80 is mapped to memory as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! 16k-slot !! 8k-slot !! Default 16k-bank !! Default 8k-bank !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || rowspan=2 | 1 || 0 || rowspan=2 | ROM || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2. &lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || rowspan=2 | 2 || 2 || rowspan=2 | 5 || 10 || Normally used for normal/shadow ULA screen. &lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || rowspan=2 | 3 || 4 || rowspan=2 | 2 || 4 || Free RAM. &lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || rowspan=2 | 4 || 6 || rowspan=2 | 0 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Paging techniques ==&lt;br /&gt;
&lt;br /&gt;
=== 128-style memory management ===&lt;br /&gt;
&lt;br /&gt;
128-style memory management can only alter the bank addressed at $c000 (16k-slot 4, or 8k-slot 7-8). The active 16k-bank at $c000 is selected by writing the 3 LSBs of the 16k-bank number to the bottom 3 bits of {{PortNo|$7FFD}}, and the 3 MSBs to the bottom 3 bits of {{PortNo|$DFFD}}. (The reason for the division is that the original Spectrum 128, having only 128k of memory, only needed 3 bits.)&lt;br /&gt;
&lt;br /&gt;
On an unexpanded Next, this allows any 16k-bank to be paged in at $c000. On an expanded Next, there are not enough bits available to access the banks at the bottom of the expanded memory, so Next memory management must be used to access these.&lt;br /&gt;
&lt;br /&gt;
If you are using the standard interrupt handler or OS routines, then any time you write to {{PortNo|$7FFD}} you should also store the value at $5B5C. Any time you write to {{PortNo|$1FFD}} you should also store the value at $5B67. There is no corresponding system variable for the Next-only {{PortNo|$DFFD}} and standard OS routines may not support the extended banks properly.&lt;br /&gt;
&lt;br /&gt;
=== 128 Special Paging Mode ===&lt;br /&gt;
&amp;quot;Special paging mode&amp;quot; (also called &amp;quot;AllRam mode&amp;quot; or &amp;quot;CP/M mode&amp;quot;) is enabled by writing a value with the LSB set to {{PortNo|$1FFD}}. Depending on the 3 low bits of this value a memory configuration is selected as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Bits !! Slot 1 !! Slot 2 !! Slot 3 || Slot 4 &lt;br /&gt;
|-&lt;br /&gt;
| %001 || 0 || 1 || 2 || 3 &lt;br /&gt;
|-&lt;br /&gt;
| %011 || 4 || 5 || 6 || 7&lt;br /&gt;
|-&lt;br /&gt;
| %101 || 4 || 5 || 6 || 3&lt;br /&gt;
|-&lt;br /&gt;
| %111 || 4 || 7 || 6 || 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Switching ===&lt;br /&gt;
Layer 2 switching can allow one of the first sixteen (0-15) 16k-banks to be &#039;&#039;written to&#039;&#039; (but not read) in 16k-slot 1, by writing the 16k-bank number to {{NextRegNo|$12}} and then enabling Layer 2 paging by writing a value with the LSB set to {{PortNo|$123B}}. You can use also the {{NextRegNo|$13}} for the same purpose (change of register $12 is immediately visible at display, while register $13 is not related to display in any way, it works only as bank selector for writing into slot 1).&lt;br /&gt;
&lt;br /&gt;
Writing to this area will then write the appropriate area of memory, whereas &#039;&#039;reading&#039;&#039; from it will give the area mapped by other memory management.&lt;br /&gt;
&lt;br /&gt;
Layer 2 is actually 3 banks big, so using Layer 2 controls to access different &amp;quot;sections&amp;quot; of Layer 2 can access the two following banks after the one selected in register $12/$13.&lt;br /&gt;
&lt;br /&gt;
=== Next Memory Management ===&lt;br /&gt;
The 8k-bank accessed in an 8k-slot is selected by writing the 8k-bank number to bits 7-0 of the 8 Next registers from {{NextRegNo|$50}} upwards. $50 addresses 8k-slot 0, $51 addresses 8k-slot 1, and so on.&lt;br /&gt;
&lt;br /&gt;
In addition, in 8k-slots 0 and 1 only, the ROM can be paged in by selecting the otherwise nonexistent 8k-page $FF. Whether the high or the low 8k of the ROM is mapped is determined by which 8k-slot is used.&lt;br /&gt;
&lt;br /&gt;
=== Interactions between paging methods ===&lt;br /&gt;
In normal mode, changes made in 128 style and Next style memory management are synchronized. The most recent change always has priority. This means that using 128-style memory management to select a new 16k-bank in 16k-slot 4 will update the MMU registers for the two 8k-slots with the corresponding 8k-bank numbers.&lt;br /&gt;
&lt;br /&gt;
However, enabling 128 special paging mode (AllRam mode) mode will &#039;&#039;&#039;override the Next MMU&#039;&#039;&#039;. The bank selections from the AllRam mode table will override the set pages in the Next registers. The MMU registers can still be changed, but they will have no effect until special paging mode is disabled.&lt;br /&gt;
&lt;br /&gt;
Since the 128-style memory management ports are not readable, there is no synchronization applicable in the other direction.&lt;br /&gt;
&lt;br /&gt;
== ROM paging and selection ==&lt;br /&gt;
$0000-$3fff is usually mapped to ROM. This area can only be fully remapped using Next memory management. ROM is not considered one of the numbered banks; it is mapped to the two 8k-banks by default, or by setting their 8k-bank numbers to 255. &lt;br /&gt;
&lt;br /&gt;
The 128k Spectrum has 2 ROM pages. Which of these is mapped is selected by altering Bit 4 of {{PortNo|$7FFD}}. The +2a/+3 has 4 ROM pages; the extra bit needed to select between these is bit 2 of {{PortNo|$1FFD}}. This maintains compatibility with the original machines&#039; ROM paging as long as the ROM is not paged out.&lt;br /&gt;
&lt;br /&gt;
=== Paging out ROM ===&lt;br /&gt;
ROM can be paged out by enabling AllRam mode, or by using Next memory management. Beware that some programs may assume that they can find ROM service routines at fixed addresses between $0000-$3fff. More importantly, if the default interrupt mode (IM 1) is set, the Z80 &#039;&#039;&#039;will&#039;&#039;&#039; jump the program counter to $0038 every frame expecting to find an interrupt handler there. If it does not, pain and suffering will likely result. [[Extended Z80 instruction set#DI|DI]] is your friend. On the plus side, this does allow you to write your own interrupt handler without the nuisance of using IM 2.&lt;br /&gt;
&lt;br /&gt;
Activating [[Layer 2]]&#039;s paging will not affect ROM operation, because it only remaps &#039;&#039;writes&#039;&#039;, not reads.&lt;br /&gt;
&lt;br /&gt;
== Screen ==&lt;br /&gt;
16k-Bank 5 is the bank read by the ULA to determine what to show on screen. The ULA connects directly to the larger memory space ignoring mapping; the screen is always 16k-Bank 5, no matter where in memory it is (or if it is switched in at all). Setting bit 3 of {{PortNo|$7FFD}} will have the ULA read from 16k-bank 7 (the &amp;quot;shadow screen&amp;quot;) instead, which can be used as an alternate screen. Beware that &#039;&#039;&#039;this does not map 16k-bank 7 into RAM&#039;&#039;&#039;; to alter 16k-bank 7 it must be mapped by other means. Also by selecting &amp;quot;shadow screen&amp;quot; the &#039;&#039;&#039;Layer 2 becomes automatically invisible&#039;&#039;&#039;, as the access of ULA to &amp;quot;shadow&amp;quot; bank 7 is slower than normal bank 5 and there&#039;s not enough time to read also Layer 2 for video signal generation (to use &amp;quot;double buffering&amp;quot; together with Layer 2, use Timex screen 0/1 by {{PortNo|$xxFF}}).&lt;/div&gt;</summary>
		<author><name>Julian S</name></author>
	</entry>
</feed>