Merge remote-tracking branch 'origin/master' into soltys_wip2

This commit is contained in:
Alyssa Milburn 2011-08-22 20:03:05 +02:00
commit 84063dc972
1124 changed files with 156919 additions and 58874 deletions

20
AUTHORS
View file

@ -1,9 +1,20 @@
ScummVM Team
************
Project Leaders
---------------
Project Leader
--------------
Eugene Sandulenko
PR Office
---------
Arnaud Boutonne - Public Relations Officer, Project Administrator
Eugene Sandulenko - Project Leader
Core Team
---------
Willem Jan Palenstijn
Eugene Sandulenko
Johannes Schickel
Retired Project Leaders
-----------------------
James Brown
@ -71,6 +82,7 @@ ScummVM Team
DreamWeb:
Vladimir Menshakov
Torbjorn Andersson
Bertrand Augereau
Gob:
Torbjorn Andersson
@ -200,6 +212,9 @@ ScummVM Team
Andre Heider
Angus Lees
BADA:
Chris Warren-Smith
Dreamcast:
Marcus Comstedt
@ -220,6 +235,7 @@ ScummVM Team
Nintendo DS:
Neil Millstone
Bertrand Augereau - HQ software scaler
OpenPandora:
John Willis

View file

@ -336,4 +336,4 @@ This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
Public License instead of this License.

View file

@ -506,5 +506,3 @@ necessary. Here is a sample; alter the names:
Ty Coon, President of Vice
That's all there is to it!

View file

@ -90,4 +90,3 @@ endif
ifneq ($(origin port_mk), undefined)
include $(srcdir)/$(port_mk)
endif

19
NEWS
View file

@ -2,9 +2,28 @@ For a more comprehensive changelog of the latest experimental code, see:
https://github.com/scummvm/scummvm/commits/
1.4.0 (????-??-??)
New Games:
- Added support for Lands of Lore: The Throne of Chaos.
- Added support for Blue's Birthday Adventure
- Added support for Ringworld: Revenge Of The Patriarch
AGI:
- Implemented sound support for the DOS version of Winnie the Pooh in the Hundred Acre Wood.
SCUMM:
- Implemented PC Speaker support for SCUMM v5 games.
- Fixed priority bug in iMuse. As a result the AdLib music should sound
better, since important notes are not interrupted anymore.
- Implemented CMS support for Loom, The Secret of Monkey Island and
Indiana Jones and the Last Crusade.
SDL ports:
- Added support for OpenGL (GSoC Task).
TINSEL:
- Fixed deleting saved games from the list of saved games (from the launcher
and the in-game ScummVM menu)
1.3.1 (2011-07-12)
General:
- Improved audio device detection and fallback.

137
README
View file

