1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * ©1995 Artsoft Development *
6 * 33659 Bielefeld-Senne *
7 * Telefon: (0521) 493245 *
8 * eMail: aeglos@valinor.owl.de *
9 * aeglos@uni-paderborn.de *
10 * q99492@pbhrzx.uni-paderborn.de *
11 *----------------------------------------------------------*
13 ***********************************************************/
17 #ifdef USE_SDL_LIBRARY
21 inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height)
23 #ifdef USE_SDL_LIBRARY
24 SDLFillRectangle(bitmap, x, y, width, height, 0x000000);
26 XFillRectangle(display, bitmap, gc, x, y, width, height);
30 inline void BlitBitmap(Bitmap src_bitmap, Bitmap dst_bitmap,
32 int width, int height,
35 #ifdef USE_SDL_LIBRARY
36 SDLCopyArea(src_bitmap, dst_bitmap,
37 src_x, src_y, width, height, dst_x, dst_y);
39 XCopyArea(display, src_bitmap, dst_bitmap, gc,
40 src_x, src_y, width, height, dst_x, dst_y);
44 #ifndef USE_SDL_LIBRARY
45 static GC last_clip_gc = 0; /* needed for XCopyArea() through clip mask */
48 inline void SetClipMask(GC clip_gc, Pixmap clip_pixmap)
50 #ifndef USE_SDL_LIBRARY
51 XSetClipMask(display, clip_gc, clip_pixmap);
52 last_clip_gc = clip_gc;
56 inline void SetClipOrigin(GC clip_gc, int clip_x, int clip_y)
58 #ifndef USE_SDL_LIBRARY
59 XSetClipOrigin(display, clip_gc, clip_x, clip_y);
60 last_clip_gc = clip_gc;
64 inline void BlitBitmapMasked(Bitmap src_bitmap, Bitmap dst_bitmap,
66 int width, int height,
69 #ifdef USE_SDL_LIBRARY
70 SDLCopyArea(src_bitmap, dst_bitmap,
71 src_x, src_y, width, height, dst_x, dst_y);
73 XCopyArea(display, src_bitmap, dst_bitmap, last_clip_gc,
74 src_x, src_y, width, height, dst_x, dst_y);
78 inline void DrawSimpleWhiteLine(Bitmap bitmap, int from_x, int from_y,
81 #ifdef USE_SDL_LIBRARY
82 SDLDrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, 0xffffff);
84 XSetForeground(display, gc, WhitePixel(display, screen));
85 XDrawLine(display, bitmap, gc, from_x, from_y, to_x, to_y);
86 XSetForeground(display, gc, BlackPixel(display, screen));
90 /* execute all pending screen drawing operations */
91 inline void FlushDisplay()
93 #ifndef USE_SDL_LIBRARY
98 /* execute and wait for all pending screen drawing operations */
99 inline void SyncDisplay()
101 #ifndef USE_SDL_LIBRARY
102 XSync(display, FALSE);
106 inline void KeyboardAutoRepeatOn()
108 #ifdef USE_SDL_LIBRARY
109 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
110 SDL_DEFAULT_REPEAT_INTERVAL / 2);
111 SDL_EnableUNICODE(1);
113 XAutoRepeatOn(display);
117 inline void KeyboardAutoRepeatOff()
119 #ifdef USE_SDL_LIBRARY
120 SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
121 SDL_EnableUNICODE(0);
123 XAutoRepeatOff(display);
127 inline boolean QueryPointer(DrawWindow window, int *win_x, int *win_y)
129 #ifdef USE_SDL_LIBRARY
130 SDL_GetMouseState(win_x, win_y);
133 DrawWindow root, child;
137 /* if XQueryPointer() returns False, the pointer
138 is not on the same screen as the specified window */
139 return XQueryPointer(display, window, &root, &child, &root_x, &root_y,
140 win_x, win_y, &mask);
144 inline boolean PendingEvent()
146 #ifdef USE_SDL_LIBRARY
147 return (SDL_PollEvent(NULL) ? TRUE : FALSE);
149 return (XPending(display) ? TRUE : FALSE);
153 inline void NextEvent(Event *event)
155 #ifdef USE_SDL_LIBRARY
156 SDL_WaitEvent(event);
158 XNextEvent(display, event);
162 inline Key GetEventKey(KeyEvent *event, boolean with_modifiers)
164 #ifdef USE_SDL_LIBRARY
166 printf("0x%x, 0x%x\n",
167 event->keysym.sym, event->keysym.unicode);
169 if (with_modifiers && event->keysym.unicode != 0)
170 return event->keysym.unicode;
172 return event->keysym.sym;
175 printf("0x%x, 0x%x\n",
176 (unsigned int)XLookupKeysym(event, 0),
177 (unsigned int)XLookupKeysym(event, event->state));
180 return XLookupKeysym(event, event->state);
182 return XLookupKeysym(event, 0);
188 #ifdef USE_SDL_LIBRARY