|
|
1.1 ! root 1: .ds ZZ DEVELOPMENT PACKAGE ! 2: .TH SCREENSWAP 3R "630 MTG" ! 3: .XE "screenswap()" ! 4: .SH NAME ! 5: screenswap \- swap screen Rectangle and Bitmap ! 6: .SH SYNOPSIS ! 7: .ft B ! 8: #include <dmd.h> ! 9: .sp ! 10: void screenswap (b, r, s) ! 11: .br ! 12: Bitmap \(**b; ! 13: .br ! 14: Rectangle r, s; ! 15: .SH DESCRIPTION ! 16: The ! 17: .I screenswap ! 18: function ! 19: does an in-place exchange of the Rectangle ! 20: .I r ! 21: within the Bitmap ! 22: .I b ! 23: and screen rectangle ! 24: .IR s. ! 25: This exchange is done by \fIbitblt\fR'ing the bitmaps back and forth ! 26: three times in XOR mode. This technique allows bitmaps to be exchanged ! 27: without need for intermediate storage. ! 28: .PP ! 29: The action of screenswap is undefined, if ! 30: .I r ! 31: and ! 32: .I s ! 33: are not the same size. ! 34: .PP ! 35: .I Screenswap ! 36: writes to the ! 37: .I physical ! 38: bitmap, so the ! 39: .I s ! 40: argument ! 41: is clipped to the screen, ! 42: not to the window's rectangle (display.rect). ! 43: .SH EXAMPLE ! 44: The following program floats a picture of a sailboat ! 45: across the screen. ! 46: .PP ! 47: The 630 MTG mouse cursor is painted in XOR mode and therefore ! 48: changes to inverse video when it moves over highlighted areas. This sailboat, ! 49: however, does not inverse video when it moves over parts of the ! 50: screen that are highlighted. This is accomplished by saving ! 51: whatever is on the screen in the spot where the sailboat is currently ! 52: painted and restoring the screen when the sailboat moves. The unique ! 53: aspect of this is that the same physical memory is used to alternately ! 54: store the picture of the sailboat and the saved screen rectangle, and ! 55: these two bitmaps are swapped without use of intermediate storage. ! 56: .PP ! 57: .RS 3 ! 58: .nf ! 59: .ft CM ! 60: #include <dmd.h> ! 61: ! 62: unsigned short sailicon[] = { ! 63: 0xFDFF, 0xF9FF, 0xF1FF, 0xE0FF, ! 64: 0xFD7F, 0xF9BF, 0xF5DF, 0xEDEF, ! 65: 0xDDF7, 0xDDF7, 0xBDFB, 0xB8FB, ! 66: 0x0000, 0x8003, 0xE007, 0xFFFF, ! 67: }; ! 68: ! 69: Bitmap sailmap = { ! 70: (Word *)sailicon, ! 71: 1, ! 72: (short)0, (short)0, (short)16, (short)16, ! 73: (char *)0 ! 74: }; ! 75: ! 76: extern Rectangle fRpt(); ! 77: extern Rectangle raddp(); ! 78: ! 79: main() ! 80: { ! 81: Rectangle r; ! 82: ! 83: r = fRpt(0, YMAX/2-8, 16, YMAX/2+8); ! 84: ! 85: /* put the sailboat onto the screen */ ! 86: screenswap(&sailmap, sailmap.rect, r); ! 87: ! 88: /* move the sailboat across the screen */ ! 89: while(r.corner.x <= YMAX) { ! 90: sleep(3); ! 91: screenswap(&sailmap, sailmap.rect, r); ! 92: r = raddp(r, Pt(1,0)); ! 93: screenswap(&sailmap, sailmap.rect, r); ! 94: } ! 95: ! 96: /* remove the sailboat for the last time */ ! 97: screenswap(&sailmap, sailmap.rect, r); ! 98: } ! 99: \fR ! 100: .fi ! 101: .RE ! 102: .PP ! 103: This example is very similar to how message boxes are implemented. ! 104: Message boxes are rectangles containing messages which float ! 105: around the screen when the mouse moves. ! 106: .SH SEE ALSO ! 107: bitblt(3R), msgbox(3R).
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.