2003-10-02 17:28:02 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Dreamcast port
|
2004-01-06 12:45:34 +00:00
|
|
|
* Copyright (C) 2002-2004 Marcus Comstedt
|
2003-10-02 17:28:02 +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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-10-02 17:28:02 +00:00
|
|
|
*
|
2006-02-09 13:25:53 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-10-02 17:28:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-09-13 15:01:20 +00:00
|
|
|
#include <common/system.h>
|
2002-04-18 23:21:40 +00:00
|
|
|
#include <ronin/soundcommon.h>
|
2002-02-02 15:44:27 +00:00
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
#define NUM_BUFFERS 4
|
2004-03-14 13:14:03 +00:00
|
|
|
#define SOUND_BUFFER_SHIFT 3
|
2002-04-18 23:21:40 +00:00
|
|
|
|
2004-03-14 22:16:22 +00:00
|
|
|
class Interactive
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual int key(int k, byte &shiftFlags) = 0;
|
2004-12-09 20:21:31 +00:00
|
|
|
virtual void mouse(int x, int y) = 0;
|
2004-03-14 22:16:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#include "softkbd.h"
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
class OSystem_Dreamcast : public OSystem {
|
|
|
|
|
2006-10-22 17:58:38 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
// Set function that generates samples
|
|
|
|
typedef void (*SoundProc)(void *param, byte *buf, int len);
|
|
|
|
bool setSoundCallback(SoundProc proc, void *param);
|
|
|
|
void clearSoundCallback();
|
|
|
|
|
|
|
|
// Add a callback timer
|
|
|
|
typedef int (*TimerProc)(int interval);
|
|
|
|
void setTimerCallback(TimerProc callback, int timer);
|
|
|
|
|
|
|
|
Common::SaveFileManager *createSavefileManager();
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
public:
|
2003-06-18 21:06:03 +00:00
|
|
|
OSystem_Dreamcast();
|
|
|
|
|
2006-10-22 17:58:38 +00:00
|
|
|
virtual void initBackend();
|
2004-03-13 13:41:50 +00:00
|
|
|
|
2004-03-13 14:00:44 +00:00
|
|
|
// Determine whether the backend supports the specified feature.
|
|
|
|
bool hasFeature(Feature f);
|
|
|
|
|
|
|
|
// En-/disable the specified feature.
|
|
|
|
void setFeatureState(Feature f, bool enable);
|
|
|
|
|
2004-03-15 00:47:59 +00:00
|
|
|
// Query the state of the specified feature.
|
2004-03-13 14:00:44 +00:00
|
|
|
bool getFeatureState(Feature f);
|
|
|
|
|
2004-03-13 13:41:50 +00:00
|
|
|
// Retrieve a list of all graphics modes supported by this backend.
|
|
|
|
const GraphicsMode *getSupportedGraphicsModes() const;
|
|
|
|
|
2004-03-15 00:47:59 +00:00
|
|
|
// Return the ID of the 'default' graphics mode.
|
|
|
|
int getDefaultGraphicsMode() const;
|
|
|
|
|
2004-03-13 13:41:50 +00:00
|
|
|
// Switch to the specified graphics mode.
|
|
|
|
bool setGraphicsMode(int mode);
|
|
|
|
|
|
|
|
// Determine which graphics mode is currently active.
|
|
|
|
int getGraphicsMode() const;
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
// Set colors of the palette
|
2004-02-28 12:58:13 +00:00
|
|
|
void setPalette(const byte *colors, uint start, uint num);
|
2005-06-27 15:16:58 +00:00
|
|
|
void grabPalette(byte *colors, uint start, uint num);
|
2002-04-18 23:21:40 +00:00
|
|
|
|
|
|
|
// Set the size of the video bitmap.
|
|
|
|
// Typically, 320x200
|
2006-05-17 23:52:45 +00:00
|
|
|
void initSize(uint w, uint h);
|
2004-03-15 00:45:45 +00:00
|
|
|
int16 getHeight() { return _screen_h; }
|
|
|
|
int16 getWidth() { return _screen_w; }
|
2002-04-18 23:21:40 +00:00
|
|
|
|
|
|
|
// Draw a bitmap to screen.
|
|
|
|
// The screen will not be updated to reflect the new bitmap
|
2004-03-28 16:30:50 +00:00
|
|
|
void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
2002-04-18 23:21:40 +00:00
|
|
|
|
2005-10-15 14:15:22 +00:00
|
|
|
// Copies the current screen contents to a new surface.
|
|
|
|
bool grabRawScreen(Graphics::Surface *surf);
|
|
|
|
|
|
|
|
// Clear the screen to black.
|
|
|
|
void clearScreen();
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
// Update the dirty areas of the screen
|
2004-02-28 12:58:13 +00:00
|
|
|
void updateScreen();
|
2002-04-18 23:21:40 +00:00
|
|
|
|
|
|
|
// Either show or hide the mouse cursor
|
2004-03-28 16:30:50 +00:00
|
|
|
bool showMouse(bool visible);
|
2004-03-13 13:41:50 +00:00
|
|
|
|
|
|
|
// Move ("warp") the mouse cursor to the specified position.
|
2004-03-28 16:30:50 +00:00
|
|
|
void warpMouse(int x, int y);
|
2003-03-02 17:41:47 +00:00
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
// Set the bitmap that's used when drawing the cursor.
|
2005-04-03 18:02:27 +00:00
|
|
|
void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-10-15 14:33:58 +00:00
|
|
|
// Replace the specified range of cursor the palette with new colors.
|
|
|
|
void setCursorPalette(const byte *colors, uint start, uint num);
|
|
|
|
|
|
|
|
// Disable or enable cursor palette.
|
|
|
|
void disableCursorPalette(bool disable);
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
// Shaking is used in SCUMM. Set current shake position.
|
2004-09-28 20:19:37 +00:00
|
|
|
void setShakePos(int shake_pos);
|
2002-04-18 23:21:40 +00:00
|
|
|
|
|
|
|
// Get the number of milliseconds since the program was started.
|
2004-09-28 20:19:37 +00:00
|
|
|
uint32 getMillis();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
// Delay for a specified amount of milliseconds
|
2004-09-28 20:19:37 +00:00
|
|
|
void delayMillis(uint msecs);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
// Get the next event.
|
2005-07-30 21:11:48 +00:00
|
|
|
// Returns true if an event was retrieved.
|
2004-09-28 20:19:37 +00:00
|
|
|
bool pollEvent(Event &event);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-03-13 13:41:50 +00:00
|
|
|
// Determine the output sample rate. Audio data provided by the sound
|
|
|
|
// callback will be played using this rate.
|
|
|
|
int getOutputSampleRate() const;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-03-13 13:41:50 +00:00
|
|
|
// Initialise the specified CD drive for audio playback.
|
|
|
|
bool openCD(int drive);
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
// Poll cdrom status
|
|
|
|
// Returns true if cd audio is playing
|
2004-09-28 20:19:37 +00:00
|
|
|
bool pollCD();
|
2002-04-18 23:21:40 +00:00
|
|
|
|
|
|
|
// Play cdrom audio track
|
2004-09-28 20:19:37 +00:00
|
|
|
void playCD(int track, int num_loops, int start_frame, int duration);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
// Stop cdrom audio track
|
2004-09-28 20:19:37 +00:00
|
|
|
void stopCD();
|
2002-04-18 23:21:40 +00:00
|
|
|
|
|
|
|
// Update cdrom audio status
|
2004-09-28 20:19:37 +00:00
|
|
|
void updateCD();
|
2002-04-18 23:21:40 +00:00
|
|
|
|
|
|
|
// Quit
|
|
|
|
void quit();
|
|
|
|
|
2002-10-18 01:42:55 +00:00
|
|
|
// Overlay
|
2005-10-15 14:15:22 +00:00
|
|
|
int16 getOverlayHeight();
|
|
|
|
int16 getOverlayWidth();
|
|
|
|
int screenToOverlayX(int x);
|
|
|
|
int screenToOverlayY(int y);
|
|
|
|
int overlayToScreenX(int x);
|
|
|
|
int overlayToScreenY(int y);
|
2004-03-28 16:30:50 +00:00
|
|
|
void showOverlay();
|
|
|
|
void hideOverlay();
|
|
|
|
void clearOverlay();
|
|
|
|
void grabOverlay(int16 *buf, int pitch);
|
|
|
|
void copyRectToOverlay(const int16 *buf, int pitch, int x, int y, int w, int h);
|
2005-04-03 19:42:02 +00:00
|
|
|
OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b) { return ARGBToColor(255, r, g, b); }
|
|
|
|
void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) {
|
|
|
|
uint8 tmp; colorToARGB(color, tmp, r, g, b);
|
|
|
|
}
|
|
|
|
OverlayColor ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) {
|
|
|
|
return ((a&0xf0)<<8)|((r&0xf0)<<4)|(g&0xf0)|(b>>4);
|
|
|
|
}
|
|
|
|
void colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) {
|
|
|
|
a = ((color>>8)&0xf0)|((color>>12)&0x0f);
|
|
|
|
r = ((color>>4)&0xf0)|((color>>8)&0x0f);
|
|
|
|
g = (color&0xf0)|((color>>4)&0x0f);
|
|
|
|
b = ((color<<4)&0xf0)|(color&0x0f);
|
|
|
|
}
|
2002-10-18 01:42:55 +00:00
|
|
|
|
2002-09-13 15:01:20 +00:00
|
|
|
// Mutex handling
|
2004-03-13 13:41:50 +00:00
|
|
|
MutexRef createMutex();
|
|
|
|
void lockMutex(MutexRef mutex);
|
|
|
|
void unlockMutex(MutexRef mutex);
|
|
|
|
void deleteMutex(MutexRef mutex);
|
|
|
|
|
|
|
|
// Set a window caption or any other comparable status display to the
|
|
|
|
// given value.
|
|
|
|
void setWindowCaption(const char *caption);
|
2002-09-13 15:01:20 +00:00
|
|
|
|
2006-10-22 17:58:38 +00:00
|
|
|
// Modulatized backend
|
|
|
|
Common::SaveFileManager *getSavefileManager() { return _savefile; }
|
|
|
|
Audio::Mixer *getMixer() { return _mixer; }
|
|
|
|
Common::TimerManager *getTimerManager() { return _timer; }
|
2002-09-13 15:01:20 +00:00
|
|
|
|
2004-12-09 20:21:31 +00:00
|
|
|
// Extra SoftKbd support
|
|
|
|
void mouseToSoftKbd(int x, int y, int &rx, int &ry) const;
|
|
|
|
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
private:
|
|
|
|
|
2006-10-22 17:58:38 +00:00
|
|
|
Common::SaveFileManager *_savefile;
|
|
|
|
Audio::Mixer *_mixer;
|
|
|
|
Common::TimerManager *_timer;
|
2004-03-14 22:16:22 +00:00
|
|
|
SoftKeyboard _softkbd;
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y;
|
|
|
|
int _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll;
|
2002-10-18 01:42:55 +00:00
|
|
|
int _current_shake_pos, _screen_w, _screen_h;
|
2003-05-04 19:08:21 +00:00
|
|
|
int _overlay_x, _overlay_y;
|
2002-04-18 23:21:40 +00:00
|
|
|
unsigned char *_ms_buf;
|
2004-05-05 02:32:46 +00:00
|
|
|
unsigned char _ms_keycolor;
|
2003-09-27 16:54:11 +00:00
|
|
|
SoundProc _sound_proc;
|
2002-04-18 23:21:40 +00:00
|
|
|
void *_sound_proc_param;
|
2002-10-18 01:42:55 +00:00
|
|
|
bool _overlay_visible, _overlay_dirty, _screen_dirty;
|
|
|
|
int _screen_buffer, _overlay_buffer, _mouse_buffer;
|
2005-10-15 14:33:58 +00:00
|
|
|
bool _aspect_stretch, _softkbd_on, _enable_cursor_palette;
|
2004-03-13 17:32:28 +00:00
|
|
|
float _overlay_fade, _xscale, _yscale, _top_offset;
|
2004-03-14 22:16:22 +00:00
|
|
|
int _softkbd_motion;
|
2002-04-18 23:21:40 +00:00
|
|
|
|
2003-03-02 20:17:21 +00:00
|
|
|
uint32 _timer_duration, _timer_next_expiry;
|
|
|
|
bool _timer_active;
|
|
|
|
int (*_timer_callback) (int);
|
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
unsigned char *screen;
|
|
|
|
unsigned short *mouse;
|
2002-10-18 01:42:55 +00:00
|
|
|
unsigned short *overlay;
|
2002-04-18 23:21:40 +00:00
|
|
|
void *screen_tx[NUM_BUFFERS];
|
|
|
|
void *mouse_tx[NUM_BUFFERS];
|
2002-10-18 01:42:55 +00:00
|
|
|
void *ovl_tx[NUM_BUFFERS];
|
2005-10-15 14:33:58 +00:00
|
|
|
unsigned short palette[256], cursor_palette[256];
|
2002-04-18 23:21:40 +00:00
|
|
|
|
2004-03-14 13:14:03 +00:00
|
|
|
int temp_sound_buffer[RING_BUFFER_SAMPLES>>SOUND_BUFFER_SHIFT];
|
2002-04-18 23:21:40 +00:00
|
|
|
|
|
|
|
void checkSound();
|
|
|
|
|
|
|
|
void drawMouse(int xdraw, int ydraw, int w, int h,
|
|
|
|
unsigned char *buf, bool visible);
|
|
|
|
|
2004-03-13 17:32:28 +00:00
|
|
|
void setScaling();
|
2002-04-18 23:21:40 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:16:22 +00:00
|
|
|
|
2002-04-18 23:21:40 +00:00
|
|
|
extern int handleInput(struct mapledev *pad,
|
|
|
|
int &mouse_x, int &mouse_y,
|
2004-03-14 22:16:22 +00:00
|
|
|
byte &shiftFlags, Interactive *inter = NULL);
|
2002-02-18 19:56:50 +00:00
|
|
|
extern void initSound();
|
2002-10-18 01:42:55 +00:00
|
|
|
extern bool selectGame(char *&, char *&, class Icon &);
|
2002-02-02 15:44:27 +00:00
|
|
|
|