diff options
| author | Torbjörn Andersson | 2003-11-16 14:18:29 +0000 |
|---|---|---|
| committer | Torbjörn Andersson | 2003-11-16 14:18:29 +0000 |
| commit | fa2b8ba8de31f5659c675b507553a2b0a1ebd841 (patch) | |
| tree | 52841e821b3283a0ff9430cf8be0cc273208f6e6 /sword2/driver | |
| parent | ab066c41e0a42320137bc6cb79d77720f932af0e (diff) | |
| download | scummvm-rg350-fa2b8ba8de31f5659c675b507553a2b0a1ebd841.tar.gz scummvm-rg350-fa2b8ba8de31f5659c675b507553a2b0a1ebd841.tar.bz2 scummvm-rg350-fa2b8ba8de31f5659c675b507553a2b0a1ebd841.zip | |
More cleanup. I've eliminated all the temporary global variables I've added
over the past few weeks, except for g_sword2. (Of course, this doesn't
necessarily make the code any prettier, but we can work on that later.)
svn-id: r11309
Diffstat (limited to 'sword2/driver')
| -rw-r--r-- | sword2/driver/_mouse.cpp | 16 | ||||
| -rw-r--r-- | sword2/driver/d_draw.cpp | 78 | ||||
| -rw-r--r-- | sword2/driver/d_draw.h | 10 | ||||
| -rw-r--r-- | sword2/driver/d_sound.cpp | 62 | ||||
| -rw-r--r-- | sword2/driver/d_sound.h | 5 | ||||
| -rw-r--r-- | sword2/driver/driver96.h | 14 | ||||
| -rw-r--r-- | sword2/driver/keyboard.cpp | 4 | ||||
| -rw-r--r-- | sword2/driver/language.cpp | 4 | ||||
| -rw-r--r-- | sword2/driver/menu.cpp | 11 | ||||
| -rw-r--r-- | sword2/driver/palette.cpp | 24 | ||||
| -rw-r--r-- | sword2/driver/rdwin.cpp | 16 | ||||
| -rw-r--r-- | sword2/driver/render.cpp | 20 | ||||
| -rw-r--r-- | sword2/driver/sprite.cpp | 6 |
13 files changed, 124 insertions, 146 deletions
diff --git a/sword2/driver/_mouse.cpp b/sword2/driver/_mouse.cpp index bce554a3f3..d516c81093 100644 --- a/sword2/driver/_mouse.cpp +++ b/sword2/driver/_mouse.cpp @@ -17,11 +17,7 @@ * $Header$ */ -#include "stdafx.h" -#include "sword2/driver/driver96.h" -#include "sword2/driver/d_draw.h" -#include "sword2/driver/render.h" -#include "sword2/driver/menu.h" +#include "common/stdafx.h" #include "sword2/sword2.h" namespace Sword2 { @@ -171,7 +167,7 @@ void Graphics::drawMouse(void) { if (_mouseAnim) decompressMouse(_mouseData, _mouseSprite, _mouseAnim->mousew, _mouseAnim->mouseh, mouse_width); - g_system->set_mouse_cursor(_mouseData, mouse_width, mouse_height, hotspot_x, hotspot_y); + _vm->_system->set_mouse_cursor(_mouseData, mouse_width, mouse_height, hotspot_x, hotspot_y); } /** @@ -225,12 +221,12 @@ int32 Graphics::setMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) { animateMouse(); drawMouse(); - g_system->show_mouse(true); + _vm->_system->show_mouse(true); } else { if (_luggageAnim) drawMouse(); else - g_system->show_mouse(false); + _vm->_system->show_mouse(false); } return RD_OK; @@ -260,12 +256,12 @@ int32 Graphics::setLuggageAnim(uint8 *ma, int32 size) { animateMouse(); drawMouse(); - g_system->show_mouse(true); + _vm->_system->show_mouse(true); } else { if (_mouseAnim) drawMouse(); else - g_system->show_mouse(false); + _vm->_system->show_mouse(false); } return RD_OK; diff --git a/sword2/driver/d_draw.cpp b/sword2/driver/d_draw.cpp index 1db17dd974..ca1ed7b9ab 100644 --- a/sword2/driver/d_draw.cpp +++ b/sword2/driver/d_draw.cpp @@ -17,22 +17,18 @@ * $Header$ */ -#include "stdafx.h" -#include "sound/mixer.h" +#include "common/stdafx.h" #include "sword2/sword2.h" -#include "sword2/driver/driver96.h" -#include "sword2/driver/d_draw.h" +#include "sword2/driver/menu.h" #include "sword2/driver/render.h" -#include "sword2/header.h" // HACK: For cutscenes instruction message -#include "sword2/maketext.h" // HACK: For cutscenes instruction message namespace Sword2 { -Graphics::Graphics(int16 width, int16 height) - : _iconCount(0), _needFullRedraw(false), _fadeStatus(RDFADE_NONE), - _mouseSprite(NULL), _mouseAnim(NULL), _luggageAnim(NULL), - _layer(0), _renderAverageTime(60), _lightMask(NULL), - _screenWide(width), _screenDeep(height) { +Graphics::Graphics(Sword2Engine *vm, int16 width, int16 height) + : _vm(vm), _iconCount(0), _needFullRedraw(false), + _fadeStatus(RDFADE_NONE), _mouseSprite(NULL), _mouseAnim(NULL), + _luggageAnim(NULL), _layer(0), _renderAverageTime(60), + _lightMask(NULL), _screenWide(width), _screenDeep(height) { int i, j; @@ -40,7 +36,7 @@ Graphics::Graphics(int16 width, int16 height) if (!_buffer) error("Could not initialise display"); - g_system->init_size(width, height); + _vm->_system->init_size(width, height); for (i = 0; i < ARRAYSIZE(_blockSurfaces); i++) _blockSurfaces[i] = NULL; @@ -98,19 +94,19 @@ void Graphics::clearScene(void) { void MoviePlayer::openTextObject(_movieTextObject *obj) { if (obj->textSprite) - g_graphics->createSurface(obj->textSprite, &_textSurface); + _vm->_graphics->createSurface(obj->textSprite, &_textSurface); } void MoviePlayer::closeTextObject(_movieTextObject *obj) { if (_textSurface) { - g_graphics->deleteSurface(_textSurface); + _vm->_graphics->deleteSurface(_textSurface); _textSurface = NULL; } } void MoviePlayer::drawTextObject(_movieTextObject *obj) { if (obj->textSprite && _textSurface) - g_graphics->drawSurface(obj->textSprite, _textSurface); + _vm->_graphics->drawSurface(obj->textSprite, _textSurface); } /** @@ -130,32 +126,32 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu uint8 oldPal[1024]; uint8 tmpPal[1024]; - g_graphics->clearScene(); + _vm->_graphics->clearScene(); // HACK: Draw instructions // // I'm using the the menu area, because that's unlikely to be // touched by anything else during the cutscene. - memset(g_graphics->_buffer, 0, g_graphics->_screenWide * MENUDEEP); + memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP); uint8 msg[] = "Cutscene - Press ESC to exit"; - mem *data = fontRenderer->makeTextSprite(msg, 640, 255, g_sword2->_speechFontId); + mem *data = _vm->_fontRenderer->makeTextSprite(msg, 640, 255, _vm->_speechFontId); _frameHeader *frame = (_frameHeader *) data->ad; _spriteInfo msgSprite; uint8 *msgSurface; - msgSprite.x = g_graphics->_screenWide / 2 - frame->width / 2; + msgSprite.x = _vm->_graphics->_screenWide / 2 - frame->width / 2; msgSprite.y = RDMENU_MENUDEEP / 2 - frame->height / 2; msgSprite.w = frame->width; msgSprite.h = frame->height; msgSprite.type = RDSPR_DISPLAYALIGN | RDSPR_NOCOMPRESSION | RDSPR_TRANS; msgSprite.data = data->ad + sizeof(_frameHeader); - g_graphics->createSurface(&msgSprite, &msgSurface); - g_graphics->drawSurface(&msgSprite, msgSurface); - g_graphics->deleteSurface(msgSurface); - memory->freeMemory(data); + _vm->_graphics->createSurface(&msgSprite, &msgSurface); + _vm->_graphics->drawSurface(&msgSprite, msgSurface); + _vm->_graphics->deleteSurface(msgSurface); + _vm->_memory->freeMemory(data); // In case the cutscene has a long lead-in, start just before // the first line of text. @@ -170,12 +166,12 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu // The text should probably be colored the same as the rest of // the in-game text. - memcpy(oldPal, g_graphics->_palCopy, 1024); + memcpy(oldPal, _vm->_graphics->_palCopy, 1024); memset(tmpPal, 0, 1024); tmpPal[255 * 4 + 0] = 255; tmpPal[255 * 4 + 1] = 255; tmpPal[255 * 4 + 2] = 255; - g_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT); + _vm->_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT); PlayingSoundHandle handle = 0; @@ -186,28 +182,28 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu break; if (frameCounter == text[textCounter]->startFrame) { - g_graphics->clearScene(); + _vm->_graphics->clearScene(); openTextObject(text[textCounter]); drawTextObject(text[textCounter]); if (text[textCounter]->speech) { - g_sword2->_mixer->playRaw(&handle, text[textCounter]->speech, text[textCounter]->speechBufferSize, 22050, SoundMixer::FLAG_16BITS); + _vm->_mixer->playRaw(&handle, text[textCounter]->speech, text[textCounter]->speechBufferSize, 22050, SoundMixer::FLAG_16BITS); } } if (frameCounter == text[textCounter]->endFrame) { closeTextObject(text[textCounter]); - g_graphics->clearScene(); + _vm->_graphics->clearScene(); textCounter++; } frameCounter++; - g_graphics->updateDisplay(); + _vm->_graphics->updateDisplay(); _keyboardEvent ke; - if (g_input->readKey(&ke) == RD_OK && ke.keycode == 27) { - g_sword2->_mixer->stopHandle(handle); + if (_vm->_input->readKey(&ke) == RD_OK && ke.keycode == 27) { + _vm->_mixer->stopHandle(handle); skipCutscene = true; break; } @@ -216,38 +212,38 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu // frame rate the original movies had, or even if it // was constant, but this seems to work reasonably. - g_system->delay_msecs(90); + _vm->_system->delay_msecs(90); } closeTextObject(text[textCounter]); - g_graphics->clearScene(); - g_graphics->setNeedFullRedraw(); + _vm->_graphics->clearScene(); + _vm->_graphics->setNeedFullRedraw(); // HACK: Remove the instructions created above Common::Rect r; - memset(g_graphics->_buffer, 0, g_graphics->_screenWide * MENUDEEP); + memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP); r.left = r.top = 0; - r.right = g_graphics->_screenWide; + r.right = _vm->_graphics->_screenWide; r.bottom = MENUDEEP; - g_graphics->updateRect(&r); + _vm->_graphics->updateRect(&r); // FIXME: For now, only play the lead-out music for cutscenes // that have subtitles. if (!skipCutscene) - g_sound->playLeadOut(musicOut); + _vm->_sound->playLeadOut(musicOut); - g_graphics->setPalette(0, 256, oldPal, RDPAL_INSTANT); + _vm->_graphics->setPalette(0, 256, oldPal, RDPAL_INSTANT); } // Lead-in and lead-out music are, as far as I can tell, only used for // the animated cut-scenes, so this seems like a good place to close // both of them. - g_sound->closeFx(-1); - g_sound->closeFx(-2); + _vm->_sound->closeFx(-1); + _vm->_sound->closeFx(-2); return RD_OK; } diff --git a/sword2/driver/d_draw.h b/sword2/driver/d_draw.h index f3c0a055ee..387ffdb355 100644 --- a/sword2/driver/d_draw.h +++ b/sword2/driver/d_draw.h @@ -20,7 +20,7 @@ #ifndef D_DRAW_H #define D_DRAW_H -#include "sword2/driver/driver96.h" +#include "common/rect.h" namespace Sword2 { @@ -61,13 +61,15 @@ struct _mouseAnim { class MoviePlayer { private: + Sword2Engine *_vm; + uint8 *_textSurface; void openTextObject(_movieTextObject *obj); void closeTextObject(_movieTextObject *obj); void drawTextObject(_movieTextObject *obj); public: - MoviePlayer() : _textSurface(NULL) {} + MoviePlayer(Sword2Engine *vm) : _vm(vm), _textSurface(NULL) {} int32 play(char *filename, _movieTextObject *text[], uint8 *musicOut); }; @@ -80,6 +82,8 @@ class Graphics { friend class MoviePlayer; private: + Sword2Engine *_vm; + byte *_buffer; int32 _renderCaps; @@ -174,7 +178,7 @@ private: int32 decompressRLE16(uint8 *dest, uint8 *source, int32 decompSize, uint8 *colTable); public: - Graphics(int16 width, int16 height); + Graphics(Sword2Engine *vm, int16 width, int16 height); // Game screen metrics int16 _screenWide; diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp index 8235d25934..89b6bece76 100644 --- a/sword2/driver/d_sound.cpp +++ b/sword2/driver/d_sound.cpp @@ -32,13 +32,9 @@ // Does anyone who can run the original interpreter have any // opinions on this? -#include "stdafx.h" -#include "sound/audiostream.h" -#include "sound/mixer.h" -#include "sound/rate.h" +#include "common/stdafx.h" +#include "common/file.h" #include "sword2/sword2.h" -#include "sword2/driver/driver96.h" -#include "sword2/driver/d_sound.h" namespace Sword2 { @@ -119,8 +115,9 @@ static void premix_proc(void *param, int16 *data, uint len) { ((Sound *) param)->fxServer(data, len); } -Sound::Sound(SoundMixer *mixer) { - _mutex = g_system->create_mutex(); +Sound::Sound(Sword2Engine *vm) { + _vm = vm; + _mutex = _vm->_system->create_mutex(); _soundOn = false; _speechStatus = false; @@ -133,21 +130,20 @@ Sound::Sound(SoundMixer *mixer) { _musicVol = 16; _musicMuted = 0; - _mixer = mixer; memset(_fx, 0, sizeof(_fx)); _soundHandleSpeech = 0; _soundOn = true; - _converter = makeRateConverter(_music[0].getRate(), _mixer->getOutputRate(), _music[0].isStereo(), false); + _converter = makeRateConverter(_music[0].getRate(), _vm->_mixer->getOutputRate(), _music[0].isStereo(), false); - _mixer->setupPremix(premix_proc, this); + _vm->_mixer->setupPremix(premix_proc, this); } Sound::~Sound() { if (_mutex) - g_system->delete_mutex(_mutex); + _vm->_system->delete_mutex(_mutex); } // -------------------------------------------------------------------------- @@ -248,8 +244,8 @@ void Sound::playLeadOut(uint8 *leadOut) { } while (_fx[i]._handle) { - g_graphics->updateDisplay(); - g_system->delay_msecs(30); + _vm->_graphics->updateDisplay(); + _vm->_system->delay_msecs(30); } } @@ -418,7 +414,7 @@ int32 Sound::playCompSpeech(const char *filename, uint32 speechid, uint8 vol, in uint32 flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE; - _mixer->playRaw(&_soundHandleSpeech, data16, bufferSize, 22050, flags, -1, volume, p); + _vm->_mixer->playRaw(&_soundHandleSpeech, data16, bufferSize, 22050, flags, -1, volume, p); _speechStatus = true; } @@ -437,7 +433,7 @@ int32 Sound::stopSpeech(void) { return RD_OK; if (_speechStatus) { - g_engine->_mixer->stopHandle(_soundHandleSpeech); + _vm->_mixer->stopHandle(_soundHandleSpeech); _speechStatus = false; return RD_OK; } @@ -474,7 +470,7 @@ void Sound::setSpeechVolume(uint8 volume) { _speechVol = volume; if (_soundHandleSpeech != 0 && !_speechMuted && getSpeechStatus() == RDSE_SAMPLEPLAYING) { - g_engine->_mixer->setChannelVolume(_soundHandleSpeech, 16 * _speechVol); + _vm->_mixer->setChannelVolume(_soundHandleSpeech, 16 * _speechVol); } } @@ -498,7 +494,7 @@ void Sound::muteSpeech(bool mute) { if (getSpeechStatus() == RDSE_SAMPLEPLAYING) { byte volume = mute ? 0 : 16 * _speechVol; - g_engine->_mixer->setChannelVolume(_soundHandleSpeech, volume); + _vm->_mixer->setChannelVolume(_soundHandleSpeech, volume); } } @@ -517,7 +513,7 @@ bool Sound::isSpeechMute(void) { void Sound::pauseSpeech(void) { if (getSpeechStatus() == RDSE_SAMPLEPLAYING) { _speechPaused = true; - g_engine->_mixer->pauseHandle(_soundHandleSpeech, true); + _vm->_mixer->pauseHandle(_soundHandleSpeech, true); } } @@ -528,7 +524,7 @@ void Sound::pauseSpeech(void) { void Sound::unpauseSpeech(void) { if (_speechPaused) { _speechPaused = false; - g_engine->_mixer->pauseHandle(_soundHandleSpeech, false); + _vm->_mixer->pauseHandle(_soundHandleSpeech, false); } } @@ -664,7 +660,7 @@ int32 Sound::playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type) { byte volume = _fxMuted ? 0 : vol * _fxVol; int8 p = _panTable[pan + 16]; - g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p); + _vm->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p); } else { if (type == RDSE_FXLEADIN || type == RDSE_FXLEADOUT) { if (type == RDSE_FXLEADIN) @@ -685,7 +681,7 @@ int32 Sound::playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type) { byte volume = _musicMuted ? 0 : musicVolTable[_musicVol]; - g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, 0); + _vm->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, 0); } else { hr = openFx(id, data); if (hr != RD_OK) { @@ -708,7 +704,7 @@ int32 Sound::playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type) { byte volume = _fxMuted ? 0 : vol * _fxVol; int8 p = _panTable[pan + 16]; - g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p); + _vm->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p); } } } @@ -735,8 +731,8 @@ int32 Sound::setFxIdVolumePan(int32 id, uint8 vol, int8 pan) { _fx[i]._volume = vol; if (!_fxMuted) { - g_engine->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol); - g_engine->_mixer->setChannelPan(_fx[i]._handle, _panTable[pan + 16]); + _vm->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol); + _vm->_mixer->setChannelPan(_fx[i]._handle, _panTable[pan + 16]); } return RD_OK; @@ -750,7 +746,7 @@ int32 Sound::setFxIdVolume(int32 id, uint8 vol) { _fx[i]._volume = vol; if (!_fxMuted) - g_engine->_mixer->setChannelVolume(_fx[i]._handle, vol * _fxVol); + _vm->_mixer->setChannelVolume(_fx[i]._handle, vol * _fxVol); return RD_OK; } @@ -766,7 +762,7 @@ void Sound::clearAllFx(void) { for (int i = 0; i < MAXFX; i++) { if (_fx[i]._id && _fx[i]._id != -1 && _fx[i]._id != -2) { - g_engine->_mixer->stopHandle(_fx[i]._handle); + _vm->_mixer->stopHandle(_fx[i]._handle); _fx[i]._id = 0; _fx[i]._paused = false; if (_fx[i]._buf != NULL) { @@ -797,7 +793,7 @@ int32 Sound::closeFx(int32 id) { if (i == MAXFX) return RDERR_FXNOTOPEN; - g_engine->_mixer->stopHandle(_fx[i]._handle); + _vm->_mixer->stopHandle(_fx[i]._handle); _fx[i]._id = 0; _fx[i]._paused = false; if (_fx[i]._buf != NULL) { @@ -814,7 +810,7 @@ void Sound::pauseFx(void) { if (!_fxPaused) { for (int i = 0; i < MAXFX; i++) { if (_fx[i]._id) { - g_engine->_mixer->pauseHandle(_fx[i]._handle, true); + _vm->_mixer->pauseHandle(_fx[i]._handle, true); _fx[i]._paused = true; } else _fx[i]._paused = false; @@ -827,7 +823,7 @@ void Sound::pauseFxForSequence(void) { if (!_fxPaused) { for (int i = 0; i < MAXFX; i++) { if (_fx[i]._id && _fx[i]._id != -2) { - g_engine->_mixer->pauseHandle(_fx[i]._handle, true); + _vm->_mixer->pauseHandle(_fx[i]._handle, true); _fx[i]._paused = true; } else { _fx[i]._paused = false; @@ -841,7 +837,7 @@ void Sound::unpauseFx(void) { if (_fxPaused) { for (int i = 0; i < MAXFX; i++) { if (_fx[i]._paused && _fx[i]._id) { - g_engine->_mixer->pauseHandle(_fx[i]._handle, false); + _vm->_mixer->pauseHandle(_fx[i]._handle, false); } } _fxPaused = false; @@ -871,7 +867,7 @@ void Sound::setFxVolume(uint8 volume) { // Now update the volume of any fxs playing for (int i = 0; i < MAXFX; i++) { if (_fx[i]._id && !_fxMuted) - g_engine->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol); + _vm->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol); } } @@ -889,7 +885,7 @@ void Sound::muteFx(bool mute) { if (_fx[i]._id) { byte volume = mute ? 0 : _fx[i]._volume * _fxVol; - g_engine->_mixer->setChannelVolume(_fx[i]._handle, volume); + _vm->_mixer->setChannelVolume(_fx[i]._handle, volume); } } } diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h index 8e7fab18c4..842c44d9ff 100644 --- a/sword2/driver/d_sound.h +++ b/sword2/driver/d_sound.h @@ -23,7 +23,6 @@ #include "sound/audiostream.h" #include "sound/mixer.h" #include "sound/rate.h" -#include "common/file.h" namespace Sword2 { @@ -71,7 +70,7 @@ public: class Sound { private: - SoundMixer *_mixer; + Sword2Engine *_vm; OSystem::MutexRef _mutex; RateConverter *_converter; @@ -100,7 +99,7 @@ private: void updateCompSampleStreaming(int16 *data, uint len); public: - Sound(SoundMixer *mixer); + Sound(Sword2Engine *vm); ~Sound(); void fxServer(int16 *data, uint len); int32 playCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan); diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h index 89f9725532..5f769ec4f3 100644 --- a/sword2/driver/driver96.h +++ b/sword2/driver/driver96.h @@ -20,13 +20,10 @@ #ifndef DRIVER96_H #define DRIVER96_H -#include "common/scummsys.h" -#include "base/engine.h" // for warning() -#include "common/system.h" -#include "common/rect.h" - namespace Sword2 { +class Sword2Engine; + // // Defines // ------- @@ -282,6 +279,9 @@ extern int32 SetLanguageVersion(uint8 version); #define MAX_KEY_BUFFER 32 class Input { +private: + Sword2Engine *_vm; + uint8 _mouseBacklog; uint8 _mouseLogPos; _mouseEvent _mouseLog[MAX_MOUSE_EVENTS]; @@ -303,8 +303,8 @@ public: int16 _mouseX; int16 _mouseY; - Input() : - _mouseBacklog(0), _mouseLogPos(0), _keyBacklog(0), + Input(Sword2Engine *vm) : + _vm(vm), _mouseBacklog(0), _mouseLogPos(0), _keyBacklog(0), _keyLogPos(0) {}; void parseEvents(void); diff --git a/sword2/driver/keyboard.cpp b/sword2/driver/keyboard.cpp index 8645f5b10d..5ddf303fc8 100644 --- a/sword2/driver/keyboard.cpp +++ b/sword2/driver/keyboard.cpp @@ -17,8 +17,8 @@ * $Header$ */ -#include "stdafx.h" -#include "sword2/driver/driver96.h" +#include "common/stdafx.h" +#include "sword2/sword2.h" namespace Sword2 { diff --git a/sword2/driver/language.cpp b/sword2/driver/language.cpp index 67bb4e8cc1..af09ef43e7 100644 --- a/sword2/driver/language.cpp +++ b/sword2/driver/language.cpp @@ -17,8 +17,8 @@ * $Header$ */ -#include "stdafx.h" -#include "sword2/driver/driver96.h" +#include "common/stdafx.h" +#include "sword2/sword2.h" namespace Sword2 { diff --git a/sword2/driver/menu.cpp b/sword2/driver/menu.cpp index bbcd63668a..c70b11f83d 100644 --- a/sword2/driver/menu.cpp +++ b/sword2/driver/menu.cpp @@ -17,11 +17,8 @@ * $Header$ */ -#include "stdafx.h" -#include "common/rect.h" -#include "sword2/driver/driver96.h" -#include "sword2/driver/menu.h" -#include "sword2/driver/d_draw.h" +#include "common/stdafx.h" +#include "sword2/sword2.h" #include "sword2/driver/render.h" namespace Sword2 { @@ -65,10 +62,10 @@ void Graphics::processMenu(void) { static int32 lastTime = 0; if (lastTime == 0) { - lastTime = g_system->get_msecs(); + lastTime = _vm->_system->get_msecs(); frameCount = 1; } else { - delta = g_system->get_msecs() - lastTime; + delta = _vm->_system->get_msecs() - lastTime; if (delta > 250) { lastTime += delta; delta = 250; diff --git a/sword2/driver/palette.cpp b/sword2/driver/palette.cpp index 4b69fbc48c..3cfa4bc580 100644 --- a/sword2/driver/palette.cpp +++ b/sword2/driver/palette.cpp @@ -17,12 +17,10 @@ * $Header$ */ -#include "stdafx.h" -#include "common/util.h" -#include "base/engine.h" +#include "common/stdafx.h" +// #include "common/util.h" +// #include "base/engine.h" #include "sword2/sword2.h" -#include "sword2/driver/d_draw.h" -#include "sword2/driver/driver96.h" namespace Sword2 { @@ -116,9 +114,9 @@ void Graphics::setPalette(int16 startEntry, int16 noEntries, uint8 *colourTable, if (noEntries) { memcpy(&_palCopy[startEntry][0], colourTable, noEntries * 4); if (fadeNow == RDPAL_INSTANT) - g_system->set_palette((const byte *) _palCopy, startEntry, noEntries); + _vm->_system->set_palette((const byte *) _palCopy, startEntry, noEntries); } else - g_system->set_palette((const byte *) _palCopy, 0, 256); + _vm->_system->set_palette((const byte *) _palCopy, 0, 256); } void Graphics::dimPalette(void) { @@ -127,7 +125,7 @@ void Graphics::dimPalette(void) { for (int i = 0; i < 256 * 4; i++) p[i] /= 2; - g_system->set_palette(p, 0, 256); + _vm->_system->set_palette(p, 0, 256); } /** @@ -141,7 +139,7 @@ int32 Graphics::fadeUp(float time) { _fadeTotalTime = (int32) (time * 1000); _fadeStatus = RDFADE_UP; - _fadeStartTime = g_system->get_msecs(); + _fadeStartTime = _vm->_system->get_msecs(); return RD_OK; } @@ -157,7 +155,7 @@ int32 Graphics::fadeDown(float time) { _fadeTotalTime = (int32) (time * 1000); _fadeStatus = RDFADE_DOWN; - _fadeStartTime = g_system->get_msecs(); + _fadeStartTime = _vm->_system->get_msecs(); return RD_OK; } @@ -175,7 +173,7 @@ uint8 Graphics::getFadeStatus(void) { void Graphics::waitForFade(void) { while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK) { updateDisplay(); - g_system->delay_msecs(20); + _vm->_system->delay_msecs(20); } } @@ -196,7 +194,7 @@ void Graphics::fadeServer(void) { // I don't know if this is necessary, but let's limit how often the // palette is updated, just to be safe. - currentTime = g_system->get_msecs(); + currentTime = _vm->_system->get_msecs(); if (currentTime - previousTime <= 25) return; @@ -228,7 +226,7 @@ void Graphics::fadeServer(void) { } } - g_system->set_palette(newPalette, 0, 256); + _vm->_system->set_palette(newPalette, 0, 256); } } // End of namespace Sword2 diff --git a/sword2/driver/rdwin.cpp b/sword2/driver/rdwin.cpp index 050e8b3021..4442c79c3d 100644 --- a/sword2/driver/rdwin.cpp +++ b/sword2/driver/rdwin.cpp @@ -19,11 +19,7 @@ #include "common/stdafx.h" #include "sword2/sword2.h" -#include "sword2/driver/driver96.h" -#include "sword2/driver/d_draw.h" -#include "sword2/driver/render.h" #include "sword2/driver/menu.h" -#include "sword2/driver/d_sound.h" namespace Sword2 { @@ -34,7 +30,7 @@ namespace Sword2 { void Input::parseEvents(void) { OSystem::Event event; - while (g_system->poll_event(&event)) { + while (_vm->_system->poll_event(&event)) { switch (event.event_code) { case OSystem::EVENT_KEYDOWN: writeKey(event.kbd.ascii, event.kbd.keycode, event.kbd.flags); @@ -56,7 +52,7 @@ void Input::parseEvents(void) { logMouseEvent(RD_RIGHTBUTTONUP); break; case OSystem::EVENT_QUIT: - g_sword2->closeGame(); + _vm->closeGame(); break; default: break; @@ -74,19 +70,19 @@ void Graphics::setNeedFullRedraw() { */ void Graphics::updateDisplay(void) { - g_input->parseEvents(); + _vm->_input->parseEvents(); fadeServer(); // FIXME: We re-render the entire picture area of the screen for each // frame, which is pretty horrible. if (_needFullRedraw) { - g_system->copy_rect(_buffer + MENUDEEP * _screenWide, _screenWide, 0, MENUDEEP, _screenWide, _screenDeep - 2 * MENUDEEP); + _vm->_system->copy_rect(_buffer + MENUDEEP * _screenWide, _screenWide, 0, MENUDEEP, _screenWide, _screenDeep - 2 * MENUDEEP); _needFullRedraw = false; } // We still need to update because of fades, menu animations, etc. - g_system->update_screen(); + _vm->_system->update_screen(); } /** @@ -97,7 +93,7 @@ void Graphics::setWindowName(const char *windowName) { OSystem::Property prop; prop.caption = windowName; - g_system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop); + _vm->_system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop); } } // End of namespace Sword2 diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp index 0fb3598d69..8beceddc51 100644 --- a/sword2/driver/render.cpp +++ b/sword2/driver/render.cpp @@ -17,12 +17,10 @@ * $Header$ */ -#include "stdafx.h" -#include "sword2/driver/driver96.h" -#include "sword2/driver/d_draw.h" -#include "sword2/driver/render.h" -#include "sword2/driver/menu.h" +#include "common/stdafx.h" #include "sword2/sword2.h" +#include "sword2/driver/menu.h" +#include "sword2/driver/render.h" namespace Sword2 { @@ -32,7 +30,7 @@ namespace Sword2 { #define BLOCKHBITS 6 void Graphics::updateRect(Common::Rect *r) { - g_system->copy_rect(_buffer + r->top * _screenWide + r->left, + _vm->_system->copy_rect(_buffer + r->top * _screenWide + r->left, _screenWide, r->left, r->top, r->right - r->left, r->bottom - r->top); } @@ -575,7 +573,7 @@ void Graphics::renderParallax(_parallax *p, int16 l) { */ void Graphics::initialiseRenderCycle(void) { - _initialTime = g_system->get_msecs(); + _initialTime = _vm->_system->get_msecs(); _totalTime = _initialTime + MILLISECSPERCYCLE; } @@ -588,7 +586,7 @@ void Graphics::startRenderCycle(void) { _scrollXOld = _scrollX; _scrollYOld = _scrollY; - _startTime = g_system->get_msecs(); + _startTime = _vm->_system->get_msecs(); if (_startTime + _renderAverageTime >= _totalTime) { _scrollX = _scrollXTarget; @@ -614,7 +612,7 @@ bool Graphics::endRenderCycle(void) { static int32 renderCountIndex = 0; int32 time; - time = g_system->get_msecs(); + time = _vm->_system->get_msecs(); renderTimeLog[renderCountIndex] = time - _startTime; _startTime = time; _renderAverageTime = (renderTimeLog[0] + renderTimeLog[1] + renderTimeLog[2] + renderTimeLog[3]) >> 2; @@ -639,8 +637,8 @@ bool Graphics::endRenderCycle(void) { if (_scrollXTarget == _scrollX && _scrollYTarget == _scrollY) { // If we have already reached the scroll target sleep for the // rest of the render cycle. - g_sword2->sleepUntil(_totalTime); - _initialTime = g_system->get_msecs(); + _vm->sleepUntil(_totalTime); + _initialTime = _vm->_system->get_msecs(); _totalTime += MILLISECSPERCYCLE; return true; } diff --git a/sword2/driver/sprite.cpp b/sword2/driver/sprite.cpp index c9e21f6639..2e3f75c950 100644 --- a/sword2/driver/sprite.cpp +++ b/sword2/driver/sprite.cpp @@ -17,10 +17,8 @@ * $Header$ */ -#include "stdafx.h" -#include "sword2/driver/driver96.h" -#include "sword2/driver/d_draw.h" -#include "sword2/driver/render.h" +#include "common/stdafx.h" +#include "sword2/sword2.h" namespace Sword2 { |