@ -56,7 +56,7 @@ Table of Contents:
* 7.7 TiMidity++ MIDI server support
* 7.8 Using compressed audio files (MP3, Ogg Vorbis, Flac)
* 7.9 Output sample rate
8.0) Configuration Files
8.0) Configuration file
9.0) Compiling
@ -153,7 +153,7 @@ support an unsupported game -- read the FAQ on our web site first.
---- ---------------
To report a bug, please create a SourceForge account and follow the
"Bug Tracker" link from our homepage. Please make sure the bug is
reproducible, and still occurs in the latest SVN/Daily build version.
reproducible, and still occurs in the latest git/Daily build version.
Also check the known problems list (below) and the compatibility list
on our website for that game, to ensure the issue is not already known:
@ -164,7 +164,7 @@ completeable in the 'Supported Games' section, or compatibility list. We
-know- those games have bugs.
Please include the following information:
- ScummVM version (PLEASE test the latest SVN/Daily build)
- ScummVM version (PLEASE test the latest git/Daily build)
- Bug details, including instructions on reproducing
- Language of game (English, German, ...)
- Version of game (talkie, floppy, ...)
@ -277,6 +277,7 @@ SCUMM Games by Humongous Entertainment:
Blue's 123 Time Activities [Blues123Time]
Blue's ABC Time Activities [BluesABCTime]
Blue's Art Time Activities [arttime]
Blue's Birthday Adventure [BluesBirthday]
Blue's Reading Time Activities [readtime]
Fatty Bear's Birthday Surprise [fbear]
Fatty Bear's Fun Pack [fbpack]
@ -303,12 +304,12 @@ SCUMM Games by Humongous Entertainment:
From Your Head to Your Feet [pajama3]
Pajama Sam's Lost & Found [lost]
Pajama Sam's Sock Works [socks]
Putt-Putt Enters the Race [puttrace]
Putt-Putt Goes to the Moon [puttmoon]
Putt-Putt Joins the Circus [puttcircus]
Putt-Putt Joins the Parade [puttputt]
Putt-Putt Goes to the Moon [puttmoon]
Putt-Putt Saves the Zoo [puttzoo]
Putt-Putt Travels Through Time [putttime]
Putt-Putt Enters the Race [puttrace]
Putt-Putt Joins the Circus [puttcircus]
Putt-Putt and Pep's Balloon-O-Rama [balloon]
Putt-Putt and Pep's Dog on a Stick [dog]
Putt-Putt & Fatty Bear's Activity Pack [activity]
@ -345,7 +346,6 @@ and view the compatibility chart.
Backyard Soccer [soccer]
Backyard Soccer MLS [soccermls]
Backyard Soccer 2004 [soccer2004]
Blue's Birthday Adventure [BluesBirthday]
Blue's Treasure Hunt [BluesTreasureHunt]
Pajama Sam: Games to Play on Any Day [pjgames]
@ -533,8 +533,8 @@ and follow the instructions in its readme.txt file. (Broken Sword II
already has subtitles; no extra work is needed for them.)
3.7.2) Broken Sword games cutscenes, in retrospect
------ -------------------------------------------
3.7.2) Broken Sword games cutscenes, in retrospect:
------ --------------------------------------------
The original releases of the Broken Sword games used RAD Game Tools's
Smacker(tm) format. As RAD was unwilling to open the older legacy
versions of this format to us, and had requested we not reverse engineer
@ -770,11 +770,12 @@ to be able to play the game under ScummVM.
3.19) Dragon History notes:
----- ---------------------
There are 3 language variants of the game: Czech, English, and Polish.
Each of them is distributed in a separate archive. The only official
version is the Czech one, and the English and Polish ports have always
been work in progress and never officially released. Although all texts
are fully translated, it is known that some of them contain typos.
There are 4 language variants of the game: Czech, English, Polish and
German. Each of them is distributed in a separate archive. The only
official version is the Czech one, and the English, Polish and German
ports have always been work in progress and never officially released.
Although all texts are fully translated, it is known that some of them
contain typos.
There exists an optional Czech dubbing for the game. For bandwidth
reasons, you can download it separately and then unpack it to the
@ -846,8 +847,8 @@ site, please see the section on reporting bugs.
Simon the Sorcerer's Puzzle Pack:
- No support for displaying, entering, loading or saving high scores.
- No support for displaying explanation, when clicking on items in
Swampy Adventures.
- No support for displaying names of items, when hovering over them
in Swampy Adventures.
The Feeble Files:
- Subtitles are often incomplete, they were always disabled in the
@ -868,7 +869,7 @@ site, please see the section on reporting bugs.
ScummVM has been ported to run on many platforms and operating systems.
Links to these ports can be found either on the ScummVM web page or by a
Google search. Many thanks to our porters for their efforts. If you have
a port of ScummVM and wish to commit it into the main SVN, feel free to
a port of ScummVM and wish to commit it into the master git, feel free to
contact us!
Supported platforms include (but are not limited to):
@ -955,7 +956,7 @@ arguments -- see the next section.
--themepath=PATH Path to where GUI themes are stored
--list-themes Display list of all usable GUI themes
-e, --music-driver=MODE Select music driver (see also section 7.0)
-q, --language=LANG Select language (see also section 5.2)
-q, --language=LANG Select game's language (see also section 5.2)
-m, --music-volume=NUM Set the music volume, 0-255 (default: 192)
-s, --sfx-volume=NUM Set the sfx volume, 0-255 (default: 192)
-r, --speech-volume=NUM Set the voice volume, 0-255 (default: 192)
@ -1026,8 +1027,8 @@ Examples:
5.2) Language options:
---- -----------------
ScummVM includes a language option for Maniac Mansion, Zak McKracken,
The Dig, The Curse of Monkey Island, Beneath a Steel Sky, Broken Sword
and Simon the Sorcerer 1 and 2.
The Dig, The Curse of Monkey Island, Beneath a Steel Sky and
Broken Sword.
Note that with the exception of Beneath a Steel Sky, Broken Sword,
multilanguage versions of Goblins games and Nippon Safes Inc., using
@ -1081,16 +1082,6 @@ Broken Sword
pt - Portuguese
cz - Czech
Simon the Sorcerer 1 and 2
en - English (default)
de - German
fr - French
it - Italian
es - Spanish
he - Hebrew
pl - Polish
ru - Russian
5.3) Graphics filters:
---- -----------------
@ -1117,8 +1108,8 @@ They are:
tv2x - Interlace filter, tries to emulate a TV. Factor 2x.
dotmatrix - Dot matrix effect. Factor 2x.
To select a graphics filter, pass its name via the '-g' option to
scummvm, for example:
To select a graphics filter, select it in the Launcher, or pass its name
via the '-g' option to scummvm, for example:
scummvm -gadvmame2x monkey2
@ -1172,8 +1163,8 @@ Engines which currently support returning to the Launcher are:
TUCKER
5.5) Hot Keys:
---- ---------
5.5) Hotkeys:
---- --------
ScummVM supports various in-game hotkeys. They differ between SCUMM games and
other games.
@ -1284,10 +1275,14 @@ other games.
b - Background sounds on/off
[Simon the Sorcerer 2 only]
Pause - Pauses
t - Switch between speech and subtitles
t - Switch between speech only and
combined speech and subtitles
[Simon the Sorcerer 1 CD (other than
English and German) and Simon the
Sorcerer 2 CD (all languages)]
v - Switch between subtitles only and
combined speech and subtitles
[Simon the Sorcerer 2 only]
[Simon the Sorcerer 2 CD only]
Simon the Sorcerer's Puzzle Pack
Ctrl-d - Starts the debugger
@ -1305,7 +1300,8 @@ other games.
F9 - Hitbox names on/off
s - Sound effects on/off
Pause - Pauses
t - Switch between speech and subtitles
t - Switch between speech only and
combined speech and subtitles
v - Switch between subtitles only and
combined speech and subtitles
@ -1447,14 +1443,14 @@ Where 'xxx' is exact the saved game slot (ie 001) under ScummVM
7.0) Music and Sound:
---- ----------------
On most operating systems and for most games, ScummVM will by default
use AdLib emulation for music playback. MIDI may not be available on all
operating systems or may need manual configuration. If you want to use
MIDI, you have several different choices of output, depending on your
operating system and configuration.
use MT-32 or AdLib emulation for music playback. MIDI may not be
available on all operating systems or may need manual configuration. If
you want to use MIDI, you have several different choices of output,
depending on your operating system and configuration.
null - Null output. Don't play any music.
adlib - Internal AdLib emulation (default)
adlib - Internal AdLib emulation
fluidsynth - FluidSynth MIDI emulation
mt32 - Internal MT-32 emulation
pcjr - Internal PCjr emulation (only usable in SCUMM games)
@ -1479,7 +1475,7 @@ via the '-e' option to scummvm, for example:
7.1) Playing sound with AdLib emulation:
---- -----------------------------------
By default an AdLib card will be emulated and ScummVM will output the
music as sampled waves. This is the default mode for most games, and
music as sampled waves. This is the default mode for several games, and
offers the best compatibility between machines and games.
@ -1650,7 +1646,7 @@ command as described earlier in this section.
7.6.2) Playing sound with IRIX dmedia sequencer: [UNIX ONLY]
---- ------------------------------------------
---- -------------------------------------------
If you are using IRIX and the dmedia driver with sequencer support, you
can set the environment variable "SCUMMVM_MIDIPORT" or the config file
variable "dmedia_port" to specify your sequencer port. The default is to
@ -1674,7 +1670,7 @@ SCUMMVM_PORT=Software Synth in your environment.
7.7) Using TiMidity++ MIDI server:
---- -----------------------------
If you system lacks any MIDI sequencer, but you still want better MIDI
If your system lacks any MIDI sequencer, but you still want better MIDI
quality than default AdLib emulation can offer, you can try the
TiMidity++ MIDI server. See http://timidity.sourceforge.net/ for
download and install instructions.
@ -1716,9 +1712,9 @@ q specifying the desired quality from 0 to 10:
7.8.2) Using Flac files for CD audio:
------ ------------------------------------
------ ------------------------------
Use flac or some other flac encoder to encode the audio tracks to files.
Name the files track1.flac track2.flac etc. In your filesystem only
Name the files track1.flac track2.flac etc. If your filesystem only
allows three letter extensions, name the files track1.fla track2.fla
etc. ScummVM must be compiled with flac support to use this option. You
will need to rip the files from the CD as a WAV file, then encode the
@ -1754,7 +1750,7 @@ of time than MP3, so have a good book handy.
7.8.5) Compressing MONSTER.SOU with Flac:
------ ----------------------------------------
------ ----------------------------------
As above, but ScummVM must be compiled with Flac support. Run:
compress_scumm_sou --flac monster.sou
@ -1768,8 +1764,8 @@ those kind of soundfiles. Be sure to read the encoder documentation
before you use other values.
7.8.6) Compressing music/sfx/speech in AGOS games
------ -----------------------------------------------------------------
7.8.6) Compressing music/sfx/speech in AGOS games:
------ -------------------------------------------
Use our 'compress_agos' utility from the scummvm-tools package to
perform this task. You can choose between multiple target formats, but
note that you can only use each if ScummVM was compiled with the
@ -1803,14 +1799,14 @@ Eventually you will have a much smaller *.mp3, *.ogg or *.fla file, copy
this file to your game directory. You can safely remove the old file.
7.8.7) Compressing speech/music in Broken Sword
------ ----------------------------------------
7.8.7) Compressing speech/music in Broken Sword:
------ -----------------------------------------
The 'compress_sword1' tool from the scummvm-tools package can encode
music and speech to MP3 as well as Ogg Vorbis. The easiest way to encode
the files is simply copying the executable into your BS1 directory
(together with the lame encoder) and run it from there. This way, it
will automatically encode everything to MP3. Afterwards, you can
manually remove the SPEECH?.CLU files and the wave music files.
music and speech to MP3, Ogg Vorbis as well as Flac. The easiest way
to encode the files is simply copying the executable into your
BS1 directory (together with the lame encoder) and run it from there.
This way, it will automatically encode everything to MP3. Afterwards,
you can manually remove the SPEECH?.CLU files and the wave music files.
Running "compress_sword1 --vorbis" will compress the files using Ogg
Vorbis instead of MP3.
@ -1821,8 +1817,8 @@ instead of MP3.
Use "compress_sword1 --help" to get a full list of the options.
7.8.8) Compressing speech/music in Broken Sword II
------ -------------------------------------------
7.8.8) Compressing speech/music in Broken Sword II:
------ --------------------------------------------
Use our 'compress_sword2' utility from the scummvm-tools package to
perform this task. You can choose between multiple target formats, but
note that you can only use each if ScummVM was compiled with the
@ -2025,7 +2021,7 @@ Flight of the Amazon Queen adds the following non-standard keywords:
music_mute bool If true, music is muted
sfx_mute bool If true, sound effects are muted
King's Quest VI Windows adds the following non-standard keywords:
King's Quest VI Windows adds the following non-standard keyword:
windows_cursors bool If true, the original unscaled black and white
Windows cursors are used instead of the DOS
@ -2059,7 +2055,7 @@ compressed sound. For compressed save states, zlib is required.
Some parts of ScummVM, particularly scalers, have highly optimized
versions written in assembler. If you wish to use this option, you will
need to install nasm assembler (see http://nasm.sf.net). Note, that
need to install nasm assembler (see http://nasm.sf.net). Note that
currently we have only x86 MMX optimized versions, and they will not
compile on other processors.
@ -2076,19 +2072,12 @@ debug messages (see http://www.sysinternals.com/ntw2k/freeware/debugview.shtml).
respectively
http://wiki.scummvm.org/index.php/Compiling_ScummVM/MinGW
Microsoft Visual C++ 6.0:
* Open the workspace file "scummwm.dsw" in the "dists\msvc6" directory.
Microsoft Visual C++ 8/9/10:
* Read up on how to create the project files in "dists\msvc8",
"dists\msvc9" respectively "dists\msvc10".
* Open the resulting solution file.
* Enter the path to the needed libraries and includes in
"Tools|Options|Directories".
* Now it should compile successfully.
* For more information refer to:
http://wiki.scummvm.org/index.php/Compiling_ScummVM/VS2005
Microsoft Visual C++ 7.0/8.0:
* Open the solution file "scummwm.sln" in the "dists\msvc7"
respectively "dists\msvc8" directory.
* Enter the path to the needed libraries and includes in
Tools|Options|Projects|VC++ Directories".
Tools|Options|Projects and Solutions|VC++ Directories".
* Now it should compile successfully.
* For more information refer to:
http://wiki.scummvm.org/index.php/Compiling_ScummVM/VS2005
@ -2140,7 +2129,7 @@ debug messages (see http://www.sysinternals.com/ntw2k/freeware/debugview.shtml).
Maemo:
* Get Scratchbox environment with Maemo 2.2 rootstrap (2.2 is for 770 and up)
* Install libmad, Tremor, FLAC from source
* patch scummvm source (some stuff is currently too dirty to be in svn directly)
* patch scummvm source (some stuff is currently too dirty to be in git directly):
patch -p1 < backends/platform/maemo/scummvm-[currentversion]-maemo.patch
* update debian/changelog
* run 'fakeroot dpkg-buildpackage -b -d'

View file

@ -61,15 +61,13 @@ static const StreamFileFormat STREAM_FILEFORMATS[] = {
{ "MPEG Layer 3", ".mp3", makeMP3Stream },
#endif
{ "MPEG-4 Audio", ".m4a", makeQuickTimeStream },
{ NULL, NULL, NULL } // Terminator
};
SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &basename) {
SeekableAudioStream *stream = NULL;
Common::File *fileHandle = new Common::File();
for (int i = 0; i < ARRAYSIZE(STREAM_FILEFORMATS)-1 && stream == NULL; ++i) {
for (int i = 0; i < ARRAYSIZE(STREAM_FILEFORMATS); ++i) {
Common::String filename = basename + STREAM_FILEFORMATS[i].fileExtension;
fileHandle->open(filename);
if (fileHandle->isOpen()) {
@ -93,7 +91,7 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b
#pragma mark -
LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse)
: _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _completeIterations(0) {
: _parent(stream, disposeAfterUse), _loops(loops), _completeIterations(0) {
assert(stream);
if (!stream->rewind()) {
@ -102,11 +100,6 @@ LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops
}
}
LoopingAudioStream::~LoopingAudioStream() {
if (_disposeAfterUse == DisposeAfterUse::YES)
delete _parent;
}
int LoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) {
if ((_loops && _completeIterations == _loops) || !numSamples)
return 0;
@ -169,7 +162,7 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream,
const Timestamp loopStart,
const Timestamp loopEnd,
DisposeAfterUse::Flag disposeAfterUse)
: _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops),
: _parent(stream, disposeAfterUse), _loops(loops),
_pos(0, getRate() * (isStereo() ? 2 : 1)),
_loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())),
_loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())),
@ -180,11 +173,6 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream,
_done = true;
}
SubLoopingAudioStream::~SubLoopingAudioStream() {
if (_disposeAfterUse == DisposeAfterUse::YES)
delete _parent;
}
int SubLoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) {
if (_done)
return 0;
@ -225,7 +213,7 @@ int SubLoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) {
#pragma mark -
SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse)
: _parent(parent), _disposeAfterUse(disposeAfterUse),
: _parent(parent, disposeAfterUse),
_start(convertTimeToStreamPos(start, getRate(), isStereo())),
_pos(0, getRate() * (isStereo() ? 2 : 1)),
_length(convertTimeToStreamPos(end, getRate(), isStereo()) - _start) {
@ -234,11 +222,6 @@ SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, cons
_parent->seek(_start);
}
SubSeekableAudioStream::~SubSeekableAudioStream() {
if (_disposeAfterUse)
delete _parent;
}
int SubSeekableAudioStream::readBuffer(int16 *buffer, const int numSamples) {
int framesLeft = MIN(_length.frameDiff(_pos), numSamples);
int framesRead = _parent->readBuffer(buffer, framesLeft);

View file

@ -23,6 +23,7 @@
#ifndef SOUND_AUDIOSTREAM_H
#define SOUND_AUDIOSTREAM_H
#include "common/ptr.h"
#include "common/scummsys.h"
#include "common/str.h"
#include "common/types.h"
@ -114,7 +115,6 @@ public:
* @param disposeAfterUse Destroy the stream after the LoopingAudioStream has finished playback.
*/
LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
~LoopingAudioStream();
int readBuffer(int16 *buffer, const int numSamples);
bool endOfData() const;
@ -129,8 +129,7 @@ public:
*/
uint getCompleteIterations() const { return _completeIterations; }
private:
RewindableAudioStream *_parent;
DisposeAfterUse::Flag _disposeAfterUse;
Common::DisposablePtr<RewindableAudioStream> _parent;
uint _loops;
uint _completeIterations;
@ -246,7 +245,6 @@ public:
const Timestamp loopStart,
const Timestamp loopEnd,
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
~SubLoopingAudioStream();
int readBuffer(int16 *buffer, const int numSamples);
bool endOfData() const { return _done; }
@ -254,8 +252,7 @@ public:
bool isStereo() const { return _parent->isStereo(); }
int getRate() const { return _parent->getRate(); }
private:
SeekableAudioStream *_parent;
DisposeAfterUse::Flag _disposeAfterUse;
Common::DisposablePtr<SeekableAudioStream> _parent;
uint _loops;
Timestamp _pos;
@ -283,7 +280,6 @@ public:
* @param disposeAfterUse Whether the parent stream object should be destroyed on destruction of the SubSeekableAudioStream.
*/
SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
~SubSeekableAudioStream();
int readBuffer(int16 *buffer, const int numSamples);
@ -297,8 +293,7 @@ public:
Timestamp getLength() const { return _length; }
private:
SeekableAudioStream *_parent;
DisposeAfterUse::Flag _disposeAfterUse;
Common::DisposablePtr<SeekableAudioStream> _parent;
const Timestamp _start;
const Timestamp _length;

View file

@ -8,19 +8,16 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "audio/decoders/aac.h"
@ -28,74 +25,34 @@
#ifdef USE_FAAD
#include "common/debug.h"
#include "common/memstream.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/audiostream.h"
#include "audio/decoders/codec.h"
#include "audio/decoders/raw.h"
#include <neaacdec.h>
namespace Audio {
class AACStream : public AudioStream {
class AACDecoder : public Codec {
public:
AACStream(Common::SeekableReadStream *stream,
DisposeAfterUse::Flag disposeStream,
Common::SeekableReadStream *extraData,
AACDecoder(Common::SeekableReadStream *extraData,
DisposeAfterUse::Flag disposeExtraData);
~AACStream();
~AACDecoder();
int readBuffer(int16 *buffer, const int numSamples);
bool endOfData() const { return _inBufferPos >= _inBufferSize && !_remainingSamples; }
bool isStereo() const { return _channels == 2; }
int getRate() const { return _rate; }
AudioStream *decodeFrame(Common::SeekableReadStream &stream);
private:
NeAACDecHandle _handle;
byte _channels;
unsigned long _rate;
byte *_inBuffer;
uint32 _inBufferSize;
uint32 _inBufferPos;
int16 *_remainingSamples;
uint32 _remainingSamplesSize;
uint32 _remainingSamplesPos;
void init(Common::SeekableReadStream *extraData);
};
AACStream::AACStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeStream,
Common::SeekableReadStream *extraData, DisposeAfterUse::Flag disposeExtraData) {
_remainingSamples = 0;
_inBufferPos = 0;
init(extraData);
// Copy all the data to a pointer so it can be passed through
// (At least MPEG-4 chunks shouldn't be large)
_inBufferSize = stream->size();
_inBuffer = new byte[_inBufferSize];
stream->read(_inBuffer, _inBufferSize);
if (disposeStream == DisposeAfterUse::YES)
delete stream;
if (disposeExtraData == DisposeAfterUse::YES)
delete extraData;
}
AACStream::~AACStream() {
NeAACDecClose(_handle);
delete[] _inBuffer;
delete[] _remainingSamples;
}
void AACStream::init(Common::SeekableReadStream *extraData) {
AACDecoder::AACDecoder(Common::SeekableReadStream *extraData, DisposeAfterUse::Flag disposeExtraData) {
// Open the library
_handle = NeAACDecOpen();
@ -117,59 +74,55 @@ void AACStream::init(Common::SeekableReadStream *extraData) {
if (err < 0)
error("Could not initialize AAC decoder: %s", NeAACDecGetErrorMessage(err));
if (disposeExtraData == DisposeAfterUse::YES)
delete extraData;
}
int AACStream::readBuffer(int16 *buffer, const int numSamples) {
int samples = 0;
AACDecoder::~AACDecoder() {
NeAACDecClose(_handle);
}
assert((numSamples % _channels) == 0);
AudioStream *AACDecoder::decodeFrame(Common::SeekableReadStream &stream) {
// read everything into a buffer
uint32 inBufferPos = 0;
uint32 inBufferSize = stream.size();
byte *inBuffer = new byte[inBufferSize];
stream.read(inBuffer, inBufferSize);
// Dip into our remaining samples pool if it's available
if (_remainingSamples) {
samples = MIN<int>(numSamples, _remainingSamplesSize - _remainingSamplesPos);
memcpy(buffer, _remainingSamples + _remainingSamplesPos, samples * 2);
_remainingSamplesPos += samples;
if (_remainingSamplesPos == _remainingSamplesSize) {
delete[] _remainingSamples;
_remainingSamples = 0;
}
}
QueuingAudioStream *audioStream = makeQueuingAudioStream(_rate, _channels == 2);
// Decode until we have enough samples (or there's no more left)
while (samples < numSamples && !endOfData()) {
while (inBufferPos < inBufferSize) {
NeAACDecFrameInfo frameInfo;
uint16 *decodedSamples = (uint16 *)NeAACDecDecode(_handle, &frameInfo, _inBuffer + _inBufferPos, _inBufferSize - _inBufferPos);
void *decodedSamples = NeAACDecDecode(_handle, &frameInfo, inBuffer + inBufferPos, inBufferSize - inBufferPos);
if (frameInfo.error != 0)
error("Failed to decode AAC frame: %s", NeAACDecGetErrorMessage(frameInfo.error));
int decodedSampleSize = frameInfo.samples;
int copySamples = (decodedSampleSize > (numSamples - samples)) ? (numSamples - samples) : decodedSampleSize;
byte *buffer = (byte *)malloc(frameInfo.samples * 2);
memcpy(buffer, decodedSamples, frameInfo.samples * 2);
memcpy(buffer + samples, decodedSamples, copySamples * 2);
samples += copySamples;
byte flags = FLAG_16BITS;
// Copy leftover samples for use in a later readBuffer() call
if (copySamples != decodedSampleSize) {
_remainingSamplesSize = decodedSampleSize - copySamples;
_remainingSamples = new int16[_remainingSamplesSize];
_remainingSamplesPos = 0;
memcpy(_remainingSamples, decodedSamples + copySamples, _remainingSamplesSize * 2);
}
if (_channels == 2)
flags |= FLAG_STEREO;
_inBufferPos += frameInfo.bytesconsumed;
#ifdef SCUMM_LITTLE_ENDIAN
flags |= FLAG_LITTLE_ENDIAN;
#endif
audioStream->queueBuffer(buffer, frameInfo.samples * 2, DisposeAfterUse::YES, flags);
inBufferPos += frameInfo.bytesconsumed;
}
return samples;
return audioStream;
}
// Factory function
AudioStream *makeAACStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeStream,
Common::SeekableReadStream *extraData, DisposeAfterUse::Flag disposeExtraData) {
return new AACStream(stream, disposeStream, extraData, disposeExtraData);
Codec *makeAACDecoder(Common::SeekableReadStream *extraData, DisposeAfterUse::Flag disposeExtraData) {
return new AACDecoder(extraData, disposeExtraData);
}
} // End of namespace Audio

View file

@ -8,19 +8,16 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
/**
@ -43,23 +40,19 @@ namespace Common {
namespace Audio {
class AudioStream;
class Codec;
/**
* Create a new AudioStream from the AAC data of an MPEG-4 file in the given stream.
* Create a new Codec for decoding AAC data of an MPEG-4 file in the given stream.
*
* @note This should *only* be called by our QuickTime/MPEG-4 decoder since it relies
* on the MPEG-4 extra data. If you want to decode a file using AAC, go use
* makeQuickTimeStream() instead!
* @param stream the SeekableReadStream from which to read the AAC data
* @param disposeStream whether to delete the stream after use
* @param extraData the SeekableReadStream from which to read the AAC extra data
* @param disposeExtraData whether to delete the extra data stream after use
* @return a new AudioStream, or NULL, if an error occurred
* @return a new Codec, or NULL, if an error occurred
*/
AudioStream *makeAACStream(
Common::SeekableReadStream *stream,
DisposeAfterUse::Flag disposeStream,
Codec *makeAACDecoder(
Common::SeekableReadStream *extraData,
DisposeAfterUse::Flag disposeExtraData = DisposeAfterUse::NO);

View file

@ -41,8 +41,7 @@ namespace Audio {
// <http://wiki.multimedia.cx/index.php?title=Microsoft_IMA_ADPCM>.
ADPCMStream::ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign)
: _stream(stream),
_disposeAfterUse(disposeAfterUse),
: _stream(stream, disposeAfterUse),
_startpos(stream->pos()),
_endpos(_startpos + size),
_channels(channels),
@ -52,11 +51,6 @@ ADPCMStream::ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Fl
reset();
}
ADPCMStream::~ADPCMStream() {
if (_disposeAfterUse == DisposeAfterUse::YES)
delete _stream;
}
void ADPCMStream::reset() {
memset(&_status, 0, sizeof(_status));
_blockPos[0] = _blockPos[1] = _blockAlign; // To make sure first header is read
@ -234,7 +228,7 @@ int MSIma_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) {
while (samples < numSamples && _samplesLeft[0] != 0) {
for (int i = 0; i < _channels; i++) {
buffer[samples] = _buffer[i][8 - _samplesLeft[i]];
buffer[samples + i] = _buffer[i][8 - _samplesLeft[i]];
_samplesLeft[i]--;
}

View file

@ -33,6 +33,7 @@
#include "audio/audiostream.h"
#include "common/endian.h"
#include "common/ptr.h"
#include "common/stream.h"
#include "common/textconsole.h"
@ -41,8 +42,7 @@ namespace Audio {
class ADPCMStream : public RewindableAudioStream {
protected:
Common::SeekableReadStream *_stream;
const DisposeAfterUse::Flag _disposeAfterUse;
Common::DisposablePtr<Common::SeekableReadStream> _stream;
const int32 _startpos;
const int32 _endpos;
const int _channels;
@ -62,7 +62,6 @@ protected:
public:
ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign);
~ADPCMStream();
virtual bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
virtual bool isStereo() const { return _channels == 2; }

View file

@ -8,44 +8,37 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef AUDIO_DECODERS_CODEC_H
#define AUDIO_DECODERS_CODEC_H
namespace Common {
class SeekableReadStream;
}
#ifndef AGI_PREAGI_COMMON_H
#define AGI_PREAGI_COMMON_H
namespace Audio {
namespace Agi {
class AudioStream;
// default attributes
#define IDA_DEFAULT 0x0F
#define IDA_DEFAULT_REV 0xF0
class Codec {
public:
Codec() {}
virtual ~Codec() {}
#define IDI_SND_OSCILLATOR_FREQUENCY 1193180
#define IDI_SND_TIMER_RESOLUTION 0.0182
#define kColorDefault 0x1337
#define IDI_MAX_ROW_PIC 20
enum SelectionTypes {
kSelYesNo,
kSelNumber,
kSelSpace,
kSelAnyKey,
kSelBackspace
virtual AudioStream *decodeFrame(Common::SeekableReadStream &data) = 0;
};
} // End of namespace Agi
} // End of namespace Audio
#endif

View file

@ -25,6 +25,7 @@
#ifdef USE_MAD
#include "common/debug.h"
#include "common/ptr.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
@ -52,8 +53,7 @@ protected:
MP3_STATE_EOS // end of data reached (may need to loop)
};
Common::SeekableReadStream *_inStream;
DisposeAfterUse::Flag _disposeAfterUse;
Common::DisposablePtr<Common::SeekableReadStream> _inStream;
uint _posInFrame;
State _state;
@ -95,8 +95,7 @@ protected:
};
MP3Stream::MP3Stream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
_inStream(inStream),
_disposeAfterUse(dispose),
_inStream(inStream, dispose),
_posInFrame(0),
_state(MP3_STATE_INIT),
_length(0, 1000),
@ -134,9 +133,6 @@ MP3Stream::MP3Stream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag
MP3Stream::~MP3Stream() {
deinitStream();
if (_disposeAfterUse == DisposeAfterUse::YES)
delete _inStream;
}
void MP3Stream::decodeMP3Data() {

View file

@ -28,10 +28,13 @@
#ifdef AUDIO_QDM2_H
#include "audio/audiostream.h"
#include "audio/decoders/codec.h"
#include "audio/decoders/qdm2data.h"
#include "audio/decoders/raw.h"
#include "common/array.h"
#include "common/debug.h"
#include "common/math.h"
#include "common/stream.h"
#include "common/textconsole.h"
@ -150,19 +153,14 @@ struct RDFTContext {
FFTContext fft;
};
class QDM2Stream : public AudioStream {
class QDM2Stream : public Codec {
public:
QDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadStream *extraData);
QDM2Stream(Common::SeekableReadStream *extraData, DisposeAfterUse::Flag disposeExtraData);
~QDM2Stream();
bool isStereo() const { return _channels == 2; }
bool endOfData() const { return _stream->pos() >= _stream->size() && _outputSamples.size() == 0 && _subPacket == 0; }
int getRate() const { return _sampleRate; }
int readBuffer(int16 *buffer, const int numSamples);
AudioStream *decodeFrame(Common::SeekableReadStream &stream);
private:
Common::SeekableReadStream *_stream;
// Parameters from codec header, do not change during playback
uint8 _channels;
uint16 _sampleRate;
@ -204,7 +202,6 @@ private:
// I/O data
uint8 *_compressedData;
float _outputBuffer[1024];
Common::Array<int16> _outputSamples;
// Synthesis filter
int16 ff_mpa_synth_window[512];
@ -285,7 +282,7 @@ private:
void qdm2_fft_tone_synthesizer(uint8 sub_packet);
void qdm2_calculate_fft(int channel);
void qdm2_synthesis_filter(uint8 index);
int qdm2_decodeFrame(Common::SeekableReadStream *in);
bool qdm2_decodeFrame(Common::SeekableReadStream &in, QueuingAudioStream *audioStream);
};
// Fix compilation for non C99-compliant compilers, like MSVC
@ -293,21 +290,6 @@ private:
typedef signed long long int int64_t;
#endif
// Integer log2 function. This is much faster than invoking
// double precision C99 log2 math functions or equivalent, since
// this is only used to determine maximum number of bits needed
// i.e. only non-fractional part is needed. Also, the double
// version is incorrect for exact cases due to floating point
// rounding errors.
static inline int scummvm_log2(int n) {
int ret = -1;
while(n != 0) {
n /= 2;
ret++;
}
return ret;
}
#define QDM2_LIST_ADD(list, size, packet) \
do { \
if (size > 0) \
@ -1711,7 +1693,7 @@ void QDM2Stream::initVlc(void) {
}
}
QDM2Stream::QDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadStream *extraData) {
QDM2Stream::QDM2Stream(Common::SeekableReadStream *extraData, DisposeAfterUse::Flag disposeExtraData) {
uint32 tmp;
int32 tmp_s;
int tmp_val;
@ -1719,7 +1701,6 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadS
debug(1, "QDM2Stream::QDM2Stream() Call");
_stream = stream;
_compressedData = NULL;
_subPacket = 0;
_superBlockStart = 0;
@ -1841,11 +1822,11 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadS
warning("QDM2Stream::QDM2Stream() u4 field not 0");
}
_fftOrder = scummvm_log2(_frameSize) + 1;
_fftOrder = Common::intLog2(_frameSize) + 1;
_fftFrameSize = 2 * _frameSize; // complex has two floats
// something like max decodable tones
_groupOrder = scummvm_log2(_blockSize) + 1;
_groupOrder = Common::intLog2(_blockSize) + 1;
_sFrameSize = _blockSize / 16; // 16 iterations per super block
_subSampling = _fftOrder - 7;
@ -1906,11 +1887,13 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadS
initNoiseSamples();
_compressedData = new uint8[_packetSize];
if (disposeExtraData == DisposeAfterUse::YES)
delete extraData;
}
QDM2Stream::~QDM2Stream() {
delete[] _compressedData;
delete _stream;
}
static int qdm2_get_vlc(GetBitContext *gb, VLC *vlc, int flag, int depth) {
@ -3158,30 +3141,30 @@ void QDM2Stream::qdm2_synthesis_filter(uint8 index)
_outputBuffer[_channels * i + ch] += (float)(samples[_channels * sub_sampling * i + ch] >> (sizeof(int16)*8-16));
}
int QDM2Stream::qdm2_decodeFrame(Common::SeekableReadStream *in) {
debug(1, "QDM2Stream::qdm2_decodeFrame in->pos(): %d in->size(): %d", in->pos(), in->size());
bool QDM2Stream::qdm2_decodeFrame(Common::SeekableReadStream &in, QueuingAudioStream *audioStream) {
debug(1, "QDM2Stream::qdm2_decodeFrame in.pos(): %d in.size(): %d", in.pos(), in.size());
int ch, i;
const int frame_size = (_sFrameSize * _channels);
// If we're in any packet but the first, seek back to the first
if (_subPacket == 0)
_superBlockStart = in->pos();
_superBlockStart = in.pos();
else
in->seek(_superBlockStart);
in.seek(_superBlockStart);
// select input buffer
if (in->eos() || in->pos() >= in->size()) {
if (in.eos() || in.pos() >= in.size()) {
debug(1, "QDM2Stream::qdm2_decodeFrame End of Input Stream");
return 0;
return false;
}
if ((in->size() - in->pos()) < _packetSize) {
debug(1, "QDM2Stream::qdm2_decodeFrame Insufficient Packet Data in Input Stream Found: %d Need: %d", in->size() - in->pos(), _packetSize);
return 0;
if ((in.size() - in.pos()) < _packetSize) {
debug(1, "QDM2Stream::qdm2_decodeFrame Insufficient Packet Data in Input Stream Found: %d Need: %d", in.size() - in.pos(), _packetSize);
return false;
}
if (!in->eos()) {
in->read(_compressedData, _packetSize);
if (!in.eos()) {
in.read(_compressedData, _packetSize);
debug(1, "QDM2Stream::qdm2_decodeFrame constructed input data");
}
@ -3190,7 +3173,7 @@ int QDM2Stream::qdm2_decodeFrame(Common::SeekableReadStream *in) {
memset(&_outputBuffer[frame_size], 0, frame_size * sizeof(float));
debug(1, "QDM2Stream::qdm2_decodeFrame cleared outputBuffer");
if (!in->eos()) {
if (!in.eos()) {
// decode block of QDM2 compressed data
debug(1, "QDM2Stream::qdm2_decodeFrame decode block of QDM2 compressed data");
if (_subPacket == 0) {
@ -3218,7 +3201,7 @@ int QDM2Stream::qdm2_decodeFrame(Common::SeekableReadStream *in) {
if (!_hasErrors && _subPacketListC[0].packet != NULL) {
error("QDM2 : has errors, and C list is not empty");
return 0;
return false;
}
}
@ -3236,6 +3219,12 @@ int QDM2Stream::qdm2_decodeFrame(Common::SeekableReadStream *in) {
debug(1, "QDM2Stream::qdm2_decodeFrame clip and convert output float[] to 16bit signed samples");
}
if (frame_size == 0)
return false;
// Prepare a buffer for queuing
uint16 *outputBuffer = (uint16 *)malloc(frame_size * 2);
for (i = 0; i < frame_size; i++) {
int value = (int)_outputBuffer[i];
@ -3244,34 +3233,35 @@ int QDM2Stream::qdm2_decodeFrame(Common::SeekableReadStream *in) {
else if (value < -SOFTCLIP_THRESHOLD)
value = (value < -HARDCLIP_THRESHOLD) ? -32767 : -_softclipTable[-value - SOFTCLIP_THRESHOLD];
_outputSamples.push_back(value);
}
return frame_size;
}
int QDM2Stream::readBuffer(int16 *buffer, const int numSamples) {
debug(1, "QDM2Stream::readBuffer numSamples: %d", numSamples);
int32 decodedSamples = _outputSamples.size();
int32 i;
while (decodedSamples < numSamples) {
i = qdm2_decodeFrame(_stream);
if (i == 0)
break; // Out Of Decode Frames...
decodedSamples += i;
outputBuffer[i] = value;
}
if (decodedSamples > numSamples)
decodedSamples = numSamples;
// Queue the translated buffer to our stream
byte flags = FLAG_16BITS;
for (i = 0; i < decodedSamples; i++)
buffer[i] = _outputSamples.remove_at(0);
if (_channels == 2)
flags |= FLAG_STEREO;
return decodedSamples;
#ifdef SCUMM_LITTLE_ENDIAN
flags |= FLAG_LITTLE_ENDIAN;
#endif
audioStream->queueBuffer((byte *)outputBuffer, frame_size * 2, DisposeAfterUse::YES, flags);
return true;
}
AudioStream *makeQDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadStream *extraData) {
return new QDM2Stream(stream, extraData);
AudioStream *QDM2Stream::decodeFrame(Common::SeekableReadStream &stream) {
QueuingAudioStream *audioStream = makeQueuingAudioStream(_sampleRate, _channels == 2);
while (qdm2_decodeFrame(stream, audioStream))
;
return audioStream;
}
Codec *makeQDM2Decoder(Common::SeekableReadStream *extraData, DisposeAfterUse::Flag disposeExtraData) {
return new QDM2Stream(extraData, disposeExtraData);
}
} // End of namespace Audio

View file

@ -26,22 +26,25 @@
#ifndef AUDIO_QDM2_H
#define AUDIO_QDM2_H
#include "common/types.h"
namespace Common {
class SeekableReadStream;
}
namespace Audio {
class AudioStream;
class Codec;
/**
* Create a new AudioStream from the QDM2 data in the given stream.
* Create a new Codec from the QDM2 data in the given stream.
*
* @param stream the SeekableReadStream from which to read the FLAC data
* @param extraData the QuickTime extra data stream
* @return a new AudioStream, or NULL, if an error occurred
* @param extraData the QuickTime extra data stream
* @param disposeExtraData the QuickTime extra data stream
* @return a new Codec, or NULL, if an error occurred
*/
AudioStream *makeQDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadStream *extraData);
Codec *makeQDM2Decoder(Common::SeekableReadStream *extraData,
DisposeAfterUse::Flag disposeExtraData = DisposeAfterUse::NO);
} // End of namespace Audio

View file

@ -8,19 +8,16 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "common/debug.h"
@ -30,6 +27,7 @@
#include "common/textconsole.h"
#include "audio/audiostream.h"
#include "audio/decoders/codec.h"
#include "audio/decoders/quicktime.h"
#include "audio/decoders/quicktime_intern.h"
@ -86,6 +84,9 @@ void QuickTimeAudioDecoder::init() {
// Make sure the bits per sample transfers to the sample size
if (entry->getCodecTag() == MKTAG('r', 'a', 'w', ' ') || entry->getCodecTag() == MKTAG('t', 'w', 'o', 's'))
_tracks[_audioTrackIndex]->sampleSize = (entry->_bitsPerSample / 8) * entry->_channels;
// Initialize the codec (if necessary)
entry->initCodec();
}
}
}
@ -217,6 +218,9 @@ void QuickTimeAudioDecoder::setAudioStreamPos(const Timestamp &where) {
Audio::QuickTimeAudioDecoder::AudioSampleDesc *entry = (Audio::QuickTimeAudioDecoder::AudioSampleDesc *)_tracks[_audioTrackIndex]->sampleDescs[0];
_audStream = Audio::makeQueuingAudioStream(entry->_sampleRate, entry->_channels == 2);
// Reinitialize the codec
entry->initCodec();
// First, we need to track down what audio sample we need
Audio::Timestamp curAudioTime = where.convertToFramerate(_tracks[_audioTrackIndex]->timeScale);
uint32 sample = curAudioTime.totalNumberOfFrames();
@ -266,6 +270,11 @@ QuickTimeAudioDecoder::AudioSampleDesc::AudioSampleDesc(Common::QuickTimeParser:
_samplesPerFrame = 0;
_bytesPerFrame = 0;
_bitsPerSample = 0;
_codec = 0;
}
QuickTimeAudioDecoder::AudioSampleDesc::~AudioSampleDesc() {
delete _codec;
}
bool QuickTimeAudioDecoder::AudioSampleDesc::isAudioCodecSupported() const {
@ -313,7 +322,12 @@ AudioStream *QuickTimeAudioDecoder::AudioSampleDesc::createAudioStream(Common::S
if (!stream)
return 0;
if (_codecTag == MKTAG('t', 'w', 'o', 's') || _codecTag == MKTAG('r', 'a', 'w', ' ')) {
if (_codec) {
// If we've loaded a codec, make sure we use first
AudioStream *audioStream = _codec->decodeFrame(*stream);
delete stream;
return audioStream;
} else if (_codecTag == MKTAG('t', 'w', 'o', 's') || _codecTag == MKTAG('r', 'a', 'w', ' ')) {
// Fortunately, most of the audio used in Myst videos is raw...
uint16 flags = 0;
if (_codecTag == MKTAG('r', 'a', 'w', ' '))
@ -330,24 +344,32 @@ AudioStream *QuickTimeAudioDecoder::AudioSampleDesc::createAudioStream(Common::S
} else if (_codecTag == MKTAG('i', 'm', 'a', '4')) {
// Riven uses this codec (as do some Myst ME videos)
return makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), kADPCMApple, _sampleRate, _channels, 34);
} else if (_codecTag == MKTAG('m', 'p', '4', 'a')) {
// The 7th Guest iOS uses an MPEG-4 codec
#ifdef USE_FAAD
if (_parentTrack->objectTypeMP4 == 0x40)
return makeAACStream(stream, DisposeAfterUse::YES, _parentTrack->extraData);
#endif
#ifdef AUDIO_QDM2_H
} else if (_codecTag == MKTAG('Q', 'D', 'M', '2')) {
// Myst ME uses this codec for many videos
return makeQDM2Stream(stream, _parentTrack->extraData);
#endif
}
error("Unsupported audio codec");
return NULL;
}
void QuickTimeAudioDecoder::AudioSampleDesc::initCodec() {
delete _codec; _codec = 0;
switch (_codecTag) {
case MKTAG('Q', 'D', 'M', '2'):
#ifdef AUDIO_QDM2_H
_codec = makeQDM2Decoder(_parentTrack->extraData);
#endif
break;
case MKTAG('m', 'p', '4', 'a'):
#ifdef USE_FAAD
if (_parentTrack->objectTypeMP4 == 0x40)
_codec = makeAACDecoder(_parentTrack->extraData);
#endif
break;
default:
break;
}
}
/**
* A wrapper around QuickTimeAudioDecoder that implements the RewindableAudioStream API
*/

View file

@ -8,19 +8,16 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
/**

View file

@ -8,19 +8,16 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
/**
@ -45,6 +42,7 @@ namespace Common {
namespace Audio {
class AudioStream;
class Codec;
class QueuingAudioStream;
class QuickTimeAudioDecoder : public Common::QuickTimeParser {
@ -68,10 +66,12 @@ protected:
class AudioSampleDesc : public Common::QuickTimeParser::SampleDesc {
public:
AudioSampleDesc(Common::QuickTimeParser::Track *parentTrack, uint32 codecTag);
~AudioSampleDesc();
bool isAudioCodecSupported() const;
uint32 getAudioChunkSampleCount(uint chunk) const;
AudioStream *createAudioStream(Common::SeekableReadStream *stream) const;
void initCodec();
// TODO: Make private in the long run
uint16 _bitsPerSample;
@ -79,6 +79,8 @@ protected:
uint32 _sampleRate;
uint32 _samplesPerFrame;
uint32 _bytesPerFrame;
Codec *_codec;
};
// Common::QuickTimeParser API

View file

@ -51,7 +51,7 @@ template<bool is16Bit, bool isUnsigned, bool isLE>
class RawStream : public SeekableAudioStream {
public:
RawStream(int rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream, const RawStreamBlockList &blocks)
: _rate(rate), _isStereo(stereo), _playtime(0, rate), _stream(stream), _disposeAfterUse(disposeStream), _blocks(blocks), _curBlock(_blocks.begin()), _blockLeft(0), _buffer(0) {
: _rate(rate), _isStereo(stereo), _playtime(0, rate), _stream(stream, disposeStream), _blocks(blocks), _curBlock(_blocks.begin()), _blockLeft(0), _buffer(0) {
assert(_blocks.size() > 0);
@ -82,9 +82,6 @@ public:
}
~RawStream() {
if (_disposeAfterUse == DisposeAfterUse::YES)
delete _stream;
delete[] _buffer;
}
@ -98,15 +95,14 @@ public:
bool seek(const Timestamp &where);
private:
const int _rate; ///< Sample rate of stream
const bool _isStereo; ///< Whether this is an stereo stream
Timestamp _playtime; ///< Calculated total play time
Common::SeekableReadStream *_stream; ///< Stream to read data from
const DisposeAfterUse::Flag _disposeAfterUse; ///< Indicates whether the stream object should be deleted when this RawStream is destructed
const RawStreamBlockList _blocks; ///< Audio block list
const int _rate; ///< Sample rate of stream
const bool _isStereo; ///< Whether this is an stereo stream
Timestamp _playtime; ///< Calculated total play time
Common::DisposablePtr<Common::SeekableReadStream> _stream; ///< Stream to read data from
const RawStreamBlockList _blocks; ///< Audio block list
RawStreamBlockList::const_iterator _curBlock; ///< Current audio block number
int32 _blockLeft; ///< How many bytes are still left in the current block
RawStreamBlockList::const_iterator _curBlock; ///< Current audio block number
int32 _blockLeft; ///< How many bytes are still left in the current block
/**
* Advance one block in the stream in case

View file

@ -29,6 +29,7 @@
#ifdef USE_VORBIS
#include "common/ptr.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
@ -42,6 +43,7 @@
#include <tremor/ivorbisfile.h>
#endif
#else
#define OV_EXCLUDE_STATIC_CALLBACKS
#include <vorbis/vorbisfile.h>
#endif
@ -88,8 +90,7 @@ static ov_callbacks g_stream_wrap = {
class VorbisStream : public SeekableAudioStream {
protected:
Common::SeekableReadStream *_inStream;
DisposeAfterUse::Flag _disposeAfterUse;
Common::DisposablePtr<Common::SeekableReadStream> _inStream;
bool _isStereo;
int _rate;
@ -120,10 +121,9 @@ protected:
};
VorbisStream::VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
_inStream(inStream),
_disposeAfterUse(dispose),
_inStream(inStream, dispose),
_length(0, 1000),
_bufferEnd(_buffer + ARRAYSIZE(_buffer)) {
_bufferEnd(ARRAYEND(_buffer)) {
int res = ov_open_callbacks(inStream, &_ovFile, NULL, 0, g_stream_wrap);
if (res < 0) {
@ -149,8 +149,6 @@ VorbisStream::VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse
VorbisStream::~VorbisStream() {
ov_clear(&_ovFile);
if (_disposeAfterUse == DisposeAfterUse::YES)
delete _inStream;
}
int VorbisStream::readBuffer(int16 *buffer, const int numSamples) {

View file

@ -192,4 +192,3 @@ FM_OPL *makeAdLibOPL(int rate) {
return opl;
}

View file

@ -176,4 +176,3 @@ void YM3812UpdateOne(FM_OPL *OPL, int16 *buffer, int length);
FM_OPL *makeAdLibOPL(int rate);
#endif

View file

@ -202,7 +202,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// If the expressly selected driver or device cannot be found (no longer compiled in, turned off, etc.)
// we display a warning and continue.
failedDevStr = selDevStr;
Common::String warningMsg = Common::String::format(_("The selected audio device '%s' was not found (e.g. might be turned off or disconnected). Attempting to fall back to the next available device..."), failedDevStr.c_str());
Common::String warningMsg = Common::String::format(_("The selected audio device '%s' was not found (e.g. might be turned off or disconnected)."), failedDevStr.c_str()) + " " + _("Attempting to fall back to the next available device...");
GUI::MessageDialog dialog(warningMsg);
dialog.runModal();
}
@ -214,7 +214,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
} else {
// If the expressly selected device cannot be used we display a warning and continue.
failedDevStr = getDeviceString(hdl, MidiDriver::kDeviceName);
Common::String warningMsg = Common::String::format(_("The selected audio device '%s' cannot be used. See log file for more information. Attempting to fall back to the next available device..."), failedDevStr.c_str());
Common::String warningMsg = Common::String::format(_("The selected audio device '%s' cannot be used. See log file for more information."), failedDevStr.c_str()) + " " + _("Attempting to fall back to the next available device...");
GUI::MessageDialog dialog(warningMsg);
dialog.runModal();
}
@ -250,7 +250,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// we display a warning and continue. Don't warn about the missing device if we did already (this becomes relevant if the
// missing device is selected as preferred device and also as GM or MT-32 device).
if (failedDevStr != devStr) {
Common::String warningMsg = Common::String::format(_("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected). Attempting to fall back to the next available device..."), devStr.c_str());
Common::String warningMsg = Common::String::format(_("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected)."), devStr.c_str()) + " " + _("Attempting to fall back to the next available device...");
GUI::MessageDialog dialog(warningMsg);
dialog.runModal();
}
@ -265,7 +265,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// Don't warn about the failing device if we did already (this becomes relevant if the failing
// device is selected as preferred device and also as GM or MT-32 device).
if (failedDevStr != getDeviceString(hdl, MidiDriver::kDeviceName)) {
Common::String warningMsg = Common::String::format(_("The preferred audio device '%s' cannot be used. See log file for more information. Attempting to fall back to the next available device..."), getDeviceString(hdl, MidiDriver::kDeviceName).c_str());
Common::String warningMsg = Common::String::format(_("The preferred audio device '%s' cannot be used. See log file for more information."), getDeviceString(hdl, MidiDriver::kDeviceName).c_str()) + " " + _("Attempting to fall back to the next available device...");
GUI::MessageDialog dialog(warningMsg);
dialog.runModal();
}
@ -412,4 +412,3 @@ void MidiDriver::sendGMReset() {
sysEx(resetSysEx, sizeof(resetSysEx));
g_system->delayMillis(100);
}

View file

@ -163,9 +163,8 @@ private:
uint32 _pauseStartTime;
uint32 _pauseTime;
DisposeAfterUse::Flag _autofreeStream;
RateConverter *_converter;
AudioStream *_stream;
Common::DisposablePtr<AudioStream> _stream;
};
#pragma mark -
@ -492,8 +491,8 @@ Channel::Channel(Mixer *mixer, Mixer::SoundType type, AudioStream *stream,
DisposeAfterUse::Flag autofreeStream, bool reverseStereo, int id, bool permanent)
: _type(type), _mixer(mixer), _id(id), _permanent(permanent), _volume(Mixer::kMaxChannelVolume),
_balance(0), _pauseLevel(0), _samplesConsumed(0), _samplesDecoded(0), _mixerTimeStamp(0),
_pauseStartTime(0), _pauseTime(0), _autofreeStream(autofreeStream), _converter(0),
_stream(stream) {
_pauseStartTime(0), _pauseTime(0), _converter(0),
_stream(stream, autofreeStream) {
assert(mixer);
assert(stream);
@ -503,8 +502,6 @@ Channel::Channel(Mixer *mixer, Mixer::SoundType type, AudioStream *stream,
Channel::~Channel() {
delete _converter;
if (_autofreeStream == DisposeAfterUse::YES)
delete _stream;
}
void Channel::setVolume(const byte volume) {

View file

@ -707,8 +707,8 @@ int8 MaxTrax::noteOn(ChannelContext &channel, const byte note, uint16 volume, ui
if ((channel.flags & ChannelContext::kFlagMono) == 0) {
voiceNum = pickvoice((channel.flags & ChannelContext::kFlagRightChannel) != 0 ? 1 : 0, pri);
} else {
VoiceContext *voice = _voiceCtx + ARRAYSIZE(_voiceCtx) - 1;
for (voiceNum = ARRAYSIZE(_voiceCtx) - 1; voiceNum >= 0 && voice->channel != &channel; --voiceNum, --voice)
VoiceContext *voice = ARRAYEND(_voiceCtx);
for (voiceNum = ARRAYSIZE(_voiceCtx); voiceNum-- != 0 && --voice->channel != &channel;)
;
if (voiceNum < 0)
voiceNum = pickvoice((channel.flags & ChannelContext::kFlagRightChannel) != 0 ? 1 : 0, pri);

View file

@ -146,6 +146,6 @@ void MidiDriver_MPU401::setTimerCallback(void *timer_param, Common::TimerManager
g_system->getTimerManager()->removeTimerProc(_timer_proc);
_timer_proc = timer_proc;
if (timer_proc)
g_system->getTimerManager()->installTimerProc(timer_proc, 10000, timer_param);
g_system->getTimerManager()->installTimerProc(timer_proc, 10000, timer_param, "MPU401");
}
}

View file

@ -467,4 +467,3 @@ RateConverter *makeRateConverter(st_rate_t inrate, st_rate_t outrate, bool stere
}
} // End of namespace Audio

View file

@ -51,4 +51,3 @@ MusicDevices AppleIIGSMusicPlugin::getDevices() const {
//#else
REGISTER_PLUGIN_STATIC(APPLEIIGS, PLUGIN_TYPE_MUSIC, AppleIIGSMusicPlugin);
//#endif

View file

@ -163,19 +163,15 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) {
struct SAA1099 *saa = &_saa1099[chip];
int j, ch;
/* if the channels are disabled we're done */
if (!saa->all_ch_enable) {
/* init output data */
if (chip == 0) {
memset(buffer, 0, sizeof(int16)*length*2);
}
return;
}
if (chip == 0) {
memset(buffer, 0, sizeof(int16)*length*2);
}
/* if the channels are disabled we're done */
if (!saa->all_ch_enable) {
return;
}
for (ch = 0; ch < 2; ch++) {
switch (saa->noise_params[ch]) {
case 0: saa->noise[ch].freq = 31250.0 * 2; break;
@ -244,8 +240,8 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) {
}
}
/* write sound data to the buffer */
buffer[j*2] += output_l / 6;
buffer[j*2+1] += output_r / 6;
buffer[j*2+0] = CLIP<int>(buffer[j*2+0] + output_l / 6, -32768, 32767);
buffer[j*2+1] = CLIP<int>(buffer[j*2+1] + output_r / 6, -32768, 32767);
}
}

View file

@ -480,4 +480,3 @@ Common::Error EASMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver
//#endif
#endif

View file

@ -26,8 +26,6 @@
#include "audio/mididrv.h"
#include "audio/mixer.h"
#define FIXP_SHIFT 16
class MidiDriver_Emulated : public Audio::AudioStream, public MidiDriver {
protected:
bool _isOpen;
@ -38,6 +36,10 @@ private:
Common::TimerManager::TimerProc _timerProc;
void *_timerParam;
enum {
FIXP_SHIFT = 16
};
int _nextTick;
int _samplesPerTick;

View file

@ -53,4 +53,3 @@ private:
};
#endif

View file

@ -181,4 +181,3 @@ private:
};
#endif

View file

@ -464,9 +464,10 @@ int TownsMidiOutputChannel::advanceEffectEnvelope(EffectEnvelope *s, EffectDef *
s->currentLevel = t;
s->modWheelLast = s->modWheelState;
t = getEffectModLevel(t, s->modWheelState);
if (t != d->phase)
if (t != d->phase) {
d->phase = t;
retFlags |= 1;
retFlags |= 1;
}
}
if (--s->stepCounter)

View file

@ -81,4 +81,3 @@ private:
};
#endif

View file

@ -1449,4 +1449,3 @@ const uint8 TownsPC98_AudioDriver::_drvTables[] = {
};
#undef EUPHONY_FADEOUT_TICKS

View file

@ -115,4 +115,3 @@ private:
};
#endif

View file

@ -185,4 +185,3 @@ private:
};
#endif

View file

@ -486,7 +486,7 @@ void MidiDriver_ThreadedMT32::setTimerCallback(void *timer_param, TimerManager::
_vm->_timer->removeTimerProc(_timer_proc);
_timer_proc = timer_proc;
if (timer_proc)
_vm->_timer->installTimerProc(timer_proc, getBaseTempo(), timer_param);
_vm->_timer->installTimerProc(timer_proc, getBaseTempo(), timer_param, "MT32tempo");
}
}

View file

@ -67,4 +67,3 @@ bool File::writeBit32u(Bit32u out) {
}
} // End of namespace MT32Emu

View file

@ -104,4 +104,3 @@ public:
#endif // !DISABLE_DOSBOX_OPL
#endif

View file

@ -1245,4 +1245,3 @@ FM_OPL *makeAdLibOPL(int rate) {
} // End of namespace MAME
} // End of namespace OPL

View file

@ -8,19 +8,16 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "backends/base-backend.h"

View file

@ -50,7 +50,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == PAD_DOWN) {
@ -63,7 +63,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == PAD_LEFT) {
@ -76,7 +76,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == PAD_RIGHT) {
@ -89,7 +89,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == BUT_Y) { // left mouse button
@ -99,7 +99,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_LBUTTONUP;
}
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == BUT_B) { // right mouse button
@ -109,7 +109,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_RBUTTONUP;
}
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == BUT_X) { // '.' skip dialogue

View file

@ -165,7 +165,7 @@ GPHEventSource::GPHEventSource()
: _buttonStateL(false){
}
//void GPHEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
//void GPHEventSource::processMouseEvent(Common::Event &event, int x, int y) {
// if (GPHGraphicsManager::_videoMode.mode == GFX_HALF && !GPHGraphicsManager::_overlayVisible){
// event.mouse.x = x*2;
// event.mouse.y = y*2;
@ -260,7 +260,7 @@ bool GPHEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event)
else
return false;
fillMouseEvent(event, ev.button.x, ev.button.y);
processMouseEvent(event, ev.button.x, ev.button.y);
return true;
}
@ -287,7 +287,7 @@ bool GPHEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
else
return false;
fillMouseEvent(event, ev.button.x, ev.button.y);
processMouseEvent(event, ev.button.x, ev.button.y);
return true;
}
@ -310,16 +310,16 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
case BUTTON_UPRIGHT:
moveStick();
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BUTTON_B:
case BUTTON_CLICK:
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BUTTON_X:
event.type = Common::EVENT_RBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BUTTON_L:
BUTTON_STATE_L = true;
@ -433,16 +433,16 @@ bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
case BUTTON_UPRIGHT:
moveStick();
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BUTTON_B:
case BUTTON_CLICK:
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BUTTON_X:
event.type = Common::EVENT_RBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BUTTON_L:
BUTTON_STATE_L = false;

View file

@ -132,7 +132,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == SDLK_RIGHT) {
if (ev.type == SDL_KEYDOWN) {
@ -144,7 +144,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == SDLK_DOWN) {
@ -157,7 +157,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == SDLK_UP) {
@ -170,7 +170,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == SDLK_RETURN) {
@ -181,7 +181,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_LBUTTONUP;
}
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == SDLK_PLUS) {
@ -191,7 +191,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
} else {
event.type = Common::EVENT_RBUTTONUP;
}
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else if (ev.key.keysym.sym == SDLK_MINUS) {
@ -202,7 +202,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_LBUTTONUP;
}
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
} else {

View file

@ -81,7 +81,7 @@ bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
else
return false;
fillMouseEvent(event, ev.button.x, ev.button.y);
processMouseEvent(event, ev.button.x, ev.button.y);
return true;
}
@ -108,7 +108,7 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
else
return false;
fillMouseEvent(event, ev.button.x, ev.button.y);
processMouseEvent(event, ev.button.x, ev.button.y);
return true;
}
@ -123,12 +123,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
switch (ev.key.keysym.sym) {
case SDLK_HOME:
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
break;
case SDLK_END:
event.type = Common::EVENT_RBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
break;
case SDLK_PAGEDOWN:
@ -159,12 +159,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
switch (ev.key.keysym.sym) {
case SDLK_HOME:
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
break;
case SDLK_END:
event.type = Common::EVENT_RBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
break;
case SDLK_PAGEDOWN:

View file

@ -60,11 +60,11 @@ bool PS3SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event)
switch (ev.jbutton.button) {
case BTN_CROSS: // Left mouse button
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BTN_CIRCLE: // Right mouse button
event.type = Common::EVENT_RBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BTN_TRIANGLE: // Game menu
event.type = Common::EVENT_KEYDOWN;
@ -98,11 +98,11 @@ bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
switch (ev.jbutton.button) {
case BTN_CROSS: // Left mouse button
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BTN_CIRCLE: // Right mouse button
event.type = Common::EVENT_RBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
break;
case BTN_TRIANGLE: // Game menu
event.type = Common::EVENT_KEYUP;

View file

@ -50,7 +50,7 @@
#define JOY_BUT_F5 5
SdlEventSource::SdlEventSource()
: _scrollLock(false), _joystick(0), _lastScreenID(0), EventSource() {
: EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0) {
// Reset mouse state
memset(&_km, 0, sizeof(_km));
@ -91,10 +91,15 @@ int SdlEventSource::mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
return key;
}
void SdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
void SdlEventSource::processMouseEvent(Common::Event &event, int x, int y) {
event.mouse.x = x;
event.mouse.y = y;
if (_graphicsManager) {
_graphicsManager->notifyMousePos(Common::Point(x, y));
_graphicsManager->transformMouseCoordinates(event.mouse);
}
// Update the "keyboard mouse" coords
_km.x = x;
_km.y = y;
@ -194,6 +199,149 @@ void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
event.kbd.flags |= Common::KBD_CAPS;
}
Common::KeyCode SdlEventSource::SDLToOSystemKeycode(const SDLKey key) {
switch (key) {
case SDLK_BACKSPACE: return Common::KEYCODE_BACKSPACE;
case SDLK_TAB: return Common::KEYCODE_TAB;
case SDLK_CLEAR: return Common::KEYCODE_CLEAR;
case SDLK_RETURN: return Common::KEYCODE_RETURN;
case SDLK_PAUSE: return Common::KEYCODE_PAUSE;
case SDLK_ESCAPE: return Common::KEYCODE_ESCAPE;
case SDLK_SPACE: return Common::KEYCODE_SPACE;
case SDLK_EXCLAIM: return Common::KEYCODE_EXCLAIM;
case SDLK_QUOTEDBL: return Common::KEYCODE_QUOTEDBL;
case SDLK_HASH: return Common::KEYCODE_HASH;
case SDLK_DOLLAR: return Common::KEYCODE_DOLLAR;
case SDLK_AMPERSAND: return Common::KEYCODE_AMPERSAND;
case SDLK_QUOTE: return Common::KEYCODE_QUOTE;
case SDLK_LEFTPAREN: return Common::KEYCODE_LEFTPAREN;
case SDLK_RIGHTPAREN: return Common::KEYCODE_RIGHTPAREN;
case SDLK_ASTERISK: return Common::KEYCODE_ASTERISK;
case SDLK_PLUS: return Common::KEYCODE_PLUS;
case SDLK_COMMA: return Common::KEYCODE_COMMA;
case SDLK_MINUS: return Common::KEYCODE_MINUS;
case SDLK_PERIOD: return Common::KEYCODE_PERIOD;
case SDLK_SLASH: return Common::KEYCODE_SLASH;
case SDLK_0: return Common::KEYCODE_0;
case SDLK_1: return Common::KEYCODE_1;
case SDLK_2: return Common::KEYCODE_2;
case SDLK_3: return Common::KEYCODE_3;
case SDLK_4: return Common::KEYCODE_4;
case SDLK_5: return Common::KEYCODE_5;
case SDLK_6: return Common::KEYCODE_6;
case SDLK_7: return Common::KEYCODE_7;
case SDLK_8: return Common::KEYCODE_8;
case SDLK_9: return Common::KEYCODE_9;
case SDLK_COLON: return Common::KEYCODE_COLON;
case SDLK_SEMICOLON: return Common::KEYCODE_SEMICOLON;
case SDLK_LESS: return Common::KEYCODE_LESS;
case SDLK_EQUALS: return Common::KEYCODE_EQUALS;
case SDLK_GREATER: return Common::KEYCODE_GREATER;
case SDLK_QUESTION: return Common::KEYCODE_QUESTION;
case SDLK_AT: return Common::KEYCODE_AT;
case SDLK_LEFTBRACKET: return Common::KEYCODE_LEFTBRACKET;
case SDLK_BACKSLASH: return Common::KEYCODE_BACKSLASH;
case SDLK_RIGHTBRACKET: return Common::KEYCODE_RIGHTBRACKET;
case SDLK_CARET: return Common::KEYCODE_CARET;
case SDLK_UNDERSCORE: return Common::KEYCODE_UNDERSCORE;
case SDLK_BACKQUOTE: return Common::KEYCODE_BACKQUOTE;
case SDLK_a: return Common::KEYCODE_a;
case SDLK_b: return Common::KEYCODE_b;
case SDLK_c: return Common::KEYCODE_c;
case SDLK_d: return Common::KEYCODE_d;
case SDLK_e: return Common::KEYCODE_e;
case SDLK_f: return Common::KEYCODE_f;
case SDLK_g: return Common::KEYCODE_g;
case SDLK_h: return Common::KEYCODE_h;
case SDLK_i: return Common::KEYCODE_i;
case SDLK_j: return Common::KEYCODE_j;
case SDLK_k: return Common::KEYCODE_k;
case SDLK_l: return Common::KEYCODE_l;
case SDLK_m: return Common::KEYCODE_m;
case SDLK_n: return Common::KEYCODE_n;
case SDLK_o: return Common::KEYCODE_o;
case SDLK_p: return Common::KEYCODE_p;
case SDLK_q: return Common::KEYCODE_q;
case SDLK_r: return Common::KEYCODE_r;
case SDLK_s: return Common::KEYCODE_s;
case SDLK_t: return Common::KEYCODE_t;
case SDLK_u: return Common::KEYCODE_u;
case SDLK_v: return Common::KEYCODE_v;
case SDLK_w: return Common::KEYCODE_w;
case SDLK_x: return Common::KEYCODE_x;
case SDLK_y: return Common::KEYCODE_y;
case SDLK_z: return Common::KEYCODE_z;
case SDLK_DELETE: return Common::KEYCODE_DELETE;
#if SDL_VERSION_ATLEAST(1, 3, 0)
case SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_GRAVE): return Common::KEYCODE_TILDE;
#else
case SDLK_WORLD_16: return Common::KEYCODE_TILDE;
#endif
case SDLK_KP0: return Common::KEYCODE_KP0;
case SDLK_KP1: return Common::KEYCODE_KP1;
case SDLK_KP2: return Common::KEYCODE_KP2;
case SDLK_KP3: return Common::KEYCODE_KP3;
case SDLK_KP4: return Common::KEYCODE_KP4;
case SDLK_KP5: return Common::KEYCODE_KP5;
case SDLK_KP6: return Common::KEYCODE_KP6;
case SDLK_KP7: return Common::KEYCODE_KP7;
case SDLK_KP8: return Common::KEYCODE_KP8;
case SDLK_KP9: return Common::KEYCODE_KP9;
case SDLK_KP_PERIOD: return Common::KEYCODE_KP_PERIOD;
case SDLK_KP_DIVIDE: return Common::KEYCODE_KP_DIVIDE;
case SDLK_KP_MULTIPLY: return Common::KEYCODE_KP_MULTIPLY;
case SDLK_KP_MINUS: return Common::KEYCODE_KP_MINUS;
case SDLK_KP_PLUS: return Common::KEYCODE_KP_PLUS;
case SDLK_KP_ENTER: return Common::KEYCODE_KP_ENTER;
case SDLK_KP_EQUALS: return Common::KEYCODE_KP_EQUALS;
case SDLK_UP: return Common::KEYCODE_UP;
case SDLK_DOWN: return Common::KEYCODE_DOWN;
case SDLK_RIGHT: return Common::KEYCODE_RIGHT;
case SDLK_LEFT: return Common::KEYCODE_LEFT;
case SDLK_INSERT: return Common::KEYCODE_INSERT;
case SDLK_HOME: return Common::KEYCODE_HOME;
case SDLK_END: return Common::KEYCODE_END;
case SDLK_PAGEUP: return Common::KEYCODE_PAGEUP;
case SDLK_PAGEDOWN: return Common::KEYCODE_PAGEDOWN;
case SDLK_F1: return Common::KEYCODE_F1;
case SDLK_F2: return Common::KEYCODE_F2;
case SDLK_F3: return Common::KEYCODE_F3;
case SDLK_F4: return Common::KEYCODE_F4;
case SDLK_F5: return Common::KEYCODE_F5;
case SDLK_F6: return Common::KEYCODE_F6;
case SDLK_F7: return Common::KEYCODE_F7;
case SDLK_F8: return Common::KEYCODE_F8;
case SDLK_F9: return Common::KEYCODE_F9;
case SDLK_F10: return Common::KEYCODE_F10;
case SDLK_F11: return Common::KEYCODE_F11;
case SDLK_F12: return Common::KEYCODE_F12;
case SDLK_F13: return Common::KEYCODE_F13;
case SDLK_F14: return Common::KEYCODE_F14;
case SDLK_F15: return Common::KEYCODE_F15;
case SDLK_NUMLOCK: return Common::KEYCODE_NUMLOCK;
case SDLK_CAPSLOCK: return Common::KEYCODE_CAPSLOCK;
case SDLK_SCROLLOCK: return Common::KEYCODE_SCROLLOCK;
case SDLK_RSHIFT: return Common::KEYCODE_RSHIFT;
case SDLK_LSHIFT: return Common::KEYCODE_LSHIFT;
case SDLK_RCTRL: return Common::KEYCODE_RCTRL;
case SDLK_LCTRL: return Common::KEYCODE_LCTRL;
case SDLK_RALT: return Common::KEYCODE_RALT;
case SDLK_LALT: return Common::KEYCODE_LALT;
case SDLK_LSUPER: return Common::KEYCODE_LSUPER;
case SDLK_RSUPER: return Common::KEYCODE_RSUPER;
case SDLK_MODE: return Common::KEYCODE_MODE;
case SDLK_COMPOSE: return Common::KEYCODE_COMPOSE;
case SDLK_HELP: return Common::KEYCODE_HELP;
case SDLK_PRINT: return Common::KEYCODE_PRINT;
case SDLK_SYSREQ: return Common::KEYCODE_SYSREQ;
case SDLK_BREAK: return Common::KEYCODE_BREAK;
case SDLK_MENU: return Common::KEYCODE_MENU;
case SDLK_POWER: return Common::KEYCODE_POWER;
case SDLK_UNDO: return Common::KEYCODE_UNDO;
default: return Common::KEYCODE_INVALID;
}
}
bool SdlEventSource::pollEvent(Common::Event &event) {
handleKbdMouse();
@ -234,16 +382,14 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
return handleJoyAxisMotion(ev, event);
case SDL_VIDEOEXPOSE:
// HACK: Send a fake event, handled by SdlGraphicsManager
event.type = (Common::EventType)OSystem_SDL::kSdlEventExpose;
return true;
if (_graphicsManager)
_graphicsManager->notifyVideoExpose();
return false;
case SDL_VIDEORESIZE:
// HACK: Send a fake event, handled by OpenGLSdlGraphicsManager
event.type = (Common::EventType)OSystem_SDL::kSdlEventResize;
event.mouse.x = ev.resize.w;
event.mouse.y = ev.resize.h;
return true;
if (_graphicsManager)
_graphicsManager->notifyResize(ev.resize.w, ev.resize.h);
return false;
case SDL_QUIT:
event.type = Common::EVENT_QUIT;
@ -302,7 +448,7 @@ bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
return true;
event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
event.kbd.keycode = SDLToOSystemKeycode(ev.key.keysym.sym);
event.kbd.ascii = mapKey(ev.key.keysym.sym, (SDLMod)ev.key.keysym.mod, (Uint16)ev.key.keysym.unicode);
return true;
@ -346,7 +492,7 @@ bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
// continue normally
event.type = Common::EVENT_KEYUP;
event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
event.kbd.keycode = SDLToOSystemKeycode(ev.key.keysym.sym);
event.kbd.ascii = mapKey(ev.key.keysym.sym, (SDLMod)ev.key.keysym.mod, (Uint16)ev.key.keysym.unicode);
// Ctrl-Alt-<key> will change the GFX mode
@ -361,7 +507,7 @@ bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
processMouseEvent(event, ev.motion.x, ev.motion.y);
return true;
}
@ -384,7 +530,7 @@ bool SdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event)
else
return false;
fillMouseEvent(event, ev.button.x, ev.button.y);
processMouseEvent(event, ev.button.x, ev.button.y);
return true;
}
@ -400,7 +546,7 @@ bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
#endif
else
return false;
fillMouseEvent(event, ev.button.x, ev.button.y);
processMouseEvent(event, ev.button.x, ev.button.y);
return true;
}
@ -408,10 +554,10 @@ bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
event.type = Common::EVENT_RBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
} else {
event.type = Common::EVENT_KEYDOWN;
switch (ev.jbutton.button) {
@ -439,10 +585,10 @@ bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
event.type = Common::EVENT_RBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
} else {
event.type = Common::EVENT_KEYUP;
switch (ev.jbutton.button) {
@ -510,7 +656,7 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
#endif
}
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
}

View file

@ -24,6 +24,7 @@
#define BACKEND_EVENTS_SDL_H
#include "backends/platform/sdl/sdl-sys.h"
#include "backends/graphics/sdl/sdl-graphics.h"
#include "common/events.h"
@ -36,6 +37,8 @@ public:
SdlEventSource();
virtual ~SdlEventSource();
void setGraphicsManager(SdlGraphicsManager *gMan) { _graphicsManager = gMan; }
/**
* Gets and processes SDL events.
*/
@ -76,6 +79,11 @@ protected:
/** Last screen id for checking if it was modified */
int _lastScreenID;
/**
* The associated graphics manager.
*/
SdlGraphicsManager *_graphicsManager;
/**
* Pre process an event before it is dispatched.
*/
@ -108,9 +116,10 @@ protected:
//@}
/**
* Assigns the mouse coords to the mouse event
* Assigns the mouse coords to the mouse event. Furthermore notify the
* graphics manager about the position change.
*/
virtual void fillMouseEvent(Common::Event &event, int x, int y);
virtual void processMouseEvent(Common::Event &event, int x, int y);
/**
* Remaps key events. This allows platforms to configure
@ -127,6 +136,11 @@ protected:
* Configures the key modifiers flags status
*/
virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
/**
* Translates SDL key codes to OSystem key codes
*/
Common::KeyCode SDLToOSystemKeycode(const SDLKey key);
};
#endif

