<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://wiki.specnext.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tanepiper</id>
	<title>SpecNext Wiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.specnext.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tanepiper"/>
	<link rel="alternate" type="text/html" href="http://wiki.specnext.dev/Special:Contributions/Tanepiper"/>
	<updated>2026-05-02T10:02:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>http://wiki.specnext.dev/index.php?title=Copper&amp;diff=11522</id>
		<title>Copper</title>
		<link rel="alternate" type="text/html" href="http://wiki.specnext.dev/index.php?title=Copper&amp;diff=11522"/>
		<updated>2020-09-11T17:52:21Z</updated>

		<summary type="html">&lt;p&gt;Tanepiper: Make the text about the opcodes clearer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Copper&#039;&#039;&#039; is a simple programmed system which allows certain [[Board feature control|Next Registers]] to be altered automatically at certain scanline positions. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Copper&amp;quot; is a strangulation of &amp;quot;co-processor&amp;quot; and is a term taken from the Amiga which had a similar function. The copper on the Spectrum Next is not associated with the [[RPi0 Acceleration|Raspberry Pi &#039;coprocessor&#039;]].&lt;br /&gt;
&lt;br /&gt;
A program is uploaded to the Copper by sending it, byte by byte, to {{NextRegNo|$60}}. Each Copper instruction is 16 bits wide and there are 2 opcodes with a single bit in an instruction determines the operation and two special case opcodes. In total the four operations are:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Opcode !! Bit pattern !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| WAIT || %1hhhhhhv %vvvvvvvv || Wait for raster line v (0-311) and horizontal position h*8 (h is 0-55) (duration 1 CLOCK)&lt;br /&gt;
|-&lt;br /&gt;
| MOVE || %0rrrrrrr %vvvvvvvv || Write value &#039;&#039;&#039;v&#039;&#039;&#039; to Next register &#039;&#039;&#039;r&#039;&#039;&#039; (duration 2 CLOCKS)&lt;br /&gt;
|-&lt;br /&gt;
| NOOP || %00000000 %00000000 || Special case of &amp;quot;value 0 to port 0&amp;quot; works as &amp;quot;no operation&amp;quot; (duration 1 CLOCK)&lt;br /&gt;
|-&lt;br /&gt;
| HALT || %11111111 %11111111 || Special case of &amp;quot;WAIT 63,511&amp;quot; works as &amp;quot;halt&amp;quot; instruction&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The copper&#039;s program storage is 2k big; since each instruction is 2 bytes it can store exactly 1024 instructions, numbered 0-1023. The copper is controlled by a word accessed through Next Registers {{NextRegNo|$61}} and {{NextRegNo|$62}}. The internal &amp;quot;program counter&amp;quot; (&#039;&#039;&#039;CPC&#039;&#039;&#039;) has 10 bits (0-1023), auto-incrementing it after each instruction, wrapping around after last one back to first one.&lt;br /&gt;
&lt;br /&gt;
The copper control word has the structure: %cc000iii %iiiiiiii. &#039;&#039;&#039;I&#039;&#039;&#039; is the storage position (0-2047) (for writing instructions with {{NextRegNo|$60}}), and &#039;&#039;&#039;c&#039;&#039;&#039; is used to set the behaviour mode of the copper, as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! C bits !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| %00 || STOP, copper does nothing (CPC keeps its current value)&lt;br /&gt;
|-&lt;br /&gt;
| %01 || reset CPC to 0, then START&lt;br /&gt;
|-&lt;br /&gt;
| %10 || START (resumes from current CPC)&lt;br /&gt;
|-&lt;br /&gt;
| %11 || reset CPC to 0, then START; Also VBLANK does reset CPC to 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;&#039;c&#039;&#039;&#039; bits are identical to previously written value, the control mode is ignored, and only write-index &#039;&#039;&#039;I&#039;&#039;&#039; is modified.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want the copper program to loop infinitely, then you can mark the &amp;quot;end&amp;quot; of the copper program by waiting for a line higher than 311 (&amp;quot;HALT&amp;quot; instruction). Since these lines will never be reached, the copper will essentially halt until reset.&lt;br /&gt;
&lt;br /&gt;
The precise timing and many more details are currently documented in distribution file [https://gitlab.com/thesmog358/tbblue/blob/a0d25589bd28b05c510e528332bcd192bc414ebb/docs/extra-hw/copper/COPPER-v0.1c.TXT &amp;quot;/docs/extra-hw/copper/COPPER-v0.1c.TXT&amp;quot;].&lt;br /&gt;
&lt;br /&gt;
(core 2.0) the copper code is executed at 14MHz, and the COPPER-v0.1c.TXT document above describes timing of the core2.0.&lt;br /&gt;
(core 3.0) the copper code is executed at 28MHz, the precise timing is not documented yet&lt;br /&gt;
&lt;br /&gt;
From practical test (with the Swedish-flags copper test) the coordinates for WAIT are identical, MOVE is twice as fast (flags are half of original width because each pixel is created by single MOVE instruction).&lt;br /&gt;
&lt;br /&gt;
Important values affecting pixel display are now sampled at the same moment when the pixel is drawn (no test yet to describe what does that mean at sub-pixel accuracy terms and in which order the copper MOVEs should be done with what kind of lead in case you want to set for example 6 different display-affecting registers, by theoretical approach of single MOVE taking half-pixel width you should start precisely 3 pixels ahead of the edge where all values should be set, but YMMV) (overall it&#039;s probably much wiser to avoid situations where you need sub-pixel precision, or test with the real board heavily)&lt;/div&gt;</summary>
		<author><name>Tanepiper</name></author>
	</entry>
	<entry>
		<id>http://wiki.specnext.dev/index.php?title=Copper&amp;diff=11521</id>
		<title>Copper</title>
		<link rel="alternate" type="text/html" href="http://wiki.specnext.dev/index.php?title=Copper&amp;diff=11521"/>
		<updated>2020-09-11T17:47:32Z</updated>

		<summary type="html">&lt;p&gt;Tanepiper: Updated to reflect there are 4 op codes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Copper&#039;&#039;&#039; is a simple programmed system which allows certain [[Board feature control|Next Registers]] to be altered automatically at certain scanline positions. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Copper&amp;quot; is a strangulation of &amp;quot;co-processor&amp;quot; and is a term taken from the Amiga which had a similar function. The copper on the Spectrum Next is not associated with the [[RPi0 Acceleration|Raspberry Pi &#039;coprocessor&#039;]].&lt;br /&gt;
&lt;br /&gt;
A program is uploaded to the Copper by sending it, byte by byte, to {{NextRegNo|$60}}. Each Copper instruction is 16 bits wide and there are 4 opcodes, so only a single bit in an instruction determines the operation. The four operations are:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Opcode !! Bit pattern !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| WAIT || %1hhhhhhv %vvvvvvvv || Wait for raster line v (0-311) and horizontal position h*8 (h is 0-55) (duration 1 CLOCK)&lt;br /&gt;
|-&lt;br /&gt;
| MOVE || %0rrrrrrr %vvvvvvvv || Write value &#039;&#039;&#039;v&#039;&#039;&#039; to Next register &#039;&#039;&#039;r&#039;&#039;&#039; (duration 2 CLOCKS)&lt;br /&gt;
|-&lt;br /&gt;
| NOOP || %00000000 %00000000 || Special case of &amp;quot;value 0 to port 0&amp;quot; works as &amp;quot;no operation&amp;quot; (duration 1 CLOCK)&lt;br /&gt;
|-&lt;br /&gt;
| HALT || %11111111 %11111111 || Special case of &amp;quot;WAIT 63,511&amp;quot; works as &amp;quot;halt&amp;quot; instruction&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The copper&#039;s program storage is 2k big; since each instruction is 2 bytes it can store exactly 1024 instructions, numbered 0-1023. The copper is controlled by a word accessed through Next Registers {{NextRegNo|$61}} and {{NextRegNo|$62}}. The internal &amp;quot;program counter&amp;quot; (&#039;&#039;&#039;CPC&#039;&#039;&#039;) has 10 bits (0-1023), auto-incrementing it after each instruction, wrapping around after last one back to first one.&lt;br /&gt;
&lt;br /&gt;
The copper control word has the structure: %cc000iii %iiiiiiii. &#039;&#039;&#039;I&#039;&#039;&#039; is the storage position (0-2047) (for writing instructions with {{NextRegNo|$60}}), and &#039;&#039;&#039;c&#039;&#039;&#039; is used to set the behaviour mode of the copper, as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! C bits !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| %00 || STOP, copper does nothing (CPC keeps its current value)&lt;br /&gt;
|-&lt;br /&gt;
| %01 || reset CPC to 0, then START&lt;br /&gt;
|-&lt;br /&gt;
| %10 || START (resumes from current CPC)&lt;br /&gt;
|-&lt;br /&gt;
| %11 || reset CPC to 0, then START; Also VBLANK does reset CPC to 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;&#039;c&#039;&#039;&#039; bits are identical to previously written value, the control mode is ignored, and only write-index &#039;&#039;&#039;I&#039;&#039;&#039; is modified.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want the copper program to loop infinitely, then you can mark the &amp;quot;end&amp;quot; of the copper program by waiting for a line higher than 311 (&amp;quot;HALT&amp;quot; instruction). Since these lines will never be reached, the copper will essentially halt until reset.&lt;br /&gt;
&lt;br /&gt;
The precise timing and many more details are currently documented in distribution file [https://gitlab.com/thesmog358/tbblue/blob/a0d25589bd28b05c510e528332bcd192bc414ebb/docs/extra-hw/copper/COPPER-v0.1c.TXT &amp;quot;/docs/extra-hw/copper/COPPER-v0.1c.TXT&amp;quot;].&lt;br /&gt;
&lt;br /&gt;
(core 2.0) the copper code is executed at 14MHz, and the COPPER-v0.1c.TXT document above describes timing of the core2.0.&lt;br /&gt;
(core 3.0) the copper code is executed at 28MHz, the precise timing is not documented yet&lt;br /&gt;
&lt;br /&gt;
From practical test (with the Swedish-flags copper test) the coordinates for WAIT are identical, MOVE is twice as fast (flags are half of original width because each pixel is created by single MOVE instruction).&lt;br /&gt;
&lt;br /&gt;
Important values affecting pixel display are now sampled at the same moment when the pixel is drawn (no test yet to describe what does that mean at sub-pixel accuracy terms and in which order the copper MOVEs should be done with what kind of lead in case you want to set for example 6 different display-affecting registers, by theoretical approach of single MOVE taking half-pixel width you should start precisely 3 pixels ahead of the edge where all values should be set, but YMMV) (overall it&#039;s probably much wiser to avoid situations where you need sub-pixel precision, or test with the real board heavily)&lt;/div&gt;</summary>
		<author><name>Tanepiper</name></author>
	</entry>
</feed>