2002-04-21 17:46:42 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
2002-04-21 17:46:42 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-09-08 01:08:12 +00:00
|
|
|
#ifndef COMMON_SYSTEM_H
|
|
|
|
#define COMMON_SYSTEM_H
|
2002-06-02 20:28:09 +00:00
|
|
|
|
2003-08-01 12:21:04 +00:00
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/savefile.h"
|
2002-09-08 01:08:12 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
2003-05-29 22:34:35 +00:00
|
|
|
* Interface for ScummVM backends. If you want to port ScummVM to a system
|
|
|
|
* which is not currently covered by any of our backends, this is the place
|
|
|
|
* to start. ScummVM will create an instance of a subclass of this interface
|
|
|
|
* and use it to interact with the system.
|
|
|
|
*
|
|
|
|
* In particular, a backend provides a video surface for ScummVM to draw in;
|
|
|
|
* methods to create threads and timers, to handle user input events,
|
|
|
|
* control audio CD playback, and sound output.
|
2003-05-29 21:45:26 +00:00
|
|
|
*/
|
2002-04-12 21:26:59 +00:00
|
|
|
class OSystem {
|
|
|
|
public:
|
2003-07-05 15:20:16 +00:00
|
|
|
typedef struct Mutex *MutexRef;
|
2002-04-12 21:26:59 +00:00
|
|
|
typedef int ThreadProc(void *param);
|
2002-04-14 18:13:08 +00:00
|
|
|
typedef void SoundProc(void *param, byte *buf, int len);
|
2003-05-29 22:34:35 +00:00
|
|
|
//typedef int TimerProc(int interval);
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
|
|
|
* The types of events backends can generate.
|
2003-05-29 22:34:35 +00:00
|
|
|
* @todo Add events for quit request, and screen size change.
|
2003-05-29 21:45:26 +00:00
|
|
|
* @see Event
|
|
|
|
*/
|
|
|
|
enum EventCode {
|
2002-04-12 21:26:59 +00:00
|
|
|
EVENT_KEYDOWN = 1,
|
2002-07-16 21:18:06 +00:00
|
|
|
EVENT_KEYUP = 2,
|
2002-04-12 21:26:59 +00:00
|
|
|
EVENT_MOUSEMOVE = 3,
|
|
|
|
EVENT_LBUTTONDOWN = 4,
|
|
|
|
EVENT_LBUTTONUP = 5,
|
|
|
|
EVENT_RBUTTONDOWN = 6,
|
|
|
|
EVENT_RBUTTONUP = 7,
|
2002-10-16 20:32:12 +00:00
|
|
|
EVENT_WHEELUP = 8,
|
2003-06-08 12:11:14 +00:00
|
|
|
EVENT_WHEELDOWN = 9,
|
|
|
|
|
|
|
|
EVENT_QUIT = 10
|
2002-04-12 21:26:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
KBD_CTRL = 1,
|
|
|
|
KBD_ALT = 2,
|
2002-12-25 00:36:04 +00:00
|
|
|
KBD_SHIFT = 4
|
2002-04-12 21:26:59 +00:00
|
|
|
};
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
|
|
|
* Data structure for an event. A pointer to an instance of Event
|
|
|
|
* can be passed to poll_event.
|
|
|
|
*/
|
|
|
|
struct Event {
|
|
|
|
EventCode event_code;
|
|
|
|
struct {
|
|
|
|
int keycode;
|
|
|
|
uint16 ascii;
|
|
|
|
byte flags;
|
|
|
|
} kbd;
|
|
|
|
struct {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
} mouse;
|
|
|
|
};
|
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
enum {
|
2002-04-14 18:13:08 +00:00
|
|
|
PROP_TOGGLE_FULLSCREEN = 1,
|
|
|
|
PROP_SET_WINDOW_CAPTION = 2,
|
|
|
|
PROP_OPEN_CD = 3,
|
|
|
|
PROP_SET_GFX_MODE = 4,
|
|
|
|
PROP_SHOW_DEFAULT_CURSOR = 5,
|
|
|
|
PROP_GET_SAMPLE_RATE = 6,
|
2003-01-29 21:28:37 +00:00
|
|
|
PROP_GET_FULLSCREEN = 7,
|
|
|
|
PROP_GET_FMOPL_ENV_BITS = 8,
|
2003-06-22 11:55:40 +00:00
|
|
|
PROP_GET_FMOPL_EG_ENT = 9,
|
2003-07-20 15:31:47 +00:00
|
|
|
PROP_TOGGLE_ASPECT_RATIO = 10,
|
|
|
|
PROP_WANT_RECT_OPTIM = 11
|
2002-04-12 21:26:59 +00:00
|
|
|
};
|
2002-05-04 09:55:10 +00:00
|
|
|
union Property {
|
2002-09-24 22:40:28 +00:00
|
|
|
const char *caption;
|
2002-05-04 09:55:10 +00:00
|
|
|
int cd_num;
|
|
|
|
int gfx_mode;
|
|
|
|
bool show_cursor;
|
|
|
|
};
|
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
enum SoundFormat {
|
2002-04-14 18:13:08 +00:00
|
|
|
SOUND_8BIT = 0,
|
2002-12-25 00:36:04 +00:00
|
|
|
SOUND_16BIT = 1
|
2002-04-12 21:26:59 +00:00
|
|
|
};
|
2003-05-29 22:34:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @name Graphics */
|
|
|
|
//@{
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/** Set the size of the video bitmap. Typically 320x200 pixels. */
|
2002-04-14 18:13:08 +00:00
|
|
|
virtual void init_size(uint w, uint h) = 0;
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
/**
|
|
|
|
* Returns the currently set screen height.
|
|
|
|
* @see init_size
|
|
|
|
* @return the currently set screen height
|
|
|
|
*/
|
|
|
|
virtual int16 get_height() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the currently set screen width.
|
|
|
|
* @see init_size
|
|
|
|
* @return the currently set screen width
|
|
|
|
*/
|
|
|
|
virtual int16 get_width() = 0;
|
|
|
|
|
|
|
|
/** Set colors of the palette. */
|
|
|
|
virtual void set_palette(const byte *colors, uint start, uint num) = 0;
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
|
|
|
* Draw a bitmap to screen.
|
|
|
|
* The screen will not be updated to reflect the new bitmap, you have
|
|
|
|
* to call update_screen to do that.
|
|
|
|
* @see update_screen
|
|
|
|
*/
|
2002-04-12 21:26:59 +00:00
|
|
|
virtual void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) = 0;
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
|
|
|
* Moves the screen content by the offset specified via dx/dy.
|
|
|
|
* Only the region from x=0 till x=height-1 is affected.
|
|
|
|
* @param dx the horizontal offset.
|
|
|
|
* @param dy the vertical offset.
|
|
|
|
* @param height the number of lines which in which the move will be done.
|
|
|
|
*/
|
2002-09-09 05:56:11 +00:00
|
|
|
virtual void move_screen(int dx, int dy, int height) = 0;
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/** Update the dirty areas of the screen. */
|
2002-04-12 21:26:59 +00:00
|
|
|
virtual void update_screen() = 0;
|
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
/**
|
|
|
|
* Set current shake position, a feature needed for some SCUMM screen effects.
|
|
|
|
* The effect causes the displayed graphics to be shifted upwards by the specified
|
|
|
|
* (always positive) offset. The area at the bottom of the screen which is moved
|
|
|
|
* into view by this is filled by black. This does not cause any graphic data to
|
|
|
|
* be lost - that is, to restore the original view, the game engine only has to
|
|
|
|
* call this method again with a 0 offset. No calls to copy_rect are necessary.
|
|
|
|
* @param shakeOffset the shake offset
|
|
|
|
*/
|
|
|
|
virtual void set_shake_pos(int shakeOffset) = 0;
|
|
|
|
|
|
|
|
/** Convert the given RGB triplet into a NewGuiColor. A NewGuiColor can be
|
|
|
|
* 8bit, 16bit or 32bit, depending on the target system. The default
|
|
|
|
* implementation generates a 16 bit color value, in the 565 format
|
|
|
|
* (that is, 5 bits red, 6 bits green, 5 bits blue).
|
|
|
|
* @see colorToRGB
|
|
|
|
*/
|
|
|
|
virtual NewGuiColor RGBToColor(uint8 r, uint8 g, uint8 b) {
|
|
|
|
return ((((r >> 3) & 0x1F) << 11) | (((g >> 2) & 0x3F) << 5) | ((b >> 3) & 0x1F));
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Convert the given NewGuiColor into a RGB triplet. A NewGuiColor can be
|
|
|
|
* 8bit, 16bit or 32bit, depending on the target system. The default
|
|
|
|
* implementation takes a 16 bit color value and assumes it to be in 565 format
|
|
|
|
* (that is, 5 bits red, 6 bits green, 5 bits blue).
|
|
|
|
* @see RGBToColor
|
|
|
|
*/
|
|
|
|
virtual void colorToRGB(NewGuiColor color, uint8 &r, uint8 &g, uint8 &b) {
|
|
|
|
r = (((color >> 11) & 0x1F) << 3);
|
|
|
|
g = (((color >> 5) & 0x3F) << 2);
|
|
|
|
b = ((color&0x1F) << 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @name Mouse */
|
|
|
|
//@{
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/** Show or hide the mouse cursor. */
|
2002-04-12 21:26:59 +00:00
|
|
|
virtual bool show_mouse(bool visible) = 0;
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
2003-08-02 00:36:38 +00:00
|
|
|
* Move ("warp) the mouse cursor to the specified position.
|
2003-05-29 21:45:26 +00:00
|
|
|
*/
|
2003-01-09 13:52:59 +00:00
|
|
|
virtual void warp_mouse(int x, int y) = 0;
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/** Set the bitmap used for drawing the cursor. */
|
2002-04-12 21:26:59 +00:00
|
|
|
virtual void set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) = 0;
|
2003-05-29 22:34:35 +00:00
|
|
|
|
|
|
|
//@}
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** @name Events and Threads */
|
|
|
|
//@{
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/** Get the number of milliseconds since the program was started. */
|
2002-04-12 21:26:59 +00:00
|
|
|
virtual uint32 get_msecs() = 0;
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/** Delay/sleep for the specified amount of milliseconds. */
|
2002-04-12 21:26:59 +00:00
|
|
|
virtual void delay_msecs(uint msecs) = 0;
|
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
|
|
|
* Create a thread with the given entry procedure.
|
|
|
|
* @param proc the thread main procedure
|
2003-05-29 22:34:35 +00:00
|
|
|
* @param param an arbitrary parameter which is stored and passed to proc
|
2003-05-29 21:45:26 +00:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
virtual void create_thread(ThreadProc *proc, void *param) = 0;
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
/** Add a new callback timer. */
|
|
|
|
virtual void set_timer(int timer, int (*callback)(int)) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the next event in the event queue.
|
|
|
|
* @param event point to an Event struct, which will be filled with the event data.
|
|
|
|
* @return true if an event was retrieved.
|
|
|
|
*/
|
2002-04-12 21:26:59 +00:00
|
|
|
virtual bool poll_event(Event *event) = 0;
|
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @name Sound */
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
* Set the audio callback which is invoked whenever samples need to be generated.
|
|
|
|
* Currently, only the 16-bit signed mode is ever used for Simon & Scumm
|
|
|
|
* @param proc pointer to the callback.
|
|
|
|
* @param param an arbitrary parameter which is stored and passed to proc.
|
|
|
|
* @param format the sample type format.
|
|
|
|
*/
|
|
|
|
virtual bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format) = 0;
|
2003-06-09 01:19:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove any audio callback previously set via set_sound_proc, thus effectively
|
|
|
|
* stopping all audio output immediately.
|
|
|
|
* @see set_sound_proc
|
|
|
|
*/
|
|
|
|
virtual void clear_sound_proc() = 0;
|
2003-05-29 22:34:35 +00:00
|
|
|
//@}
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
|
|
|
* @name Audio CD
|
|
|
|
* The methods in this group deal with Audio CD playback.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Poll CD status
|
|
|
|
* @return true if CD audio is playing
|
|
|
|
*/
|
2002-04-16 16:11:08 +00:00
|
|
|
virtual bool poll_cdrom() = 0;
|
2002-04-16 12:18:50 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
|
|
|
* Start audio CD playback.
|
2003-07-22 23:27:41 +00:00
|
|
|
* @param track the track to play.
|
|
|
|
* @param num_loops how often playback should be repeated (-1 = infinitely often).
|
|
|
|
* @param start_frame the frame at which playback should start (75 frames = 1 second).
|
|
|
|
* @param duration the number of frames to play.
|
2003-05-29 21:45:26 +00:00
|
|
|
*/
|
2003-07-22 23:27:41 +00:00
|
|
|
virtual void play_cdrom(int track, int num_loops, int start_frame, int duration) = 0;
|
2002-04-16 12:18:50 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
|
|
|
// Stop audio CD playback
|
|
|
|
*/
|
2002-04-16 16:11:08 +00:00
|
|
|
virtual void stop_cdrom() = 0;
|
2002-04-16 12:18:50 +00:00
|
|
|
|
2003-05-29 21:45:26 +00:00
|
|
|
/**
|
2002-04-16 12:18:50 +00:00
|
|
|
// Update cdrom audio status
|
2003-05-29 21:45:26 +00:00
|
|
|
*/
|
2002-04-16 16:11:08 +00:00
|
|
|
virtual void update_cdrom() = 0;
|
2003-05-29 21:45:26 +00:00
|
|
|
//@}
|
|
|
|
|
2002-04-16 12:18:50 +00:00
|
|
|
|
2002-05-14 18:14:16 +00:00
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
/** @name Mutex handling */
|
2003-05-29 21:45:26 +00:00
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
* Create a new mutex.
|
|
|
|
* @return the newly created mutex, or 0 if an error occured.
|
|
|
|
*/
|
|
|
|
virtual MutexRef create_mutex(void) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lock the given mutex.
|
|
|
|
* @param mutex the mutex to lock.
|
|
|
|
*/
|
|
|
|
virtual void lock_mutex(MutexRef mutex) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unlock the given mutex.
|
|
|
|
* @param mutex the mutex to unlock.
|
|
|
|
*/
|
|
|
|
virtual void unlock_mutex(MutexRef mutex) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete the given mutex. Make sure the mutex is unlocked before you delete it.
|
|
|
|
* If you delete a locked mutex, the behavior is undefined, in particular, your
|
|
|
|
* program may crash.
|
|
|
|
* @param mutex the mutex to delete.
|
|
|
|
*/
|
|
|
|
virtual void delete_mutex(MutexRef mutex) = 0;
|
|
|
|
//@}
|
2002-06-04 18:18:44 +00:00
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
|
2002-09-19 16:06:51 +00:00
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
/** @name Overlay */
|
2003-05-29 21:45:26 +00:00
|
|
|
//@{
|
2002-09-19 16:06:51 +00:00
|
|
|
virtual void show_overlay() = 0;
|
|
|
|
virtual void hide_overlay() = 0;
|
|
|
|
virtual void clear_overlay() = 0;
|
2003-05-02 09:23:56 +00:00
|
|
|
virtual void grab_overlay(NewGuiColor *buf, int pitch) = 0;
|
|
|
|
virtual void copy_rect_overlay(const NewGuiColor *buf, int pitch, int x, int y, int w, int h) = 0;
|
2003-05-29 21:45:26 +00:00
|
|
|
//@}
|
2002-12-13 16:15:58 +00:00
|
|
|
|
2002-12-28 04:57:28 +00:00
|
|
|
|
2002-12-17 01:15:13 +00:00
|
|
|
|
2003-05-29 22:34:35 +00:00
|
|
|
/** @name Miscellaneous */
|
|
|
|
//@{
|
|
|
|
/** Get or set a backend property. */
|
|
|
|
virtual uint32 property(int param, Property *value) = 0;
|
|
|
|
|
|
|
|
/** Quit (exit) the application. */
|
|
|
|
virtual void quit() = 0;
|
|
|
|
|
|
|
|
/** Savefile management. */
|
2003-03-06 16:27:06 +00:00
|
|
|
virtual SaveFileManager *get_savefile_manager() {
|
2002-12-17 01:15:13 +00:00
|
|
|
return new SaveFileManager();
|
|
|
|
}
|
2003-05-29 22:34:35 +00:00
|
|
|
//@}
|
2002-03-21 01:03:27 +00:00
|
|
|
};
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2002-06-02 20:28:09 +00:00
|
|
|
#endif
|