diff options
author | Robert Göffringmann | 2003-06-01 21:21:10 +0000 |
---|---|---|
committer | Robert Göffringmann | 2003-06-01 21:21:10 +0000 |
commit | 5bb59b47551c42e128e5270dd6407f375b4dd712 (patch) | |
tree | f3dc6b01100d794f527a1384793b3be39b647b8d | |
parent | 674a34a3921dc084ae6050e3f2f930cd2a3909e3 (diff) | |
download | scummvm-rg350-5bb59b47551c42e128e5270dd6407f375b4dd712.tar.gz scummvm-rg350-5bb59b47551c42e128e5270dd6407f375b4dd712.tar.bz2 scummvm-rg350-5bb59b47551c42e128e5270dd6407f375b4dd712.zip |
cleaned code a bit, added SYSTEM_FLAGS and MOUSE_FLAG
svn-id: r8253
-rw-r--r-- | sky/cd_intro.cpp | 2 | ||||
-rw-r--r-- | sky/grid.cpp | 13 | ||||
-rw-r--r-- | sky/intro.cpp | 4 | ||||
-rw-r--r-- | sky/logic.cpp | 21 | ||||
-rw-r--r-- | sky/logic.h | 7 | ||||
-rw-r--r-- | sky/music/adlibchannel.cpp | 5 | ||||
-rw-r--r-- | sky/music/adlibchannel.h | 4 | ||||
-rw-r--r-- | sky/music/adlibmusic.cpp | 9 | ||||
-rw-r--r-- | sky/music/adlibmusic.h | 3 | ||||
-rw-r--r-- | sky/music/gmmusic.cpp | 4 | ||||
-rw-r--r-- | sky/music/gmmusic.h | 2 | ||||
-rw-r--r-- | sky/music/mt32music.cpp | 4 | ||||
-rw-r--r-- | sky/music/mt32music.h | 2 | ||||
-rw-r--r-- | sky/music/musicbase.cpp | 3 | ||||
-rw-r--r-- | sky/music/musicbase.h | 3 | ||||
-rw-r--r-- | sky/screen.cpp | 37 | ||||
-rw-r--r-- | sky/sky.cpp | 34 | ||||
-rw-r--r-- | sky/sky.h | 18 | ||||
-rw-r--r-- | sky/sound.cpp | 6 | ||||
-rw-r--r-- | sky/text.cpp | 12 | ||||
-rw-r--r-- | sky/text.h | 4 |
21 files changed, 100 insertions, 97 deletions
diff --git a/sky/cd_intro.cpp b/sky/cd_intro.cpp index cf90414c50..01b7ba2424 100644 --- a/sky/cd_intro.cpp +++ b/sky/cd_intro.cpp @@ -206,7 +206,7 @@ void SkyState::doCDIntro() { uint32 loadedVocSize, bgVocSize; byte *vocBuffer, *bgVocBuffer; - assert(isCDVersion(_gameVersion)); + assert(isCDVersion()); vocBuffer = _skyDisk->loadFile(cdv_00, NULL); loadedVocSize = _skyDisk->_lastLoadedFileSize; diff --git a/sky/grid.cpp b/sky/grid.cpp index aa59cf4309..3a369db795 100644 --- a/sky/grid.cpp +++ b/sky/grid.cpp @@ -20,6 +20,7 @@ */ #include "grid.h" +#include "compact.h" #define GRID_FILE_START 60000 @@ -124,11 +125,6 @@ int8 SkyGrid::_gridConvertTable[] = { 69, //96 }; -/*void SkyState::initialiseGrids() { - - _gameGrids = (uint8 *)malloc(TOT_NO_GRIDS * GRID_SIZE); -}*/ - SkyGrid::SkyGrid(SkyDisk *pDisk) { _gameGrids = (uint8 *)malloc(TOT_NO_GRIDS * GRID_SIZE); @@ -145,7 +141,12 @@ void SkyGrid::loadGrids(void) { // no endian conversion necessary as I'm using uint8* instead of uint32* for (uint8 cnt = 0; cnt < TOT_NO_GRIDS; cnt++) _skyDisk->loadFile(GRID_FILE_START + cnt, _gameGrids + (cnt * GRID_SIZE)); - // todo: add BASS hack for Reich's door (grid.asm, load_grids proc) + if (!SkyState::isDemo()) { // single disk demos never get that far + // Reloading the grids can sometimes cause problems eg when reichs door is + // open the door grid bit gets replaced so you can't get back in (or out) + if (SkyLogic::_scriptVariables[REICH_DOOR_FLAG]) + removeGrid(256, 280, 1, &SkyCompact::reich_door_20); + } } bool SkyGrid::getGridValues(Compact *cpt, uint32 *resBitNum, uint32 *resWidth) { diff --git a/sky/intro.cpp b/sky/intro.cpp index 344ca58ee1..270e620127 100644 --- a/sky/intro.cpp +++ b/sky/intro.cpp @@ -204,7 +204,7 @@ void SkyState::intro(void) { delay(3000); //keep virgin screen up for 3 seconds CHECK_ESC - if (!isCDVersion(_gameVersion)) + if (!isCDVersion()) _skyMusic->startMusic(1); delay(3000); //and another 3 seconds. @@ -232,7 +232,7 @@ void SkyState::intro(void) { _skyScreen->paletteFadeUp(60115); - if (isCDVersion(_gameVersion)) { + if (isCDVersion()) { doCDIntro(); } else { _skyDisk->prefetchFile(FN_A_PAL); diff --git a/sky/logic.cpp b/sky/logic.cpp index 1bd0fdc86d..6bdbd83f14 100644 --- a/sky/logic.cpp +++ b/sky/logic.cpp @@ -49,7 +49,7 @@ static const LogicTable logicTable[] = { &SkyLogic::simpleAnim, // 16 Module anim without x,y's }; -SkyLogic::SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound, uint32 gameVersion) { +SkyLogic::SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound) { _skyScreen = skyScreen; _skyDisk = skyDisk; _skyGrid = skyGrid; @@ -57,7 +57,6 @@ SkyLogic::SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyGrid *skyGrid, Sky _skyMusic = skyMusic; _skySound = skySound; _skyMouse = skyMouse; - _gameVersion = gameVersion; _skyAutoRoute = new SkyAutoRoute(_skyGrid); for (int i = 0; i < ARRAYSIZE(_moduleList); i++) @@ -497,9 +496,9 @@ void SkyLogic::talk() { // If speech is allowed then check for it to finish before finishing animations - if (false // system_flags & (1 << sf_play_vocs) // sblaster? - || _compact->extCompact->spTextId == 0xffff // is this a voc file? - || false) {// !(system_flags & (1 << sf_voc_playing))) { // finished? + if ((SkyState::_systemVars.systemFlags & SF_PLAY_VOCS) && // sblaster? + (_compact->extCompact->spTextId == 0xFFFF) && // is this a voc file? + (!(SkyState::_systemVars.systemFlags & SF_VOC_PLAYING))) { // finished? _compact->logic = L_SCRIPT; // restart character control @@ -525,7 +524,7 @@ void SkyLogic::talk() { goto past_speech_anim; } - if (false) { //system_flags & (1 << sf_voc_playing)) { + if (SkyState::_systemVars.systemFlags & SF_VOC_PLAYING) { _compact->extCompact->spTime++; return; } @@ -541,7 +540,7 @@ past_speech_anim: // ok, speech has finished - if (false) { //system_flags & (1 << sf_voc_playing)) { + if (SkyState::_systemVars.systemFlags & SF_VOC_PLAYING) { _compact->extCompact->spTime++; return; } @@ -596,7 +595,7 @@ void SkyLogic::choose() { fnNoHuman(0, 0, 0); // kill mouse again - // system_flags &= ~(1 << SF_CHOOSING); // restore save/restore + SkyState::_systemVars.systemFlags &= ~SF_CHOOSING; // restore save/restore _compact->logic = L_SCRIPT; // and continue script logicScript(); @@ -2062,7 +2061,7 @@ bool SkyLogic::fnCursorUp(uint32 a, uint32 b, uint32 c) { } bool SkyLogic::fnLeaveSection(uint32 sectionNo, uint32 b, uint32 c) { - if (SkyState::isDemo(_gameVersion)) + if (SkyState::isDemo()) error("End of demo"); if (sectionNo == 5) //linc section - has different mouse icons @@ -2073,7 +2072,7 @@ bool SkyLogic::fnLeaveSection(uint32 sectionNo, uint32 b, uint32 c) { bool SkyLogic::fnEnterSection(uint32 sectionNo, uint32 b, uint32 c) { - if (SkyState::isDemo(_gameVersion)) + if (SkyState::isDemo()) if (sectionNo > 2) error("End of demo"); @@ -2222,7 +2221,7 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32 target->getToFlag = *animPtr++; target->grafixProg = animPtr; - if (SkyState::isCDVersion(_gameVersion)) + if (SkyState::isCDVersion()) _skySound->fnStartSpeech((uint16)textNum); //now form the text sprite diff --git a/sky/logic.h b/sky/logic.h index 68d6fc534a..0e587d7acf 100644 --- a/sky/logic.h +++ b/sky/logic.h @@ -56,7 +56,8 @@ enum scriptVariableOffsets { MENU_LENGTH = 100, SCROLL_OFFSET = 101, MENU = 102, - CUR_SECTION = 143 + CUR_SECTION = 143, + REICH_DOOR_FLAG = 470 }; class SkyAutoRoute; @@ -64,7 +65,7 @@ class SkyScreen; class SkyLogic { public: - SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound, uint32 gameVersion); + SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound); void engine(); void nop(); @@ -228,8 +229,6 @@ protected: uint32 _currentSection; uint32 _saveCurrentSection; - uint32 _gameVersion; - SkyScreen *_skyScreen; SkyDisk *_skyDisk; SkyGrid *_skyGrid; diff --git a/sky/music/adlibchannel.cpp b/sky/music/adlibchannel.cpp index 26ad970814..a6922af634 100644 --- a/sky/music/adlibchannel.cpp +++ b/sky/music/adlibchannel.cpp @@ -22,9 +22,8 @@ #include "adlibchannel.h" #include "sound/fmopl.h" -SkyAdlibChannel::SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData, uint32 version) +SkyAdlibChannel::SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData) { - _gameVersion = version; _musicData = pMusicData; _channelData.startOfData = startOfData; _channelData.eventDataPtr = startOfData; @@ -42,7 +41,7 @@ SkyAdlibChannel::SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData, uint32 v uint16 instrumentDataLoc; - if (_gameVersion == 267) { + if (SkyState::_systemVars.gameVersion == 267) { instrumentDataLoc = (_musicData[0x11FC] << 8) | _musicData[0x11FB]; _frequenceTable = (uint16*)(_musicData+0x7F4); _registerTable = _musicData+0xDF4; diff --git a/sky/music/adlibchannel.h b/sky/music/adlibchannel.h index a9b43c3f9b..586f92466a 100644 --- a/sky/music/adlibchannel.h +++ b/sky/music/adlibchannel.h @@ -24,6 +24,7 @@ #include "stdafx.h" #include "common/engine.h" +#include "sky/sky.h" #include "sky/music/musicbase.h" typedef struct { @@ -59,12 +60,11 @@ typedef struct { class SkyAdlibChannel : public SkyChannelBase { public: - SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData, uint32 version); + SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData); virtual void stopNote(void); virtual uint8 process(uint16 aktTime); virtual void updateVolume(uint16 pVolume); private: - uint32 _gameVersion; uint8 *_musicData; uint16 _musicVolume; AdlibChannelType _channelData; diff --git a/sky/music/adlibmusic.cpp b/sky/music/adlibmusic.cpp index b23afd879c..46b72e7f03 100644 --- a/sky/music/adlibmusic.cpp +++ b/sky/music/adlibmusic.cpp @@ -27,8 +27,8 @@ void SkyAdlibMusic::passMixerFunc(void *param, int16 *buf, uint len) { ((SkyAdlibMusic*)param)->premixerCall(buf, len); } -SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, uint32 version) - : SkyMusicBase(pSkyDisk, version) { +SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk) + : SkyMusicBase(pSkyDisk) { _driverFileBase = 60202; _mixer = pMixer; @@ -74,8 +74,7 @@ void SkyAdlibMusic::premixerCall(int16 *buf, uint len) { void SkyAdlibMusic::setupPointers(void) { - printf("game version: %d\n",_gameVersion); - if (_gameVersion == 267) { + if (SkyState::_systemVars.gameVersion == 267) { // disk demo uses a different adlib driver version, some offsets have changed _musicDataLoc = (_musicData[0x11F8] << 8) | _musicData[0x11F7]; _initSequence = _musicData + 0xE87; @@ -92,7 +91,7 @@ void SkyAdlibMusic::setupChannels(uint8 *channelData) { channelData++; for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) { uint16 chDataStart = ((channelData[(cnt << 1) | 1] << 8) | channelData[cnt << 1]) + _musicDataLoc; - _channels[cnt] = new SkyAdlibChannel(_musicData, chDataStart, _gameVersion); + _channels[cnt] = new SkyAdlibChannel(_musicData, chDataStart); } } diff --git a/sky/music/adlibmusic.h b/sky/music/adlibmusic.h index dcde24150c..4fb8fea7fb 100644 --- a/sky/music/adlibmusic.h +++ b/sky/music/adlibmusic.h @@ -23,6 +23,7 @@ #define ADLIBMUSIC_H #include "stdafx.h" +#include "sky/sky.h" #include "sound/mixer.h" #include "common/engine.h" #include "adlibchannel.h" @@ -30,7 +31,7 @@ class SkyAdlibMusic : public SkyMusicBase { public: - SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, uint32 version); + SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk); ~SkyAdlibMusic(void); private: SoundMixer *_mixer; diff --git a/sky/music/gmmusic.cpp b/sky/music/gmmusic.cpp index 2d2dabd864..92ea1e4954 100644 --- a/sky/music/gmmusic.cpp +++ b/sky/music/gmmusic.cpp @@ -26,8 +26,8 @@ void SkyGmMusic::passTimerFunc(void *param) { ((SkyGmMusic*)param)->timerCall(); } -SkyGmMusic::SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, uint32 version) - : SkyMusicBase(pSkyDisk, version) { +SkyGmMusic::SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk) + : SkyMusicBase(pSkyDisk) { _driverFileBase = 60200; _midiDrv = pMidiDrv; diff --git a/sky/music/gmmusic.h b/sky/music/gmmusic.h index be26bf26fd..b3dca05b39 100644 --- a/sky/music/gmmusic.h +++ b/sky/music/gmmusic.h @@ -30,7 +30,7 @@ class SkyGmMusic : public SkyMusicBase { public: - SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, uint32 version); + SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk); ~SkyGmMusic(void); private: static void passTimerFunc(void *param); diff --git a/sky/music/mt32music.cpp b/sky/music/mt32music.cpp index 503b182121..03f3c80a77 100644 --- a/sky/music/mt32music.cpp +++ b/sky/music/mt32music.cpp @@ -26,8 +26,8 @@ void SkyMT32Music::passTimerFunc(void *param) { ((SkyMT32Music*)param)->timerCall(); } -SkyMT32Music::SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, uint32 version) - : SkyMusicBase(pSkyDisk, version) { +SkyMT32Music::SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk) + : SkyMusicBase(pSkyDisk) { _driverFileBase = 60200; _midiDrv = pMidiDrv; diff --git a/sky/music/mt32music.h b/sky/music/mt32music.h index 9b396b649d..76b2a18fc5 100644 --- a/sky/music/mt32music.h +++ b/sky/music/mt32music.h @@ -30,7 +30,7 @@ class SkyMT32Music : public SkyMusicBase { public: - SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, uint32 version); + SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk); ~SkyMT32Music(void); private: static void passTimerFunc(void *param); diff --git a/sky/music/musicbase.cpp b/sky/music/musicbase.cpp index 7d930dae18..cc1670f996 100644 --- a/sky/music/musicbase.cpp +++ b/sky/music/musicbase.cpp @@ -21,9 +21,8 @@ #include "musicbase.h" -SkyMusicBase::SkyMusicBase(SkyDisk *pSkyDisk, uint32 version) { +SkyMusicBase::SkyMusicBase(SkyDisk *pSkyDisk) { - _gameVersion = version; _musicData = NULL; _allowedCommands = 0; _skyDisk = pSkyDisk; diff --git a/sky/music/musicbase.h b/sky/music/musicbase.h index 306cfaa0db..cae59616a8 100644 --- a/sky/music/musicbase.h +++ b/sky/music/musicbase.h @@ -43,14 +43,13 @@ private: class SkyMusicBase { public: - SkyMusicBase(SkyDisk *pSkyDisk, uint32 version); + SkyMusicBase(SkyDisk *pSkyDisk); virtual ~SkyMusicBase(void); void loadSection(uint8 pSection); void musicCommand(uint16 command); void startMusic(uint16 param) { _onNextPoll.musicToProcess = param & 0xF; }; // 4 protected: - uint32 _gameVersion; SkyDisk *_skyDisk; uint8 *_musicData; diff --git a/sky/screen.cpp b/sky/screen.cpp index ad9e356647..0fbf89da82 100644 --- a/sky/screen.cpp +++ b/sky/screen.cpp @@ -175,7 +175,7 @@ void SkyScreen::recreate(void) { void SkyScreen::flip(void) { - // mouse_flag |= MF_NO_UPDATE; + SkyState::_systemVars.mouseFlag |= MF_NO_UPDATE; // drawMouseToBackScreen(); uint8 *screenPos = _currentScreen; uint8 *backPos = _backScreen; @@ -197,7 +197,7 @@ void SkyScreen::flip(void) { screenPos += (GRID_H - 1) * GAME_SCREEN_WIDTH; backPos += (GRID_H - 1) * GAME_SCREEN_WIDTH; } - // mouse_flag &= ~MF_NO_UPDATE; + SkyState::_systemVars.mouseFlag &= ~MF_NO_UPDATE; // _skyMouse->restoreDataToBackScreen(); } @@ -215,8 +215,7 @@ void SkyScreen::fnDrawScreen(uint32 palette, uint32 scroll) { void SkyScreen::fnFadeDown(uint32 scroll) { - if (scroll) { - printf("warning: SkyScreen::fnFadeDown doesn't check (SYSTEM_FLAGS & SF_NO_SCROLL)\n"); + if (scroll && (!(SkyState::_systemVars.systemFlags & SF_NO_SCROLL))) { // scrolling is performed by fnFadeUp. It's just prepared here _scrollScreen = _currentScreen; _currentScreen = (uint8*)malloc(FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT); @@ -284,9 +283,19 @@ void SkyScreen::fnFadeUp(uint32 palNum, uint32 scroll) { //_currentScreen points to new screen, //_scrollScreen points to graphic showing old room - //if (!(systemFlags & SF_NO_SCROLL) && (!scroll)) { - if (scroll) printf("warning: fnFadeUp doesn't check (systemFlags & SF_NO_SCROLL)"); - if (scroll == 123) { + if ((scroll == 0) || (SkyState::_systemVars.systemFlags & SF_NO_SCROLL)) { + uint8 *palette = (uint8*)SkyState::fetchCompact(palNum); + if (palette == NULL) + error("SkyScreen::fnFadeUp: can't fetch compact %X.\n", palNum); +#ifdef SCUMM_BIG_ENDIAN + byte tmpPal[256 * 3]; + for (uint16 cnt = 0; cnt < 256*3; cnt++) + tmpPal[cnt] = palette[cnt ^ 1]; + paletteFadeUp(tmpPal); +#else + paletteFadeUp(palette); +#endif + } else if (scroll == 123) { // scroll left (going right) if (!_currentScreen) error("SkyScreen::fnFadeUp[Scroll L]: _currentScreen is NULL!\n"); if (!_scrollScreen) error("SkyScreen::fnFadeUp[Scroll L]: _scrollScreen is NULL!\n"); @@ -324,19 +333,7 @@ void SkyScreen::fnFadeUp(uint32 palNum, uint32 scroll) { } showScreen(_currentScreen); free(_scrollScreen); - } else { - uint8 *palette = (uint8*)SkyState::fetchCompact(palNum); - if (palette == NULL) - error("SkyScreen::fnFadeUp: can't fetch compact %X.\n", palNum); -#ifdef SCUMM_BIG_ENDIAN - byte tmpPal[256 * 3]; - for (uint16 cnt = 0; cnt < 256*3; cnt++) - tmpPal[cnt] = palette[cnt ^ 1]; - paletteFadeUp(tmpPal); -#else - paletteFadeUp(palette); -#endif - } + } else error("Unknown scroll parameter: %d\n",scroll); } void SkyScreen::waitForTimer(void) { diff --git a/sky/sky.cpp b/sky/sky.cpp index bf6c5e5b93..88f18bba98 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -54,6 +54,8 @@ Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst) { void **SkyState::_itemList[300]; +SystemVars SkyState::_systemVars = {0, 0, 0, 0}; + SkyState::SkyState(GameDetector *detector, OSystem *syst) : Engine(detector, syst) { @@ -66,7 +68,7 @@ SkyState::SkyState(GameDetector *detector, OSystem *syst) _debugMode = detector->_debugMode; _debugLevel = detector->_debugLevel; - _language = detector->_language; + _systemVars.language = detector->_language; _detector = detector; _introTextSpace = 0; @@ -79,7 +81,7 @@ void SkyState::showQuitMsg(void) { uint8 *textBuf2 = (uint8*)calloc(GAME_SCREEN_WIDTH * 14 + sizeof(struct dataFileHeader),1); char *vText1, *vText2; uint8 *screenData = _skyScreen->giveCurrent(); - switch (_language) { + switch (_systemVars.language) { case DE_DEU: vText1 = VIG_DE1; vText2 = VIG_DE2; break; case FR_FRA: vText1 = VIG_FR1; vText2 = VIG_FR2; break; case IT_ITA: vText1 = VIG_IT1; vText2 = VIG_IT2; break; @@ -137,7 +139,7 @@ void SkyState::go() { initialise(); - if (!isDemo(_gameVersion) || isCDVersion(_gameVersion)) + if (!isDemo() || isCDVersion()) intro(); _skyDisk->flushPrefetched(); @@ -161,15 +163,17 @@ void SkyState::initialise(void) { _skyDisk = new SkyDisk(_gameDataPath); _skySound = new SkySound(_mixer, _skyDisk); - _gameVersion = _skyDisk->determineGameVersion(); + _systemVars.gameVersion = _skyDisk->determineGameVersion(); if (_detector->getMidiDriverType() == MD_ADLIB) { - _skyMusic = new SkyAdlibMusic(_mixer, _skyDisk, _gameVersion); + _systemVars.systemFlags |= SF_SBLASTER; + _skyMusic = new SkyAdlibMusic(_mixer, _skyDisk); } else { - _skyMusic = new SkyGmMusic(_detector->createMidi(), _skyDisk, _gameVersion); + _systemVars.systemFlags |= SF_ROLAND; + _skyMusic = new SkyGmMusic(_detector->createMidi(), _skyDisk); } - _skyText = new SkyText(_skyDisk, _gameVersion, _language); + _skyText = new SkyText(_skyDisk); _skyMouse = new SkyMouse(_system, _skyDisk); _skyScreen = new SkyScreen(_system, _skyDisk); @@ -180,7 +184,7 @@ void SkyState::initialise(void) { //initialiseRouter(); loadFixedItems(); _skyGrid = new SkyGrid(_skyDisk); - _skyLogic = new SkyLogic(_skyScreen, _skyDisk, _skyGrid, _skyText, _skyMusic, _skyMouse, _skySound, _gameVersion); + _skyLogic = new SkyLogic(_skyScreen, _skyDisk, _skyGrid, _skyText, _skyMusic, _skyMouse, _skySound); _timer = Engine::_timer; // initialize timer *after* _skyScreen has been initialized. _timer->installProcedure(&timerHandler, 1000000 / 50); //call 50 times per second @@ -197,7 +201,7 @@ void SkyState::initItemList() { _itemList[119] = (void **)SkyCompact::data_0; // Compacts - Section 0 _itemList[120] = (void **)SkyCompact::data_1; // Compacts - Section 1 - if (isDemo(_gameVersion)) { + if (isDemo()) { _itemList[121] = _itemList[122] = _itemList[123] = _itemList[124] = _itemList[125] = (void **)SkyCompact::data_0; } else { _itemList[121] = (void **)SkyCompact::data_2; // Compacts - Section 2 @@ -217,7 +221,7 @@ void SkyState::loadBase0(void) { void SkyState::loadFixedItems(void) { - if (!isDemo(_gameVersion)) + if (!isDemo()) _itemList[36] = (void **)_skyDisk->loadFile(26, NULL); _itemList[49] = (void **)_skyDisk->loadFile(49, NULL); @@ -225,7 +229,7 @@ void SkyState::loadFixedItems(void) { _itemList[73] = (void **)_skyDisk->loadFile(73, NULL); _itemList[262] = (void **)_skyDisk->loadFile(262, NULL); - if (isDemo(_gameVersion)) + if (isDemo()) return; _itemList[263] = (void **)_skyDisk->loadFile(263, NULL); @@ -320,8 +324,8 @@ void SkyState::delay(uint amount) { //copied and mutilated from Simon.cpp } while (cur < start + amount); } -bool SkyState::isDemo(uint32 version) { - switch (version) { +bool SkyState::isDemo(void) { + switch (_systemVars.gameVersion) { case 267: return true; case 288: @@ -341,9 +345,9 @@ bool SkyState::isDemo(uint32 version) { } } -bool SkyState::isCDVersion(uint32 version) { +bool SkyState::isCDVersion(void) { - switch (version) { + switch (_systemVars.gameVersion) { case 267: return false; case 288: @@ -39,6 +39,16 @@ #include "sky/music/mt32music.h" #include "sky/mouse.h" +struct SystemVars { + uint32 systemFlags; + uint32 gameVersion; + uint32 mouseFlag; + uint16 language; + /* uint16 sfxVolume; + uint16 musicVolume; + uint16 gameSpeed; */ +}; + class SkyLogic; class SkyGrid; class SkyAutoRoute; @@ -48,7 +58,6 @@ class SkyState : public Engine { void errorString(const char *buf_input, char *buf_output); protected: byte _game; - uint32 _gameVersion; byte _key_pressed; //intro related @@ -58,7 +67,6 @@ protected: uint16 _debugMode; uint16 _debugLevel; - uint16 _language; uint _mouse_x, _mouse_y; uint _mouse_x_old, _mouse_y_old; bool _mouse_pos_changed; @@ -90,14 +98,16 @@ public: SkyState(GameDetector *detector, OSystem *syst); virtual ~SkyState(); - static bool isDemo(uint32 version); - static bool isCDVersion(uint32 version); + static bool isDemo(void); + static bool isCDVersion(void); static Compact *fetchCompact(uint32 a); static void **fetchItem(uint32 num); static void **_itemList[300]; + static SystemVars _systemVars; + //intro related void prepareText(uint32 *&cmdPtr); void showIntroText(uint32 *&cmdPtr); diff --git a/sky/sound.cpp b/sky/sound.cpp index 090f2ba9f9..99a697c672 100644 --- a/sky/sound.cpp +++ b/sky/sound.cpp @@ -1117,10 +1117,10 @@ bool SkySound::fnStartFx(uint32 sound) { uint8 volume = 0x7f; // start with max vol - // if (system_flags & (1 << sf_sblaster)) + if (SkyState::_systemVars.systemFlags & SF_SBLASTER) volume = roomList[i].adlibVolume; - // if (system_flags & (1 << sf_roland)) { - // volume = roomList[i].rolandVolume; + if (SkyState::_systemVars.systemFlags & SF_ROLAND) + volume = roomList[i].rolandVolume; // Check the flags, the sound may come on after a delay. if (sfx->flags & SFXF_START_DELAY) { diff --git a/sky/text.cpp b/sky/text.cpp index 14802bff9c..2261b3bc15 100644 --- a/sky/text.cpp +++ b/sky/text.cpp @@ -34,10 +34,8 @@ #define CHAR_SET_HEADER 128 #define MAX_NO_LINES 10 -SkyText::SkyText(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) { +SkyText::SkyText(SkyDisk *skyDisk) { _skyDisk = skyDisk; - _language = language; - _gameVersion = gameVersion; initHuffTree(); @@ -47,7 +45,7 @@ SkyText::SkyText(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) { fnSetFont(0); - if (!SkyState::isDemo(_gameVersion)) { + if (!SkyState::isDemo()) { _controlCharacterSet.addr = _skyDisk->loadFile(60520, NULL); _controlCharacterSet.charHeight = 12; _controlCharacterSet.charSpacing = 1; @@ -60,7 +58,7 @@ SkyText::SkyText(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) { _linkCharacterSet.addr = NULL; } - if (SkyState::isCDVersion(_gameVersion)) { + if (SkyState::isCDVersion()) { _preAfterTableArea = _skyDisk->loadFile(60522, NULL); } else _preAfterTableArea = NULL; } @@ -103,7 +101,7 @@ void SkyText::getText(uint32 textNr) { //load text #"textNr" into textBuffer debug(5, "Loading Text item(s) for Section %d", (sectionNo>>2)); uint32 fileNo = (sectionNo >> 2); - fileNo += ((_language * NO_OF_TEXT_SECTIONS) + 60600); + fileNo += ((SkyState::_systemVars.language * NO_OF_TEXT_SECTIONS) + 60600); SkyState::_itemList[FIRST_TEXT_SEC + sectionNo] = (void **)_skyDisk->loadFile((uint16)fileNo, NULL); } _textItemPtr = (uint8 *)SkyState::_itemList[FIRST_TEXT_SEC + sectionNo]; @@ -1441,7 +1439,7 @@ static const HuffTree huffTree_00372[] = { }; void SkyText::initHuffTree() { - switch (_gameVersion) { + switch (SkyState::_systemVars.gameVersion) { case 267: _huffTree = huffTree_00267; break; diff --git a/sky/text.h b/sky/text.h index dff61f4d41..d0e2c380ff 100644 --- a/sky/text.h +++ b/sky/text.h @@ -32,7 +32,7 @@ struct HuffTree { class SkyText { public: - SkyText(SkyDisk *skyDisk, uint32 gameVersion, uint16 _language); + SkyText(SkyDisk *skyDisk); ~SkyText(void); void getText(uint32 textNr); struct displayText_t displayText(uint8 *dest, bool centre, uint16 pixelWidth, uint8 color); @@ -47,8 +47,6 @@ protected: char getTextChar(); SkyDisk *_skyDisk; - uint16 _language; - uint32 _gameVersion; uint8 _inputValue; uint8 _shiftBits; uint8 *_textItemPtr; |