User Manual for the Atari ST Bit-Block Transfer Processor (BLiTTER) The Atari Corporation Sunnyvale, California 17 June 1987 Table of Contents 1. Introduction .......- ccc ccc c ccc c ces cces oe @ @ @@mUchOUmUCUCOUmUCUCOmUCUCOUCUOUCUMO N 2. Bit-Block Transfers ..........- cc cececes Ff 3. Functional Description ..........2-..00. Aa 4. Programming Model ...............-....-. eo eee @e8e8f ehmUMmUCUCOmUCOUCUO PWNFWOMAODM 4.1. Register Map .......2..cc. ccc ceecene . 4.2. Bit-Block Addresses ....... cc ee eeee 4.3. Bit-Block Alignments .............. 4.4. Logic Operations ..............e- cee bt bt be 4.5. Halftone Operations ..........62.... 4.6. Bus AcceSSeS .......c.eee0. cece ec eces Appendix A -- Programming Example ......... 15 Appendix B -- Extended ST BIOS Blit Configuration ..... 23 Appendix C — References ceeeeveeeereeeeeee eee e eoeeees5$ee#eke#eeeee 29 The Atari Corporation 17 June 1987 1 SHeader: blitter.me,v 2.2 87/06/17 14:50:06 art Exp §$ SSource: /u/art/0O docs/RCS/blitter.me,v $ SAuthor: art $ SRevision: 2.2 $ SDate: 87/06/17 14:50:06 §$ SState: Exp $ SLocker: art $ SLog: blitter.me,v $ Revision 2.2 87/06/17 14:50:06 art FEE SE HE Added new appendix for extended ST BIOS call. Revision 2.1 87/06/15 15:10:54 art Released. EE Revision 1.3 87/06/15 14:58:36 art SHE sth He HE HE He HE HEE Changed Bit-Block Transfers section after internal review. Revision 1.2 87/06/12 02:28:39 art Cleaned up previous hack. Revision 1.1 87/06/02 13:58:33 art Initial revision The Atari Corporation 17 June 1987 2 THE SCOPE OF THIS DOCUMENT is limited to a functional description of the Atari ST BLiTTER. This document is not a data sheet for system integration, rather it is a user manual for system programming. For more information, please refer to the texts listed at the end of this document. 1. Introduction The Atari ST Bit-Block Transfer Processor (BLiTTER) is a hardware implementation of the bit-block transfer (BitBl1t aka blit) algorithm. BitBlt can be simply described as a procedure that moves bit-aligned data from a source location to a destination location through a given logic operation. The BitBlt primitive can be used to perform such operations as: Area seed filling Rotation by recursive subdivision OoO0000000 Slice and smear magnification Brush line drawing using Bresenham DDA Text transformations eg bold, italic, outline Text scrolling Window updating Pattern filling And general memory-to-memory block copying [1]. The heart of BitBlt was first formally defined by New- man and Sproull in their description of the function RasterOp [2]. As defined, RasterOp performed its. block transfers on a bit-by-bit basis and was limited to a small subset of possible source and destination Boolean combina- tions. Enhancements to RasterOp such as processing bits in parallel or introducing a halftone pattern into the transfer were literally left as exercises for the reader. In an effort to improve the functionality and perfor- mance of the original algorithm, the prescribed enhancements were incorporated into the definition of RasterOp and imple- mented in hardware as the RasterOp Chip [3]. However the RasterOp Chip lacked the two-dimensionality of the original function and suffered from a performance bottleneck caused by the loading and reloading of source, destination, and halftone data (ie it could not DMA). While efforts were being made to improve the perfor- mance of RasterOp, the formal definition of RasterOp was further refined and became the basis of the BitBlt copyLoop primitive in the Smalltalk-80 graphics kernel [4]. Because of its comprehensive interface definition, the BitBlt The Atari Corporation 17 June 1987 3 primitive was inefficient and required special-case optimi- zations that violated its general-purpose nature. Clearly a hardware solution was necessary to increase the performance of the BitBlt copyLoop without sacrificing its functional- ity. The Atari ST BLiTTER is a hardware solution to the per- formance problems of BitBit. The BLiTTER is a DMA device that implements the full BitBlt copyLoop definition with the addition of a few minor extensions. Single word or multi- word increments and decrements are provided for transfers to destinations in Atari ST video display memory. A center mask, which would otherwise be a constant all ones, is. also provided for an additional level of texture. The remainder of this document is directly based on the original func- tional description of the Atari ST BLiTTER. The Atari Corporation 17 June 1987 4 2. Bit-Block Transfers As previously stated, a bit-block transfer can be described as a procedure that moves bit-aligned data from a source location to a destination location through a given logic operation. There are sixteen logic combination rules associated with the merging of source and destination data. Note that this set contains all possible combinations between source and destination. The following table con- tains the valid BitBit combination rules: LOGIC OPERATIONS (~s&~d)|(~s&d) | (s&~d) | (s&d) MSB LSB OP COMBINATION RULE O O 0 O all zeros O O 1 1 source AND destination HHHEHOOOOOOOO 0 1 O 2 source AND NOT destination 0 1 1 3 source 1 0 O 4 NOT source AND destination 1 0 1 5 destination 1 1 O 6 source XOR destination 1 1 1 7 source OR destination 0 O 0 8 NOT source AND NOT destination O 0 1 9 NOT source XOR destination O 1 O A NOT destination O 1 1 B source OR NOT destination 1 O O Cc NOT source PREP 1 O 1 D NOT source OR destination 1 1 O E NOT source OR NOT destination 1 1 1 F all ones Adjustments to block extents and several other transfer parameters are determined prior to the invocation of the actual block transfer. These adjustments and parameters include clipping, skew, end masks, and overlap. Clipping. The source and destination block extents are adjusted to conform with a specified clipping rectangle. Since both source and destination blocks are of equal dimen- sion, the destination block extent is clipped to the extent of the source block (or vice versa). Note that the block transfer need not be performed if the resultant extent is zero. Skew. The source-to-destination horizontal bit skew is calculated. The Atari Corporation 17 June 1987 o End Masks. The left and right partial word masks are determined. The masks are merged if the destination is one word in width. Overlap. The block locations are checked for possible overlap in order to avoid the destruction of source data before it is transferred. In non-overlapping transfers the source block scanning direction is inconsequential and can by default be from upper left to lower right. In overlapping transfers’ the source scanning direction is also from upper left to lower right if the source-to-destination transfer direction is up and/or to the left (ie source address is greater than or equal to destination address). However, if the overlapping source-to-destination transfer direction is down and/or to the right (ie source address is less than destination address), then the source data is scanned from lower right to upper left. After the transfer parameters are determined the bit- block transfer operation can be invoked, transferring source to destination through the logic operation (HALFTONE and HOP will be described in the next section): BIT-BLOCK TRANSFER | SOURCE SOURCE DESTINATION | [<< SKEW HALFTONE HOP LOGIC OP | ENDMASK | | NEW DESTINATION The Atari Corporation 17 June 1987 6 3. Functional Description Please refer to the bit-block transfer diagram in the previous section. To understand how the components of a block transfer work, let's look at the simplest possible transfer. Take the case where we wish to fill a block of memory with either all zeros or all ones (OP = O or OP = F). In this case only the LOGIC OP block, which generates the ones or zeros, and the ENDMASK block are in the data path. If the end mask contains all ones, the BLiTTER will simply write one word after the other to the destination address without ever reading the destination. As the writes take place the destination address will be adjusted according to the values in the DESTINATION X INCREMENT, DESTINATION Y INCREMENT, X COUNT, and Y COUNT registers. These registers define the size and shape of the block to be transferred. The X and Y COUNT registers define the size of the block. The X COUNT register specifies the number of word-size writes required to update one line of the destination. The Y COUNT register specifies the number of these lines in the block. The DESTINATION X INCREMENT register is a signed (2's complement) 16-bit quantity which is added to the destination address to calculate the address of the next destination word of the line. On the last write of the line the DESTINATION Y INCREMENT is added to calcu- late the address of the first word of the next line. The end mask determines which bits of the destination word will be updated. Bits of the destination which correspond to ones in the end mask will be updated. Bits of the destination which correspond to zeros in the end mask will remain unchanged. Note that if any bits of the desti- nation are to be left unchanged, a read-modify-write is required. In order to improve performance a read will only be performed if it is required. There are three ENDMASK registers numbered 1 through 3. ENDMASK 1 is used only for the first write of the line. ENDMASK 3 is used only for the last write of the line. ENDMASK 2 is used for all other writes. Now let's consider a more complicated case, suppose we want to xXOR a destination block with a 16x16 halftone pat- tern. First we load the HALFTONE RAM with the halftone pat- tern. Select halftone only using the HOP register and select source XOR destination using the OP register. The LINE NUMBER register is used to specify which of the 16 words of HALFTONE RAM is used for the current line. This register will be incremented or decremented at the end of each line according to the sign of the DESTINATION Y INCRE- MENT register. Set the DESTINATION X and Y INCREMENT and X and Y COUNT registers to the appropriate values and start the transfer. This same procedure can be followed to do the The Atari Corporation 17 June 1987 7 combination using any logic operation by simply changing the value in the OP register. Similarly the combination can be performed using a source block instead of the HALFTONE RAM or using the logical AND of a source block and the HALFTONE RAM by changing the value of the HOP register. A source block is the same size as the destination block but may have different increments and address defined by the SOURCE X and Y INCREMENT and SOURCE ADDRESS registers. Finally, let's look at the case when the source. and destination blocks are not bit-aligned. In this case we may need to read the first two source words into the 32-bit source buffer and use the 16 bits that line up with the appropriate bits of the destination, as specified by the SKEW register. When the next source word is read, the lower 16 bits of the source buffer is transferred to the upper 16 bits and the lower is replaced by the new data. This pro- cess is reversed when the source is being read from _ the right to the left (SOURCE xX INCREMENT negative). Since there are cases when it may be necessary for an extra source read to be performed at the beginning of each line to "prime" the source buffer and cases when it may not _ be necessary due to the choice of end mask, a bit has been pro- vided which forces the extra read. The FXSR (aka pre-fetch) bit in the SKEW register indicates, when set, that an extra source read should be performed at the beginning of each line to "prime" the source buffer. Similarly the NFSR (aka post-flush) bit, when set, will prevent the last source read of the line. This read may not be necessary with certain combinations of end maskKs and _e skews. If the read is suppressed, the lower to upper half buffer transfer still occurs. Also in this case, a read-modify-write cycle is performed on the destination for the last write of each line regardless of the value of the corresponding ENDMASK regis- ter. | The Atari Corporation 17 June 1987 8 4. Programming Model The BLiTTER contains a set of registers that specify bit-block addresses, bit-block alignments, logic and halftone operations, and bus accesses. The register set-up time remains practically constant and is large relative to small block transfers, whereas large bit-blocks are _ dom- inated by the execution time of the transfer itself. 4.1. Register Map The following is a map of the BLiTTER programmable registers (note that all unused bits read back as zeros): REGISTER MAP FF 8A00 QOC00O00D | | COOCO0000 HALFTONE RAM FF 8A02 OCO000000 | | COCO0000 FF 8A04 OOCO0O0CO | | COCOO0000 FF 8A1E OO000000 | | CO0CO0000 FF 8A20 QO000000 | | COOO000- SOURCE X INCREMENT FF 8A22 OOO0O00000 | | CO00000- SOURCE Y INCREMENT FF 8A24 3 £4|-------- OO0O000000 SOURCE ADDRESS FF 8A26 OQOC00000 | | COCO000- FF 8A28 OO000000 | | COCO0000 ENDMASK 1 FF 8A2A OO000000 | | COOO0000 ENDMASK 2 FF 8A2C OO000000 | | COCO0000 ENDMASK 3 FF 8A2E QOO000000 |} | COOC000- DESTINATION X INCREMENT FF 8A30 OQO000000 | | COOC000- DESTINATION Y INCREMENT FF 8A32 |rrccre--- OO000000 DESTINATION ADDRESS FF 8A34 OOO0000N | | CO0COC00- FF 8A36 OO000000 | | COOO0000 X COUNT FF 8A38 OO000000 | | COOO0000 Y COUNT FF 8A3A 3 £#t------ oo HOP FF 8A3B ----0000 OP FF 8A3C | c(00-0000 || LINE NUMBER SMUDGE HOG BUSY FF 8A3D | c0--0000 | __ SKEW NFSR FXSR The Atari Corporation 17 June 1987 9 4.2. Bit-Block Addresses This subsection describes registers that specify bit- block origins, address increments, and extents. SOURCE ADDRESS This 23-bit register contains the current address of the source field (only word addresses may be speci- fied). It may be accessed using either word or 1ong- word instructions. The value read back is always the address of the next word to be used in a source opera- tion. It will be updated by the amounts specified in the SOURCE X INCREMENT and the SOURCE Y INCREMENT registers as the transfer progresses. SOURCE X INCREMENT This is a signed 15-bit register, the least significant bit is ignored, specifying the offset in bytes to the address of the next source word in the current line. This value will be sign-extended and added to the SOURCE ADDRESS register at the end of ae source word fetch, whenever the X COUNT register does not contain a value of one. If the X COUNT register is loaded with a value of one this register is not used. Byte instruc- tions can not be used to read or write this register. SOURCE Y INCREMENT This is a signed 15-bit register, the least significant bit is ignored, specifying the offset in bytes to the address of the first source word in the next line. This value will be sign-extended and added to the SOURCE ADDRESS register at the end of the last source word fetch of each line (when the X COUNT register con- tains a value of one). If the xX COUNT register is loaded with a value of one this register is used exclusively. Byte instructions can not be used to read or write this register. DESTINATION ADDRESS This 23-bit register contains the current address of the destination field (only word addresses may be specified). It may be accessed using either word or long-word instructions. The value read back is always the address of the next word to be modified in the des- tination field. It will be updated by the amounts specified in the DESTINATION X INCREMENT and the DESTI- NATION Y INCREMENT registers as the transfer progresses. DESTINATION X INCREMENT This is a signed 15-bit register, the least significant bit is ignored, specifying the offset in bytes to the address of the next destination word in the current The Atari Corporation 17 June 1987 10 line. This value will be sign-extended and added to the DESTINATION ADDRESS register at the end of a desti- nation word write, whenever the X COUNT register does not contain a value of one. If the X COUNT register is loaded with a value of one this register is not used. Byte instructions can not be used to read or write this register. DESTINATION Y INCREMENT : This is a signed 15-bit register, the least significant bit is ignored, specifying the offset in bytes to the address of the first destination word in the next line. This value will be sign-extended and added to the DES- TINATION ADDRESS register at the end of the last desti- nation word write of each line (when the X COUNT regis- ter contains a value of one). If the X COUNT register is loaded with a value of one this register is used exclusively. Byte instructions can not be used to read or write this register. X COUNT This 16-bit register specifies the number of words con- tained in one destination line. The minimum number is one and the maximum is 65536 designated by zero. Byte instructions can not be used to read or write this register. Reading this register returns the number of destination words yet to be written in the current line, NOT necessarily the value initially written to the register. Each time a destination word is written the value will be decremented until it reaches zero, at which time it will be returned to its initial value. Y COUNT This 16-bit register specifies the number of lines in the destination field. The minimum number is one and the maximum is 65536 designated by zero. Byte instruc- tions can not be used to read or write this register. Reading this register returns the number of destination lines yet to be written, NOT necessarily the value ini- tially written to the register. Each time a destina- tion line is completed the value will be decremented until it reaches zero, at which time the tranfer is complete. The Atari Corporation 17 June 1987 11 4.3. Bit-Block Alignments This subsection describes registers that specify bit- block end masks, source-to-destination skew, and source data fetching. ENDMASK 1, 2, 3 These 16-bit registers are used to mask destination writes. Bits of the destination word which correspond to ones in the current ENDMASK register will be modi- fied. Bits of the destination word which correspond to zeros in the current ENDMASK register will remain unchanged. The current ENDMASK register is determined by position in the line. ENDMASK 1 is used only for the first write of a line. ENDMASK 3 is used only for the last write of a line. ENDMASK 2 is used in all other cases. In the case of a one word line ENDMASK 1 is used. Byte instructions can not be used to read or write these registers. SKEW The least significant four bits of the byte-wide regis- ter at FF 8A3D specify the source skew. This is the amount the data in the source data latch is’ shifted right before being combined with the halftone mask and destination data. FXSR FXSR stands for Force eXtra Source Read. When this bit is set one extra source read is performed at the start of each line to initialize the remainder portion source data latch. NFSR NFSR stands for No Final Source Read. When this bit is set the last source read of each line is not performed. Note that use of this and/or the FXSR bit the requires an adjustment to the SOURCE Y INCREMENT and SOURCE ADDRESS registers. The Atari Corporation 17 June 1987 4.4. Logic Operations This subsection describes registers that specify the logic combinations of source and destination bit-block data. OP The least significant four bits of the byte-wide regis- ter at FF 8A3B specify the source/destination combina- tion rule according to the following table: LOGIC OPERATIONS Oo Pp COMBINATION RULE all zeros source AND destination NAOQWPODNAUAWNEO source AND NOT destination source NOT source AND destination destination source XOR destination source OR destination NOT source AND NOT destination NOT source XOR destination NOT destination source OR NOT destination NOT source NOT source OR destination NOT source OR NOT destination all ones The Atari Corporation 17 June 1987 13 4.5. Halftone Operations This subsection describes registers that specify the halftone pattern memory, halftone word index, and combina- tions of source and halftone data. HALFTONE RAM This RAM holds a 16x16 halftone pattern mask. Each word is valid for one line of the destination field and is repeated every 16 lines. The current word is pointed to by the value in the LINE NUMBER register. These registers may be read, but can not be accessed using byte-wide instructions. LINE NUMBER The least significant four bits of the byte-wide regis- ter at FF 8A3C specify the current halftone mask. The current value times two plus FF8A0O0 gives the address of the current halftone mask. This value is incre- mented or decremented at the end of each line and will wrap through zero. The sign of the DESTINATION Y INCREMENT determines if the line number is incremented or decremented (increment if positive, decrement if negative). SMUDGE The SMUDGE bit, when set, causes the least significant four bits of the skewed source data to be used as the address of the current halftone pattern. Note that the halftone operation is still valid when SMUDGE is set. HOP The least significant two bits of the byte-wide regis- ter at FF 8A3A specify the source/halftone combination rule according to the following table: HALFTONE OPERATIONS HOP COMBINATION RULE O all ones 1 halftone 2 source 3 source AND halftone The Atari Corporation 17 June 1987 14 4.6. Bus Accesses This subsection describes registers that specify bus access control and BLiTTER start/status. HOG The HOG bit, when cleared, causes the processor and the BLiTTER to share the bus equally. In this mode each will get 64 bus cycles while the other is halted. When set, the bit will cause the processor to be halted until the transfer is complete. In either case _ the BLiTTER will yield to other DMA devices. Bus arbitra- tion may allow the processor to execute one or more instructions even in hog mode. Therefore, don't assume that the instruction following the one which sets’7 the BUSY bit will be executed only after the transfer is complete. The BUSY bit may be polled to achieve this kind of synchronization. BUSY The BUSY bit is set after all the other registers have been initialized to begin the transfer operation. It will remain set until the transfer is complete. The interrupt line is a duplicate of this bit. See the Programming Example for more details on how to use the BUSY bit. The Atari Corporation 17 June 1987 15 Appendix A -- Programming Example In order to maintain software compatibility with new or upgraded Atari STs equipped with the BLiTTER, software developers need only follow guidelines set forth by the VDI and "LINE A" documents. Revised TOS ROMs will work in con- cert with the BLiTTER, enhancing the performance of many VDI and "LINE A" operations. This occurs in a manner tran- Sparent to an executing program. Thus no special actions need be taken to utilize the performance advantages of the BLiITTER. As a rule of thumb, never make a VDI or "LINE A" call from within an interrupt context since unpredictable and potentially catastrophic results will occur should one BLiTTER operation interrupt another BLiTTER operation. The following program has not been optimized and is presented here for exemplary purposes only. * (c) 1987 Atari Corporation * All Rights Reserved. * BLiTTER BASE ADDRESS BLiTTER equ SFF8A00 * BLiTTER REGISTER OFFSETS Halftone equ 0 Sre Xinc equ 32 Sre_ Yine equ 34 Sre_ Addr equ 36 Endmaskl equ 40 Endmask2 equ 42 Endmask3 equ 44 Dst Xinc equ 46 Dst Yinc equ 48 Dst_ Addr equ 50 X Count equ 54 ¥Y Count equ 56 HOP equ 58 OP equ 59 Line Num equ 60 Skew equ 61 The Atari Corporation 17 June 1987 16 * BLiTTER REGISTER FLAGS fHOP Source equ 1 fHOP Halftone equ O fSkewFXSR equ 7 fSkewNFSR equ 6 fLineBusy equ 7 fLineHog equ 6 fLineSmudge equ 5 * BLiTTER REGISTER MASKS mHOP Source equ $02 mHOP Halftone equ $01 mSkewFXSR equ $80 mSkewNFSR equ $40 mLineBusy equ $80 mLineHog equ $40 mLineSmudge equ $20 * EnDmaAs K qdAtA * * These tables are referenced by PC relative instructions. Thus, *& the labels on these tables must remain within 128 bytes of the * referencing instructions forever. Amen. * * QO: Destination 1: Source <<< Invert right end mask data >>> 1f endmask: dc.w SFFFF rt _endmask: dc.w S7FFF dc.w S3FFF dc.w S1LFFF dc.w SOFFF dc.w SO7FF dc.w SO3FF dc.w SO1FF dc.w SOOFF dc.w S$OO7F dc.w SOO3F dc.w SOO1F dc.w SOOOF dc.w $0007 dc.w $0003 dc.w $0001 dc.w $0000 The Atari Corporation 17 June 1987 1‘7 TITLE: BLiT iT ee ee PuRPOS E: Transfer a rectangular block of pixels located at an arbitrary X,Y position in the source memory form to eeee another arbitrary X,Y position in the destination memory form using replace mode (boolean operator 3). The source and destination rectangles should not overlap. iN: a4 pointer to 34 byte input parameter block NoTe: This routine must be executed in supervisor mode as access is made to hardware registers in the protected region of the memory map. InPuT pATrAMEtEr Bl1loOc kK oFfSse?Ts SRC FORM equ O ; Base address of source memory form SRC_NXWD equ 4; Offset between words in source plane SRC_NXLN equ 6 ; Source form width SRC_NXPL equ 8; Offset between source planes SRC_XMIN equ 10 ; Source blit rectangle minimum X SRC_YMIN equ 12 ; Source blit rectangle minimum Y DST FORM equ 14 ; Base address of destination memory form DST_NXWD equ 18 ; Offset between words in destination plane DST _NXLN equ 20 ; Destination form width DST_NXPL equ 22 ; Offset between destination planes DST_XMIN equ 24 ; Destination blit rectangle minimum X DST _YMIN equ 26 ; Destination blit rectangle minimum Y WIDTH equ 28 ; Width of blit rectangle HEIGHT equ 30 ; Height of blit rectangle PLANES equ 32 ; Number of planes to blit BLiT iT: lea BLITTER,a5 ; a5-> BLiTTER register block * * Calculate Xmax coordinates from Xmin coordinates and width * move .w WIDTH(a4),d6 subq.w #1,d6 =6 d6<- width-1 move .w SRC _XMIN(a4),d0 =e d0<- src Xmin move .w qd, dl add.w do,dl se di<- sre Xmax sre Xmin + width-l1 move .w DST XMIN(a4),d2 =e a2z<- adst Xmin move .w d2,d3 add.w d6,d3 ne d3<- dst Xmax dst Xmin + width-1l The Atari Corporation 17 June 1987 18 * * Endmasks are derived from source Xmin mod 16 and source Xmax mod 16 * moveq.1 #SOF ,d6 > a6<- mod 16 mask move .w d2,d4 VE qg4<- DST XMIN and.w d6,d4 30 d4<- DST XMIN mod 16 add.w d4,d4 -e ad4<- offset into left end mask tbl move.w 1f endmask(pc,d4.w) “ G4 ; d4<- left endmask move .W a3,d5 VE qad5<- DST XMAX and.w d6,d5 NO qad5<- DST XMAX mod 16 add.w da5,d5 -e qad5<- offset into right end mask tbl move .W rt endmask(pc,d5.w) a5 ; dS<- inverted right end mask not.w a5 “en dqd5<- right end mask Skew value is (destination Xmin mod 16 - source Xmin mod 16) OF OF OE OH && OxOOOF. Three discriminators are used to determine the states of FXSR and NFSR flags: bit O O: Source Xmin mod 16 =< Destination Xmin mod 16 FF 1:3 Source Xmin mod 16 > Destination Xmin mod 16 EH bit 1 O: SrcxXmax/16-SrceXmin/16 <> DstXmax/16-DstXmin/16 Source span Destination span HF 1: SrcoXmax/16-SrcXmin/16 == DstXmax/16-DstXmin/16 bit 2 O: multiple word Destination span EE 1: single word Destination span ee These flags form an offset into a skew flag table yielding correct FXSR and NFSR flag states for the given source and Cee destination alignments move .w d2,da7/ VE qd7<- Dst Xmin and.w d6,da7 NE a7<- Dst Xmin modl16 and.w do, dé VE d6<- Sre Xmin modl16 sub.w d6,a7 VE gad7<- Dst Xmin mod16-Sre Xmin modl6 Ve if Sx&F > Dx&F then cy:1 else cy:0 clr.w do Ve qad6<- initial skew flag table index addx.w d6é,d6 se ad6[bitO}]<- intraword alignment flag 1lsr.w #4,d0 VO qdO<- word offset to src Xmin 1lsr.w #4,d1 Oe dl<- word offset to src Xmax sub.w dO, dl we di<- Sre span - l lsr.w #4,d2 VO dad2<- word offset to dst Xmin lsr.w #4,d3 NO d3<- word offset to dst Xmax sub.w d2,d3 Me dad3<- Dst span - 1 bne set endmasks se 2nd discriminator is one word dst The Atari Corporation 17 June 1987 19 * When destination spans a single word, both end masks are merged x into Endmaskl1. The other end masks will be ignored by the BLiTTER and.w d5,d4 NO d4<- single word end mask addq.w #4, d6 ee ad6[bit2]:1 => single word dst set endmasks: move.w d4, Endmask1(a5) ; left end mask move .w #SFFFF, Endmask2(a5) e g center end mask move .w qg5, Endmask3(a5) ; right end mask cmp.w d1,d3 ; the last discriminator is the bne set count ; equality of sre and dst spans addq.w #2,da6 ; d6[bit1]:1 => equal spans set count: move .w d3,d4 addq.w #1,d4 Ne qa4<- number of words in dst line move.w d4,X Count(ad) me set value in BLiTTER * Calculate Source starting address: FF Source Form address (Source Ymin * Source Form Width) + + +t ((Source Xmin/16) * Source Xinc) move.l SRC_FORM(a4),a0 VE aO-> start of Src form move .w SRC YMIN(a4),d4 Re d4<- offset in lines to Sre Ymin move .w SRC_NXLN(a4),d5 Ne d5<- length of Src form line mulu q5,d4 SMe d4<- byte offset to (0, Ymin) add.1 qd4,a0 =e aO-> (0, Ymin) move .W SRC_NXWD(a4),d4 ee ) d4<- offset between consecutive move .W d4,Sre_ Xinc(a5) sr words in Src plane mulu d4,d0 %e qdO<- offset to word containing Xmin add.1 dO, a0 ne aO-> lst src word (Xmin, Ymin) * Sre Yine is the offset in bytes from the last word of one Source * line to the first word of the next Source line mulu d4,dl Ne di<- width of src line in bytes sub.w di,d5 Re d5<- value added to pointer at end move .w qgd5,Sre_Yince(a5) "e of line to reach start of next * Calculate Destination starting address move.1 DST FORM(a4),al ; al-> start of dst form. move .w DST YMIN(a4),d4 ; dad4<- offset in lines to dst Ymin move .w DST NXLN(a4),d5 ; dad5<- width of dst form The Atari Corporation 17 June 1987 20 mulu q5,d4 Se dqd4<- byte offset to (0, Ymin) add.1 d4,al =e al-> dst (0, Ymin) move.w DST NXWD(a4),d4 Ne d4<- offset between consecutive move.w d4,Dst_Xinc(a5) se words in dst plane mulu d4,da2 Ne a2<- DST _NXWD * (DST _XMIN/16) add.1 d2,al =e al-> lst dst word (Xmin, Ymin) Calculate Destination Yinc mulu d4,d3 ne d3<- width of dst line - DST NXWD sub.w a3 ,d5 M6 d5<- value added to dst pointer at move.w d5,Dst_Yinc(a5) =e end of line to reach next line The low nibble of the difference in Source and Destination alignment + is the skew value. Use the skew flag index to reference FXSR and NFSR states in skew flag table. and.b #SOF,d7 VO dad7<- isolated skew count or.b skew flags(pc,d6.w),d7 RO qad7<- necessary flags and skew move.b d7,Skew(a5) see load Skew register move.b #mHOP Source, HOP(a5) Ne set HOP to source only move.b #3,0P(a5) se set OP to "replace" mode lea Line Num(a5),az2 VO fast ref to Line Num register move.b #fLineBusy,d2 Ve fast ref to LineBusy flag move.w PLANES(a4),d7 we d7 <- plane counter bra begin The Atari Corporation 17 June 1987 21 * ThE SEtTiNg Of Sk Ew FI1lAdgQs&s * * * QUALIFIERS ACTIONS BITBLT DIRECTION: LEFT -> RIGHT x * equal Sx&F> * spans Dx&F FXSR NFSR * * 0 O O 1 |..SSSSSSSSSSSSSS/SSSSSSSSSSSSSS.. * o---- -adddddddddd | ddddddddddddddddj|dd.............. * * O 1 1 O |...... SSSSSSSSSS | SSSSSSSSSSSSSSSS|SS...-- eee eee eee * . .dddddddddddddd | dddddddddddddd.. * * 1 O O O |..SSSSSSSSSSSSSS|SSSSSSSSSSSSSS.. * -. -ddddddddddddd | ddddddddddddddd. * * 1 1 1 1 |...SSSSSSSSSSSSS/|SSSSSSSSSSSSSSS. * .- .dddddddddddddd}| dddddddddddddd.. skew flags: dc.b mSkKewNFSR ; Source span < Destination span dc.b mSkKewFXSR ; Source span > Destination span dc.b 0 ; Spans equal Shift Source right dc.b mSkewNFSR+mSkewFXSR ; Spans equal Shift Source left * When Destination span is but a Single word ... dc.b 0 ; Implies a Source span of no words dc.b mSkewFXSR ; Source span of two words dc.b 8) ,; Skew flags aren't set if Source and dc.b 0 ; Destination spans are both one word The Atari Corporation 17 June 1987 22 next plane: move.1 a0,Srce_Addr(a5) ; load Source pointer to this plane move.1 al1,Dst_Addr(a5) ; load Destination ptr to this plane move.w HEIGHT(a4),Y Count(a5) ; load the line count move.b #mLineBuSy, (a2) ,; <<< start the BLiITTER >>> add.w SRC_NXPL(a4),a0 ; aO-> start of next src plane add.w DST NXPL(a4),al ,; al-> start of next dst plane The BLiTTER is usually operated with the HOG flag cleared. In this mode the BLiTTER and the ST's cpu share the bus equally, each taking 64 bus cycles while the other is halted. This mode allows interrupts to be fielded by the cpu while an extensive BitBlt is being processed by the BLiTTER. There is a drawback in that BitBits in this shared mode may take twice as long as BitBlts OO executed in hog mode. Ninety percent of hog mode performance is achieved while retaining robust interrupt handling via a method OO of prematurely restarting the BLiTTER. When control is returned to the cpu by the BLiTTER, the cpu immediately resets the BUSY OO flag, restarting the BLiTTER after just 7 bus cycles rather than after the usual 64 cycles. Interrupts pending will be serviced before the restart code regains control. If the BUSY flag is Ok reset when the Y Count is zero, the flag will remain clear indicating BLiTTER completion and the BLiTTER won't be restarted. Oe (Interrupt service routines may explicitly halt the BLiTTER during execution time critical sections by clearing the BUSY flag. Ob The original BUSY flag state must be restored however, before termination of the interrupt service routine. ) restart: bset.b d2,(a2) Restart BLiTTER and test the BUSY nop ,; flag state. The "nop" is executed bne restart , prior to the BLiTTER restarting. * ; Quit if the BUSY flag was clear. begin: dbra d7,next_ plane rts The Atari Corporation 17 June 1987 23 Appendix B -- Extended ST BIOS Blit Configuration Ox40 Blitmode - Get/Set Blit Configuration Synopsis: WORD Blitmode( flag) WORD flag; Extended ST BIOS (trap #14) function number Ox40 (64 decimal) gets and sets the blit configuration. If FLAG is -1 (Oxffff), then no set operation is performed, and _ the current blit configuration is returned. If FLAG is not -l, then the blit configuration is set as follows: bit O: O: set blit mode to soft (use software) 1: set blit mode to hard (use BLiTTER) bits 1..14: undefined, reserved bit 15: must be zero The previous blit configuration is returned in the low word of DO. The fields are: bit O: QO: blits are being done in software 1: blits are being done in hardware bit 1: O: no BLiTTER is available 1: a BLiTTER is installed in the system bits 2..14: undefined, reserved, may be zero or one on return. bit 15: always returned as zero If an attempt is made to set the blit mode to "hard" on a system that does not contain a BLiTTER, the mode is forced to "soft". The reserved fields are for future blit capabilities and other graphics chips. They should be treated as "don't care" fields and should be maintained (intact) because they will acquire meaning in the future. This call works on all ROM versions of the operating system. The Atari Corporation 17 June 1987 24 EXAMPLE CALL USING C #define Blitmode(a) xbios(64,a) curmode = Blitmode(-1); /* get current mode */ Blitmode(curmode | 1); /[* turn on BLiTTER */ do stuff(); /* --- GO some processing */ Blitmode(curmode ); /* restore blit state */ EXAMPLE CALL USING 68000 ASSEMBLY move .w #-1,-(sp) VO DO = Blitmode(-1) move .wW #$40,-(sp) Ne trap #14 NO addq #4,sSp We move .w d0O,-(sp) VO save old blit state Or .W #1,d0 VO make sure it's on move .w d0,-(sp) VO Blitmode(DO) move .w #$40,-(sp) NO trap #14 we addq #4,Sp “oe eee AO some processing ++ move.w #S40,-(sp) Ve restore old blit mode trap #14 Re from stacked old-state addq #4,Sp se The Atari Corporation 17 June 1987 25 Appendix C -- References [1] Rob Pike, Leo Guibas, and Dan Ingalls, "SIGGRAPH ' 84 Course Notes: Bitmap Graphics', AT&T Bell Laboratories 1984, [2] William Newman and Robert Sproull, "Principles of Interactive Computer Graphics', McGraw-Hill 1979, Chapter 18. [3] John Atwood, '16160 RasterOp Chip Data Sheet', Silicon Compilers 1984. See also "VL16160 RasterOp Graphics/Boolean Operation ALU', VLSI Technology 1986. [4] Adele Goldberg and David Robson, '‘'Smalltalk-80: The Language and its Implementation’, Addison-Wesley 1983, Chapter 18. The Atari Corporation