Ticket #2075: dc.h

File dc.h, 6.4 KB (added by SF/erwan2004, 19 years ago)

dc.h modified

Line 
1/* ScummVM - Scumm Interpreter
2 * Dreamcast port
3 * Copyright (C) 2002-2004 Marcus Comstedt
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 * $Header: /cvsroot/scummvm/scummvm/backends/dc/dc.h,v 1.40 2005/05/10 23:17:13 fingolfin Exp $
20 *
21 */
22
23#include <common/system.h>
24#include <ronin/soundcommon.h>
25
26#define NUM_BUFFERS 4
27#define SOUND_BUFFER_SHIFT 3
28
29class Interactive
30{
31 public:
32 virtual int key(int k, byte &shiftFlags) = 0;
33 virtual void mouse(int x, int y) = 0;
34};
35
36#include "softkbd.h"
37
38class OSystem_Dreamcast : public OSystem {
39
40 public:
41 OSystem_Dreamcast();
42
43
44 // Determine whether the backend supports the specified feature.
45 bool hasFeature(Feature f);
46
47 // En-/disable the specified feature.
48 void setFeatureState(Feature f, bool enable);
49
50 // Query the state of the specified feature.
51 bool getFeatureState(Feature f);
52
53 // Retrieve a list of all graphics modes supported by this backend.
54 const GraphicsMode *getSupportedGraphicsModes() const;
55
56 // Return the ID of the 'default' graphics mode.
57 int getDefaultGraphicsMode() const;
58
59 // Switch to the specified graphics mode.
60 bool setGraphicsMode(int mode);
61
62 // Determine which graphics mode is currently active.
63 int getGraphicsMode() const;
64
65 // Set colors of the palette
66 void setPalette(const byte *colors, uint start, uint num);
67 //
68 void grabPalette(byte *colors, uint start, uint num);
69 // Set the size of the video bitmap.
70 // Typically, 320x200
71 void initSize(uint w, uint h, int overlayScale);
72 int16 getHeight() { return _screen_h; }
73 int16 getWidth() { return _screen_w; }
74
75 // Draw a bitmap to screen.
76 // The screen will not be updated to reflect the new bitmap
77 void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
78
79 // Update the dirty areas of the screen
80 void updateScreen();
81
82 // Either show or hide the mouse cursor
83 bool showMouse(bool visible);
84
85 // Move ("warp") the mouse cursor to the specified position.
86 void warpMouse(int x, int y);
87
88 // Set the bitmap that's used when drawing the cursor.
89 void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale);
90
91 // Shaking is used in SCUMM. Set current shake position.
92 void setShakePos(int shake_pos);
93
94 // Get the number of milliseconds since the program was started.
95 uint32 getMillis();
96
97 // Delay for a specified amount of milliseconds
98 void delayMillis(uint msecs);
99
100 // Get the next event.
101 // Returns true if an event was retrieved.
102 bool pollEvent(Event &event);
103
104 // Set function that generates samples
105 bool setSoundCallback(SoundProc proc, void *param);
106 void clearSoundCallback();
107
108 // Determine the output sample rate. Audio data provided by the sound
109 // callback will be played using this rate.
110 int getOutputSampleRate() const;
111
112 // Initialise the specified CD drive for audio playback.
113 bool openCD(int drive);
114
115 // Poll cdrom status
116 // Returns true if cd audio is playing
117 bool pollCD();
118
119 // Play cdrom audio track
120 void playCD(int track, int num_loops, int start_frame, int duration);
121
122 // Stop cdrom audio track
123 void stopCD();
124
125 // Update cdrom audio status
126 void updateCD();
127
128 // Quit
129 void quit();
130
131 // Overlay
132 void showOverlay();
133 void hideOverlay();
134 void clearOverlay();
135 void grabOverlay(int16 *buf, int pitch);
136 void copyRectToOverlay(const int16 *buf, int pitch, int x, int y, int w, int h);
137 OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b) { return ARGBToColor(255, r, g, b); }
138 void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) {
139 uint8 tmp; colorToARGB(color, tmp, r, g, b);
140 }
141 OverlayColor ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) {
142 return ((a&0xf0)<<8)|((r&0xf0)<<4)|(g&0xf0)|(b>>4);
143 }
144 void colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) {
145 a = ((color>>8)&0xf0)|((color>>12)&0x0f);
146 r = ((color>>4)&0xf0)|((color>>8)&0x0f);
147 g = (color&0xf0)|((color>>4)&0x0f);
148 b = ((color<<4)&0xf0)|(color&0x0f);
149 }
150
151 // Add a callback timer
152 void setTimerCallback(TimerProc callback, int timer);
153
154 // Mutex handling
155 MutexRef createMutex();
156 void lockMutex(MutexRef mutex);
157 void unlockMutex(MutexRef mutex);
158 void deleteMutex(MutexRef mutex);
159
160 // Set a window caption or any other comparable status display to the
161 // given value.
162 void setWindowCaption(const char *caption);
163
164 // Savefile handling
165 Common::SaveFileManager *getSavefileManager();
166
167
168 // Extra SoftKbd support
169 void mouseToSoftKbd(int x, int y, int &rx, int &ry) const;
170
171
172 static OSystem *create();
173
174
175 private:
176
177 SoftKeyboard _softkbd;
178
179 int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y;
180 int _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll;
181 int _current_shake_pos, _screen_w, _screen_h;
182 int _overlay_x, _overlay_y;
183 unsigned char *_ms_buf;
184 unsigned char _ms_keycolor;
185 SoundProc _sound_proc;
186 void *_sound_proc_param;
187 bool _overlay_visible, _overlay_dirty, _screen_dirty;
188 int _screen_buffer, _overlay_buffer, _mouse_buffer;
189 bool _aspect_stretch, _softkbd_on;
190 float _overlay_fade, _xscale, _yscale, _top_offset;
191 int _softkbd_motion;
192
193 uint32 _timer_duration, _timer_next_expiry;
194 bool _timer_active;
195 int (*_timer_callback) (int);
196
197 unsigned char *screen;
198 unsigned short *mouse;
199 unsigned short *overlay;
200 void *screen_tx[NUM_BUFFERS];
201 void *mouse_tx[NUM_BUFFERS];
202 void *ovl_tx[NUM_BUFFERS];
203 unsigned short palette[256];
204
205 int temp_sound_buffer[RING_BUFFER_SAMPLES>>SOUND_BUFFER_SHIFT];
206
207 void checkSound();
208
209 void drawMouse(int xdraw, int ydraw, int w, int h,
210 unsigned char *buf, bool visible);
211
212 void setScaling();
213};
214
215
216extern int handleInput(struct mapledev *pad,
217 int &mouse_x, int &mouse_y,
218 byte &shiftFlags, Interactive *inter = NULL);
219extern void initSound();
220extern bool selectGame(char *&, char *&, class Icon &);
221