25 #include "audio/audiostream.h" 26 #include "audio/mixer.h" 28 #include "common/events.h" 29 #include "common/file.h" 30 #include "common/mutex.h" 32 #include "graphics/paletteman.h" 34 #include "bolt/bolt.h" 40 #define RF_OVERLAY_ACTIVE 0x01 // RLE overlay source stored on front surface 41 #define RF_DOUBLE_BUFFER 0x02 // Double-buffer compositing enabled 42 #define RF_FULL_REDRAW 0x04 // Full-screen overwrite, skip dirty tracking 43 #define RF_FRONT_DIRTY 0x08 // Front surface pixels changed 44 #define RF_BACK_DIRTY 0x10 // Back surface pixels changed 45 #define RF_FRONT_PAL_DIRTY 0x20 // Front surface palette changed 46 #define RF_BACK_PAL_DIRTY 0x40 // Back surface palette changed 47 #define RF_CURSOR_VISIBLE 0x80 // Cursor should be drawn this frame 88 enum XPSurfaceType :
int {
105 enum XPEventTypes : int16 {
117 enum XPEventKeyStates : int16 {
137 payloadPtr =
nullptr;
164 void blit(byte *src, uint16 srcStride, byte *dst, uint16 dstStride, uint16 width, uint16 height);
165 void maskBlit(byte *src, uint16 srcStride, byte *dst, uint16 dstStride, uint16 width, uint16 height);
168 void getPalette(int16 startIndex, int16 count, byte *destBuf);
169 void setPalette(int16 count, int16 startIndex, byte *srcBuf);
173 void setScreenBrightness(uint8 percent);
176 bool readCursor(uint16 *outButtons, int16 *outX, int16 *outY);
177 void setCursorPos(int16 x, int16 y);
178 void setCursorImage(byte *bitmap, int16 hotspotX, int16 hotspotY);
179 void setCursorColor(byte r, byte g, byte b);
182 void updateCursorPosition();
185 int16 getEvent(int16 filter, uint32 *outData, byte **outPtrData =
nullptr);
186 int16 peekEvent(int16 filter, uint32 *outData, byte **outPtrData =
nullptr);
187 void postEvent(XPEventTypes type, uint32 data, byte *ptrData =
nullptr);
188 int16 setInactivityTimer(int16 seconds);
189 int16 setScreenSaverTimer(int16 seconds);
190 bool enableController();
191 void disableController();
195 void setCoordSpec(int16 x, int16 y, int16 width, int16 height);
196 void displayPic(
XPPicDesc *pic, int16 x, int16 y, int16 page);
197 void setFrameRate(int16 fps);
198 void updateDisplay();
199 void setTransparency(
bool toggle);
200 void fillDisplay(byte color, int16 page);
203 int16 getRandom(int16 range);
207 Common::File *openFile(
const char *fileName, int16 flags);
209 bool readFile(
Common::File *handle,
void *buffer, uint32 *size);
210 bool setFilePos(
Common::File *handle, int32 offset, int32 origin);
211 void *allocMem(uint32 size);
212 void *tryAllocMem(uint32 size);
213 void freeMem(
void *mem);
216 bool playSound(byte *data, uint32 size, int16 sampleRate);
222 uint32 startTimer(int16 delay);
224 bool killTimer(uint32 timerId);
228 bool _xpInitialized =
false;
231 void dirtyBlit(byte *src, byte *dst, uint16 width, uint16 height, byte *dirtyFlags);
232 void compositeBlit(byte *src, byte *background, byte *dst, uint16 stride, uint16 width, uint16 height);
233 void rleBlit(byte *src, uint16 srcStride, byte *dst, uint16 dstStride, uint16 width, uint16 height);
234 void rleMaskBlit(byte *src, uint16 srcStride, byte *dst, uint16 dstStride, uint16 width, uint16 height);
235 void rleCompositeBlit(byte *rle, byte *background, byte *dst, uint16 width, uint16 height, byte *dirtyFlags);
236 uint16 rleDataSize(byte *rleData, uint16 height);
237 void markCursorPixels(byte *buffer, uint32 count);
241 byte _paletteBuffer[3 * 256];
242 byte _shiftedPaletteBuffer[3 * 256];
243 byte _cycleTempPalette[3 * 20];
244 uint32 _cycleTimerIds[4];
245 int16 _brightnessShift = 0;
249 void shutdownCursor();
250 void readJoystick(int16 *outX, int16 *outY);
252 byte _cursorBuffer[16 * 16];
253 int16 _cursorHotspotX = 0;
254 int16 _cursorHotspotY = 0;
255 int16 _lastCursorX = 0;
256 int16 _lastCursorY = 0;
257 int16 _cursorViewportWidth = 0;
258 int16 _cursorViewportHeight = 0;
259 int16 _cursorHidden = 1;
263 void shutdownEvents();
264 void unlinkEvent(
XPEvent *node);
265 void enqueueEvent(
XPEvent *node);
267 void handleTimer(uint32 timerId);
268 void handleMouseMove(
bool *mouseMoved);
269 void handleMouseButton(int16 down, int16 button);
270 void handleKey(Common::KeyCode vkey, int16 down);
271 void postJoystickEvent(int16 source, int16 dx, int16 dy);
272 bool canDropEvent(int16 type);
273 void activateScreenSaver();
274 void resetInactivity();
277 int16 getButtonState();
281 int8 _keyStateLeft = 0;
282 int8 _keyStateRight = 0;
283 int8 _keyStateUp = 0;
284 int8 _keyStateDown = 0;
285 int16 _lastJoystickX = 0;
286 int16 _lastJoystickY = 0;
287 int16 _mouseButtonPrev = 0;
288 int16 _mouseButtonState = 0;
289 int16 _eventMouseMoved = 0;
290 int16 _eventKeyStates = 0;
291 uint32 _inactivityDeadline = 0;
293 XPEvent *_eventQueueHead =
nullptr;
294 XPEvent *_eventQueueTail =
nullptr;
295 XPEvent *_eventFreeList =
nullptr;
297 uint32 _lastMouseEventData = 0;
302 void shutdownDisplay();
305 void virtualToScreen(int16 *x, int16 *y);
306 void screenToVirtual(int16 *x, int16 *y);
307 void dispatchBlit(int16 mode, byte *src, uint16 srcStride, byte *dst, uint16 dstStride, uint16 width, uint16 height);
310 void waitForFrameRate();
311 void handlePaletteTransitions();
313 void overlayComposite();
314 void compositeToScreen();
315 void mergeDirtyRects();
317 void compositeDirtyRects(
Common::Rect *rects, int16 count);
318 void applyCursorPalette();
319 void prepareBackSurface();
323 int16 _virtualWidth = 0;
324 int16 _virtualHeight = 0;
325 int16 _currentDisplayPage = 0;
326 int16 _prevRenderFlags = 0;
327 int16 _renderFlags = 0;
328 int16 _frameRateFPS = 0;
329 int16 _overlayCount = 0;
330 int16 _prevDirtyCount = 0;
331 int16 _prevDirtyValid = 0;
332 int16 _surfaceWidth = 0;
333 int16 _surfaceHeight = 0;
334 int16 _viewportOffsetX = 0;
335 int16 _viewportOffsetY = 0;
336 uint32 _nextFrameTime = 0;
345 byte *_vgaFramebuffer =
nullptr;
346 byte *_rowDirtyFlags =
nullptr;
347 byte _cursorBackgroundSaveBuffer[16 * 16];
353 void fileError(
const char *message);
356 bool pollSound(byte **outData);
358 void shutdownSound();
363 uint32 _nextSoundDeadlineMs = 0;
364 uint32 _pauseTimeMs = 0;
365 int16 _sndPlayState = 0;
366 int16 _sndQueued = 0;
367 int _sndCompletedCount = 0;
368 bool _sndPaused =
false;
369 int16 _sndSampleRate = 22050;
370 uint32 _sndNextDeadline = 0;
371 uint32 _sndBufferQueueTime = 0;
376 void shutdownTimer();
378 uint32 _inactivityTimerId = 0;
379 int16 _inactivityCountdown = 0;
380 int16 _inactivityTimerValue = 0;
381 int16 _screensaverCountdown = 0;
382 int16 _screenSaverTimerValue = 0;
383 int16 _inactivityTimeout = 0;
385 bool _timerInitialized =
false;
388 uint16 _nextTimerId = 0;
393 #endif // XPLIB_XPLIB_H
EventType
Definition: events.h:49
Definition: audiostream.h:370
bool maskBlit(byte *dst, const byte *src, const byte *mask, const uint dstPitch, const uint srcPitch, const uint maskPitch, const uint w, const uint h, const uint bytesPerPixel)