====== Fill a Scan Line ====== [[tools:risc#example-fill|Open this program in the workbench]]. Write 320 eight-bit pixels, all ''0x5A'', starting at local byte address ''0x00100000''. Use an address delta of 640 bytes. Local memory is configured, the range is reserved for this operation, and the drawing engines are idle on entry. ===== Register Assignment ===== ^ Register ^ Value ^ Use ^ Required write-to-fill gap ^ | ''a0 / %128'' | ''0x00000001'' | Format: one byte per pixel | 3 instructions | | ''a1 / %129'' | ''0xFFFFFFFF'' | Write mask | 1 instruction | | ''a2 / %130'' | ''0x5A5A5A5A'' | Eight-bit color replicated four times | 2 instructions | | ''%200'' | ''0x00100000'' | S2 even: starting byte address | — | | ''%201'' | ''0x00000140'' | S2 odd: 320 pixels | — | | ''%202'' | ''0x00000280'' | S1 scalar: next-line address delta | — | ''%16'' is the hardwired all-ones constant and ''%0'' is zero. With SDRAM, mask bits 0, 8, 16 and 24 enable all four bytes; with SGRAM every mask bit enables its write bit. No Pixel Engine format register is needed for this Fill Engine operation. Sources: [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=7|Technical Spec, p.7]], [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=21|Technical Spec, p.21]], [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=23|Technical Spec, p.23]] ===== Assembly ===== ; 8-bit solid fill. Local memory already configured; engines idle. ; Clobbers %40, %128..%130, %200..%205. li %40, 0x0000 ; Disable Triangle Engine shadowing. lui %200, 0x0010 ; S2 even: local byte address 0x00100000. li %201, 320 ; S2 odd: pixel count. li %202, 640 ; S1: address delta for the next scan line. li %128, 1 ; a0: one byte per pixel. or %129, %16, %0 ; a1: all-ones write mask. lui %130, 0x5A5A ; a2: upper half of replicated color. li %203, 0x5A5A or %130, %130, %203 ; a2 = 0x5A5A5A5A; final color write. li %205, 2 ; Flag.PixelBusy mask; gap 1. add %0, %0, %0 ; Gap 2. add %0, %0, %0 ; Gap 3. fill %200, %200, %202 ; Encoded word 0xE8C8C8CA. wait_fill: and %204, %37, %205 ; Flag.PixelBusy includes Fill. bnez wait_fill, %204 add %0, %0, %0 ; Branch delay slot. halt 0 The final color write has three intervening instructions before ''fill'', exceeding its hazard of two. Format and write mask have seven and six intervening instructions respectively. The waits are counted from the **last** write of each parameter. ''fill %200,%200,%202'' encodes as ''0xE8C8C8CA''. S2 starts at even index 200; its odd word supplies length. The instruction writes ''%200 = 0x00100280'' for the next scan line. The filled range is ''0x00100000..0x0010013F''. Fill launches in one cycle after any required engine wait and runs independently. The completion loop tests Flag.PixelBusy, which includes Fill, Triangle and Pixel. Host reads of the written range must wait for rendering idle to preserve coherency. The program disables triangle shadowing before using a0..a2 as fill parameters. It uses solid ''fill'', so the conflicting cbrush depth descriptions do not apply. FIFO is not an operand of ''fill''. Sources: [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=8|Technical Spec, p.8]], [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=11|Technical Spec, p.11]], [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=21|Technical Spec, p.21]], [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=22|Technical Spec, p.22]], [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=23|Technical Spec, p.23]], [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=25|Technical Spec, p.25]], [[https://verite.3d32.org/_media/source/v2200spec.pdf#page=38|Technical Spec, p.38]] [[drawing:fill|Fill reference]] · [[registers:risc-shadow-views:shadow_128|a0 format]] · [[registers:risc-shadow-views:shadow_129|a1 mask]] · [[registers:risc-shadow-views:shadow_130|a2 color]] · [[examples:start|Examples]]