View file

@ -63,7 +63,7 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
_km.y_down_count = 0;
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
@ -76,7 +76,7 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
_km.y_down_count = 0;
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
@ -89,7 +89,7 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
_km.x_down_count = 0;
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
@ -102,19 +102,19 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
_km.x_down_count = 0;
}
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
case GUI::ACTION_LEFTCLICK:
event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP);
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
case GUI::ACTION_RIGHTCLICK:
event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP);
fillMouseEvent(event, _km.x, _km.y);
processMouseEvent(event, _km.x, _km.y);
return true;
@ -132,7 +132,7 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
if (_currentZone >= TOTAL_ZONES)
_currentZone = 0;
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, _mouseXZone[_currentZone], _mouseYZone[_currentZone]);
processMouseEvent(event, _mouseXZone[_currentZone], _mouseYZone[_currentZone]);
SDL_WarpMouse(event.mouse.x, event.mouse.y);
}
@ -195,4 +195,3 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
}
#endif

View file

@ -53,4 +53,3 @@ protected:
};
#endif

View file

@ -159,7 +159,7 @@ bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &ev
if (getMillis() - dragStartTime < 250) {
dragging = true;
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, curX, curY);
processMouseEvent(event, curX, curY);
}
}
return true;
@ -180,7 +180,7 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even
if (dragging)
{
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, curX, curY);
processMouseEvent(event, curX, curY);
dragging = false;
return true;
}
@ -195,7 +195,7 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even
// left mouse click.
if (duration < 500) {
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, curX, curY);
processMouseEvent(event, curX, curY);
g_system->getEventManager()->pushEvent(event);
event.type = Common::EVENT_LBUTTONDOWN;
dragStartTime = getMillis();
@ -205,7 +205,7 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even
// right mouse click.
else if (duration < 1000) {
event.type = Common::EVENT_RBUTTONUP;
fillMouseEvent(event, curX, curY);
processMouseEvent(event, curX, curY);
g_system->getEventManager()->pushEvent(event);
event.type = Common::EVENT_RBUTTONDOWN;
}
@ -214,7 +214,7 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even
// middle mouse click.
else {
event.type = Common::EVENT_MBUTTONUP;
fillMouseEvent(event, curX, curY);
processMouseEvent(event, curX, curY);
g_system->getEventManager()->pushEvent(event);
event.type = Common::EVENT_MBUTTONDOWN;
}
@ -240,7 +240,7 @@ bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event)
dragDiffX += ev.motion.xrel;
dragDiffY += ev.motion.yrel;
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, curX, curY);
processMouseEvent(event, curX, curY);
}
return true;
}

