Open this program in the workbench.
Draw a flat opaque red triangle with vertices (16,16), (48,32), (16,48). The destination is a 64×64 ARGB8888 surface at local byte address 0x00100000, with 256 bytes per row.
Local memory and the RISC are already configured. All drawing engines are idle on entry, the surface occupies reserved memory through 0x00103FFF, and the program enters from V1000 compatibility mode.
| spr index | Register | Value | Meaning |
|---|---|---|---|
| 1 | SrcMode | 0x00000000 | No texture or specular add; SwapUV clear |
| 2 | SrcMask | 0x00000000 | U/V masks zero; unused coordinates are zero |
| 3 | Stride | 0x00000100 | DstStride0 = 1, DstStride1 = 0: 256 bytes |
| 4 | DstBase | 0x00100000 | Word-aligned surface base |
| 5 | DstMode | 0x0000000C | ALU source replace; no blend, Z write, fog, dither or alpha rejection |
| 6 | DstFmt | 0x0000000C | 32-bit ARGB8888 |
| 7 | PMask | 0xFFFFFFFF | All planes writable |
| 12 | PatMode | 0x00000000 | Pattern disabled |
| 14, 15 | ScissorX, ScissorY | 0x00000040 | Half-open range 0..64 |
Stride code 1 means a shift of eight, not a one-byte row. DstStride0 occupies bits 10:8, so its operand value is 1 « 8. The source and Z stride fields are zero because those reads are unused.
Sources: Technical Spec, p.28, Technical Spec, p.29, Technical Spec, p.30, Technical Spec, p.31, Technical Spec, p.33, Technical Spec, p.34
DrawCtl is 0x000B: triangle shadowing enabled, mono clear and all parameter iteration enables clear. XTop, YTop and XMid still iterate. Constant color comes from the shadowed R/A/G/B start values.
| Parameter | Register | Word |
|---|---|---|
| XTop, YTop | a0/%128, a1/%129 | 0x00100000, 0x00100000 |
| XMid, YMid | a16/%144, a17/%145 | 0x00300000, 0x00200000 |
| YBot | q1/%161 | 0x00300000 |
| dXLong/dy | a14/%142 | 0x00000000 |
| dXTop/dy | a30/%158 | 0x00020000 |
| dXBot/dy | q14/%174 | 0xFFFE0000 |
| dX | q0/%160 | 0x00000000: triangle, long edge on left, increasing edge walk |
| R, A | a4/%132, a5/%133 | 0x00FF0000, 0x00FF0000 |
| G, B | a6/%134, a7/%135 | Zero |
| Z | a2/%130 | Zero |
| Q | a3/%131 | 0x00800000 (0.5 in 0I.24F); perspective iteration disabled |
| R2, F, G2, B2, U, V | a8..a13/%136..%141 | Zero |
Coordinates, colors and X edge gradients use 16I.16F. The edge slopes follow directly from these vertices:
dXLong/dy = (16 - 16) / (48 - 16) = 0 dXTop/dy = (48 - 16) / (32 - 16) = +2 dXBot/dy = (16 - 48) / (48 - 32) = -2
The long edge is vertical at X=16 and lies on the left. For example, at Y=20 the right edge is X=24 and the half-open span covers X=16..23. Fractional coordinates are zero, so the initial Y subpixel correction is zero. No color, Z or texture gradients are needed when their iteration classes are disabled.
Sources: Technical Spec, p.12, Technical Spec, p.16, Technical Spec, p.17, Technical Spec, p.18, Technical Spec, p.19
Pixel state is written first. DrawCtl then enables shadowing before the start values are loaded, with mono set before color writes. No spr follows a shadow-register write, so the two-instruction shadow-destination→spr hazard is avoided by this order.
tri %128,%128,%0 adds the zero pair %0/%1 to XY, leaves XY unchanged and launches the triangle. Its word is 0xFE808000. Launch takes one cycle; the source gives total engine time as 4 + scanlines + pixels, excluding memory stalls.
Three ordinary instructions separate tri from possible Fill Engine use. The final DrawCtl write stalls until the triangle is idle, then disables shadowing. Three further instructions satisfy the DrawCtl hazard before a later compatibility draw. Every iterated start value must be loaded again before another triangle.
Sources: Technical Spec, p.7, Technical Spec, p.9, Technical Spec, p.13, Technical Spec, p.16, Technical Spec, p.17
Triangle reference · Shadow register map · DrawCtl · Hazards · Examples