|
|
1.1 root 1: /*****************************************************************************\
2: * Smart 256 Colour Bank Manager
3: *
4: * Copyright (c) 1992 Microsoft Corporation
5: \*****************************************************************************/
6:
7: #include "driver.h"
8:
9: /*****************************************************************************\
10: * pcoBankStart - Start the bank enumeration using the clip object.
11: *
12: * Used when the destination is the screen and we can't do the clipping
13: * ourselves (as we can for blt's).
14: \*****************************************************************************/
15:
16: CLIPOBJ* pcoBankStart(
17: PPDEV ppdev,
18: RECTL* prclScans,
19: SURFOBJ* pso,
20: CLIPOBJ* pco)
21: {
22: LONG iTopScan = max(0, prclScans->top);
23:
24: // Adjust for those weird cases where we're asked to start enumerating
25: // below the bottom of the screen:
26:
27: iTopScan = min(iTopScan, (LONG) ppdev->cyScreen - 1);
28:
29: // Map in the bank:
30:
31: if (iTopScan < ppdev->rcl1WindowClip.top ||
32: iTopScan >= ppdev->rcl1WindowClip.bottom)
33: {
34: ppdev->pfnBankControl(ppdev, iTopScan, JustifyTop);
35: }
36:
37: // Remember what the last scan is that we're going to, and
38: // make sure we only try to go as far as we need to. It could
39: // happen that when get a prclScans bigger than the screen:
40:
41: ppdev->iLastScan = min(prclScans->bottom, (LONG) ppdev->cyScreen);
42:
43: pso->pvScan0 = ppdev->pvBitmapStart;
44:
45: if (pco == NULL)
46: {
47: // The call may have come down to us as having no clipping, but
48: // we have to clip to the banks, so use our own clip object:
49:
50: pco = ppdev->pcoNull;
51: pco->rclBounds = ppdev->rcl1WindowClip;
52: }
53: else
54: {
55: // Save the engine's clip object data that we'll be tromping on:
56:
57: ppdev->rclSaveBounds = pco->rclBounds;
58: ppdev->iSaveDComplexity = pco->iDComplexity;
59: ppdev->fjSaveOptions = pco->fjOptions;
60:
61: // Let engine know it has to pay attention to the rclBounds of the
62: // clip object:
63:
64: pco->fjOptions |= OC_BANK_CLIP;
65:
66: if (pco->iDComplexity == DC_TRIVIAL)
67: pco->iDComplexity = DC_RECT;
68:
69: // Use the bank bounds if they are tighter than the existing
70: // bounds. We don't have to check the left case here because we
71: // know that ppdev->rcl1WindowClip.left == 0.
72:
73: if (pco->rclBounds.top <= ppdev->rcl1WindowClip.top)
74: pco->rclBounds.top = ppdev->rcl1WindowClip.top;
75:
76: if (pco->rclBounds.right >= ppdev->rcl1WindowClip.right)
77: pco->rclBounds.right = ppdev->rcl1WindowClip.right;
78:
79: if (pco->rclBounds.bottom >= ppdev->rcl1WindowClip.bottom)
80: pco->rclBounds.bottom = ppdev->rcl1WindowClip.bottom;
81: }
82:
83: return(pco);
84: }
85:
86: /*****************************************************************************\
87: * bBankEnum - Continue the bank enumeration.
88: \*****************************************************************************/
89:
90: BOOL bBankEnum(PPDEV ppdev, SURFOBJ* pso, CLIPOBJ* pco)
91: {
92: // If we're on the first portion of a broken raster, get the next:
93:
94: LONG yNewTop = ppdev->rcl1WindowClip.bottom;
95:
96: if (ppdev->flBank & BANK_BROKEN_RASTER1)
97: ppdev->pfnBankNext(ppdev);
98:
99: else if (ppdev->rcl1WindowClip.bottom < ppdev->iLastScan)
100: ppdev->pfnBankControl(ppdev, yNewTop, JustifyTop);
101:
102: else
103: {
104: // Okay, that was the last bank, so restore our structures:
105:
106: if (pco != ppdev->pcoNull)
107: {
108: pco->rclBounds = ppdev->rclSaveBounds;
109: pco->iDComplexity = ppdev->iSaveDComplexity;
110: pco->fjOptions = ppdev->fjSaveOptions;
111: }
112:
113: return(FALSE);
114: }
115:
116: // Adjust the pvScan0 because we've moved the window to view
117: // a different area:
118:
119: pso->pvScan0 = ppdev->pvBitmapStart;
120:
121: if (pco == ppdev->pcoNull)
122: {
123: // If were given a NULL clip object originally, we don't have
124: // to worry about clipping to ppdev->rclSaveBounds:
125:
126: pco->rclBounds.top = yNewTop;
127: pco->rclBounds.left = ppdev->rcl1WindowClip.left;
128: pco->rclBounds.bottom = ppdev->rcl1WindowClip.bottom;
129: pco->rclBounds.right = ppdev->rcl1WindowClip.right;
130: }
131: else
132: {
133: // Use the bank bounds if they are tighter than the bounds
134: // we were originally given:
135:
136: pco->rclBounds = ppdev->rclSaveBounds;
137:
138: if (pco->rclBounds.top <= yNewTop)
139: pco->rclBounds.top = yNewTop;
140:
141: if (pco->rclBounds.left <= ppdev->rcl1WindowClip.left)
142: pco->rclBounds.left = ppdev->rcl1WindowClip.left;
143:
144: if (pco->rclBounds.right >= ppdev->rcl1WindowClip.right)
145: pco->rclBounds.right = ppdev->rcl1WindowClip.right;
146:
147: if (pco->rclBounds.bottom >= ppdev->rcl1WindowClip.bottom)
148: pco->rclBounds.bottom = ppdev->rcl1WindowClip.bottom;
149: }
150:
151: return(TRUE);
152: }
153:
154: /***************************************************************************\
155: * vBankStartBltSrc - Start the bank enumeration for when the screen is
156: * the source.
157: \***************************************************************************/
158:
159: VOID vBankStartBltSrc(
160: PPDEV ppdev,
161: SURFOBJ* pso,
162: POINTL* pptlSrc,
163: RECTL* prclDest,
164: POINTL* pptlNewSrc,
165: RECTL* prclNewDest)
166: {
167: LONG xRightSrc;
168: LONG yBottomSrc;
169: LONG iTopScan = max(0, pptlSrc->y);
170:
171: if (iTopScan >= (LONG) ppdev->cyScreen)
172: {
173: // In some instances we may be asked to start on a scan below the screen.
174: // Since we obviously won't be drawing anything, don't bother mapping in
175: // a bank:
176:
177: return;
178: }
179:
180: // Map in the bank:
181:
182: if (iTopScan < ppdev->rcl1WindowClip.top ||
183: iTopScan >= ppdev->rcl1WindowClip.bottom)
184: {
185: ppdev->pfnBankControl(ppdev, iTopScan, JustifyTop);
186: }
187:
188: if (ppdev->rcl1WindowClip.right <= pptlSrc->x)
189: {
190: // We have to watch out for those rare cases where we're starting
191: // on a broken raster and we won't be drawing on the first part:
192:
193: ASSERTVGA(ppdev->flBank & BANK_BROKEN_RASTER1, "Weird start bounds");
194:
195: ppdev->pfnBankNext(ppdev);
196: }
197:
198: pso->pvScan0 = ppdev->pvBitmapStart;
199:
200: // Adjust the source:
201:
202: pptlNewSrc->x = pptlSrc->x;
203: pptlNewSrc->y = pptlSrc->y;
204:
205: // Adjust the destination:
206:
207: prclNewDest->left = prclDest->left;
208: prclNewDest->top = prclDest->top;
209:
210: yBottomSrc = pptlSrc->y + prclDest->bottom - prclDest->top;
211: prclNewDest->bottom = min(ppdev->rcl1WindowClip.bottom, yBottomSrc);
212: prclNewDest->bottom += prclDest->top - pptlSrc->y;
213:
214: xRightSrc = pptlSrc->x + prclDest->right - prclDest->left;
215: prclNewDest->right = min(ppdev->rcl1WindowClip.right, xRightSrc);
216: prclNewDest->right += prclDest->left - pptlSrc->x;
217: }
218:
219: /***************************************************************************\
220: * bBankEnumBltSrc - Continue the bank enumeration for when the screen is
221: * the source.
222: \***************************************************************************/
223:
224: BOOL bBankEnumBltSrc(
225: PPDEV ppdev,
226: SURFOBJ* pso,
227: POINTL* pptlSrc,
228: RECTL* prclDest,
229: POINTL* pptlNewSrc,
230: RECTL* prclNewDest)
231: {
232: LONG xLeftSrc;
233: LONG xRightSrc;
234: LONG yBottomSrc;
235:
236: LONG cx = prclDest->right - prclDest->left;
237: LONG cy = prclDest->bottom - prclDest->top;
238:
239: LONG dx;
240: LONG dy;
241:
242: LONG yBottom = min(pptlSrc->y + cy, (LONG) ppdev->cyScreen);
243: LONG yNewTop = ppdev->rcl1WindowClip.bottom;
244:
245: if (ppdev->flBank & BANK_BROKEN_RASTER1)
246: {
247: ppdev->pfnBankNext(ppdev);
248: if (ppdev->rcl1WindowClip.left >= pptlSrc->x + cx)
249: {
250: if (ppdev->rcl1WindowClip.bottom < yBottom)
251: ppdev->pfnBankNext(ppdev);
252: else
253: {
254: // We're done:
255:
256: return(FALSE);
257: }
258: }
259: }
260: else if (yNewTop < yBottom)
261: {
262: ppdev->pfnBankControl(ppdev, yNewTop, JustifyTop);
263: if (ppdev->rcl1WindowClip.right <= pptlSrc->x)
264: {
265: ASSERTVGA(ppdev->flBank & BANK_BROKEN_RASTER1, "Weird bounds");
266: ppdev->pfnBankNext(ppdev);
267: }
268: }
269: else
270: {
271: // We're done:
272:
273: return(FALSE);
274: }
275:
276: // Adjust the source:
277:
278: pso->pvScan0 = ppdev->pvBitmapStart;
279:
280: pptlNewSrc->x = max(ppdev->rcl1WindowClip.left, pptlSrc->x);
281: pptlNewSrc->y = yNewTop;
282:
283: // Adjust the destination:
284:
285: dy = prclDest->top - pptlSrc->y; // y delta from source to dest
286:
287: prclNewDest->top = yNewTop + dy;
288:
289: yBottomSrc = pptlSrc->y + cy;
290: prclNewDest->bottom = min(ppdev->rcl1WindowClip.bottom, yBottomSrc) + dy;
291:
292: dx = prclDest->left - pptlSrc->x; // x delta from source to dest
293:
294: xLeftSrc = pptlSrc->x;
295: prclNewDest->left = pptlNewSrc->x + dx;
296:
297: xRightSrc = pptlSrc->x + cx;
298: prclNewDest->right = min(ppdev->rcl1WindowClip.right, xRightSrc) + dx;
299:
300: return(TRUE);
301: }
302:
303: /***************************************************************************\
304: * vBankStartBltDest - Start the bank enumeration for when the screen is
305: * the destination.
306: \***************************************************************************/
307:
308: VOID vBankStartBltDest(
309: PPDEV ppdev,
310: SURFOBJ* pso,
311: POINTL* pptlSrc,
312: RECTL* prclDest,
313: POINTL* pptlNewSrc,
314: RECTL* prclNewDest)
315: {
316: LONG iTopScan = max(0, prclDest->top);
317:
318: if (iTopScan >= (LONG) ppdev->cyScreen)
319: {
320: // In some instances we may be asked to start on a scan below the screen.
321: // Since we obviously won't be drawing anything, don't bother mapping in
322: // a bank:
323:
324: return;
325: }
326:
327: // Map in the bank:
328:
329: if (iTopScan < ppdev->rcl1WindowClip.top ||
330: iTopScan >= ppdev->rcl1WindowClip.bottom)
331: {
332: ppdev->pfnBankControl(ppdev, iTopScan, JustifyTop);
333: }
334:
335: if (ppdev->rcl1WindowClip.right <= prclDest->left)
336: {
337: // We have to watch out for those rare cases where we're starting
338: // on a broken raster and we won't be drawing on the first part:
339:
340: ASSERTVGA(ppdev->flBank & BANK_BROKEN_RASTER1, "Weird start bounds");
341: ppdev->pfnBankNext(ppdev);
342: }
343:
344: pso->pvScan0 = ppdev->pvBitmapStart;
345:
346: // Adjust the destination:
347:
348: prclNewDest->left = prclDest->left;
349: prclNewDest->top = prclDest->top;
350: prclNewDest->bottom = min(ppdev->rcl1WindowClip.bottom, prclDest->bottom);
351: prclNewDest->right = min(ppdev->rcl1WindowClip.right, prclDest->right);
352:
353: // Adjust the source if there is one:
354:
355: if (pptlSrc != NULL)
356: *pptlNewSrc = *pptlSrc;
357: }
358:
359: /***************************************************************************\
360: * bBankEnumBltDest - Continue the bank enumeration for when the screen is
361: * the destination.
362: \***************************************************************************/
363:
364: BOOL bBankEnumBltDest(
365: PPDEV ppdev,
366: SURFOBJ* pso,
367: POINTL* pptlSrc,
368: RECTL* prclDest,
369: POINTL* pptlNewSrc,
370: RECTL* prclNewDest)
371: {
372: LONG yBottom = min(prclDest->bottom, (LONG) ppdev->cyScreen);
373: LONG yNewTop = ppdev->rcl1WindowClip.bottom;
374:
375: if (ppdev->flBank & BANK_BROKEN_RASTER1)
376: {
377: ppdev->pfnBankNext(ppdev);
378: if (ppdev->rcl1WindowClip.left >= prclDest->right)
379: {
380: if (ppdev->rcl1WindowClip.bottom < yBottom)
381: ppdev->pfnBankNext(ppdev);
382: else
383: {
384: // We're done:
385:
386: return(FALSE);
387: }
388: }
389: }
390: else if (yNewTop < yBottom)
391: {
392: ppdev->pfnBankControl(ppdev, yNewTop, JustifyTop);
393: if (ppdev->rcl1WindowClip.right <= prclDest->left)
394: {
395: ASSERTVGA(ppdev->flBank & BANK_BROKEN_RASTER1, "Weird bounds");
396: ppdev->pfnBankNext(ppdev);
397: }
398: }
399: else
400: {
401: // We're done:
402:
403: return(FALSE);
404: }
405:
406: pso->pvScan0 = ppdev->pvBitmapStart;
407:
408: // Adjust the destination:
409:
410: prclNewDest->top = yNewTop;
411: prclNewDest->left = max(ppdev->rcl1WindowClip.left, prclDest->left);
412: prclNewDest->bottom = min(ppdev->rcl1WindowClip.bottom, prclDest->bottom);
413: prclNewDest->right = min(ppdev->rcl1WindowClip.right, prclDest->right);
414:
415: // Adjust the source if there is one:
416:
417: if (pptlSrc != NULL)
418: {
419: pptlNewSrc->x = pptlSrc->x + (prclNewDest->left - prclDest->left);
420: pptlNewSrc->y = pptlSrc->y + (prclNewDest->top - prclDest->top);
421: }
422:
423: return(TRUE);
424: }
425:
426:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.