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
|
|
|
|
2002-09-08 01:08:12 +00:00
|
|
|
#include "scummsys.h"
|
2002-12-17 01:15:13 +00:00
|
|
|
#include "savefile.h"
|
2002-09-08 01:08:12 +00:00
|
|
|
|
2002-09-18 10:22:36 +00:00
|
|
|
class Timer;
|
|
|
|
|
2002-09-08 01:08:12 +00:00
|
|
|
// Interface to the ScummVM backend
|
2002-04-12 21:26:59 +00:00
|
|
|
|
|
|
|
class OSystem {
|
|
|
|
public:
|
|
|
|
typedef int ThreadProc(void *param);
|
2002-04-14 18:13:08 +00:00
|
|
|
typedef void SoundProc(void *param, byte *buf, int len);
|
2002-04-12 21:26:59 +00:00
|
|
|
|
|
|
|
struct Event {
|
|
|
|
int event_code;
|
|
|
|
struct {
|
|
|
|
uint16 ascii;
|
|
|
|
byte flags;
|
|
|
|
int keycode;
|
|
|
|
} kbd;
|
|
|
|
struct {
|
|
|
|
int x,y;
|
|
|
|
} mouse;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
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,
|
2002-12-25 00:36:04 +00:00
|
|
|
EVENT_WHEELDOWN = 9
|
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
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
|
|
|
PROP_GET_FMOPL_EG_ENT = 9
|
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;
|
|
|
|
};
|
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
enum {
|
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
|
|
|
};
|
|
|
|
|
|
|
|
// Set colors of the palette
|
|
|
|
virtual void set_palette(const byte *colors, uint start, uint num) = 0;
|
|
|
|
|
|
|
|
// Set the size of the video bitmap.
|
|
|
|
// Typically, 320x200
|
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
|
|
|
|
|
|
|
// Draw a bitmap to screen.
|
|
|
|
// The screen will not be updated to reflect the new bitmap
|
|
|
|
virtual void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) = 0;
|
|
|
|
|
2002-09-09 05:56:11 +00:00
|
|
|
// Moves the screen content around by the given amount of pixels
|
|
|
|
// but only the top height pixel rows, the rest stays untouched
|
|
|
|
virtual void move_screen(int dx, int dy, int height) = 0;
|
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
// Update the dirty areas of the screen
|
|
|
|
virtual void update_screen() = 0;
|
|
|
|
|
|
|
|
// Either show or hide the mouse cursor
|
|
|
|
virtual bool show_mouse(bool visible) = 0;
|
|
|
|
|
|
|
|
// Set the position of the mouse cursor
|
|
|
|
virtual void set_mouse_pos(int x, int y) = 0;
|
2003-01-09 13:52:59 +00:00
|
|
|
|
|
|
|
// Warp the mouse cursor. Where set_mouse_pos() only informs the
|
|
|
|
// backend of the mouse cursor's current position, this function
|
|
|
|
// actually moves the cursor to the specified position.
|
|
|
|
virtual void warp_mouse(int x, int y) = 0;
|
2002-04-12 21:26:59 +00:00
|
|
|
|
|
|
|
// Set the bitmap that's used when drawing the cursor.
|
|
|
|
virtual void set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) = 0;
|
|
|
|
|
|
|
|
// Shaking is used in SCUMM. Set current shake position.
|
|
|
|
virtual void set_shake_pos(int shake_pos) = 0;
|
|
|
|
|
|
|
|
// Get the number of milliseconds since the program was started.
|
|
|
|
virtual uint32 get_msecs() = 0;
|
|
|
|
|
|
|
|
// Delay for a specified amount of milliseconds
|
|
|
|
virtual void delay_msecs(uint msecs) = 0;
|
|
|
|
|
|
|
|
// Create a thread
|
|
|
|
virtual void *create_thread(ThreadProc *proc, void *param) = 0;
|
|
|
|
|
|
|
|
// Get the next event.
|
|
|
|
// Returns true if an event was retrieved.
|
|
|
|
virtual bool poll_event(Event *event) = 0;
|
|
|
|
|
|
|
|
// Set the function to be invoked whenever samples need to be generated
|
2002-04-14 18:13:08 +00:00
|
|
|
// Format is the sample type format.
|
|
|
|
// Only 16-bit signed mode is needed for simon & scumm
|
2002-04-16 12:07:19 +00:00
|
|
|
virtual bool set_sound_proc(void *param, SoundProc *proc, byte format) = 0;
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2002-04-14 18:13:08 +00:00
|
|
|
// Get or set a property
|
2002-05-04 09:55:10 +00:00
|
|
|
virtual uint32 property(int param, Property *value) = 0;
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2002-04-16 12:18:50 +00:00
|
|
|
// Poll cdrom status
|
|
|
|
// Returns 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
|
|
|
|
|
|
|
// Play cdrom audio track
|
2002-04-16 16:11:08 +00:00
|
|
|
virtual void play_cdrom(int track, int num_loops, int start_frame, int end_frame) = 0;
|
2002-04-16 12:18:50 +00:00
|
|
|
|
|
|
|
// Stop cdrom audio track
|
2002-04-16 16:11:08 +00:00
|
|
|
virtual void stop_cdrom() = 0;
|
2002-04-16 12:18:50 +00:00
|
|
|
|
|
|
|
// Update cdrom audio status
|
2002-04-16 16:11:08 +00:00
|
|
|
virtual void update_cdrom() = 0;
|
2002-04-16 12:18:50 +00:00
|
|
|
|
2002-05-14 18:14:16 +00:00
|
|
|
// Add a new callback timer
|
2002-05-14 19:38:28 +00:00
|
|
|
virtual void set_timer(int timer, int (*callback)(int)) = 0;
|
2002-05-14 18:14:16 +00:00
|
|
|
|
2002-06-04 18:18:44 +00:00
|
|
|
// Mutex handling
|
|
|
|
virtual void *create_mutex(void) = 0;
|
|
|
|
virtual void lock_mutex(void *mutex) = 0;
|
|
|
|
virtual void unlock_mutex(void *mutex) = 0;
|
|
|
|
virtual void delete_mutex(void *mutex) = 0;
|
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
// Quit
|
|
|
|
virtual void quit() = 0;
|
2002-09-19 16:06:51 +00:00
|
|
|
|
|
|
|
// Overlay
|
|
|
|
virtual void show_overlay() = 0;
|
|
|
|
virtual void hide_overlay() = 0;
|
|
|
|
virtual void clear_overlay() = 0;
|
|
|
|
virtual void grab_overlay(int16 *buf, int pitch) = 0;
|
|
|
|
virtual void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) = 0;
|
2002-12-13 16:15:58 +00:00
|
|
|
|
2002-12-28 04:57:28 +00:00
|
|
|
// Low-level graphics access
|
|
|
|
virtual int16 get_height() {return 200;}
|
|
|
|
virtual int16 get_width() {return 320;}
|
|
|
|
|
2002-12-13 16:15:58 +00:00
|
|
|
// Methods that convert RBG to/from colors suitable for the overlay.
|
|
|
|
// Default implementation assumes 565 mode.
|
2003-03-06 16:27:06 +00:00
|
|
|
virtual int16 RBGToColor(uint8 r, uint8 g, uint8 b) {
|
|
|
|
return ((((r >> 3) & 0x1F) << 11) | (((g >> 2) & 0x3F) << 5) | ((b >> 3) & 0x1F));
|
2002-12-13 16:15:58 +00:00
|
|
|
}
|
2003-03-06 16:27:06 +00:00
|
|
|
virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b) {
|
|
|
|
r = (((color >> 11) & 0x1F) << 3);
|
|
|
|
g = (((color >> 5) & 0x3F) << 2);
|
2002-12-13 16:15:58 +00:00
|
|
|
b = ((color&0x1F) << 3);
|
|
|
|
}
|
2002-12-17 01:15:13 +00:00
|
|
|
|
|
|
|
// 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();
|
|
|
|
}
|
2002-03-21 01:03:27 +00:00
|
|
|
};
|
2002-04-12 21:26:59 +00:00
|
|
|
|
|
|
|
/* Factory functions. This means we don't have to include the
|
|
|
|
* OSystem_SDL header file. (which in turn would require the SDL headers)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* OSystem_SDL */
|
2002-05-05 20:04:26 +00:00
|
|
|
extern OSystem *OSystem_SDL_create(int gfx_driver, bool full_screen);
|
|
|
|
extern OSystem *OSystem_NULL_create();
|
|
|
|
extern OSystem *OSystem_MorphOS_create(int game_id, int gfx_driver, bool full_screen);
|
|
|
|
extern OSystem *OSystem_Dreamcast_create();
|
|
|
|
extern OSystem *OSystem_WINCE3_create();
|
|
|
|
extern OSystem *OSystem_X11_create();
|
|
|
|
extern OSystem *OSystem_MAC_create(int gfx_mode, bool full_screen);
|
2002-11-30 16:03:46 +00:00
|
|
|
extern OSystem *OSystem_GP32_create(int gfx_mode, bool full_screen); //ph0x
|
2002-04-12 21:26:59 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
GFX_NORMAL = 0,
|
|
|
|
GFX_DOUBLESIZE = 1,
|
|
|
|
GFX_TRIPLESIZE = 2,
|
|
|
|
GFX_2XSAI = 3,
|
|
|
|
GFX_SUPER2XSAI = 4,
|
|
|
|
GFX_SUPEREAGLE = 5,
|
2003-01-15 02:11:37 +00:00
|
|
|
GFX_ADVMAME2X = 6,
|
2003-03-02 16:36:52 +00:00
|
|
|
GFX_TV2X = 7,
|
|
|
|
GFX_DOTMATRIX = 8
|
2002-04-12 21:26:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-04-13 18:34:11 +00:00
|
|
|
/* Graphics drivers */
|
|
|
|
enum {
|
2002-04-20 17:41:42 +00:00
|
|
|
GD_NULL = 0,
|
|
|
|
GD_SDL,
|
|
|
|
GD_X,
|
|
|
|
GD_MORPHOS,
|
|
|
|
GD_WINCE,
|
2002-05-05 20:04:26 +00:00
|
|
|
GD_MAC,
|
2002-11-30 16:03:46 +00:00
|
|
|
GD_DC,
|
|
|
|
GD_GP32 //ph0x
|
2002-04-13 18:34:11 +00:00
|
|
|
};
|
2002-06-02 20:28:09 +00:00
|
|
|
|
2003-01-29 08:07:10 +00:00
|
|
|
/* Languages */
|
|
|
|
enum {
|
|
|
|
EN_USA = 0,
|
|
|
|
DE_DEU = 1,
|
|
|
|
FR_FRA = 2,
|
|
|
|
IT_ITA = 3,
|
|
|
|
PT_BRA = 4,
|
|
|
|
ES_ESP = 5,
|
|
|
|
JA_JPN = 6,
|
|
|
|
ZH_TWN = 7,
|
2003-01-29 11:31:10 +00:00
|
|
|
KO_KOR = 8,
|
|
|
|
HB_HEB = 20
|
2003-01-29 08:07:10 +00:00
|
|
|
};
|
|
|
|
|
2002-07-17 20:55:36 +00:00
|
|
|
enum {
|
|
|
|
#ifdef _WIN32_WCE
|
2002-11-19 08:05:48 +00:00
|
|
|
SAMPLES_PER_SEC_OLD = 11025,
|
|
|
|
SAMPLES_PER_SEC_NEW = 22050
|
2002-07-17 20:55:36 +00:00
|
|
|
#else
|
|
|
|
SAMPLES_PER_SEC = 22050
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2003-01-29 21:28:37 +00:00
|
|
|
enum {
|
|
|
|
FMOPL_ENV_BITS_HQ = 16,
|
|
|
|
FMOPL_ENV_BITS_LQ = 8,
|
|
|
|
FMOPL_EG_ENT_HQ = 4096,
|
|
|
|
FMOPL_EG_ENT_LQ = 128
|
|
|
|
};
|
|
|
|
|
2002-06-02 20:28:09 +00:00
|
|
|
#endif
|