|
|
1.1 root 1: #ifndef lint
2: static char *rcsid_bitblt_apa16_c = "$Header: bitblt_apa16.c,v 10.1 86/11/19 10:50:57 jg Exp $";
3: #endif lint
4: /*
5: * This file contains routines to do hardware bit block transfers (bitblt's)
6: * on the APA-16.
7: *
8: * Copyright (c) 1986 Brown University
9: *
10: * Permission to use, copy, modify and distribute this software and its
11: * documentation for any purpose and without fee is hereby granted, provided
12: * that the above copyright notice appear in all copies, and that both
13: * that copyright notice and this permission notice appear in supporting
14: * documentation, and that the name of Brown University not be used in
15: * advertising or publicity pertaining to distribution of the software without
16: * specific, written prior permission. Brown University makes no
17: * representations about the suitability of this software for any purpose.
18: * It is provided "as-is" without express or implied warranty.
19: *
20: * Written by Daniel Stone, Brown University/IRIS, April 23, 1986.
21: */
22:
23: #if (APA16 && USE_APA16_HDWR)
24:
25: #include "bitblt_int.h"
26: #include "bitblt_apa16.h"
27:
28: /*
29: * This array indicates whether or not the coorisponding combination rule
30: * can be done in hardware. A non-zero indicates the hardware can do it.
31: */
32: #define NO_FUNC 0
33:
34: unsigned short execute_cmd[32] = {
35: BUILD_EXCMD(DECR_QUE_COUNT,ROT_WRDST,LF_CLEAR), /* DstClear 0 */
36: BUILD_EXCMD(DECR_QUE_COUNT,ROT_RECTCP,LF_DSTandSRC),/* SrcAnd 1 */
37: BUILD_EXCMD(DECR_QUE_COUNT,ROT_RECTCP,LF_NotDSTandSRC),/*SrcAndNotDst2*/
38: BUILD_EXCMD(DECR_QUE_COUNT,ROT_RECTCP,LF_COPYSRC), /* SrcCopy 3 */
39: BUILD_EXCMD(DECR_QUE_COUNT,ROT_RECTCP,LF_DSTandNotSRC),/* NotSrcAnd 4 */
40: NO_FUNC, /* DstCopy 5 */
41: BUILD_EXCMD(DECR_QUE_COUNT,ROT_RECTCP,LF_DSTxorSRC), /* SrcXor 6 */
42: BUILD_EXCMD(DECR_QUE_COUNT,ROT_RECTCP,LF_DSTorSRC), /* SrcOr 7 */
43: NO_FUNC, /* NotSrcAndNotDst 8 */
44: NO_FUNC, /* NotSrcXor 9 */
45: BUILD_EXCMD(DECR_QUE_COUNT,ROT_WRDST,LF_NotDST), /*NotDstCopy 10*/
46: NO_FUNC, /* SrcOrNotDst 11*/
47: NO_FUNC, /* NotSrcCopy 12 */
48: NO_FUNC, /* NotSrcOr 13 */
49: BUILD_EXCMD(DECR_QUE_COUNT,ROT_RECTCP,LF_NotDSTorNotSRC),
50: /* NotSrcOrNotDst 14*/
51: BUILD_EXCMD(DECR_QUE_COUNT,ROT_WRDST,LF_SET), /* DstSet 15 */
52: BUILD_EXCMD(DECR_QUE_COUNT,ROT_WRDST,LF_CLEAR),/* TileDstClear 16 */
53: NO_FUNC, /* TileAnd 17 */
54: NO_FUNC, /* TileAndNotDst 18 */
55: NO_FUNC, /* TileCopy 19 */
56: NO_FUNC, /* NotTileAnd 20 */
57: NO_FUNC, /* TileDstCopy 21 */
58: NO_FUNC, /* TileXor 22 */
59: NO_FUNC, /* TileOr 23 */
60: NO_FUNC, /* NotTileAndNotDst 24 */
61: NO_FUNC, /* NotTileXor 25 */
62: BUILD_EXCMD(DECR_QUE_COUNT,ROT_WRDST,LF_NotDST),/*TileNotDstCopy 26 */
63: NO_FUNC, /* TileOrNotDst 27 */
64: NO_FUNC, /* NotTileCopy 28 */
65: NO_FUNC, /* NotTileOr 29 */
66: NO_FUNC, /* NotTileOrNotDst 30 */
67: BUILD_EXCMD(DECR_QUE_COUNT,ROT_WRDST,LF_SET),/* TileDstSet 31 */
68: };
69:
70: /*
71: * Set up hardware to do screen to screen copy then do it.
72: * Returns 1 if the hardware couldn't handle it (should never happen) and 0
73: * if the blt was successful.
74: */
75: apa16_StoS(sv)
76: register Blt_sysdata *sv; /* System variables */
77: {
78: register unsigned short *Qptr = (unsigned short *)LAST_QUE_APA16BASE;
79: register tmp; /* just a garbage register */
80: int c;
81:
82: /*
83: * Check the destination and source bitmap pointers to the screen.
84: * If they are different than the start address of the screen then
85: * offset each rectangle.
86: */
87: if (sv->dst.data > (unsigned short *)APA16BASE) {
88: /*
89: * Take apart the address. Note the address is in bytes
90: * corner_x is in bits so it must be multiplied by 8.
91: */
92: sv->dst.rect.corner_x += (((long)sv->dst.data & 0x7F) << 3);
93: sv->dst.rect.corner_y += (((long)sv->dst.data & 0x7FF80) >> 7);
94: }
95:
96: if (sv->src.data > (unsigned short *)APA16BASE) {
97: /*
98: * Take apart the address. Note the address is in bytes
99: * corner_x is in bits so it must be multiplied by 8.
100: */
101: sv->src.rect.corner_x += (((long)sv->src.data & 0x7F) << 3);
102: sv->src.rect.corner_y += (((long)sv->src.data & 0x7FF80) >> 7);
103: }
104:
105: /*
106: * Wait for the previous command to finish.
107: */
108: WAIT_QUE(c,sv->rule);
109:
110: /*
111: * Load the the instructions that tell the queue command
112: * processor to load:
113: * - The X and Y destination registers with the bottom
114: * right corner of the screen area where the
115: * destination rectangle resides.
116: *
117: * - The X and Y source registers with the bottom right
118: * corner of the source screen area.
119: *
120: * - The destination width and height registers with the
121: * width and height of the rectangle to be moved.
122: *
123: * Then load an execute command instruction with one of the copy source
124: * logic functions and a Raster Operation Type (ROT) of copy screen
125: * to screen.
126: */
127: *Qptr-- = BUILD_REGLOAD(XDST_REG,sv->dst.rect.corner_x+1);
128: *Qptr-- = BUILD_REGLOAD(RECT_YDST_REG,sv->dst.rect.corner_y+1);
129: *Qptr-- = BUILD_REGLOAD(XSRC_REG,sv->src.rect.corner_x+1);
130: *Qptr-- = BUILD_REGLOAD(YSRC_REG,sv->src.rect.corner_y+1);
131: *Qptr-- = BUILD_REGLOAD(WIDTH_REG,(sv->width & 1023));
132: *Qptr-- = BUILD_REGLOAD(RECT_HEIGHT_REG,(sv->height & 1023));
133: *Qptr = execute_cmd[sv->rule];
134:
135: *QUE_PTR_R = SPTR_TO_QPTR(LAST_QUE_APA16BASE);
136:
137: INCR_QUE_COUNT(tmp);
138: return(0);
139: }
140:
141: #ifdef notdef
142: /*
143: * Set up hardware to do memory to screen copy then do it.
144: * Returns 1 if the hardware couldn't handle it (should never happen) and
145: * 0 if the blt was successful.
146: */
147: apa16_MtoS(sv)
148: register Blt_sysdata *sv; /* System variables */
149: {
150: register unsigned short *Qptr = (unsigned short *)LAST_QUE_APA16BASE;
151: register tmp; /* just a garbage register */
152: int c;
153:
154: /*
155: * Wait for the previous command to finish.
156: */
157: WAIT_QUE(c,sv->rule);
158:
159: /*
160: * Load the the instructions that tell the queue command
161: * processor to load:
162: * - The high,middle and low bytes of the source address into
163: * the APA-16 hardware registers.
164: *
165: * - The starting bit of the starting source word.
166: *
167: * - The number of shorts needed to increment the destination
168: * pointer to the next scanline.
169: *
170: * - The X and Y destination corner points plus 1 because
171: * it uses these points exclusively.
172: *
173: * - The destination width and height registers with the
174: * width and height of the rectangle to be moved.
175: *
176: * Then load an execute command instruction with one of the copy source
177: * logic functions and a Raster Operation Type (ROT) of memory to
178: * screen (TDMA).
179: */
180: *Qptr-- = BUILD_REGLOAD(REG_HIGHBYTE,HIGH_BYTE(sv->src.data));
181: *Qptr-- = BUILD_REGLOAD(REG_LOWBYTE,MID_BYTE(sv->src.data));
182: *Qptr-- = BUILD_REGLOAD(REG_Y_SRC,LOW_BYTE(sv->src.data));
183:
184: *Qptr-- = BUILD_REGLOAD(REG_GEN_B,MOD_BPW(sv->src.rect.origin_x));
185: *Qptr-- = BUILD_REGLOAD(REG_GEN_A,sv->src.nextline);
186:
187: *Qptr-- = BUILD_REGLOAD(REG_X_DST,sv->dst.rect.corner_x+1);
188: *Qptr-- = BUILD_REGLOAD(REG_Y_DST,sv->dst.rect.corner_y+1);
189:
190: *Qptr-- = BUILD_REGLOAD(REG_X_SRC,(sv->width & 1023));
191: *Qptr-- = BUILD_REGLOAD(REG_Y_LOOP,(sv->height & 1023));
192:
193: /*
194: * This HACK works, but only because ROT_TDDMA has all the bits
195: * on anyway. To do this right one would do:
196: * (execute_cmd[sv->rule] & 0x03f0) | 0x03f0
197: */
198: *Qptr = (execute_cmd[sv->rule] | ROT_TDDMA);
199:
200: /*
201: * Set up the queue pointer register and execute the command.
202: */
203: *QUE_PTR_R = SPTR_TO_QPTR(LAST_QUE_APA16BASE);
204:
205: /*
206: * I think I have to enable DMA first.
207: */
208: ENABLE_DMA_PROC(tmp);
209: INCR_QUE_COUNT(tmp);
210:
211: return(0);
212: }
213: #endif notdef
214:
215: /*
216: * Depending on the tile rule, copy the tile to the hidden area of the
217: * screen and then set up a string of queue commands to move the tile to the
218: * screen.
219: */
220: apa16_copyTile(sv)
221: register Blt_sysdata *sv; /* System variables */
222: {
223: register unsigned short *Qptr = (unsigned short *)LAST_QUE_APA16BASE;
224: register tmp; /* just a garbage register */
225: int c;
226:
227: /*
228: * Wait for the previous command to finish.
229: */
230: WAIT_QUE(c,sv->rule);
231:
232: /*
233: * Check and see if this tile combination rule is a destination only
234: * rule like DstClear, TileDstClear, NotDstCopy, TileNotDstCopy,
235: * DstSet, TileDstSet.
236: */
237: if (IS_ROT_WRDST(execute_cmd[sv->rule])) {
238: *Qptr-- = BUILD_REGLOAD(XDST_REG,sv->dst.rect.corner_x+1);
239: *Qptr-- = BUILD_REGLOAD(YDST_REG,sv->dst.rect.corner_y+1);
240: *Qptr-- = BUILD_REGLOAD(WIDTH_REG,(sv->width & 1023));
241: *Qptr-- = BUILD_REGLOAD(HEIGHT_REG,(sv->height & 1023));
242: *Qptr = execute_cmd[sv->rule];
243:
244: /*
245: * Set up the queue pointer register and execute the command.
246: */
247: *QUE_PTR_R = SPTR_TO_QPTR(LAST_QUE_APA16BASE);
248:
249: INCR_QUE_COUNT(tmp);
250: }
251: else {
252: /*
253: * Must copy the tile to the hidden area of the screen
254: * and then setup a series of que commands to copy it to
255: * the screen.
256: */
257: return(1);
258: }
259:
260: return(0);
261: }
262: #endif APA16 && USE_APA16_HDWR
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.