Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "Graphics Minterms"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
Line 63: Line 63:
 
|}
 
|}
   
Since the A channel is non-zero only when inside the rectangle, our truth table simplifies to:
+
Channel A is non-zero only when inside the rectangle. Channel C and D are the same. Therefore, our truth table simplifies to:
   
 
{| class="wikitable"
 
{| class="wikitable"
! A !! B !! C !! D !! Bit !! Minterm
+
! B !! C !! Bit !! Minterm
 
|-
 
|-
| 1 || 0 || 0 || ? || 4 || ANBNC
+
| 0 || 0 || 4 || NBNC
 
|-
 
|-
| 1 || 0 || 1 || ? || 5 || ANBC
+
| 0 || 1 || 5 || NBC
 
|-
 
|-
| 1 || 1 || 0 || ? || 6 || ABNC
+
| 1 || 0 || 6 || BNC
 
|-
 
|-
| 1 || 1 || 1 || ? || 7 || ABC
+
| 1 || 1 || 7 || BC
 
|}
 
|}
   
This means only the upper 4 bits (bits 4 to 7) of the minterm are used to select the logic operation and the lower bits (0 to 3) will always be zero.
+
This means only the upper 4 bits (bits 4 to 7) of the minterm are used to select the logic operation. The lower bits (0 to 3) will always be zero because channel A is always non-zero or inside the rectangle.

Revision as of 19:52, 28 September 2015

Several graphics function calls require a minterm value to be specified which defines a logic function to perform.

Some background knowledge of the classic Amiga blitter hardware is helpful to understand how to calculate it.

Classic Amiga Blitter

The blitter can combine the data from the three source DMA channels in up to 256 different ways to generate the values stored by the destination DMA channel. These sources might be one bitplane from each of three separate graphics images. While each of these sources is a rectangular region composed of many points, the same logic operation will be performed on each point throughout the rectangular region. Thus, for purposes of defining the blitter logic operation it is only necessary to consider what happens for all of the possible combinations of one bit from each of the three sources.

There are eight possible combinations of values of the three bits, for each of which we need to specify the corresponding destination bit as a zero or one. This can be visualized with a standard truth table, as shown below. We have listed the three source channels, and the possible values for a single bit from each one.

A B C D BLTCON0
position
Minterm
0 0 0 ? 0 NANBNC
0 0 1 ? 1 NANBC
0 1 0 ? 2 NABNC
0 1 1 ? 3 NABC
1 0 0 ? 4 ANBNC
1 0 1 ? 5 ANBC
1 1 0 ? 6 ABNC
1 1 1 ? 7 ABC

Where 'N' represents 'not'.

This information is collected in a standard format, the LF (Logic Function) control byte in the BLTCON0 register. This byte programs the blitter to perform one of the 256 possible logic operations on three sources for a given blit.

To calculate the LF control byte in BLTCON0, fill in the truth table with desired values for D, and read the function value from the bottom of the table up.

For example, if we wanted to set all bits in the destination where the corresponding A source bit is 1 or the corresponding B source bit is 1, we would fill in the last four entries of the truth table with 1 (because the A bit is set) and the third, fourth, seven, and eight entries with 1 (because the B bit is set), and all others (the first and second) with 0, because neither A nor B is set. Then, we read the truth table from the bottom up, reading 11111100, or $FC.

For another example, an LF control byte of $80 ( = 1000 0000 binary) turns on bits only for those points of the D destination rectangle where the corresponding bits of A, B, and C sources were all on (ABC = 1, bit 7 of LF on). All other points in the rectangle, which correspond to other combinations for A, B, and C, will be 0. This is because bits 6 through 0 of the LF control byte, which specify the D output for these situations, are set to 0.

Graphics Minterms

The blitter functions provided by graphics.library were originally designed to support the classic Amiga blitter with a total of 4 DMA channels. Modern graphics cards have their own blitter(s) which programmers are not allowed direct access to. However, the minterm value still exists to help specify logic operations to perform while performing the copy which may or may not be assisted by the graphics card hardware.

The roles of each of the 4 channels are as follows:

Channel Description
A Non-zero when inside the rectangle
B Source rectangle
C Destination rectangle
D Destination rectangle

Channel A is non-zero only when inside the rectangle. Channel C and D are the same. Therefore, our truth table simplifies to:

B C Bit Minterm
0 0 4 NBNC
0 1 5 NBC
1 0 6 BNC
1 1 7 BC

This means only the upper 4 bits (bits 4 to 7) of the minterm are used to select the logic operation. The lower bits (0 to 3) will always be zero because channel A is always non-zero or inside the rectangle.