View file

@ -43,7 +43,7 @@ void WINCESdlEventSource::init(WINCESdlGraphicsManager *graphicsMan) {
_graphicsMan = graphicsMan;
}
void WINCESdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
void WINCESdlEventSource::processMouseEvent(Common::Event &event, int x, int y) {
event.mouse.x = x;
event.mouse.y = y;
@ -153,7 +153,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
case SDL_MOUSEMOTION:
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
processMouseEvent(event, ev.motion.x, ev.motion.y);
_graphicsMan->setMousePos(event.mouse.x, event.mouse.y);
return true;
@ -165,7 +165,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
event.type = Common::EVENT_RBUTTONDOWN;
else
break;
fillMouseEvent(event, ev.button.x, ev.button.y);
processMouseEvent(event, ev.button.x, ev.button.y);
if (event.mouse.x > _tapX)
@ -241,7 +241,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
_rbutton = false;
}
fillMouseEvent(event, ev.button.x, ev.button.y);
processMouseEvent(event, ev.button.x, ev.button.y);
if (freeLookActive && !_closeClick) {
_tapX = event.mouse.x;
@ -261,8 +261,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
return true;
case SDL_VIDEOEXPOSE:
// HACK: Send a fake event, handled by SdlGraphicsManager
event.type = (Common::EventType)OSystem_SDL::kSdlEventExpose;
_graphicsMan->notifyVideoExpose();
break;
case SDL_QUIT:
@ -279,9 +278,8 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
if (ev.active.state & SDL_APPINPUTFOCUS) {
_graphicsMan->_hasfocus = ev.active.gain;
SDL_PauseAudio(!_graphicsMan->_hasfocus);
if (_graphicsMan->_hasfocus) {
event.type = (Common::EventType)OSystem_SDL::kSdlEventExpose;
}
if (_graphicsMan->_hasfocus)
_graphicsMan->notifyVideoExpose();
}
break;
}

