aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sky/autoroute.cpp7
-rw-r--r--sky/autoroute.h7
-rw-r--r--sky/compact.cpp3
-rw-r--r--sky/compacts/savedata.cpp22
-rw-r--r--sky/control.cpp116
-rw-r--r--sky/control.h14
-rw-r--r--sky/debug.cpp1
-rw-r--r--sky/debug.h7
-rw-r--r--sky/disk.cpp35
-rw-r--r--sky/disk.h5
-rw-r--r--sky/grid.cpp8
-rw-r--r--sky/grid.h7
-rw-r--r--sky/intro.cpp9
-rw-r--r--sky/intro.h11
-rw-r--r--sky/logic.cpp189
-rw-r--r--sky/logic.h29
-rw-r--r--sky/mouse.cpp17
-rw-r--r--sky/mouse.h6
-rw-r--r--sky/music/adlibchannel.cpp9
-rw-r--r--sky/music/adlibchannel.h3
-rw-r--r--sky/music/adlibmusic.cpp8
-rw-r--r--sky/music/adlibmusic.h9
-rw-r--r--sky/music/gmchannel.cpp1
-rw-r--r--sky/music/gmchannel.h4
-rw-r--r--sky/music/gmmusic.cpp7
-rw-r--r--sky/music/gmmusic.h8
-rw-r--r--sky/music/mt32music.cpp2
-rw-r--r--sky/music/mt32music.h7
-rw-r--r--sky/music/musicbase.cpp3
-rw-r--r--sky/music/musicbase.h5
-rw-r--r--sky/rnc_deco.h2
-rw-r--r--sky/screen.cpp38
-rw-r--r--sky/screen.h13
-rw-r--r--sky/sky.cpp77
-rw-r--r--sky/sky.h32
-rw-r--r--sky/skydefs.h2
-rw-r--r--sky/sound.cpp17
-rw-r--r--sky/sound.h6
-rw-r--r--sky/text.cpp50
-rw-r--r--sky/text.h7
40 files changed, 455 insertions, 348 deletions
diff --git a/sky/autoroute.cpp b/sky/autoroute.cpp
index 6605c1bd3a..278d1278ca 100644
--- a/sky/autoroute.cpp
+++ b/sky/autoroute.cpp
@@ -19,7 +19,12 @@
*
*/
-#include "autoroute.h"
+#include "common/util.h"
+#include "sky/autoroute.h"
+#include "sky/compact.h"
+#include "sky/grid.h"
+#include "sky/skydefs.h"
+#include "sky/struc.h"
#define ROUTE_GRID_WIDTH ((GAME_SCREEN_WIDTH/8)+2)
#define ROUTE_GRID_HEIGHT ((GAME_SCREEN_HEIGHT/8)+2)
diff --git a/sky/autoroute.h b/sky/autoroute.h
index e42eba4b77..e73d713761 100644
--- a/sky/autoroute.h
+++ b/sky/autoroute.h
@@ -23,12 +23,9 @@
#define AUTOROUTE_H
#include "stdafx.h"
-#include "sky/sky.h"
-#include "struc.h"
-#include "compact.h"
-#include "grid.h"
-#include "skydefs.h"
+#include "common/scummsys.h"
+struct Compact;
class SkyGrid;
class SkyAutoRoute {
diff --git a/sky/compact.cpp b/sky/compact.cpp
index f890f4ee19..0b377e7581 100644
--- a/sky/compact.cpp
+++ b/sky/compact.cpp
@@ -20,6 +20,7 @@
*/
#include "stdafx.h"
+#include "common/util.h"
#include "sky/compact.h"
#include "sky/compacts/0compact.h"
#include "sky/compacts/1compact.h"
@@ -65,7 +66,7 @@ uint16 *getGrafixPtr(Compact *cpt) {
error("::getGrafixPtr: request for AR pointer, extCompact is NULL, though.");
return (cpt->extCompact->animScratch + cpt->grafixProg.pos);
case COMPACT:
- buf = (uint16*)SkyState::fetchCompact(cpt->grafixProg.ptrTarget);
+ buf = (uint16*)SkyEngine::fetchCompact(cpt->grafixProg.ptrTarget);
if (buf == NULL)
error("::getGrafixPtr: request for cpt %d pointer. It's NULL.", cpt->grafixProg.ptrTarget);
return (buf + cpt->grafixProg.pos);
diff --git a/sky/compacts/savedata.cpp b/sky/compacts/savedata.cpp
index a976c483a1..29f18aa9a2 100644
--- a/sky/compacts/savedata.cpp
+++ b/sky/compacts/savedata.cpp
@@ -1,3 +1,25 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2003 The ScummVM project
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "sky/compact.h"
#include "sky/control.h"
Compact *SkyControl::_saveLoadCpts[833] = {
diff --git a/sky/control.cpp b/sky/control.cpp
index a3d2e3ba7e..0f1f6defb7 100644
--- a/sky/control.cpp
+++ b/sky/control.cpp
@@ -19,11 +19,21 @@
*
*/
+#include "common/file.h"
+#include "common/util.h"
+#include "common/system.h"
+#include "sky/compact.h"
#include "sky/control.h"
-#include "sky/skydefs.h"
+#include "sky/disk.h"
+#include "sky/logic.h"
+#include "sky/music/musicbase.h"
+#include "sky/mouse.h"
+#include "sky/screen.h"
#include "sky/sky.h"
-#include "common/file.h"
-#include "base/gameDetector.h"
+#include "sky/skydefs.h"
+#include "sky/sound.h"
+#include "sky/struc.h"
+#include "sky/text.h"
#ifdef _WIN32_WCE
extern void force_keyboard(bool);
@@ -233,7 +243,7 @@ void SkyControl::initPanel(void) {
memset(_screenBuf, 0, GAME_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
uint16 volY = (127 - _skyMusic->giveVolume()) / 4 + 59 - MPNL_Y; // volume slider's Y coordinate
- uint16 spdY = (SkyState::_systemVars.gameSpeed - 2) / SPEED_MULTIPLY;
+ uint16 spdY = (SkyEngine::_systemVars.gameSpeed - 2) / SPEED_MULTIPLY;
spdY += MPNL_Y + 83; // speed slider's initial position
_sprites.controlPanel = _skyDisk->loadFile(60500, NULL);
@@ -245,7 +255,7 @@ void SkyControl::initPanel(void) {
_sprites.slode = _skyDisk->loadFile(60506, NULL);
_sprites.slode2 = _skyDisk->loadFile(60507, NULL);
_sprites.slide2 = _skyDisk->loadFile(60508, NULL);
- if (SkyState::_systemVars.gameVersion < 368)
+ if (SkyEngine::_systemVars.gameVersion < 368)
_sprites.musicBodge = NULL;
else
_sprites.musicBodge = _skyDisk->loadFile(60509, NULL);
@@ -260,12 +270,12 @@ void SkyControl::initPanel(void) {
_savePanButton = createResource( _sprites.button, 3, 0, 58, 39, 48, SAVE_GAME_PANEL, MAINPANEL);
_dosPanButton = createResource( _sprites.button, 3, 0, 58, 59, 93, QUIT_TO_DOS, MAINPANEL);
_restartPanButton = createResource( _sprites.button, 3, 0, 58, 79, 94, RESTART, MAINPANEL);
- if (SkyState::_systemVars.systemFlags & SF_FX_OFF)
+ if (SkyEngine::_systemVars.systemFlags & SF_FX_OFF)
_fxPanButton = createResource( _sprites.button, 3, 0, 58, 99, 87, TOGGLE_FX, MAINPANEL);
else
_fxPanButton = createResource( _sprites.button, 3, 2, 58, 99, 86, TOGGLE_FX, MAINPANEL);
- if (SkyState::isCDVersion()) { // CD Version: Toggle text/speech
+ if (SkyEngine::isCDVersion()) { // CD Version: Toggle text/speech
_musicPanButton = createResource( _sprites.button, 3, 0, 58, 119, 52, TOGGLE_TEXT, MAINPANEL);
} else { // disk version: toggle music on/off
_musicPanButton = createResource( _sprites.button, 3, 0, 58, 119, 91, TOGGLE_MS, MAINPANEL);
@@ -396,17 +406,17 @@ void SkyControl::drawMainPanel(void) {
_slide->drawToScreen(WITH_MASK);
_slide2->drawToScreen(WITH_MASK);
_bodge->drawToScreen(WITH_MASK);
- if (SkyState::isCDVersion())
- drawTextCross(SkyState::_systemVars.systemFlags & TEXT_FLAG_MASK);
+ if (SkyEngine::isCDVersion())
+ drawTextCross(SkyEngine::_systemVars.systemFlags & TEXT_FLAG_MASK);
_statusBar->drawToScreen();
}
void SkyControl::doLoadSavePanel(void) {
- if (SkyState::isDemo())
+ if (SkyEngine::isDemo())
return; // I don't think this can even happen
initPanel();
_skyScreen->clearScreen();
- if (SkyState::_systemVars.gameVersion < 331)
+ if (SkyEngine::_systemVars.gameVersion < 331)
_skyScreen->setPalette(60509);
else
_skyScreen->setPalette(60510);
@@ -425,7 +435,7 @@ void SkyControl::doLoadSavePanel(void) {
_system->copy_rect(_screenBuf, GAME_SCREEN_WIDTH, 0, 0, GAME_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
_system->update_screen();
_skyScreen->forceRefresh();
- _skyScreen->setPaletteEndian((uint8 *)SkyState::fetchCompact(SkyState::_systemVars.currentPalette));
+ _skyScreen->setPaletteEndian((uint8 *)SkyEngine::fetchCompact(SkyEngine::_systemVars.currentPalette));
removePanel();
_skyMouse->spriteMouse(_savedMouse, 0, 0);
_skyText->fnSetFont(_savedCharSet);
@@ -433,7 +443,7 @@ void SkyControl::doLoadSavePanel(void) {
void SkyControl::doControlPanel(void) {
- if (SkyState::isDemo()) {
+ if (SkyEngine::isDemo()) {
return ;
}
initPanel();
@@ -442,7 +452,7 @@ void SkyControl::doControlPanel(void) {
_skyText->fnSetFont(0);
_skyScreen->clearScreen();
- if (SkyState::_systemVars.gameVersion < 331)
+ if (SkyEngine::_systemVars.gameVersion < 331)
_skyScreen->setPalette(60509);
else
_skyScreen->setPalette(60510);
@@ -491,7 +501,7 @@ void SkyControl::doControlPanel(void) {
_system->copy_rect(_screenBuf, GAME_SCREEN_WIDTH, 0, 0, GAME_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
_system->update_screen();
_skyScreen->forceRefresh();
- _skyScreen->setPaletteEndian((uint8 *)SkyState::fetchCompact(SkyState::_systemVars.currentPalette));
+ _skyScreen->setPaletteEndian((uint8 *)SkyEngine::fetchCompact(SkyEngine::_systemVars.currentPalette));
removePanel();
_skyMouse->spriteMouse(_savedMouse, 0, 0);
_skyText->fnSetFont(_savedCharSet);
@@ -679,14 +689,14 @@ uint16 SkyControl::doSpeedSlide(void) {
_text->drawToScreen(WITH_MASK);
_system->update_screen();
}
- SkyState::_systemVars.gameSpeed = speedDelay;
+ SkyEngine::_systemVars.gameSpeed = speedDelay;
return SPEED_CHANGED;
}
uint16 SkyControl::toggleFx(SkyConResource *pButton) {
- SkyState::_systemVars.systemFlags ^= SF_FX_OFF;
- if (SkyState::_systemVars.systemFlags & SF_FX_OFF) {
+ SkyEngine::_systemVars.systemFlags ^= SF_FX_OFF;
+ if (SkyEngine::_systemVars.systemFlags & SF_FX_OFF) {
pButton->_curSprite = 0;
pButton->_text = 0x7000 + 87;
_statusBar->setToText(0x7000 + 87);
@@ -703,8 +713,8 @@ uint16 SkyControl::toggleFx(SkyConResource *pButton) {
uint16 SkyControl::toggleText(void) {
- uint32 flags = SkyState::_systemVars.systemFlags & TEXT_FLAG_MASK;
- SkyState::_systemVars.systemFlags &= ~TEXT_FLAG_MASK;
+ uint32 flags = SkyEngine::_systemVars.systemFlags & TEXT_FLAG_MASK;
+ SkyEngine::_systemVars.systemFlags &= ~TEXT_FLAG_MASK;
if (flags == SF_ALLOW_TEXT) {
@@ -718,7 +728,7 @@ uint16 SkyControl::toggleText(void) {
_statusBar->setToText(0x7000 + 35); // text only
}
- SkyState::_systemVars.systemFlags |= flags;
+ SkyEngine::_systemVars.systemFlags |= flags;
drawTextCross(flags);
@@ -728,12 +738,12 @@ uint16 SkyControl::toggleText(void) {
void SkyControl::toggleMusic(void) {
- if (SkyState::_systemVars.systemFlags & SF_MUS_OFF) {
- SkyState::_systemVars.systemFlags &= ~SF_MUS_OFF;
- _skyMusic->startMusic(SkyState::_systemVars.currentMusic);
+ if (SkyEngine::_systemVars.systemFlags & SF_MUS_OFF) {
+ SkyEngine::_systemVars.systemFlags &= ~SF_MUS_OFF;
+ _skyMusic->startMusic(SkyEngine::_systemVars.currentMusic);
_statusBar->setToText(0x7000 + 88);
} else {
- SkyState::_systemVars.systemFlags |= SF_MUS_OFF;
+ SkyEngine::_systemVars.systemFlags |= SF_MUS_OFF;
_skyMusic->startMusic(0);
_statusBar->setToText(0x7000 + 89);
}
@@ -772,10 +782,10 @@ bool SkyControl::autoSaveExists(void) {
bool test = false;
SaveFile *f;
char fName[20];
- if (SkyState::isCDVersion())
+ if (SkyEngine::isCDVersion())
strcpy(fName, "SKY-VM-CD.ASD");
else
- sprintf(fName, "SKY-VM%03d.ASD", SkyState::_systemVars.gameVersion);
+ sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
SaveFileManager *mgr = _system->get_savefile_manager();
f = mgr->open_savefile(fName, _savePath, false);
if (f != NULL) {
@@ -1029,7 +1039,7 @@ void SkyControl::loadDescriptions(uint8 *destBuf) {
bool SkyControl::loadSaveAllowed(void) {
- if (SkyState::_systemVars.systemFlags & SF_CHOOSING)
+ if (SkyEngine::_systemVars.systemFlags & SF_CHOOSING)
return false; // texts get lost during load/save, so don't allow it during choosing
if (SkyLogic::_scriptVariables[SCREEN] >= 101)
return false; // same problem with LINC terminals
@@ -1072,10 +1082,10 @@ void SkyControl::saveDescriptions(uint8 *srcBuf) {
void SkyControl::doAutoSave(void) {
char fName[20];
- if (SkyState::isCDVersion())
+ if (SkyEngine::isCDVersion())
strcpy(fName, "SKY-VM-CD.ASD");
else
- sprintf(fName, "SKY-VM%03d.ASD", SkyState::_systemVars.gameVersion);
+ sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
SaveFile *outf;
SaveFileManager *mgr = _system->get_savefile_manager();
outf = mgr->open_savefile(fName, _savePath, true);
@@ -1242,14 +1252,14 @@ uint32 SkyControl::prepareSaveData(uint8 *destBuf) {
uint8 *destPos = destBuf + 4;
STOSD(destPos, SAVE_FILE_REVISION);
- STOSD(destPos, SkyState::_systemVars.gameVersion);
+ STOSD(destPos, SkyEngine::_systemVars.gameVersion);
STOSW(destPos, _skySound->_saveSounds[0]);
STOSW(destPos, _skySound->_saveSounds[1]);
STOSD(destPos, _skyMusic->giveCurrentMusic());
STOSD(destPos, _savedCharSet);
STOSD(destPos, _savedMouse);
- STOSD(destPos, SkyState::_systemVars.currentPalette);
+ STOSD(destPos, SkyEngine::_systemVars.currentPalette);
for (cnt = 0; cnt < 838; cnt++)
STOSD(destPos, SkyLogic::_scriptVariables[cnt]);
uint32 *loadedFilesList = _skyDisk->giveLoadedFilesList();
@@ -1436,10 +1446,10 @@ uint16 SkyControl::parseSaveData(uint8 *srcBuf) {
uint32 music, mouseType, palette, gameVersion;
LODSD(srcPos, gameVersion);
- if (gameVersion != SkyState::_systemVars.gameVersion) {
- if ((!SkyState::isCDVersion()) || (gameVersion < 365)) { // cd versions are compatible
+ if (gameVersion != SkyEngine::_systemVars.gameVersion) {
+ if ((!SkyEngine::isCDVersion()) || (gameVersion < 365)) { // cd versions are compatible
printf("This savegame was created by Beneath a Steel Sky v0.0%03d\n", gameVersion);
- printf("It cannot be loaded by this version (v0.0%3d)\n", SkyState::_systemVars.gameVersion);
+ printf("It cannot be loaded by this version (v0.0%3d)\n", SkyEngine::_systemVars.gameVersion);
return RESTORE_FAILED;
}
}
@@ -1476,17 +1486,17 @@ uint16 SkyControl::parseSaveData(uint8 *srcBuf) {
if (srcPos - srcBuf != (int32)size)
error("Restore failed! Savegame data = %d bytes. Expected size: %d", srcPos-srcBuf, size);
- SkyState::_systemVars.systemFlags |= SF_GAME_RESTORED;
- if (!SkyState::isDemo()) {
+ SkyEngine::_systemVars.systemFlags |= SF_GAME_RESTORED;
+ if (!SkyEngine::isDemo()) {
_skyLogic->fnLeaveSection(oldSection, 0, 0);
_skyLogic->fnEnterSection(SkyLogic::_scriptVariables[CUR_SECTION], 0, 0);
}
_skyDisk->refreshFilesList(reloadList);
- SkyState::_systemVars.currentMusic = (uint16)music;
- if (!(SkyState::_systemVars.systemFlags & SF_MUS_OFF))
+ SkyEngine::_systemVars.currentMusic = (uint16)music;
+ if (!(SkyEngine::_systemVars.systemFlags & SF_MUS_OFF))
_skyMusic->startMusic((uint16)music);
_savedMouse = (uint16)mouseType;
- SkyState::_systemVars.currentPalette = palette; // will be set when doControlPanel ends
+ SkyEngine::_systemVars.currentPalette = palette; // will be set when doControlPanel ends
return GAME_RESTORED;
}
@@ -1498,10 +1508,10 @@ uint16 SkyControl::restoreGameFromFile(bool autoSave) {
char fName[20];
if (autoSave) {
- if (SkyState::isCDVersion())
+ if (SkyEngine::isCDVersion())
strcpy(fName, "SKY-VM-CD.ASD");
else
- sprintf(fName, "SKY-VM%03d.ASD", SkyState::_systemVars.gameVersion);
+ sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion);
} else
sprintf(fName,"SKY-VM.%03d", _selectedGame);
@@ -1527,7 +1537,7 @@ uint16 SkyControl::restoreGameFromFile(bool autoSave) {
}
uint16 res = parseSaveData(saveData);
- SkyState::_systemVars.pastIntro = true;
+ SkyEngine::_systemVars.pastIntro = true;
delete inf;
delete mgr;
free(saveData);
@@ -1545,7 +1555,7 @@ uint16 SkyControl::quickXRestore(uint16 slot) {
_system->copy_rect(_screenBuf, GAME_SCREEN_WIDTH, 0, 0, FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
_system->update_screen();
- if (SkyState::_systemVars.gameVersion < 331)
+ if (SkyEngine::_systemVars.gameVersion < 331)
_skyScreen->setPalette(60509);
else
_skyScreen->setPalette(60510);
@@ -1563,7 +1573,7 @@ uint16 SkyControl::quickXRestore(uint16 slot) {
memset(_skyScreen->giveCurrent(), 0, GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT);
_skyScreen->showScreen(_skyScreen->giveCurrent());
_skyScreen->forceRefresh();
- _skyScreen->setPaletteEndian((uint8 *)SkyState::fetchCompact(SkyState::_systemVars.currentPalette));
+ _skyScreen->setPaletteEndian((uint8 *)SkyEngine::fetchCompact(SkyEngine::_systemVars.currentPalette));
} else {
memset(_screenBuf, 0, FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
_system->copy_rect(_screenBuf, GAME_SCREEN_WIDTH, 0, 0, GAME_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
@@ -1625,11 +1635,11 @@ void SkyControl::applyDiff(uint16 *data, uint16 *diffData, uint16 len) {
}
void SkyControl::restartGame(void) {
- if (SkyState::_systemVars.gameVersion <= 267)
+ if (SkyEngine::_systemVars.gameVersion <= 267)
return; // no restart for floppy demo
uint16 *resetData = lz77decode((uint16 *)_resetData288);
- switch (SkyState::_systemVars.gameVersion) {
+ switch (SkyEngine::_systemVars.gameVersion) {
case 303:
applyDiff(resetData, (uint16*)_resetDiff303, 206);
break;
@@ -1653,9 +1663,9 @@ void SkyControl::restartGame(void) {
_skyScreen->forceRefresh();
memset(_skyScreen->giveCurrent(), 0, GAME_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
_skyScreen->showScreen(_skyScreen->giveCurrent());
- _skyScreen->setPaletteEndian((uint8 *)SkyState::fetchCompact(SkyState::_systemVars.currentPalette));
+ _skyScreen->setPaletteEndian((uint8 *)SkyEngine::fetchCompact(SkyEngine::_systemVars.currentPalette));
_skyMouse->spriteMouse(_savedMouse, 0, 0);
- SkyState::_systemVars.pastIntro = true;
+ SkyEngine::_systemVars.pastIntro = true;
}
void SkyControl::delay(unsigned int amount) {
@@ -1693,7 +1703,7 @@ void SkyControl::delay(unsigned int amount) {
case OSystem::EVENT_RBUTTONDOWN:
break;
case OSystem::EVENT_QUIT:
- if (!SkyState::_systemVars.quitting)
+ if (!SkyEngine::_systemVars.quitting)
showGameQuitMsg(false);
break;
default:
@@ -1716,7 +1726,7 @@ void SkyControl::delay(unsigned int amount) {
void SkyControl::showGameQuitMsg(bool useScreen) {
- SkyState::_systemVars.quitting = true;
+ SkyEngine::_systemVars.quitting = true;
_skyText->fnSetFont(0);
uint8 *textBuf1 = (uint8 *)malloc(GAME_SCREEN_WIDTH * 14 + sizeof(dataFileHeader));
uint8 *textBuf2 = (uint8 *)malloc(GAME_SCREEN_WIDTH * 14 + sizeof(dataFileHeader));
@@ -1728,8 +1738,8 @@ void SkyControl::showGameQuitMsg(bool useScreen) {
screenData = _skyScreen->giveCurrent();
} else
screenData = _screenBuf;
- _skyText->displayText(_quitTexts[SkyState::_systemVars.language * 2 + 0], textBuf1, true, 320, 255);
- _skyText->displayText(_quitTexts[SkyState::_systemVars.language * 2 + 1], textBuf2, true, 320, 255);
+ _skyText->displayText(_quitTexts[SkyEngine::_systemVars.language * 2 + 0], textBuf1, true, 320, 255);
+ _skyText->displayText(_quitTexts[SkyEngine::_systemVars.language * 2 + 1], textBuf2, true, 320, 255);
uint8 *curLine1 = textBuf1 + sizeof(dataFileHeader);
uint8 *curLine2 = textBuf2 + sizeof(dataFileHeader);
uint8 *targetLine = screenData + GAME_SCREEN_WIDTH * 80;
diff --git a/sky/control.h b/sky/control.h
index c3a1c3e762..7fae6b948a 100644
--- a/sky/control.h
+++ b/sky/control.h
@@ -24,16 +24,18 @@
#include "common/stdafx.h"
#include "common/scummsys.h"
-#include "sky/struc.h"
-#include "base/engine.h"
-#include "sky/screen.h"
-#include "sky/disk.h"
-#include "sky/mouse.h"
-#include "sky/logic.h"
+class SkyDisk;
class SkyScreen;
class SkyLogic;
class SkyMouse;
+class SkyText;
+class SkyMusicBase;
+class SkySound;
+class OSystem;
+struct Compact;
+struct dataFileHeader;
+struct MegaSet;
#define MAX_SAVE_GAMES 999
#define MAX_TEXT_LEN 80
diff --git a/sky/debug.cpp b/sky/debug.cpp
index cb7ddb067f..65015ee264 100644
--- a/sky/debug.cpp
+++ b/sky/debug.cpp
@@ -20,6 +20,7 @@
*/
#include "stdafx.h"
+#include "common/util.h"
#include "sky/debug.h"
static const char *section_0_compacts[] = {
diff --git a/sky/debug.h b/sky/debug.h
index 1e36e7c1b5..8f0de080fe 100644
--- a/sky/debug.h
+++ b/sky/debug.h
@@ -19,7 +19,11 @@
*
*/
-#include "sky/sky.h"
+#ifndef SKY_DEBUG_H
+#define SKY_DEBUG_H
+
+#include "stdafx.h"
+#include "common/scummsys.h"
class SkyDebug {
public:
@@ -29,3 +33,4 @@ public:
static void mcode(uint32 mcode, uint32 a, uint32 b, uint32 c);
};
+#endif
diff --git a/sky/disk.cpp b/sky/disk.cpp
index 59f7b5810f..0bc256c22f 100644
--- a/sky/disk.cpp
+++ b/sky/disk.cpp
@@ -20,12 +20,13 @@
*/
#include "stdafx.h"
+#include "common/file.h"
+#include "common/util.h"
#include "common/scummsys.h"
-#include "base/engine.h"
#include "sky/disk.h"
-#include "sky/skydefs.h"
-#include "sky/sky.h"
#include "sky/rnc_deco.h"
+#include "sky/sky.h"
+#include "sky/struc.h"
static const char *dataFilename = "sky.dsk";
static const char *dinnerFilename = "sky.dnr";
@@ -138,7 +139,7 @@ uint8 *SkyDisk::loadFile(uint16 fileNr, uint8 *dest) {
_fileOffset &= 0x7FFFFF;
if (cflag) {
- if (SkyState::_systemVars.gameVersion == 331)
+ if (SkyEngine::_systemVars.gameVersion == 331)
_fileOffset <<= 3;
else
_fileOffset <<= 4;
@@ -295,7 +296,7 @@ void SkyDisk::fnCacheChip(uint32 list) {
// fnCacheChip is called after fnCacheFast
uint16 cnt = 0;
while (_buildList[cnt]) cnt++;
- uint16 *fList = (uint16 *)SkyState::fetchCompact(list);
+ uint16 *fList = (uint16 *)SkyEngine::fetchCompact(list);
uint16 fCnt = 0;
do {
_buildList[cnt + fCnt] = fList[fCnt] & 0x7FFFU;
@@ -308,7 +309,7 @@ void SkyDisk::fnCacheFast(uint32 list) {
if (list == 0) return;
uint8 cnt = 0;
- uint16 *fList = (uint16 *)SkyState::fetchCompact(list);
+ uint16 *fList = (uint16 *)SkyEngine::fetchCompact(list);
do {
_buildList[cnt] = fList[cnt] & 0x7FFFU;
cnt++;
@@ -331,8 +332,8 @@ void SkyDisk::fnCacheFiles(void) {
_loadedFilesList[targCnt] = _loadedFilesList[lCnt];
targCnt++;
} else {
- free(SkyState::_itemList[_loadedFilesList[lCnt] & 2047]);
- SkyState::_itemList[_loadedFilesList[lCnt] & 2047] = NULL;
+ free(SkyEngine::_itemList[_loadedFilesList[lCnt] & 2047]);
+ SkyEngine::_itemList[_loadedFilesList[lCnt] & 2047] = NULL;
}
lCnt++;
}
@@ -358,8 +359,8 @@ void SkyDisk::fnCacheFiles(void) {
_loadedFilesList[targCnt] = _buildList[bCnt] & 0x7FFFU;
targCnt++;
_loadedFilesList[targCnt] = 0;
- SkyState::_itemList[_buildList[bCnt] & 2047] = (void**)loadFile(_buildList[bCnt] & 0x7FFF, NULL);
- if (!SkyState::_itemList[_buildList[bCnt] & 2047])
+ SkyEngine::_itemList[_buildList[bCnt] & 2047] = (void**)loadFile(_buildList[bCnt] & 0x7FFF, NULL);
+ if (!SkyEngine::_itemList[_buildList[bCnt] & 2047])
warning("fnCacheFiles: SkyDisk::loadFile() returned NULL for file %d",_buildList[bCnt] & 0x7FFF);
bCnt++;
}
@@ -370,15 +371,15 @@ void SkyDisk::refreshFilesList(uint32 *list) {
uint8 cnt = 0;
while (_loadedFilesList[cnt]) {
- if (SkyState::_itemList[_loadedFilesList[cnt] & 2047])
- free(SkyState::_itemList[_loadedFilesList[cnt] & 2047]);
- SkyState::_itemList[_loadedFilesList[cnt] & 2047] = NULL;
+ if (SkyEngine::_itemList[_loadedFilesList[cnt] & 2047])
+ free(SkyEngine::_itemList[_loadedFilesList[cnt] & 2047]);
+ SkyEngine::_itemList[_loadedFilesList[cnt] & 2047] = NULL;
cnt++;
}
cnt = 0;
while (list[cnt]) {
_loadedFilesList[cnt] = list[cnt];
- SkyState::_itemList[_loadedFilesList[cnt] & 2047] = (void**)loadFile((uint16)(_loadedFilesList[cnt] & 0x7FFF), NULL);
+ SkyEngine::_itemList[_loadedFilesList[cnt] & 2047] = (void**)loadFile((uint16)(_loadedFilesList[cnt] & 0x7FFF), NULL);
cnt++;
}
_loadedFilesList[cnt] = 0;
@@ -393,7 +394,7 @@ void SkyDisk::fnMiniLoad(uint16 fileNum) {
}
_loadedFilesList[cnt] = fileNum & 0x7FFFU;
_loadedFilesList[cnt + 1] = 0;
- SkyState::_itemList[fileNum & 2047] = (void**)loadFile(fileNum, NULL);
+ SkyEngine::_itemList[fileNum & 2047] = (void**)loadFile(fileNum, NULL);
}
void SkyDisk::fnFlushBuffers(void) {
@@ -401,8 +402,8 @@ void SkyDisk::fnFlushBuffers(void) {
// dump all loaded sprites
uint8 lCnt = 0;
while (_loadedFilesList[lCnt]) {
- free(SkyState::_itemList[_loadedFilesList[lCnt] & 2047]);
- SkyState::_itemList[_loadedFilesList[lCnt] & 2047] = 0;
+ free(SkyEngine::_itemList[_loadedFilesList[lCnt] & 2047]);
+ SkyEngine::_itemList[_loadedFilesList[lCnt] & 2047] = 0;
lCnt++;
}
_loadedFilesList[0] = 0;
diff --git a/sky/disk.h b/sky/disk.h
index f382ba79bd..eaf9be4e58 100644
--- a/sky/disk.h
+++ b/sky/disk.h
@@ -22,7 +22,10 @@
#ifndef SKYDISK_H
#define SKYDISK_H
-#include "common/file.h"
+#include "stdafx.h"
+#include "common/scummsys.h"
+
+class File;
#define MAX_FILES_IN_LIST 60
diff --git a/sky/grid.cpp b/sky/grid.cpp
index 9a26876e19..1069e6f936 100644
--- a/sky/grid.cpp
+++ b/sky/grid.cpp
@@ -19,8 +19,10 @@
*
*/
-#include "grid.h"
-#include "compact.h"
+#include "sky/compact.h"
+#include "sky/disk.h"
+#include "sky/grid.h"
+#include "sky/logic.h"
#define GRID_FILE_START 60000
@@ -141,7 +143,7 @@ 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));
- if (!SkyState::isDemo()) { // single disk demos never get that far
+ if (!SkyEngine::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])
diff --git a/sky/grid.h b/sky/grid.h
index e214415aca..b71554cc28 100644
--- a/sky/grid.h
+++ b/sky/grid.h
@@ -23,9 +23,10 @@
#define SKYGRID_H
#include "stdafx.h"
-#include "disk.h"
-#include "struc.h"
-#include "compact.h"
+#include "common/scummsys.h"
+
+struct Compact;
+class SkyDisk;
class SkyGrid {
public:
diff --git a/sky/intro.cpp b/sky/intro.cpp
index 8f8ce3e200..3093702b79 100644
--- a/sky/intro.cpp
+++ b/sky/intro.cpp
@@ -20,8 +20,15 @@
*/
#include "stdafx.h"
+#include "common/util.h"
+#include "sky/disk.h"
#include "sky/intro.h"
+#include "sky/music/musicbase.h"
+#include "sky/screen.h"
#include "sky/sky.h"
+#include "sky/sound.h"
+#include "sky/struc.h"
+#include "sky/text.h"
#define SHOWSCREEN 0
#define COMMANDEND 0 // end of COMMANDFLIRT block
@@ -631,7 +638,7 @@ SkyIntro::~SkyIntro(void) {
bool SkyIntro::doIntro(bool floppyIntro) {
- if (!SkyState::isCDVersion())
+ if (!SkyEngine::isCDVersion())
floppyIntro = true;
_skyDisk->prefetchFile(60112);
diff --git a/sky/intro.h b/sky/intro.h
index 396cab5e50..e26f5b961d 100644
--- a/sky/intro.h
+++ b/sky/intro.h
@@ -22,8 +22,15 @@
#ifndef INTRO_H
#define INTRO_H
-#include "sky/screen.h"
-#include "sky/disk.h"
+#include "stdafx.h"
+#include "common/scummsys.h"
+#include "sound/mixer.h"
+
+class SkyDisk;
+class SkyScreen;
+class SkyMusicBase;
+class SkySound;
+class SkyText;
class SkyIntro {
public:
diff --git a/sky/logic.cpp b/sky/logic.cpp
index ab6d75b6d0..d83157204f 100644
--- a/sky/logic.cpp
+++ b/sky/logic.cpp
@@ -20,12 +20,25 @@
*/
#include "stdafx.h"
-#include "sky/logic.h"
-#include "sky/debug.h"
+#include "sky/autoroute.h"
#include "sky/compact.h"
-#include "sky/skydefs.h"
+#include "sky/control.h"
+#include "sky/debug.h"
+#include "sky/disk.h"
+#include "sky/grid.h"
+#include "sky/logic.h"
+#include "sky/mouse.h"
+#include "sky/music/musicbase.h"
+#include "sky/text.h"
+#include "sky/screen.h"
+#include "sky/sky.h"
+#include "sky/sound.h"
+#include "sky/struc.h"
#include "sky/talks.h"
+/*
+#include "sky/skydefs.h"
#include "base/gameDetector.h"
+*/
uint32 SkyLogic::_scriptVariables[838];
@@ -85,17 +98,17 @@ bool SkyLogic::checkProtection(void) {
}
void SkyLogic::engine() {
- uint16 *logicList = (uint16 *)SkyState::fetchCompact(_scriptVariables[LOGIC_LIST_NO]);
+ uint16 *logicList = (uint16 *)SkyEngine::fetchCompact(_scriptVariables[LOGIC_LIST_NO]);
while (uint16 id = *logicList++) { // 0 means end of list
if (id == 0xffff) {
// Change logic data address
- logicList = (uint16 *)SkyState::fetchCompact(*logicList);
+ logicList = (uint16 *)SkyEngine::fetchCompact(*logicList);
continue;
}
_scriptVariables[CUR_ID] = id;
- _compact = SkyState::fetchCompact(id);
+ _compact = SkyEngine::fetchCompact(id);
// check the id actually wishes to be processed
if (!(_compact->status & (1 << 6)))
@@ -191,7 +204,7 @@ void SkyLogic::arAnim() {
// fine because the later collision will almost certainly
// take longer to clear than the earlier one.
- if (collide(SkyState::fetchCompact(_compact->extCompact->waitingFor))) {
+ if (collide(SkyEngine::fetchCompact(_compact->extCompact->waitingFor))) {
stopAndWait();
return;
}
@@ -204,13 +217,13 @@ void SkyLogic::arAnim() {
// ok, our turn to check for collisions
- uint16 *logicList = (uint16 *)SkyState::fetchCompact(_scriptVariables[LOGIC_LIST_NO]);
+ uint16 *logicList = (uint16 *)SkyEngine::fetchCompact(_scriptVariables[LOGIC_LIST_NO]);
Compact *cpt = 0;
while (uint16 id = *logicList++) { // get an id
if (id == 0xffff) { // address change?
- logicList = (uint16 *)SkyState::fetchCompact(*logicList); // get new logic list
+ logicList = (uint16 *)SkyEngine::fetchCompact(*logicList); // get new logic list
continue;
}
@@ -218,7 +231,7 @@ void SkyLogic::arAnim() {
continue;
_scriptVariables[HIT_ID] = id; // save target id for any possible c_mini_bump
- cpt = SkyState::fetchCompact(id); // let's have a closer look
+ cpt = SkyEngine::fetchCompact(id); // let's have a closer look
if (!(cpt->status & (1 << ST_COLLISION_BIT))) // can it collide?
continue;
@@ -381,7 +394,7 @@ void SkyLogic::anim() {
} else if (*grafixProg >= LF_START_FX) { // do sync
grafixProg++;
- Compact *cpt = SkyState::fetchCompact(*grafixProg++);
+ Compact *cpt = SkyEngine::fetchCompact(*grafixProg++);
cpt->sync = *grafixProg++;
} else { // put coordinates and frame in
@@ -484,13 +497,13 @@ void SkyLogic::talk() {
if (_skyMouse->wasClicked())
for (int i = 0; i < ARRAYSIZE(clickTable); i++)
if (clickTable[i] == (uint16)_scriptVariables[CUR_ID]) {
- if ((SkyState::_systemVars.systemFlags & SF_ALLOW_SPEECH) && (!_skySound->speechFinished()))
+ if ((SkyEngine::_systemVars.systemFlags & SF_ALLOW_SPEECH) && (!_skySound->speechFinished()))
_skySound->stopSpeech();
- if ((SkyState::_systemVars.systemFlags & SF_ALLOW_TEXT) &&
+ if ((SkyEngine::_systemVars.systemFlags & SF_ALLOW_TEXT) &&
(_compact->extCompact->spTextId > 0) &&
(_compact->extCompact->spTextId < 0xFFFF)) {
- SkyState::fetchCompact(_compact->extCompact->spTextId)->status = 0;
+ SkyEngine::fetchCompact(_compact->extCompact->spTextId)->status = 0;
}
if (SkyCompact::getGrafixPtr(_compact)) {
_compact->frame = _compact->getToFlag; // set character to stand
@@ -542,7 +555,7 @@ void SkyLogic::talk() {
// ok, speech has finished
if (_compact->extCompact->spTextId) {
- Compact *cpt = SkyState::fetchCompact(_compact->extCompact->spTextId); // get text id to kill
+ Compact *cpt = SkyEngine::fetchCompact(_compact->extCompact->spTextId); // get text id to kill
cpt->status = 0; // kill the text
}
@@ -554,7 +567,7 @@ void SkyLogic::talk() {
void SkyLogic::listen() {
/// Stay in this mode until id in getToFlag leaves L_TALK mode
- Compact *cpt = SkyState::fetchCompact(_compact->flag);
+ Compact *cpt = SkyEngine::fetchCompact(_compact->flag);
if (cpt->logic == L_TALK)
return;
@@ -570,7 +583,7 @@ void SkyLogic::stopped() {
/// that will be one level higher than the script we
/// would wish to restart from
- Compact *cpt = SkyState::fetchCompact(_compact->extCompact->waitingFor);
+ Compact *cpt = SkyEngine::fetchCompact(_compact->extCompact->waitingFor);
if (cpt)
if (!cpt->mood && collide(cpt))
@@ -593,7 +606,7 @@ void SkyLogic::choose() {
fnNoHuman(0, 0, 0); // kill mouse again
- SkyState::_systemVars.systemFlags &= ~SF_CHOOSING; // restore save/restore
+ SkyEngine::_systemVars.systemFlags &= ~SF_CHOOSING; // restore save/restore
_compact->logic = L_SCRIPT; // and continue script
logicScript();
@@ -653,7 +666,7 @@ void SkyLogic::simpleAnim() {
grafixProg++;
// *grafix_prog: id to sync
- Compact *compact2 = SkyState::fetchCompact(*grafixProg);
+ Compact *compact2 = SkyEngine::fetchCompact(*grafixProg);
grafixProg++;
// *grafix_prog: sync
@@ -1131,7 +1144,7 @@ void SkyLogic::initScriptVariables() {
_scriptVariables[820] = 1;
_scriptVariables[821] = 1;
- if (SkyState::_systemVars.gameVersion == 288)
+ if (SkyEngine::_systemVars.gameVersion == 288)
memcpy(_scriptVariables + 352, forwardList1b288, sizeof(forwardList1b288));
else
memcpy(_scriptVariables + 352, forwardList1b, sizeof(forwardList1b));
@@ -1350,7 +1363,7 @@ bool SkyLogic::fnCacheFast(uint32 a, uint32 b, uint32 c) {
bool SkyLogic::fnDrawScreen(uint32 a, uint32 b, uint32 c) {
debug(5, "Call: fnDrawScreen(%X, %X)",a,b);
- SkyState::_systemVars.currentPalette = a;
+ SkyEngine::_systemVars.currentPalette = a;
_skyScreen->fnDrawScreen(a, b);
return true;
}
@@ -1383,7 +1396,7 @@ bool SkyLogic::fnIdle(uint32 a, uint32 b, uint32 c) {
bool SkyLogic::fnInteract(uint32 targetId, uint32 b, uint32 c) {
_compact->mode += 4; // next level up
_compact->logic = L_SCRIPT;
- Compact *cpt = SkyState::fetchCompact(targetId);
+ Compact *cpt = SkyEngine::fetchCompact(targetId);
*SkyCompact::getSub(_compact, _compact->mode) = cpt->actionScript;
*SkyCompact::getSub(_compact, _compact->mode + 2) = 0;
@@ -1399,7 +1412,7 @@ bool SkyLogic::fnStartSub(uint32 scr, uint32 b, uint32 c) {
}
bool SkyLogic::fnTheyStartSub(uint32 mega, uint32 scr, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(mega);
+ Compact *cpt = SkyEngine::fetchCompact(mega);
cpt->mode += 4;
*SkyCompact::getSub(cpt, cpt->mode) = (uint16)(scr & 0xffff);
*SkyCompact::getSub(cpt, cpt->mode + 2) = (uint16)(scr >> 16);
@@ -1407,7 +1420,7 @@ bool SkyLogic::fnTheyStartSub(uint32 mega, uint32 scr, uint32 c) {
}
bool SkyLogic::fnAssignBase(uint32 id, uint32 scr, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
cpt->mode = C_BASE_MODE;
cpt->logic = L_SCRIPT;
cpt->baseSub = (uint16)(scr & 0xffff);
@@ -1471,7 +1484,7 @@ bool SkyLogic::fnCloseHand(uint32 a, uint32 b, uint32 c) {
bool SkyLogic::fnGetTo(uint32 targetPlaceId, uint32 mode, uint32 c) {
_compact->upFlag = (uint16)mode; // save mode for action script
_compact->mode += 4; // next level up
- Compact *cpt = SkyState::fetchCompact(_compact->place);
+ Compact *cpt = SkyEngine::fetchCompact(_compact->place);
if (!cpt) {
warning("can't find _compact's getToTable. Place compact is NULL");
return false;
@@ -1552,7 +1565,7 @@ bool SkyLogic::fnSetAlternate(uint32 scr, uint32 b, uint32 c) {
}
bool SkyLogic::fnAltSetAlternate(uint32 target, uint32 scr, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(target);
+ Compact *cpt = SkyEngine::fetchCompact(target);
cpt->extCompact->alt = (uint16)(scr & 0xffff);
cpt->logic = L_ALT;
return false;
@@ -1560,7 +1573,7 @@ bool SkyLogic::fnAltSetAlternate(uint32 target, uint32 scr, uint32 c) {
bool SkyLogic::fnKillId(uint32 id, uint32 b, uint32 c) {
if (id) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
if (cpt->status & (1 << 7))
_skyGrid->removeObjectFromWalk(cpt);
cpt->status = 0;
@@ -1613,7 +1626,7 @@ bool SkyLogic::fnQuit(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnSpeakMe(uint32 targetId, uint32 mesgNum, uint32 animNum) {
- stdSpeak(SkyState::fetchCompact(targetId), mesgNum, animNum, 0);
+ stdSpeak(SkyEngine::fetchCompact(targetId), mesgNum, animNum, 0);
return false; //drop out of script
}
@@ -1652,7 +1665,7 @@ bool SkyLogic::fnSpeakWaitDir(uint32 a, uint32 b, uint32 c) {
_compact->flag = (uint16)a;
_compact->logic = L_LISTEN;
- Compact *speaker = SkyState::fetchCompact(a);
+ Compact *speaker = SkyEngine::fetchCompact(a);
if (c) {
c += speaker->extCompact->dir << 1;
stdSpeak(speaker, b, c, speaker->extCompact->dir << 1);
@@ -1667,7 +1680,7 @@ bool SkyLogic::fnChooser(uint32 a, uint32 b, uint32 c) {
// setup the text questions to be clicked on
// read from TEXT1 until 0
- SkyState::_systemVars.systemFlags |= SF_CHOOSING; // can't save/restore while choosing
+ SkyEngine::_systemVars.systemFlags |= SF_CHOOSING; // can't save/restore while choosing
_scriptVariables[THE_CHOSEN_ONE] = 0; // clear result
@@ -1697,7 +1710,7 @@ bool SkyLogic::fnChooser(uint32 a, uint32 b, uint32 c) {
index += 2;
}
- Compact *textCompact = SkyState::fetchCompact(lowText.compactNum);
+ Compact *textCompact = SkyEngine::fetchCompact(lowText.compactNum);
textCompact->getToFlag = (uint16)textNum;
textCompact->downFlag = (uint16)*p++; // get animation number
@@ -1722,8 +1735,8 @@ bool SkyLogic::fnHighlight(uint32 itemNo, uint32 pen, uint32 c) {
pen -= 11;
pen ^= 1;
pen += 241;
- Compact *textCompact = SkyState::fetchCompact(itemNo);
- uint8 *sprData = (uint8 *)SkyState::fetchItem(textCompact->flag);
+ Compact *textCompact = SkyEngine::fetchCompact(itemNo);
+ uint8 *sprData = (uint8 *)SkyEngine::fetchItem(textCompact->flag);
_skyText->changeTextSpriteColour(sprData, (uint8)pen);
return true;
}
@@ -1734,7 +1747,7 @@ bool SkyLogic::fnTextKill(uint32 a, uint32 b, uint32 c) {
uint32 id = FIRST_TEXT_COMPACT;
for (int i = 10; i > 0; i--) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
if (cpt->status & (1 << 4))
cpt->status = 0;
id++;
@@ -1757,25 +1770,25 @@ bool SkyLogic::fnWeWait(uint32 id, uint32 b, uint32 c) {
}
bool SkyLogic::fnSendSync(uint32 mega, uint32 sync, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(mega);
+ Compact *cpt = SkyEngine::fetchCompact(mega);
cpt->sync = (uint16)(sync & 0xffff);
return false;
}
bool SkyLogic::fnSendFastSync(uint32 mega, uint32 sync, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(mega);
+ Compact *cpt = SkyEngine::fetchCompact(mega);
cpt->sync = (uint16)(sync & 0xffff);
return true;
}
bool SkyLogic::fnSendRequest(uint32 target, uint32 scr, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(target);
+ Compact *cpt = SkyEngine::fetchCompact(target);
cpt->extCompact->request = (uint16)(scr & 0xffff);
return false;
}
bool SkyLogic::fnClearRequest(uint32 target, uint32 b, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(target);
+ Compact *cpt = SkyEngine::fetchCompact(target);
cpt->extCompact->request = 0;
return true;
}
@@ -1804,11 +1817,11 @@ bool SkyLogic::fnStartMenu(uint32 firstObject, uint32 b, uint32 c) {
// (1) FIRST, SET UP THE 2 ARROWS SO THEY APPEAR ON SCREEN
- Compact *cpt = SkyState::fetchCompact(47);
+ Compact *cpt = SkyEngine::fetchCompact(47);
cpt->status = ST_MOUSE + ST_FOREGROUND + ST_LOGIC + ST_RECREATE;
cpt->screen = (uint16)(_scriptVariables[SCREEN] & 0xffff);
- cpt = SkyState::fetchCompact(48);
+ cpt = SkyEngine::fetchCompact(48);
cpt->status = ST_MOUSE + ST_FOREGROUND + ST_LOGIC + ST_RECREATE;
cpt->screen = (uint16)(_scriptVariables[SCREEN] & 0xffff);
@@ -1834,7 +1847,7 @@ bool SkyLogic::fnStartMenu(uint32 firstObject, uint32 b, uint32 c) {
for (i = 0; i < ARRAYSIZE(_objectList); i++) {
if (_objectList[i])
- (SkyState::fetchCompact(_objectList[i]))->status = ST_LOGIC;
+ (SkyEngine::fetchCompact(_objectList[i]))->status = ST_LOGIC;
else break;
}
@@ -1849,7 +1862,7 @@ bool SkyLogic::fnStartMenu(uint32 firstObject, uint32 b, uint32 c) {
uint16 rollingX = TOP_LEFT_X + 28;
for (i = 0; i < 11; i++) {
- cpt = SkyState::fetchCompact(
+ cpt = SkyEngine::fetchCompact(
_objectList[_scriptVariables[SCROLL_OFFSET] + i]);
cpt->status = ST_MOUSE + ST_FOREGROUND + ST_LOGIC + ST_RECREATE;
@@ -1868,7 +1881,7 @@ bool SkyLogic::fnStartMenu(uint32 firstObject, uint32 b, uint32 c) {
}
bool SkyLogic::fnUnhighlight(uint32 item, uint32 b, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(item);
+ Compact *cpt = SkyEngine::fetchCompact(item);
cpt->frame--;
cpt->getToFlag = 0;
return true;
@@ -1878,7 +1891,7 @@ bool SkyLogic::fnFaceId(uint32 otherId, uint32 b, uint32 c) {
/// return the direction to turn to face another id
/// pass back result in c_just_flag
- Compact *cpt = SkyState::fetchCompact(otherId);
+ Compact *cpt = SkyEngine::fetchCompact(otherId);
int16 x = _compact->xcood - cpt->xcood;
@@ -1911,7 +1924,7 @@ bool SkyLogic::fnFaceId(uint32 otherId, uint32 b, uint32 c) {
bool SkyLogic::fnForeground(uint32 sprite, uint32 b, uint32 c) {
/// Make sprite a foreground sprite
- Compact *cpt = SkyState::fetchCompact(sprite);
+ Compact *cpt = SkyEngine::fetchCompact(sprite);
cpt->status &= 0xfff8;
cpt->status |= ST_FOREGROUND;
return true;
@@ -1926,14 +1939,14 @@ bool SkyLogic::fnBackground(uint32 a, uint32 b, uint32 c) {
bool SkyLogic::fnNewBackground(uint32 sprite, uint32 b, uint32 c) {
/// Make sprite a background sprite
- Compact *cpt = SkyState::fetchCompact(sprite);
+ Compact *cpt = SkyEngine::fetchCompact(sprite);
cpt->status &= 0xfff8;
cpt->status |= ST_BACKGROUND;
return true;
}
bool SkyLogic::fnSort(uint32 mega, uint32 b, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(mega);
+ Compact *cpt = SkyEngine::fetchCompact(mega);
cpt->status &= 0xfff8;
cpt->status |= ST_SORT;
return true;
@@ -1949,7 +1962,7 @@ bool SkyLogic::fnNoSpriteEngine(uint32 a, uint32 b, uint32 c) {
bool SkyLogic::fnNoSpritesA6(uint32 us, uint32 b, uint32 c) {
/// stop the compact printing
/// remove foreground, background & sort
- Compact *cpt = SkyState::fetchCompact(us);
+ Compact *cpt = SkyEngine::fetchCompact(us);
cpt->status &= 0xfff8;
return true;
}
@@ -1959,8 +1972,8 @@ bool SkyLogic::fnResetId(uint32 id, uint32 resetBlock, uint32 c) {
/// eg - when a smaller mega turn to larger
/// - a mega changes rooms...
- Compact *cpt = SkyState::fetchCompact(id);
- uint16 *rst = (uint16 *)SkyState::fetchCompact(resetBlock);
+ Compact *cpt = SkyEngine::fetchCompact(id);
+ uint16 *rst = (uint16 *)SkyEngine::fetchCompact(resetBlock);
if (!cpt) {
warning("fnResetId(): Compact %d (id) == NULL",id);
@@ -1995,7 +2008,7 @@ bool SkyLogic::fnRunAnimMod(uint32 animNo, uint32 b, uint32 c) {
_compact->grafixProg.ptrTarget = animNo;
_compact->grafixProg.pos = 0;
- //uint16 *animation = (uint16 *)SkyState::fetchCompact(animNo);
+ //uint16 *animation = (uint16 *)SkyEngine::fetchCompact(animNo);
//uint16 sprite = *animation++; // get sprite set
//_compact->offset = sprite;
_compact->offset = *SkyCompact::getGrafixPtr(_compact);
@@ -2011,7 +2024,7 @@ bool SkyLogic::fnSimpleMod(uint32 animSeqNo, uint32 b, uint32 c) {
_compact->grafixProg.ptrType = COMPACT;
_compact->grafixProg.ptrTarget = animSeqNo;
_compact->grafixProg.pos = 0;
- //uint16 *animSeq = (uint16 *)SkyState::fetchCompact(animSeqNo);
+ //uint16 *animSeq = (uint16 *)SkyEngine::fetchCompact(animSeqNo);
//_compact->offset = *animSeq++;
//assert(*animSeq != 0);
_compact->offset = *SkyCompact::getGrafixPtr(_compact);
@@ -2026,7 +2039,7 @@ bool SkyLogic::fnRunFrames(uint32 sequenceNo, uint32 b, uint32 c) {
_compact->grafixProg.ptrType = COMPACT;
_compact->grafixProg.ptrTarget = sequenceNo;
_compact->grafixProg.pos = 0;
- //uint16 *sequence = (uint16 *)SkyState::fetchCompact(sequenceNo);
+ //uint16 *sequence = (uint16 *)SkyEngine::fetchCompact(sequenceNo);
_compact->logic = L_FRAMES;
//_compact->offset = *sequence++;
@@ -2056,7 +2069,7 @@ bool SkyLogic::fnDecMegaSet(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnSetMegaSet(uint32 mega, uint32 setNo, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(mega);
+ Compact *cpt = SkyEngine::fetchCompact(mega);
cpt->extCompact->megaSet = (uint16) (setNo * NEXT_MEGA_SET);
return true;
}
@@ -2067,7 +2080,7 @@ bool SkyLogic::fnMoveItems(uint32 listNo, uint32 screenNo, uint32 c) {
for (int i = 0; i < 2; i++) {
if (!*p)
return true;
- Compact *cpt = SkyState::fetchCompact(*p++);
+ Compact *cpt = SkyEngine::fetchCompact(*p++);
cpt->screen = (uint16)(screenNo & 0xffff);
}
return true;
@@ -2096,46 +2109,46 @@ bool SkyLogic::fnRandom(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnPersonHere(uint32 id, uint32 room, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
_scriptVariables[RESULT] = cpt->screen == room ? 1 : 0;
return true;
}
bool SkyLogic::fnToggleMouse(uint32 a, uint32 b, uint32 c) {
- SkyState::fetchCompact(a)->status ^= ST_MOUSE;
+ SkyEngine::fetchCompact(a)->status ^= ST_MOUSE;
return true;
}
bool SkyLogic::fnMouseOn(uint32 a, uint32 b, uint32 c) {
//switch on the mouse highlight
- Compact *cpt = SkyState::fetchCompact(a);
+ Compact *cpt = SkyEngine::fetchCompact(a);
cpt->status |= ST_MOUSE;
return true;
}
bool SkyLogic::fnMouseOff(uint32 a, uint32 b, uint32 c) {
//switch on (off??) the mouse highlight
- Compact *cpt = SkyState::fetchCompact(a);
+ Compact *cpt = SkyEngine::fetchCompact(a);
cpt->status &= ~ST_MOUSE;
return true;
}
bool SkyLogic::fnFetchX(uint32 id, uint32 b, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
_scriptVariables[RESULT] = cpt->xcood;
return true;
}
bool SkyLogic::fnFetchY(uint32 id, uint32 b, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
_scriptVariables[RESULT] = cpt->ycood;
return true;
}
bool SkyLogic::fnTestList(uint32 id, uint32 x, uint32 y) {
_scriptVariables[RESULT] = 0; // assume fail
- uint16 *list = (uint16 *)SkyState::fetchCompact(id);
+ uint16 *list = (uint16 *)SkyEngine::fetchCompact(id);
while (*list) {
if ((x >= list[0]) && (x < list[1]) && (y >= list[2]) && (y < list[3]))
@@ -2146,7 +2159,7 @@ bool SkyLogic::fnTestList(uint32 id, uint32 x, uint32 y) {
}
bool SkyLogic::fnFetchPlace(uint32 id, uint32 b, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
_scriptVariables[RESULT] = cpt->place;
return true;
}
@@ -2156,7 +2169,7 @@ bool SkyLogic::fnCustomJoey(uint32 id, uint32 b, uint32 c) {
/// used by Joey-Logic - done in code like this because scripts can't
/// get access to another megas compact as easily
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
_scriptVariables[PLAYER_X] = cpt->xcood;
_scriptVariables[PLAYER_Y] = cpt->ycood;
@@ -2166,8 +2179,8 @@ bool SkyLogic::fnCustomJoey(uint32 id, uint32 b, uint32 c) {
}
bool SkyLogic::fnSetPalette(uint32 a, uint32 b, uint32 c) {
- _skyScreen->setPaletteEndian((uint8 *)SkyState::fetchCompact(a));
- SkyState::_systemVars.currentPalette = a;
+ _skyScreen->setPaletteEndian((uint8 *)SkyEngine::fetchCompact(a));
+ SkyEngine::_systemVars.currentPalette = a;
return true;
}
@@ -2177,7 +2190,7 @@ bool SkyLogic::fnTextModule(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnChangeName(uint32 id, uint32 textNo, uint32 c) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
cpt->cursorText = (uint16) textNo;
return true;
}
@@ -2216,8 +2229,8 @@ bool SkyLogic::fnEyeball(uint32 id, uint32 b, uint32 c) {
// set 'result' to frame no. pointing to foster, according to table used
// eg. FN_eyeball (id_eye_90_table);
- uint16 *eyeTable = (uint16 *)SkyState::fetchCompact(id);
- Compact *cpt = SkyState::fetchCompact(ID_BLUE_FOSTER);
+ uint16 *eyeTable = (uint16 *)SkyEngine::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(ID_BLUE_FOSTER);
uint32 x = cpt->xcood; // 168 < x < 416
x -= 168;
@@ -2232,7 +2245,7 @@ bool SkyLogic::fnEyeball(uint32 id, uint32 b, uint32 c) {
}
bool SkyLogic::fnLeaveSection(uint32 sectionNo, uint32 b, uint32 c) {
- if (SkyState::isDemo())
+ if (SkyEngine::isDemo())
_skyControl->showGameQuitMsg();
if (sectionNo == 5) //linc section - has different mouse icons
@@ -2245,23 +2258,23 @@ bool SkyLogic::fnLeaveSection(uint32 sectionNo, uint32 b, uint32 c) {
bool SkyLogic::fnEnterSection(uint32 sectionNo, uint32 b, uint32 c) {
- if (SkyState::isDemo() && (sectionNo > 2))
+ if (SkyEngine::isDemo() && (sectionNo > 2))
_skyControl->showGameQuitMsg();
_scriptVariables[CUR_SECTION] = sectionNo;
- SkyState::_systemVars.currentMusic = 0;
+ SkyEngine::_systemVars.currentMusic = 0;
if (sectionNo == 5) //linc section - has different mouse icons
_skyMouse->replaceMouseCursors(60302);
- if ((sectionNo != _currentSection) || (SkyState::_systemVars.systemFlags & SF_GAME_RESTORED)) {
+ if ((sectionNo != _currentSection) || (SkyEngine::_systemVars.systemFlags & SF_GAME_RESTORED)) {
_currentSection = sectionNo;
sectionNo++;
_skyMusic->loadSection((byte)sectionNo);
_skySound->loadSection((byte)sectionNo);
_skyGrid->loadGrids();
- SkyState::_systemVars.systemFlags &= ~SF_GAME_RESTORED;
+ SkyEngine::_systemVars.systemFlags &= ~SF_GAME_RESTORED;
}
return true;
@@ -2295,7 +2308,7 @@ bool SkyLogic::fnWaitSwingEnd(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnSkipIntroCode(uint32 a, uint32 b, uint32 c) {
- SkyState::_systemVars.pastIntro = true;
+ SkyEngine::_systemVars.pastIntro = true;
return true;
}
@@ -2307,7 +2320,7 @@ bool SkyLogic::fnBlankScreen(uint32 a, uint32 b, uint32 c) {
bool SkyLogic::fnPrintCredit(uint32 a, uint32 b, uint32 c) {
lowTextManager_t creditText = _skyText->lowTextManager(a , 240, 0, 248, true);
- Compact *credCompact = SkyState::fetchCompact(creditText.compactNum);
+ Compact *credCompact = SkyEngine::fetchCompact(creditText.compactNum);
credCompact->xcood = 168;
if ((a == 558) && (c == 215))
credCompact->ycood = 211;
@@ -2320,7 +2333,7 @@ bool SkyLogic::fnPrintCredit(uint32 a, uint32 b, uint32 c) {
bool SkyLogic::fnLookAt(uint32 a, uint32 b, uint32 c) {
struct lowTextManager_t textInfo = _skyText->lowTextManager(a, 240, 0, 248, true);
- Compact *textCpt = SkyState::fetchCompact(textInfo.compactNum);
+ Compact *textCpt = SkyEngine::fetchCompact(textInfo.compactNum);
textCpt->xcood = 168;
textCpt->ycood = (uint16)c;
@@ -2352,7 +2365,7 @@ bool SkyLogic::fnLincTextModule(uint32 textPos, uint32 textNo, uint32 buttonActi
lowTextManager_t text = _skyText->lowTextManager(textNo, 220, 0, 215, false);
- Compact *textCpt = SkyState::fetchCompact(text.compactNum);
+ Compact *textCpt = SkyEngine::fetchCompact(text.compactNum);
if (textPos < 20) { // line number (for text)
textCpt->xcood = 152;
@@ -2371,7 +2384,7 @@ bool SkyLogic::fnTextKill2(uint32 a, uint32 b, uint32 c) {
uint32 id = FIRST_TEXT_COMPACT;
for (int i = 10; i > 0; i--) {
- Compact *cpt = SkyState::fetchCompact(id);
+ Compact *cpt = SkyEngine::fetchCompact(id);
cpt->status = 0;
id++;
}
@@ -2394,15 +2407,15 @@ bool SkyLogic::fnStopFx(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnStartMusic(uint32 a, uint32 b, uint32 c) {
- if (!(SkyState::_systemVars.systemFlags & SF_MUS_OFF))
+ if (!(SkyEngine::_systemVars.systemFlags & SF_MUS_OFF))
_skyMusic->startMusic((uint16)a);
- SkyState::_systemVars.currentMusic = (uint16)a;
+ SkyEngine::_systemVars.currentMusic = (uint16)a;
return true;
}
bool SkyLogic::fnStopMusic(uint32 a, uint32 b, uint32 c) {
_skyMusic->startMusic(0);
- SkyState::_systemVars.currentMusic = 0;
+ SkyEngine::_systemVars.currentMusic = 0;
return true;
}
@@ -2412,7 +2425,7 @@ bool SkyLogic::fnFadeDown(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnFadeUp(uint32 a, uint32 b, uint32 c) {
- SkyState::_systemVars.currentPalette = a;
+ SkyEngine::_systemVars.currentPalette = a;
_skyScreen->fnFadeUp(a,b);
return true;
}
@@ -2448,7 +2461,7 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32
target->grafixProg.ptrType = TALKTABLE;
target->grafixProg.ptrTarget = animNum;
} else { //then it must be a value
- //animPtr = (uint16 *)SkyState::fetchCompact(SkyTalkAnims::animTalkTableVal[animNum]);
+ //animPtr = (uint16 *)SkyEngine::fetchCompact(SkyTalkAnims::animTalkTableVal[animNum]);
target->grafixProg.ptrType = COMPACT;
target->grafixProg.ptrTarget = SkyTalkAnims::animTalkTableVal[animNum];
}
@@ -2465,12 +2478,12 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32
bool speechUsed = false;
// startSpeech returns false if no speech file exists for that text
- if (SkyState::isCDVersion())
+ if (SkyEngine::isCDVersion())
speechUsed = _skySound->startSpeech((uint16)textNum);
// if sky is configured to speech-only return now - except if we're running another
// language than english
- if (speechUsed && (!(SkyState::_systemVars.systemFlags & SF_ALLOW_TEXT))) {
+ if (speechUsed && (!(SkyEngine::_systemVars.systemFlags & SF_ALLOW_TEXT))) {
target->extCompact->spTime = 10;
target->logic = L_TALK;
return ;
@@ -2479,7 +2492,7 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32
//now form the text sprite
struct lowTextManager_t textInfo;
textInfo = _skyText->lowTextManager(textNum, FIXED_TEXT_WIDTH, 0, (uint8)target->extCompact->spColour, true);
- Compact *textCompact = SkyState::fetchCompact(textInfo.compactNum);
+ Compact *textCompact = SkyEngine::fetchCompact(textInfo.compactNum);
target->extCompact->spTextId = textInfo.compactNum; //So we know what text to kill
byte *textGfx = textInfo.textData;
@@ -2489,7 +2502,7 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32
if (_scriptVariables[SCREEN] == target->screen) { // Only use coordinates if we are on the current screen
//talking on-screen
- byte *targetGfx = (byte *)SkyState::fetchItem(target->frame >> 6);
+ byte *targetGfx = (byte *)SkyEngine::fetchItem(target->frame >> 6);
uint16 xPos = target->xcood + ((struct dataFileHeader *)targetGfx)->s_offset_x;
uint16 width = (((struct dataFileHeader *)targetGfx)->s_width >> 1);
diff --git a/sky/logic.h b/sky/logic.h
index 8b0859591b..78554cd96a 100644
--- a/sky/logic.h
+++ b/sky/logic.h
@@ -22,14 +22,10 @@
#ifndef SKYLOGIC_H
#define SKYLOGIC_H
-#include "sky/sky.h"
-#include "sky/disk.h"
-#include "sky/grid.h"
-#include "sky/autoroute.h"
-#include "sky/music/musicbase.h"
-#include "sky/mouse.h"
-#include "sky/screen.h"
-#include "sky/control.h"
+#include "stdafx.h"
+#include "common/util.h"
+
+struct Compact;
enum scriptVariableOffsets {
RESULT = 0,
@@ -83,13 +79,24 @@ enum scriptVariableOffsets {
};
class SkyAutoRoute;
-class SkyScreen;
-class SkyMouse;
class SkyControl;
+class SkyDisk;
+class SkyGrid;
+class SkyMouse;
+class SkyMusicBase;
+class SkyScreen;
+class SkySound;
+class SkyText;
class SkyLogic {
public:
- SkyLogic(SkyScreen *skyScreen, SkyDisk *skyDisk, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound);
+ SkyLogic(
+ SkyScreen *skyScreen,
+ SkyDisk *skyDisk,
+ SkyText *skyText,
+ SkyMusicBase *skyMusic,
+ SkyMouse *skyMouse,
+ SkySound *skySound);
void engine();
bool checkProtection(void);
void useControlInstance(SkyControl *control) { _skyControl = control; };
diff --git a/sky/mouse.cpp b/sky/mouse.cpp
index cb4c84b7a4..d5d44813c5 100644
--- a/sky/mouse.cpp
+++ b/sky/mouse.cpp
@@ -19,8 +19,13 @@
*
*/
-#include "stdafx.h"
+#include "common/system.h"
+#include "sky/disk.h"
+#include "sky/logic.h"
+#include "sky/mouse.h"
#include "sky/sky.h"
+#include "sky/skydefs.h"
+#include "sky/struc.h"
#define MICE_FILE 60300
#define NO_MAIN_OBJECTS 24
@@ -137,11 +142,11 @@ void SkyMouse::fnSaveCoods(void) {
}
void SkyMouse::lockMouse(void) {
- SkyState::_systemVars.systemFlags |= SF_MOUSE_LOCKED;
+ SkyEngine::_systemVars.systemFlags |= SF_MOUSE_LOCKED;
}
void SkyMouse::unlockMouse(void) {
- SkyState::_systemVars.systemFlags &= ~SF_MOUSE_LOCKED;
+ SkyEngine::_systemVars.systemFlags &= ~SF_MOUSE_LOCKED;
}
void SkyMouse::restoreMouseData(uint16 frameNum) {
@@ -224,10 +229,10 @@ void SkyMouse::pointerEngine(uint16 xPos, uint16 yPos) {
uint32 currentListNum = SkyLogic::_scriptVariables[MOUSE_LIST_NO];
uint16 *currentList;
do {
- currentList = (uint16 *)SkyState::fetchCompact(currentListNum);
+ currentList = (uint16 *)SkyEngine::fetchCompact(currentListNum);
while ((*currentList != 0) && (*currentList != 0xFFFF)) {
uint16 itemNum = *currentList;
- Compact *itemData = SkyState::fetchCompact(itemNum);
+ Compact *itemData = SkyEngine::fetchCompact(itemNum);
currentList++;
if ((itemData->screen == SkyLogic::_scriptVariables[SCREEN]) && (itemData->status & 16)) {
if (itemData->xcood + ((int16)itemData->mouseRelX) > xPos) continue;
@@ -270,7 +275,7 @@ void SkyMouse::buttonEngine1(void) {
if (_mouseB) { //anything pressed?
SkyLogic::_scriptVariables[BUTTON] = _mouseB;
if (SkyLogic::_scriptVariables[SPECIAL_ITEM]) { //over anything?
- Compact *item = SkyState::fetchCompact(SkyLogic::_scriptVariables[SPECIAL_ITEM]);
+ Compact *item = SkyEngine::fetchCompact(SkyLogic::_scriptVariables[SPECIAL_ITEM]);
if (item->mouseClick)
_skyLogic->mouseScript(item->mouseClick, item);
}
diff --git a/sky/mouse.h b/sky/mouse.h
index 2d18b77eaa..b56d382459 100644
--- a/sky/mouse.h
+++ b/sky/mouse.h
@@ -23,10 +23,10 @@
#define SKYMOUSE_H
#include "stdafx.h"
-#include "sky/disk.h"
-#include "sky/logic.h"
-#include "sky/struc.h"
+#include "common/scummsys.h"
+class OSystem;
+class SkyDisk;
class SkyLogic;
class SkyMouse {
diff --git a/sky/music/adlibchannel.cpp b/sky/music/adlibchannel.cpp
index a5215ca2b5..4e68c4458f 100644
--- a/sky/music/adlibchannel.cpp
+++ b/sky/music/adlibchannel.cpp
@@ -19,8 +19,9 @@
*
*/
-#include "adlibchannel.h"
-#include "sound/fmopl.h"
+#include "common/util.h"
+#include "sky/music/adlibchannel.h"
+#include "sky/sky.h"
SkyAdlibChannel::SkyAdlibChannel(FM_OPL *opl, uint8 *pMusicData, uint16 startOfData)
{
@@ -42,7 +43,7 @@ SkyAdlibChannel::SkyAdlibChannel(FM_OPL *opl, uint8 *pMusicData, uint16 startOfD
uint16 instrumentDataLoc;
- if (SkyState::_systemVars.gameVersion == 109) {
+ if (SkyEngine::_systemVars.gameVersion == 109) {
//instrumentDataLoc = (_musicData[0x11D0] << 8) | _musicData[0x11CF];
//_frequenceTable = (uint16*)(_musicData + 0x835);
//_registerTable = _musicData + 0xE35;
@@ -54,7 +55,7 @@ SkyAdlibChannel::SkyAdlibChannel(FM_OPL *opl, uint8 *pMusicData, uint16 startOfD
_registerTable = _musicData + 0xE68;
_opOutputTable = _musicData + 0xE7A;
_adlibRegMirror = _musicData + 0xF7D;
- } else if (SkyState::_systemVars.gameVersion == 267) {
+ } else if (SkyEngine::_systemVars.gameVersion == 267) {
instrumentDataLoc = READ_LE_UINT16(_musicData + 0x11FB);
_frequenceTable = (uint16*)(_musicData + 0x7F4);
_registerTable = _musicData + 0xDF4;
diff --git a/sky/music/adlibchannel.h b/sky/music/adlibchannel.h
index f13fb78e96..e7f9d27e13 100644
--- a/sky/music/adlibchannel.h
+++ b/sky/music/adlibchannel.h
@@ -22,9 +22,6 @@
#ifndef ADLIBCHANNEL_H
#define ADLIBCHANNEL_H
-#include "stdafx.h"
-#include "base/engine.h"
-#include "sky/sky.h"
#include "sky/music/musicbase.h"
#include "sound/fmopl.h"
diff --git a/sky/music/adlibmusic.cpp b/sky/music/adlibmusic.cpp
index d3916269bd..d8f80d772a 100644
--- a/sky/music/adlibmusic.cpp
+++ b/sky/music/adlibmusic.cpp
@@ -20,7 +20,9 @@
*/
#include "sky/music/adlibmusic.h"
-#include "sound/fmopl.h"
+#include "sky/music/adlibchannel.h"
+#include "sound/mixer.h"
+#include "sky/sky.h"
void SkyAdlibMusic::passMixerFunc(void *param, int16 *buf, uint len) {
@@ -91,14 +93,14 @@ void SkyAdlibMusic::premixerCall(int16 *data, uint len) {
void SkyAdlibMusic::setupPointers(void) {
- if (SkyState::_systemVars.gameVersion == 109) {
+ if (SkyEngine::_systemVars.gameVersion == 109) {
// disk demo uses a different adlib driver version, some offsets have changed
//_musicDataLoc = (_musicData[0x11CC] << 8) | _musicData[0x11CB];
//_initSequence = _musicData + 0xEC8;
_musicDataLoc = READ_LE_UINT16(_musicData + 0x1200);
_initSequence = _musicData + 0xEFB;
- } else if (SkyState::_systemVars.gameVersion == 267) {
+ } else if (SkyEngine::_systemVars.gameVersion == 267) {
_musicDataLoc = READ_LE_UINT16(_musicData + 0x11F7);
_initSequence = _musicData + 0xE87;
} else {
diff --git a/sky/music/adlibmusic.h b/sky/music/adlibmusic.h
index b1b366c402..09782f5512 100644
--- a/sky/music/adlibmusic.h
+++ b/sky/music/adlibmusic.h
@@ -22,14 +22,11 @@
#ifndef ADLIBMUSIC_H
#define ADLIBMUSIC_H
-#include "stdafx.h"
-#include "sky/sky.h"
-#include "sound/mixer.h"
-#include "base/engine.h"
-#include "adlibchannel.h"
-#include "musicbase.h"
+#include "sky/music/musicbase.h"
#include "sound/fmopl.h"
+class SoundMixer;
+
class SkyAdlibMusic : public SkyMusicBase {
public:
SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, OSystem *system);
diff --git a/sky/music/gmchannel.cpp b/sky/music/gmchannel.cpp
index 16e493db52..5635f9a20d 100644
--- a/sky/music/gmchannel.cpp
+++ b/sky/music/gmchannel.cpp
@@ -21,6 +21,7 @@
#include "gmchannel.h"
#include "common/util.h"
+#include "sound/mididrv.h"
SkyGmChannel::SkyGmChannel(uint8 *pMusicData, uint16 startOfData, MidiDriver *pMidiDrv, byte *pInstMap, uint8 *veloTab) {
diff --git a/sky/music/gmchannel.h b/sky/music/gmchannel.h
index 8105141890..7214168586 100644
--- a/sky/music/gmchannel.h
+++ b/sky/music/gmchannel.h
@@ -22,10 +22,10 @@
#ifndef SKYGMCHANNEL_H
#define SKYGMCHANNEL_H
-#include "stdafx.h"
-#include "sound/mididrv.h"
#include "sky/music/musicbase.h"
+class MidiDriver;
+
typedef struct {
uint16 eventDataPtr;
int32 nextEventTime;
diff --git a/sky/music/gmmusic.cpp b/sky/music/gmmusic.cpp
index 581ebd841e..4bdef54e46 100644
--- a/sky/music/gmmusic.cpp
+++ b/sky/music/gmmusic.cpp
@@ -20,7 +20,10 @@
*/
#include "sky/music/gmmusic.h"
+#include "sky/music/gmchannel.h"
#include "sky/sky.h"
+#include "common/util.h"
+#include "sound/mididrv.h"
void SkyGmMusic::passTimerFunc(void *param) {
@@ -34,7 +37,7 @@ SkyGmMusic::SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, OSystem *system)
_midiDrv = pMidiDrv;
int midiRes = _midiDrv->open();
if (midiRes != 0) {
- error("Can't open midi device. Errorcode: %d",midiRes);
+ error("Can't open midi device. Errorcode: %d", midiRes);
}
_midiDrv->setTimerCallback(this, passTimerFunc);
_ignoreNextPoll = false;
@@ -73,7 +76,7 @@ void SkyGmMusic::timerCall(void) {
void SkyGmMusic::setupPointers(void) {
- if (SkyState::_systemVars.gameVersion == 109) {
+ if (SkyEngine::_systemVars.gameVersion == 109) {
_musicDataLoc = (_musicData[0x79C] << 8) | _musicData[0x79B];
_sysExSequence = _musicData + 0x1EF2;
} else {
diff --git a/sky/music/gmmusic.h b/sky/music/gmmusic.h
index 78aaea4d7f..85bb43d033 100644
--- a/sky/music/gmmusic.h
+++ b/sky/music/gmmusic.h
@@ -22,11 +22,9 @@
#ifndef GMMUSIC_H
#define GMMUSIC_H
-#include "stdafx.h"
-#include "base/engine.h"
-#include "musicbase.h"
-#include "sound/mididrv.h"
-#include "gmchannel.h"
+#include "sky/music/musicbase.h"
+
+class MidiDriver;
class SkyGmMusic : public SkyMusicBase {
public:
diff --git a/sky/music/mt32music.cpp b/sky/music/mt32music.cpp
index 9e062546f4..d5bf335422 100644
--- a/sky/music/mt32music.cpp
+++ b/sky/music/mt32music.cpp
@@ -20,7 +20,9 @@
*/
#include "sky/music/mt32music.h"
+#include "sky/music/gmchannel.h"
#include "common/util.h"
+#include "sound/mididrv.h"
void SkyMT32Music::passTimerFunc(void *param) {
diff --git a/sky/music/mt32music.h b/sky/music/mt32music.h
index d9624229b3..78cc439ac9 100644
--- a/sky/music/mt32music.h
+++ b/sky/music/mt32music.h
@@ -22,10 +22,9 @@
#ifndef MT32MUSIC_H
#define MT32MUSIC_H
-#include "stdafx.h"
-#include "musicbase.h"
-#include "sound/mididrv.h"
-#include "gmchannel.h"
+#include "sky/music/musicbase.h"
+
+class MidiDriver;
class SkyMT32Music : public SkyMusicBase {
public:
diff --git a/sky/music/musicbase.cpp b/sky/music/musicbase.cpp
index fecfff6dae..368a9c308d 100644
--- a/sky/music/musicbase.cpp
+++ b/sky/music/musicbase.cpp
@@ -19,7 +19,8 @@
*
*/
-#include "musicbase.h"
+#include "sky/music/musicbase.h"
+#include "sky/disk.h"
#include "common/util.h"
SkyMusicBase::SkyMusicBase(SkyDisk *pSkyDisk, OSystem *system) {
diff --git a/sky/music/musicbase.h b/sky/music/musicbase.h
index 1fa34be2bf..d5d17986c8 100644
--- a/sky/music/musicbase.h
+++ b/sky/music/musicbase.h
@@ -23,9 +23,12 @@
#define MUSICBASE_H
#include "stdafx.h"
-#include "sky/disk.h"
+#include "common/scummsys.h"
#include "common/system.h"
+class SkyDisk;
+class OSystem;
+
#define FILES_PER_SECTION 4
typedef struct {
diff --git a/sky/rnc_deco.h b/sky/rnc_deco.h
index ef97caa3e9..a6f875e511 100644
--- a/sky/rnc_deco.h
+++ b/sky/rnc_deco.h
@@ -22,6 +22,8 @@
#ifndef RNC_DECO_H
#define RNC_DECO_H
+#include "stdafx.h"
+
class RncDecoder {
protected:
diff --git a/sky/screen.cpp b/sky/screen.cpp
index f2584b53b4..de8f50158f 100644
--- a/sky/screen.cpp
+++ b/sky/screen.cpp
@@ -19,7 +19,13 @@
*
*/
-#include "screen.h"
+#include "common/system.h"
+#include "sky/disk.h"
+#include "sky/logic.h"
+#include "sky/screen.h"
+#include "sky/sky.h"
+#include "sky/skydefs.h"
+#include "sky/struc.h"
uint8 SkyScreen::_top16Colours[16*3] =
{
@@ -164,9 +170,9 @@ void SkyScreen::recreate(void) {
// check the game grid for changed blocks
if (!SkyLogic::_scriptVariables[LAYER_0_ID]) return ;
uint8 *gridPos = _gameGrid;
- uint8 *screenData = (uint8 *)SkyState::fetchItem(SkyLogic::_scriptVariables[LAYER_0_ID]);
+ uint8 *screenData = (uint8 *)SkyEngine::fetchItem(SkyLogic::_scriptVariables[LAYER_0_ID]);
if (!screenData) {
- error("SkyScreen::recreate():\nSkyState::fetchItem(SkyLogic::_scriptVariables[LAYER_0_ID](%X)) returned NULL",SkyLogic::_scriptVariables[LAYER_0_ID]);
+ error("SkyScreen::recreate():\nSkyEngine::fetchItem(SkyLogic::_scriptVariables[LAYER_0_ID](%X)) returned NULL",SkyLogic::_scriptVariables[LAYER_0_ID]);
}
uint8 *screenPos = _currentScreen;
@@ -229,7 +235,7 @@ void SkyScreen::fnDrawScreen(uint32 palette, uint32 scroll) {
void SkyScreen::fnFadeDown(uint32 scroll) {
- if (scroll && (!(SkyState::_systemVars.systemFlags & SF_NO_SCROLL))) {
+ if (scroll && (!(SkyEngine::_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);
@@ -301,8 +307,8 @@ void SkyScreen::fnFadeUp(uint32 palNum, uint32 scroll) {
scroll = 0;
}
- if ((scroll == 0) || (SkyState::_systemVars.systemFlags & SF_NO_SCROLL)) {
- uint8 *palette = (uint8 *)SkyState::fetchCompact(palNum);
+ if ((scroll == 0) || (SkyEngine::_systemVars.systemFlags & SF_NO_SCROLL)) {
+ uint8 *palette = (uint8 *)SkyEngine::fetchCompact(palNum);
if (palette == NULL)
error("SkyScreen::fnFadeUp: can't fetch compact %X", palNum);
#ifdef SCUMM_BIG_ENDIAN
@@ -392,7 +398,7 @@ void SkyScreen::startSequence(uint16 fileNum) {
void SkyScreen::startSequenceItem(uint16 itemNum) {
- _seqInfo.seqData = (uint8 *)SkyState::fetchItem(itemNum);
+ _seqInfo.seqData = (uint8 *)SkyEngine::fetchItem(itemNum);
_seqInfo.framesLeft = _seqInfo.seqData[0] - 1;
_seqInfo.seqDataPos = _seqInfo.seqData + 1;
_seqInfo.delay = SEQ_DELAY;
@@ -506,7 +512,7 @@ void SkyScreen::sortSprites(void) {
currDrawList++;
do { // a_new_draw_list:
- uint16 *drawListData = (uint16 *)SkyState::fetchCompact(loadDrawList);
+ uint16 *drawListData = (uint16 *)SkyEngine::fetchCompact(loadDrawList);
nextDrawList = false;
while ((!nextDrawList) && (drawListData[0])) {
if (drawListData[0] == 0xFFFF) {
@@ -514,11 +520,11 @@ void SkyScreen::sortSprites(void) {
nextDrawList = true;
} else {
// process_this_id:
- Compact *spriteComp = SkyState::fetchCompact(drawListData[0]);
+ Compact *spriteComp = SkyEngine::fetchCompact(drawListData[0]);
if ((spriteComp->status & 4) && // is it sortable playfield?(!?!)
(spriteComp->screen == SkyLogic::_scriptVariables[SCREEN])) { // on current screen
dataFileHeader *spriteData =
- (dataFileHeader *)SkyState::fetchItem(spriteComp->frame >> 6);
+ (dataFileHeader *)SkyEngine::fetchItem(spriteComp->frame >> 6);
if (!spriteData) {
debug(9,"Missing file %d",spriteComp->frame >> 6);
spriteComp->status = 0;
@@ -568,17 +574,17 @@ void SkyScreen::doSprites(uint8 layer) {
idNum = SkyLogic::_scriptVariables[drawListNum];
drawListNum++;
- drawList = (uint16 *)SkyState::fetchCompact(idNum);
+ drawList = (uint16 *)SkyEngine::fetchCompact(idNum);
while(drawList[0]) {
// new_draw_list:
while ((drawList[0] != 0) && (drawList[0] != 0xFFFF)) {
// back_loop:
// not_new_list
- Compact *spriteData = SkyState::fetchCompact(drawList[0]);
+ Compact *spriteData = SkyEngine::fetchCompact(drawList[0]);
drawList++;
if ((spriteData->status & (1 << layer)) &&
(spriteData->screen == SkyLogic::_scriptVariables[SCREEN])) {
- uint8 *toBeDrawn = (uint8 *)SkyState::fetchItem(spriteData->frame >> 6);
+ uint8 *toBeDrawn = (uint8 *)SkyEngine::fetchItem(spriteData->frame >> 6);
if (!toBeDrawn) {
debug(9, "Spritedata %d not loaded",spriteData->frame >> 6);
spriteData->status = 0;
@@ -591,7 +597,7 @@ void SkyScreen::doSprites(uint8 layer) {
}
}
while (drawList[0] == 0xFFFF)
- drawList = (uint16 *)SkyState::fetchCompact(drawList[1]);
+ drawList = (uint16 *)SkyEngine::fetchCompact(drawList[1]);
}
}
}
@@ -702,7 +708,7 @@ void SkyScreen::vertMaskSub(uint16 *grid, uint32 gridOfs, uint8 *screenPtr, uint
if (!(FROM_LE_16(grid[gridOfs]) & 0x8000)) {
uint32 gridVal = FROM_LE_16(grid[gridOfs]) - 1;
gridVal *= GRID_W * GRID_H;
- uint8 *dataSrc = (uint8 *)SkyState::fetchItem(SkyLogic::_scriptVariables[layerId]) + gridVal;
+ uint8 *dataSrc = (uint8 *)SkyEngine::fetchItem(SkyLogic::_scriptVariables[layerId]) + gridVal;
uint8 *dataTrg = screenPtr;
for (uint32 grdCntY = 0; grdCntY < GRID_H; grdCntY++) {
for (uint32 grdCntX = 0; grdCntX < GRID_W; grdCntX++)
@@ -730,7 +736,7 @@ void SkyScreen::verticalMask(void) {
uint32 nLayerCnt = layerCnt;
while (SkyLogic::_scriptVariables[nLayerCnt + 3]) {
uint16 *scrGrid;
- scrGrid = (uint16 *)SkyState::fetchItem(SkyLogic::_scriptVariables[layerCnt + 3]);
+ scrGrid = (uint16 *)SkyEngine::fetchItem(SkyLogic::_scriptVariables[layerCnt + 3]);
if (scrGrid[gridOfs]) {
vertMaskSub(scrGrid, gridOfs, screenPtr, layerCnt);
break;
diff --git a/sky/screen.h b/sky/screen.h
index 555cb0401d..c891267fde 100644
--- a/sky/screen.h
+++ b/sky/screen.h
@@ -23,13 +23,14 @@
#define SKYSCREEN_H
#include "stdafx.h"
-#include <string.h>
-#include "base/engine.h"
#include "common/scummsys.h"
-#include "sky/disk.h"
#include "sky/skydefs.h"
-#include "sky/sky.h"
-#include "sky/logic.h"
+
+class OSystem;
+class SkyDisk;
+class SkyEngine;
+struct Compact;
+struct dataFileHeader;
#define SCROLL_JUMP 16
#define VGA_COLOURS 256
@@ -45,8 +46,6 @@ typedef struct {
dataFileHeader *sprite;
} StSortList;
-class SkyState;
-
class SkyScreen {
public:
SkyScreen(OSystem *pSystem, SkyDisk *pDisk);
diff --git a/sky/sky.cpp b/sky/sky.cpp
index 0b8b3acc41..8d7264f258 100644
--- a/sky/sky.cpp
+++ b/sky/sky.cpp
@@ -25,16 +25,27 @@
#include "base/plugins.h"
#include "common/file.h"
+#include "common/timer.h"
-#include "sky/sky.h"
-#include "sky/skydefs.h" //game specific defines
#include "sky/compact.h"
-#include "sky/logic.h"
+#include "sky/control.h"
#include "sky/debug.h"
+#include "sky/disk.h"
+#include "sky/intro.h"
+#include "sky/logic.h"
#include "sky/mouse.h"
+#include "sky/music/adlibmusic.h"
+#include "sky/music/gmmusic.h"
+#include "sky/music/mt32music.h"
+#include "sky/music/musicbase.h"
+#include "sky/screen.h"
+#include "sky/sky.h"
+#include "sky/skydefs.h"
+#include "sky/sound.h"
+#include "sky/text.h"
-#include <errno.h>
-#include <time.h>
+#include "sound/mididrv.h"
+#include "sound/mixer.h"
extern uint16 _debugLevel;
@@ -75,16 +86,16 @@ const TargetSettings *Engine_SKY_targetList() {
}
Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst) {
- return new SkyState(detector, syst);
+ return new SkyEngine(detector, syst);
}
REGISTER_PLUGIN("Beneath a Steel Sky", Engine_SKY_targetList, Engine_SKY_create);
-void **SkyState::_itemList[300];
+void **SkyEngine::_itemList[300];
-SystemVars SkyState::_systemVars = {0, 0, 0, 0, 4316, 0, 0, false, false };
+SystemVars SkyEngine::_systemVars = {0, 0, 0, 0, 4316, 0, 0, false, false };
-SkyState::SkyState(GameDetector *detector, OSystem *syst)
+SkyEngine::SkyEngine(GameDetector *detector, OSystem *syst)
: Engine(detector, syst) {
_game = detector->_game.id;
@@ -105,7 +116,7 @@ SkyState::SkyState(GameDetector *detector, OSystem *syst)
_system->init_size(320, 200);
}
-SkyState::~SkyState() {
+SkyEngine::~SkyEngine() {
delete _skyLogic;
delete _skySound;
@@ -115,17 +126,17 @@ SkyState::~SkyState() {
delete _skyScreen;
}
-void SkyState::errorString(const char *buf1, char *buf2) {
+void SkyEngine::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1);
}
-void SkyState::initVirgin() {
+void SkyEngine::initVirgin() {
_skyScreen->setPalette(60111);
_skyScreen->showScreen(60110);
}
-uint8 SkyState::_languageTable[11] = {
+uint8 SkyEngine::_languageTable[11] = {
SKY_USA, // EN_USA
SKY_GERMAN, // DE_DEU
SKY_FRENCH, // FR_FRA
@@ -139,7 +150,7 @@ uint8 SkyState::_languageTable[11] = {
SKY_ENGLISH // EN_GRB
};
-void SkyState::doCheat(uint8 num) {
+void SkyEngine::doCheat(uint8 num) {
switch(num) {
case 1: warning("executed cheat: get jammer");
@@ -163,7 +174,7 @@ void SkyState::doCheat(uint8 num) {
}
}
-void SkyState::handleKey(void) {
+void SkyEngine::handleKey(void) {
if (_key_pressed == 63)
_skyControl->doControlPanel();
@@ -184,7 +195,7 @@ void SkyState::handleKey(void) {
_key_pressed = 0;
}
-void SkyState::go() {
+void SkyEngine::go() {
if (!_dump_file)
_dump_file = stdout;
@@ -238,7 +249,7 @@ void SkyState::go() {
}
}
-void SkyState::initialise(void) {
+void SkyEngine::initialise(void) {
_skyDisk = new SkyDisk(_gameDataPath);
_skySound = new SkySound(_mixer, _skyDisk, _detector->_sfx_volume);
@@ -290,16 +301,16 @@ void SkyState::initialise(void) {
else
_systemVars.language = _languageTable[_detector->_language];
- if (!_skyDisk->fileExists(60600 + SkyState::_systemVars.language * 8)) {
+ if (!_skyDisk->fileExists(60600 + SkyEngine::_systemVars.language * 8)) {
warning("The language you selected does not exist in your BASS version.");
if (_skyDisk->fileExists(60600))
- SkyState::_systemVars.language = SKY_ENGLISH;
+ SkyEngine::_systemVars.language = SKY_ENGLISH;
else if (_skyDisk->fileExists(60600 + SKY_USA * 8))
- SkyState::_systemVars.language = SKY_USA;
+ SkyEngine::_systemVars.language = SKY_USA;
else
for (uint8 cnt = SKY_ENGLISH; cnt <= SKY_SPANISH; cnt++)
if (_skyDisk->fileExists(60600 + cnt * 8)) {
- SkyState::_systemVars.language = cnt;
+ SkyEngine::_systemVars.language = cnt;
break;
}
}
@@ -316,7 +327,7 @@ void SkyState::initialise(void) {
_skyMusic->setVolume(_detector->_music_volume >> 1);
}
-void SkyState::initItemList() {
+void SkyEngine::initItemList() {
//See List.asm for (cryptic) item # descriptions
@@ -338,14 +349,14 @@ void SkyState::initItemList() {
}
}
-void SkyState::loadBase0(void) {
+void SkyEngine::loadBase0(void) {
_skyLogic->fnEnterSection(0, 0, 0);
_skyMusic->startMusic(2);
_systemVars.currentMusic = 2;
}
-void SkyState::loadFixedItems(void) {
+void SkyEngine::loadFixedItems(void) {
if (!isDemo())
_itemList[36] = (void **)_skyDisk->loadFile(36, NULL);
@@ -369,22 +380,22 @@ void SkyState::loadFixedItems(void) {
}
-void **SkyState::fetchItem(uint32 num) {
+void **SkyEngine::fetchItem(uint32 num) {
return _itemList[num];
}
-void SkyState::timerHandler(void *refCon) {
+void SkyEngine::timerHandler(void *refCon) {
- ((SkyState *)refCon)->gotTimerTick();
+ ((SkyEngine *)refCon)->gotTimerTick();
}
-void SkyState::gotTimerTick(void) {
+void SkyEngine::gotTimerTick(void) {
_skyScreen->handleTimer();
}
-Compact *SkyState::fetchCompact(uint32 a) {
+Compact *SkyEngine::fetchCompact(uint32 a) {
SkyDebug::fetchCompact(a);
uint32 sectionNum = (a & 0xf000) >> 12;
uint32 compactNum = (a & 0x0fff);
@@ -392,7 +403,7 @@ Compact *SkyState::fetchCompact(uint32 a) {
return (Compact *)(_itemList[119 + sectionNum][compactNum]);
}
-void SkyState::delay(uint amount) { //copied and mutilated from Simon.cpp
+void SkyEngine::delay(uint amount) { //copied and mutilated from Simon.cpp
OSystem::Event event;
@@ -438,7 +449,7 @@ void SkyState::delay(uint amount) { //copied and mutilated from Simon.cpp
_skyMouse->buttonPressed(1);
break;
case OSystem::EVENT_QUIT:
- if (!SkyState::_systemVars.quitting)
+ if (!SkyEngine::_systemVars.quitting)
_skyControl->showGameQuitMsg(); // will call _system->quit()
break;
default:
@@ -462,7 +473,7 @@ void SkyState::delay(uint amount) { //copied and mutilated from Simon.cpp
} while (cur < start + amount);
}
-bool SkyState::isDemo(void) {
+bool SkyEngine::isDemo(void) {
switch (_systemVars.gameVersion) {
case 109: // pc gamer demo
case 267: // floppy demo
@@ -480,7 +491,7 @@ bool SkyState::isDemo(void) {
}
}
-bool SkyState::isCDVersion(void) {
+bool SkyEngine::isCDVersion(void) {
switch (_systemVars.gameVersion) {
case 109:
diff --git a/sky/sky.h b/sky/sky.h
index 573fc6a807..6f80ef8819 100644
--- a/sky/sky.h
+++ b/sky/sky.h
@@ -22,24 +22,8 @@
#ifndef SKYMAIN_H
#define SKYMAIN_H
-#include <stdio.h>
+#include "stdafx.h"
#include "base/engine.h"
-#include "common/util.h"
-#include "common/timer.h"
-#include "sound/mixer.h"
-#include "sky/sound.h"
-#include "sky/text.h"
-#include "sky/disk.h"
-#include "sky/struc.h"
-#include "sky/screen.h"
-#include "sky/music/musicbase.h"
-#include "sky/music/adlibmusic.h"
-#include "sky/music/gmmusic.h"
-#include "sky/music/mt32music.h"
-#include "sky/mouse.h"
-#include "sky/control.h"
-#include "sky/intro.h"
-#include "common/config-file.h"
struct SystemVars {
uint32 systemFlags;
@@ -53,12 +37,18 @@ struct SystemVars {
bool quitting;
};
+struct Compact;
+class SkySound;
+class SkyDisk;
+class SkyText;
class SkyLogic;
+class SkyMouse;
class SkyScreen;
class SkyControl;
+class SkyMusicBase;
class SkyIntro;
-class SkyState : public Engine {
+class SkyEngine : public Engine {
void errorString(const char *buf_input, char *buf_output);
protected:
byte _game;
@@ -71,8 +61,6 @@ protected:
int _numScreenUpdates;
- Timer *_timer;
-
FILE *_dump_file;
int _number_of_savegames;
@@ -92,8 +80,8 @@ protected:
GameDetector *_detector; // necessary for music
public:
- SkyState(GameDetector *detector, OSystem *syst);
- virtual ~SkyState();
+ SkyEngine(GameDetector *detector, OSystem *syst);
+ virtual ~SkyEngine();
static bool isDemo(void);
static bool isCDVersion(void);
diff --git a/sky/skydefs.h b/sky/skydefs.h
index 369ce317f8..2cb382b20d 100644
--- a/sky/skydefs.h
+++ b/sky/skydefs.h
@@ -22,7 +22,7 @@
#ifndef SKYDEFS_H
#define SKYDEFS_H
-#include "struc.h"
+#include "stdafx.h"
//This file is incomplete, several flags still missing.
diff --git a/sky/sound.cpp b/sky/sound.cpp
index 671bd720fd..e3ff675bee 100644
--- a/sky/sound.cpp
+++ b/sky/sound.cpp
@@ -20,9 +20,12 @@
*/
#include "stdafx.h"
+#include "sky/disk.h"
+#include "sky/logic.h"
+#include "sky/sky.h"
+#include "sky/skydefs.h"
#include "sky/sound.h"
#include "sky/struc.h"
-#include "sky/logic.h"
#define SOUND_FILE_BASE 60203
#define MAX_FX_NUMBER 393
@@ -1065,7 +1068,7 @@ void SkySound::loadSection(uint8 pSection) {
if (_soundData) free(_soundData);
_soundData = _skyDisk->loadFile(pSection * 4 + SOUND_FILE_BASE, NULL);
uint16 asmOfs;
- if (SkyState::_systemVars.gameVersion == 109) {
+ if (SkyEngine::_systemVars.gameVersion == 109) {
if (pSection == 0)
asmOfs = 0x78;
else
@@ -1085,7 +1088,7 @@ void SkySound::loadSection(uint8 pSection) {
_sampleRates = _soundData + sRateTabOfs;
_sfxInfo = _soundData + _sfxBaseOfs;
// if we just restored a savegame, the sfxqueue holds the sound we need to restart
- if (!(SkyState::_systemVars.systemFlags & SF_GAME_RESTORED))
+ if (!(SkyEngine::_systemVars.systemFlags & SF_GAME_RESTORED))
for (uint8 cnt = 0; cnt < 4; cnt++)
_sfxQueue[cnt].count = 0;
}
@@ -1137,7 +1140,7 @@ void SkySound::playSound(uint16 sound, uint16 volume, uint8 channel) {
void SkySound::fnStartFx(uint32 sound, uint8 channel) {
_saveSounds[channel] = 0xFFFF;
- if (sound < 256 || sound > MAX_FX_NUMBER || (SkyState::_systemVars.systemFlags & SF_FX_OFF))
+ if (sound < 256 || sound > MAX_FX_NUMBER || (SkyEngine::_systemVars.systemFlags & SF_FX_OFF))
return;
uint8 screen = (uint8)(SkyLogic::_scriptVariables[SCREEN] & 0xff);
@@ -1161,9 +1164,9 @@ void SkySound::fnStartFx(uint32 sound, uint8 channel) {
uint8 volume = _mainSfxVolume; // start with standard vol
- if (SkyState::_systemVars.systemFlags & SF_SBLASTER)
+ if (SkyEngine::_systemVars.systemFlags & SF_SBLASTER)
volume = roomList[i].adlibVolume;
- else if (SkyState::_systemVars.systemFlags & SF_ROLAND)
+ else if (SkyEngine::_systemVars.systemFlags & SF_ROLAND)
volume = roomList[i].rolandVolume;
volume = (volume * _mainSfxVolume) >> 8;
@@ -1229,7 +1232,7 @@ void SkySound::stopSpeech(void) {
bool SkySound::startSpeech(uint16 textNum) {
- if (!(SkyState::_systemVars.systemFlags & SF_ALLOW_SPEECH))
+ if (!(SkyEngine::_systemVars.systemFlags & SF_ALLOW_SPEECH))
return false;
uint16 speechFileNum = _speechConvertTable[textNum >> 12] + (textNum & 0xFFF);
diff --git a/sky/sound.h b/sky/sound.h
index 084726dd97..298ba1ef0b 100644
--- a/sky/sound.h
+++ b/sky/sound.h
@@ -22,9 +22,11 @@
#ifndef SKYSOUND_H
#define SKYSOUND_H
+#include "stdafx.h"
+#include "common/scummsys.h"
#include "sound/mixer.h"
-#include "sky/disk.h"
-#include "base/engine.h"
+
+class SkyDisk;
enum {
SOUND_CH0 = 0,
diff --git a/sky/text.cpp b/sky/text.cpp
index cf81edb7aa..a05c730f96 100644
--- a/sky/text.cpp
+++ b/sky/text.cpp
@@ -19,12 +19,12 @@
*
*/
-#include "stdafx.h"
-#include "common/scummsys.h"
-#include "sky/skydefs.h"
-#include "sky/sky.h"
-#include "sky/text.h"
+#include "sky/disk.h"
#include "sky/logic.h"
+#include "sky/text.h"
+#include "sky/sky.h"
+#include "sky/skydefs.h"
+#include "sky/struc.h"
#define FIRST_TEXT_SEC 77
#define FIRST_TEXT_BUFFER 274
@@ -45,7 +45,7 @@ SkyText::SkyText(SkyDisk *skyDisk) {
fnSetFont(0);
- if (!SkyState::isDemo()) {
+ if (!SkyEngine::isDemo()) {
_controlCharacterSet.addr = _skyDisk->loadFile(60520, NULL);
_controlCharacterSet.charHeight = 12;
_controlCharacterSet.charSpacing = 0;
@@ -60,7 +60,7 @@ SkyText::SkyText(SkyDisk *skyDisk) {
_linkCharacterSet.addr = NULL;
}
- if (SkyState::isCDVersion()) {
+ if (SkyEngine::isCDVersion()) {
_preAfterTableArea = _skyDisk->loadFile(60522, NULL);
} else _preAfterTableArea = NULL;
}
@@ -96,7 +96,7 @@ void SkyText::patchLINCCharset() {
// the width for every character by one, except for space which needs
// to be one pixel wider than before.
- if (SkyState::_systemVars.gameVersion == 288) {
+ if (SkyEngine::_systemVars.gameVersion == 288) {
for (int i = 1; i < CHAR_SET_HEADER; i++)
charSetPtr[i]--;
charSetPtr[0]++;
@@ -204,7 +204,7 @@ void SkyText::patchLINCCharset() {
patchChar(charSetPtr, 5, charHeight, 93, U_umlaut);
patchChar(charSetPtr, 5, charHeight, 74, normal_j);
patchChar(charSetPtr, 6, charHeight, 17, normal_1);
- if (SkyState::_systemVars.gameVersion <= 303) {
+ if (SkyEngine::_systemVars.gameVersion <= 303) {
patchChar(charSetPtr, 5, charHeight, 10, a_umlaut);
} else {
patchChar(charSetPtr, 5, charHeight, 94, A_umlaut);
@@ -244,10 +244,10 @@ void SkyText::fnSetFont(uint32 fontNr) {
void SkyText::fnTextModule(uint32 textInfoId, uint32 textNo) {
fnSetFont(1);
- uint16* msgData = (uint16 *)SkyState::fetchCompact(textInfoId);
+ uint16* msgData = (uint16 *)SkyEngine::fetchCompact(textInfoId);
lowTextManager_t textId = lowTextManager(textNo, msgData[1], msgData[2], 209, false);
SkyLogic::_scriptVariables[RESULT] = textId.compactNum;
- Compact *textCompact = SkyState::fetchCompact(textId.compactNum);
+ Compact *textCompact = SkyEngine::fetchCompact(textId.compactNum);
textCompact->xcood = msgData[3];
textCompact->ycood = msgData[4];
fnSetFont(0);
@@ -260,13 +260,13 @@ void SkyText::getText(uint32 textNr) { //load text #"textNr" into textBuffer
uint32 sectionNo = (textNr & 0x0F000) >> 12;
- if (SkyState::_itemList[FIRST_TEXT_SEC + sectionNo] == (void **)NULL) { //check if already loaded
+ if (SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo] == (void **)NULL) { //check if already loaded
debug(5, "Loading Text item(s) for Section %d", (sectionNo>>2));
- uint32 fileNo = sectionNo + ((SkyState::_systemVars.language * NO_OF_TEXT_SECTIONS) + 60600);
- SkyState::_itemList[FIRST_TEXT_SEC + sectionNo] = (void **)_skyDisk->loadFile((uint16)fileNo, NULL);
+ uint32 fileNo = sectionNo + ((SkyEngine::_systemVars.language * NO_OF_TEXT_SECTIONS) + 60600);
+ SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo] = (void **)_skyDisk->loadFile((uint16)fileNo, NULL);
}
- _textItemPtr = (uint8 *)SkyState::_itemList[FIRST_TEXT_SEC + sectionNo];
+ _textItemPtr = (uint8 *)SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo];
uint32 offset = 0;
uint32 nr32MsgBlocks = (textNr & 0x0fe0);
@@ -328,7 +328,7 @@ void SkyText::getText(uint32 textNr) { //load text #"textNr" into textBuffer
void SkyText::fnPointerText(uint32 pointedId, uint16 mouseX, uint16 mouseY) {
- Compact *ptrComp = SkyState::fetchCompact(pointedId);
+ Compact *ptrComp = SkyEngine::fetchCompact(pointedId);
lowTextManager_t text = lowTextManager(ptrComp->cursorText, TEXT_MOUSE_WIDTH, L_CURSOR, 242, false);
SkyLogic::_scriptVariables[CURSOR_ID] = text.compactNum;
if (SkyLogic::_scriptVariables[MENU]) {
@@ -340,7 +340,7 @@ void SkyText::fnPointerText(uint32 pointedId, uint16 mouseX, uint16 mouseY) {
if (mouseX < 150) _mouseOfsX = TOP_LEFT_X + 13;
else _mouseOfsX = TOP_LEFT_X - 8 - _lowTextWidth;
}
- Compact *textCompact = SkyState::fetchCompact(text.compactNum);
+ Compact *textCompact = SkyEngine::fetchCompact(text.compactNum);
logicCursor(textCompact, mouseX, mouseY);
}
@@ -541,17 +541,17 @@ lowTextManager_t SkyText::lowTextManager(uint32 textNum, uint16 width, uint16 lo
uint32 compactNum = FIRST_TEXT_COMPACT;
- Compact *cpt = SkyState::fetchCompact(compactNum);
+ Compact *cpt = SkyEngine::fetchCompact(compactNum);
while (cpt->status != 0) {
compactNum++;
- cpt = SkyState::fetchCompact(compactNum);
+ cpt = SkyEngine::fetchCompact(compactNum);
}
cpt->flag = (uint16)(compactNum - FIRST_TEXT_COMPACT) + FIRST_TEXT_BUFFER;
- byte *oldText = (byte *)SkyState::_itemList[cpt->flag];
- SkyState::_itemList[cpt->flag] = (void **)textData;
+ byte *oldText = (byte *)SkyEngine::_itemList[cpt->flag];
+ SkyEngine::_itemList[cpt->flag] = (void **)textData;
if (oldText != NULL)
free (oldText);
@@ -576,7 +576,7 @@ void SkyText::changeTextSpriteColour(uint8 *sprData, uint8 newCol) {
}
void SkyText::initHuffTree() {
- switch (SkyState::_systemVars.gameVersion) {
+ switch (SkyEngine::_systemVars.gameVersion) {
case 109:
_huffTree = _huffTree_00109;
break;
@@ -605,7 +605,7 @@ void SkyText::initHuffTree() {
_huffTree = _huffTree_00372;
break;
default:
- error("Unknown game version %d", SkyState::_systemVars.gameVersion);
+ error("Unknown game version %d", SkyEngine::_systemVars.gameVersion);
}
}
@@ -624,8 +624,8 @@ char SkyText::getTextChar() {
bool SkyText::patchMessage(uint32 textNum) {
- uint16 patchIdx = _patchLangIdx[SkyState::_systemVars.language];
- uint16 patchNum = _patchLangNum[SkyState::_systemVars.language];
+ uint16 patchIdx = _patchLangIdx[SkyEngine::_systemVars.language];
+ uint16 patchNum = _patchLangNum[SkyEngine::_systemVars.language];
for (uint16 cnt = 0; cnt < patchNum; cnt++) {
if (_patchedMessages[cnt + patchIdx].textNr == textNum) {
strcpy(_textBuffer, _patchedMessages[cnt + patchIdx].text);
diff --git a/sky/text.h b/sky/text.h
index bd9e4f4fef..d659711a18 100644
--- a/sky/text.h
+++ b/sky/text.h
@@ -22,8 +22,11 @@
#ifndef SKYTEXT_H
#define SKYTEXT_H
-#include "sky/disk.h"
-#include "sky/struc.h"
+#include "stdafx.h"
+#include "common/scummsys.h"
+
+struct Compact;
+class SkyDisk;
struct HuffTree {
unsigned char lChild;