|
|
1.1 root 1: /* $Header: bitblt_int.h,v 10.1 86/11/19 10:52:05 jg Exp $ */
2: /*
3: * Copyright (c) 1986 Brown University
4: *
5: * Permission to use, copy, modify and distribute this software and its
6: * documentation for any purpose and without fee is hereby granted, provided
7: * that the above copyright notice appear in all copies, and that both
8: * that copyright notice and this permission notice appear in supporting
9: * documentation, and that the name of Brown University not be used in
10: * advertising or publicity pertaining to distribution of the software without
11: * specific, written prior permission. Brown University makes no
12: * representations about the suitability of this software for any purpose.
13: * It is provided "as-is" without express or implied warranty.
14: *
15: * Written by Daniel Stone, Brown University/IRIS (des@iris)
16: */
17:
18: /*
19: * BITBLT COMPILATION OPTIONS:
20: * define APA16 Bltter handles the APA16 screen.
21: * define APA8 Bltter handles the APA8 screen.
22: * define APA8C Bltter handles the APA8C screen.
23: * define AED Bltter handles the AED screen.
24: * define BLT_DEBUG Bltter debug messages on.
25: * define USE_APA16_HDWR Bltter will use screen hardware where
26: * implemented.
27: */
28:
29: #ifdef BLT_DEBUG
30: #define DEBUGF(cond,stmt) if (cond) { stmt; }
31: #else
32: #define DEBUGF(cond,stmt)
33: #endif
34:
35: /*
36: * bitblt_ext.h needs this defined because of XAddr.
37: */
38: #include <machinecons/xio.h>
39: /*
40: * Include the external interface routine to the bitblt routine, bitblt_ext.h.
41: */
42: #include "bitblt_ext.h"
43:
44: typedef Blt Blt_userdata;
45:
46: typedef struct Blt_screen_info {
47: unsigned short *firstaddr; /* first address on the screen bitmap */
48: unsigned short *lastaddr; /* last address on the screen bitmap */
49: unsigned long cursortype; /* Indicate the type of cursor on this
50: screen. */
51: } Blt_screen_info;
52:
53: typedef struct bitmap_info {
54: unsigned short *data; /* pointer to the starting place of the bit
55: blt. */
56: Blt_Rectangle rect; /* bounds of the area to be used or changed */
57: long nextline; /* The amount to be added to the pointer to
58: get to the next logical scanline */
59: } Blt_bitmap_info;
60:
61: typedef struct Blt_sysdata {
62: long height,width; /* the height and width (in bits) of the
63: destination area to be changed */
64: short nshorts; /* number of destination shorts to be changed */
65: short top_to_bot; /* If non-zero it indicates the blt is to go
66: from right to left, bottom to top */
67: short is_src; /* Indicates that the rule uses the source */
68: short rule; /* combination rule or "mode" to be used with
69: the data */
70: short preload_src; /* Indicates 2 source words are needed to make
71: the first destination word. */
72: short preload_msk; /* Indicates 2 mask words are needed to make
73: the first destination word. */
74: short skew_src; /* The amount the source must be shifted to
75: line up with the destination */
76: short skew_msk; /* The amount the mask must be shifted to
77: line up with the destination */
78: unsigned short left_mask; /* left mask to protect those bits on the
79: left edge that are not to be changed */
80: unsigned short right_mask; /* right mask to protect those bits on the
81: right edge that are not to be changed */
82:
83: unsigned short *tile_ptr; /* Points to the Tile to be used to tile
84: the destination */
85: Blt_bitmap_info dst; /* Internal information for the destination
86: bitmap. */
87: Blt_bitmap_info src; /* Internal information for the source bitmap */
88: Blt_bitmap_info msk; /* Internal information for the mask bitmap*/
89: #if (APA8 || APA8C)
90: short dst_plus; /* the amount to increment the destination
91: pointer to get to the next word. (usually
92: its 1, with the APA-8 its 2)*/
93: short src_plus; /* the amount to increment the source
94: pointer to get to the next word. (usually
95: its 1, with the APA-8 its 2)*/
96: #endif
97: } Blt_sysdata;
98:
99: #define SETRECT(dst,l,t,r,b) { \
100: (dst)->origin_x = l; (dst)->origin_y = t; \
101: (dst)->corner_x = r; (dst)->corner_y = b; \
102: }
103:
104: /*
105: * Macro to determine if a bitmap points to the APA-8 screen.
106: */
107: #define APA8BASE 0xf4d00000
108: #define APA8_BYTE_SIZE (128*512)
109:
110: /*
111: * Macro to determine if a bitmap points to the APA-8 screen.
112: */
113: #define APA8CBASE 0xf4d20000
114: #define APA8C_BYTE_SIZE (128*512)
115:
116: /*
117: * Macro to determine if a bitmap points to the APA-16 screen.
118: */
119: #define APA16BASE 0xf4d80000
120: #define APA16_BYTE_SIZE (128*1024)
121:
122: /*
123: * Macro to determine if a bitmap points to the AED's offscreen bitmap
124: */
125: #define AEDBASE 0xEF100000
126: #define AED_BYTE_SIZE (128*800)
127:
128: /*
129: * Macro to determine if a bitmap points to the screen.
130: */
131: #define IS_APA8(BM) (APA8BASE <= (long)BM.base && \
132: (long)BM.base < (APA8BASE+(2*APA8_BYTE_SIZE)))
133:
134: #define IS_APA8C(BM) (APA8CBASE <= (long)BM.base && \
135: (long)BM.base < (APA8CBASE+(2*APA8C_BYTE_SIZE)))
136:
137: #define IS_APA8orAPA8C(BM) (APA8BASE <= (long)BM.base && \
138: (long)BM.base < (APA8CBASE+(2*APA8C_BYTE_SIZE)))
139:
140: #define IS_APA16(BM) (APA16BASE <= (long)BM.base && \
141: (long)BM.base < (APA16BASE+APA16_BYTE_SIZE))
142:
143: #define IS_AED(BM) (AEDBASE <= (long)BM.base && \
144: (long)BM.base < (AEDBASE+AED_BYTE_SIZE))
145:
146: #define DstClear 0
147: #define SrcAnd 1
148: #define SrcAndNotDst 2
149: #define SrcCopy 3
150: #define NotSrcAnd 4
151: #define DstCopy 5
152: #define SrcXor 6
153: #define SrcOr 7
154: #define NotSrcAndNotDst 8
155: #define NotSrcXor 9
156: #define NotDstCopy 10
157: #define SrcOrNotDst 11
158: #define NotSrcCopy 12
159: #define NotSrcOr 13
160: #define NotSrcOrNotDst 14
161: #define DstSet 15
162:
163: #define TileDstClear 16
164: #define TileAnd 17
165: #define TileAndNotDst 18
166: #define TileCopy 19
167: #define NotTileAnd 20
168: #define TileDstCopy 21
169: #define TileXor 22
170: #define TileOr 23
171: #define NotTileAndNotDst 24
172: #define NotTileXor 25
173: #define TileNotDstCopy 26
174: #define TileOrNotDst 27
175: #define NotTileCopy 28
176: #define NotTileOr 29
177: #define NotTileOrNotDst 30
178: #define TileDstSet 31
179:
180: #define SRC_TO_TILE TileDstClear
181:
182: /*
183: * Macros to determine if the given rule refers to a tile or a source
184: * bitmap.
185: * NOTE: This Macro depends on the order of the defines above.
186: */
187: #define IS_SRC(rule) ((rule < TileDstClear) && (rule != DstSet) && \
188: (rule != DstClear) && (rule != NotDstCopy))
189:
190: #define IS_SCREEN(bitmap) (blt_cur_screen.firstaddr <= bitmap.base && \
191: bitmap.base < blt_cur_screen.lastaddr)
192:
193: #ifndef BPW
194: /*
195: * Macros for division from words and bytes.
196: */
197: #define BPW 16 /* Bits per Word */
198: #define LOG2_BPW 4
199: #define MOD_BPW(value) ((value) & (BPW-1))
200: #define DIV_BPW(value) ((value) >> LOG2_BPW)
201: #define MUL_BPW(value) ((value) << LOG2_BPW)
202:
203: /*
204: * Bits TO Words.
205: */
206: #define BTOW(bits) (DIV_BPW((bits) + (BPW-1)))
207: #endif BPW
208:
209: /*
210: * Macros for the division and multiplication by 2.
211: */
212: #define DIV_2(n) ((n) >> 1)
213: #define MUL_2(n) ((n) << 1)
214: #define MOD_2(n) ((n) & 0x1)
215:
216: /*
217: * Need to multiply by 4 when using the APA-8.
218: */
219: #define MUL_4(n) ((n) << 2)
220:
221: /*
222: * Bits Per Byte.
223: */
224: #define BPB 8
225: #define LOG2_BPB 3
226: #define MOD_BPB(value) ((value) & (BPB-1))
227: #define DIV_BPB(value) ((value) >> LOG2_BPB)
228: #define MUL_BPB(value) ((value) << LOG2_BPB)
229: /*
230: * Bits TO Bytes.
231: */
232: #define BTOB(bits) (DIV_BPB((bits) + (BPB-1)))
233:
234: extern Blt_screen_info blt_cur_screen;
235: #ifdef BLT_DEBUG
236: extern int blt_debug;
237: #endif
238:
239: #define MIN(a,b) ((a < b) ? (a) : (b))
240: #define MAX(a,b) ((a > b) ? (a) : (b))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.