View file

@ -43,7 +43,7 @@ public:
// Overloaded from SDL backend (toolbar handling)
bool pollEvent(Common::Event &event);
// Overloaded from SDL backend (mouse and new scaler handling)
void fillMouseEvent(Common::Event &event, int x, int y);
void processMouseEvent(Common::Event &event, int x, int y);
protected:

View file

@ -42,4 +42,3 @@ AbstractFSNode *N64FilesystemFactory::makeFileNodePath(const Common::String &pat
}
#endif

View file

@ -161,4 +161,3 @@ Common::WriteStream *N64FilesystemNode::createWriteStream() {
}
#endif //#ifdef __N64__

View file

@ -83,4 +83,3 @@ RomfsStream *RomfsStream::makeFromPath(const Common::String &path, bool writeMod
}
#endif /* __N64__ */

View file

@ -20,6 +20,8 @@
*
*/
#if !defined(DISABLE_STDIO_FILESTREAM)
// Disable symbol overrides so that we can use FILE, fopen etc.
#define FORBIDDEN_SYMBOL_ALLOW_ALL
@ -100,3 +102,5 @@ StdioStream *StdioStream::makeFromPath(const Common::String &path, bool writeMod
return new StdioStream(handle);
return 0;
}
#endif

View file

@ -231,5 +231,3 @@ Common::WriteStream *SymbianFilesystemNode::createWriteStream() {
return SymbianStdioStream::makeFromPath(getPath(), true);
}
#endif //#if defined (__SYMBIAN32__)

