<?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=Em00k</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=Em00k"/>
	<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/Special:Contributions/Em00k"/>
	<updated>2026-06-01T23:01:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=41856</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=41856"/>
		<updated>2026-02-24T17:04:30Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuildStudio =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is IDE featuring tools libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] to create software for the ZX Spectrum Next. Version 9 introduces significant changes, including NEX file generation that contains all your assets in a single file, full sprite, palette and tile editing. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect] which can be downloaded from Mike&#039;s itch on install.&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is a fork of [https://code.visualstudio.com/ Visual Studio Code], with simple installation for both Windows and Linux operating systems. NextBuildStudio is fully integrated tightly with VSCode.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://zxnext.uk/nextbuildstudio NextBuild Studio Download] (includes everything : Boriel ZX Basic, ability to download CSpect emulator, ZX Next OS image and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
* For Linux machines, you will need &#039;&#039;&#039;mono-complete&#039;&#039;&#039; installed to run CSpect.&lt;br /&gt;
&lt;br /&gt;
A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
There are two types when referring to tile maps. Software tiles are drawn by copying tiles from preloaded banks to the Layer2 graphics screen. Hardware tile maps use a tile system similar found on retro consoles and computers such as the Commodore 64, Nintendo NES and Sega MegaDrive. Below uses software tiles. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For details on using the hardware tile map see the [Hardware Tilemap] section.&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(n*frames)&lt;br /&gt;
WaitRaster(raster_line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=41855</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=41855"/>
		<updated>2026-02-24T17:04:02Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuildStudio =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is IDE featuring tools libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] to create software for the ZX Spectrum Next. Version 9 introduces significant changes, including NEX file generation that contains all your assets in a single file, full sprite, palette and tile editing. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect] which can be downloaded from Mike&#039;s itch on install.&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is a fork of [https://code.visualstudio.com/ Visual Studio Code], with simple installation for both Windows and Linux operating systems. NextBuildStudio is fully integrated tightly with VSCode.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://zxnext.uk/NextBuildStudio NextBuild Studio Download] (includes everything : Boriel ZX Basic, ability to download CSpect emulator, ZX Next OS image and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
* For Linux machines, you will need &#039;&#039;&#039;mono-complete&#039;&#039;&#039; installed to run CSpect.&lt;br /&gt;
&lt;br /&gt;
A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
There are two types when referring to tile maps. Software tiles are drawn by copying tiles from preloaded banks to the Layer2 graphics screen. Hardware tile maps use a tile system similar found on retro consoles and computers such as the Commodore 64, Nintendo NES and Sega MegaDrive. Below uses software tiles. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For details on using the hardware tile map see the [Hardware Tilemap] section.&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(n*frames)&lt;br /&gt;
WaitRaster(raster_line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=30692</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=30692"/>
		<updated>2025-09-15T01:16:41Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Timing and Synchronization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuildStudio =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is IDE featuring tools libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] to create software for the ZX Spectrum Next. Version 9 introduces significant changes, including NEX file generation that contains all your assets in a single file, full sprite, palette and tile editing. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is a fork of [https://code.visualstudio.com/ Visual Studio Code], with simple installation for both Windows and Linux operating systems. NextBuildStudio is fully integrated tightly with VSCode.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://zxnext.uk/NextBuildStudio NextBuild Studio Download] (includes everything : Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
* For Linux machines, you will need &#039;&#039;&#039;mono-complete&#039;&#039;&#039; installed to run CSpect.&lt;br /&gt;
&lt;br /&gt;
A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
There are two types when referring to tile maps. Software tiles are drawn by copying tiles from preloaded banks to the Layer2 graphics screen. Hardware tile maps use a tile system similar found on retro consoles and computers such as the Commodore 64, Nintendo NES and Sega MegaDrive. Below uses software tiles. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For details on using the hardware tile map see the [Hardware Tilemap] section.&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(n*frames)&lt;br /&gt;
WaitRaster(raster_line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuild:Main_Page&amp;diff=30691</id>
		<title>NextBuild:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuild:Main_Page&amp;diff=30691"/>
		<updated>2025-09-15T01:15:32Z</updated>

		<summary type="html">&lt;p&gt;Em00k: Em00k moved page NextBuild:Main Page to NextBuildStudio:Main Page: NextBuild is now NextBuildStudio&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[NextBuildStudio:Main Page]]&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=30690</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=30690"/>
		<updated>2025-09-15T01:15:31Z</updated>

		<summary type="html">&lt;p&gt;Em00k: Em00k moved page NextBuild:Main Page to NextBuildStudio:Main Page: NextBuild is now NextBuildStudio&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuildStudio =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is IDE featuring tools libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] to create software for the ZX Spectrum Next. Version 9 introduces significant changes, including NEX file generation that contains all your assets in a single file, full sprite, palette and tile editing. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is a fork of [https://code.visualstudio.com/ Visual Studio Code], with simple installation for both Windows and Linux operating systems. NextBuildStudio is fully integrated tightly with VSCode.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://zxnext.uk/NextBuildStudio NextBuild Studio Download] (includes everything : Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
* For Linux machines, you will need &#039;&#039;&#039;mono-complete&#039;&#039;&#039; installed to run CSpect.&lt;br /&gt;
&lt;br /&gt;
A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
There are two types when referring to tile maps. Software tiles are drawn by copying tiles from preloaded banks to the Layer2 graphics screen. Hardware tile maps use a tile system similar found on retro consoles and computers such as the Commodore 64, Nintendo NES and Sega MegaDrive. Below uses software tiles. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For details on using the hardware tile map see the [Hardware Tilemap] section.&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=30689</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=30689"/>
		<updated>2025-09-15T01:14:06Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuildStudio =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is IDE featuring tools libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] to create software for the ZX Spectrum Next. Version 9 introduces significant changes, including NEX file generation that contains all your assets in a single file, full sprite, palette and tile editing. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is a fork of [https://code.visualstudio.com/ Visual Studio Code], with simple installation for both Windows and Linux operating systems. NextBuildStudio is fully integrated tightly with VSCode.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://zxnext.uk/NextBuildStudio NextBuild Studio Download] (includes everything : Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
* For Linux machines, you will need &#039;&#039;&#039;mono-complete&#039;&#039;&#039; installed to run CSpect.&lt;br /&gt;
&lt;br /&gt;
A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
There are two types when referring to tile maps. Software tiles are drawn by copying tiles from preloaded banks to the Layer2 graphics screen. Hardware tile maps use a tile system similar found on retro consoles and computers such as the Commodore 64, Nintendo NES and Sega MegaDrive. Below uses software tiles. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For details on using the hardware tile map see the [Hardware Tilemap] section.&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=30688</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=30688"/>
		<updated>2025-09-15T01:12:11Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* NextBuild v8 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuildStudio =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is IDE featuring tools libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] to create software for the ZX Spectrum Next. Version 9 introduces significant changes, including NEX file generation that contains all your assets in a single file, full sprite, palette and tile editing. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
NextBuildStudio is a fork of [https://code.visualstudio.com/ Visual Studio Code], with simple installation for both Windows and Linux operating systems. NextBuildStudio is fully integrated tightly with VSCode.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
There are two types when referring to tile maps. Software tiles are drawn by copying tiles from preloaded banks to the Layer2 graphics screen. Hardware tile maps use a tile system similar found on retro consoles and computers such as the Commodore 64, Nintendo NES and Sega MegaDrive. Below uses software tiles. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For details on using the hardware tile map see the [Hardware Tilemap] section.&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Kempston_Joystick&amp;diff=28327</id>
		<title>Kempston Joystick</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Kempston_Joystick&amp;diff=28327"/>
		<updated>2025-09-10T09:35:04Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Port&lt;br /&gt;
|Number=$xx1F&lt;br /&gt;
|NumberDec=31&lt;br /&gt;
|PortMask=%---- ---- 0001 1111&lt;br /&gt;
|ShortDesc=Reads movement of joysticks using Kempston (Joystick/Gamepad) interface.&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=No&lt;br /&gt;
|Subsystem=Input&lt;br /&gt;
}}&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot;| Bit !!colspan=&amp;quot;2&amp;quot;| Function &lt;br /&gt;
|-&lt;br /&gt;
! Kempston joystick !! MD controller&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 0 || start button&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 0 || A button&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Fire 2 || C button&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Fire 1 || B button&lt;br /&gt;
|-&lt;br /&gt;
| 3 ||colspan=&amp;quot;2&amp;quot;| up&lt;br /&gt;
|-&lt;br /&gt;
| 2 ||colspan=&amp;quot;2&amp;quot;| down&lt;br /&gt;
|-&lt;br /&gt;
| 1 ||colspan=&amp;quot;2&amp;quot;| left&lt;br /&gt;
|-&lt;br /&gt;
| 0 ||colspan=&amp;quot;2&amp;quot;| right&lt;br /&gt;
|}&lt;br /&gt;
For all bits 0 = not pressed / 1 = pressed&lt;br /&gt;
&lt;br /&gt;
since core3.1.4 the X/Y/Z/mode buttons of 6-button controllers are not read by the FPGA (and Fire 1 is &amp;quot;B&amp;quot; button, this page and some other documentation was mentioning button &amp;quot;C&amp;quot;, but seems like it was &amp;quot;B&amp;quot; all the time, or got remapped in core3.1.4).&lt;br /&gt;
&lt;br /&gt;
Note for non-programmers: the Next board does read fire1(B)/fire2(C)/A/start buttons of controller and provide the state for SW through this port, but that does not imply the SW will react to the extra buttons. Actually majority of legacy SW was not aware of existence of joysticks with more than one fire button, the &amp;quot;fire2&amp;quot; input in Kempston interface did appear very late in the life cycle of ZX when game producers already moved onto more modern platforms. So support for second fire button or full four button of MD pads needs to be present also in the code of the particular game, either patched version of legacy game, or new production designed for ZX Next.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Extended_MD_Pad_Buttons_Register&amp;diff=28326</id>
		<title>Extended MD Pad Buttons Register</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Extended_MD_Pad_Buttons_Register&amp;diff=28326"/>
		<updated>2025-09-10T09:33:27Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NextRegister&lt;br /&gt;
|Number=$B2&lt;br /&gt;
|Readable=Yes&lt;br /&gt;
|Writable=No&lt;br /&gt;
|ShortDesc=Reading additional buttons on MD pads (Joystick/Gamepad)&lt;br /&gt;
}}&lt;br /&gt;
  bit 7 = 1 if Right Pad X pressed&lt;br /&gt;
  bit 6 = 1 if Right Pad Z pressed&lt;br /&gt;
  bit 5 = 1 if Right Pad Y pressed&lt;br /&gt;
  bit 4 = 1 if Right Pad MODE pressed&lt;br /&gt;
  bit 3 = 1 if Left Pad X pressed&lt;br /&gt;
  bit 2 = 1 if Left Pad Z pressed&lt;br /&gt;
  bit 1 = 1 if Left Pad Y pressed&lt;br /&gt;
  bit 0 = 1 if Left Pad MODE pressed&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14057</id>
		<title>Turbo Sound Next</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14057"/>
		<updated>2025-05-25T12:01:42Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* AY-3-8912 layout */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Turbo Sound Next is the audio system integrated on the Spectrum Next. It features 3 AY-3-8912 sound chips as used in the Spectrum.&lt;br /&gt;
