ScummVM API documentation
dc.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "backends/base-backend.h"
23#include <graphics/surface.h>
24#include <graphics/paletteman.h>
25#include <ronin/soundcommon.h>
26#include "backends/timer/default/default-timer.h"
27#include "backends/audiocd/default/default-audiocd.h"
28#include "backends/fs/fs-factory.h"
29#include "audio/mixer_intern.h"
30#include "common/events.h"
31#include "common/language.h"
32#include "common/platform.h"
33#ifdef DYNAMIC_MODULES
34#include "backends/plugins/dynamic-plugin.h"
35#endif
36
37#define NUM_BUFFERS 4
38#define SOUND_BUFFER_SHIFT 3
39
41{
42 public:
43 virtual int key(int k, byte &shiftFlags) = 0;
44 virtual void mouse(int x, int y) = 0;
45 virtual ~Interactive() = 0;
46};
47inline Interactive::~Interactive() { }
48
49#include "softkbd.h"
50
52 private:
53 static void dc_init_hardware();
54 protected:
55 DCHardware() { dc_init_hardware(); }
56};
57
59public:
60 // Poll cdrom status
61 // Returns true if cd audio is playing
62 bool isPlaying() const override;
63
64 // Play cdrom audio track
65 bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false,
67
68 // Stop cdrom audio track
69 void stop() override;
70};
71
72class OSystem_Dreamcast : virtual public BaseBackend, public Common::EventSource, private DCHardware, public PaletteManager, public FilesystemFactory
73#ifdef DYNAMIC_MODULES
74 , public FilePluginProvider
75#endif
76 {
77
78 public:
80
81 virtual void initBackend();
82
83 // Determine whether the backend supports the specified feature.
85
86 // En-/disable the specified feature.
87 void setFeatureState(Feature f, bool enable);
88
89 // Query the state of the specified feature.
91
92 // Set colors of the palette
94protected:
95 // PaletteManager API
96 void setPalette(const byte *colors, uint start, uint num);
97 void grabPalette(byte *colors, uint start, uint num) const;
98
99public:
100
101 // Determine the pixel format currently in use for screen rendering.
102 Graphics::PixelFormat getScreenFormat() const;
103
104 // Returns a list of all pixel formats supported by the backend.
105 Common::List<Graphics::PixelFormat> getSupportedFormats() const;
106
107 // Set the size of the video bitmap.
108 // Typically, 320x200
109 void initSize(uint w, uint h, const Graphics::PixelFormat *format);
110 int16 getHeight() { return _screen_h; }
111 int16 getWidth() { return _screen_w; }
112
113 // Draw a bitmap to screen.
114 // The screen will not be updated to reflect the new bitmap
115 void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
116
118 virtual void unlockScreen();
119
120 // Update the dirty areas of the screen
122
123 // Either show or hide the mouse cursor
124 bool showMouse(bool visible);
125
126 // Move ("warp") the mouse cursor to the specified position.
127 void warpMouse(int x, int y);
128
129 // Set the bitmap that's used when drawing the cursor.
130 void setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, const Graphics::PixelFormat *format, const byte *mask, frac_t scaleX, frac_t scaleY);
131
132 // Replace the specified range of cursor the palette with new colors.
133 void setCursorPalette(const byte *colors, uint start, uint num);
134
135 // Shaking is used in SCUMM. Set current shake position.
136 void setShakePos(int shake_x_pos, int shake_y_pos);
137
138 // Get the number of milliseconds since the program was started.
139 uint32 getMillis(bool skipRecord = false);
140
141 // Delay for a specified amount of milliseconds
142 void delayMillis(uint msecs);
143
144 // Get the current time and date. Correspond to time()+localtime().
145 void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
146
147 // Get the next event.
148 // Returns true if an event was retrieved.
150
151 // Quit
152 void quit();
153
154 // Overlay
155 int16 getOverlayHeight() const;
156 int16 getOverlayWidth() const;
157 bool isOverlayVisible() const { return _overlay_visible; }
158 void showOverlay(bool inGUI);
162 void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h);
163 virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12); }
164
165 // Mutex handling
167
168 // Set a window caption or any other comparable status display to the
169 // given value.
171
172 // Modulatized backend
173 Audio::Mixer *getMixer() { return _mixer; }
174
175 // Extra SoftKbd support
176 void mouseToSoftKbd(int x, int y, int &rx, int &ry) const;
177
178 // Filesystem
181 AbstractFSNode *makeFileNodePath(const Common::String &path) const override;
182
183 private:
184
185 Audio::MixerImpl *_mixer;
186 SoftKeyboard _softkbd;
187
188 int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y;
189 int _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll, _last_screen_refresh;
190 int _current_shake_x_pos, _current_shake_y_pos, _screen_w, _screen_h;
191 int _overlay_x, _overlay_y;
192 unsigned char *_ms_buf;
193 uint32 _ms_keycolor;
194 bool _overlay_visible, _overlay_dirty, _screen_dirty;
195 int _screen_buffer, _overlay_buffer, _mouse_buffer;
196 bool _aspect_stretch, _softkbd_on, _enable_cursor_palette;
197 bool _overlay_in_gui;
198 float _overlay_fade, _xscale, _yscale, _top_offset;
199 int _softkbd_motion;
200
201 unsigned char *screen;
202 unsigned short *mouse;
203 unsigned short *overlay;
204 void *screen_tx[NUM_BUFFERS];
205 void *mouse_tx[NUM_BUFFERS];
206 void *ovl_tx[NUM_BUFFERS];
207 unsigned short palette[256], cursor_palette[256];
208
209 Graphics::Surface _framebuffer;
210 int _screenFormat, _mouseFormat;
211
212 int temp_sound_buffer[RING_BUFFER_SAMPLES>>SOUND_BUFFER_SHIFT];
213
214 uint initSound();
215 void checkSound();
216
217 void updateScreenTextures(void);
218 void updateScreenPolygons(void);
219 void maybeRefreshScreen(void);
220 void drawMouse(int xdraw, int ydraw, int w, int h,
221 unsigned char *buf, bool visible);
222
223 void setScaling();
224
225
226 Common::SaveFileManager *createSavefileManager();
227
228 Common::SeekableReadStream *createConfigReadStream();
229 Common::WriteStream *createConfigWriteStream();
230
231 void logMessage(LogMessageType::Type type, const char *message);
232 Common::String getSystemLanguage() const;
233
234#ifdef DYNAMIC_MODULES
235 class DCPlugin;
236
237 protected:
238 Plugin* createPlugin(const Common::FSNode &node) const;
239 bool isPluginFilename(const Common::FSNode &node) const;
240 void addCustomDirectories(Common::FSList &dirs) const;
241 public:
242 PluginList getPlugins();
243 private:
244 const char *pluginCustomDirectory;
245#endif
246};
247
248
249extern int handleInput(struct mapledev *pad,
250 int &mouse_x, int &mouse_y,
251 byte &shiftFlags, Interactive *inter = NULL);
252extern bool selectGame(char *&, char *&, char *&, Common::Language &, Common::Platform &, class Icon &);
253#ifdef DYNAMIC_MODULES
254extern bool selectPluginDir(Common::String &selection, const Common::FSNode &base);
255#endif
Definition: abstract-fs.h:41
Definition: mixer.h:70
SoundType
Definition: mixer.h:73
@ kMusicSoundType
Definition: mixer.h:76
Definition: mixer_intern.h:58
Definition: base-backend.h:31
Definition: events.h:278
Definition: fs.h:57
Definition: fs.h:69
Definition: list.h:44
Definition: mutex.h:40
Definition: savefile.h:142
Definition: stream.h:745
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
Definition: dc.h:58
void stop() override
bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate=false, Audio::Mixer::SoundType soundType=Audio::Mixer::kMusicSoundType) override
bool isPlaying() const override
Definition: dc.h:51
Definition: default-audiocd.h:35
Definition: fs-factory.h:31
Definition: icon.h:26
Definition: dc.h:41
Definition: dc.h:76
PaletteManager * getPaletteManager()
Definition: dc.h:93
bool getFeatureState(Feature f)
void initSize(uint w, uint h, const Graphics::PixelFormat *format)
AbstractFSNode * makeCurrentDirectoryFileNode() const override
void grabPalette(byte *colors, uint start, uint num) const
Audio::Mixer * getMixer()
Definition: dc.h:173
void delayMillis(uint msecs)
bool showMouse(bool visible)
void setFeatureState(Feature f, bool enable)
virtual void unlockScreen()
void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h)
bool pollEvent(Common::Event &event)
void setWindowCaption(const Common::U32String &caption)
void warpMouse(int x, int y)
int16 getHeight()
Definition: dc.h:110
bool hasFeature(Feature f)
void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h)
int16 getOverlayHeight() const
void setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, const Graphics::PixelFormat *format, const byte *mask, frac_t scaleX, frac_t scaleY)
virtual Graphics::PixelFormat getOverlayFormat() const
Definition: dc.h:163
int16 getOverlayWidth() const
AbstractFSNode * makeRootFileNode() const override
void showOverlay(bool inGUI)
void setCursorPalette(const byte *colors, uint start, uint num)
uint32 getMillis(bool skipRecord=false)
virtual void initBackend()
void setPalette(const byte *colors, uint start, uint num)
Common::MutexInternal * createMutex()
void getTimeAndDate(TimeDate &td, bool skipRecord=false) const
virtual Graphics::Surface * lockScreen()
bool isOverlayVisible() const
Definition: dc.h:157
int16 getWidth()
Definition: dc.h:111
AbstractFSNode * makeFileNodePath(const Common::String &path) const override
void setShakePos(int shake_x_pos, int shake_y_pos)
void grabOverlay(Graphics::Surface &surface)
Definition: paletteman.h:47
Definition: plugins.h:157
Definition: softkbd.h:32
int32 frac_t
Definition: frac.h:52
Language
Definition: language.h:45
Platform
Definition: platform.h:93
Feature
Definition: system.h:415
Type
Definition: log.h:33
Definition: events.h:218
Definition: pixelformat.h:138
Definition: surface.h:67
Definition: system.h:111