View file

@ -268,4 +268,3 @@ SymbianStdioStream *SymbianStdioStream::makeFromPath(const Common::String &path,
return new SymbianStdioStream(handle);
return 0;
}

View file

@ -218,4 +218,3 @@ void WiiFilesystemFactory::umountUnused(const String &path) {
}
#endif

View file

@ -85,4 +85,3 @@ private:
};
#endif /*Wii_FILESYSTEM_FACTORY_H*/

View file

@ -202,4 +202,3 @@ Common::WriteStream *WiiFilesystemNode::createWriteStream() {
}
#endif //#if defined(__WII__)

View file

@ -122,7 +122,7 @@ void DINGUXSdlGraphicsManager::initSize(uint w, uint h) {
if (w > 320 || h > 240) {
setGraphicsMode(GFX_HALF);
setGraphicsModeIntern();
_sdlEventSource->toggleMouseGrab();
_eventSource->toggleMouseGrab();
}
_transactionDetails.sizeChanged = true;
@ -427,6 +427,7 @@ void DINGUXSdlGraphicsManager::hideOverlay() {
}
bool DINGUXSdlGraphicsManager::loadGFXMode() {
debug("Game ScreenMode = %d*%d", _videoMode.screenWidth, _videoMode.screenHeight);
// Forcefully disable aspect ratio correction for games
// which starts with a native 240px height resolution.
@ -435,7 +436,6 @@ bool DINGUXSdlGraphicsManager::loadGFXMode() {
_videoMode.aspectRatioCorrection = false;
}
debug("Game ScreenMode = %d*%d", _videoMode.screenWidth, _videoMode.screenHeight);
if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) {
_videoMode.aspectRatioCorrection = false;
setGraphicsMode(GFX_HALF);
@ -473,9 +473,13 @@ bool DINGUXSdlGraphicsManager::hasFeature(OSystem::Feature f) {
void DINGUXSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
switch (f) {
case OSystem::kFeatureAspectRatioCorrection:
case OSystem::kFeatureAspectRatioCorrection:
setAspectRatioCorrection(enable);
break;
case OSystem::kFeatureCursorPalette:
_cursorPaletteDisabled = !enable;
blitCursor();
break;
default:
break;
}
@ -485,8 +489,10 @@ bool DINGUXSdlGraphicsManager::getFeatureState(OSystem::Feature f) {
assert(_transactionMode == kTransactionNone);
switch (f) {
case OSystem::kFeatureAspectRatioCorrection:
return _videoMode.aspectRatioCorrection;
case OSystem::kFeatureAspectRatioCorrection:
return _videoMode.aspectRatioCorrection;
case OSystem::kFeatureCursorPalette:
return !_cursorPaletteDisabled;
default:
return false;
}
@ -510,21 +516,16 @@ void DINGUXSdlGraphicsManager::warpMouse(int x, int y) {
SurfaceSdlGraphicsManager::warpMouse(x, y);
}
void DINGUXSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
if (!event.synthetic) {
Common::Event newEvent(event);
newEvent.synthetic = true;
if (!_overlayVisible) {
if (_videoMode.mode == GFX_HALF) {
newEvent.mouse.x *= 2;
newEvent.mouse.y *= 2;
}
newEvent.mouse.x /= _videoMode.scaleFactor;
newEvent.mouse.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
newEvent.mouse.y = aspect2Real(newEvent.mouse.y);
void DINGUXSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) {
if (!_overlayVisible) {
if (_videoMode.mode == GFX_HALF) {
point.x *= 2;
point.y *= 2;
}
g_system->getEventManager()->pushEvent(newEvent);
point.x /= _videoMode.scaleFactor;
point.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
point.y = aspect2Real(point.y);
}
}

View file

@ -57,7 +57,7 @@ public:
SurfaceSdlGraphicsManager::MousePos *getMouseCurState();
SurfaceSdlGraphicsManager::VideoState *getVideoMode();
virtual void adjustMouseEvent(const Common::Event &event);
virtual void transformMouseCoordinates(Common::Point &point);
};
#endif /* BACKENDS_GRAPHICS_SDL_DINGUX_H */

View file

@ -141,7 +141,7 @@ void GPHGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *f
if (w > 320 || h > 240){
setGraphicsMode(GFX_HALF);
setGraphicsModeIntern();
_sdlEventSource->toggleMouseGrab();
_eventSource->toggleMouseGrab();
}
_videoMode.overlayWidth = 320;
@ -579,21 +579,16 @@ void GPHGraphicsManager::warpMouse(int x, int y) {
SurfaceSdlGraphicsManager::warpMouse(x, y);
}
void GPHGraphicsManager::adjustMouseEvent(const Common::Event &event) {
if (!event.synthetic) {
Common::Event newEvent(event);
newEvent.synthetic = true;
if (!_overlayVisible) {
if (_videoMode.mode == GFX_HALF) {
newEvent.mouse.x *= 2;
newEvent.mouse.y *= 2;
}
newEvent.mouse.x /= _videoMode.scaleFactor;
newEvent.mouse.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
newEvent.mouse.y = aspect2Real(newEvent.mouse.y);
void GPHGraphicsManager::transformMouseCoordinates(Common::Point &point) {
if (!_overlayVisible) {
if (_videoMode.mode == GFX_HALF) {
point.x *= 2;
point.y *= 2;
}
g_system->getEventManager()->pushEvent(newEvent);
point.x /= _videoMode.scaleFactor;
point.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
point.y = aspect2Real(point.y);
}
}

View file

@ -56,7 +56,7 @@ public:
SurfaceSdlGraphicsManager::MousePos *getMouseCurState();
SurfaceSdlGraphicsManager::VideoState *getVideoMode();
virtual void adjustMouseEvent(const Common::Event &event);
virtual void transformMouseCoordinates(Common::Point &point);
};
#endif /* BACKENDS_GRAPHICS_GPH_H */

View file

@ -84,6 +84,10 @@ public:
virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0;
virtual void displayMessageOnOSD(const char *msg) {}
// Graphics::PaletteManager interface
//virtual void setPalette(const byte *colors, uint start, uint num) = 0;
//virtual void grabPalette(byte *colors, uint start, uint num) = 0;
};
#endif

View file

@ -134,7 +134,7 @@ void LinuxmotoSdlGraphicsManager::initSize(uint w, uint h) {
if (w > 320 || h > 240) {
setGraphicsMode(GFX_HALF);
setGraphicsModeIntern();
_sdlEventSource->toggleMouseGrab();
_eventSource->toggleMouseGrab();
}
_transactionDetails.sizeChanged = true;
@ -478,21 +478,16 @@ void LinuxmotoSdlGraphicsManager::warpMouse(int x, int y) {
SurfaceSdlGraphicsManager::warpMouse(x, y);
}
void LinuxmotoSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
if (!event.synthetic) {
Common::Event newEvent(event);
newEvent.synthetic = true;
if (!_overlayVisible) {
if (_videoMode.mode == GFX_HALF) {
newEvent.mouse.x *= 2;
newEvent.mouse.y *= 2;
}
newEvent.mouse.x /= _videoMode.scaleFactor;
newEvent.mouse.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
newEvent.mouse.y = aspect2Real(newEvent.mouse.y);
void LinuxmotoSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) {
if (!_overlayVisible) {
if (_videoMode.mode == GFX_HALF) {
point.x *= 2;
point.y *= 2;
}
g_system->getEventManager()->pushEvent(newEvent);
point.x /= _videoMode.scaleFactor;
point.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
point.y = aspect2Real(point.y);
}
}

View file

@ -42,8 +42,7 @@ public:
virtual void hideOverlay();
virtual void warpMouse(int x, int y);
protected:
virtual void adjustMouseEvent(const Common::Event &event);
virtual void transformMouseCoordinates(Common::Point &point);
};
#endif

View file

@ -20,6 +20,9 @@
*
*/
#ifndef BACKENDS_GRAPHICS_OPENGL_GLTEXTURE_H
#define BACKENDS_GRAPHICS_OPENGL_GLTEXTURE_H
#include "common/scummsys.h"
#ifdef WIN32
@ -31,7 +34,20 @@
#undef ARRAYSIZE
#endif
#if defined(USE_GLES)
// HACK: At this point in Windows platforms, common/util.h has been included
// via common/rect.h (from backends/graphics/sdl/sdl-graphics.h), via
// backends/graphics/openglsdl/openglsdl-graphics.h. Thus, we end up with
// COMMON_UTIL_H defined, and ARRAYSIZE undefined (bad!). Therefore,
// ARRAYSIZE is undefined in openglsdl-graphics.cpp. This is a temporary
// hackish solution fo fix compilation under Windows.
#if !defined(ARRAYSIZE) && defined(COMMON_UTIL_H)
#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
#endif
#if defined(BADA)
#include <FGraphicsOpengl.h>
using namespace Osp::Graphics::Opengl;
#elif defined(USE_GLES)
#include <GLES/gl.h>
#elif defined(SDL_BACKEND)
#include <SDL_opengl.h>
@ -106,3 +122,5 @@ protected:
GLint _filter;
bool _refresh;
};
#endif

View file

@ -67,10 +67,6 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
}
OpenGLGraphicsManager::~OpenGLGraphicsManager() {
// Unregister the event observer
if (g_system->getEventManager()->getEventDispatcher() != NULL)
g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this);
free(_gamePalette);
free(_cursorPalette);
@ -79,11 +75,6 @@ OpenGLGraphicsManager::~OpenGLGraphicsManager() {
delete _cursorTexture;
}
void OpenGLGraphicsManager::initEventObserver() {
// Register the graphics manager as a event observer
g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false);
}
//
// Feature
//
@ -1254,12 +1245,16 @@ void OpenGLGraphicsManager::toggleAntialiasing() {
_transactionDetails.filterChanged = true;
}
uint OpenGLGraphicsManager::getAspectRatio() {
uint OpenGLGraphicsManager::getAspectRatio() const {
// In case we enable aspect ratio correction we force a 4/3 ratio.
// But just for 320x200 and 640x400 games, since other games do not need
// this.
// TODO: This makes OpenGL Normal behave like OpenGL Conserve, when aspect
// ratio correction is enabled, but it's better than the previous 4/3 mode
// mess at least...
if (_videoMode.aspectRatioCorrection)
if (_videoMode.aspectRatioCorrection
&& ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200)
|| (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400)))
return 13333;
else if (_videoMode.mode == OpenGL::GFX_NORMAL)
return _videoMode.hardwareWidth * 10000 / _videoMode.hardwareHeight;
@ -1282,36 +1277,6 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {
}
}
bool OpenGLGraphicsManager::notifyEvent(const Common::Event &event) {
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
if (!event.synthetic) {
_cursorState.x = event.mouse.x;
_cursorState.y = event.mouse.y;
}
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_WHEELUP:
case Common::EVENT_WHEELDOWN:
case Common::EVENT_MBUTTONDOWN:
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
case Common::EVENT_MBUTTONUP:
if (!event.synthetic) {
Common::Event newEvent(event);
newEvent.synthetic = true;
adjustMousePosition(newEvent.mouse.x, newEvent.mouse.y);
g_system->getEventManager()->pushEvent(newEvent);
}
return !event.synthetic;
default:
break;
}
return false;
}
bool OpenGLGraphicsManager::saveScreenshot(const char *filename) {
int width = _videoMode.hardwareWidth;
int height = _videoMode.hardwareHeight;
@ -1383,9 +1348,13 @@ const char *OpenGLGraphicsManager::getCurrentModeName() {
}
#ifdef USE_OSD
const Graphics::Font *OpenGLGraphicsManager::getFontOSD() {
return FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont);
}
void OpenGLGraphicsManager::updateOSD() {
// The font we are going to use:
const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont);
const Graphics::Font *font = getFontOSD();
if (_osdSurface.w != _osdTexture->getWidth() || _osdSurface.h != _osdTexture->getHeight())
_osdSurface.create(_osdTexture->getWidth(), _osdTexture->getHeight(), _overlayFormat);

View file

@ -26,7 +26,8 @@
#include "backends/graphics/opengl/gltexture.h"
#include "backends/graphics/graphics.h"
#include "common/array.h"
#include "common/events.h"
#include "common/rect.h"
#include "graphics/font.h"
#include "graphics/pixelformat.h"
// Uncomment this to enable the 'on screen display' code.
@ -50,13 +51,11 @@ enum {
* the buffers swap, and implement loadGFXMode for handling the window/context if
* needed. If USE_RGB_COLOR is enabled, getSupportedFormats must be implemented.
*/
class OpenGLGraphicsManager : public GraphicsManager, public Common::EventObserver {
class OpenGLGraphicsManager : public GraphicsManager {
public:
OpenGLGraphicsManager();
virtual ~OpenGLGraphicsManager();
virtual void initEventObserver();
virtual bool hasFeature(OSystem::Feature f);
virtual void setFeatureState(OSystem::Feature f, bool enable);
virtual bool getFeatureState(OSystem::Feature f);
@ -109,10 +108,6 @@ public:
virtual void setCursorPalette(const byte *colors, uint start, uint num);
virtual void displayMessageOnOSD(const char *msg);
// Override from Common::EventObserver
bool notifyEvent(const Common::Event &event);
protected:
/**
* Setup OpenGL settings
@ -220,10 +215,7 @@ protected:
virtual void calculateDisplaySize(int &width, int &height);
virtual void refreshDisplaySize();
/**
* Returns the current target aspect ratio x 10000
*/
virtual uint getAspectRatio();
uint getAspectRatio() const;
bool _formatBGR;
@ -324,6 +316,11 @@ protected:
*/
Common::Array<Common::String> _osdLines;
/**
* Returns the font used for on screen display
*/
virtual const Graphics::Font *getFontOSD();
/**
* Update the OSD texture / surface.
*/

View file

@ -30,8 +30,9 @@
#include "common/textconsole.h"
#include "common/translation.h"
OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager()
OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(SdlEventSource *eventSource)
:
SdlGraphicsManager(eventSource),
_hwscreen(0),
_screenResized(false),
_activeFullscreenMode(-2),
@ -71,6 +72,14 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager()
}
OpenGLSdlGraphicsManager::~OpenGLSdlGraphicsManager() {
// Unregister the event observer
if (g_system->getEventManager()->getEventDispatcher() != NULL)
g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this);
}
void OpenGLSdlGraphicsManager::initEventObserver() {
// Register the graphics manager as a event observer
g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false);
}
bool OpenGLSdlGraphicsManager::hasFeature(OSystem::Feature f) {
@ -304,14 +313,17 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
_videoMode.overlayWidth = _videoMode.hardwareWidth = _videoMode.screenWidth * scaleFactor;
_videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * scaleFactor;
int screenAspectRatio = _videoMode.screenWidth * 10000 / _videoMode.screenHeight;
int desiredAspectRatio = getAspectRatio();
// Do not downscale dimensions, only enlarge them if needed
if (screenAspectRatio > desiredAspectRatio)
_videoMode.hardwareHeight = (_videoMode.overlayWidth * 10000 + 5000) / desiredAspectRatio;
else if (screenAspectRatio < desiredAspectRatio)
_videoMode.hardwareWidth = (_videoMode.overlayHeight * desiredAspectRatio + 5000) / 10000;
// The only modes where we need to adapt the aspect ratio are 320x200
// and 640x400. That is since our aspect ratio correction in fact is
// only used to ensure that the original pixel size aspect for these
// modes is used.
// (Non-square pixels on old monitors vs square pixel on new ones).
if (_videoMode.aspectRatioCorrection
&& ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200)
|| (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400)))
_videoMode.overlayHeight = _videoMode.hardwareHeight = 240 * scaleFactor;
else
_videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * scaleFactor;
}
_screenResized = false;
@ -609,50 +621,54 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
}
}
break;
case Common::EVENT_KEYUP:
return isHotkey(event);
// HACK: Handle special SDL event
// The new screen size is saved on the mouse event as part of HACK,
// there is no common resize event.
case OSystem_SDL::kSdlEventResize:
// Do not resize if ignoring resize events.
if (!_ignoreResizeFrames && !getFullscreenMode()) {
bool scaleChanged = false;
beginGFXTransaction();
_videoMode.hardwareWidth = event.mouse.x;
_videoMode.hardwareHeight = event.mouse.y;
if (_videoMode.mode != OpenGL::GFX_ORIGINAL) {
_screenResized = true;
calculateDisplaySize(_videoMode.hardwareWidth, _videoMode.hardwareHeight);
}
int scale = MIN(_videoMode.hardwareWidth / _videoMode.screenWidth,
_videoMode.hardwareHeight / _videoMode.screenHeight);
if (getScale() != scale) {
scaleChanged = true;
setScale(MAX(MIN(scale, 3), 1));
}
if (_videoMode.mode == OpenGL::GFX_ORIGINAL) {
calculateDisplaySize(_videoMode.hardwareWidth, _videoMode.hardwareHeight);
}
_transactionDetails.sizeChanged = true;
endGFXTransaction();
#ifdef USE_OSD
if (scaleChanged)
displayScaleChangedMsg();
#endif
}
return true;
default:
break;
}
return OpenGLGraphicsManager::notifyEvent(event);
return false;
}
void OpenGLSdlGraphicsManager::notifyVideoExpose() {
}
void OpenGLSdlGraphicsManager::notifyResize(const uint width, const uint height) {
// Do not resize if ignoring resize events.
if (!_ignoreResizeFrames && !getFullscreenMode()) {
bool scaleChanged = false;
beginGFXTransaction();
_videoMode.hardwareWidth = width;
_videoMode.hardwareHeight = height;
_screenResized = true;
int scale = MIN(_videoMode.hardwareWidth / _videoMode.screenWidth,
_videoMode.hardwareHeight / _videoMode.screenHeight);
if (getScale() != scale) {
scaleChanged = true;
setScale(MAX(MIN(scale, 3), 1));
}
_transactionDetails.sizeChanged = true;
endGFXTransaction();
#ifdef USE_OSD
if (scaleChanged)
displayScaleChangedMsg();
#endif
}
}
void OpenGLSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) {
adjustMousePosition(point.x, point.y);
}
void OpenGLSdlGraphicsManager::notifyMousePos(Common::Point mouse) {
_cursorState.x = mouse.x;
_cursorState.y = mouse.y;
}
#endif