&lt;br /&gt;
A MOS 6581 (SID), as used on the Commodore 64, was experimentally added to the FPGA during development but it was later removed due to the large amount of space it takes up (it is 4 times as big as an AY). &lt;br /&gt;
&lt;br /&gt;
For information on playing back PT3 files, have a look here : [[https://wiki.specnext.dev/Code:PT3 Various PT3 replay methods]]&lt;br /&gt;
&lt;br /&gt;
= Chip Selection =&lt;br /&gt;
{{PortNo|$FFFD}} controls the selected chip and enables and disables stereo channels per chip. {{NextRegNo|$08}} controls the mapping of chip channels to stereo channels and {{NextRegNo|$09}} can be used to enable &amp;quot;mono&amp;quot; output per chip.&lt;br /&gt;
&lt;br /&gt;
Once a sound chip is selected, {{PortNo|$FFFD}} also selects the active register on that chip. {{PortNo|$BFFD}} then allows it to be read or written.&lt;br /&gt;
&lt;br /&gt;
{{NextRegNo|$06}} controls audio chip mode. &lt;br /&gt;
&lt;br /&gt;
= AY-3-8912 layout =&lt;br /&gt;
The 3 AY-3-8912 chips have the following register layout:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Register !! Function&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Channel A Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Channel A Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Channel B Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Channel B Coarse Tune (4 bits)&lt;br /&gt;
|- &lt;br /&gt;
| 4 || Channel C Fine Tune&lt;br /&gt;
|- &lt;br /&gt;
| 5 || Channel C Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Noise Period (5 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tone enable flags. &lt;br /&gt;
&lt;br /&gt;
Bits 0-2 enable tone on channels A, B, C respectively, but are inverted - 0 is enabled. &lt;br /&gt;
&lt;br /&gt;
Bits 3-5 enable noise on A, B, C are are likewise inverted.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Channel A amplitude. &lt;br /&gt;
&lt;br /&gt;
Bits 0-3 set the fixed amplitude which is used if bit 4 is 0. If bit 4 is 1, the envelope generator is used instead, and bits 0-3 are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Channel B amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Channel C amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Envelope period fine.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Envelope period coarse.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Envelope shape. &lt;br /&gt;
Bits 0-3 alter the behaviour of the envelope generator:&lt;br /&gt;
Bit 0: &amp;quot;Hold&amp;quot;; If 1 the envelope generator performs one cycle then holds at the end value. If 0, it cycles continuously.&lt;br /&gt;
&lt;br /&gt;
Bit 1: &amp;quot;Alternate&amp;quot;; If 1 the envelope generator alters direction after each cycle. If 0, it resets after each cycle. If Hold is set, this instead chooses if the value held is the final value (0) or the initial value (1).&lt;br /&gt;
&lt;br /&gt;
Bit 2: &amp;quot;Attack&amp;quot;; if 1 the generator counts up. If 0 the generator counts down.&lt;br /&gt;
&lt;br /&gt;
Bit 3: &amp;quot;Continue&amp;quot;; if 0, the envelope generator performs one cycle then drops amplitude to 0 and stays there, overriding Hold. If 1, Hold is followed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AY I/O registers 14 and 15 are not implemented on the Next, so bit-banged software written to use RS-232 and AUX ports on the Amstrad Spectrum models is not supported. The Next has a separate high-speed hardware [[UART]], which can be connected to the [[ESP8266-01]] wifi module or a wired RS-232 cable. The UART is interfaced through the {{PortNo|$133B}} and {{PortNo|$143B}} ports.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14046</id>
		<title>Turbo Sound Next</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14046"/>
		<updated>2025-05-24T19:05:30Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Turbo Sound Next is the audio system integrated on the Spectrum Next. It features 3 AY-3-8912 sound chips as used in the Spectrum.&lt;br /&gt;
&lt;br /&gt;
A MOS 6581 (SID), as used on the Commodore 64, was experimentally added to the FPGA during development but it was later removed due to the large amount of space it takes up (it is 4 times as big as an AY). &lt;br /&gt;
&lt;br /&gt;
For information on playing back PT3 files, have a look here : [[https://wiki.specnext.dev/Code:PT3 Various PT3 replay methods]]&lt;br /&gt;
&lt;br /&gt;
= Chip Selection =&lt;br /&gt;
{{PortNo|$FFFD}} controls the selected chip and enables and disables stereo channels per chip. {{NextRegNo|$08}} controls the mapping of chip channels to stereo channels and {{NextRegNo|$09}} can be used to enable &amp;quot;mono&amp;quot; output per chip.&lt;br /&gt;
&lt;br /&gt;
Once a sound chip is selected, {{PortNo|$FFFD}} also selects the active register on that chip. {{PortNo|$BFFD}} then allows it to be read or written.&lt;br /&gt;
&lt;br /&gt;
{{NextRegNo|$06}} controls audio chip mode. &lt;br /&gt;
&lt;br /&gt;
= AY-3-8912 layout =&lt;br /&gt;
The 3 AY-3-8912 chips have the following register layout:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Register !! Function&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Channel A Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Channel A Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Channel B Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Channel B Coarse Tune (4 bits)&lt;br /&gt;
|- &lt;br /&gt;
| 4 || Channel C Fine Tune&lt;br /&gt;
|- &lt;br /&gt;
| 5 || Channel C Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Noise Period (5 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tone enable flags. Bits 0-2 enable tone on channels A, B, C respectively, but are inverted - 0 is enabled. Bits 3-5 enable noise on A, B, C are are likewise inverted.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Channel A amplitude. Bits 0-3 set the fixed amplitude which is used if bit 4 is 0. If bit 4 is 1, the envelope generator is used instead, and bits 0-3 are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Channel B amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Channel C amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Envelope period fine.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Envelope period coarse.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Envelope shape. Bits 0-3 alter the behaviour of the envelope generator:&lt;br /&gt;
Bit 0: &amp;quot;Hold&amp;quot;; If 1 the envelope generator performs one cycle then holds at the end value. If 0, it cycles continuously.&lt;br /&gt;
&lt;br /&gt;
Bit 1: &amp;quot;Alternate&amp;quot;; If 1 the envelope generator alters direction after each cycle. If 0, it resets after each cycle. If Hold is set, this instead chooses if the value held is the final value (0) or the initial value (1).&lt;br /&gt;
&lt;br /&gt;
Bit 2: &amp;quot;Attack&amp;quot;; if 1 the generator counts up. If 0 the generator counts down.&lt;br /&gt;
&lt;br /&gt;
Bit 3: &amp;quot;Continue&amp;quot;; if 0, the envelope generator performs one cycle then drops amplitude to 0 and stays there, overriding Hold. If 1, Hold is followed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AY I/O registers 14 and 15 are not implemented on the Next, so bit-banged software written to use RS-232 and AUX ports on the Amstrad Spectrum models is not supported. The Next has a separate high-speed hardware [[UART]], which can be connected to the [[ESP8266-01]] wifi module or a wired RS-232 cable. The UART is interfaced through the {{PortNo|$133B}} and {{PortNo|$143B}} ports.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14045</id>
		<title>Turbo Sound Next</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14045"/>
		<updated>2025-05-24T19:04:45Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Turbo Sound Next is the audio system integrated on the Spectrum Next. It features 3 AY-3-8912 sound chips as used in the Spectrum.&lt;br /&gt;
&lt;br /&gt;
A MOS 6581 (SID), as used on the Commodore 64, was experimentally added to the FPGA during development but it was later removed due to the large amount of space it takes up (it is 4 times as big as an AY). &lt;br /&gt;
&lt;br /&gt;
For information on playing back PT3 files, have a look here : [[https://wiki.specnext.dev/Code:PT3 |Various PT3 replay methods]]&lt;br /&gt;
&lt;br /&gt;
= Chip Selection =&lt;br /&gt;
{{PortNo|$FFFD}} controls the selected chip and enables and disables stereo channels per chip. {{NextRegNo|$08}} controls the mapping of chip channels to stereo channels and {{NextRegNo|$09}} can be used to enable &amp;quot;mono&amp;quot; output per chip.&lt;br /&gt;
&lt;br /&gt;
Once a sound chip is selected, {{PortNo|$FFFD}} also selects the active register on that chip. {{PortNo|$BFFD}} then allows it to be read or written.&lt;br /&gt;
&lt;br /&gt;
{{NextRegNo|$06}} controls audio chip mode. &lt;br /&gt;
&lt;br /&gt;
= AY-3-8912 layout =&lt;br /&gt;
The 3 AY-3-8912 chips have the following register layout:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Register !! Function&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Channel A Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Channel A Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Channel B Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Channel B Coarse Tune (4 bits)&lt;br /&gt;
|- &lt;br /&gt;
| 4 || Channel C Fine Tune&lt;br /&gt;
|- &lt;br /&gt;
| 5 || Channel C Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Noise Period (5 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tone enable flags. Bits 0-2 enable tone on channels A, B, C respectively, but are inverted - 0 is enabled. Bits 3-5 enable noise on A, B, C are are likewise inverted.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Channel A amplitude. Bits 0-3 set the fixed amplitude which is used if bit 4 is 0. If bit 4 is 1, the envelope generator is used instead, and bits 0-3 are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Channel B amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Channel C amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Envelope period fine.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Envelope period coarse.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Envelope shape. Bits 0-3 alter the behaviour of the envelope generator:&lt;br /&gt;
Bit 0: &amp;quot;Hold&amp;quot;; If 1 the envelope generator performs one cycle then holds at the end value. If 0, it cycles continuously.&lt;br /&gt;
&lt;br /&gt;
Bit 1: &amp;quot;Alternate&amp;quot;; If 1 the envelope generator alters direction after each cycle. If 0, it resets after each cycle. If Hold is set, this instead chooses if the value held is the final value (0) or the initial value (1).&lt;br /&gt;
&lt;br /&gt;
Bit 2: &amp;quot;Attack&amp;quot;; if 1 the generator counts up. If 0 the generator counts down.&lt;br /&gt;
&lt;br /&gt;
Bit 3: &amp;quot;Continue&amp;quot;; if 0, the envelope generator performs one cycle then drops amplitude to 0 and stays there, overriding Hold. If 1, Hold is followed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AY I/O registers 14 and 15 are not implemented on the Next, so bit-banged software written to use RS-232 and AUX ports on the Amstrad Spectrum models is not supported. The Next has a separate high-speed hardware [[UART]], which can be connected to the [[ESP8266-01]] wifi module or a wired RS-232 cable. The UART is interfaced through the {{PortNo|$133B}} and {{PortNo|$143B}} ports.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14044</id>
		<title>Turbo Sound Next</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14044"/>
		<updated>2025-05-24T19:03:41Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Turbo Sound Next is the audio system integrated on the Spectrum Next. It features 3 AY-3-8912 sound chips as used in the Spectrum.&lt;br /&gt;
&lt;br /&gt;
A MOS 6581 (SID), as used on the Commodore 64, was experimentally added to the FPGA during development but it was later removed due to the large amount of space it takes up (it is 4 times as big as an AY). &lt;br /&gt;
&lt;br /&gt;
For information on playing back PT3 files, have a look here : [[https://wiki.specnext.dev/Code:PT3|Various PT3 replay methods]]&lt;br /&gt;
&lt;br /&gt;
= Chip Selection =&lt;br /&gt;
{{PortNo|$FFFD}} controls the selected chip and enables and disables stereo channels per chip. {{NextRegNo|$08}} controls the mapping of chip channels to stereo channels and {{NextRegNo|$09}} can be used to enable &amp;quot;mono&amp;quot; output per chip.&lt;br /&gt;
&lt;br /&gt;
Once a sound chip is selected, {{PortNo|$FFFD}} also selects the active register on that chip. {{PortNo|$BFFD}} then allows it to be read or written.&lt;br /&gt;
&lt;br /&gt;
{{NextRegNo|$06}} controls audio chip mode. &lt;br /&gt;
&lt;br /&gt;
= AY-3-8912 layout =&lt;br /&gt;
The 3 AY-3-8912 chips have the following register layout:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Register !! Function&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Channel A Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Channel A Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Channel B Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Channel B Coarse Tune (4 bits)&lt;br /&gt;
|- &lt;br /&gt;
| 4 || Channel C Fine Tune&lt;br /&gt;
|- &lt;br /&gt;
| 5 || Channel C Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Noise Period (5 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tone enable flags. Bits 0-2 enable tone on channels A, B, C respectively, but are inverted - 0 is enabled. Bits 3-5 enable noise on A, B, C are are likewise inverted.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Channel A amplitude. Bits 0-3 set the fixed amplitude which is used if bit 4 is 0. If bit 4 is 1, the envelope generator is used instead, and bits 0-3 are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Channel B amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Channel C amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Envelope period fine.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Envelope period coarse.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Envelope shape. Bits 0-3 alter the behaviour of the envelope generator:&lt;br /&gt;
Bit 0: &amp;quot;Hold&amp;quot;; If 1 the envelope generator performs one cycle then holds at the end value. If 0, it cycles continuously.&lt;br /&gt;
&lt;br /&gt;
Bit 1: &amp;quot;Alternate&amp;quot;; If 1 the envelope generator alters direction after each cycle. If 0, it resets after each cycle. If Hold is set, this instead chooses if the value held is the final value (0) or the initial value (1).&lt;br /&gt;
&lt;br /&gt;
Bit 2: &amp;quot;Attack&amp;quot;; if 1 the generator counts up. If 0 the generator counts down.&lt;br /&gt;
&lt;br /&gt;
Bit 3: &amp;quot;Continue&amp;quot;; if 0, the envelope generator performs one cycle then drops amplitude to 0 and stays there, overriding Hold. If 1, Hold is followed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AY I/O registers 14 and 15 are not implemented on the Next, so bit-banged software written to use RS-232 and AUX ports on the Amstrad Spectrum models is not supported. The Next has a separate high-speed hardware [[UART]], which can be connected to the [[ESP8266-01]] wifi module or a wired RS-232 cable. The UART is interfaced through the {{PortNo|$133B}} and {{PortNo|$143B}} ports.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14043</id>
		<title>Turbo Sound Next</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Turbo_Sound_Next&amp;diff=14043"/>
		<updated>2025-05-24T19:03:19Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Turbo Sound Next is the audio system integrated on the Spectrum Next. It features 3 AY-3-8912 sound chips as used in the Spectrum.&lt;br /&gt;
&lt;br /&gt;
A MOS 6581 (SID), as used on the Commodore 64, was experimentally added to the FPGA during development but it was later removed due to the large amount of space it takes up (it is 4 times as big as an AY). &lt;br /&gt;
&lt;br /&gt;
For information on playing back PT3 files, have a look here : [[https://wiki.specnext.dev/Code:PT3|Various PT3 replay methods]]&lt;br /&gt;
&lt;br /&gt;
= Chip Selection =&lt;br /&gt;
{{PortNo|$FFFD}} controls the selected chip and enables and disables stereo channels per chip. {{NextRegNo|$08}} controls the mapping of chip channels to stereo channels and {{NextRegNo|$09}} can be used to enable &amp;quot;mono&amp;quot; output per chip.&lt;br /&gt;
&lt;br /&gt;
Once a sound chip is selected, {{PortNo|$FFFD}} also selects the active register on that chip. {{PortNo|$BFFD}} then allows it to be read or written.&lt;br /&gt;
&lt;br /&gt;
{{NextRegNo|$06}} controls audio chip mode. &lt;br /&gt;
&lt;br /&gt;
= AY-3-8912 layout =&lt;br /&gt;
The 3 AY-3-8912 chips have the following register layout:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Register !! Function&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Channel A Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Channel A Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Channel B Fine Tune&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Channel B Coarse Tune (4 bits)&lt;br /&gt;
|- &lt;br /&gt;
| 4 || Channel C Fine Tune&lt;br /&gt;
|- &lt;br /&gt;
| 5 || Channel C Coarse Tune (4 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Noise Period (5 bits)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tone enable flags. Bits 0-2 enable tone on channels A, B, C respectively, but are inverted - 0 is enabled. Bits 3-5 enable noise on A, B, C are are likewise inverted.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Channel A amplitude. Bits 0-3 set the fixed amplitude which is used if bit 4 is 0. If bit 4 is 1, the envelope generator is used instead, and bits 0-3 are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Channel B amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Channel C amplitude, same as above.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Envelope period fine.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Envelope period coarse.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Envelope shape. Bits 0-3 alter the behavior of the envelope generator:&lt;br /&gt;
Bit 0: &amp;quot;Hold&amp;quot;; If 1 the envelope generator performs one cycle then holds at the end value. If 0, it cycles continuously.&lt;br /&gt;
&lt;br /&gt;
Bit 1: &amp;quot;Alternate&amp;quot;; If 1 the envelope generator alters direction after each cycle. If 0, it resets after each cycle. If Hold is set, this instead chooses if the value held is the final value (0) or the initial value (1).&lt;br /&gt;
&lt;br /&gt;
Bit 2: &amp;quot;Attack&amp;quot;; if 1 the generator counts up. If 0 the generator counts down.&lt;br /&gt;
&lt;br /&gt;
Bit 3: &amp;quot;Continue&amp;quot;; if 0, the envelope generator performs one cycle then drops amplitude to 0 and stays there, overriding Hold. If 1, Hold is followed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AY I/O registers 14 and 15 are not implemented on the Next, so bit-banged software written to use RS-232 and AUX ports on the Amstrad Spectrum models is not supported. The Next has a separate high-speed hardware [[UART]], which can be connected to the [[ESP8266-01]] wifi module or a wired RS-232 cable. The UART is interfaced through the {{PortNo|$133B}} and {{PortNo|$143B}} ports.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Code:PT3&amp;diff=14039</id>
		<title>Code:PT3</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Code:PT3&amp;diff=14039"/>
		<updated>2025-05-24T17:03:32Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Playing back .PT3 Audio Files&lt;br /&gt;
&lt;br /&gt;
=== Assembler ===&lt;br /&gt;
* [[Code:PT3:sjasmplus|sjasmplus]]&lt;br /&gt;
* https://github.com/em00k/3ch-6ch-PT3-player-ZXNext&lt;br /&gt;
=== BASIC ===&lt;br /&gt;
* [[Dot:playpt3|DOT]]&lt;br /&gt;
* [[Code:PT3:BASIC|BASIC Driver]]&lt;br /&gt;
* [[Code:PT3:Boriel|Boriel]]&lt;br /&gt;
&lt;br /&gt;
=== C ===&lt;br /&gt;
* [[Code:PT3:Z88DK|Z88DK]]&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13564</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13564"/>
		<updated>2025-04-15T00:02:02Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* How do I connect to Wi-Fi? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== I am using HDMI and I get no picture ==&lt;br /&gt;
When the Next boots hold down D for DIGITAL (HDMI) – Mode 7 50hz / 60hz can be selected. N selects the next frequency, ENTER selects it and saves. ONLY PRESS ENTER if you actually see a screen like the one below. N is NOT necessary as the testscreen will automatically go to the next mode albeit slower.&lt;br /&gt;
[[File:Figure02-TestScreenMode7.png|thumb|ZX Spectrum Next Test Screen]]&lt;br /&gt;
&lt;br /&gt;
You will also get an audible intermittent tone so you know your audio is working. It&#039;s possible your display can lock onto both modes but only one being able to lock onto the audio. Choose the one with the tone before pressing ENTER. Extract the files and copy over the BIN / SYS/ TMP folders to the root of your SD.&lt;br /&gt;
&lt;br /&gt;
== How to use esxDOS with 48K mode ==&lt;br /&gt;
[[File:2023-12-17 21 01 56-Window.png|thumb|esxDOS files]]&lt;br /&gt;
Your ZX Next can simulate the divMMC hardware for other machines. You can use esxDOS with 128/48K machines. You can download the latest esxDOS zip file here https://esxdos.org/index.html Download the zip and copy over the following folders BIN/SYS/TMP.&lt;br /&gt;
&lt;br /&gt;
You will need to place the ESXMMC.BIN in to /machines/next/roms&lt;br /&gt;
&lt;br /&gt;
Boot up your Next and press SPACE to open the configuration menu. Use the arrow keys to select 48K Mode, SPACE again and ensure DIVmmc ROM = YES. Exit and save this configuration. When your Next boots it should show the esxDOS logo just before the (c)1982 Sinclair Research Ltd message.&lt;br /&gt;
&lt;br /&gt;
[[ESXDOS|Further information can be found here]]&lt;br /&gt;
&lt;br /&gt;
[[File:Pre boot machine select menu.png|thumb]]&lt;br /&gt;
[[File:2023-12-17 21 21 11-OBS 30.0.0 - Profile Untitled - Scenes Untitled.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== I am using VGA and I get no picture ==&lt;br /&gt;
When the Next boots hold down V for VGA – Mode 0-6 50hz / 60hz can be selected. VGA0 is the&lt;br /&gt;
preferred mode as this has accurate timings. 1 – 6 are also accurate timings but increase slightly&lt;br /&gt;
in speed. N works as above but there are 12 possible configurations you can choose from. You&#039;ll start at VGA0@50Hz, next one will be the same at 60Hz and so forth. ENTER again selects and saves the changes. Audio is also being produced during the VGA Test Screen phase, however you will need powered speakers (or earphones) plugged in the audio out connector at the back of your Next.&lt;br /&gt;
&lt;br /&gt;
== I&#039;m using an HDMI display and a game&#039;s graphics appear garbled ==&lt;br /&gt;
Some games (specifically ones with multicolour or border effects - eg. Nirvana/Bifrost engine games, certain demos particularly ex-Soviet demoscene ones) require precise timings as with a regular Spectrum. Due to the nature of HDMI displays and the lack of internal buffering on the Spectrum Next display hardware currently these will not work properly and require a VGA or RGB display. &lt;br /&gt;
This is expected to be fixed in a future edition of the core/distribution but until then, there are a few alternative solutions:&lt;br /&gt;
a. An extra Spectrum core that implements precise HDMI timings by removing some of the Next&#039;s extra features. &lt;br /&gt;
b. Use of OSSC hardware which takes the Next&#039;s RGB/VGA display and converts it to HDMI independently&lt;br /&gt;
c. Use of the ZXHD or TkPie hardware expansions (only for standard Spectrum modes at 3.5MHz clock) &lt;br /&gt;
Next specific programs do not have this issue as they&#039;re made taking the current HDMI timing differences into account and will continue to work in the future when the most appropriate HDMI solution is implemented.&lt;br /&gt;
&lt;br /&gt;
== I am updating to the latest distro from GitLab or the N-Go website and my ps/2 keyboard doesn&#039;t work ==&lt;br /&gt;
To use a ps/2 keyboard you need to first choose whether you have a mouse or keyboard plugged into your ps/2 port. Unfortunately you can&#039;t get to the screen where you can make this choice &#039;&#039;until&#039;&#039; you have chosen your video mode on the testcard screen... which &#039;&#039;needs&#039;&#039; the keyboard to be already working!  &lt;br /&gt;
&lt;br /&gt;
Download this minimal config.ini file [https://dl.dropbox.com/s/5na7sd21328jnz5/CONFIG.INI] and copy it to the &#039;&#039;&#039;/Machines/Next&#039;&#039;&#039; folder on your SD card, then try again.&lt;br /&gt;
&lt;br /&gt;
When updating your distro from the official [[https://www.specnext.com/latestdistro/ Latest Distro]] page, or when using the internal keyboard on your official kickstarter 1 or 2 Next, this problem will not occur.&lt;br /&gt;
&lt;br /&gt;
== My monitor shows wrong image with Soviet timings(Pentagon)  ==&lt;br /&gt;
Pentagon has a non-standard screen refresh rate of 48.828Hz, some monitors do not support it. In some cases, can help manual picture settings in menu of your monitor. &lt;br /&gt;
Another solution to the issue is to buy a monitor that is compatible with Pentagon timings. User-generated list of compatible monitors located here: http://www.nedopc.com/zxevo/zxevo_supported_monitors.pdf&lt;br /&gt;
As a rule, monitors from this list are available on the secondary market at a low cost. Before purchasing desirable testing monitor with Pentagon mode.&lt;br /&gt;
&lt;br /&gt;
== HELP! My &amp;lt;insert game name here&amp;gt; doesn&#039;t work while it works on my &amp;lt;insert older Spectrum model here&amp;gt; ==&lt;br /&gt;
This is most likely due to a specific incompatibility of said program with the Next&#039;s extra hardware. The NextZXOS loader module, provides a lot of options for loading software catering to each model&#039;s idiosyncracies but also gives you the option to disable almost all Next extra hardware in order to make it work. If, after trying everything, the software doesn&#039;t work, you need to inform the team using the official gitlab repo &amp;quot;Issues&amp;quot; (registration is required) and provide a link to a copy of your program. The team will look at the specific issue and respond/fix the issue as soon as possible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What classic files can I load on my Next? ==&lt;br /&gt;
The Next supports NEXs, TAPs (preferred for classic software), SNAs, DSKs, Z80s, SNXs which can be loaded from the browser&lt;br /&gt;
menu by selecting them with the cursor keys and ENTER (or a joystick and Fire) -OR- by using the SPECTRUM command. (See Chapter 20 in the manual for details).&lt;br /&gt;
Place the files on your SD card and pick from the Browser.&lt;br /&gt;
&lt;br /&gt;
== How to load from a software cassette tape ==&lt;br /&gt;
For a successful load a clear signal from the player has to arrive on the &amp;quot;ring&amp;quot; part of the plug which you insert in the EAR/MIC socket of your Next, as in the picture &amp;quot;Next&#039;s EAR/MIC socket wiring&amp;quot;.&lt;br /&gt;
[[File:Ear-mic-socket-1.png|thumb|Next&#039;s EAR/MIC socket wiring]]&lt;br /&gt;
The plug inserted into the Next is referred to in many descriptions as a &amp;quot;3.5mm stereo plug&amp;quot;. Even if the Next always uses a single channel to load, the plug on its side has to be the same as those used for stereo (two channel) equipment, because, as stated, it then receives the signal over the &amp;quot;ring&amp;quot;, which doesn&#039;t exist on &amp;quot;mono&amp;quot; plugs. That&#039;s also why the cables delivered with the Spectrum 128 and earlier models won&#039;t work: their both sides lack the ring on their plugs.&lt;br /&gt;
&lt;br /&gt;
So the cable on the Next&#039;s side needs a 3.5mm plug commonly described as a &amp;quot;stereo&amp;quot; plug. The other side will depend on the output socket on your cassette player.&lt;br /&gt;
&lt;br /&gt;
[[File:Spectrum-plus-3-tape-lead.jpg|thumb|ZX Spectrum Next/+3 Tape Lead]]&lt;br /&gt;
&lt;br /&gt;
To load from a player with a &#039;&#039;mono earphone&#039;&#039; socket: you can try to use, if you have it, a cable made for Spectrum +3 or later (see the picture: &amp;quot;ZX Spectrum Next/+3 Tape Lead&amp;quot;), or, you can try to obtain an [https://store.activeconsult.co.uk/shop?olsPage=products%2Fear-mic-cable&amp;amp;page=2 &amp;quot;Ear/Mic Cable&amp;quot;], or, as a possible substitution, a TRS stereo cable and a fitting stereo to mono adapter.&lt;br /&gt;
&lt;br /&gt;
All other scenarios need different solutions. Often, if the player has a 3.5mm &#039;&#039;stereo&#039;&#039; socket and the signal on its right channel sounds good, then a plain TRS cable with 3.5mm plugs on both sides could work (in TRS, the T stands for the &amp;quot;tip&amp;quot; and the R for the &amp;quot;ring&amp;quot; of the plug). Otherwise, including in the case where you want to connect a mono socket from the player and you can&#039;t obtain or use the linked &amp;quot;Ear/Mic Cable&amp;quot;, the rule is still: the Next needs a clear and strong signal on its &amp;quot;ring&amp;quot; connection. The standard for analog stereo and AV cables or adapters which split the &amp;quot;stereo&amp;quot; side to separate channels on another side is to call the separated audio channels the left and the right channel and to assign white and red color to them, respectively. On those, the &#039;&#039;Red&#039;&#039; one is the one connected to the &#039;&#039;Ring&#039;&#039; needed by ZX Spectrum Next when loading. (Note 1: Memory aid: R-R-R, red-ring-right) (Note 2: Typically, the splitters to mono signals will have bigger sockets or plugs, called RCA: unless sockets on the player match, one splitter won&#039;t be the enough to construct the whole solution, but two can be combined, the second used to lead two, still separate, signals to a single multi-channel plug. A splitter allows to try which of the two channels from a stereo player has a better signal). (Note 3: when orienting the common splitters, the color mark from the historic +3 cable picture should be ignored: even if that cable is also a splitter, differently from the &amp;quot;stereo&amp;quot; convention, on it, the black side is the &amp;quot;right&amp;quot; one).&lt;br /&gt;
&lt;br /&gt;
NextZXOS provides a Tape Tester in the main menu of NextZXOS – Select More and Tape Tester. It can help once you already have a signal but need to find the best volume or, in some cases, adjust the azimuth. Once you are ready to load a real tape choose the Tape Loader and press PLAY on your player.&lt;br /&gt;
&lt;br /&gt;
== How can I load TZX files? ==&lt;br /&gt;
TZX files can be loaded if you have a pi0 or an external TZX player. If you have a pi0 please see&lt;br /&gt;
below for more information. Before asking for help please have this information ready&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My LED does not go out when I unplug the power! ==&lt;br /&gt;
&lt;br /&gt;
[[File:Next HDMI PSU.jpg|thumb|Remove ALL cables]]&lt;br /&gt;
Some TVs will back-power the Next through the HDMI cable, so it’s important to &#039;&#039;&#039;REMOVE ALL CABLES&#039;&#039;&#039; after a firmware&lt;br /&gt;
update and to turn off completely. If your TV/Display has multiple inputs try using one of the other ones as usually NOT ALL HDMI ports exhibit this behaviour.&lt;br /&gt;
&lt;br /&gt;
The back-power situation also happened in one case with I/O serial cable used at joystick port, general rule seems to be &amp;quot;if it has own power, and is connected to Next, it may back-power it&amp;quot; - in case of problems to power-cycle the Next properly, unplug all such cables/peripherals first and try again.&lt;br /&gt;
&lt;br /&gt;
== How do I update my Next? ==&lt;br /&gt;
Latest stable distro is [https://www.specnext.com/latestdistro/ here]. To update your Next, extract the contents of the distro to your SD card. Power down the Next,&lt;br /&gt;
Press and hold U and power on until you see the Updater screen and follow the instructions. As&lt;br /&gt;
above if you are using HDMI you need to remove all cables when instructed to power off your&lt;br /&gt;
Next.&lt;br /&gt;
&lt;br /&gt;
You can also read [https://www.specnext.com/forum/viewtopic.php?p=13644 this forum post] by Allen with greater detail about the update process.&lt;br /&gt;
&lt;br /&gt;
You may occasionally be directed to download the latest versions from gitlab [https://gitlab.com/thesmog358/tbblue here]. Sometimes this is desirable if you&#039;re being asked to test a specific fix or recent hardware features.&lt;br /&gt;
&lt;br /&gt;
== My SD card is not recognized by my Next during boot ==&lt;br /&gt;
The Next supports FAT32 (including long filenames), FAT16 and FAT12. It does &#039;&#039;&#039;not&#039;&#039;&#039; support exFAT, NTFS, AFS or ext formats. Some disk formatters, such as the Windows GUI formatter and the SD Association Formatter, force exFAT for SD cards 32GB or larger, and will &#039;&#039;&#039;not&#039;&#039;&#039; let you format with FAT32. On Windows, format with &amp;lt;code&amp;gt;format x: /FS:FAT32&amp;lt;/code&amp;gt; using the command line (where x: is the drive letter your card is mounted as).&lt;br /&gt;
&lt;br /&gt;
== How do I update the Pi in my Next (NextPi)? ==&lt;br /&gt;
NextPi that came with KS1 and requires a 1GB SD card can be downloaded [https://zx.xalior.com/NextPi/ here], and you can use [https://www.balena.io/etcher/ Etcher]. For NextPi2 (recommended) you will require a 16GB SD card and can download from [https://zx.xalior.com/NextPi2 here.]&lt;br /&gt;
&lt;br /&gt;
== I have a pi0 but cannot get TZXs to load ==&lt;br /&gt;
You will require a new updated &#039;&#039;&#039;dot/pisend&#039;&#039;&#039; and &#039;&#039;&#039;nextzxos/tzxload.bas&#039;&#039;&#039; from the&lt;br /&gt;
[https://gitlab.com/thesmog358/tbblue git repository]. These need to be placed in the correct folders on your SD&lt;br /&gt;
card. These files have updated after the distro was released.&amp;lt;br&amp;gt;&lt;br /&gt;
You can check if the pi0 is correctly responding by going into Command Line and running “.term”&lt;br /&gt;
You should see Terminex, press SYM+SHIFT+B to switch to 115,200 baud and press Enter. If you&lt;br /&gt;
see the words “SUP&amp;amp;gt;” then your pi0 is ready. You can quit Terminex by pressing SYM+SHIFT+Q&lt;br /&gt;
&lt;br /&gt;
To load a TZX, place some TZX files on your SD card and you should be able to select the files&lt;br /&gt;
from the Browser and the Next should do the rest. If you come across a game that doesn’t work&lt;br /&gt;
please let us know.&lt;br /&gt;
&lt;br /&gt;
I have problems loading TZXs:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Are you on the latest core / NextZXOS?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you updated to the latest git distro? [https://gitlab.com/thesmog358/tbblue/-/archive/master/tbblue-master.zip git repository]&amp;lt;br&amp;gt;&lt;br /&gt;
What video mode are you using? (VGA0/HDMI etc)&amp;lt;br&amp;gt;&lt;br /&gt;
What game didn&#039;t work? (You need to supply the exact name)&amp;lt;br&amp;gt;&lt;br /&gt;
Where did the loading fail? Did the game load fine but crash etc?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you left something plugged into the EAR port?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I sort the contents of my SD card? ==&lt;br /&gt;
On NextZXOS 2.07 and above, the browser can sort files dynamically. Press O to toggle between ordering by date, size and none. Press + (SYM+K) to toggle between ascending and descending order.&lt;br /&gt;
&lt;br /&gt;
For esxDOS or older versions of NextZXOS, you will need to use a tool on a PC such as [http://www.anerty.net/software/file/DriveSort/?lang=en DriveSort] (Windows) or [https://fatsort.sourceforge.io/ FatSort] (cross OS compatible) to physically reorder the files in the SD card&#039;s directory database. &lt;br /&gt;
&lt;br /&gt;
== Where do I buy RTC / Mouse / Memory / Wifi / Pi0 / Inline Power Switch… ==&lt;br /&gt;
ActiveConsult sell most of these products and can be found [https://store.activeconsult.co.uk/shop?olsPage=products&amp;amp;amp;page=1 here].&lt;br /&gt;
SCART cables can be purchased [https://coolnovelties.co.uk/coolnovelties/sinclair-zx-spectrum/312-zx-spectrum-next-analog-rgb-scart-cable-0705693507088.html here], also here: [https://www.retrocomputershack.com/] NOTE that you will need to boot your ZX Spectrum Next and press the R key to set up the SCART output.&lt;br /&gt;
&lt;br /&gt;
== What controller / joystick / gamepad can I use? ==&lt;br /&gt;
[[File:Atari-2600-Paddles.jpg|thumb|Atari 2600 Paddles]]The Next supports any “Atari” standard joystick or gamepad, along with Master System and MegaDrive pads. A good option is the [[M30 8BitDo wireless MegaDrive pad]].&lt;br /&gt;
You &#039;&#039;&#039;CANNOT&#039;&#039;&#039; use the &#039;&#039;&#039;Sinclair Branded SJS-1&#039;&#039;&#039; joysticks sold for +2/2A/3 ZX Spectrums as they require a special adapter. &lt;br /&gt;
If your joystick has both black and grey plugs, &#039;&#039;&#039;DO NOT&#039;&#039;&#039; plug in the grey plug, as that only works on +2/2A/3 ZX Spectrums and will damage your Next.&lt;br /&gt;
&lt;br /&gt;
The Next also supports [https://www.atariage.com/controller_page.php?ControllerID=3&amp;amp;SystemID=2600 Atari 2600 driving controllers]. These are digital quadrature rotary encoder devices, identifiable by the word &amp;quot;driving&amp;quot; and picture of a racing car. [https://www.atariage.com/controller_page.php?SystemID=2600&amp;amp;ControllerID=2 Atari 2600 paddles] (identifiable by the word &amp;quot;paddle&amp;quot; and picture of tennis rackets) contain analogue potentiometers, which are &#039;&#039;&#039;NOT&#039;&#039;&#039; physically compatible and could damage your Next.&lt;br /&gt;
&lt;br /&gt;
== How do I configure the joystick ports to be Kempston / Sinclair / Megadrive / Cursor? ==&lt;br /&gt;
&lt;br /&gt;
Your Next lets you configure how each joystick port behaves. By default the Left port will be configured to Kempston1 and Right will be Sinclair1. If you wish to change this configuration press the NMI button, Choose &amp;quot;Settings&amp;quot;, then &amp;quot;Joysticks&amp;quot;. You can now select JoyL for Left or JoyR for right and cycle through the options : &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston1&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston2&amp;lt;br&amp;gt;&lt;br /&gt;
Cursor&amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair1 &amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair2&amp;lt;br&amp;gt;&lt;br /&gt;
MD 1 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
MD 2 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You cannot set both ports to the same configuration. This will only set the choice until a cold reboot (complete power off). You can set these options to be permanent by powering off your Next, on the Sinclair ZX Next boot screen hold down SPACE, then press &#039;E&#039; - Change the options for Left Joy and Right Joy with SPACE. Once you have chosen your preferred joystick configuration press ENTER twice. Your Next will now reboot and once back into NextZXOS your settings will now be applied. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My ZX ProPad Button 2 Doesn&#039;t Work ==&lt;br /&gt;
The Next only supports two directly wired fire buttons. On the ZX ProPad these are buttons 1 and 3. Additional buttons are supported for Sega Megadrive pads and sticks only. Both 3 and 6 button Sega pads are compatible. Up, down, left, right, A, B, C, X, Y, Z, Start and Mode are all readable.&lt;br /&gt;
&lt;br /&gt;
The limitation of two directly wired fire buttons on non-Sega pads and sticks is baked into the Next hardware, unfortunately. So it cannot be enhanced in a future core update. All Next boards have a physical multiplex chip which hardwires six pins as input only (for direction and two fire buttons), one pin as output only (for Sega select), one pin as 5V, and one pin as ground.&lt;br /&gt;
== How do I change the CPU speed/ Scanlines etc? ==&lt;br /&gt;
The following keys combinations can be used to :&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 1 Hard reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 2 toggle scan doubler&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 3 toggle 50 / 60 Hz&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 4 Soft reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 7 Toggle scan lines (25/50/75%)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 8 Toggle CPU speed (3.5/7/14/28)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 9 NMI menu&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Where can I download games / roms ? ==&lt;br /&gt;
[https://spectrumcomputing.co.uk/ Spectrum Computing] and [https://www.worldofspectrum.org/ World of Spectrum] are good places to start. If your Next has wifi, [[https://github.com/em00k/next-zxdb-downloader zxdb-dl]] can also search and download directly on your Next. zxdb-dl is also on your SD card as part of the latest distro.&lt;br /&gt;
&lt;br /&gt;
== My internal keyboard is not responding – help!== &lt;br /&gt;
First turn off the Next completely and remove all cables and try again. Failing that a keyboard&lt;br /&gt;
cable may have become loose. You can watch a video on how to open your Next here:&amp;lt;br&amp;gt;&lt;br /&gt;
https://www.youtube.com/watch?v=iLDz4AjL3rA also see [[NexTest|NexTest diagnostic tool]]&lt;br /&gt;
&lt;br /&gt;
== My ps/2 keyboard is not responding – help!== &lt;br /&gt;
Edit your &#039;&#039;&#039;c:/machines/next/config.ini&#039;&#039;&#039; file so that &#039;&#039;&#039;ps2=0&#039;&#039;&#039;, or use a [https://store.activeconsult.co.uk/shop?olsPage=products%2Fps2-keyboard-mouse-splitter ps/2 splitter].&lt;br /&gt;
&lt;br /&gt;
== How do I install pi0 / Wifi / RTC / Memory? ==&lt;br /&gt;
As above a guide on how to open your Next can be viewed. Also read the appropriate Chapter in the manual.&lt;br /&gt;
[https://www.youtube.com/watch?v=iLDz4AjL3rA here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I connect to Wi-Fi? ==&lt;br /&gt;
The Next&#039;s ESP can only connect to 2.4Ghz Wi-Fi networks, make sure your password does not contain spaces. You can use the application wifi2.bas from /apps/wifi/setup - when you load wifi2.bas and type RUN to start&lt;br /&gt;
&lt;br /&gt;
You can confirm your IP address by going in to command line and typing .uart then the following:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+CIFSR&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should return your IP. If you are still having issues, confirm the network is 2.4Ghz, and you are not too far away from an access point.&lt;br /&gt;
&lt;br /&gt;
See if other internet apps work, try ZXDB-DL from /apps/wifi/zxdb-dl and launch zxdb-loader.bas. When the program launches, enter a game search term and press return. If you see results wifi is working.&lt;br /&gt;
&lt;br /&gt;
If you continue to have issues confirm the ESP baud rate, from the command line : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;.espbaud -dR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will &amp;gt;Reset and try to &amp;gt;detect the current speed. A message saying &amp;quot;Resetting ESP&amp;quot;, then a baud rate test will begin, once the program has finished, a success would look like this :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;ESP reports 115273&lt;br /&gt;
  Setting uart to 115273&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This usually confirms the correct speed has been negotiated. Now run .uart and run the command above and see if you get a response. &lt;br /&gt;
Another useful AT command to run is :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+GMR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will report your current ESP firmware. FW v1.2.0.0 is the version shipped with both KS models. The reliability of this differs in opinion and some people have updated to newer versions 1.6.0.0 and 1.7.6.0 reporting less oddities and overall more stable operation. Owner&#039;s must understand the risks involved when updating fw as it is possible to brick your ESP and for KS2 models, the ESP is soldered to the motherboard making replacing more complicated. FW updates can be done using the .espupdate dotcommand supplied on the official distro and heading over [https://github.com/Threetwosevensixseven/espupdate/wiki/Update-ESP-Firmware-From-ZX-Spectrum-Next here for more information]. &lt;br /&gt;
&lt;br /&gt;
Furthur information on the ESP and AT commands is [[ESP8266-01|linked here]]  &lt;br /&gt;
&lt;br /&gt;
[[File:Uart-fw.png|frameless]]&lt;br /&gt;
&lt;br /&gt;
== How can I get the expansion bus working with external hardware? ==&lt;br /&gt;
By default, the Next disables the expansion bus, as external hardware can conflict and is unlikely to run at CPU speeds faster than 3.5MHz. The bus can be enabled and and individual conflicting internal hardware disabled through Next registers 128 and 130..137 (manual pages 270..271). [https://www.specnext.com/forum/viewtopic.php?f=6&amp;amp;t=1482&amp;amp;p=9701&amp;amp;hilit=RAM+music+machine+expansion+bus#p9701 Here] is a detailed example of getting the RAM Music Machine working, and [https://www.youtube.com/watch?v=EU9NTQqQ1fg here] is a video demonstrating unsing Interface 1/microdrives.&lt;br /&gt;
&lt;br /&gt;
== Can I use Amstrad/Sinclair SJS-1 joysticks with the Next? ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NO!&#039;&#039;&#039; [https://rk.nvg.ntnu.no/sinclair/computers/peripherals/sjs1.htm SJS-1 joysticks] have fundamentally incompatible wiring compared with the standard Atari-wired joysticks the Next uses. Using them on the Next will short the 5V line to ground, potentially damaging your Next. Bin them, sell them, or keep them for your original +2, +2A or +3, where they will work fine but still be quite rubbish.&lt;br /&gt;
&lt;br /&gt;
== Why don&#039;t my VGA/joystick sockets have hex nuts to screw the cable in? ==&lt;br /&gt;
VGA sockets with hex nuts are typically bolted to a metal chassis. On the Next there is no chassis to screw onto, so you would just be screwing into the connector which is a VERY bad idea. The Next sockets are only fixed tight with small solder pads.&lt;br /&gt;
VGA cables are heavy and will put a lot of leverage on the VGA PCB pins, and likely to fracture the PCB or pins on the VGA socket. An unscrewed cable will still stay firmly in the socket during normal use, but will safely unplug if you yank the cable or leverage the plug.&lt;br /&gt;
&lt;br /&gt;
== I thought I had the latest version of the distro? ==&lt;br /&gt;
Go by the version numbers of the firmware, core and NextZXOS when deciding if you have the latest version. Ignore the post date on the [https://www.specnext.com/latestdistro/ latest distro] page. Wordpress post dates don&#039;t automatically update when existing posts are edited.&lt;br /&gt;
&lt;br /&gt;
== Why doesn&#039;t the manual have a table of contents / index ==&lt;br /&gt;
Short answer: It didn&#039;t fit in the box as the boxes were made way before the manual was completed. &lt;br /&gt;
Long answer: TL;DR :)&lt;br /&gt;
&lt;br /&gt;
== Where can I download a copy of the manual with a ToC and index? ==&lt;br /&gt;
Right here : https://www.specnext.com/zx-spectrum-next-user-manual-first-edition/   &lt;br /&gt;
&lt;br /&gt;
Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/manual-fixed.pdf fixed version] displays correctly in Safari, and can be read directly in browsers.&lt;br /&gt;
&lt;br /&gt;
== Further Spectrum Next Video Guides ==&lt;br /&gt;
https://www.youtube.com/playlist?list=PL2lCM2mJCG_AonDyHJfqjxFR5VoqBWqoh&lt;br /&gt;
&lt;br /&gt;
== Which Raspberry Pi Model Can I use for the Next Accelerator? ==&lt;br /&gt;
Pi Zero 1.3 has fairly major design changes from 1.2, but as long as you’re using official NextPi images and using it as advised you should see no issues using the original 1.2 Pi Zero (the one without camera connectors). The Pi Zero 1.3 will also work just fine, and doesn’t use the camera connector even if found.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero W (all of 1.x ones) are very similar to the 1.3. NextPi can use it, and will disable the wireless.&lt;br /&gt;
&lt;br /&gt;
It’s worth knowing that, &#039;&#039;in theory,&#039;&#039; someone could develop a plugin for NextPi that only works for the the non wireless version, but the only people to do that so far are the Next Team, to prove it was possible.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero 2 series is not supported, has never been supported, won’t work properly, and no support is offered or given into getting it to work properly. Neither are any other non-Zero Pi models, or clones such as Banana Pi.&lt;br /&gt;
&lt;br /&gt;
Other, non-official, &amp;quot;NextPi-compatible&amp;quot; distributions are starting to come available, from 3rd party users and - so far - are NOT fully nextpi compatible, at all.&lt;br /&gt;
&lt;br /&gt;
== Essential Lesser-Known Technical Docs ==&lt;br /&gt;
* The master [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/nextreg.txt nextreg] and [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/ports.txt port] lists are kept up to date, and fully describe the Next hardware for developers.  &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/blob/master/docs/extra-hw/pinouts/pinouts.txt pinouts] list has detailed information on connectors. &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/raw/master/docs/nextzxos-changelog.txt NextZXOS change log] details what was new and fixed in each version of NextZXOS/NextBASIC. &lt;br /&gt;
* The four [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos NextZXOS PDFs] have detailed information on the NextZXOS and esxDOS APIs, NextBASIC sysvars, and NextBASIC syntax.&lt;br /&gt;
* varmfskii&#039;s [https://raw.githubusercontent.com/varmfskii/zxnext_code/master/zx_next_notes/zxnext_notes.pdf ZX Spectrum Next Programming Notes] are an attempt to consolidate the Next programming interface into a single location.&lt;br /&gt;
* Myopian&#039;s [https://docs.google.com/spreadsheets/d/1dB8fKIfByGJTts409Ud8ly450a6SLPnLZc-nCBghBl8 API spreadsheet] summarises NextZXOS/IDEDOS entry points along with calling conditions.&lt;br /&gt;
* Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/dot-cmds.html dot command summary] collects together help and readme text for NextZXOS dot commands in one handy place.&lt;br /&gt;
* Tomaz&#039;s [https://github.com/tomaz/zx-next-dev-guide/releases/latest ZX Spectrum Next Assembly Developer Guide] is almost like &amp;quot;User manual&amp;quot; for Assembly developers.&lt;br /&gt;
* Luzie/Rat Mal&#039;s [https://docs.google.com/spreadsheets/d/17-ifpHcy932_AP7SAv9uBLxg-2ZptcdgTvQ8ILXQLM4/edit?usp=sharing_eil&amp;amp;ts=599361c7 Almost (In-) Complete List of esxDOS DOT-Commands] attempts to list dot commands for several systems, including the Next. Some of the non-Next-specific commands may work on the Next, and some may only work on other FPGA/divMMC systems.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13563</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13563"/>
		<updated>2025-04-14T23:53:05Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* How do I connect to Wi-Fi? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== I am using HDMI and I get no picture ==&lt;br /&gt;
When the Next boots hold down D for DIGITAL (HDMI) – Mode 7 50hz / 60hz can be selected. N selects the next frequency, ENTER selects it and saves. ONLY PRESS ENTER if you actually see a screen like the one below. N is NOT necessary as the testscreen will automatically go to the next mode albeit slower.&lt;br /&gt;
[[File:Figure02-TestScreenMode7.png|thumb|ZX Spectrum Next Test Screen]]&lt;br /&gt;
&lt;br /&gt;
You will also get an audible intermittent tone so you know your audio is working. It&#039;s possible your display can lock onto both modes but only one being able to lock onto the audio. Choose the one with the tone before pressing ENTER. Extract the files and copy over the BIN / SYS/ TMP folders to the root of your SD.&lt;br /&gt;
&lt;br /&gt;
== How to use esxDOS with 48K mode ==&lt;br /&gt;
[[File:2023-12-17 21 01 56-Window.png|thumb|esxDOS files]]&lt;br /&gt;
Your ZX Next can simulate the divMMC hardware for other machines. You can use esxDOS with 128/48K machines. You can download the latest esxDOS zip file here https://esxdos.org/index.html Download the zip and copy over the following folders BIN/SYS/TMP.&lt;br /&gt;
&lt;br /&gt;
You will need to place the ESXMMC.BIN in to /machines/next/roms&lt;br /&gt;
&lt;br /&gt;
Boot up your Next and press SPACE to open the configuration menu. Use the arrow keys to select 48K Mode, SPACE again and ensure DIVmmc ROM = YES. Exit and save this configuration. When your Next boots it should show the esxDOS logo just before the (c)1982 Sinclair Research Ltd message.&lt;br /&gt;
&lt;br /&gt;
[[ESXDOS|Further information can be found here]]&lt;br /&gt;
&lt;br /&gt;
[[File:Pre boot machine select menu.png|thumb]]&lt;br /&gt;
[[File:2023-12-17 21 21 11-OBS 30.0.0 - Profile Untitled - Scenes Untitled.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== I am using VGA and I get no picture ==&lt;br /&gt;
When the Next boots hold down V for VGA – Mode 0-6 50hz / 60hz can be selected. VGA0 is the&lt;br /&gt;
preferred mode as this has accurate timings. 1 – 6 are also accurate timings but increase slightly&lt;br /&gt;
in speed. N works as above but there are 12 possible configurations you can choose from. You&#039;ll start at VGA0@50Hz, next one will be the same at 60Hz and so forth. ENTER again selects and saves the changes. Audio is also being produced during the VGA Test Screen phase, however you will need powered speakers (or earphones) plugged in the audio out connector at the back of your Next.&lt;br /&gt;
&lt;br /&gt;
== I&#039;m using an HDMI display and a game&#039;s graphics appear garbled ==&lt;br /&gt;
Some games (specifically ones with multicolour or border effects - eg. Nirvana/Bifrost engine games, certain demos particularly ex-Soviet demoscene ones) require precise timings as with a regular Spectrum. Due to the nature of HDMI displays and the lack of internal buffering on the Spectrum Next display hardware currently these will not work properly and require a VGA or RGB display. &lt;br /&gt;
This is expected to be fixed in a future edition of the core/distribution but until then, there are a few alternative solutions:&lt;br /&gt;
a. An extra Spectrum core that implements precise HDMI timings by removing some of the Next&#039;s extra features. &lt;br /&gt;
b. Use of OSSC hardware which takes the Next&#039;s RGB/VGA display and converts it to HDMI independently&lt;br /&gt;
c. Use of the ZXHD or TkPie hardware expansions (only for standard Spectrum modes at 3.5MHz clock) &lt;br /&gt;
Next specific programs do not have this issue as they&#039;re made taking the current HDMI timing differences into account and will continue to work in the future when the most appropriate HDMI solution is implemented.&lt;br /&gt;
&lt;br /&gt;
== I am updating to the latest distro from GitLab or the N-Go website and my ps/2 keyboard doesn&#039;t work ==&lt;br /&gt;
To use a ps/2 keyboard you need to first choose whether you have a mouse or keyboard plugged into your ps/2 port. Unfortunately you can&#039;t get to the screen where you can make this choice &#039;&#039;until&#039;&#039; you have chosen your video mode on the testcard screen... which &#039;&#039;needs&#039;&#039; the keyboard to be already working!  &lt;br /&gt;
&lt;br /&gt;
Download this minimal config.ini file [https://dl.dropbox.com/s/5na7sd21328jnz5/CONFIG.INI] and copy it to the &#039;&#039;&#039;/Machines/Next&#039;&#039;&#039; folder on your SD card, then try again.&lt;br /&gt;
&lt;br /&gt;
When updating your distro from the official [[https://www.specnext.com/latestdistro/ Latest Distro]] page, or when using the internal keyboard on your official kickstarter 1 or 2 Next, this problem will not occur.&lt;br /&gt;
&lt;br /&gt;
== My monitor shows wrong image with Soviet timings(Pentagon)  ==&lt;br /&gt;
Pentagon has a non-standard screen refresh rate of 48.828Hz, some monitors do not support it. In some cases, can help manual picture settings in menu of your monitor. &lt;br /&gt;
Another solution to the issue is to buy a monitor that is compatible with Pentagon timings. User-generated list of compatible monitors located here: http://www.nedopc.com/zxevo/zxevo_supported_monitors.pdf&lt;br /&gt;
As a rule, monitors from this list are available on the secondary market at a low cost. Before purchasing desirable testing monitor with Pentagon mode.&lt;br /&gt;
&lt;br /&gt;
== HELP! My &amp;lt;insert game name here&amp;gt; doesn&#039;t work while it works on my &amp;lt;insert older Spectrum model here&amp;gt; ==&lt;br /&gt;
This is most likely due to a specific incompatibility of said program with the Next&#039;s extra hardware. The NextZXOS loader module, provides a lot of options for loading software catering to each model&#039;s idiosyncracies but also gives you the option to disable almost all Next extra hardware in order to make it work. If, after trying everything, the software doesn&#039;t work, you need to inform the team using the official gitlab repo &amp;quot;Issues&amp;quot; (registration is required) and provide a link to a copy of your program. The team will look at the specific issue and respond/fix the issue as soon as possible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What classic files can I load on my Next? ==&lt;br /&gt;
The Next supports NEXs, TAPs (preferred for classic software), SNAs, DSKs, Z80s, SNXs which can be loaded from the browser&lt;br /&gt;
menu by selecting them with the cursor keys and ENTER (or a joystick and Fire) -OR- by using the SPECTRUM command. (See Chapter 20 in the manual for details).&lt;br /&gt;
Place the files on your SD card and pick from the Browser.&lt;br /&gt;
&lt;br /&gt;
== How to load from a software cassette tape ==&lt;br /&gt;
For a successful load a clear signal from the player has to arrive on the &amp;quot;ring&amp;quot; part of the plug which you insert in the EAR/MIC socket of your Next, as in the picture &amp;quot;Next&#039;s EAR/MIC socket wiring&amp;quot;.&lt;br /&gt;
[[File:Ear-mic-socket-1.png|thumb|Next&#039;s EAR/MIC socket wiring]]&lt;br /&gt;
The plug inserted into the Next is referred to in many descriptions as a &amp;quot;3.5mm stereo plug&amp;quot;. Even if the Next always uses a single channel to load, the plug on its side has to be the same as those used for stereo (two channel) equipment, because, as stated, it then receives the signal over the &amp;quot;ring&amp;quot;, which doesn&#039;t exist on &amp;quot;mono&amp;quot; plugs. That&#039;s also why the cables delivered with the Spectrum 128 and earlier models won&#039;t work: their both sides lack the ring on their plugs.&lt;br /&gt;
&lt;br /&gt;
So the cable on the Next&#039;s side needs a 3.5mm plug commonly described as a &amp;quot;stereo&amp;quot; plug. The other side will depend on the output socket on your cassette player.&lt;br /&gt;
&lt;br /&gt;
[[File:Spectrum-plus-3-tape-lead.jpg|thumb|ZX Spectrum Next/+3 Tape Lead]]&lt;br /&gt;
&lt;br /&gt;
To load from a player with a &#039;&#039;mono earphone&#039;&#039; socket: you can try to use, if you have it, a cable made for Spectrum +3 or later (see the picture: &amp;quot;ZX Spectrum Next/+3 Tape Lead&amp;quot;), or, you can try to obtain an [https://store.activeconsult.co.uk/shop?olsPage=products%2Fear-mic-cable&amp;amp;page=2 &amp;quot;Ear/Mic Cable&amp;quot;], or, as a possible substitution, a TRS stereo cable and a fitting stereo to mono adapter.&lt;br /&gt;
&lt;br /&gt;
All other scenarios need different solutions. Often, if the player has a 3.5mm &#039;&#039;stereo&#039;&#039; socket and the signal on its right channel sounds good, then a plain TRS cable with 3.5mm plugs on both sides could work (in TRS, the T stands for the &amp;quot;tip&amp;quot; and the R for the &amp;quot;ring&amp;quot; of the plug). Otherwise, including in the case where you want to connect a mono socket from the player and you can&#039;t obtain or use the linked &amp;quot;Ear/Mic Cable&amp;quot;, the rule is still: the Next needs a clear and strong signal on its &amp;quot;ring&amp;quot; connection. The standard for analog stereo and AV cables or adapters which split the &amp;quot;stereo&amp;quot; side to separate channels on another side is to call the separated audio channels the left and the right channel and to assign white and red color to them, respectively. On those, the &#039;&#039;Red&#039;&#039; one is the one connected to the &#039;&#039;Ring&#039;&#039; needed by ZX Spectrum Next when loading. (Note 1: Memory aid: R-R-R, red-ring-right) (Note 2: Typically, the splitters to mono signals will have bigger sockets or plugs, called RCA: unless sockets on the player match, one splitter won&#039;t be the enough to construct the whole solution, but two can be combined, the second used to lead two, still separate, signals to a single multi-channel plug. A splitter allows to try which of the two channels from a stereo player has a better signal). (Note 3: when orienting the common splitters, the color mark from the historic +3 cable picture should be ignored: even if that cable is also a splitter, differently from the &amp;quot;stereo&amp;quot; convention, on it, the black side is the &amp;quot;right&amp;quot; one).&lt;br /&gt;
&lt;br /&gt;
NextZXOS provides a Tape Tester in the main menu of NextZXOS – Select More and Tape Tester. It can help once you already have a signal but need to find the best volume or, in some cases, adjust the azimuth. Once you are ready to load a real tape choose the Tape Loader and press PLAY on your player.&lt;br /&gt;
&lt;br /&gt;
== How can I load TZX files? ==&lt;br /&gt;
TZX files can be loaded if you have a pi0 or an external TZX player. If you have a pi0 please see&lt;br /&gt;
below for more information. Before asking for help please have this information ready&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My LED does not go out when I unplug the power! ==&lt;br /&gt;
&lt;br /&gt;
[[File:Next HDMI PSU.jpg|thumb|Remove ALL cables]]&lt;br /&gt;
Some TVs will back-power the Next through the HDMI cable, so it’s important to &#039;&#039;&#039;REMOVE ALL CABLES&#039;&#039;&#039; after a firmware&lt;br /&gt;
update and to turn off completely. If your TV/Display has multiple inputs try using one of the other ones as usually NOT ALL HDMI ports exhibit this behaviour.&lt;br /&gt;
&lt;br /&gt;
The back-power situation also happened in one case with I/O serial cable used at joystick port, general rule seems to be &amp;quot;if it has own power, and is connected to Next, it may back-power it&amp;quot; - in case of problems to power-cycle the Next properly, unplug all such cables/peripherals first and try again.&lt;br /&gt;
&lt;br /&gt;
== How do I update my Next? ==&lt;br /&gt;
Latest stable distro is [https://www.specnext.com/latestdistro/ here]. To update your Next, extract the contents of the distro to your SD card. Power down the Next,&lt;br /&gt;
Press and hold U and power on until you see the Updater screen and follow the instructions. As&lt;br /&gt;
above if you are using HDMI you need to remove all cables when instructed to power off your&lt;br /&gt;
Next.&lt;br /&gt;
&lt;br /&gt;
You can also read [https://www.specnext.com/forum/viewtopic.php?p=13644 this forum post] by Allen with greater detail about the update process.&lt;br /&gt;
&lt;br /&gt;
You may occasionally be directed to download the latest versions from gitlab [https://gitlab.com/thesmog358/tbblue here]. Sometimes this is desirable if you&#039;re being asked to test a specific fix or recent hardware features.&lt;br /&gt;
&lt;br /&gt;
== My SD card is not recognized by my Next during boot ==&lt;br /&gt;
The Next supports FAT32 (including long filenames), FAT16 and FAT12. It does &#039;&#039;&#039;not&#039;&#039;&#039; support exFAT, NTFS, AFS or ext formats. Some disk formatters, such as the Windows GUI formatter and the SD Association Formatter, force exFAT for SD cards 32GB or larger, and will &#039;&#039;&#039;not&#039;&#039;&#039; let you format with FAT32. On Windows, format with &amp;lt;code&amp;gt;format x: /FS:FAT32&amp;lt;/code&amp;gt; using the command line (where x: is the drive letter your card is mounted as).&lt;br /&gt;
&lt;br /&gt;
== How do I update the Pi in my Next (NextPi)? ==&lt;br /&gt;
NextPi that came with KS1 and requires a 1GB SD card can be downloaded [https://zx.xalior.com/NextPi/ here], and you can use [https://www.balena.io/etcher/ Etcher]. For NextPi2 (recommended) you will require a 16GB SD card and can download from [https://zx.xalior.com/NextPi2 here.]&lt;br /&gt;
&lt;br /&gt;
== I have a pi0 but cannot get TZXs to load ==&lt;br /&gt;
You will require a new updated &#039;&#039;&#039;dot/pisend&#039;&#039;&#039; and &#039;&#039;&#039;nextzxos/tzxload.bas&#039;&#039;&#039; from the&lt;br /&gt;
[https://gitlab.com/thesmog358/tbblue git repository]. These need to be placed in the correct folders on your SD&lt;br /&gt;
card. These files have updated after the distro was released.&amp;lt;br&amp;gt;&lt;br /&gt;
You can check if the pi0 is correctly responding by going into Command Line and running “.term”&lt;br /&gt;
You should see Terminex, press SYM+SHIFT+B to switch to 115,200 baud and press Enter. If you&lt;br /&gt;
see the words “SUP&amp;amp;gt;” then your pi0 is ready. You can quit Terminex by pressing SYM+SHIFT+Q&lt;br /&gt;
&lt;br /&gt;
To load a TZX, place some TZX files on your SD card and you should be able to select the files&lt;br /&gt;
from the Browser and the Next should do the rest. If you come across a game that doesn’t work&lt;br /&gt;
please let us know.&lt;br /&gt;
&lt;br /&gt;
I have problems loading TZXs:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Are you on the latest core / NextZXOS?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you updated to the latest git distro? [https://gitlab.com/thesmog358/tbblue/-/archive/master/tbblue-master.zip git repository]&amp;lt;br&amp;gt;&lt;br /&gt;
What video mode are you using? (VGA0/HDMI etc)&amp;lt;br&amp;gt;&lt;br /&gt;
What game didn&#039;t work? (You need to supply the exact name)&amp;lt;br&amp;gt;&lt;br /&gt;
Where did the loading fail? Did the game load fine but crash etc?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you left something plugged into the EAR port?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I sort the contents of my SD card? ==&lt;br /&gt;
On NextZXOS 2.07 and above, the browser can sort files dynamically. Press O to toggle between ordering by date, size and none. Press + (SYM+K) to toggle between ascending and descending order.&lt;br /&gt;
&lt;br /&gt;
For esxDOS or older versions of NextZXOS, you will need to use a tool on a PC such as [http://www.anerty.net/software/file/DriveSort/?lang=en DriveSort] (Windows) or [https://fatsort.sourceforge.io/ FatSort] (cross OS compatible) to physically reorder the files in the SD card&#039;s directory database. &lt;br /&gt;
&lt;br /&gt;
== Where do I buy RTC / Mouse / Memory / Wifi / Pi0 / Inline Power Switch… ==&lt;br /&gt;
ActiveConsult sell most of these products and can be found [https://store.activeconsult.co.uk/shop?olsPage=products&amp;amp;amp;page=1 here].&lt;br /&gt;
SCART cables can be purchased [https://coolnovelties.co.uk/coolnovelties/sinclair-zx-spectrum/312-zx-spectrum-next-analog-rgb-scart-cable-0705693507088.html here], also here: [https://www.retrocomputershack.com/] NOTE that you will need to boot your ZX Spectrum Next and press the R key to set up the SCART output.&lt;br /&gt;
&lt;br /&gt;
== What controller / joystick / gamepad can I use? ==&lt;br /&gt;
[[File:Atari-2600-Paddles.jpg|thumb|Atari 2600 Paddles]]The Next supports any “Atari” standard joystick or gamepad, along with Master System and MegaDrive pads. A good option is the [[M30 8BitDo wireless MegaDrive pad]].&lt;br /&gt;
You &#039;&#039;&#039;CANNOT&#039;&#039;&#039; use the &#039;&#039;&#039;Sinclair Branded SJS-1&#039;&#039;&#039; joysticks sold for +2/2A/3 ZX Spectrums as they require a special adapter. &lt;br /&gt;
If your joystick has both black and grey plugs, &#039;&#039;&#039;DO NOT&#039;&#039;&#039; plug in the grey plug, as that only works on +2/2A/3 ZX Spectrums and will damage your Next.&lt;br /&gt;
&lt;br /&gt;
The Next also supports [https://www.atariage.com/controller_page.php?ControllerID=3&amp;amp;SystemID=2600 Atari 2600 driving controllers]. These are digital quadrature rotary encoder devices, identifiable by the word &amp;quot;driving&amp;quot; and picture of a racing car. [https://www.atariage.com/controller_page.php?SystemID=2600&amp;amp;ControllerID=2 Atari 2600 paddles] (identifiable by the word &amp;quot;paddle&amp;quot; and picture of tennis rackets) contain analogue potentiometers, which are &#039;&#039;&#039;NOT&#039;&#039;&#039; physically compatible and could damage your Next.&lt;br /&gt;
&lt;br /&gt;
== How do I configure the joystick ports to be Kempston / Sinclair / Megadrive / Cursor? ==&lt;br /&gt;
&lt;br /&gt;
Your Next lets you configure how each joystick port behaves. By default the Left port will be configured to Kempston1 and Right will be Sinclair1. If you wish to change this configuration press the NMI button, Choose &amp;quot;Settings&amp;quot;, then &amp;quot;Joysticks&amp;quot;. You can now select JoyL for Left or JoyR for right and cycle through the options : &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston1&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston2&amp;lt;br&amp;gt;&lt;br /&gt;
Cursor&amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair1 &amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair2&amp;lt;br&amp;gt;&lt;br /&gt;
MD 1 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
MD 2 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You cannot set both ports to the same configuration. This will only set the choice until a cold reboot (complete power off). You can set these options to be permanent by powering off your Next, on the Sinclair ZX Next boot screen hold down SPACE, then press &#039;E&#039; - Change the options for Left Joy and Right Joy with SPACE. Once you have chosen your preferred joystick configuration press ENTER twice. Your Next will now reboot and once back into NextZXOS your settings will now be applied. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My ZX ProPad Button 2 Doesn&#039;t Work ==&lt;br /&gt;
The Next only supports two directly wired fire buttons. On the ZX ProPad these are buttons 1 and 3. Additional buttons are supported for Sega Megadrive pads and sticks only. Both 3 and 6 button Sega pads are compatible. Up, down, left, right, A, B, C, X, Y, Z, Start and Mode are all readable.&lt;br /&gt;
&lt;br /&gt;
The limitation of two directly wired fire buttons on non-Sega pads and sticks is baked into the Next hardware, unfortunately. So it cannot be enhanced in a future core update. All Next boards have a physical multiplex chip which hardwires six pins as input only (for direction and two fire buttons), one pin as output only (for Sega select), one pin as 5V, and one pin as ground.&lt;br /&gt;
== How do I change the CPU speed/ Scanlines etc? ==&lt;br /&gt;
The following keys combinations can be used to :&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 1 Hard reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 2 toggle scan doubler&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 3 toggle 50 / 60 Hz&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 4 Soft reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 7 Toggle scan lines (25/50/75%)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 8 Toggle CPU speed (3.5/7/14/28)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 9 NMI menu&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Where can I download games / roms ? ==&lt;br /&gt;
[https://spectrumcomputing.co.uk/ Spectrum Computing] and [https://www.worldofspectrum.org/ World of Spectrum] are good places to start. If your Next has wifi, [[https://github.com/em00k/next-zxdb-downloader zxdb-dl]] can also search and download directly on your Next. zxdb-dl is also on your SD card as part of the latest distro.&lt;br /&gt;
&lt;br /&gt;
== My internal keyboard is not responding – help!== &lt;br /&gt;
First turn off the Next completely and remove all cables and try again. Failing that a keyboard&lt;br /&gt;
cable may have become loose. You can watch a video on how to open your Next here:&amp;lt;br&amp;gt;&lt;br /&gt;
https://www.youtube.com/watch?v=iLDz4AjL3rA also see [[NexTest|NexTest diagnostic tool]]&lt;br /&gt;
&lt;br /&gt;
== My ps/2 keyboard is not responding – help!== &lt;br /&gt;
Edit your &#039;&#039;&#039;c:/machines/next/config.ini&#039;&#039;&#039; file so that &#039;&#039;&#039;ps2=0&#039;&#039;&#039;, or use a [https://store.activeconsult.co.uk/shop?olsPage=products%2Fps2-keyboard-mouse-splitter ps/2 splitter].&lt;br /&gt;
&lt;br /&gt;
== How do I install pi0 / Wifi / RTC / Memory? ==&lt;br /&gt;
As above a guide on how to open your Next can be viewed. Also read the appropriate Chapter in the manual.&lt;br /&gt;
[https://www.youtube.com/watch?v=iLDz4AjL3rA here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I connect to Wi-Fi? ==&lt;br /&gt;
The Next&#039;s ESP can only connect to 2.4Ghz Wi-Fi networks, make sure your password does not contain spaces. You can use the application wifi2.bas from /apps/wifi/setup - when you load wifi2.bas and type RUN to start&lt;br /&gt;
&lt;br /&gt;
You can confirm your IP address by going in to command line and typing .uart then the following:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+CIFSR&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should return your IP. If you are still having issues, confirm the network is 2.4Ghz, and you are not too far away from an access point.&lt;br /&gt;
&lt;br /&gt;
See if other internet apps work, try ZXDB-DL from /apps/wifi/zxdb-dl and launch zxdb-loader.bas. When the program launches, enter a game search term and press return. If you see results wifi is working.&lt;br /&gt;
&lt;br /&gt;
If you continue to have issues confirm the ESP baud rate, from the command line : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;.espbaud -dR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will &amp;gt;Reset and try to &amp;gt;detect the current speed. A message saying &amp;quot;Resetting ESP&amp;quot;, then a baud rate test will begin, once the program has finished, a success would look like this :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;ESP reports 115273&lt;br /&gt;
  Setting uart to 115273&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This usually confirms the correct speed has been negotiated. Now run .uart and run the command above and see if you get a response. &lt;br /&gt;
Another useful AT command to run is :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+GMR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Furthur information on the ESP and AT commands is [[ESP8266-01|linked here]]  &lt;br /&gt;
&lt;br /&gt;
This will report your current ESP firmware. FW v1.2.0.0 is the version shipped with both KS models. The reliability of this differs in opinion and some people have updated to newer versions 1.6.0.0 and 1.7.6.0 reporting less oddities and overall more stable operation. Owner&#039;s must understand the risks involved when updating fw as it is possible to brick your ESP and for KS2 models, the ESP is soldered to the motherboard making replacing more complicated. FW updates can be done using the .espupdate dotcommand supplied on the official distro and heading over [https://github.com/Threetwosevensixseven/espupdate/wiki/Update-ESP-Firmware-From-ZX-Spectrum-Next here for more information]. &lt;br /&gt;
&lt;br /&gt;
[[File:Uart-fw.png|frameless]]&lt;br /&gt;
&lt;br /&gt;
== How can I get the expansion bus working with external hardware? ==&lt;br /&gt;
By default, the Next disables the expansion bus, as external hardware can conflict and is unlikely to run at CPU speeds faster than 3.5MHz. The bus can be enabled and and individual conflicting internal hardware disabled through Next registers 128 and 130..137 (manual pages 270..271). [https://www.specnext.com/forum/viewtopic.php?f=6&amp;amp;t=1482&amp;amp;p=9701&amp;amp;hilit=RAM+music+machine+expansion+bus#p9701 Here] is a detailed example of getting the RAM Music Machine working, and [https://www.youtube.com/watch?v=EU9NTQqQ1fg here] is a video demonstrating unsing Interface 1/microdrives.&lt;br /&gt;
&lt;br /&gt;
== Can I use Amstrad/Sinclair SJS-1 joysticks with the Next? ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NO!&#039;&#039;&#039; [https://rk.nvg.ntnu.no/sinclair/computers/peripherals/sjs1.htm SJS-1 joysticks] have fundamentally incompatible wiring compared with the standard Atari-wired joysticks the Next uses. Using them on the Next will short the 5V line to ground, potentially damaging your Next. Bin them, sell them, or keep them for your original +2, +2A or +3, where they will work fine but still be quite rubbish.&lt;br /&gt;
&lt;br /&gt;
== Why don&#039;t my VGA/joystick sockets have hex nuts to screw the cable in? ==&lt;br /&gt;
VGA sockets with hex nuts are typically bolted to a metal chassis. On the Next there is no chassis to screw onto, so you would just be screwing into the connector which is a VERY bad idea. The Next sockets are only fixed tight with small solder pads.&lt;br /&gt;
VGA cables are heavy and will put a lot of leverage on the VGA PCB pins, and likely to fracture the PCB or pins on the VGA socket. An unscrewed cable will still stay firmly in the socket during normal use, but will safely unplug if you yank the cable or leverage the plug.&lt;br /&gt;
&lt;br /&gt;
== I thought I had the latest version of the distro? ==&lt;br /&gt;
Go by the version numbers of the firmware, core and NextZXOS when deciding if you have the latest version. Ignore the post date on the [https://www.specnext.com/latestdistro/ latest distro] page. Wordpress post dates don&#039;t automatically update when existing posts are edited.&lt;br /&gt;
&lt;br /&gt;
== Why doesn&#039;t the manual have a table of contents / index ==&lt;br /&gt;
Short answer: It didn&#039;t fit in the box as the boxes were made way before the manual was completed. &lt;br /&gt;
Long answer: TL;DR :)&lt;br /&gt;
&lt;br /&gt;
== Where can I download a copy of the manual with a ToC and index? ==&lt;br /&gt;
Right here : https://www.specnext.com/zx-spectrum-next-user-manual-first-edition/   &lt;br /&gt;
&lt;br /&gt;
Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/manual-fixed.pdf fixed version] displays correctly in Safari, and can be read directly in browsers.&lt;br /&gt;
&lt;br /&gt;
== Further Spectrum Next Video Guides ==&lt;br /&gt;
https://www.youtube.com/playlist?list=PL2lCM2mJCG_AonDyHJfqjxFR5VoqBWqoh&lt;br /&gt;
&lt;br /&gt;
== Which Raspberry Pi Model Can I use for the Next Accelerator? ==&lt;br /&gt;
Pi Zero 1.3 has fairly major design changes from 1.2, but as long as you’re using official NextPi images and using it as advised you should see no issues using the original 1.2 Pi Zero (the one without camera connectors). The Pi Zero 1.3 will also work just fine, and doesn’t use the camera connector even if found.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero W (all of 1.x ones) are very similar to the 1.3. NextPi can use it, and will disable the wireless.&lt;br /&gt;
&lt;br /&gt;
It’s worth knowing that, &#039;&#039;in theory,&#039;&#039; someone could develop a plugin for NextPi that only works for the the non wireless version, but the only people to do that so far are the Next Team, to prove it was possible.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero 2 series is not supported, has never been supported, won’t work properly, and no support is offered or given into getting it to work properly. Neither are any other non-Zero Pi models, or clones such as Banana Pi.&lt;br /&gt;
&lt;br /&gt;
Other, non-official, &amp;quot;NextPi-compatible&amp;quot; distributions are starting to come available, from 3rd party users and - so far - are NOT fully nextpi compatible, at all.&lt;br /&gt;
&lt;br /&gt;
== Essential Lesser-Known Technical Docs ==&lt;br /&gt;
* The master [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/nextreg.txt nextreg] and [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/ports.txt port] lists are kept up to date, and fully describe the Next hardware for developers.  &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/blob/master/docs/extra-hw/pinouts/pinouts.txt pinouts] list has detailed information on connectors. &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/raw/master/docs/nextzxos-changelog.txt NextZXOS change log] details what was new and fixed in each version of NextZXOS/NextBASIC. &lt;br /&gt;
* The four [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos NextZXOS PDFs] have detailed information on the NextZXOS and esxDOS APIs, NextBASIC sysvars, and NextBASIC syntax.&lt;br /&gt;
* varmfskii&#039;s [https://raw.githubusercontent.com/varmfskii/zxnext_code/master/zx_next_notes/zxnext_notes.pdf ZX Spectrum Next Programming Notes] are an attempt to consolidate the Next programming interface into a single location.&lt;br /&gt;
* Myopian&#039;s [https://docs.google.com/spreadsheets/d/1dB8fKIfByGJTts409Ud8ly450a6SLPnLZc-nCBghBl8 API spreadsheet] summarises NextZXOS/IDEDOS entry points along with calling conditions.&lt;br /&gt;
* Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/dot-cmds.html dot command summary] collects together help and readme text for NextZXOS dot commands in one handy place.&lt;br /&gt;
* Tomaz&#039;s [https://github.com/tomaz/zx-next-dev-guide/releases/latest ZX Spectrum Next Assembly Developer Guide] is almost like &amp;quot;User manual&amp;quot; for Assembly developers.&lt;br /&gt;
* Luzie/Rat Mal&#039;s [https://docs.google.com/spreadsheets/d/17-ifpHcy932_AP7SAv9uBLxg-2ZptcdgTvQ8ILXQLM4/edit?usp=sharing_eil&amp;amp;ts=599361c7 Almost (In-) Complete List of esxDOS DOT-Commands] attempts to list dot commands for several systems, including the Next. Some of the non-Next-specific commands may work on the Next, and some may only work on other FPGA/divMMC systems.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13562</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13562"/>
		<updated>2025-04-14T23:50:53Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* How do I connect to Wi-Fi? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== I am using HDMI and I get no picture ==&lt;br /&gt;
When the Next boots hold down D for DIGITAL (HDMI) – Mode 7 50hz / 60hz can be selected. N selects the next frequency, ENTER selects it and saves. ONLY PRESS ENTER if you actually see a screen like the one below. N is NOT necessary as the testscreen will automatically go to the next mode albeit slower.&lt;br /&gt;
[[File:Figure02-TestScreenMode7.png|thumb|ZX Spectrum Next Test Screen]]&lt;br /&gt;
&lt;br /&gt;
You will also get an audible intermittent tone so you know your audio is working. It&#039;s possible your display can lock onto both modes but only one being able to lock onto the audio. Choose the one with the tone before pressing ENTER. Extract the files and copy over the BIN / SYS/ TMP folders to the root of your SD.&lt;br /&gt;
&lt;br /&gt;
== How to use esxDOS with 48K mode ==&lt;br /&gt;
[[File:2023-12-17 21 01 56-Window.png|thumb|esxDOS files]]&lt;br /&gt;
Your ZX Next can simulate the divMMC hardware for other machines. You can use esxDOS with 128/48K machines. You can download the latest esxDOS zip file here https://esxdos.org/index.html Download the zip and copy over the following folders BIN/SYS/TMP.&lt;br /&gt;
&lt;br /&gt;
You will need to place the ESXMMC.BIN in to /machines/next/roms&lt;br /&gt;
&lt;br /&gt;
Boot up your Next and press SPACE to open the configuration menu. Use the arrow keys to select 48K Mode, SPACE again and ensure DIVmmc ROM = YES. Exit and save this configuration. When your Next boots it should show the esxDOS logo just before the (c)1982 Sinclair Research Ltd message.&lt;br /&gt;
&lt;br /&gt;
[[ESXDOS|Further information can be found here]]&lt;br /&gt;
&lt;br /&gt;
[[File:Pre boot machine select menu.png|thumb]]&lt;br /&gt;
[[File:2023-12-17 21 21 11-OBS 30.0.0 - Profile Untitled - Scenes Untitled.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== I am using VGA and I get no picture ==&lt;br /&gt;
When the Next boots hold down V for VGA – Mode 0-6 50hz / 60hz can be selected. VGA0 is the&lt;br /&gt;
preferred mode as this has accurate timings. 1 – 6 are also accurate timings but increase slightly&lt;br /&gt;
in speed. N works as above but there are 12 possible configurations you can choose from. You&#039;ll start at VGA0@50Hz, next one will be the same at 60Hz and so forth. ENTER again selects and saves the changes. Audio is also being produced during the VGA Test Screen phase, however you will need powered speakers (or earphones) plugged in the audio out connector at the back of your Next.&lt;br /&gt;
&lt;br /&gt;
== I&#039;m using an HDMI display and a game&#039;s graphics appear garbled ==&lt;br /&gt;
Some games (specifically ones with multicolour or border effects - eg. Nirvana/Bifrost engine games, certain demos particularly ex-Soviet demoscene ones) require precise timings as with a regular Spectrum. Due to the nature of HDMI displays and the lack of internal buffering on the Spectrum Next display hardware currently these will not work properly and require a VGA or RGB display. &lt;br /&gt;
This is expected to be fixed in a future edition of the core/distribution but until then, there are a few alternative solutions:&lt;br /&gt;
a. An extra Spectrum core that implements precise HDMI timings by removing some of the Next&#039;s extra features. &lt;br /&gt;
b. Use of OSSC hardware which takes the Next&#039;s RGB/VGA display and converts it to HDMI independently&lt;br /&gt;
c. Use of the ZXHD or TkPie hardware expansions (only for standard Spectrum modes at 3.5MHz clock) &lt;br /&gt;
Next specific programs do not have this issue as they&#039;re made taking the current HDMI timing differences into account and will continue to work in the future when the most appropriate HDMI solution is implemented.&lt;br /&gt;
&lt;br /&gt;
== I am updating to the latest distro from GitLab or the N-Go website and my ps/2 keyboard doesn&#039;t work ==&lt;br /&gt;
To use a ps/2 keyboard you need to first choose whether you have a mouse or keyboard plugged into your ps/2 port. Unfortunately you can&#039;t get to the screen where you can make this choice &#039;&#039;until&#039;&#039; you have chosen your video mode on the testcard screen... which &#039;&#039;needs&#039;&#039; the keyboard to be already working!  &lt;br /&gt;
&lt;br /&gt;
Download this minimal config.ini file [https://dl.dropbox.com/s/5na7sd21328jnz5/CONFIG.INI] and copy it to the &#039;&#039;&#039;/Machines/Next&#039;&#039;&#039; folder on your SD card, then try again.&lt;br /&gt;
&lt;br /&gt;
When updating your distro from the official [[https://www.specnext.com/latestdistro/ Latest Distro]] page, or when using the internal keyboard on your official kickstarter 1 or 2 Next, this problem will not occur.&lt;br /&gt;
&lt;br /&gt;
== My monitor shows wrong image with Soviet timings(Pentagon)  ==&lt;br /&gt;
Pentagon has a non-standard screen refresh rate of 48.828Hz, some monitors do not support it. In some cases, can help manual picture settings in menu of your monitor. &lt;br /&gt;
Another solution to the issue is to buy a monitor that is compatible with Pentagon timings. User-generated list of compatible monitors located here: http://www.nedopc.com/zxevo/zxevo_supported_monitors.pdf&lt;br /&gt;
As a rule, monitors from this list are available on the secondary market at a low cost. Before purchasing desirable testing monitor with Pentagon mode.&lt;br /&gt;
&lt;br /&gt;
== HELP! My &amp;lt;insert game name here&amp;gt; doesn&#039;t work while it works on my &amp;lt;insert older Spectrum model here&amp;gt; ==&lt;br /&gt;
This is most likely due to a specific incompatibility of said program with the Next&#039;s extra hardware. The NextZXOS loader module, provides a lot of options for loading software catering to each model&#039;s idiosyncracies but also gives you the option to disable almost all Next extra hardware in order to make it work. If, after trying everything, the software doesn&#039;t work, you need to inform the team using the official gitlab repo &amp;quot;Issues&amp;quot; (registration is required) and provide a link to a copy of your program. The team will look at the specific issue and respond/fix the issue as soon as possible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What classic files can I load on my Next? ==&lt;br /&gt;
The Next supports NEXs, TAPs (preferred for classic software), SNAs, DSKs, Z80s, SNXs which can be loaded from the browser&lt;br /&gt;
menu by selecting them with the cursor keys and ENTER (or a joystick and Fire) -OR- by using the SPECTRUM command. (See Chapter 20 in the manual for details).&lt;br /&gt;
Place the files on your SD card and pick from the Browser.&lt;br /&gt;
&lt;br /&gt;
== How to load from a software cassette tape ==&lt;br /&gt;
For a successful load a clear signal from the player has to arrive on the &amp;quot;ring&amp;quot; part of the plug which you insert in the EAR/MIC socket of your Next, as in the picture &amp;quot;Next&#039;s EAR/MIC socket wiring&amp;quot;.&lt;br /&gt;
[[File:Ear-mic-socket-1.png|thumb|Next&#039;s EAR/MIC socket wiring]]&lt;br /&gt;
The plug inserted into the Next is referred to in many descriptions as a &amp;quot;3.5mm stereo plug&amp;quot;. Even if the Next always uses a single channel to load, the plug on its side has to be the same as those used for stereo (two channel) equipment, because, as stated, it then receives the signal over the &amp;quot;ring&amp;quot;, which doesn&#039;t exist on &amp;quot;mono&amp;quot; plugs. That&#039;s also why the cables delivered with the Spectrum 128 and earlier models won&#039;t work: their both sides lack the ring on their plugs.&lt;br /&gt;
&lt;br /&gt;
So the cable on the Next&#039;s side needs a 3.5mm plug commonly described as a &amp;quot;stereo&amp;quot; plug. The other side will depend on the output socket on your cassette player.&lt;br /&gt;
&lt;br /&gt;
[[File:Spectrum-plus-3-tape-lead.jpg|thumb|ZX Spectrum Next/+3 Tape Lead]]&lt;br /&gt;
&lt;br /&gt;
To load from a player with a &#039;&#039;mono earphone&#039;&#039; socket: you can try to use, if you have it, a cable made for Spectrum +3 or later (see the picture: &amp;quot;ZX Spectrum Next/+3 Tape Lead&amp;quot;), or, you can try to obtain an [https://store.activeconsult.co.uk/shop?olsPage=products%2Fear-mic-cable&amp;amp;page=2 &amp;quot;Ear/Mic Cable&amp;quot;], or, as a possible substitution, a TRS stereo cable and a fitting stereo to mono adapter.&lt;br /&gt;
&lt;br /&gt;
All other scenarios need different solutions. Often, if the player has a 3.5mm &#039;&#039;stereo&#039;&#039; socket and the signal on its right channel sounds good, then a plain TRS cable with 3.5mm plugs on both sides could work (in TRS, the T stands for the &amp;quot;tip&amp;quot; and the R for the &amp;quot;ring&amp;quot; of the plug). Otherwise, including in the case where you want to connect a mono socket from the player and you can&#039;t obtain or use the linked &amp;quot;Ear/Mic Cable&amp;quot;, the rule is still: the Next needs a clear and strong signal on its &amp;quot;ring&amp;quot; connection. The standard for analog stereo and AV cables or adapters which split the &amp;quot;stereo&amp;quot; side to separate channels on another side is to call the separated audio channels the left and the right channel and to assign white and red color to them, respectively. On those, the &#039;&#039;Red&#039;&#039; one is the one connected to the &#039;&#039;Ring&#039;&#039; needed by ZX Spectrum Next when loading. (Note 1: Memory aid: R-R-R, red-ring-right) (Note 2: Typically, the splitters to mono signals will have bigger sockets or plugs, called RCA: unless sockets on the player match, one splitter won&#039;t be the enough to construct the whole solution, but two can be combined, the second used to lead two, still separate, signals to a single multi-channel plug. A splitter allows to try which of the two channels from a stereo player has a better signal). (Note 3: when orienting the common splitters, the color mark from the historic +3 cable picture should be ignored: even if that cable is also a splitter, differently from the &amp;quot;stereo&amp;quot; convention, on it, the black side is the &amp;quot;right&amp;quot; one).&lt;br /&gt;
&lt;br /&gt;
NextZXOS provides a Tape Tester in the main menu of NextZXOS – Select More and Tape Tester. It can help once you already have a signal but need to find the best volume or, in some cases, adjust the azimuth. Once you are ready to load a real tape choose the Tape Loader and press PLAY on your player.&lt;br /&gt;
&lt;br /&gt;
== How can I load TZX files? ==&lt;br /&gt;
TZX files can be loaded if you have a pi0 or an external TZX player. If you have a pi0 please see&lt;br /&gt;
below for more information. Before asking for help please have this information ready&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My LED does not go out when I unplug the power! ==&lt;br /&gt;
&lt;br /&gt;
[[File:Next HDMI PSU.jpg|thumb|Remove ALL cables]]&lt;br /&gt;
Some TVs will back-power the Next through the HDMI cable, so it’s important to &#039;&#039;&#039;REMOVE ALL CABLES&#039;&#039;&#039; after a firmware&lt;br /&gt;
update and to turn off completely. If your TV/Display has multiple inputs try using one of the other ones as usually NOT ALL HDMI ports exhibit this behaviour.&lt;br /&gt;
&lt;br /&gt;
The back-power situation also happened in one case with I/O serial cable used at joystick port, general rule seems to be &amp;quot;if it has own power, and is connected to Next, it may back-power it&amp;quot; - in case of problems to power-cycle the Next properly, unplug all such cables/peripherals first and try again.&lt;br /&gt;
&lt;br /&gt;
== How do I update my Next? ==&lt;br /&gt;
Latest stable distro is [https://www.specnext.com/latestdistro/ here]. To update your Next, extract the contents of the distro to your SD card. Power down the Next,&lt;br /&gt;
Press and hold U and power on until you see the Updater screen and follow the instructions. As&lt;br /&gt;
above if you are using HDMI you need to remove all cables when instructed to power off your&lt;br /&gt;
Next.&lt;br /&gt;
&lt;br /&gt;
You can also read [https://www.specnext.com/forum/viewtopic.php?p=13644 this forum post] by Allen with greater detail about the update process.&lt;br /&gt;
&lt;br /&gt;
You may occasionally be directed to download the latest versions from gitlab [https://gitlab.com/thesmog358/tbblue here]. Sometimes this is desirable if you&#039;re being asked to test a specific fix or recent hardware features.&lt;br /&gt;
&lt;br /&gt;
== My SD card is not recognized by my Next during boot ==&lt;br /&gt;
The Next supports FAT32 (including long filenames), FAT16 and FAT12. It does &#039;&#039;&#039;not&#039;&#039;&#039; support exFAT, NTFS, AFS or ext formats. Some disk formatters, such as the Windows GUI formatter and the SD Association Formatter, force exFAT for SD cards 32GB or larger, and will &#039;&#039;&#039;not&#039;&#039;&#039; let you format with FAT32. On Windows, format with &amp;lt;code&amp;gt;format x: /FS:FAT32&amp;lt;/code&amp;gt; using the command line (where x: is the drive letter your card is mounted as).&lt;br /&gt;
&lt;br /&gt;
== How do I update the Pi in my Next (NextPi)? ==&lt;br /&gt;
NextPi that came with KS1 and requires a 1GB SD card can be downloaded [https://zx.xalior.com/NextPi/ here], and you can use [https://www.balena.io/etcher/ Etcher]. For NextPi2 (recommended) you will require a 16GB SD card and can download from [https://zx.xalior.com/NextPi2 here.]&lt;br /&gt;
&lt;br /&gt;
== I have a pi0 but cannot get TZXs to load ==&lt;br /&gt;
You will require a new updated &#039;&#039;&#039;dot/pisend&#039;&#039;&#039; and &#039;&#039;&#039;nextzxos/tzxload.bas&#039;&#039;&#039; from the&lt;br /&gt;
[https://gitlab.com/thesmog358/tbblue git repository]. These need to be placed in the correct folders on your SD&lt;br /&gt;
card. These files have updated after the distro was released.&amp;lt;br&amp;gt;&lt;br /&gt;
You can check if the pi0 is correctly responding by going into Command Line and running “.term”&lt;br /&gt;
You should see Terminex, press SYM+SHIFT+B to switch to 115,200 baud and press Enter. If you&lt;br /&gt;
see the words “SUP&amp;amp;gt;” then your pi0 is ready. You can quit Terminex by pressing SYM+SHIFT+Q&lt;br /&gt;
&lt;br /&gt;
To load a TZX, place some TZX files on your SD card and you should be able to select the files&lt;br /&gt;
from the Browser and the Next should do the rest. If you come across a game that doesn’t work&lt;br /&gt;
please let us know.&lt;br /&gt;
&lt;br /&gt;
I have problems loading TZXs:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Are you on the latest core / NextZXOS?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you updated to the latest git distro? [https://gitlab.com/thesmog358/tbblue/-/archive/master/tbblue-master.zip git repository]&amp;lt;br&amp;gt;&lt;br /&gt;
What video mode are you using? (VGA0/HDMI etc)&amp;lt;br&amp;gt;&lt;br /&gt;
What game didn&#039;t work? (You need to supply the exact name)&amp;lt;br&amp;gt;&lt;br /&gt;
Where did the loading fail? Did the game load fine but crash etc?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you left something plugged into the EAR port?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I sort the contents of my SD card? ==&lt;br /&gt;
On NextZXOS 2.07 and above, the browser can sort files dynamically. Press O to toggle between ordering by date, size and none. Press + (SYM+K) to toggle between ascending and descending order.&lt;br /&gt;
&lt;br /&gt;
For esxDOS or older versions of NextZXOS, you will need to use a tool on a PC such as [http://www.anerty.net/software/file/DriveSort/?lang=en DriveSort] (Windows) or [https://fatsort.sourceforge.io/ FatSort] (cross OS compatible) to physically reorder the files in the SD card&#039;s directory database. &lt;br /&gt;
&lt;br /&gt;
== Where do I buy RTC / Mouse / Memory / Wifi / Pi0 / Inline Power Switch… ==&lt;br /&gt;
ActiveConsult sell most of these products and can be found [https://store.activeconsult.co.uk/shop?olsPage=products&amp;amp;amp;page=1 here].&lt;br /&gt;
SCART cables can be purchased [https://coolnovelties.co.uk/coolnovelties/sinclair-zx-spectrum/312-zx-spectrum-next-analog-rgb-scart-cable-0705693507088.html here], also here: [https://www.retrocomputershack.com/] NOTE that you will need to boot your ZX Spectrum Next and press the R key to set up the SCART output.&lt;br /&gt;
&lt;br /&gt;
== What controller / joystick / gamepad can I use? ==&lt;br /&gt;
[[File:Atari-2600-Paddles.jpg|thumb|Atari 2600 Paddles]]The Next supports any “Atari” standard joystick or gamepad, along with Master System and MegaDrive pads. A good option is the [[M30 8BitDo wireless MegaDrive pad]].&lt;br /&gt;
You &#039;&#039;&#039;CANNOT&#039;&#039;&#039; use the &#039;&#039;&#039;Sinclair Branded SJS-1&#039;&#039;&#039; joysticks sold for +2/2A/3 ZX Spectrums as they require a special adapter. &lt;br /&gt;
If your joystick has both black and grey plugs, &#039;&#039;&#039;DO NOT&#039;&#039;&#039; plug in the grey plug, as that only works on +2/2A/3 ZX Spectrums and will damage your Next.&lt;br /&gt;
&lt;br /&gt;
The Next also supports [https://www.atariage.com/controller_page.php?ControllerID=3&amp;amp;SystemID=2600 Atari 2600 driving controllers]. These are digital quadrature rotary encoder devices, identifiable by the word &amp;quot;driving&amp;quot; and picture of a racing car. [https://www.atariage.com/controller_page.php?SystemID=2600&amp;amp;ControllerID=2 Atari 2600 paddles] (identifiable by the word &amp;quot;paddle&amp;quot; and picture of tennis rackets) contain analogue potentiometers, which are &#039;&#039;&#039;NOT&#039;&#039;&#039; physically compatible and could damage your Next.&lt;br /&gt;
&lt;br /&gt;
== How do I configure the joystick ports to be Kempston / Sinclair / Megadrive / Cursor? ==&lt;br /&gt;
&lt;br /&gt;
Your Next lets you configure how each joystick port behaves. By default the Left port will be configured to Kempston1 and Right will be Sinclair1. If you wish to change this configuration press the NMI button, Choose &amp;quot;Settings&amp;quot;, then &amp;quot;Joysticks&amp;quot;. You can now select JoyL for Left or JoyR for right and cycle through the options : &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston1&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston2&amp;lt;br&amp;gt;&lt;br /&gt;
Cursor&amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair1 &amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair2&amp;lt;br&amp;gt;&lt;br /&gt;
MD 1 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
MD 2 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You cannot set both ports to the same configuration. This will only set the choice until a cold reboot (complete power off). You can set these options to be permanent by powering off your Next, on the Sinclair ZX Next boot screen hold down SPACE, then press &#039;E&#039; - Change the options for Left Joy and Right Joy with SPACE. Once you have chosen your preferred joystick configuration press ENTER twice. Your Next will now reboot and once back into NextZXOS your settings will now be applied. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My ZX ProPad Button 2 Doesn&#039;t Work ==&lt;br /&gt;
The Next only supports two directly wired fire buttons. On the ZX ProPad these are buttons 1 and 3. Additional buttons are supported for Sega Megadrive pads and sticks only. Both 3 and 6 button Sega pads are compatible. Up, down, left, right, A, B, C, X, Y, Z, Start and Mode are all readable.&lt;br /&gt;
&lt;br /&gt;
The limitation of two directly wired fire buttons on non-Sega pads and sticks is baked into the Next hardware, unfortunately. So it cannot be enhanced in a future core update. All Next boards have a physical multiplex chip which hardwires six pins as input only (for direction and two fire buttons), one pin as output only (for Sega select), one pin as 5V, and one pin as ground.&lt;br /&gt;
== How do I change the CPU speed/ Scanlines etc? ==&lt;br /&gt;
The following keys combinations can be used to :&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 1 Hard reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 2 toggle scan doubler&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 3 toggle 50 / 60 Hz&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 4 Soft reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 7 Toggle scan lines (25/50/75%)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 8 Toggle CPU speed (3.5/7/14/28)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 9 NMI menu&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Where can I download games / roms ? ==&lt;br /&gt;
[https://spectrumcomputing.co.uk/ Spectrum Computing] and [https://www.worldofspectrum.org/ World of Spectrum] are good places to start. If your Next has wifi, [[https://github.com/em00k/next-zxdb-downloader zxdb-dl]] can also search and download directly on your Next. zxdb-dl is also on your SD card as part of the latest distro.&lt;br /&gt;
&lt;br /&gt;
== My internal keyboard is not responding – help!== &lt;br /&gt;
First turn off the Next completely and remove all cables and try again. Failing that a keyboard&lt;br /&gt;
cable may have become loose. You can watch a video on how to open your Next here:&amp;lt;br&amp;gt;&lt;br /&gt;
https://www.youtube.com/watch?v=iLDz4AjL3rA also see [[NexTest|NexTest diagnostic tool]]&lt;br /&gt;
&lt;br /&gt;
== My ps/2 keyboard is not responding – help!== &lt;br /&gt;
Edit your &#039;&#039;&#039;c:/machines/next/config.ini&#039;&#039;&#039; file so that &#039;&#039;&#039;ps2=0&#039;&#039;&#039;, or use a [https://store.activeconsult.co.uk/shop?olsPage=products%2Fps2-keyboard-mouse-splitter ps/2 splitter].&lt;br /&gt;
&lt;br /&gt;
== How do I install pi0 / Wifi / RTC / Memory? ==&lt;br /&gt;
As above a guide on how to open your Next can be viewed. Also read the appropriate Chapter in the manual.&lt;br /&gt;
[https://www.youtube.com/watch?v=iLDz4AjL3rA here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I connect to Wi-Fi? ==&lt;br /&gt;
The Next&#039;s ESP can only connect to 2.4Ghz Wi-Fi networks, make sure your password does not contain spaces. You can use the application wifi2.bas from /apps/wifi/setup - when you load wifi2.bas and type RUN to start&lt;br /&gt;
&lt;br /&gt;
You can confirm your IP address by going in to command line and typing .uart then the following:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+CIFSR&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should return your IP. If you are still having issues, confirm the network is 2.4Ghz, and you are not too far away from an access point.&lt;br /&gt;
&lt;br /&gt;
See if other internet apps work, try ZXDB-DL from /apps/wifi/zxdb-dl and launch zxdb-loader.bas. When the program launches, enter a game search term and press return. If you see results wifi is working.&lt;br /&gt;
&lt;br /&gt;
If you continue to have issues confirm the ESP baud rate, from the command line : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;.espbaud -dR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will &amp;gt;Reset and try to &amp;gt;detect the current speed. A message saying &amp;quot;Resetting ESP&amp;quot;, then a baud rate test will begin, once the program has finished, a success would look like this :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;ESP reports 115273&lt;br /&gt;
  Setting uart to 115273&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This usually confirms the correct speed has been negotiated. Now run .uart and run the command above and see if you get a response. &lt;br /&gt;
Another useful AT command to run is :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+GMR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Furthur information on the ESP and AT commands is [[ESP8266-01|linked here]]  &lt;br /&gt;
&lt;br /&gt;
This will report your current ESP firmware. FW v1.2.0.0 is the version shipped with both KS models. The reliability of this differs in opinion and some people have updated to newer versions 1.6.0.0 and 1.7.6.0 reporting less oddities and overall more stable operation. Owner&#039;s must understand the risks involved when updating fw as it is possible to brick your ESP and for KS2 models, the ESP is soldered to the motherboard making replacing more complicated. FW updates can be done using the .espupdate dotcommand supplied on the official distro and heading over [https://github.com/Threetwosevensixseven/espupdate/wiki/Update-ESP-Firmware-From-ZX-Spectrum-Next here for more information]. &lt;br /&gt;
&lt;br /&gt;
[[File:Uart-fw.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== How can I get the expansion bus working with external hardware? ==&lt;br /&gt;
By default, the Next disables the expansion bus, as external hardware can conflict and is unlikely to run at CPU speeds faster than 3.5MHz. The bus can be enabled and and individual conflicting internal hardware disabled through Next registers 128 and 130..137 (manual pages 270..271). [https://www.specnext.com/forum/viewtopic.php?f=6&amp;amp;t=1482&amp;amp;p=9701&amp;amp;hilit=RAM+music+machine+expansion+bus#p9701 Here] is a detailed example of getting the RAM Music Machine working, and [https://www.youtube.com/watch?v=EU9NTQqQ1fg here] is a video demonstrating unsing Interface 1/microdrives.&lt;br /&gt;
&lt;br /&gt;
== Can I use Amstrad/Sinclair SJS-1 joysticks with the Next? ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NO!&#039;&#039;&#039; [https://rk.nvg.ntnu.no/sinclair/computers/peripherals/sjs1.htm SJS-1 joysticks] have fundamentally incompatible wiring compared with the standard Atari-wired joysticks the Next uses. Using them on the Next will short the 5V line to ground, potentially damaging your Next. Bin them, sell them, or keep them for your original +2, +2A or +3, where they will work fine but still be quite rubbish.&lt;br /&gt;
&lt;br /&gt;
== Why don&#039;t my VGA/joystick sockets have hex nuts to screw the cable in? ==&lt;br /&gt;
VGA sockets with hex nuts are typically bolted to a metal chassis. On the Next there is no chassis to screw onto, so you would just be screwing into the connector which is a VERY bad idea. The Next sockets are only fixed tight with small solder pads.&lt;br /&gt;
VGA cables are heavy and will put a lot of leverage on the VGA PCB pins, and likely to fracture the PCB or pins on the VGA socket. An unscrewed cable will still stay firmly in the socket during normal use, but will safely unplug if you yank the cable or leverage the plug.&lt;br /&gt;
&lt;br /&gt;
== I thought I had the latest version of the distro? ==&lt;br /&gt;
Go by the version numbers of the firmware, core and NextZXOS when deciding if you have the latest version. Ignore the post date on the [https://www.specnext.com/latestdistro/ latest distro] page. Wordpress post dates don&#039;t automatically update when existing posts are edited.&lt;br /&gt;
&lt;br /&gt;
== Why doesn&#039;t the manual have a table of contents / index ==&lt;br /&gt;
Short answer: It didn&#039;t fit in the box as the boxes were made way before the manual was completed. &lt;br /&gt;
Long answer: TL;DR :)&lt;br /&gt;
&lt;br /&gt;
== Where can I download a copy of the manual with a ToC and index? ==&lt;br /&gt;
Right here : https://www.specnext.com/zx-spectrum-next-user-manual-first-edition/   &lt;br /&gt;
&lt;br /&gt;
Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/manual-fixed.pdf fixed version] displays correctly in Safari, and can be read directly in browsers.&lt;br /&gt;
&lt;br /&gt;
== Further Spectrum Next Video Guides ==&lt;br /&gt;
https://www.youtube.com/playlist?list=PL2lCM2mJCG_AonDyHJfqjxFR5VoqBWqoh&lt;br /&gt;
&lt;br /&gt;
== Which Raspberry Pi Model Can I use for the Next Accelerator? ==&lt;br /&gt;
Pi Zero 1.3 has fairly major design changes from 1.2, but as long as you’re using official NextPi images and using it as advised you should see no issues using the original 1.2 Pi Zero (the one without camera connectors). The Pi Zero 1.3 will also work just fine, and doesn’t use the camera connector even if found.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero W (all of 1.x ones) are very similar to the 1.3. NextPi can use it, and will disable the wireless.&lt;br /&gt;
&lt;br /&gt;
It’s worth knowing that, &#039;&#039;in theory,&#039;&#039; someone could develop a plugin for NextPi that only works for the the non wireless version, but the only people to do that so far are the Next Team, to prove it was possible.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero 2 series is not supported, has never been supported, won’t work properly, and no support is offered or given into getting it to work properly. Neither are any other non-Zero Pi models, or clones such as Banana Pi.&lt;br /&gt;
&lt;br /&gt;
Other, non-official, &amp;quot;NextPi-compatible&amp;quot; distributions are starting to come available, from 3rd party users and - so far - are NOT fully nextpi compatible, at all.&lt;br /&gt;
&lt;br /&gt;
== Essential Lesser-Known Technical Docs ==&lt;br /&gt;
* The master [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/nextreg.txt nextreg] and [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/ports.txt port] lists are kept up to date, and fully describe the Next hardware for developers.  &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/blob/master/docs/extra-hw/pinouts/pinouts.txt pinouts] list has detailed information on connectors. &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/raw/master/docs/nextzxos-changelog.txt NextZXOS change log] details what was new and fixed in each version of NextZXOS/NextBASIC. &lt;br /&gt;
* The four [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos NextZXOS PDFs] have detailed information on the NextZXOS and esxDOS APIs, NextBASIC sysvars, and NextBASIC syntax.&lt;br /&gt;
* varmfskii&#039;s [https://raw.githubusercontent.com/varmfskii/zxnext_code/master/zx_next_notes/zxnext_notes.pdf ZX Spectrum Next Programming Notes] are an attempt to consolidate the Next programming interface into a single location.&lt;br /&gt;
* Myopian&#039;s [https://docs.google.com/spreadsheets/d/1dB8fKIfByGJTts409Ud8ly450a6SLPnLZc-nCBghBl8 API spreadsheet] summarises NextZXOS/IDEDOS entry points along with calling conditions.&lt;br /&gt;
* Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/dot-cmds.html dot command summary] collects together help and readme text for NextZXOS dot commands in one handy place.&lt;br /&gt;
* Tomaz&#039;s [https://github.com/tomaz/zx-next-dev-guide/releases/latest ZX Spectrum Next Assembly Developer Guide] is almost like &amp;quot;User manual&amp;quot; for Assembly developers.&lt;br /&gt;
* Luzie/Rat Mal&#039;s [https://docs.google.com/spreadsheets/d/17-ifpHcy932_AP7SAv9uBLxg-2ZptcdgTvQ8ILXQLM4/edit?usp=sharing_eil&amp;amp;ts=599361c7 Almost (In-) Complete List of esxDOS DOT-Commands] attempts to list dot commands for several systems, including the Next. Some of the non-Next-specific commands may work on the Next, and some may only work on other FPGA/divMMC systems.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13561</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13561"/>
		<updated>2025-04-14T23:46:43Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* How do I connect to Wi-Fi? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== I am using HDMI and I get no picture ==&lt;br /&gt;
When the Next boots hold down D for DIGITAL (HDMI) – Mode 7 50hz / 60hz can be selected. N selects the next frequency, ENTER selects it and saves. ONLY PRESS ENTER if you actually see a screen like the one below. N is NOT necessary as the testscreen will automatically go to the next mode albeit slower.&lt;br /&gt;
[[File:Figure02-TestScreenMode7.png|thumb|ZX Spectrum Next Test Screen]]&lt;br /&gt;
&lt;br /&gt;
You will also get an audible intermittent tone so you know your audio is working. It&#039;s possible your display can lock onto both modes but only one being able to lock onto the audio. Choose the one with the tone before pressing ENTER. Extract the files and copy over the BIN / SYS/ TMP folders to the root of your SD.&lt;br /&gt;
&lt;br /&gt;
== How to use esxDOS with 48K mode ==&lt;br /&gt;
[[File:2023-12-17 21 01 56-Window.png|thumb|esxDOS files]]&lt;br /&gt;
Your ZX Next can simulate the divMMC hardware for other machines. You can use esxDOS with 128/48K machines. You can download the latest esxDOS zip file here https://esxdos.org/index.html Download the zip and copy over the following folders BIN/SYS/TMP.&lt;br /&gt;
&lt;br /&gt;
You will need to place the ESXMMC.BIN in to /machines/next/roms&lt;br /&gt;
&lt;br /&gt;
Boot up your Next and press SPACE to open the configuration menu. Use the arrow keys to select 48K Mode, SPACE again and ensure DIVmmc ROM = YES. Exit and save this configuration. When your Next boots it should show the esxDOS logo just before the (c)1982 Sinclair Research Ltd message.&lt;br /&gt;
&lt;br /&gt;
[[ESXDOS|Further information can be found here]]&lt;br /&gt;
&lt;br /&gt;
[[File:Pre boot machine select menu.png|thumb]]&lt;br /&gt;
[[File:2023-12-17 21 21 11-OBS 30.0.0 - Profile Untitled - Scenes Untitled.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== I am using VGA and I get no picture ==&lt;br /&gt;
When the Next boots hold down V for VGA – Mode 0-6 50hz / 60hz can be selected. VGA0 is the&lt;br /&gt;
preferred mode as this has accurate timings. 1 – 6 are also accurate timings but increase slightly&lt;br /&gt;
in speed. N works as above but there are 12 possible configurations you can choose from. You&#039;ll start at VGA0@50Hz, next one will be the same at 60Hz and so forth. ENTER again selects and saves the changes. Audio is also being produced during the VGA Test Screen phase, however you will need powered speakers (or earphones) plugged in the audio out connector at the back of your Next.&lt;br /&gt;
&lt;br /&gt;
== I&#039;m using an HDMI display and a game&#039;s graphics appear garbled ==&lt;br /&gt;
Some games (specifically ones with multicolour or border effects - eg. Nirvana/Bifrost engine games, certain demos particularly ex-Soviet demoscene ones) require precise timings as with a regular Spectrum. Due to the nature of HDMI displays and the lack of internal buffering on the Spectrum Next display hardware currently these will not work properly and require a VGA or RGB display. &lt;br /&gt;
This is expected to be fixed in a future edition of the core/distribution but until then, there are a few alternative solutions:&lt;br /&gt;
a. An extra Spectrum core that implements precise HDMI timings by removing some of the Next&#039;s extra features. &lt;br /&gt;
b. Use of OSSC hardware which takes the Next&#039;s RGB/VGA display and converts it to HDMI independently&lt;br /&gt;
c. Use of the ZXHD or TkPie hardware expansions (only for standard Spectrum modes at 3.5MHz clock) &lt;br /&gt;
Next specific programs do not have this issue as they&#039;re made taking the current HDMI timing differences into account and will continue to work in the future when the most appropriate HDMI solution is implemented.&lt;br /&gt;
&lt;br /&gt;
== I am updating to the latest distro from GitLab or the N-Go website and my ps/2 keyboard doesn&#039;t work ==&lt;br /&gt;
To use a ps/2 keyboard you need to first choose whether you have a mouse or keyboard plugged into your ps/2 port. Unfortunately you can&#039;t get to the screen where you can make this choice &#039;&#039;until&#039;&#039; you have chosen your video mode on the testcard screen... which &#039;&#039;needs&#039;&#039; the keyboard to be already working!  &lt;br /&gt;
&lt;br /&gt;
Download this minimal config.ini file [https://dl.dropbox.com/s/5na7sd21328jnz5/CONFIG.INI] and copy it to the &#039;&#039;&#039;/Machines/Next&#039;&#039;&#039; folder on your SD card, then try again.&lt;br /&gt;
&lt;br /&gt;
When updating your distro from the official [[https://www.specnext.com/latestdistro/ Latest Distro]] page, or when using the internal keyboard on your official kickstarter 1 or 2 Next, this problem will not occur.&lt;br /&gt;
&lt;br /&gt;
== My monitor shows wrong image with Soviet timings(Pentagon)  ==&lt;br /&gt;
Pentagon has a non-standard screen refresh rate of 48.828Hz, some monitors do not support it. In some cases, can help manual picture settings in menu of your monitor. &lt;br /&gt;
Another solution to the issue is to buy a monitor that is compatible with Pentagon timings. User-generated list of compatible monitors located here: http://www.nedopc.com/zxevo/zxevo_supported_monitors.pdf&lt;br /&gt;
As a rule, monitors from this list are available on the secondary market at a low cost. Before purchasing desirable testing monitor with Pentagon mode.&lt;br /&gt;
&lt;br /&gt;
== HELP! My &amp;lt;insert game name here&amp;gt; doesn&#039;t work while it works on my &amp;lt;insert older Spectrum model here&amp;gt; ==&lt;br /&gt;
This is most likely due to a specific incompatibility of said program with the Next&#039;s extra hardware. The NextZXOS loader module, provides a lot of options for loading software catering to each model&#039;s idiosyncracies but also gives you the option to disable almost all Next extra hardware in order to make it work. If, after trying everything, the software doesn&#039;t work, you need to inform the team using the official gitlab repo &amp;quot;Issues&amp;quot; (registration is required) and provide a link to a copy of your program. The team will look at the specific issue and respond/fix the issue as soon as possible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What classic files can I load on my Next? ==&lt;br /&gt;
The Next supports NEXs, TAPs (preferred for classic software), SNAs, DSKs, Z80s, SNXs which can be loaded from the browser&lt;br /&gt;
menu by selecting them with the cursor keys and ENTER (or a joystick and Fire) -OR- by using the SPECTRUM command. (See Chapter 20 in the manual for details).&lt;br /&gt;
Place the files on your SD card and pick from the Browser.&lt;br /&gt;
&lt;br /&gt;
== How to load from a software cassette tape ==&lt;br /&gt;
For a successful load a clear signal from the player has to arrive on the &amp;quot;ring&amp;quot; part of the plug which you insert in the EAR/MIC socket of your Next, as in the picture &amp;quot;Next&#039;s EAR/MIC socket wiring&amp;quot;.&lt;br /&gt;
[[File:Ear-mic-socket-1.png|thumb|Next&#039;s EAR/MIC socket wiring]]&lt;br /&gt;
The plug inserted into the Next is referred to in many descriptions as a &amp;quot;3.5mm stereo plug&amp;quot;. Even if the Next always uses a single channel to load, the plug on its side has to be the same as those used for stereo (two channel) equipment, because, as stated, it then receives the signal over the &amp;quot;ring&amp;quot;, which doesn&#039;t exist on &amp;quot;mono&amp;quot; plugs. That&#039;s also why the cables delivered with the Spectrum 128 and earlier models won&#039;t work: their both sides lack the ring on their plugs.&lt;br /&gt;
&lt;br /&gt;
So the cable on the Next&#039;s side needs a 3.5mm plug commonly described as a &amp;quot;stereo&amp;quot; plug. The other side will depend on the output socket on your cassette player.&lt;br /&gt;
&lt;br /&gt;
[[File:Spectrum-plus-3-tape-lead.jpg|thumb|ZX Spectrum Next/+3 Tape Lead]]&lt;br /&gt;
&lt;br /&gt;
To load from a player with a &#039;&#039;mono earphone&#039;&#039; socket: you can try to use, if you have it, a cable made for Spectrum +3 or later (see the picture: &amp;quot;ZX Spectrum Next/+3 Tape Lead&amp;quot;), or, you can try to obtain an [https://store.activeconsult.co.uk/shop?olsPage=products%2Fear-mic-cable&amp;amp;page=2 &amp;quot;Ear/Mic Cable&amp;quot;], or, as a possible substitution, a TRS stereo cable and a fitting stereo to mono adapter.&lt;br /&gt;
&lt;br /&gt;
All other scenarios need different solutions. Often, if the player has a 3.5mm &#039;&#039;stereo&#039;&#039; socket and the signal on its right channel sounds good, then a plain TRS cable with 3.5mm plugs on both sides could work (in TRS, the T stands for the &amp;quot;tip&amp;quot; and the R for the &amp;quot;ring&amp;quot; of the plug). Otherwise, including in the case where you want to connect a mono socket from the player and you can&#039;t obtain or use the linked &amp;quot;Ear/Mic Cable&amp;quot;, the rule is still: the Next needs a clear and strong signal on its &amp;quot;ring&amp;quot; connection. The standard for analog stereo and AV cables or adapters which split the &amp;quot;stereo&amp;quot; side to separate channels on another side is to call the separated audio channels the left and the right channel and to assign white and red color to them, respectively. On those, the &#039;&#039;Red&#039;&#039; one is the one connected to the &#039;&#039;Ring&#039;&#039; needed by ZX Spectrum Next when loading. (Note 1: Memory aid: R-R-R, red-ring-right) (Note 2: Typically, the splitters to mono signals will have bigger sockets or plugs, called RCA: unless sockets on the player match, one splitter won&#039;t be the enough to construct the whole solution, but two can be combined, the second used to lead two, still separate, signals to a single multi-channel plug. A splitter allows to try which of the two channels from a stereo player has a better signal). (Note 3: when orienting the common splitters, the color mark from the historic +3 cable picture should be ignored: even if that cable is also a splitter, differently from the &amp;quot;stereo&amp;quot; convention, on it, the black side is the &amp;quot;right&amp;quot; one).&lt;br /&gt;
&lt;br /&gt;
NextZXOS provides a Tape Tester in the main menu of NextZXOS – Select More and Tape Tester. It can help once you already have a signal but need to find the best volume or, in some cases, adjust the azimuth. Once you are ready to load a real tape choose the Tape Loader and press PLAY on your player.&lt;br /&gt;
&lt;br /&gt;
== How can I load TZX files? ==&lt;br /&gt;
TZX files can be loaded if you have a pi0 or an external TZX player. If you have a pi0 please see&lt;br /&gt;
below for more information. Before asking for help please have this information ready&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My LED does not go out when I unplug the power! ==&lt;br /&gt;
&lt;br /&gt;
[[File:Next HDMI PSU.jpg|thumb|Remove ALL cables]]&lt;br /&gt;
Some TVs will back-power the Next through the HDMI cable, so it’s important to &#039;&#039;&#039;REMOVE ALL CABLES&#039;&#039;&#039; after a firmware&lt;br /&gt;
update and to turn off completely. If your TV/Display has multiple inputs try using one of the other ones as usually NOT ALL HDMI ports exhibit this behaviour.&lt;br /&gt;
&lt;br /&gt;
The back-power situation also happened in one case with I/O serial cable used at joystick port, general rule seems to be &amp;quot;if it has own power, and is connected to Next, it may back-power it&amp;quot; - in case of problems to power-cycle the Next properly, unplug all such cables/peripherals first and try again.&lt;br /&gt;
&lt;br /&gt;
== How do I update my Next? ==&lt;br /&gt;
Latest stable distro is [https://www.specnext.com/latestdistro/ here]. To update your Next, extract the contents of the distro to your SD card. Power down the Next,&lt;br /&gt;
Press and hold U and power on until you see the Updater screen and follow the instructions. As&lt;br /&gt;
above if you are using HDMI you need to remove all cables when instructed to power off your&lt;br /&gt;
Next.&lt;br /&gt;
&lt;br /&gt;
You can also read [https://www.specnext.com/forum/viewtopic.php?p=13644 this forum post] by Allen with greater detail about the update process.&lt;br /&gt;
&lt;br /&gt;
You may occasionally be directed to download the latest versions from gitlab [https://gitlab.com/thesmog358/tbblue here]. Sometimes this is desirable if you&#039;re being asked to test a specific fix or recent hardware features.&lt;br /&gt;
&lt;br /&gt;
== My SD card is not recognized by my Next during boot ==&lt;br /&gt;
The Next supports FAT32 (including long filenames), FAT16 and FAT12. It does &#039;&#039;&#039;not&#039;&#039;&#039; support exFAT, NTFS, AFS or ext formats. Some disk formatters, such as the Windows GUI formatter and the SD Association Formatter, force exFAT for SD cards 32GB or larger, and will &#039;&#039;&#039;not&#039;&#039;&#039; let you format with FAT32. On Windows, format with &amp;lt;code&amp;gt;format x: /FS:FAT32&amp;lt;/code&amp;gt; using the command line (where x: is the drive letter your card is mounted as).&lt;br /&gt;
&lt;br /&gt;
== How do I update the Pi in my Next (NextPi)? ==&lt;br /&gt;
NextPi that came with KS1 and requires a 1GB SD card can be downloaded [https://zx.xalior.com/NextPi/ here], and you can use [https://www.balena.io/etcher/ Etcher]. For NextPi2 (recommended) you will require a 16GB SD card and can download from [https://zx.xalior.com/NextPi2 here.]&lt;br /&gt;
&lt;br /&gt;
== I have a pi0 but cannot get TZXs to load ==&lt;br /&gt;
You will require a new updated &#039;&#039;&#039;dot/pisend&#039;&#039;&#039; and &#039;&#039;&#039;nextzxos/tzxload.bas&#039;&#039;&#039; from the&lt;br /&gt;
[https://gitlab.com/thesmog358/tbblue git repository]. These need to be placed in the correct folders on your SD&lt;br /&gt;
card. These files have updated after the distro was released.&amp;lt;br&amp;gt;&lt;br /&gt;
You can check if the pi0 is correctly responding by going into Command Line and running “.term”&lt;br /&gt;
You should see Terminex, press SYM+SHIFT+B to switch to 115,200 baud and press Enter. If you&lt;br /&gt;
see the words “SUP&amp;amp;gt;” then your pi0 is ready. You can quit Terminex by pressing SYM+SHIFT+Q&lt;br /&gt;
&lt;br /&gt;
To load a TZX, place some TZX files on your SD card and you should be able to select the files&lt;br /&gt;
from the Browser and the Next should do the rest. If you come across a game that doesn’t work&lt;br /&gt;
please let us know.&lt;br /&gt;
&lt;br /&gt;
I have problems loading TZXs:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Are you on the latest core / NextZXOS?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you updated to the latest git distro? [https://gitlab.com/thesmog358/tbblue/-/archive/master/tbblue-master.zip git repository]&amp;lt;br&amp;gt;&lt;br /&gt;
What video mode are you using? (VGA0/HDMI etc)&amp;lt;br&amp;gt;&lt;br /&gt;
What game didn&#039;t work? (You need to supply the exact name)&amp;lt;br&amp;gt;&lt;br /&gt;
Where did the loading fail? Did the game load fine but crash etc?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you left something plugged into the EAR port?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I sort the contents of my SD card? ==&lt;br /&gt;
On NextZXOS 2.07 and above, the browser can sort files dynamically. Press O to toggle between ordering by date, size and none. Press + (SYM+K) to toggle between ascending and descending order.&lt;br /&gt;
&lt;br /&gt;
For esxDOS or older versions of NextZXOS, you will need to use a tool on a PC such as [http://www.anerty.net/software/file/DriveSort/?lang=en DriveSort] (Windows) or [https://fatsort.sourceforge.io/ FatSort] (cross OS compatible) to physically reorder the files in the SD card&#039;s directory database. &lt;br /&gt;
&lt;br /&gt;
== Where do I buy RTC / Mouse / Memory / Wifi / Pi0 / Inline Power Switch… ==&lt;br /&gt;
ActiveConsult sell most of these products and can be found [https://store.activeconsult.co.uk/shop?olsPage=products&amp;amp;amp;page=1 here].&lt;br /&gt;
SCART cables can be purchased [https://coolnovelties.co.uk/coolnovelties/sinclair-zx-spectrum/312-zx-spectrum-next-analog-rgb-scart-cable-0705693507088.html here], also here: [https://www.retrocomputershack.com/] NOTE that you will need to boot your ZX Spectrum Next and press the R key to set up the SCART output.&lt;br /&gt;
&lt;br /&gt;
== What controller / joystick / gamepad can I use? ==&lt;br /&gt;
[[File:Atari-2600-Paddles.jpg|thumb|Atari 2600 Paddles]]The Next supports any “Atari” standard joystick or gamepad, along with Master System and MegaDrive pads. A good option is the [[M30 8BitDo wireless MegaDrive pad]].&lt;br /&gt;
You &#039;&#039;&#039;CANNOT&#039;&#039;&#039; use the &#039;&#039;&#039;Sinclair Branded SJS-1&#039;&#039;&#039; joysticks sold for +2/2A/3 ZX Spectrums as they require a special adapter. &lt;br /&gt;
If your joystick has both black and grey plugs, &#039;&#039;&#039;DO NOT&#039;&#039;&#039; plug in the grey plug, as that only works on +2/2A/3 ZX Spectrums and will damage your Next.&lt;br /&gt;
&lt;br /&gt;
The Next also supports [https://www.atariage.com/controller_page.php?ControllerID=3&amp;amp;SystemID=2600 Atari 2600 driving controllers]. These are digital quadrature rotary encoder devices, identifiable by the word &amp;quot;driving&amp;quot; and picture of a racing car. [https://www.atariage.com/controller_page.php?SystemID=2600&amp;amp;ControllerID=2 Atari 2600 paddles] (identifiable by the word &amp;quot;paddle&amp;quot; and picture of tennis rackets) contain analogue potentiometers, which are &#039;&#039;&#039;NOT&#039;&#039;&#039; physically compatible and could damage your Next.&lt;br /&gt;
&lt;br /&gt;
== How do I configure the joystick ports to be Kempston / Sinclair / Megadrive / Cursor? ==&lt;br /&gt;
&lt;br /&gt;
Your Next lets you configure how each joystick port behaves. By default the Left port will be configured to Kempston1 and Right will be Sinclair1. If you wish to change this configuration press the NMI button, Choose &amp;quot;Settings&amp;quot;, then &amp;quot;Joysticks&amp;quot;. You can now select JoyL for Left or JoyR for right and cycle through the options : &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston1&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston2&amp;lt;br&amp;gt;&lt;br /&gt;
Cursor&amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair1 &amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair2&amp;lt;br&amp;gt;&lt;br /&gt;
MD 1 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
MD 2 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You cannot set both ports to the same configuration. This will only set the choice until a cold reboot (complete power off). You can set these options to be permanent by powering off your Next, on the Sinclair ZX Next boot screen hold down SPACE, then press &#039;E&#039; - Change the options for Left Joy and Right Joy with SPACE. Once you have chosen your preferred joystick configuration press ENTER twice. Your Next will now reboot and once back into NextZXOS your settings will now be applied. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My ZX ProPad Button 2 Doesn&#039;t Work ==&lt;br /&gt;
The Next only supports two directly wired fire buttons. On the ZX ProPad these are buttons 1 and 3. Additional buttons are supported for Sega Megadrive pads and sticks only. Both 3 and 6 button Sega pads are compatible. Up, down, left, right, A, B, C, X, Y, Z, Start and Mode are all readable.&lt;br /&gt;
&lt;br /&gt;
The limitation of two directly wired fire buttons on non-Sega pads and sticks is baked into the Next hardware, unfortunately. So it cannot be enhanced in a future core update. All Next boards have a physical multiplex chip which hardwires six pins as input only (for direction and two fire buttons), one pin as output only (for Sega select), one pin as 5V, and one pin as ground.&lt;br /&gt;
== How do I change the CPU speed/ Scanlines etc? ==&lt;br /&gt;
The following keys combinations can be used to :&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 1 Hard reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 2 toggle scan doubler&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 3 toggle 50 / 60 Hz&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 4 Soft reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 7 Toggle scan lines (25/50/75%)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 8 Toggle CPU speed (3.5/7/14/28)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 9 NMI menu&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Where can I download games / roms ? ==&lt;br /&gt;
[https://spectrumcomputing.co.uk/ Spectrum Computing] and [https://www.worldofspectrum.org/ World of Spectrum] are good places to start. If your Next has wifi, [[https://github.com/em00k/next-zxdb-downloader zxdb-dl]] can also search and download directly on your Next. zxdb-dl is also on your SD card as part of the latest distro.&lt;br /&gt;
&lt;br /&gt;
== My internal keyboard is not responding – help!== &lt;br /&gt;
First turn off the Next completely and remove all cables and try again. Failing that a keyboard&lt;br /&gt;
cable may have become loose. You can watch a video on how to open your Next here:&amp;lt;br&amp;gt;&lt;br /&gt;
https://www.youtube.com/watch?v=iLDz4AjL3rA also see [[NexTest|NexTest diagnostic tool]]&lt;br /&gt;
&lt;br /&gt;
== My ps/2 keyboard is not responding – help!== &lt;br /&gt;
Edit your &#039;&#039;&#039;c:/machines/next/config.ini&#039;&#039;&#039; file so that &#039;&#039;&#039;ps2=0&#039;&#039;&#039;, or use a [https://store.activeconsult.co.uk/shop?olsPage=products%2Fps2-keyboard-mouse-splitter ps/2 splitter].&lt;br /&gt;
&lt;br /&gt;
== How do I install pi0 / Wifi / RTC / Memory? ==&lt;br /&gt;
As above a guide on how to open your Next can be viewed. Also read the appropriate Chapter in the manual.&lt;br /&gt;
[https://www.youtube.com/watch?v=iLDz4AjL3rA here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I connect to Wi-Fi? ==&lt;br /&gt;
The Next&#039;s ESP can only connect to 2.4Ghz Wi-Fi networks, make sure your password does not contain spaces. You can use the application wifi2.bas from /apps/wifi/setup - when you load wifi2.bas and type RUN to start&lt;br /&gt;
&lt;br /&gt;
You can confirm your IP address by going in to command line and typing .uart then the following:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+CIFSR&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should return your IP. If you are still having issues, confirm the network is 2.4Ghz, and you are not too far away from an access point.&lt;br /&gt;
&lt;br /&gt;
See if other internet apps work, try ZXDB-DL from /apps/wifi/zxdb-dl and launch zxdb-loader.bas. When the program launches, enter a game search term and press return. If you see results wifi is working.&lt;br /&gt;
&lt;br /&gt;
If you continue to have issues confirm the ESP baud rate, from the command line : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;.espbaud -dR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will &amp;gt;Reset and try to &amp;gt;detect the current speed. A message saying &amp;quot;Resetting ESP&amp;quot;, then a baud rate test will begin, once the program has finished, it will either say :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;ESP reports 115273&lt;br /&gt;
  Setting uart to 115273&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This usually confirms the correct speed has been negotiated. Now run .uart and run the command above and see if you get a response. &lt;br /&gt;
A comprehensive overview of the ESP and AT commands can be found here [[ESP8266-01]] Another useful AT command to run is :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+GMR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will report your current ESP firmware. FW v1.2.0.0 is the version shipped with both KS models. The reliability of this differs in opinion and some people have updated to newer versions 1.6.0.0 and 1.7.6.0 reporting less oddities and overall more stable operation. Owner&#039;s must understand the risks involved when updating fw as it is possible to brick your ESP and for KS2 models, the ESP is soldered to the motherboard making replacing more complicated. FW updates can be done using the .espupdate dotcommand supplied on the official distro and heading over [https://github.com/Threetwosevensixseven/espupdate/wiki/Update-ESP-Firmware-From-ZX-Spectrum-Next here for more information]. &lt;br /&gt;
&lt;br /&gt;
[[File:Uart-fw.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== How can I get the expansion bus working with external hardware? ==&lt;br /&gt;
By default, the Next disables the expansion bus, as external hardware can conflict and is unlikely to run at CPU speeds faster than 3.5MHz. The bus can be enabled and and individual conflicting internal hardware disabled through Next registers 128 and 130..137 (manual pages 270..271). [https://www.specnext.com/forum/viewtopic.php?f=6&amp;amp;t=1482&amp;amp;p=9701&amp;amp;hilit=RAM+music+machine+expansion+bus#p9701 Here] is a detailed example of getting the RAM Music Machine working, and [https://www.youtube.com/watch?v=EU9NTQqQ1fg here] is a video demonstrating unsing Interface 1/microdrives.&lt;br /&gt;
&lt;br /&gt;
== Can I use Amstrad/Sinclair SJS-1 joysticks with the Next? ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NO!&#039;&#039;&#039; [https://rk.nvg.ntnu.no/sinclair/computers/peripherals/sjs1.htm SJS-1 joysticks] have fundamentally incompatible wiring compared with the standard Atari-wired joysticks the Next uses. Using them on the Next will short the 5V line to ground, potentially damaging your Next. Bin them, sell them, or keep them for your original +2, +2A or +3, where they will work fine but still be quite rubbish.&lt;br /&gt;
&lt;br /&gt;
== Why don&#039;t my VGA/joystick sockets have hex nuts to screw the cable in? ==&lt;br /&gt;
VGA sockets with hex nuts are typically bolted to a metal chassis. On the Next there is no chassis to screw onto, so you would just be screwing into the connector which is a VERY bad idea. The Next sockets are only fixed tight with small solder pads.&lt;br /&gt;
VGA cables are heavy and will put a lot of leverage on the VGA PCB pins, and likely to fracture the PCB or pins on the VGA socket. An unscrewed cable will still stay firmly in the socket during normal use, but will safely unplug if you yank the cable or leverage the plug.&lt;br /&gt;
&lt;br /&gt;
== I thought I had the latest version of the distro? ==&lt;br /&gt;
Go by the version numbers of the firmware, core and NextZXOS when deciding if you have the latest version. Ignore the post date on the [https://www.specnext.com/latestdistro/ latest distro] page. Wordpress post dates don&#039;t automatically update when existing posts are edited.&lt;br /&gt;
&lt;br /&gt;
== Why doesn&#039;t the manual have a table of contents / index ==&lt;br /&gt;
Short answer: It didn&#039;t fit in the box as the boxes were made way before the manual was completed. &lt;br /&gt;
Long answer: TL;DR :)&lt;br /&gt;
&lt;br /&gt;
== Where can I download a copy of the manual with a ToC and index? ==&lt;br /&gt;
Right here : https://www.specnext.com/zx-spectrum-next-user-manual-first-edition/   &lt;br /&gt;
&lt;br /&gt;
Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/manual-fixed.pdf fixed version] displays correctly in Safari, and can be read directly in browsers.&lt;br /&gt;
&lt;br /&gt;
== Further Spectrum Next Video Guides ==&lt;br /&gt;
https://www.youtube.com/playlist?list=PL2lCM2mJCG_AonDyHJfqjxFR5VoqBWqoh&lt;br /&gt;
&lt;br /&gt;
== Which Raspberry Pi Model Can I use for the Next Accelerator? ==&lt;br /&gt;
Pi Zero 1.3 has fairly major design changes from 1.2, but as long as you’re using official NextPi images and using it as advised you should see no issues using the original 1.2 Pi Zero (the one without camera connectors). The Pi Zero 1.3 will also work just fine, and doesn’t use the camera connector even if found.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero W (all of 1.x ones) are very similar to the 1.3. NextPi can use it, and will disable the wireless.&lt;br /&gt;
&lt;br /&gt;
It’s worth knowing that, &#039;&#039;in theory,&#039;&#039; someone could develop a plugin for NextPi that only works for the the non wireless version, but the only people to do that so far are the Next Team, to prove it was possible.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero 2 series is not supported, has never been supported, won’t work properly, and no support is offered or given into getting it to work properly. Neither are any other non-Zero Pi models, or clones such as Banana Pi.&lt;br /&gt;
&lt;br /&gt;
Other, non-official, &amp;quot;NextPi-compatible&amp;quot; distributions are starting to come available, from 3rd party users and - so far - are NOT fully nextpi compatible, at all.&lt;br /&gt;
&lt;br /&gt;
== Essential Lesser-Known Technical Docs ==&lt;br /&gt;
* The master [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/nextreg.txt nextreg] and [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/ports.txt port] lists are kept up to date, and fully describe the Next hardware for developers.  &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/blob/master/docs/extra-hw/pinouts/pinouts.txt pinouts] list has detailed information on connectors. &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/raw/master/docs/nextzxos-changelog.txt NextZXOS change log] details what was new and fixed in each version of NextZXOS/NextBASIC. &lt;br /&gt;
* The four [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos NextZXOS PDFs] have detailed information on the NextZXOS and esxDOS APIs, NextBASIC sysvars, and NextBASIC syntax.&lt;br /&gt;
* varmfskii&#039;s [https://raw.githubusercontent.com/varmfskii/zxnext_code/master/zx_next_notes/zxnext_notes.pdf ZX Spectrum Next Programming Notes] are an attempt to consolidate the Next programming interface into a single location.&lt;br /&gt;
* Myopian&#039;s [https://docs.google.com/spreadsheets/d/1dB8fKIfByGJTts409Ud8ly450a6SLPnLZc-nCBghBl8 API spreadsheet] summarises NextZXOS/IDEDOS entry points along with calling conditions.&lt;br /&gt;
* Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/dot-cmds.html dot command summary] collects together help and readme text for NextZXOS dot commands in one handy place.&lt;br /&gt;
* Tomaz&#039;s [https://github.com/tomaz/zx-next-dev-guide/releases/latest ZX Spectrum Next Assembly Developer Guide] is almost like &amp;quot;User manual&amp;quot; for Assembly developers.&lt;br /&gt;
* Luzie/Rat Mal&#039;s [https://docs.google.com/spreadsheets/d/17-ifpHcy932_AP7SAv9uBLxg-2ZptcdgTvQ8ILXQLM4/edit?usp=sharing_eil&amp;amp;ts=599361c7 Almost (In-) Complete List of esxDOS DOT-Commands] attempts to list dot commands for several systems, including the Next. Some of the non-Next-specific commands may work on the Next, and some may only work on other FPGA/divMMC systems.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13560</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13560"/>
		<updated>2025-04-14T23:45:01Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* How do I connect to Wifi? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== I am using HDMI and I get no picture ==&lt;br /&gt;
When the Next boots hold down D for DIGITAL (HDMI) – Mode 7 50hz / 60hz can be selected. N selects the next frequency, ENTER selects it and saves. ONLY PRESS ENTER if you actually see a screen like the one below. N is NOT necessary as the testscreen will automatically go to the next mode albeit slower.&lt;br /&gt;
[[File:Figure02-TestScreenMode7.png|thumb|ZX Spectrum Next Test Screen]]&lt;br /&gt;
&lt;br /&gt;
You will also get an audible intermittent tone so you know your audio is working. It&#039;s possible your display can lock onto both modes but only one being able to lock onto the audio. Choose the one with the tone before pressing ENTER. Extract the files and copy over the BIN / SYS/ TMP folders to the root of your SD.&lt;br /&gt;
&lt;br /&gt;
== How to use esxDOS with 48K mode ==&lt;br /&gt;
[[File:2023-12-17 21 01 56-Window.png|thumb|esxDOS files]]&lt;br /&gt;
Your ZX Next can simulate the divMMC hardware for other machines. You can use esxDOS with 128/48K machines. You can download the latest esxDOS zip file here https://esxdos.org/index.html Download the zip and copy over the following folders BIN/SYS/TMP.&lt;br /&gt;
&lt;br /&gt;
You will need to place the ESXMMC.BIN in to /machines/next/roms&lt;br /&gt;
&lt;br /&gt;
Boot up your Next and press SPACE to open the configuration menu. Use the arrow keys to select 48K Mode, SPACE again and ensure DIVmmc ROM = YES. Exit and save this configuration. When your Next boots it should show the esxDOS logo just before the (c)1982 Sinclair Research Ltd message.&lt;br /&gt;
&lt;br /&gt;
[[ESXDOS|Further information can be found here]]&lt;br /&gt;
&lt;br /&gt;
[[File:Pre boot machine select menu.png|thumb]]&lt;br /&gt;
[[File:2023-12-17 21 21 11-OBS 30.0.0 - Profile Untitled - Scenes Untitled.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== I am using VGA and I get no picture ==&lt;br /&gt;
When the Next boots hold down V for VGA – Mode 0-6 50hz / 60hz can be selected. VGA0 is the&lt;br /&gt;
preferred mode as this has accurate timings. 1 – 6 are also accurate timings but increase slightly&lt;br /&gt;
in speed. N works as above but there are 12 possible configurations you can choose from. You&#039;ll start at VGA0@50Hz, next one will be the same at 60Hz and so forth. ENTER again selects and saves the changes. Audio is also being produced during the VGA Test Screen phase, however you will need powered speakers (or earphones) plugged in the audio out connector at the back of your Next.&lt;br /&gt;
&lt;br /&gt;
== I&#039;m using an HDMI display and a game&#039;s graphics appear garbled ==&lt;br /&gt;
Some games (specifically ones with multicolour or border effects - eg. Nirvana/Bifrost engine games, certain demos particularly ex-Soviet demoscene ones) require precise timings as with a regular Spectrum. Due to the nature of HDMI displays and the lack of internal buffering on the Spectrum Next display hardware currently these will not work properly and require a VGA or RGB display. &lt;br /&gt;
This is expected to be fixed in a future edition of the core/distribution but until then, there are a few alternative solutions:&lt;br /&gt;
a. An extra Spectrum core that implements precise HDMI timings by removing some of the Next&#039;s extra features. &lt;br /&gt;
b. Use of OSSC hardware which takes the Next&#039;s RGB/VGA display and converts it to HDMI independently&lt;br /&gt;
c. Use of the ZXHD or TkPie hardware expansions (only for standard Spectrum modes at 3.5MHz clock) &lt;br /&gt;
Next specific programs do not have this issue as they&#039;re made taking the current HDMI timing differences into account and will continue to work in the future when the most appropriate HDMI solution is implemented.&lt;br /&gt;
&lt;br /&gt;
== I am updating to the latest distro from GitLab or the N-Go website and my ps/2 keyboard doesn&#039;t work ==&lt;br /&gt;
To use a ps/2 keyboard you need to first choose whether you have a mouse or keyboard plugged into your ps/2 port. Unfortunately you can&#039;t get to the screen where you can make this choice &#039;&#039;until&#039;&#039; you have chosen your video mode on the testcard screen... which &#039;&#039;needs&#039;&#039; the keyboard to be already working!  &lt;br /&gt;
&lt;br /&gt;
Download this minimal config.ini file [https://dl.dropbox.com/s/5na7sd21328jnz5/CONFIG.INI] and copy it to the &#039;&#039;&#039;/Machines/Next&#039;&#039;&#039; folder on your SD card, then try again.&lt;br /&gt;
&lt;br /&gt;
When updating your distro from the official [[https://www.specnext.com/latestdistro/ Latest Distro]] page, or when using the internal keyboard on your official kickstarter 1 or 2 Next, this problem will not occur.&lt;br /&gt;
&lt;br /&gt;
== My monitor shows wrong image with Soviet timings(Pentagon)  ==&lt;br /&gt;
Pentagon has a non-standard screen refresh rate of 48.828Hz, some monitors do not support it. In some cases, can help manual picture settings in menu of your monitor. &lt;br /&gt;
Another solution to the issue is to buy a monitor that is compatible with Pentagon timings. User-generated list of compatible monitors located here: http://www.nedopc.com/zxevo/zxevo_supported_monitors.pdf&lt;br /&gt;
As a rule, monitors from this list are available on the secondary market at a low cost. Before purchasing desirable testing monitor with Pentagon mode.&lt;br /&gt;
&lt;br /&gt;
== HELP! My &amp;lt;insert game name here&amp;gt; doesn&#039;t work while it works on my &amp;lt;insert older Spectrum model here&amp;gt; ==&lt;br /&gt;
This is most likely due to a specific incompatibility of said program with the Next&#039;s extra hardware. The NextZXOS loader module, provides a lot of options for loading software catering to each model&#039;s idiosyncracies but also gives you the option to disable almost all Next extra hardware in order to make it work. If, after trying everything, the software doesn&#039;t work, you need to inform the team using the official gitlab repo &amp;quot;Issues&amp;quot; (registration is required) and provide a link to a copy of your program. The team will look at the specific issue and respond/fix the issue as soon as possible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What classic files can I load on my Next? ==&lt;br /&gt;
The Next supports NEXs, TAPs (preferred for classic software), SNAs, DSKs, Z80s, SNXs which can be loaded from the browser&lt;br /&gt;
menu by selecting them with the cursor keys and ENTER (or a joystick and Fire) -OR- by using the SPECTRUM command. (See Chapter 20 in the manual for details).&lt;br /&gt;
Place the files on your SD card and pick from the Browser.&lt;br /&gt;
&lt;br /&gt;
== How to load from a software cassette tape ==&lt;br /&gt;
For a successful load a clear signal from the player has to arrive on the &amp;quot;ring&amp;quot; part of the plug which you insert in the EAR/MIC socket of your Next, as in the picture &amp;quot;Next&#039;s EAR/MIC socket wiring&amp;quot;.&lt;br /&gt;
[[File:Ear-mic-socket-1.png|thumb|Next&#039;s EAR/MIC socket wiring]]&lt;br /&gt;
The plug inserted into the Next is referred to in many descriptions as a &amp;quot;3.5mm stereo plug&amp;quot;. Even if the Next always uses a single channel to load, the plug on its side has to be the same as those used for stereo (two channel) equipment, because, as stated, it then receives the signal over the &amp;quot;ring&amp;quot;, which doesn&#039;t exist on &amp;quot;mono&amp;quot; plugs. That&#039;s also why the cables delivered with the Spectrum 128 and earlier models won&#039;t work: their both sides lack the ring on their plugs.&lt;br /&gt;
&lt;br /&gt;
So the cable on the Next&#039;s side needs a 3.5mm plug commonly described as a &amp;quot;stereo&amp;quot; plug. The other side will depend on the output socket on your cassette player.&lt;br /&gt;
&lt;br /&gt;
[[File:Spectrum-plus-3-tape-lead.jpg|thumb|ZX Spectrum Next/+3 Tape Lead]]&lt;br /&gt;
&lt;br /&gt;
To load from a player with a &#039;&#039;mono earphone&#039;&#039; socket: you can try to use, if you have it, a cable made for Spectrum +3 or later (see the picture: &amp;quot;ZX Spectrum Next/+3 Tape Lead&amp;quot;), or, you can try to obtain an [https://store.activeconsult.co.uk/shop?olsPage=products%2Fear-mic-cable&amp;amp;page=2 &amp;quot;Ear/Mic Cable&amp;quot;], or, as a possible substitution, a TRS stereo cable and a fitting stereo to mono adapter.&lt;br /&gt;
&lt;br /&gt;
All other scenarios need different solutions. Often, if the player has a 3.5mm &#039;&#039;stereo&#039;&#039; socket and the signal on its right channel sounds good, then a plain TRS cable with 3.5mm plugs on both sides could work (in TRS, the T stands for the &amp;quot;tip&amp;quot; and the R for the &amp;quot;ring&amp;quot; of the plug). Otherwise, including in the case where you want to connect a mono socket from the player and you can&#039;t obtain or use the linked &amp;quot;Ear/Mic Cable&amp;quot;, the rule is still: the Next needs a clear and strong signal on its &amp;quot;ring&amp;quot; connection. The standard for analog stereo and AV cables or adapters which split the &amp;quot;stereo&amp;quot; side to separate channels on another side is to call the separated audio channels the left and the right channel and to assign white and red color to them, respectively. On those, the &#039;&#039;Red&#039;&#039; one is the one connected to the &#039;&#039;Ring&#039;&#039; needed by ZX Spectrum Next when loading. (Note 1: Memory aid: R-R-R, red-ring-right) (Note 2: Typically, the splitters to mono signals will have bigger sockets or plugs, called RCA: unless sockets on the player match, one splitter won&#039;t be the enough to construct the whole solution, but two can be combined, the second used to lead two, still separate, signals to a single multi-channel plug. A splitter allows to try which of the two channels from a stereo player has a better signal). (Note 3: when orienting the common splitters, the color mark from the historic +3 cable picture should be ignored: even if that cable is also a splitter, differently from the &amp;quot;stereo&amp;quot; convention, on it, the black side is the &amp;quot;right&amp;quot; one).&lt;br /&gt;
&lt;br /&gt;
NextZXOS provides a Tape Tester in the main menu of NextZXOS – Select More and Tape Tester. It can help once you already have a signal but need to find the best volume or, in some cases, adjust the azimuth. Once you are ready to load a real tape choose the Tape Loader and press PLAY on your player.&lt;br /&gt;
&lt;br /&gt;
== How can I load TZX files? ==&lt;br /&gt;
TZX files can be loaded if you have a pi0 or an external TZX player. If you have a pi0 please see&lt;br /&gt;
below for more information. Before asking for help please have this information ready&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My LED does not go out when I unplug the power! ==&lt;br /&gt;
&lt;br /&gt;
[[File:Next HDMI PSU.jpg|thumb|Remove ALL cables]]&lt;br /&gt;
Some TVs will back-power the Next through the HDMI cable, so it’s important to &#039;&#039;&#039;REMOVE ALL CABLES&#039;&#039;&#039; after a firmware&lt;br /&gt;
update and to turn off completely. If your TV/Display has multiple inputs try using one of the other ones as usually NOT ALL HDMI ports exhibit this behaviour.&lt;br /&gt;
&lt;br /&gt;
The back-power situation also happened in one case with I/O serial cable used at joystick port, general rule seems to be &amp;quot;if it has own power, and is connected to Next, it may back-power it&amp;quot; - in case of problems to power-cycle the Next properly, unplug all such cables/peripherals first and try again.&lt;br /&gt;
&lt;br /&gt;
== How do I update my Next? ==&lt;br /&gt;
Latest stable distro is [https://www.specnext.com/latestdistro/ here]. To update your Next, extract the contents of the distro to your SD card. Power down the Next,&lt;br /&gt;
Press and hold U and power on until you see the Updater screen and follow the instructions. As&lt;br /&gt;
above if you are using HDMI you need to remove all cables when instructed to power off your&lt;br /&gt;
Next.&lt;br /&gt;
&lt;br /&gt;
You can also read [https://www.specnext.com/forum/viewtopic.php?p=13644 this forum post] by Allen with greater detail about the update process.&lt;br /&gt;
&lt;br /&gt;
You may occasionally be directed to download the latest versions from gitlab [https://gitlab.com/thesmog358/tbblue here]. Sometimes this is desirable if you&#039;re being asked to test a specific fix or recent hardware features.&lt;br /&gt;
&lt;br /&gt;
== My SD card is not recognized by my Next during boot ==&lt;br /&gt;
The Next supports FAT32 (including long filenames), FAT16 and FAT12. It does &#039;&#039;&#039;not&#039;&#039;&#039; support exFAT, NTFS, AFS or ext formats. Some disk formatters, such as the Windows GUI formatter and the SD Association Formatter, force exFAT for SD cards 32GB or larger, and will &#039;&#039;&#039;not&#039;&#039;&#039; let you format with FAT32. On Windows, format with &amp;lt;code&amp;gt;format x: /FS:FAT32&amp;lt;/code&amp;gt; using the command line (where x: is the drive letter your card is mounted as).&lt;br /&gt;
&lt;br /&gt;
== How do I update the Pi in my Next (NextPi)? ==&lt;br /&gt;
NextPi that came with KS1 and requires a 1GB SD card can be downloaded [https://zx.xalior.com/NextPi/ here], and you can use [https://www.balena.io/etcher/ Etcher]. For NextPi2 (recommended) you will require a 16GB SD card and can download from [https://zx.xalior.com/NextPi2 here.]&lt;br /&gt;
&lt;br /&gt;
== I have a pi0 but cannot get TZXs to load ==&lt;br /&gt;
You will require a new updated &#039;&#039;&#039;dot/pisend&#039;&#039;&#039; and &#039;&#039;&#039;nextzxos/tzxload.bas&#039;&#039;&#039; from the&lt;br /&gt;
[https://gitlab.com/thesmog358/tbblue git repository]. These need to be placed in the correct folders on your SD&lt;br /&gt;
card. These files have updated after the distro was released.&amp;lt;br&amp;gt;&lt;br /&gt;
You can check if the pi0 is correctly responding by going into Command Line and running “.term”&lt;br /&gt;
You should see Terminex, press SYM+SHIFT+B to switch to 115,200 baud and press Enter. If you&lt;br /&gt;
see the words “SUP&amp;amp;gt;” then your pi0 is ready. You can quit Terminex by pressing SYM+SHIFT+Q&lt;br /&gt;
&lt;br /&gt;
To load a TZX, place some TZX files on your SD card and you should be able to select the files&lt;br /&gt;
from the Browser and the Next should do the rest. If you come across a game that doesn’t work&lt;br /&gt;
please let us know.&lt;br /&gt;
&lt;br /&gt;
I have problems loading TZXs:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Are you on the latest core / NextZXOS?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you updated to the latest git distro? [https://gitlab.com/thesmog358/tbblue/-/archive/master/tbblue-master.zip git repository]&amp;lt;br&amp;gt;&lt;br /&gt;
What video mode are you using? (VGA0/HDMI etc)&amp;lt;br&amp;gt;&lt;br /&gt;
What game didn&#039;t work? (You need to supply the exact name)&amp;lt;br&amp;gt;&lt;br /&gt;
Where did the loading fail? Did the game load fine but crash etc?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you left something plugged into the EAR port?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I sort the contents of my SD card? ==&lt;br /&gt;
On NextZXOS 2.07 and above, the browser can sort files dynamically. Press O to toggle between ordering by date, size and none. Press + (SYM+K) to toggle between ascending and descending order.&lt;br /&gt;
&lt;br /&gt;
For esxDOS or older versions of NextZXOS, you will need to use a tool on a PC such as [http://www.anerty.net/software/file/DriveSort/?lang=en DriveSort] (Windows) or [https://fatsort.sourceforge.io/ FatSort] (cross OS compatible) to physically reorder the files in the SD card&#039;s directory database. &lt;br /&gt;
&lt;br /&gt;
== Where do I buy RTC / Mouse / Memory / Wifi / Pi0 / Inline Power Switch… ==&lt;br /&gt;
ActiveConsult sell most of these products and can be found [https://store.activeconsult.co.uk/shop?olsPage=products&amp;amp;amp;page=1 here].&lt;br /&gt;
SCART cables can be purchased [https://coolnovelties.co.uk/coolnovelties/sinclair-zx-spectrum/312-zx-spectrum-next-analog-rgb-scart-cable-0705693507088.html here], also here: [https://www.retrocomputershack.com/] NOTE that you will need to boot your ZX Spectrum Next and press the R key to set up the SCART output.&lt;br /&gt;
&lt;br /&gt;
== What controller / joystick / gamepad can I use? ==&lt;br /&gt;
[[File:Atari-2600-Paddles.jpg|thumb|Atari 2600 Paddles]]The Next supports any “Atari” standard joystick or gamepad, along with Master System and MegaDrive pads. A good option is the [[M30 8BitDo wireless MegaDrive pad]].&lt;br /&gt;
You &#039;&#039;&#039;CANNOT&#039;&#039;&#039; use the &#039;&#039;&#039;Sinclair Branded SJS-1&#039;&#039;&#039; joysticks sold for +2/2A/3 ZX Spectrums as they require a special adapter. &lt;br /&gt;
If your joystick has both black and grey plugs, &#039;&#039;&#039;DO NOT&#039;&#039;&#039; plug in the grey plug, as that only works on +2/2A/3 ZX Spectrums and will damage your Next.&lt;br /&gt;
&lt;br /&gt;
The Next also supports [https://www.atariage.com/controller_page.php?ControllerID=3&amp;amp;SystemID=2600 Atari 2600 driving controllers]. These are digital quadrature rotary encoder devices, identifiable by the word &amp;quot;driving&amp;quot; and picture of a racing car. [https://www.atariage.com/controller_page.php?SystemID=2600&amp;amp;ControllerID=2 Atari 2600 paddles] (identifiable by the word &amp;quot;paddle&amp;quot; and picture of tennis rackets) contain analogue potentiometers, which are &#039;&#039;&#039;NOT&#039;&#039;&#039; physically compatible and could damage your Next.&lt;br /&gt;
&lt;br /&gt;
== How do I configure the joystick ports to be Kempston / Sinclair / Megadrive / Cursor? ==&lt;br /&gt;
&lt;br /&gt;
Your Next lets you configure how each joystick port behaves. By default the Left port will be configured to Kempston1 and Right will be Sinclair1. If you wish to change this configuration press the NMI button, Choose &amp;quot;Settings&amp;quot;, then &amp;quot;Joysticks&amp;quot;. You can now select JoyL for Left or JoyR for right and cycle through the options : &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston1&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston2&amp;lt;br&amp;gt;&lt;br /&gt;
Cursor&amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair1 &amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair2&amp;lt;br&amp;gt;&lt;br /&gt;
MD 1 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
MD 2 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You cannot set both ports to the same configuration. This will only set the choice until a cold reboot (complete power off). You can set these options to be permanent by powering off your Next, on the Sinclair ZX Next boot screen hold down SPACE, then press &#039;E&#039; - Change the options for Left Joy and Right Joy with SPACE. Once you have chosen your preferred joystick configuration press ENTER twice. Your Next will now reboot and once back into NextZXOS your settings will now be applied. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My ZX ProPad Button 2 Doesn&#039;t Work ==&lt;br /&gt;
The Next only supports two directly wired fire buttons. On the ZX ProPad these are buttons 1 and 3. Additional buttons are supported for Sega Megadrive pads and sticks only. Both 3 and 6 button Sega pads are compatible. Up, down, left, right, A, B, C, X, Y, Z, Start and Mode are all readable.&lt;br /&gt;
&lt;br /&gt;
The limitation of two directly wired fire buttons on non-Sega pads and sticks is baked into the Next hardware, unfortunately. So it cannot be enhanced in a future core update. All Next boards have a physical multiplex chip which hardwires six pins as input only (for direction and two fire buttons), one pin as output only (for Sega select), one pin as 5V, and one pin as ground.&lt;br /&gt;
== How do I change the CPU speed/ Scanlines etc? ==&lt;br /&gt;
The following keys combinations can be used to :&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 1 Hard reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 2 toggle scan doubler&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 3 toggle 50 / 60 Hz&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 4 Soft reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 7 Toggle scan lines (25/50/75%)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 8 Toggle CPU speed (3.5/7/14/28)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 9 NMI menu&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Where can I download games / roms ? ==&lt;br /&gt;
[https://spectrumcomputing.co.uk/ Spectrum Computing] and [https://www.worldofspectrum.org/ World of Spectrum] are good places to start. If your Next has wifi, [[https://github.com/em00k/next-zxdb-downloader zxdb-dl]] can also search and download directly on your Next. zxdb-dl is also on your SD card as part of the latest distro.&lt;br /&gt;
&lt;br /&gt;
== My internal keyboard is not responding – help!== &lt;br /&gt;
First turn off the Next completely and remove all cables and try again. Failing that a keyboard&lt;br /&gt;
cable may have become loose. You can watch a video on how to open your Next here:&amp;lt;br&amp;gt;&lt;br /&gt;
https://www.youtube.com/watch?v=iLDz4AjL3rA also see [[NexTest|NexTest diagnostic tool]]&lt;br /&gt;
&lt;br /&gt;
== My ps/2 keyboard is not responding – help!== &lt;br /&gt;
Edit your &#039;&#039;&#039;c:/machines/next/config.ini&#039;&#039;&#039; file so that &#039;&#039;&#039;ps2=0&#039;&#039;&#039;, or use a [https://store.activeconsult.co.uk/shop?olsPage=products%2Fps2-keyboard-mouse-splitter ps/2 splitter].&lt;br /&gt;
&lt;br /&gt;
== How do I install pi0 / Wifi / RTC / Memory? ==&lt;br /&gt;
As above a guide on how to open your Next can be viewed. Also read the appropriate Chapter in the manual.&lt;br /&gt;
[https://www.youtube.com/watch?v=iLDz4AjL3rA here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I connect to Wi-Fi? ==&lt;br /&gt;
You can connect to a 2.4Ghz Wi-Fi network, make sure your password does not contain spaces. You can use the application wifi2.bas from /apps/wifi/setup - when you load wifi2.bas and type RUN to start&lt;br /&gt;
&lt;br /&gt;
You can confirm your IP address by going in to command line and typing .uart then the following:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+CIFSR&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should return your IP. If you are still having issues, confirm the network is 2.4Ghz, and you are not too far away from an access point.&lt;br /&gt;
&lt;br /&gt;
See if other internet apps work, try ZXDB-DL from /apps/wifi/zxdb-dl and launch zxdb-loader.bas. When the program launches, enter a game search term and press return. If you see results wifi is working.&lt;br /&gt;
&lt;br /&gt;
If you continue to have issues confirm the ESP baud rate, from the command line : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;.espbaud -dR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will &amp;gt;Reset and try to &amp;gt;detect the current speed. A message saying &amp;quot;Resetting ESP&amp;quot;, then a baud rate test will begin, once the program has finished, it will either say :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;ESP reports 115273&lt;br /&gt;
  Setting uart to 115273&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This usually confirms the correct speed has been negotiated. Now run .uart and run the command above and see if you get a response. &lt;br /&gt;
A comprehensive overview of the ESP and AT commands can be found here [[ESP8266-01]] Another useful AT command to run is :&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;AT+GMR &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will report your current ESP firmware. FW v1.2.0.0 is the version shipped with both KS models. The reliability of this differs in opinion and some people have updated to newer versions 1.6.0.0 and 1.7.6.0 reporting less oddities and overall more stable operation. Owner&#039;s must understand the risks involved when updating fw as it is possible to brick your ESP and for KS2 models, the ESP is soldered to the motherboard making replacing more complicated. FW updates can be done using the .espupdate dotcommand supplied on the official distro and heading over [https://github.com/Threetwosevensixseven/espupdate/wiki/Update-ESP-Firmware-From-ZX-Spectrum-Next here for more information]. &lt;br /&gt;
&lt;br /&gt;
[[File:Uart-fw.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== How can I get the expansion bus working with external hardware? ==&lt;br /&gt;
By default, the Next disables the expansion bus, as external hardware can conflict and is unlikely to run at CPU speeds faster than 3.5MHz. The bus can be enabled and and individual conflicting internal hardware disabled through Next registers 128 and 130..137 (manual pages 270..271). [https://www.specnext.com/forum/viewtopic.php?f=6&amp;amp;t=1482&amp;amp;p=9701&amp;amp;hilit=RAM+music+machine+expansion+bus#p9701 Here] is a detailed example of getting the RAM Music Machine working, and [https://www.youtube.com/watch?v=EU9NTQqQ1fg here] is a video demonstrating unsing Interface 1/microdrives.&lt;br /&gt;
&lt;br /&gt;
== Can I use Amstrad/Sinclair SJS-1 joysticks with the Next? ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NO!&#039;&#039;&#039; [https://rk.nvg.ntnu.no/sinclair/computers/peripherals/sjs1.htm SJS-1 joysticks] have fundamentally incompatible wiring compared with the standard Atari-wired joysticks the Next uses. Using them on the Next will short the 5V line to ground, potentially damaging your Next. Bin them, sell them, or keep them for your original +2, +2A or +3, where they will work fine but still be quite rubbish.&lt;br /&gt;
&lt;br /&gt;
== Why don&#039;t my VGA/joystick sockets have hex nuts to screw the cable in? ==&lt;br /&gt;
VGA sockets with hex nuts are typically bolted to a metal chassis. On the Next there is no chassis to screw onto, so you would just be screwing into the connector which is a VERY bad idea. The Next sockets are only fixed tight with small solder pads.&lt;br /&gt;
VGA cables are heavy and will put a lot of leverage on the VGA PCB pins, and likely to fracture the PCB or pins on the VGA socket. An unscrewed cable will still stay firmly in the socket during normal use, but will safely unplug if you yank the cable or leverage the plug.&lt;br /&gt;
&lt;br /&gt;
== I thought I had the latest version of the distro? ==&lt;br /&gt;
Go by the version numbers of the firmware, core and NextZXOS when deciding if you have the latest version. Ignore the post date on the [https://www.specnext.com/latestdistro/ latest distro] page. Wordpress post dates don&#039;t automatically update when existing posts are edited.&lt;br /&gt;
&lt;br /&gt;
== Why doesn&#039;t the manual have a table of contents / index ==&lt;br /&gt;
Short answer: It didn&#039;t fit in the box as the boxes were made way before the manual was completed. &lt;br /&gt;
Long answer: TL;DR :)&lt;br /&gt;
&lt;br /&gt;
== Where can I download a copy of the manual with a ToC and index? ==&lt;br /&gt;
Right here : https://www.specnext.com/zx-spectrum-next-user-manual-first-edition/   &lt;br /&gt;
&lt;br /&gt;
Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/manual-fixed.pdf fixed version] displays correctly in Safari, and can be read directly in browsers.&lt;br /&gt;
&lt;br /&gt;
== Further Spectrum Next Video Guides ==&lt;br /&gt;
https://www.youtube.com/playlist?list=PL2lCM2mJCG_AonDyHJfqjxFR5VoqBWqoh&lt;br /&gt;
&lt;br /&gt;
== Which Raspberry Pi Model Can I use for the Next Accelerator? ==&lt;br /&gt;
Pi Zero 1.3 has fairly major design changes from 1.2, but as long as you’re using official NextPi images and using it as advised you should see no issues using the original 1.2 Pi Zero (the one without camera connectors). The Pi Zero 1.3 will also work just fine, and doesn’t use the camera connector even if found.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero W (all of 1.x ones) are very similar to the 1.3. NextPi can use it, and will disable the wireless.&lt;br /&gt;
&lt;br /&gt;
It’s worth knowing that, &#039;&#039;in theory,&#039;&#039; someone could develop a plugin for NextPi that only works for the the non wireless version, but the only people to do that so far are the Next Team, to prove it was possible.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero 2 series is not supported, has never been supported, won’t work properly, and no support is offered or given into getting it to work properly. Neither are any other non-Zero Pi models, or clones such as Banana Pi.&lt;br /&gt;
&lt;br /&gt;
Other, non-official, &amp;quot;NextPi-compatible&amp;quot; distributions are starting to come available, from 3rd party users and - so far - are NOT fully nextpi compatible, at all.&lt;br /&gt;
&lt;br /&gt;
== Essential Lesser-Known Technical Docs ==&lt;br /&gt;
* The master [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/nextreg.txt nextreg] and [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/ports.txt port] lists are kept up to date, and fully describe the Next hardware for developers.  &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/blob/master/docs/extra-hw/pinouts/pinouts.txt pinouts] list has detailed information on connectors. &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/raw/master/docs/nextzxos-changelog.txt NextZXOS change log] details what was new and fixed in each version of NextZXOS/NextBASIC. &lt;br /&gt;
* The four [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos NextZXOS PDFs] have detailed information on the NextZXOS and esxDOS APIs, NextBASIC sysvars, and NextBASIC syntax.&lt;br /&gt;
* varmfskii&#039;s [https://raw.githubusercontent.com/varmfskii/zxnext_code/master/zx_next_notes/zxnext_notes.pdf ZX Spectrum Next Programming Notes] are an attempt to consolidate the Next programming interface into a single location.&lt;br /&gt;
* Myopian&#039;s [https://docs.google.com/spreadsheets/d/1dB8fKIfByGJTts409Ud8ly450a6SLPnLZc-nCBghBl8 API spreadsheet] summarises NextZXOS/IDEDOS entry points along with calling conditions.&lt;br /&gt;
* Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/dot-cmds.html dot command summary] collects together help and readme text for NextZXOS dot commands in one handy place.&lt;br /&gt;
* Tomaz&#039;s [https://github.com/tomaz/zx-next-dev-guide/releases/latest ZX Spectrum Next Assembly Developer Guide] is almost like &amp;quot;User manual&amp;quot; for Assembly developers.&lt;br /&gt;
* Luzie/Rat Mal&#039;s [https://docs.google.com/spreadsheets/d/17-ifpHcy932_AP7SAv9uBLxg-2ZptcdgTvQ8ILXQLM4/edit?usp=sharing_eil&amp;amp;ts=599361c7 Almost (In-) Complete List of esxDOS DOT-Commands] attempts to list dot commands for several systems, including the Next. Some of the non-Next-specific commands may work on the Next, and some may only work on other FPGA/divMMC systems.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=File:Uart-fw.png&amp;diff=13559</id>
		<title>File:Uart-fw.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=File:Uart-fw.png&amp;diff=13559"/>
		<updated>2025-04-14T23:10:05Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AT version 1.7.6.0 connected at 115,200.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13552</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13552"/>
		<updated>2025-04-12T03:24:06Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Tile Operations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
There are two types when referring to tile maps. Software tiles are drawn by copying tiles from preloaded banks to the Layer2 graphics screen. Hardware tile maps use a tile system similar found on retro consoles and computers such as the Commodore 64, Nintendo NES and Sega MegaDrive. Below uses software tiles. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For details on using the hardware tile map see the [Hardware Tilemap] section.&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13551</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13551"/>
		<updated>2025-04-12T03:13:23Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Setup Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13550</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13550"/>
		<updated>2025-04-12T03:12:52Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Project Structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder.&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13549</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13549"/>
		<updated>2025-04-12T02:49:17Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Drawing a Sprite */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder. A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Upload 64 sprites from bank 34&lt;br /&gt;
InitSprites2(64, 0, 34, 0)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13548</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13548"/>
		<updated>2025-04-12T02:47:21Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* SD Card Access */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder. A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13547</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13547"/>
		<updated>2025-04-12T02:46:55Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Preprocessor Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder. A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your `.bas` file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!org=nn&amp;lt;/code&amp;gt; || Program start address (24576–65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!heap=nn&amp;lt;/code&amp;gt; || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!opt=n&amp;lt;/code&amp;gt; || Optimization value (0–4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!bmp=filename&amp;lt;/code&amp;gt; || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!copy=filename&amp;lt;/code&amp;gt; || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!noemu&amp;lt;/code&amp;gt; || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!asm&amp;lt;/code&amp;gt; || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosys&amp;lt;/code&amp;gt; || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!nosp&amp;lt;/code&amp;gt; || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13546</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13546"/>
		<updated>2025-04-12T02:45:37Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Creating Your First Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder. A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your .bas file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!org=nn || Program start address (24576-65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!heap=nn || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!opt=n || Optimization value (0-4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!bmp=filename || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!copy=filename || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!noemu || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!asm || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosys || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosp || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13545</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13545"/>
		<updated>2025-04-12T02:42:11Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Creating Your First Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder. A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new folder in the Sources directory, then a .bas file inside the new folder. &lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&#039;!opt=4&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PAPER 0 : INK 7 : CLS &lt;br /&gt;
&lt;br /&gt;
PRINT &amp;quot;Congratulations!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your .bas file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!org=nn || Program start address (24576-65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!heap=nn || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!opt=n || Optimization value (0-4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!bmp=filename || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!copy=filename || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!noemu || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!asm || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosys || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosp || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13544</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13544"/>
		<updated>2025-04-12T02:40:10Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* NextBuild v8 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= NextBuild v8 =&lt;br /&gt;
[[File:VSCode With NextBuild.png|thumb|Right|NextBuild]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with [https://zxbasic.readthedocs.io/en/docs/ Boriel&#039;s ZX Basic compiler] for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Cspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is [https://code.visualstudio.com/ Visual Studio Code], with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* [https://code.visualstudio.com/ Visual Studio Code] (recommended IDE)&lt;br /&gt;
* [https://github.com/em00k/NextBuild NextBuild tools package] (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When launching Visual Studio Code proceed to open a project and select the &amp;quot;Source&amp;quot; directory inside the NextBuildvN folder. A video demonstrating how to correctly setup up is available here : https://www.youtube.com/watch?v=kF_jfE7mAvg&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new .bas file in the Sources directory&lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&#039;!opt=4&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Your code here&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your .bas file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!org=nn || Program start address (24576-65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!heap=nn || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!opt=n || Optimization value (0-4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!bmp=filename || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!copy=filename || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!noemu || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!asm || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosys || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosp || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=File:VSCode_With_NextBuild.png&amp;diff=13543</id>
		<title>File:VSCode With NextBuild.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=File:VSCode_With_NextBuild.png&amp;diff=13543"/>
		<updated>2025-04-12T02:31:59Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Image showing Visual Studio Code with the NextBuild extension&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13542</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13542"/>
		<updated>2025-04-12T01:42:53Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* NOTE : This documentation is still in progress */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= NextBuild v8 =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with Boriel&#039;s ZX Basic compiler for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file. At the heart of the suite is the NextBuild Library, which facilitates communication directly with the ZX Nexts hardware through optimized assembly routines. Combine this ZX Basic compiler&#039;s compiled code produces blazingly fast professional results.&lt;br /&gt;
&lt;br /&gt;
Code is executed with Aspect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The IDE strongly recommended is Visual Studio Code, with setup being straightforward through automatically configured build scripts, tasks, and extensions. NextBuild has been designed to integrate tightly with VSCode. NextBuild will also operate faultlessly with AI editors such as Cursor.   &lt;br /&gt;
&lt;br /&gt;
Note, the ZX Basic has been tweaked slightly to work with nicely with the Next&#039;s HW. Special conditions are put in place to make sure interrupts or stack locations interfere when paging memory banks or using additional graphics modes. If the nextlib library is used outside the NextBuild suite, it is likely that you will experience issues.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Visual Studio Code (recommended IDE)&lt;br /&gt;
* NextBuild tools package (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new .bas file in the Sources directory&lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&#039;!opt=4&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Your code here&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your .bas file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!org=nn || Program start address (24576-65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!heap=nn || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!opt=n || Optimization value (0-4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!bmp=filename || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!copy=filename || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!noemu || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!asm || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosys || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosp || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13540</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13540"/>
		<updated>2025-04-12T01:33:33Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= NextBuild v8 =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with Boriel&#039;s ZX Basic compiler for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file.&lt;br /&gt;
&lt;br /&gt;
Code is executed with CSpect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The preferred IDE is Visual Studio Code, with setup being straightforward through automatically configured build scripts, tasks, and extensions.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Visual Studio Code (recommended IDE)&lt;br /&gt;
* NextBuild tools package (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new .bas file in the Sources directory&lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&#039;!opt=4&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Your code here&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your .bas file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!org=nn || Program start address (24576-65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!heap=nn || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!opt=n || Optimization value (0-4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!bmp=filename || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!copy=filename || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!noemu || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!asm || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosys || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosp || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BBREAK macros in your code or BREAK inside an asm block&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13539</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13539"/>
		<updated>2025-04-12T01:31:32Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Additional Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= NextBuild v8 =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with Boriel&#039;s ZX Basic compiler for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file.&lt;br /&gt;
&lt;br /&gt;
Code is executed with CSpect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The preferred IDE is Visual Studio Code, with setup being straightforward through automatically configured build scripts, tasks, and extensions.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Visual Studio Code (recommended IDE)&lt;br /&gt;
* NextBuild tools package (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new .bas file in the Sources directory&lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&#039;!opt=4&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Your code here&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your .bas file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!org=nn || Program start address (24576-65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!heap=nn || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!opt=n || Optimization value (0-4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!bmp=filename || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!copy=filename || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!noemu || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!asm || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosys || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosp || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BREAK or BBREAK macros in your code&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full ZX Basic Compiler command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* NextBuild Github [https://github.com/em00k/NextBuild]&lt;br /&gt;
* NextBuild command lookup [https://zxnext.uk/docs/]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13538</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13538"/>
		<updated>2025-04-12T01:07:40Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Manual Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Nextest-screenshot.png|right|600px]]&lt;br /&gt;
&lt;br /&gt;
= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
[[File:Nextest Joystick Detail.png|above|Joystick detail]]&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13537</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13537"/>
		<updated>2025-04-12T01:07:03Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Kempston Joystick */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Nextest-screenshot.png|right|600px]]&lt;br /&gt;
&lt;br /&gt;
= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
[[File:Nextest Joystick Detail.png|above|Joystick detail]]&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuild_Topics&amp;diff=13536</id>
		<title>NextBuild Topics</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuild_Topics&amp;diff=13536"/>
		<updated>2025-04-12T00:42:47Z</updated>

		<summary type="html">&lt;p&gt;Em00k: Created page with &amp;quot;= NextBuild Topics =  This page serves as a central hub for all NextBuild-related topics. Each section below links to detailed articles about specific aspects of developing fo...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= NextBuild Topics =&lt;br /&gt;
&lt;br /&gt;
This page serves as a central hub for all NextBuild-related topics. Each section below links to detailed articles about specific aspects of developing for the ZX Spectrum Next using NextBuild.&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
* [[NextBuild Installation and Setup]]&lt;br /&gt;
* [[Creating Your First NextBuild Project]]&lt;br /&gt;
* [[NextBuild Preprocessor Options]]&lt;br /&gt;
* [[Building and Running NextBuild Projects]]&lt;br /&gt;
* [[VSCode Integration and Tasks]]&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
&lt;br /&gt;
* [[Layer 2 Graphics in NextBuild]]&lt;br /&gt;
* [[Sprites and Animation]]&lt;br /&gt;
* [[Tile-Based Graphics]]&lt;br /&gt;
* [[Palette Management]]&lt;br /&gt;
* [[Drawing Text in Layer 2]]&lt;br /&gt;
* [[Advanced Drawing Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Audio ==&lt;br /&gt;
&lt;br /&gt;
* [[Sound Effects with AYFX]]&lt;br /&gt;
* [[Music with PT3 Format]]&lt;br /&gt;
* [[Setting Up Interrupt Mode 2 for Audio]]&lt;br /&gt;
* [[NextSID Audio Engine]]&lt;br /&gt;
* [[Mixing Music and Sound Effects]]&lt;br /&gt;
&lt;br /&gt;
== Input and Control ==&lt;br /&gt;
&lt;br /&gt;
* [[Keyboard Input in NextBuild]]&lt;br /&gt;
* [[Joystick and Gamepad Support]]&lt;br /&gt;
* [[Mouse Input]]&lt;br /&gt;
* [[Creating Responsive Controls]]&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
* [[Understanding MMU and Banking]]&lt;br /&gt;
* [[Memory Organization on the ZX Spectrum Next]]&lt;br /&gt;
* [[Efficient Memory Usage]]&lt;br /&gt;
* [[Working with Multiple Banks]]&lt;br /&gt;
&lt;br /&gt;
== File Operations ==&lt;br /&gt;
&lt;br /&gt;
* [[Loading and Saving to SD Card]]&lt;br /&gt;
* [[Working with NEX Files]]&lt;br /&gt;
* [[File Formats and Conversions]]&lt;br /&gt;
* [[Asset Management]]&lt;br /&gt;
&lt;br /&gt;
== Advanced Topics ==&lt;br /&gt;
&lt;br /&gt;
* [[Copper Effects and Raster Interrupts]]&lt;br /&gt;
* [[Optimizing NextBuild Code]]&lt;br /&gt;
* [[Assembly Language Integration]]&lt;br /&gt;
* [[DMA Operations]]&lt;br /&gt;
* [[NextBuild Debugging Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Game Development ==&lt;br /&gt;
&lt;br /&gt;
* [[Game Loop Structure]]&lt;br /&gt;
* [[Collision Detection]]&lt;br /&gt;
* [[Scrolling Backgrounds]]&lt;br /&gt;
* [[Sprite-Based Animation]]&lt;br /&gt;
* [[Game State Management]]&lt;br /&gt;
* [[Example Game Projects]]&lt;br /&gt;
&lt;br /&gt;
== Tools and Utilities ==&lt;br /&gt;
&lt;br /&gt;
* [[NextBuild Command Line Tools]]&lt;br /&gt;
* [[Asset Creation Tools]]&lt;br /&gt;
* [[Sprite and Tile Editors]]&lt;br /&gt;
* [[CSpect Emulator Features]]&lt;br /&gt;
* [[Converting Existing Assets]]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* [[NextLib Function Reference]]&lt;br /&gt;
* [[ZX Spectrum Next Hardware Registers]]&lt;br /&gt;
* [[NextBuild Preprocessor Reference]]&lt;br /&gt;
* [[Common Error Messages and Solutions]]&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
* [[Creating a Simple Platform Game]]&lt;br /&gt;
* [[Building a Scrolling Shooter]]&lt;br /&gt;
* [[Text Adventure Development]]&lt;br /&gt;
* [[Creating Special Effects]]&lt;br /&gt;
* [[Optimizing Performance]]&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13535</id>
		<title>NextBuildStudio:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextBuildStudio:Main_Page&amp;diff=13535"/>
		<updated>2025-04-12T00:35:57Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= NextBuild v8 =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== NOTE : This documentation is still in progress ===&lt;br /&gt;
&lt;br /&gt;
NextBuild is a collection of tools and libraries which works with Boriel&#039;s ZX Basic compiler for working with the ZX Spectrum Next. Version 8 introduces significant changes, including NEX file generation that contains all your assets in a single file.&lt;br /&gt;
&lt;br /&gt;
Code is executed with CSpect emulator written by Mike Dailly [https://mdf200.itch.io/cspect].&lt;br /&gt;
&lt;br /&gt;
The preferred IDE is Visual Studio Code, with setup being straightforward through automatically configured build scripts, tasks, and extensions.&lt;br /&gt;
&lt;br /&gt;
== Setup Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Visual Studio Code (recommended IDE)&lt;br /&gt;
* NextBuild tools package (includes Boriel ZX Basic, CSpect emulator, and NextBuild scripts)&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
# Clone or download the NextBuild repository&lt;br /&gt;
# Open the project folder in Visual Studio Code&lt;br /&gt;
# Install recommended extensions:&lt;br /&gt;
#* em00k.nextbuild&lt;br /&gt;
#* eliverlara.andromeda&lt;br /&gt;
#* maziac.nex-fileviewer&lt;br /&gt;
#* maziac.asm-code-lens&lt;br /&gt;
#* alefragnani.bookmarks&lt;br /&gt;
#* commandvariable.dateTime&lt;br /&gt;
&lt;br /&gt;
== Project Structure ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/NextBuild&lt;br /&gt;
├── zxbasic/         (Boriel ZX Basic compiler)&lt;br /&gt;
├── Emu/             (CSpect emulator)&lt;br /&gt;
│   └── CSpect/      &lt;br /&gt;
├── Scripts/         (NextBuild python scripts)&lt;br /&gt;
├── Sources/         (Main sources folder)&lt;br /&gt;
│   ├── examples/    (Example code)&lt;br /&gt;
    └───└── data/     (Assets: sprites, sounds, etc.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating Your First Project ==&lt;br /&gt;
&lt;br /&gt;
# Create a new .bas file in the Sources directory&lt;br /&gt;
# Add the following template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&#039;!opt=4&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Your code here&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Main loop&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; from the Terminal menu to compile&lt;br /&gt;
&lt;br /&gt;
== Preprocessor Options ==&lt;br /&gt;
&lt;br /&gt;
These options are set at the top of your .bas file:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!org=nn || Program start address (24576-65530) || 32768&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!heap=nn || Heap size in bytes || 2048&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!opt=n || Optimization value (0-4) || 4&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!bmp=filename || BMP loading screen for NEX || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!copy=filename || Copy NEX file to specified path || None&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!noemu || Do not launch emulator after compilation || Emulator launches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!asm || Produce ASM output only || NEX file created&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosys || Do not include system variables || Include sysvars&lt;br /&gt;
|-&lt;br /&gt;
| &#039;!nosp || Do not set up stack pointer || Set up SP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== NextLib Library ==&lt;br /&gt;
&lt;br /&gt;
NextLib provides functions to access ZX Spectrum Next hardware features.&lt;br /&gt;
&lt;br /&gt;
=== SD Card Access ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Load data from SD card to a memory bank&lt;br /&gt;
LoadSDBank(filename$, address, size, offset, bank)&lt;br /&gt;
&#039; Load from SD to memory address&lt;br /&gt;
LoadSD(filename$, address, size, offset)&lt;br /&gt;
&#039; Save from memory to SD card&lt;br /&gt;
SaveSD(filename$, address, size)&lt;br /&gt;
&#039; Load a BMP file to Layer 2&lt;br /&gt;
LoadBMP(filename$)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layer 2 Graphics ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Enable/disable Layer 2&lt;br /&gt;
ShowLayer2(n)  &#039; 0=off, 1=on&lt;br /&gt;
&#039; Clear Layer 2 with color&lt;br /&gt;
CLS256(color)&lt;br /&gt;
&#039; Scroll Layer 2&lt;br /&gt;
ScrollLayer(x, y)&lt;br /&gt;
&#039; Set clipping regions&lt;br /&gt;
ClipLayer2(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerULA(x1, x2, y1, y2)&lt;br /&gt;
ClipLayerTile(x1, x2, y1, y2)&lt;br /&gt;
ClipSprite(x1, x2, y1, y2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Draw a 16x16 tile from bank&lt;br /&gt;
DoTileBank16(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw an 8x8 tile from bank&lt;br /&gt;
DoTileBank8(x, y, tile_number, bank_number)&lt;br /&gt;
&#039; Draw a tile in 320x256 mode&lt;br /&gt;
FDoTileBank8(y, x, tile_number, bank_number)&lt;br /&gt;
FDoTileBank16(y, x, tile_number, bank_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pixel Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (256x192)&lt;br /&gt;
PlotL2(x, y, color)&lt;br /&gt;
&#039; Plot a pixel in Layer 2 (320x256)&lt;br /&gt;
FPlotL2(x, y, color)&lt;br /&gt;
&#039; Draw text on Layer 2&lt;br /&gt;
L2Text(x, y, string$, bank, mask)&lt;br /&gt;
FL2Text(x, y, string$, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palette Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Upload a palette&lt;br /&gt;
PalUpload(address, colors_count, offset, bank)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sprite Operations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize sprites&lt;br /&gt;
InitSprites(total, sprite_address)&lt;br /&gt;
InitSprites2(total, sprite_address, bank, sprite_offset)&lt;br /&gt;
&#039; Update sprite parameters&lt;br /&gt;
UpdateSprite(x, y, sprite_id, pattern, mirror_flip, anchor)&lt;br /&gt;
&#039; Remove a sprite&lt;br /&gt;
RemoveSprite(sprite_id, visible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Memory Management ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Get/set MMU banks&lt;br /&gt;
MMU8(slot, bank)&lt;br /&gt;
MMU16(bank)&lt;br /&gt;
GetMMU(slot)&lt;br /&gt;
GetReg(register)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Timing and Synchronization ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Wait for vertical retrace&lt;br /&gt;
WaitRetrace(frames)&lt;br /&gt;
WaitRetrace2(line_number)&lt;br /&gt;
&#039; Wait for key press&lt;br /&gt;
WaitKey()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Music and Sound Effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; Initialize music player&lt;br /&gt;
InitMusic(player_bank, music_bank, music_offset)&lt;br /&gt;
&#039; Initialize sound effects&lt;br /&gt;
InitSFX(bank)&lt;br /&gt;
&#039; Set up interrupt mode&lt;br /&gt;
SetUpIM()&lt;br /&gt;
&#039; Control sound&lt;br /&gt;
EnableSFX&lt;br /&gt;
DisableSFX&lt;br /&gt;
EnableMusic&lt;br /&gt;
DisableMusic&lt;br /&gt;
&#039; Play a sound effect&lt;br /&gt;
PlaySFX(effect_number)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Memory Management ==&lt;br /&gt;
&lt;br /&gt;
=== MMU Slots ===&lt;br /&gt;
&lt;br /&gt;
The ZX Spectrum Next divides its memory into 8KB slots that can be mapped to different banks:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Address Range !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| $0000-$1fff || Slot 0 || ROM (255) || Normally ROM. Writes mappable by layer 2. IRQ and NMI routines here.&lt;br /&gt;
|-&lt;br /&gt;
| $2000-$3fff || Slot 1 || ROM (255) || Normally ROM. Writes mapped by Layer 2.&lt;br /&gt;
|-&lt;br /&gt;
| $4000-$5fff || Slot 2 || 10 || Normally used for normal/shadow ULA screen.&lt;br /&gt;
|-&lt;br /&gt;
| $6000-$7fff || Slot 3 || 11 || Timex ULA extended attribute/graphics area.&lt;br /&gt;
|-&lt;br /&gt;
| $8000-$9fff || Slot 4 || 4 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $a000-$bfff || Slot 5 || 5 || Free RAM.&lt;br /&gt;
|-&lt;br /&gt;
| $c000-$dfff || Slot 6 || 0 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|-&lt;br /&gt;
| $e000-$ffff || Slot 7 || 1 || Free RAM. Only this area is remappable by 128 memory management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== RAM Banks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16kb      8kb &lt;br /&gt;
 8-15      16-31       $060000-$07ffff 128K    Extra RAM&lt;br /&gt;
16-47      32-95       $080000-$0fffff 512K    1st extra IC RAM (available on unexpanded Next)&lt;br /&gt;
48-79      96-159  $100000-$17ffff 512K    2nd extra IC RAM (only available on expanded Next)&lt;br /&gt;
80-111    160-223  $180000-$1fffff 512K    3rd extra IC RAM (only available on expanded Next)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== NEX File Format ==&lt;br /&gt;
&lt;br /&gt;
The NEX file is a container that holds your program and all assets in a single file. It is created automatically during the build process.&lt;br /&gt;
&lt;br /&gt;
=== Configuration Options ===&lt;br /&gt;
&lt;br /&gt;
The NEX file configuration is generated from preprocessor directives in your source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768     &#039; Program start address&lt;br /&gt;
&#039;!bmp=intro.bmp &#039; Loading screen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending With Interrupt Mode 2 ==&lt;br /&gt;
&lt;br /&gt;
For advanced applications requiring sound and music, you can enable Interrupt Mode 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#define IM2&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib_ints.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
InitSFX(36)                 &#039; SFX bank&lt;br /&gt;
InitMusic(38, 39, 0000)     &#039; Player bank, music bank, offset&lt;br /&gt;
SetUpIM()                   &#039; Set up IM2&lt;br /&gt;
EnableSFX                   &#039; Enable SFX playback&lt;br /&gt;
EnableMusic                 &#039; Enable music playback&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Drawing a Sprite ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
#include &amp;lt;keys.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load sprites from SD card to bank 34&lt;br /&gt;
LoadSDBank(&amp;quot;testsprites.spr&amp;quot;, 0, 0, 0, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Set up banks and initialize sprites&lt;br /&gt;
asm&lt;br /&gt;
    nextreg $56, 34&lt;br /&gt;
    nextreg $57, 35&lt;br /&gt;
end asm&lt;br /&gt;
&lt;br /&gt;
InitSprites2(64, $c000, 34)&lt;br /&gt;
&lt;br /&gt;
&#039; Main loop&lt;br /&gt;
do&lt;br /&gt;
    &#039; Update sprite at position 100,100&lt;br /&gt;
    UpdateSprite(100, 100, 0, 0, 0, 128)&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tile-Based Game Screen ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=32768&lt;br /&gt;
&#039;!heap=2048&lt;br /&gt;
&lt;br /&gt;
#define NEX&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039; Load tile data&lt;br /&gt;
LoadSDBank(&amp;quot;tiles.spr&amp;quot;, 0, 0, 0, 36)&lt;br /&gt;
&lt;br /&gt;
&#039; Clear Layer 2&lt;br /&gt;
CLS256(0)&lt;br /&gt;
ShowLayer2(1)&lt;br /&gt;
&lt;br /&gt;
&#039; Draw a 16x16 tilemap&lt;br /&gt;
dim map(16, 12) as ubyte&lt;br /&gt;
&lt;br /&gt;
&#039; Initialize map with tile numbers&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        &#039; Set tile numbers (0-63)&lt;br /&gt;
        map(x, y) = (x + y) mod 64&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
&#039; Draw the map&lt;br /&gt;
for y = 0 to 11&lt;br /&gt;
    for x = 0 to 15&lt;br /&gt;
        DoTileBank16(x, y, map(x, y), 36)&lt;br /&gt;
    next x&lt;br /&gt;
next y&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
    &#039; Game loop&lt;br /&gt;
    WaitRetrace(1)&lt;br /&gt;
loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loading from SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039; NextBuild simple load from SD card&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
border 2: paper 0 : ink 0 : cls&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,size,offset)&lt;br /&gt;
ShowLayer2(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    LoadSD(&amp;quot;screen2.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
    border 0&lt;br /&gt;
    pause 100&lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Saving to SD Card ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dim n as ubyte &lt;br /&gt;
&lt;br /&gt;
paper 7: ink 0: border 7: cls &lt;br /&gt;
&lt;br /&gt;
print ink 1;&amp;quot;Lets print some text..&amp;quot; : pause 50 : cls &lt;br /&gt;
&lt;br /&gt;
for n = 0 to 22&lt;br /&gt;
    print &amp;quot;HELLO THERE WORLD ! ! ! ! ! !&amp;quot;&lt;br /&gt;
    ink rnd*7&lt;br /&gt;
next &lt;br /&gt;
&lt;br /&gt;
&#039; SaveSD(filename,address,number of bytes)&lt;br /&gt;
&#039; lets save the screen &lt;br /&gt;
SaveSD(&amp;quot;output.scr&amp;quot;,16384,6912)&lt;br /&gt;
&lt;br /&gt;
pause 100 : cls&lt;br /&gt;
print ink 1;&amp;quot;Screen saved to SD..&amp;quot;&lt;br /&gt;
print ink 1;&amp;quot;Lets load it back..&amp;quot;&lt;br /&gt;
pause 100&lt;br /&gt;
&lt;br /&gt;
&#039; LoadSD(filename,address,number of bytes,offset)&lt;br /&gt;
LoadSD(&amp;quot;output.scr&amp;quot;,16384,6912,0)&lt;br /&gt;
&lt;br /&gt;
border 1 : pause 0 &lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
loop &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Layer 2 Image Drawing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
&#039;!org=24576&lt;br /&gt;
&#039; NextBuild Layer2 Template &lt;br /&gt;
&lt;br /&gt;
#define NEX &lt;br /&gt;
#define IM2 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nextlib.bas&amp;gt;&lt;br /&gt;
&lt;br /&gt;
asm &lt;br /&gt;
    &#039; setting registers in an asm block means you can use the global equs for register names &lt;br /&gt;
    &#039; 28mhz, black transparency,sprites on over border,320x256&lt;br /&gt;
    nextreg TURBO_CONTROL_NR_07,%11         &#039; 28 mhz &lt;br /&gt;
    nextreg GLOBAL_TRANSPARENCY_NR_14,$0    &#039; black &lt;br /&gt;
    nextreg SPRITE_CONTROL_NR_15,%00000011  &#039; %000    S L U, %11 sprites on over border&lt;br /&gt;
    nextreg LAYER2_CONTROL_NR_70,%00000000  &#039; 5-4 %01 = 320x256x8bpp&lt;br /&gt;
end asm &lt;br /&gt;
&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-win.raw&amp;quot;,0,0,0,32)       &#039; load in pirate 1&lt;br /&gt;
LoadSDBank(&amp;quot;pirate-loss.raw&amp;quot;,4096,0,0,32)   &#039; load in pirate 2&lt;br /&gt;
&lt;br /&gt;
Cls256(0)&lt;br /&gt;
&lt;br /&gt;
do &lt;br /&gt;
    DrawImage(0,0,@image_pirate,0)          &#039; frame 0 pirate 1&lt;br /&gt;
    WaitKey()&lt;br /&gt;
    DrawImage(0,0,@image_pirate,1)          &#039; frame 1 pirate 2&lt;br /&gt;
    WaitKey()&lt;br /&gt;
loop &lt;br /&gt;
&lt;br /&gt;
image_pirate:&lt;br /&gt;
    asm&lt;br /&gt;
        &#039; bank  spare  &lt;br /&gt;
        db  32, 64, 64&lt;br /&gt;
        &#039; offset in bank  &lt;br /&gt;
        dw 2&lt;br /&gt;
    end asm &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File Formats ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite Files (.spr) ===&lt;br /&gt;
Binary files containing sprite data. Each 16x16 sprite uses 256 bytes (or 128 bytes for 4-bit sprites).&lt;br /&gt;
&lt;br /&gt;
=== Palette Files (.pal) ===&lt;br /&gt;
Color palette data files.&lt;br /&gt;
&lt;br /&gt;
=== Audio Files ===&lt;br /&gt;
* .afb: AYFX sound effects bank&lt;br /&gt;
* .pt3: ProTracker 3 music files&lt;br /&gt;
&lt;br /&gt;
== Building and Running ==&lt;br /&gt;
&lt;br /&gt;
# Press Ctrl+Shift+B or select &amp;quot;Run Build Task&amp;quot; to compile your project&lt;br /&gt;
# If compilation succeeds, CSpect emulator will launch with your program&lt;br /&gt;
# Press ESC to exit CSpect (F1 enters the debugger)&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
&lt;br /&gt;
# Press F1 in CSpect to enter the debugger&lt;br /&gt;
# Use the Memory window to inspect memory contents&lt;br /&gt;
# Set breakpoints with the BREAK or BBREAK macros in your code&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
&lt;br /&gt;
* Full NextLib command reference: [https://zxbasic.readthedocs.io/en/docs ZX Basic Documentation]&lt;br /&gt;
* ZX Spectrum Next Hardware Manual for detailed hardware specifications&lt;br /&gt;
* Example programs in the Sources/examples directory&lt;br /&gt;
&lt;br /&gt;
== Common Issues and Solutions ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Compilation Error&#039;&#039;&#039;: Check the COMPILE.TXT file for error details&lt;br /&gt;
* &#039;&#039;&#039;Bank Conflicts&#039;&#039;&#039;: Ensure you&#039;re not using overlapping memory banks&lt;br /&gt;
* &#039;&#039;&#039;Graphics Issues&#039;&#039;&#039;: Check palette settings and Layer 2 initialization&lt;br /&gt;
* &#039;&#039;&#039;Sound Not Working&#039;&#039;&#039;: Verify IM2 is properly set up and banks are correct&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
NextBuild would not exist without the help of many contributors including:&lt;br /&gt;
* Jose Rodrigez / Boriel&lt;br /&gt;
* Mike Dailly&lt;br /&gt;
* D Rimron Soutter&lt;br /&gt;
* Robin Van HagenGuest&lt;br /&gt;
* Michael Flash Ware&lt;br /&gt;
* Kev 9bitColor Brady&lt;br /&gt;
* Jim Bagley&lt;br /&gt;
* Dufectu&lt;br /&gt;
* sol_hsa&lt;br /&gt;
* ped7g&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Talk:Main_Page&amp;diff=13534</id>
		<title>Talk:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Talk:Main_Page&amp;diff=13534"/>
		<updated>2025-04-11T22:51:49Z</updated>

		<summary type="html">&lt;p&gt;Em00k: Created page with &amp;quot;Added the link under the FAQ heading, as it can appear that clicking &amp;quot;FAQ&amp;quot; in the contents can look like the current page is the FAQ.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Added the link under the FAQ heading, as it can appear that clicking &amp;quot;FAQ&amp;quot; in the contents can look like the current page is the FAQ.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=Main_Page&amp;diff=13533</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=Main_Page&amp;diff=13533"/>
		<updated>2025-04-11T22:50:24Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* FAQ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== References ==&lt;br /&gt;
&lt;br /&gt;
=== [[FAQ]] === &lt;br /&gt;
&lt;br /&gt;
[[FAQ|Click here to go to the FAQ page]]&lt;br /&gt;
&lt;br /&gt;
=== System architecture ===&lt;br /&gt;
* [[Specifications]]&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]] (NextRegs) and port list&lt;br /&gt;
* [[Interrupts]]&lt;br /&gt;
* [[RPi0 Acceleration]]&lt;br /&gt;
* [[DMA|zxnDMA]]&lt;br /&gt;
* [[CTC]]&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 | Enhanced ULA 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;
* [[Refresh Rates]]&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;
* [https://gitlab.com/thesmog358/tbblue TBBlue Official Distribution git repository]&lt;br /&gt;
* [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/tree/master Official Next Core git repository]&lt;br /&gt;
* [[NextZXOS]]&lt;br /&gt;
* [[ESXDOS]]&lt;br /&gt;
* [[NextBASIC]]&lt;br /&gt;
* [[System Variables]]&lt;br /&gt;
* [[API|esxDOS and NextZXOS APIs]]&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;
* [[Audio_/_Music | Audio/Music]]&lt;br /&gt;
* [[Miscellaneous]]&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;
* [[RPi0_Acceleration| Accelerator - Raspberry Pi Zero]]&lt;br /&gt;
* [[ESP8266-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;
=== Peripherals ===&lt;br /&gt;
&lt;br /&gt;
* [[Mouse]]&lt;br /&gt;
* [https://gitlab.com/thesmog358/tbblue/-/blob/master/docs/extra-hw/pinouts/pinouts.txt Pinouts (Joystick / VGA / GPIO / Daugherboard / Beeper]&lt;br /&gt;
&lt;br /&gt;
=== Classic Peripheral Information ===&lt;br /&gt;
&lt;br /&gt;
* [[esxDOS together with Interface 1]]&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://discordapp.com/invite/HdRvZVw Discord chat]&lt;br /&gt;
* [https://www.specnext.com/ Official site]&lt;br /&gt;
* [https://wiki.specnext.dev/ZX_Next_Clones Running the Next core on ZX Next clones]&lt;br /&gt;
&lt;br /&gt;
= Sources =&lt;br /&gt;
* [[Bibliography]]&lt;br /&gt;
&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>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13532</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=FAQ&amp;diff=13532"/>
		<updated>2025-04-11T22:43:43Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* My internal keyboard is not responding – help! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== I am using HDMI and I get no picture ==&lt;br /&gt;
When the Next boots hold down D for DIGITAL (HDMI) – Mode 7 50hz / 60hz can be selected. N selects the next frequency, ENTER selects it and saves. ONLY PRESS ENTER if you actually see a screen like the one below. N is NOT necessary as the testscreen will automatically go to the next mode albeit slower.&lt;br /&gt;
[[File:Figure02-TestScreenMode7.png|thumb|ZX Spectrum Next Test Screen]]&lt;br /&gt;
&lt;br /&gt;
You will also get an audible intermittent tone so you know your audio is working. It&#039;s possible your display can lock onto both modes but only one being able to lock onto the audio. Choose the one with the tone before pressing ENTER. Extract the files and copy over the BIN / SYS/ TMP folders to the root of your SD.&lt;br /&gt;
&lt;br /&gt;
== How to use esxDOS with 48K mode ==&lt;br /&gt;
[[File:2023-12-17 21 01 56-Window.png|thumb|esxDOS files]]&lt;br /&gt;
Your ZX Next can simulate the divMMC hardware for other machines. You can use esxDOS with 128/48K machines. You can download the latest esxDOS zip file here https://esxdos.org/index.html Download the zip and copy over the following folders BIN/SYS/TMP.&lt;br /&gt;
&lt;br /&gt;
You will need to place the ESXMMC.BIN in to /machines/next/roms&lt;br /&gt;
&lt;br /&gt;
Boot up your Next and press SPACE to open the configuration menu. Use the arrow keys to select 48K Mode, SPACE again and ensure DIVmmc ROM = YES. Exit and save this configuration. When your Next boots it should show the esxDOS logo just before the (c)1982 Sinclair Research Ltd message.&lt;br /&gt;
&lt;br /&gt;
[[ESXDOS|Further information can be found here]]&lt;br /&gt;
&lt;br /&gt;
[[File:Pre boot machine select menu.png|thumb]]&lt;br /&gt;
[[File:2023-12-17 21 21 11-OBS 30.0.0 - Profile Untitled - Scenes Untitled.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
== I am using VGA and I get no picture ==&lt;br /&gt;
When the Next boots hold down V for VGA – Mode 0-6 50hz / 60hz can be selected. VGA0 is the&lt;br /&gt;
preferred mode as this has accurate timings. 1 – 6 are also accurate timings but increase slightly&lt;br /&gt;
in speed. N works as above but there are 12 possible configurations you can choose from. You&#039;ll start at VGA0@50Hz, next one will be the same at 60Hz and so forth. ENTER again selects and saves the changes. Audio is also being produced during the VGA Test Screen phase, however you will need powered speakers (or earphones) plugged in the audio out connector at the back of your Next.&lt;br /&gt;
&lt;br /&gt;
== I&#039;m using an HDMI display and a game&#039;s graphics appear garbled ==&lt;br /&gt;
Some games (specifically ones with multicolour or border effects - eg. Nirvana/Bifrost engine games, certain demos particularly ex-Soviet demoscene ones) require precise timings as with a regular Spectrum. Due to the nature of HDMI displays and the lack of internal buffering on the Spectrum Next display hardware currently these will not work properly and require a VGA or RGB display. &lt;br /&gt;
This is expected to be fixed in a future edition of the core/distribution but until then, there are a few alternative solutions:&lt;br /&gt;
a. An extra Spectrum core that implements precise HDMI timings by removing some of the Next&#039;s extra features. &lt;br /&gt;
b. Use of OSSC hardware which takes the Next&#039;s RGB/VGA display and converts it to HDMI independently&lt;br /&gt;
c. Use of the ZXHD or TkPie hardware expansions (only for standard Spectrum modes at 3.5MHz clock) &lt;br /&gt;
Next specific programs do not have this issue as they&#039;re made taking the current HDMI timing differences into account and will continue to work in the future when the most appropriate HDMI solution is implemented.&lt;br /&gt;
&lt;br /&gt;
== I am updating to the latest distro from GitLab or the N-Go website and my ps/2 keyboard doesn&#039;t work ==&lt;br /&gt;
To use a ps/2 keyboard you need to first choose whether you have a mouse or keyboard plugged into your ps/2 port. Unfortunately you can&#039;t get to the screen where you can make this choice &#039;&#039;until&#039;&#039; you have chosen your video mode on the testcard screen... which &#039;&#039;needs&#039;&#039; the keyboard to be already working!  &lt;br /&gt;
&lt;br /&gt;
Download this minimal config.ini file [https://dl.dropbox.com/s/5na7sd21328jnz5/CONFIG.INI] and copy it to the &#039;&#039;&#039;/Machines/Next&#039;&#039;&#039; folder on your SD card, then try again.&lt;br /&gt;
&lt;br /&gt;
When updating your distro from the official [[https://www.specnext.com/latestdistro/ Latest Distro]] page, or when using the internal keyboard on your official kickstarter 1 or 2 Next, this problem will not occur.&lt;br /&gt;
&lt;br /&gt;
== My monitor shows wrong image with Soviet timings(Pentagon)  ==&lt;br /&gt;
Pentagon has a non-standard screen refresh rate of 48.828Hz, some monitors do not support it. In some cases, can help manual picture settings in menu of your monitor. &lt;br /&gt;
Another solution to the issue is to buy a monitor that is compatible with Pentagon timings. User-generated list of compatible monitors located here: http://www.nedopc.com/zxevo/zxevo_supported_monitors.pdf&lt;br /&gt;
As a rule, monitors from this list are available on the secondary market at a low cost. Before purchasing desirable testing monitor with Pentagon mode.&lt;br /&gt;
&lt;br /&gt;
== HELP! My &amp;lt;insert game name here&amp;gt; doesn&#039;t work while it works on my &amp;lt;insert older Spectrum model here&amp;gt; ==&lt;br /&gt;
This is most likely due to a specific incompatibility of said program with the Next&#039;s extra hardware. The NextZXOS loader module, provides a lot of options for loading software catering to each model&#039;s idiosyncracies but also gives you the option to disable almost all Next extra hardware in order to make it work. If, after trying everything, the software doesn&#039;t work, you need to inform the team using the official gitlab repo &amp;quot;Issues&amp;quot; (registration is required) and provide a link to a copy of your program. The team will look at the specific issue and respond/fix the issue as soon as possible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What classic files can I load on my Next? ==&lt;br /&gt;
The Next supports NEXs, TAPs (preferred for classic software), SNAs, DSKs, Z80s, SNXs which can be loaded from the browser&lt;br /&gt;
menu by selecting them with the cursor keys and ENTER (or a joystick and Fire) -OR- by using the SPECTRUM command. (See Chapter 20 in the manual for details).&lt;br /&gt;
Place the files on your SD card and pick from the Browser.&lt;br /&gt;
&lt;br /&gt;
== How to load from a software cassette tape ==&lt;br /&gt;
For a successful load a clear signal from the player has to arrive on the &amp;quot;ring&amp;quot; part of the plug which you insert in the EAR/MIC socket of your Next, as in the picture &amp;quot;Next&#039;s EAR/MIC socket wiring&amp;quot;.&lt;br /&gt;
[[File:Ear-mic-socket-1.png|thumb|Next&#039;s EAR/MIC socket wiring]]&lt;br /&gt;
The plug inserted into the Next is referred to in many descriptions as a &amp;quot;3.5mm stereo plug&amp;quot;. Even if the Next always uses a single channel to load, the plug on its side has to be the same as those used for stereo (two channel) equipment, because, as stated, it then receives the signal over the &amp;quot;ring&amp;quot;, which doesn&#039;t exist on &amp;quot;mono&amp;quot; plugs. That&#039;s also why the cables delivered with the Spectrum 128 and earlier models won&#039;t work: their both sides lack the ring on their plugs.&lt;br /&gt;
&lt;br /&gt;
So the cable on the Next&#039;s side needs a 3.5mm plug commonly described as a &amp;quot;stereo&amp;quot; plug. The other side will depend on the output socket on your cassette player.&lt;br /&gt;
&lt;br /&gt;
[[File:Spectrum-plus-3-tape-lead.jpg|thumb|ZX Spectrum Next/+3 Tape Lead]]&lt;br /&gt;
&lt;br /&gt;
To load from a player with a &#039;&#039;mono earphone&#039;&#039; socket: you can try to use, if you have it, a cable made for Spectrum +3 or later (see the picture: &amp;quot;ZX Spectrum Next/+3 Tape Lead&amp;quot;), or, you can try to obtain an [https://store.activeconsult.co.uk/shop?olsPage=products%2Fear-mic-cable&amp;amp;page=2 &amp;quot;Ear/Mic Cable&amp;quot;], or, as a possible substitution, a TRS stereo cable and a fitting stereo to mono adapter.&lt;br /&gt;
&lt;br /&gt;
All other scenarios need different solutions. Often, if the player has a 3.5mm &#039;&#039;stereo&#039;&#039; socket and the signal on its right channel sounds good, then a plain TRS cable with 3.5mm plugs on both sides could work (in TRS, the T stands for the &amp;quot;tip&amp;quot; and the R for the &amp;quot;ring&amp;quot; of the plug). Otherwise, including in the case where you want to connect a mono socket from the player and you can&#039;t obtain or use the linked &amp;quot;Ear/Mic Cable&amp;quot;, the rule is still: the Next needs a clear and strong signal on its &amp;quot;ring&amp;quot; connection. The standard for analog stereo and AV cables or adapters which split the &amp;quot;stereo&amp;quot; side to separate channels on another side is to call the separated audio channels the left and the right channel and to assign white and red color to them, respectively. On those, the &#039;&#039;Red&#039;&#039; one is the one connected to the &#039;&#039;Ring&#039;&#039; needed by ZX Spectrum Next when loading. (Note 1: Memory aid: R-R-R, red-ring-right) (Note 2: Typically, the splitters to mono signals will have bigger sockets or plugs, called RCA: unless sockets on the player match, one splitter won&#039;t be the enough to construct the whole solution, but two can be combined, the second used to lead two, still separate, signals to a single multi-channel plug. A splitter allows to try which of the two channels from a stereo player has a better signal). (Note 3: when orienting the common splitters, the color mark from the historic +3 cable picture should be ignored: even if that cable is also a splitter, differently from the &amp;quot;stereo&amp;quot; convention, on it, the black side is the &amp;quot;right&amp;quot; one).&lt;br /&gt;
&lt;br /&gt;
NextZXOS provides a Tape Tester in the main menu of NextZXOS – Select More and Tape Tester. It can help once you already have a signal but need to find the best volume or, in some cases, adjust the azimuth. Once you are ready to load a real tape choose the Tape Loader and press PLAY on your player.&lt;br /&gt;
&lt;br /&gt;
== How can I load TZX files? ==&lt;br /&gt;
TZX files can be loaded if you have a pi0 or an external TZX player. If you have a pi0 please see&lt;br /&gt;
below for more information. Before asking for help please have this information ready&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My LED does not go out when I unplug the power! ==&lt;br /&gt;
&lt;br /&gt;
[[File:Next HDMI PSU.jpg|thumb|Remove ALL cables]]&lt;br /&gt;
Some TVs will back-power the Next through the HDMI cable, so it’s important to &#039;&#039;&#039;REMOVE ALL CABLES&#039;&#039;&#039; after a firmware&lt;br /&gt;
update and to turn off completely. If your TV/Display has multiple inputs try using one of the other ones as usually NOT ALL HDMI ports exhibit this behaviour.&lt;br /&gt;
&lt;br /&gt;
The back-power situation also happened in one case with I/O serial cable used at joystick port, general rule seems to be &amp;quot;if it has own power, and is connected to Next, it may back-power it&amp;quot; - in case of problems to power-cycle the Next properly, unplug all such cables/peripherals first and try again.&lt;br /&gt;
&lt;br /&gt;
== How do I update my Next? ==&lt;br /&gt;
Latest stable distro is [https://www.specnext.com/latestdistro/ here]. To update your Next, extract the contents of the distro to your SD card. Power down the Next,&lt;br /&gt;
Press and hold U and power on until you see the Updater screen and follow the instructions. As&lt;br /&gt;
above if you are using HDMI you need to remove all cables when instructed to power off your&lt;br /&gt;
Next.&lt;br /&gt;
&lt;br /&gt;
You can also read [https://www.specnext.com/forum/viewtopic.php?p=13644 this forum post] by Allen with greater detail about the update process.&lt;br /&gt;
&lt;br /&gt;
You may occasionally be directed to download the latest versions from gitlab [https://gitlab.com/thesmog358/tbblue here]. Sometimes this is desirable if you&#039;re being asked to test a specific fix or recent hardware features.&lt;br /&gt;
&lt;br /&gt;
== My SD card is not recognized by my Next during boot ==&lt;br /&gt;
The Next supports FAT32 (including long filenames), FAT16 and FAT12. It does &#039;&#039;&#039;not&#039;&#039;&#039; support exFAT, NTFS, AFS or ext formats. Some disk formatters, such as the Windows GUI formatter and the SD Association Formatter, force exFAT for SD cards 32GB or larger, and will &#039;&#039;&#039;not&#039;&#039;&#039; let you format with FAT32. On Windows, format with &amp;lt;code&amp;gt;format x: /FS:FAT32&amp;lt;/code&amp;gt; using the command line (where x: is the drive letter your card is mounted as).&lt;br /&gt;
&lt;br /&gt;
== How do I update the Pi in my Next (NextPi)? ==&lt;br /&gt;
NextPi that came with KS1 and requires a 1GB SD card can be downloaded [https://zx.xalior.com/NextPi/ here], and you can use [https://www.balena.io/etcher/ Etcher]. For NextPi2 (recommended) you will require a 16GB SD card and can download from [https://zx.xalior.com/NextPi2 here.]&lt;br /&gt;
&lt;br /&gt;
== I have a pi0 but cannot get TZXs to load ==&lt;br /&gt;
You will require a new updated &#039;&#039;&#039;dot/pisend&#039;&#039;&#039; and &#039;&#039;&#039;nextzxos/tzxload.bas&#039;&#039;&#039; from the&lt;br /&gt;
[https://gitlab.com/thesmog358/tbblue git repository]. These need to be placed in the correct folders on your SD&lt;br /&gt;
card. These files have updated after the distro was released.&amp;lt;br&amp;gt;&lt;br /&gt;
You can check if the pi0 is correctly responding by going into Command Line and running “.term”&lt;br /&gt;
You should see Terminex, press SYM+SHIFT+B to switch to 115,200 baud and press Enter. If you&lt;br /&gt;
see the words “SUP&amp;amp;gt;” then your pi0 is ready. You can quit Terminex by pressing SYM+SHIFT+Q&lt;br /&gt;
&lt;br /&gt;
To load a TZX, place some TZX files on your SD card and you should be able to select the files&lt;br /&gt;
from the Browser and the Next should do the rest. If you come across a game that doesn’t work&lt;br /&gt;
please let us know.&lt;br /&gt;
&lt;br /&gt;
I have problems loading TZXs:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Are you on the latest core / NextZXOS?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you updated to the latest git distro? [https://gitlab.com/thesmog358/tbblue/-/archive/master/tbblue-master.zip git repository]&amp;lt;br&amp;gt;&lt;br /&gt;
What video mode are you using? (VGA0/HDMI etc)&amp;lt;br&amp;gt;&lt;br /&gt;
What game didn&#039;t work? (You need to supply the exact name)&amp;lt;br&amp;gt;&lt;br /&gt;
Where did the loading fail? Did the game load fine but crash etc?&amp;lt;br&amp;gt;&lt;br /&gt;
Have you left something plugged into the EAR port?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I sort the contents of my SD card? ==&lt;br /&gt;
On NextZXOS 2.07 and above, the browser can sort files dynamically. Press O to toggle between ordering by date, size and none. Press + (SYM+K) to toggle between ascending and descending order.&lt;br /&gt;
&lt;br /&gt;
For esxDOS or older versions of NextZXOS, you will need to use a tool on a PC such as [http://www.anerty.net/software/file/DriveSort/?lang=en DriveSort] (Windows) or [https://fatsort.sourceforge.io/ FatSort] (cross OS compatible) to physically reorder the files in the SD card&#039;s directory database. &lt;br /&gt;
&lt;br /&gt;
== Where do I buy RTC / Mouse / Memory / Wifi / Pi0 / Inline Power Switch… ==&lt;br /&gt;
ActiveConsult sell most of these products and can be found [https://store.activeconsult.co.uk/shop?olsPage=products&amp;amp;amp;page=1 here].&lt;br /&gt;
SCART cables can be purchased [https://coolnovelties.co.uk/coolnovelties/sinclair-zx-spectrum/312-zx-spectrum-next-analog-rgb-scart-cable-0705693507088.html here], also here: [https://www.retrocomputershack.com/] NOTE that you will need to boot your ZX Spectrum Next and press the R key to set up the SCART output.&lt;br /&gt;
&lt;br /&gt;
== What controller / joystick / gamepad can I use? ==&lt;br /&gt;
[[File:Atari-2600-Paddles.jpg|thumb|Atari 2600 Paddles]]The Next supports any “Atari” standard joystick or gamepad, along with Master System and MegaDrive pads. A good option is the [[M30 8BitDo wireless MegaDrive pad]].&lt;br /&gt;
You &#039;&#039;&#039;CANNOT&#039;&#039;&#039; use the &#039;&#039;&#039;Sinclair Branded SJS-1&#039;&#039;&#039; joysticks sold for +2/2A/3 ZX Spectrums as they require a special adapter. &lt;br /&gt;
If your joystick has both black and grey plugs, &#039;&#039;&#039;DO NOT&#039;&#039;&#039; plug in the grey plug, as that only works on +2/2A/3 ZX Spectrums and will damage your Next.&lt;br /&gt;
&lt;br /&gt;
The Next also supports [https://www.atariage.com/controller_page.php?ControllerID=3&amp;amp;SystemID=2600 Atari 2600 driving controllers]. These are digital quadrature rotary encoder devices, identifiable by the word &amp;quot;driving&amp;quot; and picture of a racing car. [https://www.atariage.com/controller_page.php?SystemID=2600&amp;amp;ControllerID=2 Atari 2600 paddles] (identifiable by the word &amp;quot;paddle&amp;quot; and picture of tennis rackets) contain analogue potentiometers, which are &#039;&#039;&#039;NOT&#039;&#039;&#039; physically compatible and could damage your Next.&lt;br /&gt;
&lt;br /&gt;
== How do I configure the joystick ports to be Kempston / Sinclair / Megadrive / Cursor? ==&lt;br /&gt;
&lt;br /&gt;
Your Next lets you configure how each joystick port behaves. By default the Left port will be configured to Kempston1 and Right will be Sinclair1. If you wish to change this configuration press the NMI button, Choose &amp;quot;Settings&amp;quot;, then &amp;quot;Joysticks&amp;quot;. You can now select JoyL for Left or JoyR for right and cycle through the options : &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston1&amp;lt;br&amp;gt;&lt;br /&gt;
Kempston2&amp;lt;br&amp;gt;&lt;br /&gt;
Cursor&amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair1 &amp;lt;br&amp;gt;&lt;br /&gt;
Sinclair2&amp;lt;br&amp;gt;&lt;br /&gt;
MD 1 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
MD 2 (Megadrive 3/6 buttons)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You cannot set both ports to the same configuration. This will only set the choice until a cold reboot (complete power off). You can set these options to be permanent by powering off your Next, on the Sinclair ZX Next boot screen hold down SPACE, then press &#039;E&#039; - Change the options for Left Joy and Right Joy with SPACE. Once you have chosen your preferred joystick configuration press ENTER twice. Your Next will now reboot and once back into NextZXOS your settings will now be applied. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== My ZX ProPad Button 2 Doesn&#039;t Work ==&lt;br /&gt;
The Next only supports two directly wired fire buttons. On the ZX ProPad these are buttons 1 and 3. Additional buttons are supported for Sega Megadrive pads and sticks only. Both 3 and 6 button Sega pads are compatible. Up, down, left, right, A, B, C, X, Y, Z, Start and Mode are all readable.&lt;br /&gt;
&lt;br /&gt;
The limitation of two directly wired fire buttons on non-Sega pads and sticks is baked into the Next hardware, unfortunately. So it cannot be enhanced in a future core update. All Next boards have a physical multiplex chip which hardwires six pins as input only (for direction and two fire buttons), one pin as output only (for Sega select), one pin as 5V, and one pin as ground.&lt;br /&gt;
== How do I change the CPU speed/ Scanlines etc? ==&lt;br /&gt;
The following keys combinations can be used to :&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 1 Hard reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 2 toggle scan doubler&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 3 toggle 50 / 60 Hz&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 4 Soft reset&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 7 Toggle scan lines (25/50/75%)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 8 Toggle CPU speed (3.5/7/14/28)&amp;lt;br&amp;gt;&lt;br /&gt;
NMI + 9 NMI menu&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Where can I download games / roms ? ==&lt;br /&gt;
[https://spectrumcomputing.co.uk/ Spectrum Computing] and [https://www.worldofspectrum.org/ World of Spectrum] are good places to start. If your Next has wifi, [[https://github.com/em00k/next-zxdb-downloader zxdb-dl]] can also search and download directly on your Next. zxdb-dl is also on your SD card as part of the latest distro.&lt;br /&gt;
&lt;br /&gt;
== My internal keyboard is not responding – help!== &lt;br /&gt;
First turn off the Next completely and remove all cables and try again. Failing that a keyboard&lt;br /&gt;
cable may have become loose. You can watch a video on how to open your Next here:&amp;lt;br&amp;gt;&lt;br /&gt;
https://www.youtube.com/watch?v=iLDz4AjL3rA also see [[NexTest|NexTest diagnostic tool]]&lt;br /&gt;
&lt;br /&gt;
== My ps/2 keyboard is not responding – help!== &lt;br /&gt;
Edit your &#039;&#039;&#039;c:/machines/next/config.ini&#039;&#039;&#039; file so that &#039;&#039;&#039;ps2=0&#039;&#039;&#039;, or use a [https://store.activeconsult.co.uk/shop?olsPage=products%2Fps2-keyboard-mouse-splitter ps/2 splitter].&lt;br /&gt;
&lt;br /&gt;
== How do I install pi0 / Wifi / RTC / Memory? ==&lt;br /&gt;
As above a guide on how to open your Next can be viewed. Also read the appropriate Chapter in the manual.&lt;br /&gt;
[https://www.youtube.com/watch?v=iLDz4AjL3rA here].&lt;br /&gt;
&lt;br /&gt;
== How do I connect to Wifi? ==&lt;br /&gt;
You can connect to a 2.4Ghz wifi network, make sure your password does not contain spaces. You can use the application wifi2.bas from /apps/wifi/setup - when you load wifi2.bas and type RUN to start&lt;br /&gt;
&lt;br /&gt;
You can confirm your IP address by going in to command line and typing .uart then the following:&lt;br /&gt;
&lt;br /&gt;
AT+CIFSR&lt;br /&gt;
&lt;br /&gt;
This should return your IP. If you are still having issues confirm the network is 2.4Ghz and you are not too far away from an access point.&lt;br /&gt;
&lt;br /&gt;
See if other internet apps work, try ZXDB-DL from /apps/wifi/zxdb-dl and launch zxdb-loader.bas. When the program launches enter a game search term and press return. If you see results wifi is working.&lt;br /&gt;
&lt;br /&gt;
== How can I get the expansion bus working with external hardware? ==&lt;br /&gt;
By default, the Next disables the expansion bus, as external hardware can conflict and is unlikely to run at CPU speeds faster than 3.5MHz. The bus can be enabled and and individual conflicting internal hardware disabled through Next registers 128 and 130..137 (manual pages 270..271). [https://www.specnext.com/forum/viewtopic.php?f=6&amp;amp;t=1482&amp;amp;p=9701&amp;amp;hilit=RAM+music+machine+expansion+bus#p9701 Here] is a detailed example of getting the RAM Music Machine working, and [https://www.youtube.com/watch?v=EU9NTQqQ1fg here] is a video demonstrating unsing Interface 1/microdrives.&lt;br /&gt;
&lt;br /&gt;
== Can I use Amstrad/Sinclair SJS-1 joysticks with the Next? ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NO!&#039;&#039;&#039; [https://rk.nvg.ntnu.no/sinclair/computers/peripherals/sjs1.htm SJS-1 joysticks] have fundamentally incompatible wiring compared with the standard Atari-wired joysticks the Next uses. Using them on the Next will short the 5V line to ground, potentially damaging your Next. Bin them, sell them, or keep them for your original +2, +2A or +3, where they will work fine but still be quite rubbish.&lt;br /&gt;
&lt;br /&gt;
== Why don&#039;t my VGA/joystick sockets have hex nuts to screw the cable in? ==&lt;br /&gt;
VGA sockets with hex nuts are typically bolted to a metal chassis. On the Next there is no chassis to screw onto, so you would just be screwing into the connector which is a VERY bad idea. The Next sockets are only fixed tight with small solder pads.&lt;br /&gt;
VGA cables are heavy and will put a lot of leverage on the VGA PCB pins, and likely to fracture the PCB or pins on the VGA socket. An unscrewed cable will still stay firmly in the socket during normal use, but will safely unplug if you yank the cable or leverage the plug.&lt;br /&gt;
&lt;br /&gt;
== I thought I had the latest version of the distro? ==&lt;br /&gt;
Go by the version numbers of the firmware, core and NextZXOS when deciding if you have the latest version. Ignore the post date on the [https://www.specnext.com/latestdistro/ latest distro] page. Wordpress post dates don&#039;t automatically update when existing posts are edited.&lt;br /&gt;
&lt;br /&gt;
== Why doesn&#039;t the manual have a table of contents / index ==&lt;br /&gt;
Short answer: It didn&#039;t fit in the box as the boxes were made way before the manual was completed. &lt;br /&gt;
Long answer: TL;DR :)&lt;br /&gt;
&lt;br /&gt;
== Where can I download a copy of the manual with a ToC and index? ==&lt;br /&gt;
Right here : https://www.specnext.com/zx-spectrum-next-user-manual-first-edition/   &lt;br /&gt;
&lt;br /&gt;
Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/manual-fixed.pdf fixed version] displays correctly in Safari, and can be read directly in browsers.&lt;br /&gt;
&lt;br /&gt;
== Further Spectrum Next Video Guides ==&lt;br /&gt;
https://www.youtube.com/playlist?list=PL2lCM2mJCG_AonDyHJfqjxFR5VoqBWqoh&lt;br /&gt;
&lt;br /&gt;
== Which Raspberry Pi Model Can I use for the Next Accelerator? ==&lt;br /&gt;
Pi Zero 1.3 has fairly major design changes from 1.2, but as long as you’re using official NextPi images and using it as advised you should see no issues using the original 1.2 Pi Zero (the one without camera connectors). The Pi Zero 1.3 will also work just fine, and doesn’t use the camera connector even if found.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero W (all of 1.x ones) are very similar to the 1.3. NextPi can use it, and will disable the wireless.&lt;br /&gt;
&lt;br /&gt;
It’s worth knowing that, &#039;&#039;in theory,&#039;&#039; someone could develop a plugin for NextPi that only works for the the non wireless version, but the only people to do that so far are the Next Team, to prove it was possible.&lt;br /&gt;
&lt;br /&gt;
The Pi Zero 2 series is not supported, has never been supported, won’t work properly, and no support is offered or given into getting it to work properly. Neither are any other non-Zero Pi models, or clones such as Banana Pi.&lt;br /&gt;
&lt;br /&gt;
Other, non-official, &amp;quot;NextPi-compatible&amp;quot; distributions are starting to come available, from 3rd party users and - so far - are NOT fully nextpi compatible, at all.&lt;br /&gt;
&lt;br /&gt;
== Essential Lesser-Known Technical Docs ==&lt;br /&gt;
* The master [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/nextreg.txt nextreg] and [https://gitlab.com/SpectrumNext/ZX_Spectrum_Next_FPGA/-/blob/master/cores/zxnext/ports.txt port] lists are kept up to date, and fully describe the Next hardware for developers.  &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/blob/master/docs/extra-hw/pinouts/pinouts.txt pinouts] list has detailed information on connectors. &lt;br /&gt;
* The [https://gitlab.com/thesmog358/tbblue/-/raw/master/docs/nextzxos-changelog.txt NextZXOS change log] details what was new and fixed in each version of NextZXOS/NextBASIC. &lt;br /&gt;
* The four [https://gitlab.com/thesmog358/tbblue/-/tree/master/docs/nextzxos NextZXOS PDFs] have detailed information on the NextZXOS and esxDOS APIs, NextBASIC sysvars, and NextBASIC syntax.&lt;br /&gt;
* varmfskii&#039;s [https://raw.githubusercontent.com/varmfskii/zxnext_code/master/zx_next_notes/zxnext_notes.pdf ZX Spectrum Next Programming Notes] are an attempt to consolidate the Next programming interface into a single location.&lt;br /&gt;
* Myopian&#039;s [https://docs.google.com/spreadsheets/d/1dB8fKIfByGJTts409Ud8ly450a6SLPnLZc-nCBghBl8 API spreadsheet] summarises NextZXOS/IDEDOS entry points along with calling conditions.&lt;br /&gt;
* Myopian&#039;s [https://www.cs.hmc.edu/~oneill/specnext/dot-cmds.html dot command summary] collects together help and readme text for NextZXOS dot commands in one handy place.&lt;br /&gt;
* Tomaz&#039;s [https://github.com/tomaz/zx-next-dev-guide/releases/latest ZX Spectrum Next Assembly Developer Guide] is almost like &amp;quot;User manual&amp;quot; for Assembly developers.&lt;br /&gt;
* Luzie/Rat Mal&#039;s [https://docs.google.com/spreadsheets/d/17-ifpHcy932_AP7SAv9uBLxg-2ZptcdgTvQ8ILXQLM4/edit?usp=sharing_eil&amp;amp;ts=599361c7 Almost (In-) Complete List of esxDOS DOT-Commands] attempts to list dot commands for several systems, including the Next. Some of the non-Next-specific commands may work on the Next, and some may only work on other FPGA/divMMC systems.&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NextTest&amp;diff=13531</id>
		<title>NextTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NextTest&amp;diff=13531"/>
		<updated>2025-04-11T22:42:40Z</updated>

		<summary type="html">&lt;p&gt;Em00k: Em00k moved page NextTest to NexTest: Spelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[NexTest]]&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13530</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13530"/>
		<updated>2025-04-11T22:42:40Z</updated>

		<summary type="html">&lt;p&gt;Em00k: Em00k moved page NextTest to NexTest: Spelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Nextest-screenshot.png|right|600px]]&lt;br /&gt;
&lt;br /&gt;
= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
[[File:Nextest Joystick Detail.png|left|Joystick detail]]&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13529</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13529"/>
		<updated>2025-04-11T22:40:23Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Kempston Joystick */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Nextest-screenshot.png|right|600px]]&lt;br /&gt;
&lt;br /&gt;
= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
[[File:Nextest Joystick Detail.png|left|Joystick detail]]&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13528</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13528"/>
		<updated>2025-04-11T22:39:42Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Kempston Joystick */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Nextest-screenshot.png|right|600px]]&lt;br /&gt;
&lt;br /&gt;
= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
[[File:Nextest Joystick Detail.png|left|Joystick detail]]&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13527</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13527"/>
		<updated>2025-04-11T22:39:14Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Kempston Joystick */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Nextest-screenshot.png|right|600px]]&lt;br /&gt;
&lt;br /&gt;
= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
[[File:Nextest Joystick Detail.png|frameless|left|Joystick detail]]&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=File:Nextest_Joystick_Detail.png&amp;diff=13526</id>
		<title>File:Nextest Joystick Detail.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=File:Nextest_Joystick_Detail.png&amp;diff=13526"/>
		<updated>2025-04-11T22:38:37Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Shows the Joystick detail&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13525</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13525"/>
		<updated>2025-04-11T22:34:50Z</updated>

		<summary type="html">&lt;p&gt;Em00k: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Nextest-screenshot.png|right|600px]]&lt;br /&gt;
&lt;br /&gt;
= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13524</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13524"/>
		<updated>2025-04-11T22:33:54Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* NEXTEST v2.0A User Guide */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
	<entry>
		<id>https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13523</id>
		<title>NexTest</title>
		<link rel="alternate" type="text/html" href="https://wiki.specnext.dev/index.php?title=NexTest&amp;diff=13523"/>
		<updated>2025-04-11T22:33:00Z</updated>

		<summary type="html">&lt;p&gt;Em00k: /* Welcome */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= NEXTEST v2.0A User Guide =&lt;br /&gt;
&lt;br /&gt;
[[File:Nextest-screenshot.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
== Welcome ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NEXTEST&#039;&#039;&#039; is a test application for the ZX Spectrum Next. It automatically checks the SRAM and SD card transfer bus, while allowing the user to verify input devices manually. It is included on the official distro in C:/EXTRAS/NEXTEST/NEXTEST.NEX &lt;br /&gt;
&lt;br /&gt;
The test duration is left to the user&#039;s discretion and may range from minutes to several hours of soak testing.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Runs under &#039;&#039;&#039;NextZXOS v2.1&#039;&#039;&#039; or later.&lt;br /&gt;
* Requires &#039;&#039;&#039;core v3.00.00&#039;&#039;&#039; or later.&lt;br /&gt;
* Compatible with all CPU speeds and video mode configurations.&lt;br /&gt;
* Detects systems with 1MB or 2MB RAM.&lt;br /&gt;
* The SD card used to launch `NEXTEST.NEX` must remain inserted during testing.&lt;br /&gt;
* A mouse is recommended but not required.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
* Default CPU speed is set to &#039;&#039;&#039;28MHz&#039;&#039;&#039; at startup.&lt;br /&gt;
* Speed drops to &#039;&#039;&#039;3.5MHz&#039;&#039;&#039; if the expansion bus is enabled.&lt;br /&gt;
* Respects user configuration for machine timing, video mode, and refresh rate.&lt;br /&gt;
* &#039;&#039;&#039;NMI/Multiface&#039;&#039;&#039; and turbo shortcut key are disabled while running.&lt;br /&gt;
* Both joystick ports are set to &#039;&#039;&#039;Mega Drive mode&#039;&#039;&#039; to support multi-button gamepads.&lt;br /&gt;
* &#039;&#039;&#039;Power-off or reset&#039;&#039;&#039; is required to exit.&lt;br /&gt;
* SD card is treated as read-only – no file writes are performed.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
&lt;br /&gt;
The application performs several quick checks during startup:&lt;br /&gt;
&lt;br /&gt;
* Data and address bus verification.&lt;br /&gt;
* CRC check on the application binary.&lt;br /&gt;
* Checks for:&lt;br /&gt;
  * Operating system version&lt;br /&gt;
  * Core version&lt;br /&gt;
  * SD card&lt;br /&gt;
  * Video mode&lt;br /&gt;
  * Machine identity&lt;br /&gt;
&lt;br /&gt;
The application relocates into the &#039;&#039;&#039;16K bank shared with the ULA&#039;&#039;&#039;. This memory is shadowed in FPGA BRAM for additional protection against SRAM issues.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The CRC status should read &#039;&#039;&#039;PASS&#039;&#039;&#039;. A failed CRC indicates a corrupt application and unreliable results.&lt;br /&gt;
&lt;br /&gt;
== Display ==&lt;br /&gt;
&lt;br /&gt;
* Uses a &#039;&#039;&#039;640×256 screen&#039;&#039;&#039; layout.&lt;br /&gt;
* System information is displayed at the top in a large font.&lt;br /&gt;
* Test results and status appear below in a smaller font.&lt;br /&gt;
* &#039;&#039;&#039;Green text = pass&#039;&#039;&#039;; &#039;&#039;&#039;Red text = fail&#039;&#039;&#039;.&lt;br /&gt;
* A multi-colour ZX Spectrum Next graphic is displayed centrally.&lt;br /&gt;
* On fatal errors, a black &amp;quot;stop screen&amp;quot; with a bold white error message is shown.&lt;br /&gt;
* Reset or power-off is required to exit a fatal error screen.&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
&lt;br /&gt;
* A mouse is required to change:&lt;br /&gt;
  * CPU turbo speed&lt;br /&gt;
  * Refresh rate&lt;br /&gt;
  * Machine timing&lt;br /&gt;
&lt;br /&gt;
* Tooltips are displayed in the top-left when hovering over active areas.&lt;br /&gt;
* Left and right mouse buttons cycle through configurable parameters.&lt;br /&gt;
* Tooltip text shows warning messages if a mode is locked.&lt;br /&gt;
* The 3.5MHz speed is displayed as &#039;&#039;&#039;3MHZ&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Automatic Tests ==&lt;br /&gt;
&lt;br /&gt;
Background tasks run continuously, regardless of user input:&lt;br /&gt;
&lt;br /&gt;
# SRAM bit inversion write/verify&lt;br /&gt;
# DMA write/verify&lt;br /&gt;
# SD card read/verify&lt;br /&gt;
# Real-time clock (RTC) poll using the NextZXOS API&lt;br /&gt;
&lt;br /&gt;
* Background tests loop indefinitely.&lt;br /&gt;
* Completion time varies with CPU speed.&lt;br /&gt;
* Memory bank ID, SD card block, and RTC status are updated in real-time.&lt;br /&gt;
* Memory errors at or above bank 95 are shown as &#039;&#039;&#039;95&#039;&#039;&#039; in the bottom-right.&lt;br /&gt;
* SD card CRC checks are disabled at 3.5MHz.&lt;br /&gt;
&lt;br /&gt;
== Manual Tests ==&lt;br /&gt;
&lt;br /&gt;
The following inputs are monitored and displayed in real-time:&lt;br /&gt;
&lt;br /&gt;
* Keyboard&lt;br /&gt;
* Mouse&lt;br /&gt;
* Joystick&lt;br /&gt;
* Board buttons&lt;br /&gt;
&lt;br /&gt;
=== Kempston Joystick ===&lt;br /&gt;
&lt;br /&gt;
* Inputs shown as:&lt;br /&gt;
  * &#039;1&#039; when pressed&lt;br /&gt;
  * Initial letter of the direction/button when released&lt;br /&gt;
* Letters used:&lt;br /&gt;
  * &#039;&#039;&#039;SACBUDLR&#039;&#039;&#039; = Start, A, C, B, Up, Down, Left, Right&lt;br /&gt;
&lt;br /&gt;
=== Kempston Mouse ===&lt;br /&gt;
&lt;br /&gt;
* X range: 0–319  &lt;br /&gt;
* Y range: 0–255  &lt;br /&gt;
* Scroll wheel: hex 0–F  &lt;br /&gt;
* Buttons:  &lt;br /&gt;
  * &#039;1&#039; when pressed  &lt;br /&gt;
  * Initial letter when released: &#039;&#039;&#039;LMR&#039;&#039;&#039; = Left, Middle, Right&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Mouse pointer may be invisible at display edges.&lt;br /&gt;
&lt;br /&gt;
=== Keyboard ===&lt;br /&gt;
&lt;br /&gt;
* Keys flash until pressed&lt;br /&gt;
* I/O port number for each group is shown&lt;br /&gt;
* All keys (including extended and shifted combos) are translated and shown on the graphic&lt;br /&gt;
* Pressed keys turn red; a stuck key stays red&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
&lt;br /&gt;
* 3.5mm jack outputs a looping audio track streamed from the SD card&lt;br /&gt;
* HDMI audio is supported (if display device allows)&lt;br /&gt;
* &#039;&#039;&#039;Glitches are normal&#039;&#039;&#039; when switching refresh rate or machine timing&lt;br /&gt;
&lt;br /&gt;
== Fatal Errors ==&lt;br /&gt;
&lt;br /&gt;
Each of these messages appears as a stop screen. A system reset or power-off is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CORE V.3.00.00 OR ABOVE REQUIRED&lt;br /&gt;
NEXTZXOS 2.01 OR ABOVE REQUIRED&lt;br /&gt;
ESXDOS API ERROR&lt;br /&gt;
NEX LOAD ERROR&lt;br /&gt;
FILE ERROR&lt;br /&gt;
FILE FRAGMENTATION ERROR&lt;br /&gt;
DISK FILEMAP ERROR&lt;br /&gt;
SD CARD STREAM ERROR&lt;br /&gt;
SD CARD NOT READY&lt;br /&gt;
DATA BUS ERROR&lt;br /&gt;
ADDRESS BUS ERROR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
* Design and development: &#039;&#039;&#039;Kev Brady&#039;&#039;&#039;&lt;br /&gt;
* Music: &#039;&#039;&#039;&amp;quot;Humanoids&amp;quot;&#039;&#039;&#039; written and produced by Kev Brady  &lt;br /&gt;
(c)2023 9bitcolor&lt;/div&gt;</summary>
		<author><name>Em00k</name></author>
	</entry>
</feed>