View file

@ -27,15 +27,17 @@
#if defined(ARRAYSIZE) && !defined(_WINDOWS_)
#undef ARRAYSIZE
#endif
#include "backends/graphics/sdl/sdl-graphics.h"
#include "backends/graphics/opengl/opengl-graphics.h"
#include "common/events.h"
/**
* SDL OpenGL graphics manager
*/
class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager {
class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager, public SdlGraphicsManager, public Common::EventObserver {
public:
OpenGLSdlGraphicsManager();
OpenGLSdlGraphicsManager(SdlEventSource *eventSource);
virtual ~OpenGLSdlGraphicsManager();
virtual bool hasFeature(OSystem::Feature f);
@ -45,10 +47,17 @@ public:
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;
#endif
virtual void initEventObserver();
virtual bool notifyEvent(const Common::Event &event);
virtual void updateScreen();
// SdlGraphicsManager interface
virtual void notifyVideoExpose();
virtual void notifyResize(const uint width, const uint height);
virtual void transformMouseCoordinates(Common::Point &point);
virtual void notifyMousePos(Common::Point mouse);
protected:
virtual void internUpdateScreen();

View file

@ -0,0 +1,35 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "backends/graphics/sdl/sdl-graphics.h"
#include "backends/events/sdl/sdl-events.h"
SdlGraphicsManager::SdlGraphicsManager(SdlEventSource *source)
: _eventSource(source) {
_eventSource->setGraphicsManager(this);
}
SdlGraphicsManager::~SdlGraphicsManager() {
_eventSource->setGraphicsManager(0);
}

View file

@ -0,0 +1,86 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef BACKENDS_GRAPHICS_SDL_SDLGRAPHICS_H
#define BACKENDS_GRAPHICS_SDL_SDLGRAPHICS_H
#include "common/rect.h"
class SdlEventSource;
/**
* Base class for a SDL based graphics manager.
*
* It features a few extra a few extra features required by SdlEventSource.
* FIXME/HACK:
* Note it does not inherit from GraphicsManager to avoid a diamond inheritance
* in the current OpenGLSdlGraphicsManager.
*/
class SdlGraphicsManager {
public:
SdlGraphicsManager(SdlEventSource *source);
virtual ~SdlGraphicsManager();
/**
* Notify the graphics manager that the graphics needs to be redrawn, since
* the application window was modified.
*
* This is basically called when SDL_VIDEOEXPOSE was received.
*/
virtual void notifyVideoExpose() = 0;
/**
* Notify the graphics manager about an resize event.
*
* It is noteworthy that the requested width/height should actually be set
* up as is and not changed by the graphics manager, since else it might
* lead to odd behavior for certain window managers.
*
* It is only required to overwrite this method in case you want a
* resizable window. The default implementation just does nothing.
*
* @param width Requested window width.
* @param height Requested window height.
*/
virtual void notifyResize(const uint width, const uint height) {}
/**
* Transforms real screen coordinates into the current active screen
* coordinates (may be either game screen or overlay).
*
* @param point Mouse coordinates to transform.
*/
virtual void transformMouseCoordinates(Common::Point &point) = 0;
/**
* Notifies the graphics manager about a position change according to the
* real screen coordinates.
*
* @param mouse Mouse position.
*/
virtual void notifyMousePos(Common::Point mouse) = 0;
protected:
SdlEventSource *_eventSource;
};
#endif

View file

@ -122,7 +122,7 @@ static AspectRatio getDesiredAspectRatio() {
SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource)
:
_sdlEventSource(sdlEventSource),
SdlGraphicsManager(sdlEventSource),
#ifdef USE_OSD
_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
#endif
@ -249,7 +249,10 @@ void SurfaceSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)
}
bool SurfaceSdlGraphicsManager::getFeatureState(OSystem::Feature f) {
assert(_transactionMode == kTransactionNone);
// We need to allow this to be called from within a transaction, since we
// currently use it to retreive the graphics state, when switching from
// SDL->OpenGL mode for example.
//assert(_transactionMode == kTransactionNone);
switch (f) {
case OSystem::kFeatureFullscreenMode:
@ -846,7 +849,7 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {
SDL_SetColorKey(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOSDColorKey);
#endif
_sdlEventSource->resetKeyboadEmulation(
_eventSource->resetKeyboadEmulation(
_videoMode.screenWidth * _videoMode.scaleFactor - 1,
effectiveScreenHeight() - 1);
@ -2235,20 +2238,6 @@ bool SurfaceSdlGraphicsManager::isScalerHotkey(const Common::Event &event) {
return false;
}
void SurfaceSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
if (!event.synthetic) {
Common::Event newEvent(event);
newEvent.synthetic = true;
if (!_overlayVisible) {
newEvent.mouse.x /= _videoMode.scaleFactor;
newEvent.mouse.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
newEvent.mouse.y = aspect2Real(newEvent.mouse.y);
}
g_system->getEventManager()->pushEvent(newEvent);
}
}
void SurfaceSdlGraphicsManager::toggleFullScreen() {
beginGFXTransaction();
setFullscreenMode(!_videoMode.fullscreen);
@ -2297,26 +2286,10 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
if (handleScalerHotkeys(event.kbd.keycode))
return true;
}
case Common::EVENT_KEYUP:
return isScalerHotkey(event);
case Common::EVENT_MOUSEMOVE:
if (event.synthetic)
setMousePos(event.mouse.x, event.mouse.y);
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_WHEELUP:
case Common::EVENT_WHEELDOWN:
case Common::EVENT_MBUTTONDOWN:
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
case Common::EVENT_MBUTTONUP:
adjustMouseEvent(event);
return !event.synthetic;
// HACK: Handle special SDL event
case OSystem_SDL::kSdlEventExpose:
_forceFull = true;
return false;
default:
break;
}
@ -2324,4 +2297,22 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
return false;
}
void SurfaceSdlGraphicsManager::notifyVideoExpose() {
_forceFull = true;
}
void SurfaceSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) {
if (!_overlayVisible) {
point.x /= _videoMode.scaleFactor;
point.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
point.y = aspect2Real(point.y);
}
}
void SurfaceSdlGraphicsManager::notifyMousePos(Common::Point mouse) {
transformMouseCoordinates(mouse);
setMousePos(mouse.x, mouse.y);
}
#endif

View file

@ -24,6 +24,7 @@
#define BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H
#include "backends/graphics/graphics.h"
#include "backends/graphics/sdl/sdl-graphics.h"
#include "graphics/pixelformat.h"
#include "graphics/scaler.h"
#include "common/events.h"
@ -74,7 +75,7 @@ public:
/**
* SDL graphics manager
*/
class SurfaceSdlGraphicsManager : public GraphicsManager, public Common::EventObserver {
class SurfaceSdlGraphicsManager : public GraphicsManager, public SdlGraphicsManager, public Common::EventObserver {
public:
SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource);
virtual ~SurfaceSdlGraphicsManager();
@ -140,9 +141,12 @@ public:
// Override from Common::EventObserver
bool notifyEvent(const Common::Event &event);
protected:
SdlEventSource *_sdlEventSource;
// SdlGraphicsManager interface
virtual void notifyVideoExpose();
virtual void transformMouseCoordinates(Common::Point &point);
virtual void notifyMousePos(Common::Point mouse);
protected:
#ifdef USE_OSD
/** Surface containing the OSD message */
SDL_Surface *_osdSurface;
@ -329,7 +333,6 @@ protected:
virtual bool handleScalerHotkeys(Common::KeyCode key);
virtual bool isScalerHotkey(const Common::Event &event);
virtual void adjustMouseEvent(const Common::Event &event);
virtual void setMousePos(int x, int y);
virtual void toggleFullScreen();
virtual bool saveScreenshot(const char *filename);

View file

@ -77,4 +77,3 @@ void SymbianSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)
}
#endif

View file

@ -39,4 +39,3 @@ public:
};
#endif

View file

@ -934,7 +934,7 @@ bool WINCESdlGraphicsManager::loadGFXMode() {
_toolbarHigh = NULL;
// keyboard cursor control, some other better place for it?
_sdlEventSource->resetKeyboadEmulation(_videoMode.screenWidth * _scaleFactorXm / _scaleFactorXd - 1, _videoMode.screenHeight * _scaleFactorXm / _scaleFactorXd - 1);
_eventSource->resetKeyboadEmulation(_videoMode.screenWidth * _scaleFactorXm / _scaleFactorXd - 1, _videoMode.screenHeight * _scaleFactorXm / _scaleFactorXd - 1);
return true;
}
@ -1158,22 +1158,17 @@ void WINCESdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, in
}
}
void WINCESdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
if (!event.synthetic) {
Common::Event newEvent(event);
newEvent.synthetic = true;
/*
if (!_overlayVisible) {
newEvent.mouse.x = newEvent.mouse.x * _scaleFactorXd / _scaleFactorXm;
newEvent.mouse.y = newEvent.mouse.y * _scaleFactorYd / _scaleFactorYm;
newEvent.mouse.x /= _videoMode.scaleFactor;
newEvent.mouse.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
newEvent.mouse.y = aspect2Real(newEvent.mouse.y);
}
*/
g_system->getEventManager()->pushEvent(newEvent);
void WINCESdlGraphicsManager::transformMouseCoordinates(Common::Point &point) {
/*
if (!_overlayVisible) {
point.x = point.x * _scaleFactorXd / _scaleFactorXm;
point.y = point.y * _scaleFactorYd / _scaleFactorYm;
point.x /= _videoMode.scaleFactor;
point.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
point.y = aspect2Real(point.y);
}
*/
}
void WINCESdlGraphicsManager::setMousePos(int x, int y) {
@ -1657,4 +1652,3 @@ WINCESdlGraphicsManager::zoneDesc WINCESdlGraphicsManager::_zones[TOTAL_ZONES] =
};
#endif /* _WIN32_WCE */

View file

@ -158,8 +158,7 @@ public:
static zoneDesc _zones[TOTAL_ZONES];
protected:
virtual void adjustMouseEvent(const Common::Event &event);
virtual void transformMouseCoordinates(Common::Point &point);
private:
bool update_scalers();
@ -206,4 +205,3 @@ private:
};
#endif /* BACKENDS_GRAPHICS_WINCE_SDL_H */

View file

@ -102,4 +102,3 @@ void Log::printTimeStamp() {
} // End of namespace Log
} // End of namespace Backends

View file

@ -126,4 +126,3 @@ private:
} // End of namespace Backends
#endif

View file

@ -72,4 +72,3 @@ void SymbianSdlMixerManager::callbackHandler(byte *samples, int len) {
}
#endif

View file

@ -41,4 +41,3 @@ protected:
};
#endif

View file

@ -131,15 +131,20 @@ uint32 WINCESdlMixerManager::compute_sample_rate() {
ConfMan.setBool("FM_medium_quality", true);
ConfMan.flushToDisk();
}
} else {
if (!ConfMan.hasKey("FM_high_quality") && !ConfMan.hasKey("FM_medium_quality")) {
ConfMan.setBool("FM_high_quality", true);
ConfMan.flushToDisk();
}
}
// See if the output frequency is forced by the game
if (gameid == "ft" || gameid == "dig" || gameid == "comi" || gameid == "queen" || gameid == "sword" || gameid == "agi")
sampleRate = SAMPLES_PER_SEC_NEW;
else {
if (ConfMan.hasKey("high_sample_rate") && ConfMan.getBool("high_sample_rate"))
sampleRate = SAMPLES_PER_SEC_NEW;
else
if (ConfMan.hasKey("high_sample_rate") && !ConfMan.getBool("high_sample_rate"))
sampleRate = SAMPLES_PER_SEC_OLD;
else
sampleRate = SAMPLES_PER_SEC_NEW;
}
#ifdef USE_VORBIS
@ -182,4 +187,3 @@ bool WINCESdlMixerManager::checkOggHighSampleRate() {
#endif
#endif

View file

@ -47,4 +47,3 @@ private:
};
#endif

View file

@ -61,6 +61,7 @@ endif
ifdef SDL_BACKEND
MODULE_OBJS += \
events/sdl/sdl-events.o \
graphics/sdl/sdl-graphics.o \
graphics/surfacesdl/surfacesdl-graphics.o \
mixer/doublebuffersdl/doublebuffersdl-mixer.o \
mixer/sdl/sdl-mixer.o \
@ -87,7 +88,8 @@ endif
ifdef MACOSX
MODULE_OBJS += \
midi/coreaudio.o \
midi/coremidi.o
midi/coremidi.o \
updates/macosx/macosx-updates.o
endif
ifdef WIN32
@ -115,6 +117,11 @@ MODULE_OBJS += \
mixer/sdl13/sdl13-mixer.o
endif
ifeq ($(BACKEND),bada)
MODULE_OBJS += \
timer/bada/timer.o
endif
ifeq ($(BACKEND),ds)
MODULE_OBJS += \
fs/ds/ds-fs.o \

View file

@ -602,4 +602,3 @@ void AndroidPluginProvider::addCustomDirectories(Common::FSList &dirs) const {
#endif
#endif

View file

@ -296,4 +296,3 @@ public:
#endif
#endif

View file

@ -189,4 +189,3 @@ androiddistdebug: all
done
.PHONY: androidrelease androidtest

View file

@ -52,4 +52,3 @@ private:
#endif
#endif

View file

@ -820,4 +820,3 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
}
#endif

View file

@ -826,4 +826,3 @@ void OSystem_Android::disableCursorPalette() {
}
#endif

View file

@ -619,4 +619,3 @@ void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
}
#endif

View file

@ -145,4 +145,3 @@ inline int JNI::writeAudio(JNIEnv *env, jbyteArray &data, int offset, int size)
#endif
#endif

Some files were not shown because too many files have changed in this diff Show more