From c545ebd0d5d1b0690e16f7472048e7ffde40d934 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 8 Jun 2011 00:01:44 +0200 Subject: CGE: Add minimal engine and detection --- base/plugins.cpp | 3 + configure | 1 + engines/cge/cge.cpp | 68 +++++++++++++ engines/cge/cge.h | 67 ++++++++++++ engines/cge/console.cpp | 34 +++++++ engines/cge/console.h | 43 ++++++++ engines/cge/detection.cpp | 255 ++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/module.mk | 17 ++++ engines/engines.mk | 5 + 9 files changed, 493 insertions(+) create mode 100644 engines/cge/cge.cpp create mode 100644 engines/cge/cge.h create mode 100644 engines/cge/console.cpp create mode 100644 engines/cge/console.h create mode 100644 engines/cge/detection.cpp create mode 100644 engines/cge/module.mk diff --git a/base/plugins.cpp b/base/plugins.cpp index 4a3b201714..a838414da3 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -94,6 +94,9 @@ public: #if PLUGIN_ENABLED_STATIC(AGOS) LINK_PLUGIN(AGOS) #endif + #if PLUGIN_ENABLED_STATIC(CGE) + LINK_PLUGIN(CGE) + #endif #if PLUGIN_ENABLED_STATIC(CINE) LINK_PLUGIN(CINE) #endif diff --git a/configure b/configure index b436a3822d..711bd6eaee 100755 --- a/configure +++ b/configure @@ -79,6 +79,7 @@ add_engine he "HE71+ games" yes add_engine agi "AGI" yes add_engine agos "AGOS" yes "agos2" add_engine agos2 "AGOS 2 games" yes +add_engine cge "CGE" no add_engine cine "Cinematique evo 1" yes add_engine cruise "Cinematique evo 2" yes add_engine draci "Dragon History" yes diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp new file mode 100644 index 0000000000..e7c462e772 --- /dev/null +++ b/engines/cge/cge.cpp @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" + +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/debug-channels.h" +#include "common/error.h" +#include "common/EventRecorder.h" +#include "common/file.h" +#include "common/fs.h" + +#include "engines/util.h" + +#include "cge/cge.h" + +namespace CGE { + +CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) + : Engine(syst), _gameDescription(gameDescription) { + + DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); + _console = new CGEConsole(this); + + debug("CGEEngine::CGEEngine"); +} + +CGEEngine::~CGEEngine() { + debug("CGEEngine::~CGEEngine"); + + // Remove all of our debug levels here + DebugMan.clearAllDebugChannels(); +} + +Common::Error CGEEngine::run() { + // Initialize graphics using following: + initGraphics(320, 200, false); + + // Create debugger console. It requires GFX to be initialized + _console = new CGEConsole(this); + + // Additional setup. + debug("CGEEngine::init"); + + return Common::kNoError; +} + +} // End of namespace CGE diff --git a/engines/cge/cge.h b/engines/cge/cge.h new file mode 100644 index 0000000000..fac4f2c6cc --- /dev/null +++ b/engines/cge/cge.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef CGE_H +#define CGE_H + +#include "common/random.h" +#include "engines/engine.h" +#include "gui/debugger.h" +#include "graphics/surface.h" +#include "engines/advancedDetector.h" +#include "cge/console.h" + +#define CGE_SAVEGAME_VERSION 1 + +namespace CGE { + +class Console; + +// our engine debug channels +enum { + kCGEDebug = 1 << 0 +}; + +class CGEEngine : public Engine { +public: + CGEEngine(OSystem *syst, const ADGameDescription *gameDescription); + ~CGEEngine(); + + const ADGameDescription *_gameDescription; + + virtual Common::Error run(); + GUI::Debugger *getDebugger() { return _console; } + +private: + CGEConsole *_console; +}; + +// Example console class +class Console : public GUI::Debugger { +public: + Console(CGEEngine *vm) {} + virtual ~Console(void) {} +}; + +} // End of namespace CGE + +#endif diff --git a/engines/cge/console.cpp b/engines/cge/console.cpp new file mode 100644 index 0000000000..71eedf34ea --- /dev/null +++ b/engines/cge/console.cpp @@ -0,0 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "cge/console.h" +#include "cge/cge.h" + +namespace CGE { + +CGEConsole::CGEConsole(CGEEngine *vm) : GUI::Debugger(), _vm(vm) { +} + +CGEConsole::~CGEConsole() { +} + +} // End of namespace CGE diff --git a/engines/cge/console.h b/engines/cge/console.h new file mode 100644 index 0000000000..7f265202ea --- /dev/null +++ b/engines/cge/console.h @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef CGE_CONSOLE_H +#define CGE_CONSOLE_H + +#include "gui/debugger.h" + +namespace CGE { + +class CGEEngine; + +class CGEConsole : public GUI::Debugger { +public: + CGEConsole(CGEEngine *vm); + virtual ~CGEConsole(void); + +private: + CGEEngine *_vm; +}; + +} // End of namespace CGE + +#endif diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp new file mode 100644 index 0000000000..7d7a82a82b --- /dev/null +++ b/engines/cge/detection.cpp @@ -0,0 +1,255 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/config-manager.h" +#include "engines/advancedDetector.h" +#include "common/savefile.h" +#include "common/system.h" +#include "base/plugins.h" +#include "graphics/thumbnail.h" +#include "cge/cge.h" + +static const PlainGameDescriptor CGEGames[] = { + { "soltys", "Soltys" }, + { 0, 0 } +}; + +namespace CGE { + +using Common::GUIO_NONE; + +static const ADGameDescription gameDescriptions[] = { + + { + "soltys", "", + { + {"vol.cat", 0, "0c33e2c304821a2444d297fc5e2d67c6", 50176}, + {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8437572}, + AD_LISTEND + }, + Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + }, + { + "soltys", "Soltys Freeware", + { + {"vol.cat", 0, "0c33e2c304821a2444d297fc5e2d67c6", 50176}, + {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8437676}, + AD_LISTEND + }, + Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + }, + { + "soltys", "Soltys Demo", + { + {"vol.cat", 0, "1e077c8ff58109a187f07ac54b0c873a", 18788}, + {"vol.dat", 0, "75d385a6074c58b69f7730481f256051", 1796710}, + AD_LISTEND + }, + Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + }, + { + "soltys", "Soltys Demo", + { + {"vol.cat", 0, "f17987487fab1ebddd781d8d02fedecc", 7168}, + {"vol.dat", 0, "c5d9b15863cab61dc125551576dece04", 1075272}, + AD_LISTEND + }, + Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + }, + AD_TABLE_END_MARKER +}; + +static const ADFileBasedFallback fileBasedFallback[] = { + { &gameDescriptions[0], { "vol.cat", "vol.dat", 0 } }, + { 0, { 0 } } +}; + +} // End of namespace CGE + +static const ADParams detectionParams = { + // Pointer to ADGameDescription or its superset structure + (const byte *)CGE::gameDescriptions, + // Size of that superset structure + sizeof(ADGameDescription), + // Number of bytes to compute MD5 sum for + 5000, + // List of all engine targets + CGEGames, + // Structure for autoupgrading obsolete targets + 0, + // Name of single gameid (optional) + "Soltys", + // List of files for file-based fallback detection (optional) + CGE::fileBasedFallback, + // Flags + 0, + // Additional GUI options (for every game} + Common::GUIO_NONE, + // Maximum directory depth + 0, + // List of directory globs + NULL +}; + +class CGEMetaEngine : public AdvancedMetaEngine { +public: + CGEMetaEngine() : AdvancedMetaEngine(detectionParams) {} + + virtual const char *getName() const { + return "CGE"; + } + + virtual const char *getOriginalCopyright() const { + return "Soltys (c) 1994-1996 L.K. Avalon"; + } + + virtual bool hasFeature(MetaEngineFeature f) const; + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; + virtual int getMaximumSaveSlot() const; + virtual SaveStateList listSaves(const char *target) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; + virtual void removeSaveState(const char *target, int slot) const; +}; + +bool CGEMetaEngine::hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail) || + (f == kSavesSupportCreationDate); +} + +void CGEMetaEngine::removeSaveState(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s.%03d", target, slot); + g_system->getSavefileManager()->removeSavefile(fileName); +} + +int CGEMetaEngine::getMaximumSaveSlot() const { return 99; } + +SaveStateList CGEMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String pattern = target; + pattern += ".???"; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + int slotNum = 0; + for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { + // Obtain the last 3 digits of the filename, since they correspond to the save slot + slotNum = atoi(filename->c_str() + filename->size() - 3); + + if (slotNum >= 0 && slotNum <= 99) { + Common::InSaveFile *file = saveFileMan->openForLoading(*filename); + if (file) { + int32 version = file->readSint32BE(); + if (version != CGE_SAVEGAME_VERSION) { + delete file; + continue; + } + + // read name + uint16 nameSize = file->readUint16BE(); + if (nameSize >= 255) { + delete file; + continue; + } + char name[256]; + file->read(name, nameSize); + name[nameSize] = 0; + + saveList.push_back(SaveStateDescriptor(slotNum, name)); + delete file; + } + } + } + + return saveList; +} + +SaveStateDescriptor CGEMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s.%03d", target, slot); + Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName); + + if (file) { + + int32 version = file->readSint32BE(); + if (version != CGE_SAVEGAME_VERSION) { + delete file; + return SaveStateDescriptor(); + } + + uint32 saveNameLength = file->readUint16BE(); + char saveName[256]; + file->read(saveName, saveNameLength); + saveName[saveNameLength] = 0; + + SaveStateDescriptor desc(slot, saveName); + + Graphics::Surface *thumbnail = new Graphics::Surface(); + assert(thumbnail); + if (!Graphics::loadThumbnail(*file, *thumbnail)) { + delete thumbnail; + thumbnail = 0; + } + desc.setThumbnail(thumbnail); + + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + + uint32 saveDate = file->readUint32BE(); + uint16 saveTime = file->readUint16BE(); + + int day = (saveDate >> 24) & 0xFF; + int month = (saveDate >> 16) & 0xFF; + int year = saveDate & 0xFFFF; + + desc.setSaveDate(year, month, day); + + int hour = (saveTime >> 8) & 0xFF; + int minutes = saveTime & 0xFF; + + desc.setSaveTime(hour, minutes); + + delete file; + return desc; + } + + return SaveStateDescriptor(); +} + +bool CGEMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + if (desc) { + *engine = new CGE::CGEEngine(syst, desc); + } + return desc != 0; +} + +#if PLUGIN_ENABLED_DYNAMIC(CGE) + REGISTER_PLUGIN_DYNAMIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine); +#else + REGISTER_PLUGIN_STATIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine); +#endif diff --git a/engines/cge/module.mk b/engines/cge/module.mk new file mode 100644 index 0000000000..62ddd9d362 --- /dev/null +++ b/engines/cge/module.mk @@ -0,0 +1,17 @@ +MODULE := engines/cge + +MODULE_OBJS := \ + cge.o \ + console.o \ + detection.o + +MODULE_DIRS += \ + engines/cge + +# This module can be built as a plugin +ifeq ($(ENABLE_CGE), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk diff --git a/engines/engines.mk b/engines/engines.mk index f8ff823c13..63e4665d28 100644 --- a/engines/engines.mk +++ b/engines/engines.mk @@ -26,6 +26,11 @@ DEFINES += -DENABLE_AGOS2 endif endif +ifdef ENABLE_CGE +DEFINES += -DENABLE_CGE=$(ENABLE_CGE) +MODULES += engines/cge +endif + ifdef ENABLE_CINE DEFINES += -DENABLE_CINE=$(ENABLE_CINE) MODULES += engines/cine -- cgit v1.2.3 From 01a7e7ad60819d247bfe815a8e2183a46c1c6437 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 9 Jun 2011 08:20:53 +0200 Subject: CGE: Add several sources based on headers --- engines/cge/bitmap.cpp | 433 +++++++++ engines/cge/bitmap.h | 60 ++ engines/cge/bitmaps.cpp | 214 +++++ engines/cge/bitmaps.h | 18 + engines/cge/boot.h | 49 + engines/cge/cfile.cpp | 332 +++++++ engines/cge/cfile.h | 56 ++ engines/cge/cge.cpp | 5 +- engines/cge/cge.h | 2 +- engines/cge/cge_main.cpp | 2232 ++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/cge_main.h | 181 ++++ engines/cge/drop.h | 1 + engines/cge/game.cpp | 91 ++ engines/cge/game.h | 40 + engines/cge/general.h | 241 +++++ engines/cge/gettext.cpp | 110 +++ engines/cge/gettext.h | 35 + engines/cge/ident.h | 14 + engines/cge/jbw.h | 149 ++++ engines/cge/keybd.cpp | 114 +++ engines/cge/keybd.h | 31 + engines/cge/mixer.cpp | 129 +++ engines/cge/mixer.h | 31 + engines/cge/module.mk | 19 +- engines/cge/mouse.cpp | 207 +++++ engines/cge/mouse.h | 58 ++ engines/cge/snail.cpp | 1280 ++++++++++++++++++++++++++ engines/cge/snail.h | 98 ++ engines/cge/snddrv.h | 104 +++ engines/cge/sound.cpp | 293 ++++++ engines/cge/sound.h | 61 ++ engines/cge/startup.cpp | 168 ++++ engines/cge/startup.h | 52 ++ engines/cge/talk.cpp | 376 ++++++++ engines/cge/talk.h | 81 ++ engines/cge/text.cpp | 291 ++++++ engines/cge/text.h | 60 ++ engines/cge/vga13h.cpp | 1775 ++++++++++++++++++++++++++++++++++++ engines/cge/vga13h.h | 310 +++++++ engines/cge/vmenu.cpp | 149 ++++ engines/cge/vmenu.h | 45 + engines/cge/vol.cpp | 79 ++ engines/cge/vol.h | 64 ++ engines/cge/wav.h | 109 +++ 44 files changed, 10244 insertions(+), 3 deletions(-) create mode 100644 engines/cge/bitmap.cpp create mode 100644 engines/cge/bitmap.h create mode 100644 engines/cge/bitmaps.cpp create mode 100644 engines/cge/bitmaps.h create mode 100644 engines/cge/boot.h create mode 100644 engines/cge/cfile.cpp create mode 100644 engines/cge/cfile.h create mode 100644 engines/cge/cge_main.cpp create mode 100644 engines/cge/cge_main.h create mode 100644 engines/cge/drop.h create mode 100644 engines/cge/game.cpp create mode 100644 engines/cge/game.h create mode 100644 engines/cge/general.h create mode 100644 engines/cge/gettext.cpp create mode 100644 engines/cge/gettext.h create mode 100644 engines/cge/ident.h create mode 100644 engines/cge/jbw.h create mode 100644 engines/cge/keybd.cpp create mode 100644 engines/cge/keybd.h create mode 100644 engines/cge/mixer.cpp create mode 100644 engines/cge/mixer.h create mode 100644 engines/cge/mouse.cpp create mode 100644 engines/cge/mouse.h create mode 100644 engines/cge/snail.cpp create mode 100644 engines/cge/snail.h create mode 100644 engines/cge/snddrv.h create mode 100644 engines/cge/sound.cpp create mode 100644 engines/cge/sound.h create mode 100644 engines/cge/startup.cpp create mode 100644 engines/cge/startup.h create mode 100644 engines/cge/talk.cpp create mode 100644 engines/cge/talk.h create mode 100644 engines/cge/text.cpp create mode 100644 engines/cge/text.h create mode 100644 engines/cge/vga13h.cpp create mode 100644 engines/cge/vga13h.h create mode 100644 engines/cge/vmenu.cpp create mode 100644 engines/cge/vmenu.h create mode 100644 engines/cge/vol.cpp create mode 100644 engines/cge/vol.h create mode 100644 engines/cge/wav.h diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp new file mode 100644 index 0000000000..f3a7f85331 --- /dev/null +++ b/engines/cge/bitmap.cpp @@ -0,0 +1,433 @@ +#include "bitmap.h" +#include + +#ifdef VOL + #include "vol.h" +#endif + +#ifdef DROP_H + #include "drop.h" +#endif + + +#include +#include +#include +#include + + +//-------------------------------------------------------------------------- + + + + +DAC far * BITMAP::Pal = NULL; + + + +#pragma argsused +BITMAP::BITMAP (const char * fname, Boolean rem) +: M(NULL), V(NULL) +{ + char pat[MAXPATH]; + + ForceExt(pat, fname, ".VBM"); + + #if (BMP_MODE < 2) + if (rem && PIC_FILE::Exist(pat)) + { + PIC_FILE file(pat); + if (file.Error == 0) + if (! VBMLoad(&file)) + DROP("Bad VBM", fname); + } + else + #endif + { + #if (BMP_MODE) + ForceExt(pat, fname, ".BMP"); + PIC_FILE file(pat); + if (file.Error == 0) + { + if (BMPLoad(&file)) + { + Code(); + if (rem) + { + farfree(M); + M = NULL; + } + } + else DROP("Bad BMP", fname); + } + #else + DROP("Bad VBM", fname); + #endif + } +} + + + + + +BITMAP::BITMAP (word w, word h, byte far * map) +: W(w), H(h), M(map), V(NULL) +{ + if (map) Code(); +} + + + + +// following routine creates filled rectangle +// immediately as VGA video chunks, in near memory as fast as possible, +// especially for text line real time display + +BITMAP::BITMAP (word w, word h, byte fill) +: W((w + 3) & ~3), // only full dwords allowed! + H(h), + M(NULL) +{ + word dsiz = W >> 2; // data size (1 plane line size) + word lsiz = 2 + dsiz + 2; // word for line header, word for gap + word psiz = H * lsiz; // - last gape, but + plane trailer + byte * v = new byte[4 * psiz // the same for 4 planes + + H * sizeof(*B)]; // + room for wash table + if (v == NULL) DROP("No core", NULL); + + * (word *) v = CPY | dsiz; // data chunk hader + memset(v+2, fill, dsiz); // data bytes + * (word *) (v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap + memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines + * (word *) (v + psiz - 2) = EOI; // plane trailer word + memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes + HideDesc * b = (HideDesc *) (v + 4 * psiz); + b->skip = (SCR_WID - W) >> 2; + b->hide = W >> 2; + memcpy(b+1, b, (H-1) * sizeof(*b)); // tricky fill entire table + b->skip = 0; // fix the first entry + V = v; + B = b; +} + + + + + + + +BITMAP::BITMAP (const BITMAP& bmp) +: W(bmp.W), H(bmp.H), + M(NULL), V(NULL) +{ + byte far * v0 = bmp.V; + if (v0) + { + word vsiz = FP_OFF(bmp.B) - FP_OFF(v0); + word siz = vsiz + H * sizeof(HideDesc); + byte far * v1 = farnew(byte, siz); + if (v1 == NULL) DROP("No core", NULL); + _fmemcpy(v1, v0, siz); + B = (HideDesc far *) ((V = v1) + vsiz); + } +} + + + + + +BITMAP::~BITMAP (void) +{ + switch (MemType(M)) + { + case FAR_MEM : farfree(M); break; + } + switch (MemType(V)) + { + case NEAR_MEM : delete[] (byte *) V; break; + case FAR_MEM : farfree(V); break; + } +} + + + +BITMAP& BITMAP::operator = (const BITMAP& bmp) +{ + byte far * v0 = bmp.V; + W = bmp.W; + H = bmp.H; + M = NULL; + if (MemType(V) == FAR_MEM) farfree(V); + if (v0 == NULL) V = NULL; + else + { + word vsiz = FP_OFF(bmp.B) - FP_OFF(v0); + word siz = vsiz + H * sizeof(HideDesc); + byte far * v1 = farnew(byte, siz); + if (v1 == NULL) DROP("No core", NULL); + _fmemcpy(v1, v0, siz); + B = (HideDesc far *) ((V = v1) + vsiz); + } + return *this; +} + + + + + +word BITMAP::MoveVmap (byte far * buf) +{ + if (V) + { + word vsiz = FP_OFF(B) - FP_OFF(V); + word siz = vsiz + H * sizeof(HideDesc); + _fmemcpy(buf, V, siz); + if (MemType(V) == FAR_MEM) farfree(V); + B = (HideDesc far *) ((V = buf) + vsiz); + return siz; + } + return 0; +} + + + + + + + +BMP_PTR BITMAP::Code (void) +{ + if (M) + { + word i, cnt; + + if (V) // old X-map exists, so remove it + { + switch (MemType(V)) + { + case NEAR_MEM : delete[] (byte *) V; break; + case FAR_MEM : farfree(V); break; + } + V = NULL; + } + + while (TRUE) // at most 2 times: for (V == NULL) & for allocated block; + { + byte far * im = V+2; + word far * cp = (word far *) V; + int bpl; + + if (V) // 2nd pass - fill the hide table + { + for (i = 0; i < H; i ++) + { + B[i].skip = 0xFFFF; + B[i].hide = 0x0000; + } + } + for (bpl = 0; bpl < 4; bpl ++) // once per each bitplane + { + byte far * bm = M; + Boolean skip = (bm[bpl] == TRANS); + word j; + + cnt = 0; + for (i = 0; i < H; i ++) // once per each line + { + byte pix; + for (j = bpl; j < W; j += 4) + { + pix = bm[j]; + if (V && pix != TRANS) + { + if (j < B[i].skip) B[i].skip = j; + if (j >= B[i].hide) B[i].hide = j+1; + } + if ((pix == TRANS) != skip || cnt >= 0x3FF0) // end of block + { + cnt |= (skip) ? SKP : CPY; + if (V) + { + *cp = cnt; // store block description word + } + cp = (word far *) im; + im += 2; + skip = (pix == TRANS); + cnt = 0; + } + if (! skip) + { + if (V) * im = pix; + ++ im; + } + ++ cnt; + } + + bm += W; + if (W < SCR_WID) + { + if (skip) + { + cnt += (SCR_WID - j + 3) / 4; + } + else + { + cnt |= CPY; + if (V) + { + *cp = cnt; + } + cp = (word far *) im; + im += 2; + skip = TRUE; + cnt = (SCR_WID - j + 3) / 4; + } + } + } + if (cnt && ! skip) + { + cnt |= CPY; + if (V) + { + *cp = cnt; + } + cp = (word far *) im; + im += 2; + } + if (V) *cp = EOI; + cp = (word far *) im; + im += 2; + } + if (V) break; + word sizV = (word) (im - 2 - V); + V = farnew(byte, sizV + H * sizeof(*B)); + if (! V) + { + DROP("No core", NULL); + } + B = (HideDesc far *) (V + sizV); + } + cnt = 0; + for (i = 0; i < H; i ++) + { + if (B[i].skip == 0xFFFF) // whole line is skipped + { + B[i].skip = (cnt + SCR_WID) >> 2; + cnt = 0; + } + else + { + word s = B[i].skip & ~3; + word h = (B[i].hide + 3) & ~3; + B[i].skip = (cnt + s) >> 2; + B[i].hide = (h - s) >> 2; + cnt = SCR_WID - h; + } + } + } + return this; +} + + + + + + +Boolean BITMAP::SolidAt (int x, int y) +{ + byte far * m; + word r, n, n0; + + if (x >= W || y >= H) return FALSE; + + m = V; + r = x % 4; + n0 = (SCR_WID * y + x) / 4, n = 0; + + while (r) + { + word w, t; + + w = * (word far *) m; + m += 2; + t = w & 0xC000; + w &= 0x3FFF; + + switch (t) + { + case EOI : -- r; + case SKP : w = 0; break; + case REP : w = 1; break; + } + m += w; + } + + while (TRUE) + { + word w, t; + + w = * (word far *) m; + m += 2; + t = w & 0xC000; + w &= 0x3FFF; + + if (n > n0) return FALSE; + n += w; + switch (t) + { + case EOI : return FALSE; + case SKP : w = 0; break; + case REP : + case CPY : if (n-w <= n0 && n > n0) return TRUE; break; + } + m += (t == REP) ? 1 : w; + } +} + + + + + + +Boolean BITMAP::VBMSave (XFILE * f) +{ + word p = (Pal != NULL), + n = ((word) (((byte far *)B) - V)) + H * sizeof(HideDesc); + if (f->Error == 0) f->Write((byte far *)&p, sizeof(p)); + if (f->Error == 0) f->Write((byte far *)&n, sizeof(n)); + if (f->Error == 0) f->Write((byte far *)&W, sizeof(W)); + if (f->Error == 0) f->Write((byte far *)&H, sizeof(H)); + if (f->Error == 0) if (p) f->Write((byte far *)Pal, 256 * sizeof(DAC)); + if (f->Error == 0) f->Write(V, n); + return (f->Error == 0); +} + + + + + +Boolean BITMAP::VBMLoad (XFILE * f) +{ + word p, n; + if (f->Error == 0) f->Read((byte far *)&p, sizeof(p)); + if (f->Error == 0) f->Read((byte far *)&n, sizeof(n)); + if (f->Error == 0) f->Read((byte far *)&W, sizeof(W)); + if (f->Error == 0) f->Read((byte far *)&H, sizeof(H)); + if (f->Error == 0) + { + if (p) + { + if (Pal) f->Read((byte far *)Pal, 256 * sizeof(DAC)); + else f->Seek(f->Mark() + 256 * sizeof(DAC)); + } + } + if ((V = farnew(byte, n)) == NULL) return FALSE; + if (f->Error == 0) f->Read(V, n); + B = (HideDesc far *) (V + n - H * sizeof(HideDesc)); + return (f->Error == 0); +} + + + + + diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h new file mode 100644 index 0000000000..10d85430dc --- /dev/null +++ b/engines/cge/bitmap.h @@ -0,0 +1,60 @@ +#ifndef __BITMAP__ +#define __BITMAP__ + +#include + +#define EOI 0x0000 +#define SKP 0x4000 +#define REP 0x8000 +#define CPY 0xC000 + +#define TRANS 0xFE + + +typedef struct { word b : 2; + word B : 6; + word g : 2; + word G : 6; + word r : 2; + word R : 6; + word Z : 8; + } BGR4; + + +typedef struct { word skip; word hide; } HideDesc; + + + + +class BITMAP +{ + Boolean BMPLoad (XFILE * f); + Boolean VBMLoad (XFILE * f); +public: + static DAC far * Pal; + word W, H; + byte far * M, far * V; HideDesc far * B; + BITMAP (const char * fname, Boolean rem = TRUE); + BITMAP (word w, word h, byte far * map); + BITMAP (word w, word h, byte fill); + BITMAP (const BITMAP& bmp); + ~BITMAP (void); + BITMAP * FlipH (void); + BITMAP * Code (); + BITMAP& operator = (const BITMAP& bmp); + void Hide (int x, int y); + void Show (int x, int y); + void XShow (int x, int y); + Boolean SolidAt (int x, int y); + Boolean VBMSave (XFILE * f); + word MoveVmap (byte far * buf); +}; + + + +typedef BITMAP * BMP_PTR; + + + + +#endif \ No newline at end of file diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp new file mode 100644 index 0000000000..2f79599c87 --- /dev/null +++ b/engines/cge/bitmaps.cpp @@ -0,0 +1,214 @@ +#include "bitmaps.h" +/* + +#define W 255, +#define x 252, +#define _ TRANS, +#define o 0, +#define L LGRAY, +#define G GRAY, +#define D DGRAY, + +static byte MCDesign0[]= { W W W W W W _ + W W W W W o _ + W W W W o _ _ + W W W W W _ _ + W W o W W W _ + W o _ o W W W + o _ _ _ o W W + _ _ _ _ _ o o }; + + +static byte MCDesign1[]= { _ }; + + + +static byte SLDesign[] = { G G G G G G G G G _ _ _ _ _ _ + L G G G G G G G G D _ _ _ _ _ + _ L G G G G G G G D _ _ _ _ _ + _ _ L G G G G G G G D _ _ _ _ + _ _ _ L G G G G G G D _ _ _ _ + _ _ _ _ L G G G G G D _ _ _ _ + _ _ _ _ _ L G G G G G D _ _ _ + _ _ _ _ _ _ L G G G G D _ _ _ + _ _ _ _ _ _ _ L G G G D _ _ _ + _ _ _ _ _ _ _ _ L G G G D _ _ + _ _ _ _ _ _ _ _ _ L G G D _ _ + _ _ _ _ _ _ _ _ _ _ L G D _ _ + _ _ _ _ _ _ _ _ _ _ _ L G D _ + _ _ _ _ _ _ _ _ _ _ _ _ L D _ + _ _ _ _ _ _ _ _ _ _ _ _ _ L D + _ _ _ _ _ _ _ _ _ _ _ _ _ _ D + }; + +static byte SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G + _ _ _ _ _ L G G G G G G G G D + _ _ _ _ _ L G G G G G G G D _ + _ _ _ _ L G G G G G G G D _ _ + _ _ _ _ L G G G G G G D _ _ _ + _ _ _ _ L G G G G G D _ _ _ _ + _ _ _ L G G G G G D _ _ _ _ _ + _ _ _ L G G G G D _ _ _ _ _ _ + _ _ _ L G G G D _ _ _ _ _ _ _ + _ _ L G G G D _ _ _ _ _ _ _ _ + _ _ L G G D _ _ _ _ _ _ _ _ _ + _ _ L G D _ _ _ _ _ _ _ _ _ _ + _ L G D _ _ _ _ _ _ _ _ _ _ _ + _ L D _ _ _ _ _ _ _ _ _ _ _ _ + L D _ _ _ _ _ _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ _ _ _ _ _ _ + }; + +static byte MapBrick[] = { L L L L L L L G + L G G G G G G D + L G G G G G G D + G D D D D D D D + }; + +#undef W +#undef _ +#undef x +#undef o +#undef L +#undef G +#undef D + + +#if 0 + +#define _ TRANS, +#define A 213, +#define B 207, +#define C 225, +#define D 219, +#define E 231, + +static byte PRDesign[] = { A E E E C C D A B + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + B A A A A A A A B + B B B B B B B B B + }; + +#else + +#define _ TRANS, +#define A 213, +#define B 207, +#define C 225, // DGRAY +#define D 219, +#define E 231, +#define F 237, + +static byte PRDesign[] = { D D D D D D D D _ + D D D D D D D D _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ C _ + D C C C C C C C _ + _ _ _ _ _ _ _ _ _ + }; +#endif + + +#undef _ +#undef A +#undef B +#undef C +#undef D +#undef E + + + +#define _ 0x00, +#define x 0xFF, +#define A _ x _ x _ x _ x +#define B A A A A A A A A + +static byte HLDesign[] = { B B B B B }; + +#undef _ +#undef x +#undef A +#undef B + + +// 228 yellow +// 211 red +// 226 light green +// 221 blue + +#define A 208, +#define B 214, +#define C 220, +#define D 226, +#define E 255, + +static byte LIDesign[][9] = { { A A A + A B A + A A A }, + + { A B A + B C B + A B A }, + + { B C B + C D C + B C B }, + + { C D C + D E D + C D C }, + }; + +#undef A +#undef B +#undef C +#undef D +#undef E + + +#define R 211, +#define G 0, +//226, + +static byte MEDesign[][9] = { { R R R R R R R R R }, // 0 + { R R R R R R R R G }, // 1 + { R R R R R R R G G }, // 2 + { R R R R R R G G G }, // 3 + { R R R R R G G G G }, // 4 + { R R R R G G G G G }, // 5 + { R R R G G G G G G }, // 6 + { R R G G G G G G G }, // 7 + { R G G G G G G G G }, // 8 + { G G G G G G G G G }, // 9 + }; + +#undef R +#undef G +*/ + +#ifdef DEBUG + BMP_PTR MB[] = { new BITMAP("BRICK"), NULL }; + BMP_PTR HL[] = { new BITMAP("HLINE"), NULL }; +#endif + + BMP_PTR MC[] = { new BITMAP("MOUSE"), + new BITMAP("DUMMY"), + NULL }; + BMP_PTR PR[] = { new BITMAP("PRESS"), NULL }; + BMP_PTR SP[] = { new BITMAP("SPK_L"), + new BITMAP("SPK_R"), + NULL }; + BMP_PTR LI[] = { new BITMAP("LITE0"), + new BITMAP("LITE1"), + new BITMAP("LITE2"), + new BITMAP("LITE3"), + NULL }; diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h new file mode 100644 index 0000000000..ef02c034e1 --- /dev/null +++ b/engines/cge/bitmaps.h @@ -0,0 +1,18 @@ +#ifndef __BITMAPS__ +#define __BITMAPS__ + +#include "vga13h.h" + +#ifdef DEBUG + extern BITMAP * MB[]; + extern BITMAP * HL[]; +#endif + +extern BITMAP * MC[]; +extern BITMAP * PR[]; +extern BITMAP * SP[]; +extern BITMAP * LI[]; + + +#endif + \ No newline at end of file diff --git a/engines/cge/boot.h b/engines/cge/boot.h new file mode 100644 index 0000000000..18c7cd2499 --- /dev/null +++ b/engines/cge/boot.h @@ -0,0 +1,49 @@ +#ifndef __BOOT__ +#define __BOOT__ + +#include + +#define BOOTSECT_SIZ 512 +#define BOOTHEAD_SIZ 62 +#define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ +#define FreeBoot(b) free(b) + +#ifndef EC + #define EC +#endif + +typedef struct { + byte Jmp[3]; // NEAR jump machine code + char OEM_ID[8]; // OEM name and version + word SectSize; // bytes per sector + byte ClustSize; // sectors per cluster + word ResSecs; // sectors before 1st FAT + byte FatCnt; // number of FATs + word RootSize; // root directory entries + word TotSecs; // total sectors on disk + byte Media; // media descriptor byte + word FatSize; // sectors per FAT + word TrkSecs; // sectors per track + word HeadCnt; // number of sufraces + word HidnSecs; // special hidden sectors + word _; // (unknown: reserved?) + dword lTotSecs; // total number of sectors + word DriveNum; // physical drive number + byte XSign; // extended boot signature + dword Serial; // volume serial number + char Label[11]; // volume label + char FileSysID[8]; // file system ID + char Code[BOOTCODE_SIZ-8]; // 8 = length of following + dword Secret; // long secret number + byte BootCheck; // boot sector checksum + byte BootFlags; // secret flags + word BootSig; // boot signature 0xAA55 + } Boot; + + +EC Boot * ReadBoot (int drive); +EC byte CheckBoot (Boot * boot); +EC Boolean WriteBoot (int drive, Boot * boot); + + +#endif \ No newline at end of file diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp new file mode 100644 index 0000000000..53b845b89f --- /dev/null +++ b/engines/cge/cfile.cpp @@ -0,0 +1,332 @@ +#include +#include +#include +#include +#include + +#ifdef DROP_H + #include "drop.h" +#else + #include + #include + #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } +#endif + + + + +IOBUF::IOBUF (IOMODE mode, CRYPT * crpt) +: IOHAND(mode, crpt), + BufMark(0), + Ptr(0), + Lim(0) +{ + Buff = farnew(byte, IOBUF_SIZE); + if (Buff == NULL) DROP("No core for I/O", NULL); +} + + + + + + + + + +IOBUF::IOBUF (const char * name, IOMODE mode, CRYPT * crpt) +: IOHAND(name, mode, crpt), + BufMark(0), + Ptr(0), + Lim(0) +{ + Buff = farnew(byte, IOBUF_SIZE); + if (Buff == NULL) DROP("No core for I/O", name); +} + + + + + + + + + +IOBUF::~IOBUF (void) +{ + if (Mode > REA) WriteBuff(); + if (Buff) farfree(Buff); +} + + + + + + +void IOBUF::ReadBuff (void) +{ + BufMark = IOHAND::Mark(); + Lim = IOHAND::Read(Buff, IOBUF_SIZE); + Ptr = 0; +} + + + + + +void IOBUF::WriteBuff (void) +{ + if (Lim) + { + IOHAND::Write(Buff, Lim); + BufMark = IOHAND::Mark(); + Lim = 0; + } +} + + + + + +word IOBUF::Read (void far * buf, word len) +{ + word total = 0; + while (len) + { + if (Ptr >= Lim) ReadBuff(); + word n = Lim - Ptr; + if (n) + { + if (len < n) n = len; + _fmemcpy(buf, Buff+Ptr, n); + (byte far *) buf += n; + len -= n; + total += n; + Ptr += n; + } + else break; + } + return total; +} + + + + + + +word IOBUF::Read (byte far * buf) +{ + word total = 0; + + while (total < LINE_MAX-2) + { + if (Ptr >= Lim) ReadBuff(); + byte far * p = Buff + Ptr; + word n = Lim - Ptr; + if (n) + { + if (total + n >= LINE_MAX-2) n = LINE_MAX-2 - total; + byte far * eol = (byte far *) _fmemchr(p, '\r', n); + if (eol) n = (word) (eol - p); + byte far * eof = (byte far *) _fmemchr(p, '\32', n); + if (eof) // end-of-file + { + n = (word) (eof - p); + Ptr = (word) (eof - Buff); + } + if (n) _fmemcpy(buf, p, n); + buf += n; + total += n; + if (eof) break; + Ptr += n; + if (eol) + { + ++ Ptr; + * (buf ++) = '\n'; + ++ total; + if (Ptr >= Lim) ReadBuff(); + if (Ptr < Lim) if (Buff[Ptr] == '\n') ++ Ptr; + break; + } + } + else break; + } + *buf = '\0'; + return total; +} + + + + + + + +word IOBUF::Write (void far * buf, word len) +{ + word tot = 0; + while (len) + { + word n = IOBUF_SIZE - Lim; + if (n > len) n = len; + if (n) + { + _fmemcpy(Buff+Lim, buf, n); + Lim += n; + len -= n; + (byte far *) buf += n; + tot += n; + } + else WriteBuff(); + } + return tot; +} + + + + + + +word IOBUF::Write (byte far * buf) +{ + word len = 0; + if (buf) + { + len = _fstrlen((const char far *) buf); + if (len) if (buf[len-1] == '\n') -- len; + len = Write(buf, len); + if (len) + { + static char EOL[] = "\r\n"; + word n = Write(EOL, sizeof(EOL)-1); + len += n; + } + } + return len; +} + + + + + + +int IOBUF::Read (void) +{ + if (Ptr >= Lim) + { + ReadBuff(); + if (Lim == 0) return -1; + } + return Buff[Ptr ++]; +} + + + + + + +void IOBUF::Write (byte b) +{ + if (Lim >= IOBUF_SIZE) + { + WriteBuff(); + } + Buff[Lim ++] = b; +} + + + + + + + word CFILE::MaxLineLen = LINE_MAX; + + + + + + + + +CFILE::CFILE (const char near * name, IOMODE mode, CRYPT * crpt) +: IOBUF(name, mode, crpt) +{ +} + + + + + + + + + +CFILE::~CFILE (void) +{ +} + + + + + + +void CFILE::Flush (void) +{ + if (Mode > REA) WriteBuff(); + else Lim = 0; + _BX = Handle; + _AH = 0x68; // Flush buffer + asm int 0x21 +} + + + + + +long CFILE::Mark (void) +{ + return BufMark + ((Mode > REA) ? Lim : Ptr); +} + + + + + +long CFILE::Seek (long pos) +{ + if (pos >= BufMark && pos < BufMark + Lim) + { + ((Mode == REA) ? Ptr : Lim) = (word) (pos - BufMark); + return pos; + } + else + { + if (Mode > REA) + { + WriteBuff(); + } + else + { + Lim = 0; + } + Ptr = 0; + return BufMark = IOHAND::Seek(pos); + } +} + + + + + + +void CFILE::Append (CFILE& f) +{ + Seek(Size()); + if (f.Error == 0) + { + while (TRUE) + { + if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) WriteBuff(); + else break; + if ((Error = f.Error) != 0) break; + } + } +} diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h new file mode 100644 index 0000000000..57ff38831c --- /dev/null +++ b/engines/cge/cfile.h @@ -0,0 +1,56 @@ +#ifndef __CFILE__ +#define __CFILE__ + +#include +#include + + +#define LINE_MAX 512 + +#ifndef IOBUF_SIZE + #define IOBUF_SIZE K(2) +#endif + +#define CFREAD(x) Read((byte far *)(x),sizeof(*(x))) + + + + +class IOBUF : public IOHAND +{ +protected: + byte far * Buff; + word Ptr, Lim; + long BufMark; + word Seed; + CRYPT * Crypt; + virtual void ReadBuff (void); + virtual void WriteBuff (void); +public: + IOBUF (IOMODE mode, CRYPT * crpt = NULL); + IOBUF (const char * name, IOMODE mode, CRYPT * crpt = NULL); + virtual ~IOBUF (void); + word Read (void far * buf, word len); + word Read (char far * buf); + int Read (void); + word Write (void far * buf, word len); + word Write (byte far * buf); + void Write (byte b); +}; + + + +class CFILE : public IOBUF +{ +public: + static word MaxLineLen; + CFILE (const char near * name, IOMODE mode = REA, CRYPT * crpt = NULL); + virtual ~CFILE (void); + void Flush (void); + long Mark (void); + long Seek (long pos); + void Append (CFILE& f); +}; + + +#endif diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index e7c462e772..5613c3bb68 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -33,6 +33,7 @@ #include "engines/util.h" #include "cge/cge.h" +#include "cge/cge_main.h" namespace CGE { @@ -61,7 +62,9 @@ Common::Error CGEEngine::run() { // Additional setup. debug("CGEEngine::init"); - + + cge_main(); + return Common::kNoError; } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index fac4f2c6cc..cb2c507ffa 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -40,7 +40,7 @@ class Console; enum { kCGEDebug = 1 << 0 }; - + class CGEEngine : public Engine { public: CGEEngine(OSystem *syst, const ADGameDescription *gameDescription); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp new file mode 100644 index 0000000000..23865ec386 --- /dev/null +++ b/engines/cge/cge_main.cpp @@ -0,0 +1,2232 @@ +#include "cge\general.h" +#include "cge\boot.h" +#include "cge\ident.h" +#include "cge\sound.h" +#include "cge\startup.h" +#include "cge\config.h" +#include "cge\vga13h.h" +#include "cge\snail.h" +#include "cge\text.h" +#include "cge\game.h" +#include "cge\mouse.h" +#include "cge\keybd.h" +#include "cge\cfile.h" +#include "cge\vol.h" +#include "cge\talk.h" +#include "cge\vmenu.h" +#include "cge\gettext.h" +#include "cge\mixer.h" +#include "cge\cge_main.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define STACK_SIZ (K(2)) +#define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText) + +#ifdef DEMO + #ifdef DEBUG + #define SVG0NAME ("{{INIT}}" SVG_EXT) + #else + #define SVG0NAME (ProgName(SVG_EXT)) + #endif +#else + #define SVG0NAME ("{{INIT}}" SVG_EXT) +#endif + +#ifdef DEBUG + #define SVG0FILE CFILE +#else + #define SVG0FILE INI_FILE +#endif + +extern word _stklen = (STACK_SIZ * 2); + +// 0.75 - 17II95 - full sound support +// 0.76 - 18II95 - small MiniEMS in DEMO, +// unhide CavLight in SNLEVEL +// keyclick suppress in startup +// keyclick on key service in: SYSTEM, GET_TEXT +// 1.01 - 17VII95 - default savegame with sound ON +// coditionals EVA for 2-month evaluation version + +/* + char Copr[] = "Common Game Engine " + #ifdef EVA + "ú" + #else + #ifdef CD + "ù" + #else + " " + #endif + #endif + " version 1.05 [" + #if sizeof(INI_FILE) == sizeof(VFILE) + "I" + #else + "i" + #endif + #if sizeof(PIC_FILE) == sizeof(VFILE) + "B" + #else + "b" + #endif + "]\n" + "Copyright (c) 1994 by Janusz B. Wi$niewski"; +*/ + char Copr[] = "To be fixed - Copr[]"; + +static char UsrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; +static int OldLev = 0; +static int DemoText = DEMO_TEXT; + +//-------------------------------------------------------------------------- + + Boolean JBW = FALSE; + DAC *SysPal = farnew(DAC, PAL_CNT); + +//------------------------------------------------------------------------- + SPRITE PocLight = LI; + SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, }; + int PocPtr = 0; +//------------------------------------------------------------------------- +//extern SPRITE * PocLight; +//extern SPRITE * Pocket[]; +//extern int PocPtr; +//------------------------------------------------------------------------- + + MOUSE Mouse; +static SPRITE * Sprite = NULL; +static SPRITE * MiniCave = NULL; +static SPRITE * Shadow = NULL; + +static VGA Vga = M13H; +static EMS * Mini = MiniEmm.Alloc((word)MINI_EMM_SIZE); +static BMP_PTR * MiniShpList = NULL; +static BMP_PTR MiniShp[] = { NULL, NULL }; +static KEYBOARD Keyboard; +static Boolean Finis = FALSE; +static int Startup = 1; +static int OffUseCount = atoi(Text[OFF_USE_COUNT]); + word * intStackPtr = FALSE; + + + HXY HeroXY[CAVE_MAX] = {{0,0}}; + BAR Barriers[1+CAVE_MAX] = { { 0xFF, 0xFF } }; + + +extern int FindPocket (SPRITE *); + +extern DAC StdPal[58]; + +#ifdef DEBUG +static SPRITE HorzLine = HL; +#endif + + + +void FeedSnail (SPRITE * spr, SNLIST snq); // defined in SNAIL + +//-------------------------------------------------------------------------- + + + + +byte CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; + + + +byte & CLUSTER::Cell (void) +{ + return Map[B][A]; +} + + + + + + + + +Boolean CLUSTER::Protected (void) +{ + if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return TRUE; + + _DX = (MAP_ZCNT << 8) + MAP_XCNT; + _BX = (word) this; + + asm mov ax,1 + asm mov cl,[bx].(COUPLE)A + asm mov ch,[bx].(COUPLE)B + asm test cx,0x8080 // (A < 0) || (B < 0) + asm jnz xit + + asm cmp cl,dl + asm jge xit + asm cmp ch,dh + asm jge xit + +// if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return TRUE; + + asm mov al,dl + asm mul ch + asm xor ch,ch + asm add ax,cx + asm mov bx,ax + _BX += (word) Map; + //asm add bx,offset CLUSTER::Map + asm mov al,[bx] + asm and ax,0xFF + asm jz xit + asm mov ax,1 + +// return Map[B][A] != 0; + + xit: return _AX; +} + + + + + +CLUSTER XZ (int x, int y) +{ + if (y < MAP_TOP) y = MAP_TOP; + if (y > MAP_TOP + MAP_HIG - MAP_ZGRID) y = MAP_TOP + MAP_HIG - MAP_ZGRID; + return CLUSTER(x / MAP_XGRID, (y-MAP_TOP) / MAP_ZGRID); +} + + + + +CLUSTER XZ (COUPLE xy) +{ + signed char x, y; + xy.Split(x, y); + return XZ(x, y); +} + + + + + + + +//-------------------------------------------------------------------------- + + + int pocref[POCKET_NX]; + byte volume[2]; + struct SAVTAB { void * Ptr; int Len; byte Flg; } SavTab[] = + {{ &Now, sizeof(Now), 1 }, + { &OldLev, sizeof(OldLev), 1 }, + { &DemoText, sizeof(DemoText), 1 }, + { &Game, sizeof(Game), 1 }, + { &Game, sizeof(Game), 1 }, // spare 1 + { &Game, sizeof(Game), 1 }, // spare 2 + { &Game, sizeof(Game), 1 }, // spare 3 + { &Game, sizeof(Game), 1 }, // spare 4 + { &VGA::Mono, sizeof(VGA::Mono), 0 }, + { &Music, sizeof(Music), 1 }, + { volume, sizeof(volume), 1 }, + + { Flag, sizeof(Flag), 1 }, + { HeroXY, sizeof(HeroXY), 1 }, + { Barriers, sizeof(Barriers), 1 }, + { pocref, sizeof(pocref), 1 }, + { NULL, 0, 0 } }; + + + + + +static void LoadGame (XFILE& file, Boolean tiny = FALSE) +{ + SAVTAB * st; + SPRITE * spr; + int i; + + for (st = SavTab; st->Ptr; st ++) + { + if (file.Error) VGA::Exit("Bad SVG"); + file.Read((byte far *) ((tiny || st->Flg) ? st->Ptr : &i), st->Len); + } + + file.Read((byte far *) &i, sizeof(i)); + if (i != SVGCHKSUM) VGA::Exit(BADSVG_TEXT); + if (STARTUP::Core < CORE_HIG) Music = FALSE; + if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) + { + SNDDrvInfo.VOL2.D = volume[0]; + SNDDrvInfo.VOL2.M = volume[1]; + SNDSetVolume(); + } + + if (! tiny) // load sprites & pocket + { + while (! file.Error) + { + SPRITE S(NULL); + word n = file.Read((byte far *) &S, sizeof(S)); + + if (n != sizeof(S)) break; + S.Prev = S.Next = NULL; + spr = (stricmp(S.File+2, "MUCHA") == 0) ? new FLY(NULL) + : new SPRITE(NULL); + if (spr == NULL) VGA::Exit("No core"); + *spr = S; + VGA::SpareQ.Append(spr); + } + + for (i = 0; i < POCKET_NX; i ++) + { + register int r = pocref[i]; + Pocket[i] = (r < 0) ? NULL : VGA::SpareQ.Locate(r); + } + } +} + + + + +static void SaveSound (void) +{ + CFILE cfg(UsrPath(ProgName(CFG_EXT)), WRI); + if (! cfg.Error) cfg.Write(&SNDDrvInfo,sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); +} + + + + + + +static void SaveGame (XFILE& file) +{ + SAVTAB * st; + SPRITE * spr; + int i; + + for (i = 0; i < POCKET_NX; i ++) + { + register SPRITE * s = Pocket[i]; + pocref[i] = (s) ? s->Ref : -1; + } + + volume[0] = SNDDrvInfo.VOL2.D; + volume[1] = SNDDrvInfo.VOL2.M; + + for (st = SavTab; st->Ptr; st ++) + { + if (file.Error) VGA::Exit("Bad SVG"); + file.Write((byte far *) st->Ptr, st->Len); + } + + file.Write((byte far *) &(i = SVGCHKSUM), sizeof(i)); + + for (spr = VGA::SpareQ.First(); spr; spr = spr->Next) + if (spr->Ref >= 1000) + if (!file.Error) file.Write((byte far *)spr, sizeof(*spr)); +} + + + + + + + +static void HeroCover (int cvr) +{ + SNPOST(SNCOVER, 1, cvr, NULL); +} + + + + +static void Trouble (int seq, int txt) +{ + Hero->Park(); + SNPOST(SNWAIT, -1, -1, Hero); + SNPOST(SNSEQ, -1, seq, Hero); + SNPOST(SNSOUND, -1, 2, Hero); + SNPOST(SNWAIT, -1, -1, Hero); + SNPOST(SNSAY, 1, txt, Hero); +} + + + +static void OffUse (void) +{ + Trouble(OFF_USE, OFF_USE_TEXT+random(OffUseCount)); +} + + + + +static void TooFar (void) +{ + Trouble(TOO_FAR, TOO_FAR_TEXT); +} + + + + +static void NoWay (void) +{ + Trouble(NO_WAY, NO_WAY_TEXT); +} + + + + + +static void LoadHeroXY (void) +{ + INI_FILE cf(ProgName(".HXY")); + memset(HeroXY, 0, sizeof(HeroXY)); + if (! cf.Error) cf.CFREAD(&HeroXY); +} + + + + + +static void LoadMapping (void) +{ + if (Now <= CAVE_MAX) + { + INI_FILE cf(ProgName(".TAB")); + if (! cf.Error) + { + memset(CLUSTER::Map, 0, sizeof(CLUSTER::Map)); + cf.Seek((Now - 1) * sizeof(CLUSTER::Map)); + cf.Read((byte far *) CLUSTER::Map, sizeof(CLUSTER::Map)); + } + } +} + + + + + + +//-------------------------------------------------------------------------- + +CLUSTER Trace[MAX_FIND_LEVEL]; +int FindLevel; + + + + + + + + +WALK::WALK (BMP_PTR * shpl) +: SPRITE(shpl), Dir(NO_DIR), TracePtr(-1) +{ +} + + + + + +void WALK::Tick (void) +{ + if (Flags.Hide) return; + + Here = XZ(X+W/2, Y+H); + + if (Dir != NO_DIR) + { + SPRITE * spr; + SYSTEM::FunTouch(); + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) + { + if (Distance(spr) < 2) + { + if (! spr->Flags.Near) + { + FeedSnail(spr, NEAR); + spr->Flags.Near = TRUE; + } + } + else spr->Flags.Near = FALSE; + } + } + + if (Flags.Hold || TracePtr < 0) Park(); + else + { + if (Here == Trace[TracePtr]) + { + if (-- TracePtr < 0) Park(); + } + else + { + signed char dx, dz; + (Trace[TracePtr] - Here).Split(dx, dz); + DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN); + Turn(d); + } + } + Step(); + if ((Dir == WW && X <= 0) || + (Dir == EE && X + W >= SCR_WID) || + (Dir == SS && Y + W >= WORLD_HIG-2)) Park(); + else + { + signed char x; // dummy var + Here.Split(x, Z); // take current Z position + SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue + } +} + + + + + + +int WALK::Distance (SPRITE * spr) +{ + int dx, dz; + dx = spr->X - (X+W-WALKSIDE); + if (dx < 0) dx = (X+WALKSIDE) - (spr->X+spr->W); + if (dx < 0) dx = 0; + dx /= MAP_XGRID; + dz = spr->Z - Z; + if (dz < 0) dz = - dz; + dx = dx * dx + dz * dz; + for (dz = 1; dz * dz < dx; dz ++) ; + return dz-1; +} + + + + + + + + + + +void WALK::Turn (DIR d) +{ + DIR dir = (Dir == NO_DIR) ? SS : Dir; + if (d != Dir) + { + Step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); + Dir = d; + } +} + + + + + +void WALK::Park (void) +{ + if (Time == 0) ++ Time; + if (Dir != NO_DIR) + { + Step(9 + 4 * Dir + Dir); + Dir = NO_DIR; + TracePtr = -1; + } +} + + + + + + + +void WALK::FindWay (CLUSTER c) +{ + Boolean Find1Way(void); + extern word Target; + + if (c != Here) + { + for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel ++) + { + signed char x, z; + Here.Split(x, z); + Target = (z << 8) | x; + c.Split(x, z); + _CX = (z << 8) | x; + if (Find1Way()) break; + } + TracePtr = (FindLevel > MAX_FIND_LEVEL) ? -1 : (FindLevel - 1); + if (TracePtr < 0) NoWay(); + Time = 1; + } +} + + + + + + +void WALK::FindWay (SPRITE * spr) +{ + if (spr && spr != this) + { + int x = spr->X, z = spr->Z; + if (spr->Flags.East) x += spr->W + W/2 - WALKSIDE; + else x -= W/2 - WALKSIDE; + FindWay(CLUSTER((x/MAP_XGRID), + ((z < MAP_ZCNT-MAX_DISTANCE) ? (z+1) + : (z-1)))); + } +} + + + + + + +Boolean WALK::Lower (SPRITE * spr) +{ + return (spr->Y > Y + (H * 3) / 5); +} + + + + + + +void WALK::Reach (SPRITE * spr, int mode) +{ + if (spr) + { + Hero->FindWay(spr); + if (mode < 0) + { + mode = spr->Flags.East; + if (Lower(spr)) mode += 2; + } + } + // note: insert SNAIL commands in reverse order + SNINSERT(SNPAUSE, -1, 64, NULL); + SNINSERT(SNSEQ, -1, TSEQ + mode, this); + if (spr) + { + SNINSERT(SNWAIT, -1, -1, Hero); /////--------$$$$$$$ + //SNINSERT(SNWALK, -1, -1, spr); + } + // sequence is not finished, + // now it is just at sprite appear (disappear) point +} + + + + + + +//-------------------------------------------------------------------------- + + + +#ifdef DEBUG + + +class SQUARE : public SPRITE +{ +public: + SQUARE (void); + void Touch (word mask, int x, int y); +}; + + + + + + +SQUARE::SQUARE (void) +: SPRITE(MB) +{ + Flags.Kill = TRUE; + Flags.BDel = FALSE; +} + + + + + + + + +void SQUARE::Touch (word mask, int x, int y) +{ + SPRITE::Touch(mask, x, y); + if (mask & L_UP) + { + XZ(X+x, Y+y).Cell() = 0; + SNPOST_(SNKILL, -1, 0, this); + } +} + + + + + + +static void SetMapBrick (int x, int z) +{ + SQUARE * s = new SQUARE; + if (s) + { + static char n[] = "00:00"; + s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); + wtom(x, n+0, 10, 2); + wtom(z, n+3, 10, 2); + CLUSTER::Map[z][x] = 1; + s->SetName(n); + VGA::ShowQ.Insert(s, VGA::ShowQ.First()); + } +} + + +#endif + + + +//-------------------------------------------------------------------------- + +void dummy (void) { } +void SwitchMapping (void); +void SwitchColorMode (void); +void StartCountDown (void); +Debug( void SwitchDebug (void); ) +void SwitchMusic (void); +void KillSprite (void); +void PushSprite (void); +void PullSprite (void); +void BackPaint (void); +void NextStep (void); +void SaveMapping (void); + + + WALK * Hero = NULL; +static INFO_LINE InfoLine = INFO_W; + +static HEART Heart; + +static SPRITE CavLight = PR; + + + + + +static void KeyClick (void) +{ + SNPOST_(SNSOUND, -1, 5, NULL); +} + + + +static void ResetQSwitch (void) +{ + SNPOST_(SNSEQ, 123, 0, NULL); + KeyClick(); +} + + + + +static void Quit (void) +{ + static CHOICE QuitMenu[]={ { NULL, StartCountDown }, + { NULL, ResetQSwitch }, + { NULL, dummy } }; + + if (Snail.Idle() && ! Hero->Flags.Hide) + { + if (VMENU::Addr) + { + SNPOST_(SNKILL, -1, 0, VMENU::Addr); + ResetQSwitch(); + } + else + { + QuitMenu[0].Text = Text[QUIT_TEXT]; + QuitMenu[1].Text = Text[NOQUIT_TEXT]; + (new VMENU(QuitMenu, -1, -1))->SetName(Text[QUIT_TITLE]); + SNPOST_(SNSEQ, 123, 1, NULL); + KeyClick(); + } + } +} + + + + +static void AltCtrlDel (void) +{ + #if 0 + //def DEBUG + if (KEYBOARD::Key[LSHIFT] || KEYBOARD::Key[RSHIFT]) + { + PostFlag = 0x1234; + POST(); + } + else + #endif + SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero); +} + + + + +static void MiniStep (int stp) +{ + if (stp < 0) MiniCave->Flags.Hide = TRUE; + else + { + &*Mini; + *MiniShp[0] = *MiniShpList[stp]; + if (Fx.Current) &*(Fx.Current->EAddr()); + MiniCave->Flags.Hide = FALSE; + } +} + + + + + +static void PostMiniStep (int stp) +{ + static int recent = -2; + if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *) MiniStep); +} + + + +//-------------------------------------------------------------------------- + + + +int SYSTEM::FunDel = HEROFUN0; + + + + +void SYSTEM::SetPal (void) +{ + int i; + DAC far * p = SysPal + 256-ArrayCount(StdPal); + for (i = 0; i < ArrayCount(StdPal); i ++) + { + p[i].R = StdPal[i].R >> 2; + p[i].G = StdPal[i].G >> 2; + p[i].B = StdPal[i].B >> 2; + } +} + + + + + +void SYSTEM::FunTouch (void) +{ + word n = (PAIN) ? HEROFUN1 : HEROFUN0; + if (Talk == NULL || n > FunDel) FunDel = n; +} + + + + + + +static void ShowBak (int ref) +{ + SPRITE * spr = VGA::SpareQ.Locate(ref); + if (spr) + { + BITMAP::Pal = SysPal; + spr->Expand(); + BITMAP::Pal = NULL; + spr->Show(2); + VGA::CopyPage(1, 2); + SYSTEM::SetPal(); + spr->Contract(); + } +} + + + + + + +static void CaveUp (void) +{ + int BakRef = 1000 * Now; + if (Music) LoadMIDI(Now); + ShowBak(BakRef); + LoadMapping(); + Text.Preload(BakRef, BakRef+1000); + SPRITE * spr = VGA::SpareQ.First(); + while (spr) + { + SPRITE * n = spr->Next; + if (spr->Cave == Now || spr->Cave == 0) + if (spr->Ref != BakRef) + { + if (spr->Flags.Back) spr->BackShow(); + else ExpandSprite(spr); + } + spr = n; + } + if (SNDDrvInfo.DDEV) + { + Sound.Stop(); + Fx.Clear(); + Fx.Preload(0); + Fx.Preload(BakRef); + } + + if (Hero) + { + Hero->Goto(HeroXY[Now-1].X, HeroXY[Now-1].Y); + // following 2 lines trims Hero's Z position! + Hero->Tick(); + Hero->Time = 1; + Hero->Flags.Hide = FALSE; + } + + if (! Dark) Vga.Sunset(); + VGA::CopyPage(0, 1); + SelectPocket(-1); + if (Hero) VGA::ShowQ.Insert(VGA::ShowQ.Remove(Hero)); + if (Shadow) + { + VGA::ShowQ.Remove(Shadow); + Shadow->MakeXlat(Glass(SysPal, 204, 204, 204)); + VGA::ShowQ.Insert(Shadow, Hero); + Shadow->Z = Hero->Z; + } + FeedSnail(VGA::ShowQ.Locate(BakRef+999), TAKE); + Vga.Show(); + Vga.CopyPage(1, 0); + Vga.Show(); + Vga.Sunrise(SysPal); + Dark = FALSE; + if (! Startup) Mouse.On(); + HEART::Enable = TRUE; +} + + + + + +static void CaveDown (void) +{ + SPRITE * spr; + Debug( if (! HorzLine.Flags.Hide) SwitchMapping(); ) + + for (spr = VGA::ShowQ.First(); spr; ) + { + SPRITE * n = spr->Next; + if (spr->Ref >= 1000 /*&& spr->Cave*/) + { + if (spr->Ref % 1000 == 999) FeedSnail(spr, TAKE); + VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); + } + spr = n; + } + Text.Clear(1000); +} + + + + + +static void XCave (void) +{ + CaveDown(); + CaveUp(); +} + + + + +static void QGame (void) +{ + CaveDown(); + OldLev = Lev; + SaveSound(); + SaveGame(CFILE(UsrPath(UsrFnam), WRI, RCrypt)); + Vga.Sunset(); + Finis = TRUE; +} + + + + +void SwitchCave (int cav) +{ + if (cav != Now) + { + HEART::Enable = FALSE; + if (cav < 0) + { + SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint + SNPOST(SNEXEC, -1, 0, (void *) QGame); // switch cave + } + else + { + Now = cav; + Mouse.Off(); + if (Hero) + { + Hero->Park(); + Hero->Step(0); + #ifndef DEMO + ///// protection: auto-destruction on! ---------------------- + VGA::SpareQ.Show = STARTUP::Summa * (cav <= CAVE_MAX); + /////-------------------------------------------------------- + #endif + } + CavLight.Goto(CAVE_X + ((Now-1) % CAVE_NX) * CAVE_DX + CAVE_SX, + CAVE_Y + ((Now-1) / CAVE_NX) * CAVE_DY + CAVE_SY); + KillText(); + if (! Startup) KeyClick(); + SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint + SNPOST(SNEXEC, 0, 0, (void *) XCave); // switch cave + } + } +} + + + + + + +void SYSTEM::Touch (word mask, int x, int y) +{ + static int pp = 0; + void SwitchCave (int cav); + int cav = 0; + + FunTouch(); + + if (mask & KEYB) + { + int pp0; + KeyClick(); + KillText(); + if (Startup == 1) + { + SNPOST(SNCLEAR, -1, 0, NULL); + return; + } + pp0 = pp; + switch (x) + { + case Del : if (KEYBOARD::Key[ALT] && + KEYBOARD::Key[CTRL]) AltCtrlDel(); + Debug ( else KillSprite(); ) + break; + case 'F' : if (KEYBOARD::Key[ALT]) + { + SPRITE * m = VGA::ShowQ.Locate(17001); + if (m) + { + m->Step(1); + m->Time = 216; // 3s + } + } + break; + + #ifdef DEBUG + case PgUp : PushSprite(); break; + case PgDn : PullSprite(); break; + case '+' : NextStep(); break; + case '`' : if (KEYBOARD::Key[ALT]) SaveMapping(); else SwitchMapping(); break; + case F1 : SwitchDebug(); break; + case F3 : Hero->Step(TSEQ + 4); break; + case F4 : Hero->Step(TSEQ + 5); break; + case F5 : Hero->Step(TSEQ + 0); break; + case F6 : Hero->Step(TSEQ + 1); break; + case F7 : Hero->Step(TSEQ + 2); break; + case F8 : Hero->Step(TSEQ + 3); break; + case F9 : SYSTEM::FunDel = 1; break; + case 'X' : if (KEYBOARD::Key[ALT]) Finis = TRUE; break; + case '0' : + case '1' : + case '2' : + case '3' : + case '4' : if (KEYBOARD::Key[ALT]) { SNPOST(SNLEVEL, -1, x - '0', NULL); break; } + case '5' : + case '6' : + case '7' : + case '8' : + case '9' : if (Sprite) Sprite->Step(x - '0'); break; + #else + case '1' : + case '2' : + case '3' : + case '4' : + case '5' : + case '6' : + case '7' : + case '8' : SelectPocket(x - '1'); break; + #endif + + case F10 : if (Snail.Idle() && ! Hero->Flags.Hide) + StartCountDown(); + break; + case 'J' : if (pp == 0) ++ pp; break; + case 'B' : if (pp == 1) ++ pp; break; + case 'W' : if (pp == 2) JBW = !JBW; break; + } + if (pp == pp0) pp = 0; + } + else + { + if (Startup) return; + InfoLine.Update(NULL); + if (y >= WORLD_HIG) + { + if (x < BUTTON_X) // select cave? + { + if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && + x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && ! Game) + { + cav = ((y-CAVE_Y) / CAVE_DY) * CAVE_NX + (x-CAVE_X) / CAVE_DX + 1; + if (cav > MaxCave) cav = 0; + } + else + { + cav = 0; + } + } + else if (mask & L_UP) + { + if (y >= POCKET_Y && y < POCKET_Y + POCKET_NY * POCKET_DY && + x >= POCKET_X && x < POCKET_X + POCKET_NX * POCKET_DX) + { + int n = ((y-POCKET_Y) / POCKET_DY) * POCKET_NX + (x-POCKET_X) / POCKET_DX; + SelectPocket(n); + } + } + } + + PostMiniStep(cav-1); + + if (mask & L_UP) + { + if (cav && Snail.Idle() && Hero->TracePtr < 0) + { + SwitchCave(cav); + } + #ifdef DEBUG + if (! HorzLine.Flags.Hide) + { + if (y >= MAP_TOP && y < MAP_TOP+MAP_HIG) + { + signed char x1, z1; + XZ(x, y).Split(x1, z1); + CLUSTER::Map[z1][x1] = 1; + SetMapBrick(x1, z1); + } + } + else + #endif + { + if (! Talk && Snail.Idle() && Hero + && y >= MAP_TOP && y < MAP_TOP+MAP_HIG && ! Game) + { + Hero->FindWay(XZ(x, y)); + } + } + } + } +} + + + + + + + +void SYSTEM::Tick (void) +{ + if (! Startup) if (-- FunDel == 0) + { + KillText(); + if (Snail.Idle()) + { + if (PAIN) HeroCover(9); + else if (STARTUP::Core >= CORE_MID) + { + int n = random(100); + if (n > 96) HeroCover(6+(Hero->X+Hero->W/2 < SCR_WID/2)); + else + { + if (n > 90) HeroCover(5); + else + { + if (n > 60) HeroCover(4); + else HeroCover(3); + } + } + } + } + FunTouch(); + } + Time = SYSTIMERATE; +} + + + + + + + + + + +//-------------------------------------------------------------------------- + + + +/* +static void SpkOpen (void) +{ + asm in al,0x61 + asm or al,0x03 + asm out 0x61,al + asm mov al,0x90 + asm out 0x43,al +} + + + + + +static void SpkClose (void) +{ + asm in al,0x61 + asm and al,0xFC + asm out 0x61,al +} + +*/ + + + +static void SwitchColorMode (void) +{ + SNPOST_(SNSEQ, 121, VGA::Mono = ! VGA::Mono, NULL); + KeyClick(); + VGA::SetColors(SysPal, 64); +} + + + +static void SwitchMusic (void) +{ + if (KEYBOARD::Key[ALT]) + { + if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); + else + { + SNPOST_(SNSEQ, 122, (Music = FALSE), NULL); + SNPOST(SNEXEC, -1, 0, (void *) SelectSound); + } + } + else + { + if (STARTUP::Core < CORE_HIG) SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL); + else + { + SNPOST_(SNSEQ, 122, (Music = ! Music), NULL); + KeyClick(); + } + } + if (Music) LoadMIDI(Now); + else KillMIDI(); +} + + + + + +static void StartCountDown (void) +{ + //SNPOST(SNSEQ, 123, 0, NULL); + SwitchCave(-1); +} + + + + +#ifndef DEMO +static void TakeName (void) +{ + if (GET_TEXT::Ptr) SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr); + else + { + GET_TEXT * tn = new GET_TEXT(Text[GETNAME_PROMPT], UsrFnam, 8, KeyClick); + if (tn) + { + tn->SetName(Text[GETNAME_TITLE]); + tn->Center(); + tn->Goto(tn->X, tn->Y - 10); + tn->Z = 126; + VGA::ShowQ.Insert(tn); + } + } +} +#endif + + + + + +#ifdef DEBUG + + +static void SwitchMapping (void) +{ + if (HorzLine.Flags.Hide) + { + int i; + for (i = 0; i < MAP_ZCNT; i ++) + { + int j; + for (j = 0; j < MAP_XCNT; j ++) + { + if (CLUSTER::Map[i][j]) + SetMapBrick(j, i); + } + } + } + else + { + SPRITE * s; + for (s = VGA::ShowQ.First(); s; s = s->Next) + if (s->W == MAP_XGRID && s->H == MAP_ZGRID) + SNPOST_(SNKILL, -1, 0, s); + } + HorzLine.Flags.Hide = ! HorzLine.Flags.Hide; +} + + + + + +static void KillSprite (void) +{ + Sprite->Flags.Kill = TRUE; + Sprite->Flags.BDel = TRUE; + SNPOST_(SNKILL, -1, 0, Sprite); + Sprite = NULL; +} + + + + + +static void PushSprite (void) +{ + SPRITE * spr = Sprite->Prev; + if (spr) + { + VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr); + while (Sprite->Z > Sprite->Next->Z) -- Sprite->Z; + } + else SNPOST_(SNSOUND, -1, 2, NULL); +} + + + + + +static void PullSprite (void) +{ + Boolean ok = FALSE; + SPRITE * spr = Sprite->Next; + if (spr) + { + spr = spr->Next; + if (spr) + { + ok = (! spr->Flags.Slav); + } + } + if (ok) + { + VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr); + if (Sprite->Prev) + while (Sprite->Z < Sprite->Prev->Z) ++ Sprite->Z; + } + else SNPOST_(SNSOUND, -1, 2, NULL); +} + + + + + + +static void NextStep (void) +{ + SNPOST_(SNSTEP, 0, 0, Sprite); +} + + + + + + + + + +static void SaveMapping (void) +{ + { + IOHAND cf(ProgName(".TAB"), UPD); + if (! cf.Error) + { + cf.Seek((Now-1) * sizeof(CLUSTER::Map)); + cf.Write((byte far *) CLUSTER::Map, sizeof(CLUSTER::Map)); + } + } + { + IOHAND cf(ProgName(".HXY"), WRI); + if (! cf.Error) + { + HeroXY[Now-1].X = Hero->X; + HeroXY[Now-1].Y = Hero->Y; + cf.Write((byte far *) HeroXY, sizeof(HeroXY)); + } + } +} + +#endif + + + +//-------------------------------------------------------------------------- + + + + + + + + + +#ifdef DEBUG + + + + // 1111111111222222222233333333 334444444444555555555566666666667777777777 + // 01234567890123456789012345678901234567 890123456789012345678901234567890123456789 +static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 000:000:000 000:000 00 "; + +#define NFRE (DebugText + 3) +#define FFRE (DebugText + 11) +#define ABSX (DebugText + 20) +#define ABSY (DebugText + 26) +#define FRPS (DebugText + 34) +#define XSPR (DebugText + 38) +#define SP_N (DebugText + 41) +#define SP_S (DebugText + 44) + +#define SP_X (DebugText + 47) +#define SP_Y (DebugText + 51) +#define SP_Z (DebugText + 55) +#define SP_W (DebugText + 59) +#define SP_H (DebugText + 63) +#define SP_F (DebugText + 67) +#define SP__ (DebugText + 70) + +INFO_LINE DebugLine(SCR_WID); + +static void SayDebug (void) +{ + if (! DebugLine.Flags.Hide) + { + static long t = -1L; + long t1 = Timer(); + + if (t1 - t >= 18) + { + static dword old = 0L; + dword now = Vga.FrmCnt; + dwtom(now - old, FRPS, 10, 4); + old = now; + t = t1; + } + + dwtom(Mouse.X, ABSX, 10, 3); + dwtom(Mouse.Y, ABSY, 10, 3); + dwtom(coreleft(), NFRE, 10, 5); + dwtom(farcoreleft(), FFRE, 10, 6); + + // sprite queue size + word n = 0; + SPRITE * spr; + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) + { + ++ n; + if (spr == Sprite) + { + *XSPR = ' '; + dwtom(n, SP_N, 10, 2); + dwtom(Sprite->X, SP_X, 10, 3); + dwtom(Sprite->Y, SP_Y, 10, 3); + dwtom(Sprite->Z, SP_Z, 10, 3); + dwtom(Sprite->W, SP_W, 10, 3); + dwtom(Sprite->H, SP_H, 10, 3); + dwtom(*(word *) (&Sprite->Flags), SP_F, 16, 2); + } + } + dwtom(n, SP_S, 10, 2); + *SP__ = (heapcheck() < 0) ? '!' : ' '; + DebugLine.Update(DebugText); + } +} + + + + + +static void SwitchDebug (void) +{ + DebugLine.Flags.Hide = ! DebugLine.Flags.Hide; +} + + + +#endif + + + + + + +static void OptionTouch (int opt, word mask) +{ + switch (opt) + { + case 1 : if (mask & L_UP) SwitchColorMode(); break; + case 2 : if (mask & L_UP) SwitchMusic(); + else + if (mask & R_UP) + if (! MIXER::Appear) + { + MIXER::Appear = TRUE; + new MIXER(BUTTON_X, BUTTON_Y); + } + break; + case 3 : if (mask & L_UP) Quit(); break; + } +} + + + + + +#pragma argsused +void SPRITE::Touch (word mask, int x, int y) +{ + SYSTEM::FunTouch(); + if ((mask & ATTN) == 0) + { + InfoLine.Update(Name()); + if (mask & (R_DN | L_DN)) Sprite = this; // DEBUG mode only? + if (Ref/10 == 12) + { + OptionTouch(Ref % 10, mask); + return; + } + if (Flags.Syst) return; // cannot access system sprites + if (Game) if (mask & L_UP) { mask &= ~L_UP; mask |= R_UP; } + if ((mask & R_UP) && Snail.Idle()) + { + SPRITE * ps = (PocLight.SeqPtr) ? Pocket[PocPtr] : NULL; + if (ps) + { + if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) + { + if (Works(ps)) + { + FeedSnail(ps, TAKE); + } + else OffUse(); + SelectPocket(-1); + } + else TooFar(); + } + else + { + if (Flags.Kept) mask |= L_UP; + else + { + if (Hero->Distance(this) < MAX_DISTANCE) + {/// + if (Flags.Port) + { + if (FindPocket(NULL) < 0) PocFul(); + else + { + SNPOST(SNREACH, -1, -1, this); + SNPOST(SNKEEP, -1, -1, this); + Flags.Port = FALSE; + } + } + else + { + if (TakePtr != NO_PTR) + { + if (SnList(TAKE)[TakePtr].Com == SNNEXT) OffUse(); + else FeedSnail(this, TAKE); + } + else OffUse(); + } + }/// + else TooFar(); + } + } + } + if ((mask & L_UP) && Snail.Idle()) + { + if (Flags.Kept) + { + int n; + for (n = 0; n < POCKET_NX; n ++) + { + if (Pocket[n] == this) + { + SelectPocket(n); + break; + } + } + } + else SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this); + } + } +} + + + + + + + +//-------------------------------------------------------------------------- +//-------------------------------------------------------------------------- + + + + + + +static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) +{ + static char * Comd[] = { "Name", "Type", "Phase", "East", + "Left", "Right", "Top", "Bottom", + "Seq", "Near", "Take", + "Portable", "Transparent", + NULL }; + static char * Type[] = { "DEAD", "AUTO", "WALK", "NEWTON", "LISSAJOUS", + "FLY", NULL }; + char line[LINE_MAX]; + + int shpcnt = 0; + int type = 0; // DEAD + Boolean east = FALSE; + Boolean port = FALSE; + Boolean tran = FALSE; + int i, lcnt = 0; + word len; + + MergeExt(line, fname, SPR_EXT); + if (INI_FILE::Exist(line)) // sprite description file exist + { + INI_FILE sprf(line); + if (sprf.Error) + { + VGA::Exit("Bad SPR", line); + } + + while ((len = sprf.Read(line)) != 0) + { + ++ lcnt; + if (len && line[len-1] == '\n') line[-- len] = '\0'; + if (len == 0 || *line == '.') continue; + + if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) + { + VGA::Exit(NumStr("Bad line ######", lcnt), fname); + } + + switch (i) + { + case 0 : // Name - will be taken in Expand routine + break; + case 1 : // Type + if ((type = TakeEnum(Type, strtok(NULL, " \t,;/"))) < 0) + VGA::Exit(NumStr("Bad line ######", lcnt), fname); + break; + case 2 : // Phase + ++ shpcnt; + break; + case 3 : // East + east = (atoi(strtok(NULL, " \t,;/")) != 0); + break; + case 11 : // Portable + port = (atoi(strtok(NULL, " \t,;/")) != 0); + break; + case 12 : // Transparent + tran = (atoi(strtok(NULL, " \t,;/")) != 0); + break; + } + } + if (! shpcnt) + { + VGA::Exit("No shapes", fname); + } + } + else // no sprite description: mono-shaped sprite with only .BMP file + { + ++ shpcnt; + } + + // make sprite of choosen type + switch (type) + { + case 1 : // AUTO + Sprite = new SPRITE(NULL); + if (Sprite) + { + Sprite->Goto(col, row); + //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$ + } + break; + case 2 : // WALK + WALK * w = new WALK(NULL); + if (w && ref == 1) + { + w->Goto(col, row); + if (Hero) + { + VGA::Exit("2nd HERO", fname); + } + Hero = w; + } + Sprite = w; + break; + /* + case 3 : // NEWTON + NEWTON * n = new NEWTON(NULL); + if (n) + { + n->Ay = (bottom-n->H); + n->By = 90; + n->Cy = 3; + n->Bx = 99; + n->Cx = 3; + n->Goto(col, row); + } + Sprite = n; + break; + */ + case 4 : // LISSAJOUS + VGA::Exit("Bad type", fname); + /* + LISSAJOUS * l = new LISSAJOUS(NULL); + if (l) + { + l->Ax = SCR_WID/2; + l->Ay = SCR_HIG/2; + l->Bx = 7; + l->By = 13; + l->Cx = 300; + l->Cy = 500; + * (long *) &l->Dx = 0; // movex * cnt + l->Goto(col, row); + } + Sprite = l; + */ + break; + case 5 : // FLY + FLY * f = new FLY(NULL); + Sprite = f; + //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$ + break; + default: // DEAD + Sprite = new SPRITE(NULL); + if (Sprite) Sprite->Goto(col, row); + break; + } + if (Sprite) + { + Sprite->Ref = ref; + Sprite->Cave = cav; + Sprite->Z = pos; + Sprite->Flags.East = east; + Sprite->Flags.Port = port; + Sprite->Flags.Tran = tran; + Sprite->Flags.Kill = TRUE; + Sprite->Flags.BDel = TRUE; + fnsplit(fname, NULL, NULL, Sprite->File, NULL); + Sprite->ShpCnt = shpcnt; + VGA::SpareQ.Append(Sprite); + } +} + + + + + + +static void LoadScript (const char *fname) +{ + char line[LINE_MAX]; + char * SpN; + int SpI, SpA, SpX, SpY, SpZ; + Boolean BkG = FALSE; + INI_FILE scrf(fname); + int lcnt = 0; + Boolean ok = TRUE; + + if (scrf.Error) return; + + while (scrf.Read(line) != 0) + { + char *p; + + ++ lcnt; + if (*line == 0 || *line == '\n' || *line == '.') continue; + + ok = FALSE; // not OK if break + // sprite ident number + if ((p = strtok(line, " \t\n")) == NULL) break; + SpI = atoi(p); + // sprite file name + if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) break; + // sprite cave + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; + SpA = atoi(p); + // sprite column + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; + SpX = atoi(p); + // sprite row + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; + SpY = atoi(p); + // sprite Z pos + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; + SpZ = atoi(p); + // sprite life + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; + BkG = atoi(p) == 0; + + ok = TRUE; // no break: OK + + Sprite = NULL; + LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); + if (Sprite && BkG) Sprite->Flags.Back = TRUE; + } + if (! ok) + { + VGA::Exit(NumStr("Bad INI line ######", lcnt), fname); + } +} + + + + +static void MainLoop (void) +{ +#if 0 +//def DEBUG + static VgaRegBlk Mode[] = { + + { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode + + { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 + { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 + { 0x06, VGAGRA, 0x02, 0x00 }, // misc + + { 0x14, VGACRT, 0x40, 0x00 }, // underline + { 0x13, VGACRT, 0xFF, 0x28 }, // screen width + { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control + + { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end + { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line + + { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode + +// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end +// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb +// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr + + { 0x00 } }; + + Vga.Setup(Mode); +#endif + + Debug( SayDebug(); ) + + #ifdef DEMO + #define TIM ((182L*6L) * 5L) + static dword tc = 0; + if (TimerCount - tc >= TIM && Talk == NULL && Snail.Idle()) + { + if (Text[DemoText]) + { + SNPOST(SNSOUND, -1, 4, NULL); // drumla + SNPOST(SNINF, -1, DemoText, NULL); + SNPOST(SNLABEL, -1, -1, NULL); + if (Text[++ DemoText] == NULL) DemoText = DEMO_TEXT + 1; + } + tc = TimerCount; + } + #undef TIM + #endif + + Vga.Show(); + Snail_.RunCom(); + Snail.RunCom(); +} + + + + + +void LoadUser (void) +{ + // set scene + if (STARTUP::Mode == 0) // user .SVG file found + { + LoadGame(CFILE(UsrPath(UsrFnam), REA, RCrypt)); + } + else + { + if (STARTUP::Mode == 1) LoadGame(SVG0FILE(SVG0NAME)); + else + { + LoadScript(ProgName(INI_EXT)); + Music = TRUE; + SaveGame(CFILE(SVG0NAME, WRI)); + VGA::Exit("Ok", SVG0NAME); + } + } + LoadScript(ProgName(IN0_EXT)); +} + + + + + +static void RunGame (void) +{ + Text.Clear(); + Text.Preload(100, 1000); + LoadHeroXY(); + + CavLight.Flags.Tran = TRUE; + VGA::ShowQ.Append(&CavLight); + CavLight.Flags.Hide = TRUE; + + static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 }, + { 1, 2, 0, 0, 4 }, + { 2, 3, 0, 0, 4 }, + { 3, 4, 0, 0, 16 }, + { 2, 5, 0, 0, 4 }, + { 1, 6, 0, 0, 4 }, + { 0, 1, 0, 0, 16 }, + }; + PocLight.SetSeq(PocSeq); + PocLight.Flags.Tran = TRUE; + PocLight.Time = 1; + PocLight.Z = 120; + VGA::ShowQ.Append(&PocLight); + SelectPocket(-1); + + VGA::ShowQ.Append(&Mouse); + +// ___________ + LoadUser(); +// ~~~~~~~~~~~ + + if ((Sprite = VGA::SpareQ.Locate(121)) != NULL) + SNPOST_(SNSEQ, -1, VGA::Mono, Sprite); + if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) Sprite->Step(Music); + SNPOST_(SNSEQ, -1, Music, Sprite); + if (! Music) KillMIDI(); + + if (Mini && INI_FILE::Exist("MINI.SPR")) + { + byte far * ptr = (byte far *) &*Mini; + if (ptr != NULL) + { + LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); + ExpandSprite(MiniCave = Sprite); // NULL is ok + if (MiniCave) + { + MiniCave->Flags.Hide = TRUE; + MiniCave->MoveShapes(ptr); + MiniShp[0] = new BITMAP(*MiniCave->Shp()); + MiniShpList = MiniCave->SetShapeList(MiniShp); + PostMiniStep(-1); + } + } + } + + if (Hero) + { + ExpandSprite(Hero); + Hero->Goto(HeroXY[Now-1].X, HeroXY[Now-1].Y); + if (INI_FILE::Exist("00SHADOW.SPR")) + { + LoadSprite("00SHADOW", -1, 0, Hero->X + 14, Hero->Y + 51); + if ((Shadow = Sprite) != NULL) + { + Shadow->Ref = 2; + Shadow->Flags.Tran = TRUE; + Hero->Flags.Shad = TRUE; + VGA::ShowQ.Insert(VGA::SpareQ.Remove(Shadow), Hero); + } + } + } + + InfoLine.Goto(INFO_X, INFO_Y); + InfoLine.Flags.Tran = TRUE; + InfoLine.Update(NULL); + VGA::ShowQ.Insert(&InfoLine); + + #ifdef DEBUG + DebugLine.Z = 126; + VGA::ShowQ.Insert(&DebugLine); + + HorzLine.Y = MAP_TOP - (MAP_TOP > 0); + HorzLine.Z = 126; + VGA::ShowQ.Insert(&HorzLine); + #endif + + Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF); + if (Mouse.Busy) ExpandSprite(Mouse.Busy); + + Startup = 0; + + SNPOST(SNLEVEL, -1, OldLev, &CavLight); + CavLight.Goto(CAVE_X + ((Now-1) % CAVE_NX) * CAVE_DX + CAVE_SX, + CAVE_Y + ((Now-1) / CAVE_NX) * CAVE_DY + CAVE_SY); + CaveUp(); + + KEYBOARD::SetClient(Sys); + // main loop + while (! Finis) + { + if (FINIS) SNPOST(SNEXEC, -1, 0, (void *) QGame); + MainLoop(); + } + + KEYBOARD::SetClient(NULL); + HEART::Enable = FALSE; + SNPOST(SNCLEAR, -1, 0, NULL); + SNPOST_(SNCLEAR, -1, 0, NULL); + Mouse.Off(); + VGA::ShowQ.Clear(); + VGA::SpareQ.Clear(); + Hero = NULL; + Shadow = NULL; +} + + + + +void Movie (const char * ext) +{ + const char * fn = ProgName(ext); + if (INI_FILE::Exist(fn)) + { + LoadScript(fn); + ExpandSprite(VGA::SpareQ.Locate(999)); + FeedSnail(VGA::ShowQ.Locate(999), TAKE); + VGA::ShowQ.Append(&Mouse); + HEART::Enable = TRUE; + KEYBOARD::SetClient(Sys); + while (! Snail.Idle()) + { + MainLoop(); + } + KEYBOARD::SetClient(NULL); + HEART::Enable = FALSE; + SNPOST(SNCLEAR, -1, 0, NULL); + SNPOST_(SNCLEAR, -1, 0, NULL); + VGA::ShowQ.Clear(); + VGA::SpareQ.Clear(); + } +} + + + + + + +Boolean ShowTitle (const char * name) +{ + BITMAP::Pal = SysPal; + BMP_PTR LB[] = { new BITMAP(name), NULL }; + BITMAP::Pal = NULL; + Boolean usr_ok = FALSE; + + SPRITE D(LB); + D.Flags.Kill = TRUE; + D.Flags.BDel = TRUE; + D.Center(); + D.Show(2); + + if (STARTUP::Mode == 2) + { + Inf(SVG0NAME); + Talk->Show(2); + } + + Vga.Sunset(); + VGA::CopyPage(1, 2); + VGA::CopyPage(0, 1); + SelectPocket(-1); + Vga.Sunrise(SysPal); + + if (STARTUP::Mode < 2 && ! STARTUP::SoundOk) + { + VGA::CopyPage(1, 2); + VGA::CopyPage(0, 1); + VGA::ShowQ.Append(&Mouse); + HEART::Enable = TRUE; + Mouse.On(); + for (SelectSound(); ! Snail.Idle() || VMENU::Addr; ) MainLoop(); + Mouse.Off(); + HEART::Enable = FALSE; + VGA::ShowQ.Clear(); + VGA::CopyPage(0, 2); + STARTUP::SoundOk = 2; + if (Music) LoadMIDI(0); + } + + if (STARTUP::Mode < 2) + { + #ifdef DEMO + strcpy(UsrFnam, ProgName(SVG_EXT)); + usr_ok = TRUE; + #else + //----------------------------------------- + #ifndef EVA + #ifdef CD + STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; + #else + Boot * b = ReadBoot(getdisk()); + dword sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; + free(b); + sn -= ((IDENT *)Copr)->disk; + STARTUP::Summa |= Lo(sn) | Hi(sn); + #endif + #endif + //----------------------------------------- + Movie("X00"); // paylist + VGA::CopyPage(1, 2); + VGA::CopyPage(0, 1); + VGA::ShowQ.Append(&Mouse); + //Mouse.On(); + HEART::Enable = TRUE; + for (TakeName(); GET_TEXT::Ptr; ) MainLoop(); + HEART::Enable = FALSE; + if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = TRUE; + if (usr_ok) strcat(UsrFnam, SVG_EXT); + //Mouse.Off(); + VGA::ShowQ.Clear(); + VGA::CopyPage(0, 2); + #endif + if (usr_ok && STARTUP::Mode == 0) + { + const char *n = UsrPath(UsrFnam); + if (CFILE::Exist(n)) + { + LoadGame(CFILE(n, REA, RCrypt), TRUE); // only system vars + VGA::SetColors(SysPal, 64); + Vga.Update(); + if (FINIS) + { + ++ STARTUP::Mode; + FINIS = FALSE; + } + } + else ++ STARTUP::Mode; + } + } + + if (STARTUP::Mode < 2) Movie("X01"); // wink + + VGA::CopyPage(0, 2); + + #ifdef DEMO + return TRUE; + #else + return (STARTUP::Mode == 2 || usr_ok); + #endif +} + + + + +/* +#ifdef DEBUG +void StkDump (void) +{ + CFILE f("!STACK.DMP", BFW); + f.Write((byte far *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2); +} +#endif +*/ + + + + +void cge_main (void) +{ + word intStack[STACK_SIZ/2]; + intStackPtr = intStack; + + //Debug( memset((void *) (-K(2)), 0, K(1)); ) + //Debug( memset((void *) (-K(4)), 0, K(1)); ) + memset(Barriers, 0xFF, sizeof(Barriers)); + + if (! Mouse.Exist) VGA::Exit(NO_MOUSE_TEXT); + if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; + + Debug( DebugLine.Flags.Hide = TRUE; ) + Debug( HorzLine.Flags.Hide = TRUE; ) + + srand((word) Timer()); + Sys = new SYSTEM; + + if (Music && STARTUP::SoundOk) LoadMIDI(0); + if (STARTUP::Mode < 2) Movie(LGO_EXT); + if (ShowTitle("WELCOME")) + { + #ifndef DEMO + if (STARTUP::Mode == 1) Movie("X02"); // intro + #endif + RunGame(); + Startup = 2; + if (FINIS) Movie("X03"); + } + else Vga.Sunset(); + VGA::Exit(EXIT_OK_TEXT+FINIS); +} diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h new file mode 100644 index 0000000000..f5c104600a --- /dev/null +++ b/engines/cge/cge_main.h @@ -0,0 +1,181 @@ +#ifndef __CGE__ +#define __CGE__ + +#include "cge\wav.h" + +namespace CGE { + +#define TSEQ 96 +#define HTALK (TSEQ+4) +#define TOO_FAR (TSEQ+5) +#define NO_WAY (TSEQ+5) +#define POC_FUL (TSEQ+5) +#define OFF_USE (TSEQ+6) + +#define EXIT_OK_TEXT 40 +#define NOMUSIC_TEXT 98 +#define BADSVG_TEXT 99 +#define OFF_USE_COUNT 600 +#define OFF_USE_TEXT 601 +#define NO_WAY_TEXT 671 +#define TOO_FAR_TEXT 681 +#define POC_FUL_TEXT 691 +#define A_C_D_TEXT 777 + +#define GETNAME_PROMPT 50 +#define GETNAME_TITLE 51 + +#define QUIT_TITLE 200 +#define QUIT_TEXT 201 +#define NOQUIT_TEXT 202 +#define DEMO_TEXT 300 +#define NOSOUND_TEXT 310 + +#define PAN_HIG 40 +#define WORLD_HIG (SCR_HIG-PAN_HIG) + +#define INFO_X 177 +#define INFO_Y 164 +#define INFO_W 140 + +#if defined(DEMO) + #define CAVE_X 4 + #define CAVE_Y 166 + #define CAVE_SX 0 + #define CAVE_SY 0 + #define CAVE_DX 23 + #define CAVE_DY 29 + #define CAVE_NX 3 + #define CAVE_NY 1 +#else + #define CAVE_X 4 + #define CAVE_Y 166 + #define CAVE_SX 0 + #define CAVE_SY 0 + #define CAVE_DX 9 + #define CAVE_DY 10 + #define CAVE_NX 8 + #define CAVE_NY 3 +#endif + +#define BUTTON_X 151 +#define BUTTON_Y 164 +#define BUTTON_DX 19 +#define BUTTON_DY 11 +#define BUTTON_NX 1 +#define BUTTON_NY 3 + +#define MINI_X 86 +#define MINI_Y 162 + +//#define MAP_XCNT 16 +//#define MAP_ZCNT 4 +#define MAP_XCNT 40 +#define MAP_ZCNT 20 +#define MAP_TOP 80 +#define MAP_HIG 80 +#define MAP_XGRID (SCR_WID / MAP_XCNT) +#define MAP_ZGRID (MAP_HIG / MAP_ZCNT) + +//#if SCR_WID % MAP_XGRID +// #error Illegal horizontal grid size or count +//#endif + +//#if MAP_HIG % MAP_ZGRID +// #error Illegal vertical grid size or count +//#endif + +#define LINE_MAX 512 +#define USER_MAX 100 +#define SHP_MAX 1024 +#define STD_DELAY 3 +#define LEV_MAX 5 +#define CAVE_MAX (CAVE_NX*CAVE_NY) +#define MAX_FIND_LEVEL 3 +#define MAX_DISTANCE 3 + +#define INI_EXT ".INI" +#define IN0_EXT ".IN0" +#define LGO_EXT ".LGO" +#define SVG_EXT ".SVG" + +#define WALKSIDE 10 + +#define BUSY_REF 500 + +#define SYSTIMERATE 6 // 12 Hz +#define HEROFUN0 (40*12) +#define HEROFUN1 ( 2*12) +#define PAIN (Flag[0]) +#define FINIS (Flag[3]) + + +//-------------------------------------------------------------------------- + + +class SYSTEM : public SPRITE +{ + int lum; +public: + static int FunDel; + static void SetPal (void); + static void FunTouch (void); + SYSTEM (void) : SPRITE(NULL) { SetPal(); Tick(); } + void Touch (word mask, int x, int y); + void Tick (void); +}; + + + + +//-------------------------------------------------------------------------- + + + + +class CLUSTER : public COUPLE +{ +public: + static byte Map[MAP_ZCNT][MAP_XCNT]; + byte &Cell (void); + CLUSTER (void) : COUPLE () { } + CLUSTER (int a, int b) : COUPLE (a, b) { } + Boolean Protected (void); +}; + + + + +class WALK : public SPRITE +{ +public: + CLUSTER Here; + enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; + int TracePtr; + WALK (BMP_PTR * shpl); + void Tick (void); + void FindWay(CLUSTER c); + void FindWay(SPRITE * spr); + int Distance (SPRITE * spr); + void Turn (DIR d); + void Park (void); + Boolean Lower (SPRITE * spr); + void Reach (SPRITE * spr, int mode = -1); +}; + + + + + CLUSTER XZ (int x, int y); + CLUSTER XZ (COUPLE xy); + + +extern WALK * Hero; + + + void ExpandSprite (SPRITE * spr); + void ContractSprite (SPRITE * spr); + void cge_main(void); + +} // End of CGE +#endif diff --git a/engines/cge/drop.h b/engines/cge/drop.h new file mode 100644 index 0000000000..e79b2eb899 --- /dev/null +++ b/engines/cge/drop.h @@ -0,0 +1 @@ +#include "vga13h.h" diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp new file mode 100644 index 0000000000..4ac27651b7 --- /dev/null +++ b/engines/cge/game.cpp @@ -0,0 +1,91 @@ +#include "game.h" +#include "mouse.h" +#include +#include + + + + + +byte * Glass (DAC far * pal, byte r, byte g, byte b) +{ + byte * x = new byte[256]; + if (x) + { + word i; + for (i = 0; i < 256; i ++) + { + x[i] = Closest(pal, MkDAC(((word)(pal[i].R) * r) / 255, + ((word)(pal[i].G) * g) / 255, + ((word)(pal[i].B) * b) / 255)); + } + } + return x; +} + + + + + +byte * Mark (DAC far * pal) +{ + #define f(c) (c ^ 63) + byte * x = new byte[256]; + if (x) + { + word i; + for (i = 0; i < 256; i ++) + { + x[i] = Closest(pal, MkDAC(f(pal[i].R), + f(pal[i].G), + f(pal[i].B)) ); + } + } + return x; + #undef f +} + + + + + +//-------------------------------------------------------------------------- + + + +int FLY::L = 20, + FLY::T = 40, + FLY::R = 110, + FLY::B = 100; + + + +FLY::FLY (BITMAP ** shpl) +: SPRITE(shpl), Tx(0), Ty(0) +{ + Step(random(2)); + Goto(L+random(R-L-W), T+random(B-T-H)); +} + + + + +void FLY::Tick (void) +{ + Step(); + if (! Flags.Kept) + { + if (random(10) < 1) + { + Tx = random(3) - 1; + Ty = random(3) - 1; + } + if (X + Tx < L || X + Tx + W > R) Tx = -Tx; + if (Y + Ty < T || Y + Ty + H > B) Ty = -Ty; + Goto(X + Tx, Y + Ty); + } +} + + +//-------------------------------------------------------------------------- + diff --git a/engines/cge/game.h b/engines/cge/game.h new file mode 100644 index 0000000000..92ad49b2a4 --- /dev/null +++ b/engines/cge/game.h @@ -0,0 +1,40 @@ +#ifndef __GAME__ +#define __GAME__ + +#include "vga13h.h" +#include "bitmaps.h" + + + +#define PAN_HIG 40 +#define LBound(s) (s->X <= 0) +#define RBound(s) (s->X+s->W >= SCR_WID) +#define TBound(s) (s->Y <= 0) +#define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG) + + + +extern SPRITE * Sys; + +int Sinus (long x); +byte * Glass (DAC far * pal, byte r, byte g, byte b); +byte * Mark (DAC far * pal); + + + + + +class FLY : public SPRITE +{ + static int L, T, R, B; +public: + int Tx, Ty; + FLY (BITMAP ** shpl); + void Tick (void); +}; + + + + + +#endif \ No newline at end of file diff --git a/engines/cge/general.h b/engines/cge/general.h new file mode 100644 index 0000000000..7e9551e076 --- /dev/null +++ b/engines/cge/general.h @@ -0,0 +1,241 @@ +#ifndef __GENERAL__ +#define __GENERAL__ + +#include "cge\jbw.h" +#include + +#define SEED 0xA5 + +#define SCR_WID_ 320 +#define SCR_HIG_ 200 +#define SCR_WID ((word)SCR_WID_) +#define SCR_HIG ((word)SCR_HIG_) +#define SCR_SEG 0xA000 +#define SCR_ADR ((byte far *) MK_FP(SCR_SEG, 0)) + + + +enum CPU { _8086, _80186, _80286, _80386, _80486 }; +enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM }; +enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT }; +enum IOMODE { REA, WRI, UPD }; + +typedef struct { + byte R, G, B; + } DAC; + +typedef word CRYPT (void far * buf, word siz, word seed); + + + + + + +class COUPLE +{ +protected: + signed char A; + signed char B; +public: + COUPLE (void) { } + COUPLE (const signed char a, const signed char b) : A(a), B(b) { } + COUPLE operator + (COUPLE c) { return COUPLE(A+c.A, B+c.B); } + void operator += (COUPLE c) { A += c.A; B += c.B; } + COUPLE operator - (COUPLE c) { return COUPLE(A-c.A, B-c.B); } + void operator -= (COUPLE c) { A -= c.A; B -= c.B; } + Boolean operator == (COUPLE c) { return ((A - c.A) | (B - c.B)) == 0; } + Boolean operator != (COUPLE c) { return ! (operator == (c)); } + void Split (signed char& a, signed char& b) { a = A; b = B; } +}; + + +//------------------------------------------------------------------------- + + + +class ENGINE +{ +protected: + static void interrupt (far * OldTimer) (...); + static void interrupt NewTimer (...); +public: + ENGINE (word tdiv); + ~ENGINE (void); +}; + + + + +//------------------------------------------------------------------------- + + +class EMS; + + + +class EMM +{ + friend EMS; + Boolean Test (void); + long Top, Lim; + EMS * List; + int Han; + static void _seg * Frame; +public: + EMM::EMM (long size = 0); + EMM::~EMM (void); + EMS * Alloc (word siz); + void Release (void); +}; + + + + + +class EMS +{ + friend EMM; + EMM * Emm; + long Ptr; + word Siz; + EMS * Nxt; +public: + EMS (void); + void far * operator & () const; + word Size (void); +}; + + + +//------------------------------------------------------------------------- + + + + +template +void Swap (T& A, T& B) +{ + T a = A; + A = B; + B = a; +}; + + + + + +#ifdef __cplusplus + + +template +T max (T A, T B) +{ + return (A > B) ? A : B; +}; + + + +template +T min (T A, T B) +{ + return (A < B) ? A : B; +}; + + +#endif + + + + + + + +class XFILE +{ +public: + IOMODE Mode; + word Error; + XFILE (void) : Mode(REA), Error(0) { } + XFILE (IOMODE mode) : Mode(mode), Error(0) { } + virtual word Read (void far * buf, word len) = 0; + virtual word Write (void far * buf, word len) = 0; + virtual long Mark (void) = 0; + virtual long Size (void) = 0; + virtual long Seek (long pos) = 0; +}; + + + + + +template +inline word XRead (XFILE * xf, T * t) +{ + return xf->Read((byte far *) t, sizeof(*t)); +}; + + + + + +class IOHAND : public XFILE +{ +protected: + int Handle; + word Seed; + CRYPT * Crypt; +public: + IOHAND (const char near * name, IOMODE mode = REA, CRYPT crypt = NULL); + IOHAND (IOMODE mode = REA, CRYPT * crpt = NULL); + virtual ~IOHAND (void); + static Boolean Exist (const char * name); + word Read (void far * buf, word len); + word Write (void far * buf, word len); + long Mark (void); + long Size (void); + long Seek (long pos); + ftime Time (void); + void SetTime (ftime t); +}; + + + + + +CRYPT XCrypt; +CRYPT RXCrypt; +CRYPT RCrypt; + +MEM_TYPE MemType (void far * mem); +unsigned FastRand (void); +unsigned FastRand (unsigned s); +CPU Cpu (void); +ALLOC_MODE SetAllocMode (ALLOC_MODE am); +word atow (const char * a); +word xtow (const char * x); +char * wtom (word val, char * str, int radix, int len); +char * dwtom (dword val, char * str, int radix, int len); +char * DateTimeString (void); +void StdLog (const char *msg, const char *nam = NULL); +void StdLog (const char *msg, word w); +void StdLog (const char *msg, dword d); +int TakeEnum (const char ** tab, const char * txt); +word ChkSum (void far * m, word n); +long Timer (void); +long TimerLimit (word t); +Boolean TimerLimitGone (long t); +char * MergeExt (char * buf, const char * nam, const char * ext); +char * ForceExt (char * buf, const char * nam, const char * ext); +inline const char * ProgPath (void); +const char * ProgName (const char * ext = NULL); +int DriveFixed (unsigned drv); +int DriveRemote (unsigned drv); +int DriveCD (unsigned drv); +Boolean IsVga (void); + +EC void _fqsort (void far *base, word nelem, word width, + int (*fcmp)(const void far *, const void far *)); + + + +#endif diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp new file mode 100644 index 0000000000..69350b5fc8 --- /dev/null +++ b/engines/cge/gettext.cpp @@ -0,0 +1,110 @@ +#include "gettext.h" +#include "keybd.h" +#include "mouse.h" +#include + + + + + +GET_TEXT * GET_TEXT::Ptr = NULL; + + + +GET_TEXT::GET_TEXT (const char * info, char * text, int size, void (*click)(void)) +: Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), + Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)) +{ + int i = 2 * TEXT_HM + Font.Width(info); + Ptr = this; + Mode = RECT; + TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); + SetShapeList(TS); + Flags.BDel = TRUE; + Flags.Kill = TRUE; + memcpy(Buff, text, Len); + Buff[Len] = ' '; + Buff[Len+1] = '\0'; + PutLine(0, info); + Tick(); +} + + + + + + +GET_TEXT::~GET_TEXT (void) +{ + KEYBOARD::SetClient(OldKeybClient); + Ptr = NULL; +} + + + + + + +void GET_TEXT::Tick (void) +{ + if (++ Cntr >= GTBLINK) + { + Buff[Len] ^= (' ' ^ '_'); + Cntr = 0; + } + PutLine(1, Buff); + Time = GTTIME; +} + + + + +void GET_TEXT::Touch (word mask, int x, int y) +{ + static char ogon[] = "•œ¥£˜ ¡"; + static char bezo[] = "ACELNOSXZ"; + char * p; + + if (mask & KEYB) + { + if (Click) Click(); + switch (x) + { + case Enter : Buff[Len] = '\0'; strcpy(Text, Buff); + for (p = Text; *p; p ++) + { + char * q = strchr(ogon, *p); + if (q) *p = bezo[q-ogon]; + } + case Esc : SNPOST_(SNKILL, -1, 0, this); break; + case BSp : if (Len) + { + -- Len; + Buff[Len] = Buff[Len+1]; + Buff[Len+1] = Buff[Len+2]; + } + break; + default : if (x < 'A' || x > 'Z') + { + if (OldKeybClient) + OldKeybClient->Touch(mask, x, y); + } + else + { + if (KEYBOARD::Key[ALT]) + { + p = strchr(bezo, x); + if (p) x = ogon[p-bezo]; + } + if (Len < Size && 2 * TEXT_HM + Font.Width(Buff) + Font.Wid[x] <= W) + { + Buff[Len+2] = Buff[Len+1]; + Buff[Len+1] = Buff[Len]; + Buff[Len ++] = x; + } + } + break; + } + } + else SPRITE::Touch(mask, x, y); +} diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h new file mode 100644 index 0000000000..8d4e15c6cb --- /dev/null +++ b/engines/cge/gettext.h @@ -0,0 +1,35 @@ +#ifndef __GETTEXT__ +#define __GETTEXT__ + +#include +#include "talk.h" + + +#define GTMAX 24 +#define GTBLINK 6 +#define GTTIME 6 + + + + + + + +class GET_TEXT : public TALK +{ + char Buff[GTMAX+2], * Text; + word Size, Len; + word Cntr; + SPRITE * OldKeybClient; + void (*Click)(void); +public: + static GET_TEXT * Ptr; + GET_TEXT (const char * info, char * text, int size, void (*click)(void) = NULL); + ~GET_TEXT (void); + void Touch (word mask, int x, int y); + void Tick (void); +}; + + + +#endif diff --git a/engines/cge/ident.h b/engines/cge/ident.h new file mode 100644 index 0000000000..5370b9638c --- /dev/null +++ b/engines/cge/ident.h @@ -0,0 +1,14 @@ +#ifndef __IDENT__ +#define __IDENT__ + + +struct IDENT + { + char copr[83]; + char fill[8]; + unsigned long disk; + unsigned char cork; + }; + + +#endif diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h new file mode 100644 index 0000000000..98ce9e27b5 --- /dev/null +++ b/engines/cge/jbw.h @@ -0,0 +1,149 @@ +#ifndef __JBW__ +#define __JBW__ + +#define BEL 7 +#define BS 8 +#define HT 9 +#define LF 10 +#define FF 12 +#define CR 13 + +#define NULL 0 +#define TRUE (1==1) +#define FALSE (!TRUE) +#define OFF FALSE +#define ON TRUE + +#define IsWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') +#define IsUpper(c) ((c) >= 'A' && (c) <= 'Z') +#define IsLower(c) ((c) >= 'a' && (c) <= 'z') +#define IsDigit(c) ((c) >= '0' && (c) <= '9') +#define IsAlpha(c) (IsLower(c) || IsUpper(c) || (c) == '_') +#define IsAlNum(c) (IsAlpha(c) || IsDigit(c)) +#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) + +#define farnew(t,n) ((t far *) farmalloc(sizeof(t) * (n))) +#define ArrayCount(a) (sizeof(a)/sizeof((a)[0])) +#define MAX_TIMER 0x1800B0L + +typedef unsigned char BYTE; +typedef unsigned int WORD; +typedef unsigned long DWORD; + +typedef int Boolean; +typedef unsigned char byte; +typedef unsigned int word; +typedef unsigned long dword; +typedef void (far _loadds MouseFunType)(void); + +#define Lo(d) (((int *) &d)[0]) +#define Hi(d) (((int *) &d)[1]) +#define LoWord(d) ((word) Lo(d)) +#define HiWord(d) ((word) Hi(d)) +#define K(n) (1024*(n)) +#define MASK(n) ((1< + + +SPRITE * KEYBOARD::Client = NULL; +byte KEYBOARD::Key[0x60] = { 0 }; +word KEYBOARD::Current = 0; +word KEYBOARD::Code[0x60] = { 0,Esc,'1','2','3','4','5','6','7','8','9','0', + '-','+',BSp,Tab,'Q','W','E','R','T','Y','U', + 'I','O','P','[',']',Enter,0/*Ctrl*/,'A','S', + 'D','F','G','H','J','K','L',';','\'','`', + 0/*LShift*/,'\\','Z','X','C','V','B','N','M', + ',','.','/',0/*RShift*/,'*',0/*Alt*/,' ', + 0/*Caps*/,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10, + 0/*NumLock*/,0/*ScrollLock*/,Home,Up,PgUp, + '-',Left,Ctr,Right,'+',End,Down,PgDn,Ins,Del, + 0*0x54,0*0x55,0*0x56,F11,F12,0*0x59,0*0x5A, + 0*0x5B,0*0x5C,0*0x5D,0*0x5E,0*0x5F + }; +void interrupt (far * KEYBOARD::OldKeyboard) (...); + + + +KEYBOARD::KEYBOARD (void) +{ + // steal keyboard interrupt + OldKeyboard = getvect(KEYBD_INT); + setvect(KEYBD_INT, NewKeyboard); +} + + + + +KEYBOARD::~KEYBOARD (void) +{ + // bring back keyboard interrupt + setvect(KEYBD_INT, OldKeyboard); +} + + + + +SPRITE * KEYBOARD::SetClient (SPRITE * spr) +{ + Swap(Client, spr); + return spr; +} + + + + + +void interrupt KEYBOARD::NewKeyboard (...) +{ + // table address + _SI = (word) Key; + + // take keyboard code + asm in al,60h + asm mov bl,al + asm and bx,007Fh + asm cmp bl,60h + asm jae xit + asm cmp al,bl + asm je ok // key pressed + + // key released... + asm cmp [si+bx],bh // BH == 0 + asm jne ok + // ...but not pressed: call the original service + OldKeyboard(); + return; + + ok: + asm shl ax,1 + asm and ah,1 + asm xor ah,1 + asm mov [si+bx],ah + asm jz xit // released: exit + + // pressed: lock ASCII code + _SI = (word) Code; + asm add bx,bx // word size + asm mov ax,[si+bx] + asm or ax,ax + asm jz xit // zero means NO KEY + Current = _AX; + + _SI = (word) Client; + asm or si,si + asm jz xit // if (Client) ... +//--- fill current event entry with mask, key code and sprite + asm mov bx,EvtHead // take queue head pointer + asm inc byte ptr EvtHead // update queue head pointer + asm shl bx,3 // * 8 + _AX = Current; + asm mov Evt[bx].(struct EVENT)X,ax // key code + asm mov ax,KEYB // event mask + asm mov Evt[bx].(struct EVENT)Msk,ax // event mask + //asm mov Evt[bx].(struct EVENT)Y,dx // row + asm mov Evt[bx].(struct EVENT)Ptr,si // SPRITE pointer + + xit: + + asm in al,61h // kbd control lines + asm push ax // save it + asm or al,80h // set the "enable kbd" bit + asm out 61h,al // and write it out + asm pop ax // original control port value + asm out 61h,al // write it back + asm mov al,20h // send End-Of-Interrupt + asm out 20h,al // to the 8259 IC +} diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h new file mode 100644 index 0000000000..744dc8c8ac --- /dev/null +++ b/engines/cge/keybd.h @@ -0,0 +1,31 @@ +#ifndef __KEYBD__ +#define __KEYBD__ + +#include +#include "vga13h.h" + + +#define KEYBD_INT 9 +#define LSHIFT 42 +#define RSHIFT 54 +#define CTRL 29 +#define ALT 56 + + +class KEYBOARD +{ + static void interrupt (far * OldKeyboard) (...); + static void interrupt NewKeyboard (...); + static word Code[0x60]; + static word Current; + static SPRITE * Client; +public: + static byte Key[0x60]; + static word Last (void) { _AX = Current; Current = 0; return _AX; } + static SPRITE * SetClient (SPRITE * spr); + KEYBOARD (void); + ~KEYBOARD (void); +}; + + +#endif diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp new file mode 100644 index 0000000000..7a494d0b90 --- /dev/null +++ b/engines/cge/mixer.cpp @@ -0,0 +1,129 @@ +#include "mixer.h" +#include "text.h" +#include "snail.h" +#include "mouse.h" +#include +#include +#include + +//-------------------------------------------------------------------------- + + +extern MOUSE Mouse; + + Boolean MIXER::Appear = FALSE; + + + +MIXER::MIXER (int x, int y) +: SPRITE(NULL), Fall(MIX_FALL) +{ + int i; + Appear = TRUE; + mb[0] = new BITMAP("VOLUME"); + mb[1] = NULL; + SetShapeList(mb); + SetName(Text[MIX_NAME]); + Flags.Syst = TRUE; + Flags.Kill = TRUE; + Flags.BDel = TRUE; + Goto(x, y); + Z = MIX_Z; + + // slaves + + for (i = 0; i < MIX_MAX; i ++) + { + static char fn[] = "V00"; + wtom(i, fn+1, 10, 2); + lb[i] = new BITMAP(fn); + ls[i].Now = ls[i].Next = i; + ls[i].Dx = ls[i].Dy = ls[i].Dly = 0; + } + lb[i] = NULL; + + for (i = 0; i < ArrayCount(Led); i ++) + { + register SPRITE * spr = new SPRITE(lb); + spr->SetSeq(ls); + spr->Goto(x+2+12*i, y+8); + spr->Flags.Tran = TRUE; + spr->Flags.Kill = TRUE; + spr->Flags.BDel = FALSE; + spr->Z = MIX_Z; + Led[i] = spr; + } + Led[ArrayCount(Led)-1]->Flags.BDel = TRUE; + + VGA::ShowQ.Insert(this); + for (i = 0; i < ArrayCount(Led); i ++) VGA::ShowQ.Insert(Led[i]); + + //--- reset balance + i = (SNDDrvInfo.VOL4.ML + SNDDrvInfo.VOL4.MR) / 2; + SNDDrvInfo.VOL4.ML = i; + SNDDrvInfo.VOL4.MR = i; + i = (SNDDrvInfo.VOL4.DL + SNDDrvInfo.VOL4.DR) / 2; + SNDDrvInfo.VOL4.DL = i; + SNDDrvInfo.VOL4.DR = i; + Update(); + Time = MIX_DELAY; +} + + + + +MIXER::~MIXER (void) +{ + Appear = FALSE; +} + + + +#pragma argsused +void MIXER::Touch (word mask, int x, int y) +{ + SPRITE::Touch(mask, x, y); + if (mask & L_UP) + { + byte * vol = (&SNDDrvInfo.VOL2.D) + (x < W/2); + if (y < MIX_BHIG) { if (*vol < 0xFF) *vol += 0x11; } + else if (y >= H-MIX_BHIG) { if (*vol > 0x00) *vol -= 0x11; } + Update(); + } +} + + + +void MIXER::Tick (void) +{ + int x = Mouse.X, y = Mouse.Y; + if (SpriteAt(x, y) == this) + { + Fall = MIX_FALL; + if (Flags.Hold) Touch(L_UP, x-X, y-Y); + } + else + { + if (Fall) -- Fall; + else + { + int i; + for (i = 0; i < ArrayCount(Led); i ++) + { + SNPOST_(SNKILL, -1, 0, Led[i]); + } + SNPOST_(SNKILL, -1, 0, this); + } + } + Time = MIX_DELAY; +} + + + + +void MIXER::Update (void) +{ + Led[0]->Step(SNDDrvInfo.VOL4.ML); + Led[1]->Step(SNDDrvInfo.VOL4.DL); + SNPOST_(SNEXEC, -1, 0, SNDSetVolume); +} diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h new file mode 100644 index 0000000000..8ee2bb6f80 --- /dev/null +++ b/engines/cge/mixer.h @@ -0,0 +1,31 @@ +#ifndef __MIXER__ +#define __MIXER__ + +#include "vga13h.h" + +#define MIX_MAX 16 // count of Leds +#define MIX_Z 64 // mixer Z position +#define MIX_DELAY 12 // 6/s +#define MIX_FALL 6 // in MIX_DELAY units +#define MIX_BHIG 6 // mixer button high +#define MIX_NAME 105 // sprite name + +class MIXER : public SPRITE +{ + BMP_PTR mb[2]; + BMP_PTR lb[MIX_MAX+1]; + SEQ ls[MIX_MAX]; + SPRITE * Led[2]; + int Fall; + void Update (void); +public: + static Boolean Appear; + MIXER (int x, int y); + ~MIXER (void); + void Touch (word mask, int x, int y); + void Tick (void); +}; + + + +#endif diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 62ddd9d362..7424c8bc38 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -1,9 +1,26 @@ MODULE := engines/cge MODULE_OBJS := \ + bitmap.o \ + bitmaps.o \ + cfile.o \ cge.o \ + cge_main.o \ console.o \ - detection.o + detection.o \ + game.o \ + gettext.o \ + keybd.o \ + mixer.o \ + mouse.o \ + snail.o \ + sound.o \ + startup.o \ + talk.o \ + text.o \ + vga13h.o \ + vmenu.o \ + vol.o MODULE_DIRS += \ engines/cge diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp new file mode 100644 index 0000000000..703fd80f65 --- /dev/null +++ b/engines/cge/mouse.cpp @@ -0,0 +1,207 @@ +#include "mouse.h" +#include "text.h" +#include + + + + EVENT Evt[EVT_MAX]; + + word EvtHead = 0, EvtTail = 0; +//-------------------------------------------------------------------------- + +MOUSE_FUN * MOUSE::OldMouseFun = NULL; +word MOUSE::OldMouseMask = 0; + + + +//-------------------------------------------------------------------------- + + + + + +MOUSE::MOUSE (BITMAP ** shpl) + : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0) +{ + static SEQ ms[] = { { 0,0,0,0,1 }, { 1,1,0,0,1 } }; + SetSeq(ms); + + // Mouse reset + _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work) + __int__(0x33); + Exist = (_AX != 0); + Buttons = _BX; + + Goto(SCR_WID/2, SCR_HIG/2); + Z = 127; + Step(1); +} + + + + +MOUSE::~MOUSE (void) +{ + Off(); +} + + + + + +//void MOUSE::SetFun (void) +//{ +//} + + + + + +void MOUSE::On (void) +{ + if (SeqPtr && Exist) + { + _CX = X + X; // horizontal position + _DX = Y; // vertical position + _AX = 0x0004; // Set Mouse Position + __int__(0x33); + // set new mouse fun + _ES = FP_SEG(NewMouseFun); + _DX = FP_OFF(NewMouseFun); + _CX = 0x001F; // 11111b = all events + _AX = 0x0014; // Swap User-Interrupt Vector + __int__(0x33); + // save old mouse fun + OldMouseMask = _CX; + OldMouseFun = (MOUSE_FUN *) MK_FP(_ES, _DX); + + // set X bounds + _DX = (SCR_WID - W) * 2; // right limit + _CX = 0; // left limit + _AX = 0x0007; // note: each pixel = 2 + __int__(0x33); + + // set Y bounds + _DX = SCR_HIG - H; // bottom limit + _CX = 0; // top limit + _AX = 0x0008; + __int__(0x33); + + Step(0); + if (Busy) Busy->Step(0); + } +} + + + + + + +void MOUSE::Off (void) +{ + if (SeqPtr == 0) + { + if (Exist) + { + // bring back old mouse fun + _ES = FP_SEG(OldMouseFun); + _DX = FP_OFF(OldMouseFun); + _CX = OldMouseMask; + _AX = 0x0014; // Swap User-Interrupt Vector + __int__(0x33); + } + Step(1); + if (Busy) Busy->Step(1); + } +} + + + + + + +void MOUSE::ClrEvt (SPRITE * spr) +{ + if (spr) + { + word e; + for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) + if (Evt[e].Ptr == spr) Evt[e].Msk = 0; + } + else EvtTail = EvtHead; +} + + + + + + +void MOUSE::Tick (void) +{ + Step(); + while (EvtTail != EvtHead) + { + EVENT e = Evt[EvtTail]; + if (e.Msk) + { + if (Hold && e.Ptr != Hold) + { + Hold->Touch(e.Msk | ATTN, e.X - Hold->X, e.Y - Hold->Y); + } + + // update mouse cursor position + if (e.Msk & ROLL) + { + Goto(e.X, e.Y); + } + + // activate current touched SPRITE + if (e.Ptr) + { + if (e.Msk & KEYB) e.Ptr->Touch(e.Msk, e.X, e.Y); + else e.Ptr->Touch(e.Msk, e.X - e.Ptr->X, e.Y - e.Ptr->Y); + } + else if (Sys) Sys->Touch(e.Msk, e.X, e.Y); + + if (e.Msk & L_DN) + { + Hold = e.Ptr; + if (Hold) + { + Hold->Flags.Hold = TRUE; + #ifndef DEBUG + if (Hold->Flags.Drag) + #endif + { + hx = e.X - Hold->X; + hy = e.Y - Hold->Y; + } + } + } + + if (e.Msk & L_UP) + { + if (Hold) + { + Hold->Flags.Hold = FALSE; + Hold = NULL; + } + } + ///Touched = e.Ptr; + + // discard Text if button released + if (e.Msk & (L_UP | R_UP)) KillText(); + } + EvtTail = (EvtTail + 1) % EVT_MAX; + } + if (Hold) + #ifndef DEBUG + if (Hold->Flags.Drag) + #endif + Hold->Goto(X-hx, Y-hy); +} + + + +//-------------------------------------------------------------------------- + diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h new file mode 100644 index 0000000000..9f51456baf --- /dev/null +++ b/engines/cge/mouse.h @@ -0,0 +1,58 @@ +#ifndef __MOUSE__ +#define __MOUSE__ + +#include "game.h" +#include "talk.h" + +#define EVT_MAX 256 + +#define ROLL 0x01 +#define L_DN 0x02 +#define L_UP 0x04 +#define R_DN 0x08 +#define R_UP 0x10 +#define ATTN 0x20 +// 0x40 +#define KEYB 0x80 + + +extern TALK * Talk; + +struct EVENT { word Msk; + word X, Y; + SPRITE * Ptr; + }; +extern EVENT Evt[EVT_MAX]; +extern word EvtHead, EvtTail; +typedef void (far MOUSE_FUN) (void); + + + + + +class MOUSE : public SPRITE +{ + static MOUSE_FUN * OldMouseFun; + static MOUSE_FUN NewMouseFun; + static word OldMouseMask; + SPRITE * Hold; + int hx, hy; + //void SetFun (void); + //void ResetFun (void); +public: + Boolean Exist; + int Buttons; + SPRITE * Busy; + //SPRITE * Touched; + MOUSE (BITMAP ** shpl = MC); + ~MOUSE (void); + void On (void); + void Off (void); + static void ClrEvt (SPRITE * spr = NULL); + void Tick (void); +}; + + + + +#endif diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp new file mode 100644 index 0000000000..d6b2528310 --- /dev/null +++ b/engines/cge/snail.cpp @@ -0,0 +1,1280 @@ +#include +#include "sound.h" +#include "snail.h" +#include "vga13h.h" +#include "bitmaps.h" +#include "text.h" +#include "mouse.h" +#include "cge.h" +#include +#include +#include +#include +#include + +#include "keybd.h" + + int MaxCave = 0; + + SCB Scb = { NULL, 0, NULL }; + Boolean Flag[4]; + Boolean Dark = FALSE; + Boolean Game = FALSE; + int Now = 1; + int Lev = -1; + SNAIL Snail = FALSE; + SNAIL Snail_ = TRUE; + +extern SPRITE PocLight; + +//------------------------------------------------------------------------- +// SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, +// NULL, NULL, NULL, NULL, }; +// int PocPtr = 0; +//------------------------------------------------------------------------- +extern SPRITE * Pocket[]; +extern int PocPtr; +//------------------------------------------------------------------------- + +extern DAC far * SysPal; +extern MOUSE Mouse; + + + +//------------------------------------------------------------------------- + + +static void SNGame (SPRITE * spr, int num) +{ + switch (num) + { + //-------------------------------------------------------------------- + case 1 : + { + #define STAGES 8 + #define DRESSED 3 + static SPRITE * dup[3] = { NULL, NULL, NULL }; + int buref; + int Stage; + + for (dup[0] = VGA::ShowQ.First(); dup[0]; dup[0] = dup[0]->Next) + { + buref = dup[0]->Ref; + if (buref / 1000 == 16 && buref % 100 == 6) + { + Stage = (buref / 100) % 10; + break; + } + } + if (dup[1] == NULL) + { + dup[1] = VGA::ShowQ.Locate(16003); // pan + dup[2] = VGA::ShowQ.Locate(16004); // pani + } + + if (Game) // continue game + { + int i = random(3), hand = (dup[0]->ShpCnt == 6); + ++ Stage; + if (hand && Stage > DRESSED) ++ hand; + if ( + Debug( i >= 0 || ) + dup[i] == spr && random(3) == 0) + { + SNPOST(SNSEQ, -1, 3, dup[0]); // yes + SNPOST(SNSEQ, -1, 3, dup[1]); // yes + SNPOST(SNSEQ, -1, 3, dup[2]); // yes + SNPOST(SNTNEXT, -1, 0, dup[0]); // reset Take + SNPOST(SNTNEXT, -1, 0, dup[1]); // reset Take + SNPOST(SNTNEXT, -1, 0, dup[2]); // reset Take + SNPOST(SNNNEXT, -1, 0, dup[0]); // reset Near + SNPOST(SNPAUSE, -1, 72, NULL); // little rest + SNPOST(SNSAY, 1, 16009, NULL); // hura + SNPOST(SNSAY, buref, 16010, NULL); // siadaj + SNPOST(SNSAY, 1, 16011, NULL); // postoj‘ + + if (hand) + { + SNPOST(SNSEND, 16060+hand, 16, NULL); // dawaj r‘k‘ + SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie + SNPOST(SNSEQ, 16060+hand, 1, NULL); // ruch + SNPOST(SNSOUND, 16060+hand, 16002, NULL); // szelest + SNPOST(SNWAIT, 16060+hand, 3, NULL); // podniesie + SNPOST(SNSWAP, buref, buref+100, NULL); // rozdziana + SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa + SNPOST(SNSEND, 16060+hand, -1, NULL); // chowaj r‘k‘ + SNPOST(SNWAIT, 16060+hand, -1, NULL); // r‘ka zamar’a + } + else + { + SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie + SNPOST(SNSOUND, 16060+hand, 16002, NULL); // szelest + SNPOST(SNWAIT, buref, -1, NULL); // zdejmie + SNPOST(SNSWAP, buref, buref+100, NULL); // rozdziana + SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa + } + //SNPOST(SNSEQ, buref+100, 0, NULL); // reset + SNPOST(SNPAUSE, -1, 72, NULL); // chwilk‘... + + SNPOST(SNSEQ, -1, 0, dup[1]); // odstaw Go + SNPOST(SNSETXY, -1, 203 + SCR_WID * 49, dup[1]); + SNPOST(SNSETZ, -1, 7, dup[1]); + + SNPOST(SNSEQ, -1, 0, dup[2]); // odstaw J† + SNPOST(SNSETXY, -1, 182 + SCR_WID * 62, dup[2]); + SNPOST(SNSETZ, -1, 9, dup[2]); + Game = 0; + return; + } + else + { + SNPOST(SNSEQ, -1, 2, dup[0]); // no + SNPOST(SNSEQ, -1, 2, dup[1]); // no + SNPOST(SNSEQ, -1, 2, dup[2]); // no + SNPOST(SNPAUSE, -1, 72, NULL); // 1 sec + } + } + SNPOST(SNWALK, 198, 134, NULL); // na miejsce + SNPOST(SNWAIT, 1, -1, NULL); // stoi + SNPOST(SNCOVER, 1, 16101, NULL); // ch’op do bicia + SNPOST(SNSEQ, 16101, 1, NULL); // wystaw + SNPOST(SNWAIT, 16101, 5, NULL); // czekaj + SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘ + SNPOST(SNSEQ, 16040, 1, NULL); // plask + SNPOST(SNSOUND, 16101, 16001, NULL); // plask! + SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘ + SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask + SNPOST(SNWAIT, 16101, -1, NULL); // stoi + SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS + if (! Game) + { + SNPOST(SNSAY, buref, 16008, NULL); // zgadnij! + Game = TRUE; + } + #undef STEPS + #undef DRESSED + } break; + //-------------------------------------------------------------------- + case 2 : + { + static SPRITE * k = NULL, * k1, * k2, * k3; + static int count = 0; + Boolean hit; + + if (k == NULL) + { + k = VGA::ShowQ.Locate(20700); + k1 = VGA::ShowQ.Locate(20701); + k2 = VGA::ShowQ.Locate(20702); + k3 = VGA::ShowQ.Locate(20703); + } + + if (! Game) // init + { + SNPOST(SNGAME, 20002, 2, NULL); + Game = TRUE; + } + else // cont + { + k1->Step(random(6)); + k2->Step(random(6)); + k3->Step(random(6)); + ///-------------------- + if (spr->Ref == 1 && KEYBOARD::Key[ALT]) + { + k1->Step(5); + k2->Step(5); + k3->Step(5); + } + ///-------------------- + SNPOST(SNSETZ, 20700, 0, NULL); + hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15); + if (hit) + { + if (spr->Ref == 1) + { + SNPOST(SNSAY, 1, 20003, NULL); // hura! + SNPOST(SNSEQ, 20011, 2, NULL); // kamera won + SNPOST(SNSEND, 20701, -1, NULL); // k1 won + SNPOST(SNSEND, 20702, -1, NULL); // k2 won + SNPOST(SNSEND, 20703, -1, NULL); // k3 won + SNPOST(SNSEND, 20700, -1, NULL); // tv won + SNPOST(SNKEEP, 20007, 0, NULL); // do kieszeni + SNPOST(SNSEND, 20006, 20, NULL); // bilon + SNPOST(SNSOUND,20006, 20002, NULL); // bilon! + SNPOST(SNSAY, 20002, 20004, NULL); + SNPOST(SNSEND, 20010, 20, NULL); // papier + SNPOST(SNSOUND,20010, 20003, NULL); // papier! + SNPOST(SNSAY, 20001, 20005, NULL); + Game = FALSE; + return; + } + else k3->Step(random(5)); + } + if (count < 100) + { + switch (count) + { + case 15 : SNPOST(SNSAY, 20003, 20021, NULL); break; + case 30 : + case 45 : + case 60 : + case 75 : SNPOST(SNSAY, 20003, 20022, NULL); break; + } + ++ count; + } + switch (spr->Ref) + { + case 1 : SNPOST(SNSAY, 20001, 20011, NULL); // zapro + SNPOST(SNSEQ, 20001, 1, NULL); // rzu + SNPOST(SNWAIT, 20001, 1, NULL); // czekaj + SNPOST(SNSETZ, 20700, 2, NULL); // skryj k + SNPOST(SNHIDE, 20007, 1, NULL); // skryj k + SNPOST(SNWAIT, 20001, 16, NULL); // czekaj + SNPOST(SNSEQ, 20007, 1, NULL); // lec† + SNPOST(SNHIDE, 20007, 0, NULL); // poka§ + SNPOST(SNSOUND,20007, 20001, NULL); // grzech + SNPOST(SNWAIT, 20007, -1, NULL); // koniec + SNPOST(SNGAME, 20001, 2, NULL); // again! + break; + case 20001 : SNPOST(SNSAY, 20002, 20012, NULL); // zapro + SNPOST(SNSEQ, 20002, 1, NULL); // rzu + SNPOST(SNWAIT, 20002, 3, NULL); // czekaj + SNPOST(SNSETZ, 20700, 2, NULL); // skryj k + SNPOST(SNHIDE, 20007, 1, NULL); // skryj k + SNPOST(SNWAIT, 20002, 10, NULL); // czekaj + SNPOST(SNSEQ, 20007, 2, NULL); // lec† + SNPOST(SNHIDE, 20007, 0, NULL); // poka§ + SNPOST(SNSOUND,20007, 20001, NULL); // grzech + SNPOST(SNWAIT, 20007, -1, NULL); // koniec + SNPOST(SNGAME, 20002, 2, NULL); // again! + break; + case 20002 : SNPOST(SNSAY, 20002, 20010, NULL); // zapro + SNPOST(SNWALK, 20005, -1, NULL); // do stol + SNPOST(SNWAIT, 1, -1, NULL); // stoi + SNPOST(SNCOVER, 1, 20101, NULL); // grasol + SNPOST(SNSEQ, 20101, 1, NULL); // rzu + SNPOST(SNWAIT, 20101, 5, NULL); // czekaj + SNPOST(SNSETZ, 20700, 2, NULL); // skryj k + SNPOST(SNHIDE, 20007, 1, NULL); // skryj k + SNPOST(SNWAIT, 20101, 15, NULL); // czekaj + SNPOST(SNSEQ, 20007, 1, NULL); // lec† + SNPOST(SNHIDE, 20007, 0, NULL); // poka§ + SNPOST(SNSOUND,20007, 20001, NULL); // grzech + SNPOST(SNWAIT, 20101, -1, NULL); // koniec + SNPOST(SNUNCOVER, 1, 20101, NULL); // SDS + SNPOST(SNGAME, 1, 2, NULL); // again! + break; + } + } + } break; + //-------------------------------------------------------------------- + } +} + + +//------------------------------------------------------------------------- + + + + +void ExpandSprite (SPRITE * spr) +{ + if (spr) VGA::ShowQ.Insert(VGA::SpareQ.Remove(spr)); +} + + + + + +void ContractSprite (SPRITE * spr) +{ + if (spr) VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); +} + + + + + + + +int FindPocket (SPRITE * spr) +{ + int i; + for (i = 0; i < POCKET_NX; i ++) if (Pocket[i] == spr) return i; + return -1; +} + + + + + +void SelectPocket (int n) +{ + if (n < 0 || (PocLight.SeqPtr && PocPtr == n)) + { + PocLight.Step(0); + n = FindPocket(NULL); + if (n >= 0) PocPtr = n; + } + else + { + if (Pocket[n] != NULL) + { + PocPtr = n; + PocLight.Step(1); + } + } + PocLight.Goto(POCKET_X+PocPtr*POCKET_DX+POCKET_SX, POCKET_Y+POCKET_SY); +} + + + + + +void PocFul (void) +{ + Hero->Park(); + SNPOST(SNWAIT, -1, -1, Hero); + SNPOST(SNSEQ, -1, POC_FUL, Hero); + SNPOST(SNSOUND, -1, 2, Hero); + SNPOST(SNWAIT, -1, -1, Hero); + SNPOST(SNSAY, 1, POC_FUL_TEXT, Hero); +} + + + + +void Hide1 (SPRITE * spr) +{ + SNPOST_(SNGHOST, -1, 0, spr->Ghost()); +} + + + + +void SNGhost (BITMAP * bmp) +{ + bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M)); + bmp->M = NULL; + delete bmp; +} + + + + +void FeedSnail (SPRITE * spr, SNLIST snq) +{ + if (spr) if (spr->Active()) + { + byte ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; + + if (ptr != NO_PTR) + { + SNAIL::COM * comtab = spr->SnList(snq); + SNAIL::COM * c = comtab + ptr; + + if (FindPocket(NULL) < 0) // no empty pockets? + { + SNAIL::COM * p; + for (p = c; p->Com != SNNEXT; p ++) // find KEEP command + { + if (p->Com == SNKEEP) + { + PocFul(); + return; + } + if (p->Ptr) break; + } + } + while (TRUE) + { + if (c->Com == SNTALK) + { + if ((Snail.TalkEnable = (c->Val != 0)) == FALSE) KillText(); + } + if (c->Com == SNNEXT) + { + SPRITE * s = (c->Ref < 0) ? spr : Locate(c->Ref); + if (s) + { + byte * idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr; + if (*idx != NO_PTR) + { + int v; + switch (c->Val) + { + case -1 : v = c - comtab + 1; break; + case -2 : v = c - comtab; break; + case -3 : v = -1; break; + default : v = c->Val; break; + } + if (v >= 0) *idx = v; + } + } + if (s == spr) break; + } + if (c->Com == SNIF) + { + SPRITE * s = (c->Ref < 0) ? spr : Locate(c->Ref); + if (s) // sprite extsts + { + if (! s->SeqTest(-1)) c = comtab + c->Val; // not parked + else ++ c; + } + else ++ c; + } + else + { + SNPOST(c->Com, c->Ref, c->Val, spr); + if (c->Ptr) break; + else ++ c; + } + } + } + } +} + + + + + + +//-------------------------------------------------------------------------- + +char * SNAIL::ComTxt[] = { "LABEL", "PAUSE", "WAIT", "LEVEL", + "HIDE", "SAY", "INF", "TIME", + "CAVE", "KILL", "RSEQ", + "SEQ", "SEND", "SWAP", "KEEP", "GIVE", + "IF", "GAME", "SETX0", "SETY0", "SLAVE", + "SETXY", "RELX", "RELY", "RELZ", + "SETX", "SETY", "SETZ", "TRANS", "PORT", + "NEXT","NNEXT", "TNEXT", "RNNEXT", "RTNEXT", + "RMNEAR", "RMTAKE", "FLAG", "SETREF", + "BACKPT", "FLASH", "LIGHT", + "SETHB", "SETVB", + "WALK", "REACH", "COVER", "UNCOVER", + "CLEAR", "TALK", "MOUSE", + "SOUND", "COUNT", + NULL }; + + + +SNAIL::SNAIL (Boolean turbo) +: Turbo(turbo), Busy(FALSE), TextDelay(FALSE), + Pause(0), TalkEnable(TRUE), + Head(0), Tail(0), SNList(farnew(COM, 256)) +{ +} + + + + + + +SNAIL::~SNAIL (void) +{ + if (SNList) farfree(SNList); +} + + + + + + +void SNAIL::AddCom (SNCOM com, int ref, int val, void * ptr) +{ + _disable(); + COM far * snc = &SNList[Head ++]; + snc->Com = com; + snc->Ref = ref; + snc->Val = val; + snc->Ptr = ptr; + if (com == SNCLEAR) + { + Tail = Head; + KillText(); + Pause = 0; + } + _enable(); +} + + + + +void SNAIL::InsCom (SNCOM com, int ref, int val, void * ptr) +{ + COM far * snc; + + _disable(); + if (Busy) + { + SNList[(Tail-1)&0xFF] = SNList[Tail]; + snc = &SNList[Tail]; + } + else snc = &SNList[(Tail-1)&0xFF]; + -- Tail; + snc->Com = com; + snc->Ref = ref; + snc->Val = val; + snc->Ptr = ptr; + if (com == SNCLEAR) + { + Tail = Head; + KillText(); + Pause = 0; + } + _enable(); +} + + + + + + + +static void SNNNext(SPRITE * sprel, int p) +{ + if (sprel) if (sprel->NearPtr != NO_PTR) sprel->NearPtr = p; +} + + + + + + +static void SNTNext(SPRITE * sprel, int p) +{ + if (sprel) if (sprel->TakePtr != NO_PTR) sprel->TakePtr = p; +} + + + + + + +static void SNRNNext(SPRITE * sprel, int p) +{ + if (sprel) if (sprel->NearPtr != NO_PTR) sprel->NearPtr += p; +} + + + + + + +static void SNRTNext(SPRITE * sprel, int p) +{ + if (sprel) if (sprel->TakePtr != NO_PTR) sprel->TakePtr += p; +} + + + + + + +static void SNZTrim (SPRITE * spr) +{ + if (spr) if (spr->Active()) + { + Boolean en = HEART::Enable; + SPRITE * s; + HEART::Enable = FALSE; + s = (spr->Flags.Shad) ? spr->Prev : NULL; + VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr)); + if (s) + { + s->Z = spr->Z; + VGA::ShowQ.Insert(VGA::ShowQ.Remove(s), spr); + } + HEART::Enable = en; + } +} + + + + + + +static void SNHide (SPRITE * spr, int val) +{ + if (spr) + { + spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide); + if (spr->Flags.Shad) spr->Prev->Flags.Hide = spr->Flags.Hide; + } +} + + + + + +static void SNRmNear (SPRITE * spr) +{ + if (spr) spr->NearPtr = NO_PTR; +} + + + + + +static void SNRmTake (SPRITE * spr) +{ + if (spr) spr->TakePtr = NO_PTR; +} + + + + + +void SNSeq (SPRITE * spr, int val) +{ + if (spr) + { + if (spr == Hero && val == 0) Hero->Park(); + else spr->Step(val); + } +} + + + + + +void SNRSeq (SPRITE * spr, int val) +{ + if (spr) SNSeq(spr, spr->SeqPtr + val); +} + + + + + +void SNSend (SPRITE * spr, int val) +{ + if (spr) + { + int was = spr->Cave; + Boolean was1 = (was == 0 || was == Now); + Boolean val1 = (val == 0 || val == Now); + spr->Cave = val; + if (val1 != was1) + { + if (was1) + { + if (spr->Flags.Kept) + { + int n = FindPocket(spr); + if (n >= 0) Pocket[n] = NULL; + } + Hide1(spr); + ContractSprite(spr); + spr->Flags.Slav = FALSE; + } + else + { + if (spr->Ref % 1000 == 0) BITMAP::Pal = SysPal; + if (spr->Flags.Back) spr->BackShow(TRUE); + else ExpandSprite(spr); + BITMAP::Pal = NULL; + } + } + } +} + + + + + +void SNSwap (SPRITE * spr, int xref) +{ + SPRITE * xspr = Locate(xref); + if (spr && xspr) + { + int was = spr->Cave; + int xwas = xspr->Cave; + Boolean was1 = (was == 0 || was == Now); + Boolean xwas1 = (xwas == 0 || xwas == Now); + + Swap(spr->Cave, xspr->Cave); + Swap(spr->X, xspr->X); + Swap(spr->Y, xspr->Y); + Swap(spr->Z, xspr->Z); + if (spr->Flags.Kept) + { + int n = FindPocket(spr); + if (n >= 0) Pocket[n] = xspr; + xspr->Flags.Kept = TRUE; + xspr->Flags.Port = FALSE; + } + if (xwas1 != was1) + { + if (was1) + { + Hide1(spr); + ContractSprite(spr); + } + else ExpandSprite(spr); + if (xwas1) + { + Hide1(xspr); + ContractSprite(xspr); + } + else ExpandSprite(xspr); + } + } +} + + + + + +void SNCover (SPRITE * spr, int xref) +{ + SPRITE * xspr = Locate(xref); + if (spr && xspr) + { + spr->Flags.Hide = TRUE; + xspr->Z = spr->Z; + xspr->Cave = spr->Cave; + xspr->Goto(spr->X, spr->Y); + ExpandSprite(xspr); + if ((xspr->Flags.Shad = spr->Flags.Shad) == TRUE) + { + VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr); + spr->Flags.Shad = FALSE; + } + FeedSnail(xspr, NEAR); + } +} + + + + + +void SNUncover (SPRITE * spr, SPRITE * xspr) +{ + if (spr && xspr) + { + spr->Flags.Hide = FALSE; + spr->Cave = xspr->Cave; + spr->Goto(xspr->X, xspr->Y); + if ((spr->Flags.Shad = xspr->Flags.Shad) == TRUE) + { + VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr); + xspr->Flags.Shad = FALSE; + } + spr->Z = xspr->Z; + SNSend(xspr, -1); + if (spr->Time == 0) ++ spr->Time; + } +} + + + + + +void SNSetX0 (int cav, int x0) +{ + HeroXY[cav-1].X = x0; +} + + + + + +void SNSetY0 (int cav, int y0) +{ + HeroXY[cav-1].Y = y0; +} + + + + + +void SNSetXY (SPRITE * spr, word xy) +{ + if (spr) + { + spr->Goto(xy % SCR_WID, xy / SCR_WID); + } +} + + + + + +void SNRelX (SPRITE * spr, int x) +{ + if (spr && Hero) + { + spr->Goto(Hero->X + x, spr->Y); + } +} + + + + + +void SNRelY (SPRITE * spr, int y) +{ + if (spr && Hero) + { + spr->Goto(spr->X, Hero->Y + y); + } +} + + + + + +void SNRelZ (SPRITE * spr, int z) +{ + if (spr && Hero) + { + spr->Z = Hero->Z + z; + SNZTrim(spr); + } +} + + + + + +void SNSetX (SPRITE * spr, int x) +{ + if (spr) + { + spr->Goto(x, spr->Y); + } +} + + + + + +void SNSetY (SPRITE * spr, int y) +{ + if (spr) + { + spr->Goto(spr->X, y); + } +} + + + + + +void SNSetZ (SPRITE * spr, int z) +{ + if (spr) + { + spr->Z = z; + //SNPOST_(SNZTRIM, -1, 0, spr); + SNZTrim(spr); + } +} + + + + + +void SNSlave (SPRITE * spr, int ref) +{ + SPRITE * slv = Locate(ref); + if (spr && slv) + { + if (spr->Active()) + { + SNSend(slv, spr->Cave); + slv->Flags.Slav = TRUE; + slv->Z = spr->Z; + VGA::ShowQ.Insert(VGA::ShowQ.Remove(slv), spr->Next); + } + } +} + + + + + +void SNTrans (SPRITE * spr, int trans) +{ + if (spr) + { + spr->Flags.Tran = (trans < 0) ? !spr->Flags.Tran : (trans != 0); + } +} + + + + + +void SNPort (SPRITE * spr, int port) +{ + if (spr) + { + spr->Flags.Port = (port < 0) ? !spr->Flags.Port : (port != 0); + } +} + + + + + +void SNKill (SPRITE * spr) +{ + if (spr) + { + if (spr->Flags.Kept) + { + int n = FindPocket(spr); + if (n >= 0) Pocket[n] = NULL; + } + SPRITE * nx = spr->Next; + Hide1(spr); + VGA::ShowQ.Remove(spr); + MOUSE::ClrEvt(spr); + if (spr->Flags.Kill) delete spr; + else + { + spr->Cave = -1; + VGA::SpareQ.Append(spr); + } + if (nx) if (nx->Flags.Slav) SNKill(nx); + } +} + + + + + +static void SNSound (SPRITE * spr, int wav, int cnt) +{ + if (SNDDrvInfo.DDEV) + { + if (wav == -1) Sound.Stop(); + else + Sound.Play(Fx[wav], (spr) ? ((spr->X+spr->W/2)/(SCR_WID/16)) : 8, cnt); + } +} + + + + + +void SNKeep (SPRITE * spr, int stp) +{ + SelectPocket(-1); + if (spr && ! spr->Flags.Kept && Pocket[PocPtr] == NULL) + { + SNSound(spr, 3, 1); + Pocket[PocPtr] = spr; + spr->Cave = 0; + spr->Flags.Kept = TRUE; + spr->Goto(POCKET_X + POCKET_DX*PocPtr + POCKET_DX/2 - spr->W/2, + POCKET_Y + POCKET_DY/2 - spr->H/2); + if (stp >= 0) spr->Step(stp); + } + SelectPocket(-1); +} + + + + + + +void SNGive (SPRITE * spr, int stp) +{ + if (spr) + { + int p = FindPocket(spr); + if (p >= 0) + { + Pocket[p] = NULL; + spr->Cave = Now; + spr->Flags.Kept = FALSE; + if (stp >= 0) spr->Step(stp); + } + } + SelectPocket(-1); +} + + + + +static void SNBackPt (SPRITE * spr, int stp) +{ + if (spr) + { + if (stp >= 0) spr->Step(stp); + spr->BackShow(TRUE); + } +} + + + + + +static void SNLevel (SPRITE * spr, int lev) +{ + #ifdef DEMO + static int maxcav[] = { CAVE_MAX }; + #else + static int maxcav[] = { 1, 8, 16, 23, 24 }; + #endif + while (Lev < lev) + { + SPRITE * spr; + ++ Lev; + spr = VGA::SpareQ.Locate(100+Lev); + if (spr) + { + spr->BackShow(TRUE); + spr->Cave = 0; + } + } + MaxCave = maxcav[Lev]; + if (spr) spr->Flags.Hide = FALSE; +} + + + + + + +static void SNFlag (int fn, Boolean v) +{ + Flag[fn] = v; +} + + + + + + +static void SNSetRef (SPRITE * spr, int nr) +{ + if (spr) + { + spr->Ref = nr; + } +} + + + + +void SNFlash (Boolean on) +{ + if (on) + { + DAC far * pal = farnew(DAC, PAL_CNT); + if (pal) + { + int i; + _fmemcpy(pal, SysPal, PAL_SIZ); + for (i = 0; i < PAL_CNT; i ++) + { + register int c; + c = pal[i].R << 1; pal[i].R = (c < 64) ? c : 63; + c = pal[i].G << 1; pal[i].G = (c < 64) ? c : 63; + c = pal[i].B << 1; pal[i].B = (c < 64) ? c : 63; + } + VGA::SetColors(pal, 64); + } + } + else VGA::SetColors(SysPal, 64); + Dark = FALSE; +} + + + + + +static void SNLight (Boolean in) +{ + if (in) VGA::Sunrise(SysPal); + else VGA::Sunset(); + Dark = ! in; +} + + + + + +static void SNBarrier (int cav, int bar, Boolean horz) +{ + ((byte *) (Barriers + ((cav > 0) ? cav : Now)))[horz] = bar; +} + + + + + +static void SNWalk (SPRITE * spr, int x, int y) +{ + if (Hero) + { + if (spr && y < 0) Hero->FindWay(spr); + else Hero->FindWay(XZ(x, y)); + } +} + + + + + +static void SNReach (SPRITE * spr, int mode) +{ + if (Hero) Hero->Reach(spr, mode); +} + + + + + + +static void SNMouse (Boolean on) +{ + if (on) Mouse.On(); + else Mouse.Off(); +} + + + + + + +void SNAIL::RunCom (void) +{ + static int count = 1; + extern void SwitchCave(int); + if (! Busy) + { + Busy = TRUE; + byte tmphea = Head; + while (Tail != tmphea) + { + COM far * snc = &SNList[Tail]; + + if (! Turbo) // only for the slower one + { + if (Pause) break; + else + { + if (TextDelay) + { + KillText(); + TextDelay = FALSE; + } + } + if (Talk && snc->Com != SNPAUSE) break; + } + + SPRITE * sprel = ((snc->Ref >= 0) ? Locate(snc->Ref) + : ((SPRITE *) snc->Ptr)); + switch (snc->Com) + { + case SNLABEL : break; + case SNPAUSE : HEART::SetXTimer(&Pause, snc->Val); + if (Talk) TextDelay = TRUE; break; + case SNWAIT : if (sprel) + { + if (sprel->SeqTest(snc->Val) && + (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) + { + HEART::SetXTimer(&Pause, sprel->Time); + } + else goto xit; + } + break; + case SNLEVEL : SNLevel(sprel, snc->Val); break; + case SNHIDE : SNHide(sprel, snc->Val); break; + case SNSAY : if (sprel && TalkEnable) + { + if (sprel == Hero && sprel->SeqTest(-1)) + sprel->Step(HTALK); + Say(Text[snc->Val], sprel); + SYSTEM::FunDel = HEROFUN0; + } + break; + case SNINF : if (TalkEnable) + { + Inf(Text[snc->Val]); + SYSTEM::FunDel = HEROFUN0; + } + break; + case SNTIME : if (sprel && TalkEnable) + { + if (sprel == Hero && sprel->SeqTest(-1)) + sprel->Step(HTALK); + SayTime(sprel); + } + break; + case SNCAVE : SwitchCave(snc->Val); break; + case SNKILL : SNKill(sprel); break; + case SNSEQ : SNSeq(sprel, snc->Val); break; + case SNRSEQ : SNRSeq(sprel, snc->Val); break; + case SNSEND : SNSend(sprel, snc->Val); break; + case SNSWAP : SNSwap(sprel, snc->Val); break; + case SNCOVER : SNCover(sprel, snc->Val); break; + case SNUNCOVER : SNUncover(sprel, (snc->Val >= 0) ? Locate(snc->Val) + : ((SPRITE *) snc->Ptr)); + break; + case SNKEEP : SNKeep(sprel, snc->Val); break; + case SNGIVE : SNGive(sprel, snc->Val); break; + case SNGAME : SNGame(sprel, snc->Val); break; + case SNSETX0 : SNSetX0(snc->Ref, snc->Val); break; + case SNSETY0 : SNSetY0(snc->Ref, snc->Val); break; + case SNSETXY : SNSetXY(sprel, snc->Val); break; + case SNRELX : SNRelX(sprel, snc->Val); break; + case SNRELY : SNRelY(sprel, snc->Val); break; + case SNRELZ : SNRelZ(sprel, snc->Val); break; + case SNSETX : SNSetX(sprel, snc->Val); break; + case SNSETY : SNSetY(sprel, snc->Val); break; + case SNSETZ : SNSetZ(sprel, snc->Val); break; + case SNSLAVE : SNSlave(sprel, snc->Val); break; + case SNTRANS : SNTrans(sprel, snc->Val); break; + case SNPORT : SNPort(sprel, snc->Val); break; + case SNNEXT : break; + case SNIF : break; + case SNTALK : break; + case SNMOUSE : SNMouse(snc->Val != 0); break; + case SNNNEXT : SNNNext(sprel, snc->Val); break; + case SNTNEXT : SNTNext(sprel, snc->Val); break; + case SNRNNEXT : SNRNNext(sprel, snc->Val); break; + case SNRTNEXT : SNRTNext(sprel, snc->Val); break; + case SNRMNEAR : SNRmNear(sprel); break; + case SNRMTAKE : SNRmTake(sprel); break; + case SNFLAG : SNFlag(snc->Ref & 3, snc->Val != 0); break; + case SNSETREF : SNSetRef(sprel, snc->Val); break; + case SNBACKPT : SNBackPt(sprel, snc->Val); break; + case SNFLASH : SNFlash(snc->Val != 0); break; + case SNLIGHT : SNLight(snc->Val != 0); break; + case SNSETHB : SNBarrier(snc->Ref, snc->Val, TRUE); break; + case SNSETVB : SNBarrier(snc->Ref, snc->Val, FALSE); break; + case SNWALK : SNWalk(sprel, snc->Ref, snc->Val); break; + case SNREACH : SNReach(sprel, snc->Val); break; + case SNSOUND : SNSound(sprel, snc->Val, count); count = 1; break; + case SNCOUNT : count = snc->Val; break; + + case SNEXEC : ((void(*)(int)) (snc->Ptr))(snc->Val); break; + case SNSTEP : sprel->Step(); break; + case SNZTRIM : SNZTrim(sprel); break; + case SNGHOST : SNGhost((BITMAP *) snc->Ptr); break; + } + ++ Tail; + if (! Turbo) break; + } + xit: + Busy = FALSE; + } +} + + + + + +Boolean SNAIL::Idle (void) +{ + return (Head == Tail); +} diff --git a/engines/cge/snail.h b/engines/cge/snail.h new file mode 100644 index 0000000000..f1b0ab762f --- /dev/null +++ b/engines/cge/snail.h @@ -0,0 +1,98 @@ +#ifndef __SNAIL__ +#define __SNAIL__ + +#include + +#define POCKET_X 174 +#define POCKET_Y 176 +#define POCKET_DX 18 +#define POCKET_DY 22 +#define POCKET_NX 8 +#define POCKET_NY 1 + +#define POCKET_SX 8 +#define POCKET_SY 3 + +#define SNINSERT(c,r,v,p) Snail.InsCom(c,r,v,p) +#define SNPOST(c,r,v,p) Snail.AddCom(c,r,v,p) +#define SNPOST_(c,r,v,p) Snail_.AddCom(c,r,v,p) + + + +typedef struct { byte Horz, Vert; } BAR; + + + +struct SCB +{ + byte far * Ptr; + word Siz; + SCB * Nxt; +}; + + + +enum SNCOM { SNLABEL, SNPAUSE, SNWAIT, SNLEVEL, + SNHIDE, SNSAY, SNINF, SNTIME, + SNCAVE, SNKILL, SNRSEQ, + SNSEQ, SNSEND, SNSWAP, SNKEEP, SNGIVE, + SNIF, SNGAME, SNSETX0, SNSETY0, SNSLAVE, + SNSETXY, SNRELX, SNRELY, SNRELZ, + SNSETX, SNSETY, SNSETZ, SNTRANS, SNPORT, + SNNEXT, SNNNEXT, SNTNEXT, SNRNNEXT, SNRTNEXT, + SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, + SNBACKPT, SNFLASH, SNLIGHT, + SNSETHB, SNSETVB, + SNWALK, SNREACH, SNCOVER, SNUNCOVER, + SNCLEAR, SNTALK, SNMOUSE, + SNSOUND, SNCOUNT, + SNEXEC, SNSTEP, SNZTRIM, + SNGHOST + }; + +enum SNLIST { NEAR, TAKE }; + +class SNAIL +{ + struct COM { SNCOM Com; int Ref; int Val; void * Ptr; } far * SNList; + byte Head, Tail; + Boolean Turbo, Busy, TextDelay; + word Pause; +public: + static char * ComTxt[]; + Boolean TalkEnable; + SNAIL (Boolean turbo = FALSE); + ~SNAIL (void); + void RunCom (void); + void AddCom (SNCOM com, int ref = 0, int val = 0, void * ptr = NULL); + void InsCom (SNCOM com, int ref = 0, int val = 0, void * ptr = NULL); + Boolean Idle (void); +}; + + + + + +void SelectPocket (int n); +void PocFul (void); + + + + + + + +extern SCB Scb; +extern Boolean Flag[4]; +extern Boolean Game; +extern Boolean Dark; +extern SNAIL Snail; +extern SNAIL Snail_; +extern int Now; +extern int Lev; +extern int MaxCave; +extern int PocPtr; +extern BAR Barriers[]; +extern struct HXY { int X; int Y; } HeroXY[]; + +#endif diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h new file mode 100644 index 0000000000..69ea3c2b15 --- /dev/null +++ b/engines/cge/snddrv.h @@ -0,0 +1,104 @@ +// ****************************************************** +// * Sound Driver by Hedges (c) 1995 LK AVALON * +// * Ver 1.00: 01-Mar-95 * +// * Ver 1.10: 03-Mar-95 * +// * Ver 1.20: 07-Mar-95 * +// * Ver 1.30: 09-Mar-95 * +// * Ver 1.40: 11-Mar-95 * +// ****************************************************** + +#ifndef __SNDDRV__ +#define __SNDDRV__ + +// ****************************************************** +// * Constants * +// ****************************************************** +// available devices + +enum DEV_TYPE { DEV_AUTO = -1, // auto-detect mode + DEV_QUIET, // disable sound + DEV_SB, // sb/pro/16/awe32 + DEV_GUS, // gus/max + DEV_GM // general midi + }; + +#define SERR_OK 0 // no error +#define SERR_INITFAIL 1 // couldn't initialize +#define SERR_BADDDEV 128 // bad device + +// driver info +struct DRVINFO +{ + DEV_TYPE DDEV; // digi device + DEV_TYPE MDEV; // midi device + WORD DBASE; // digi base port + WORD DDMA; // digi dma no + WORD DIRQ; // digi irq no + WORD MBASE; // midi base port + union + { + struct + { + WORD DR : 4; + WORD DL : 4; + WORD MR : 4; + WORD ML : 4; + } VOL4; + struct + { + BYTE D; // digi volume + BYTE M; // midi volume + } VOL2; + }; +}; + +// sample info +struct SMPINFO +{ + BYTE far * saddr; // address + WORD slen; // length + WORD span; // left/right pan (0-15) + int sflag; // flag +}; + +// ****************************************************** +// * Data * +// ****************************************************** +// driver info +extern DRVINFO SNDDrvInfo; + +// midi player flag (1 means we are playing) +extern WORD MIDIPlayFlag; + +// midi song end flag (1 means we have crossed end mark) +extern WORD MIDIEndFlag; + +// ****************************************************** +// * Driver Code * +// ****************************************************** +// Init Digi Device +EC void SNDInit (void); + +// Close Digi Device +EC void SNDDone (void); + +// Set Volume +EC void SNDSetVolume (void); + +// Start Digi +EC void SNDDigiStart (SMPINFO *PSmpInfo); + +// Stop Digi +EC void SNDDigiStop (SMPINFO *PSmpInfo); + +// Start MIDI File +EC void SNDMIDIStart (BYTE far *MIDFile); + +// Stop MIDI File +EC void SNDMIDIStop (void); + +// Play MIDI File (to be called while interrupting) +// WARNING: Uses ALL registers! +EC void SNDMIDIPlay (void); + +#endif diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp new file mode 100644 index 0000000000..f4fc27ddd7 --- /dev/null +++ b/engines/cge/sound.cpp @@ -0,0 +1,293 @@ +#include +#include "startup.h" +#include "sound.h" + +#ifdef DROP_H + #include "drop.h" +#else + #include + #include + #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } +#endif + +#include "text.h" +#include +#include "vol.h" +#include + + + Boolean Music = TRUE; + FX Fx = 16; // must precede SOUND!! + SOUND Sound; + + + +SOUND::SOUND (void) +{ + if (STARTUP::SoundOk) Open(); +} + + + + +SOUND::~SOUND (void) +{ + Close(); +} + + + + + +void SOUND::Close (void) +{ + KillMIDI(); + SNDDone(); +} + + + + + +void SOUND::Open (void) +{ + SNDInit(); + Play(Fx[30000], 8); +} + + + + +void SOUND::Play (DATACK * wav, int pan, int cnt) +{ + if (wav) + { + Stop(); + smpinf.saddr = (char far *) &*(wav->EAddr()); + smpinf.slen = (word)wav->Size(); + smpinf.span = pan; + smpinf.sflag = cnt; + SNDDigiStart(&smpinf); + } +} + + + + +void SOUND::Stop (void) +{ + SNDDigiStop(&smpinf); +} + + +//------------------------------------------------------------------------ + + + + + + + + +FX::FX (int size) +: Emm(0L), Current(NULL) +{ + Cache = new HAN[size]; + for (Size = 0; Size < size; Size ++) + { + Cache[Size].Ref = 0; + Cache[Size].Wav = NULL; + } +} + + + + +FX::~FX (void) +{ + Clear(); + delete[] Cache; +} + + + + + +void FX::Clear (void) +{ + HAN * p, * q; + for (p = Cache, q = p+Size; p < q; p ++) + { + if (p->Ref) + { + p->Ref = 0; + delete p->Wav; + p->Wav = NULL; + } + } + Emm.Release(); + Current = NULL; +} + + + + + +int FX::Find (int ref) +{ + HAN * p, * q; + int i = 0; + for (p = Cache, q = p+Size; p < q; p ++) + { + if (p->Ref == ref) break; + else ++ i; + } + return i; +} + + + + + + + + + + + +void FX::Preload (int ref0) +{ + HAN * CacheLim = Cache + Size; + int ref; + + for (ref = ref0; ref < ref0+10; ref ++) + { + static char fname[] = "FX00000.WAV"; + wtom(ref, fname+2, 10, 5); + DATACK * wav = LoadWave(&INI_FILE(fname), &Emm); + if (wav) + { + HAN * p = &Cache[Find(0)]; + if (p >= CacheLim) break; + p->Wav = wav; + p->Ref = ref; + } + } +} + + + + + +DATACK * FX::Load (int idx, int ref) +{ + static char fname[] = "FX00000.WAV"; + wtom(ref, fname+2, 10, 5); + + DATACK * wav = LoadWave(&INI_FILE(fname), &Emm); + if (wav) + { + HAN * p = &Cache[idx]; + p->Wav = wav; + p->Ref = ref; + } + return wav; +} + + + + +DATACK * FX::operator [] (int ref) +{ + int i; + if ((i = Find(ref)) < Size) Current = Cache[i].Wav; + else + { + if ((i = Find(0)) >= Size) + { + Clear(); + i = 0; + } + Current = Load(i, ref); + } + return Current; +} + + + + +//------------------------------------------------------------------------- + + +static byte far * midi = NULL; + + + +void KillMIDI (void) +{ + SNDMIDIStop(); + if (midi) + { + delete[] midi; + midi = NULL; + } +} + + + + + +void LoadMIDI (int ref) +{ + static char fn[] = "00.MID"; + wtom(ref, fn, 10, 2); + if (INI_FILE::Exist(fn)) + { + KillMIDI(); + INI_FILE mid = fn; + if (mid.Error == 0) + { + word siz = (word) mid.Size(); + midi = new far byte[siz]; + if (midi) + { + mid.Read(midi, siz); + if (mid.Error) KillMIDI(); + else + { + SNDMIDIStart(midi); + } + } + } + } +} + + + + + + +EC void far * Patch (int pat) +{ + void far * p = NULL; + static char fn[] = "PATCH000.SND"; + + wtom(pat, fn+5, 10, 3); + INI_FILE snd = fn; + if (! snd.Error) + { + word siz = (word) snd.Size(); + p = (byte far *) farmalloc(siz); + if (p) + { + snd.Read(p, siz); + if (snd.Error) + { + farfree(p); + p = NULL; + } + } + } + return p; +} + diff --git a/engines/cge/sound.h b/engines/cge/sound.h new file mode 100644 index 0000000000..b4efd99808 --- /dev/null +++ b/engines/cge/sound.h @@ -0,0 +1,61 @@ +#ifndef __SOUND__ +#define __SOUND__ + +#include +#include + + +#define BAD_SND_TEXT 97 +#define BAD_MIDI_TEXT 98 + + + + +class SOUND +{ +public: + SMPINFO smpinf; + SOUND (void); + ~SOUND (void); + void Open (void); + void Close (void); + void Play (DATACK * wav, int pan, int cnt = 1); + void Stop (void); +}; + + + + + +class FX +{ + EMM Emm; + struct HAN { int Ref; DATACK * Wav; } * Cache; + int Size; + DATACK * Load (int idx, int ref); + int Find (int ref); +public: + DATACK * Current; + FX (int size = 16); + ~FX (void); + void Clear (void); + void Preload (int ref0); + DATACK * operator[] (int ref); +}; + + + + + + +extern Boolean Music; +extern SOUND Sound; +extern FX Fx; + + +void LoadMIDI (int ref); +void KillMIDI (void); + + +#endif + diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp new file mode 100644 index 0000000000..3557891a03 --- /dev/null +++ b/engines/cge/startup.cpp @@ -0,0 +1,168 @@ +#include "startup.h" +#include "text.h" +#include "sound.h" +#include "ident.h" +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG + #include +#endif + +extern char Copr[]; + +#define id (*(IDENT*)Copr) + + + EMM MiniEmm = MINI_EMM_SIZE; + +static STARTUP StartUp; + + + int STARTUP::Mode = 0; + int STARTUP::Core; + int STARTUP::SoundOk = 0; + word STARTUP::Summa; + + + +void quit_now (int ref) +{ + fputs(Text[ref], stderr); + fputc('\n', stderr); + _exit(1); +} + + + +Boolean STARTUP::get_parms (void) +{ + int i = _argc; + while (i > 1) + { + static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", + "P", "D", "I", "M" }; + int n = TakeEnum(PrmTab, strtok(_argv[--i], " =:(")); + word p = xtow(strtok(NULL, " h,)")); + switch (n) + { + case 0 : if (Mode != 2) Mode = 1; break; + case 1 : Mode = 2; break; + case 2 : SNDDrvInfo.DDEV = DEV_QUIET; break; + case 3 : SNDDrvInfo.DDEV = DEV_SB; break; + case 4 : SNDDrvInfo.DDEV = DEV_GUS; break; + case 5 : SNDDrvInfo.MDEV = DEV_GM; break; + case 6 : SNDDrvInfo.DBASE = p; break; + case 7 : SNDDrvInfo.DDMA = p; break; + case 8 : SNDDrvInfo.DIRQ = p; break; + case 9 : SNDDrvInfo.MBASE = p; + SNDDrvInfo.MDEV = DEV_GM; break; + default: return FALSE; + } + if (n >= 2) SoundOk = 2; + } + #ifdef DEMO + // protection disabled + Summa = 0; + #else + #ifdef EVA + { + union { dosdate_t d; dword n; } today; + _dos_getdate(&today.d); + id.disk += (id.disk < today.n); + } + #endif + #ifdef CD + Summa = 0; + #else + // disk signature checksum + Summa = ChkSum(Copr, sizeof(IDENT)); + #endif + #endif + if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; + return TRUE; +} + + + + +STARTUP::STARTUP (void) +{ + dword m = farcoreleft() >> 10; + if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF; + + if (! IsVga()) quit_now(NOT_VGA_TEXT); + if (Cpu() < _80286) quit_now(BAD_CHIP_TEXT); + if (100 * _osmajor + _osminor < 330) quit_now(BAD_DOS_TEXT); + + #ifndef DEBUG + if (Core < CORE_LOW) quit_now(NO_CORE_TEXT); + if (Core < CORE_HIG) + { + SNDDrvInfo.MDEV = DEV_QUIET; + Music = FALSE; + } + #endif + if (! get_parms()) quit_now(BAD_ARG_TEXT); + //--- load sound configuration + const char * fn = UsrPath(ProgName(CFG_EXT)); + if (! STARTUP::SoundOk && CFILE::Exist(fn)) + { + CFILE cfg(fn, REA); + if (! cfg.Error) + { + cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); + if (! cfg.Error) STARTUP::SoundOk = 1; + } + } +} + + + + + + +const char *UsrPath (const char *nam) +{ + static char buf[MAXPATH] = ".\\", *p = buf+2; + #if defined(CD) + if (DriveCD(0)) + { + Boolean ok = FALSE; + CFILE ini = Text[CDINI_FNAME]; + if (!ini.Error) + { + char *key = Text[GAME_ID]; + int i = strlen(key); + while (ini.Read(buf) && !ok) + { + int j = strlen(buf); + if (j) if (buf[--j] == '\n') buf[j] = '\0'; + if (memicmp(buf, key, i) == 0) ok = TRUE; + } + if (ok) + { + strcpy(buf, buf+i); + p = buf + strlen(buf); + if (*(p-1) != '\\') *(p++) = '\\'; + strcpy(p, "NUL"); + if (_dos_open(buf, 0, &i) == 0) _dos_close(i); + else ok = FALSE; + } + } + if (!ok) quit_now(BADCD_TEXT); + } + #endif + strcpy(p, nam); + return buf; +} + + + + + diff --git a/engines/cge/startup.h b/engines/cge/startup.h new file mode 100644 index 0000000000..6db566a781 --- /dev/null +++ b/engines/cge/startup.h @@ -0,0 +1,52 @@ +#ifndef __STARTUP__ +#define __STARTUP__ + + +#include + +#define GAME_ID 45 +#define CDINI_FNAME 46 + +#define NOT_VGA_TEXT 90 +#define BAD_CHIP_TEXT 91 +#define BAD_DOS_TEXT 92 +#define NO_CORE_TEXT 93 +#define BAD_MIPS_TEXT 94 +#define NO_MOUSE_TEXT 95 +#define BAD_ARG_TEXT 96 +#define BADCD_TEXT 97 + +#define CFG_EXT ".CFG" + +#if defined(DEMO) + #define MINI_EMM_SIZE 0x00004000L + #define CORE_HIG 400 +#else + #define MINI_EMM_SIZE 0x00010000L + #define CORE_HIG 450 +#endif + +#define CORE_MID (CORE_HIG-20) +#define CORE_LOW (CORE_MID-20) + + +class STARTUP +{ + static Boolean get_parms (void); +public: + static int Mode; + static int Core; + static int SoundOk; + static word Summa; + STARTUP (void); +}; + + + + +extern EMM MiniEmm; + +const char *UsrPath (const char *nam); + + +#endif diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp new file mode 100644 index 0000000000..a018761000 --- /dev/null +++ b/engines/cge/talk.cpp @@ -0,0 +1,376 @@ +#include +#include "talk.h" +#include "vol.h" +#include "game.h" +#include "mouse.h" +#include +#include +#include + +#define WID_SIZ 256 +#define POS_SIZ 256 +#define MAP_SIZ (256*8) + + +//-------------------------------------------------------------------------- + + + +//byte FONT::Wid[WID_SIZ]; +//word FONT::Pos[POS_SIZ]; +//byte FONT::Map[MAP_SIZ]; + + + + + + + +FONT::FONT (const char * name) +{ + Map = farnew(byte, MAP_SIZ); + Pos = farnew(word, POS_SIZ); + Wid = farnew(byte, WID_SIZ); + if (Map == NULL || Pos == NULL || Wid == NULL) DROP("No core", NULL); + MergeExt(Path, name, FONT_EXT); + Load(); +} + + + + +FONT::~FONT (void) +{ + farfree(Map); + farfree(Pos); + farfree(Wid); +} + + + + +void FONT::Load (void) +{ + INI_FILE f(Path); + if (! f.Error) + { + f.Read(Wid, WID_SIZ); + if (! f.Error) + { + word i, p = 0; + for (i = 0; i < POS_SIZ; i ++) + { + Pos[i] = p; + p += Wid[i]; + } + f.Read(Map, p); + } + } +} + + + + + +word FONT::Width (const char * text) +{ + word w = 0; + if (text) while (* text) w += Wid[*(text ++)]; + return w; +} + + + +/* +void FONT::Save (void) +{ + CFILE f((const char *) Path, WRI); + if (! f.Error) + { + f.Write(Wid, WID_SIZ); + if (! f.Error) + { + f.Write(Map, Pos[POS_SIZ-1] + Wid[WID_SIZ-1]); + } + } +} +*/ + + + + +//-------------------------------------------------------------------------- + + + +FONT TALK::Font(ProgName()); + + + +TALK::TALK (const char * tx, TBOX_STYLE mode) +: SPRITE(NULL), Mode(mode) +{ + TS[0] = TS[1] = NULL; + Flags.Syst = TRUE; + Update(tx); +} + + + + + +TALK::TALK (void) +: SPRITE(NULL), Mode(PURE) +{ + TS[0] = TS[1] = NULL; + Flags.Syst = TRUE; +} + + + + + +/* +TALK::~TALK (void) +{ + word i; + for (i = 0; i < ShpCnt; i ++) + { + if (FP_SEG(ShpList[i]) != _DS) // small model: always FALSE + { + delete ShpList[i]; + ShpList[i] = NULL; + } + } +} +*/ + + + +void TALK::Update (const char * tx) +{ + word vmarg = (Mode) ? TEXT_VM : 0; + word hmarg = (Mode) ? TEXT_HM : 0; + word mw, mh, ln = vmarg; + const char * p; + byte far * m; + + if (! TS[0]) + { + word k = 2 * hmarg; + mh = 2 * vmarg + FONT_HIG; + mw = 0; + for (p = tx; *p; p ++) + { + if (*p == '|' || *p == '\n') + { + mh += FONT_HIG + TEXT_LS; + if (k > mw) mw = k; + k = 2 * hmarg; + } + else k += Font.Wid[*p]; + } + if (k > mw) mw = k; + TS[0] = Box(mw, mh); + } + + m = TS[0]->M + ln * mw + hmarg; + + while (* tx) + { + if (*tx == '|' || *tx == '\n') + m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; + else + { + int cw = Font.Wid[*tx], i; + char far * f = Font.Map + Font.Pos[*tx]; + for (i = 0; i < cw; i ++) + { + char far * p = m; + word n; + register word b = * (f ++); + for (n = 0; n < FONT_HIG; n ++) + { + if (b & 1) * p = TEXT_FG; + b >>= 1; + p += mw; + } + ++ m; + } + } + ++ tx; + } + TS[0]->Code(); + SetShapeList(TS); +} + + + + +BITMAP * TALK::Box (word w, word h) +{ + byte far * b, far * p, far * q; + word n, r = (Mode == ROUND) ? TEXT_RD : 0; + int i; + + if (w < 8) w = 8; + if (h < 8) h = 8; + b = farnew(byte, n = w * h); + if (! b) VGA::Exit("No core"); + _fmemset(b, TEXT_BG, n); + + if (Mode) + { + p = b; q = b + n - w; + _fmemset(p, LGRAY, w); + _fmemset(q, DGRAY, w); + while (p < q) + { + p += w; + * (p-1) = DGRAY; + * p = LGRAY; + } + p = b; + for (i = 0; i < r; i ++) + { + int j; + for (j = 0; j < r-i; j ++) + { + p[ j ] = TRANS; + p[w-j-1] = TRANS; + q[ j ] = TRANS; + q[w-j-1] = TRANS; + } + p[ j ] = LGRAY; + p[w-j-1] = DGRAY; + q[ j ] = LGRAY; + q[w-j-1] = DGRAY; + p += w; + q -= w; + } + } + return new BITMAP(w, h, b); +} + + + + + +void TALK::PutLine (int line, const char * text) +// Note: (TS[0].W % 4) have to be 0 +{ + word w = TS[0]->W, h = TS[0]->H; + byte far * v = TS[0]->V, far * p; + word dsiz = w >> 2; // data size (1 plane line size) + word lsiz = 2 + dsiz + 2; // word for line header, word for gap + word psiz = h * lsiz; // - last gap, but + plane trailer + word size = 4 * psiz; // whole map size + word rsiz = FONT_HIG * lsiz; // length of whole text row map + + // set desired line pointer + v += (TEXT_VM + (FONT_HIG + TEXT_LS) * line) * lsiz; + + // clear whole rectangle + p = v; // assume blanked line above text + _fmemcpy(p, p-lsiz, rsiz); p += psiz; // tricky replicate lines for plane 0 + _fmemcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 1 + _fmemcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 2 + _fmemcpy(p, p-lsiz, rsiz); // same for plane 3 + + // paint text line + if (text) + { + byte far * q; + p = v + 2 + TEXT_HM/4 + (TEXT_HM%4)*psiz; + q = v + size; + + while (* text) + { + word cw = Font.Wid[*text], i; + byte far * fp = Font.Map + Font.Pos[*text]; + + for (i = 0; i < cw; i ++) + { + register word b = fp[i]; + word n; + for (n = 0; n < FONT_HIG; n ++) + { + if (b & 1) *p = TEXT_FG; + b >>= 1; + p += lsiz; + } + p = p - rsiz + psiz; + if (p >= q) p = p - size + 1; + } + ++ text; + } + } +} + + + + + + +//-------------------------------------------------------------------------- + + + + +INFO_LINE::INFO_LINE (word w) +: OldTxt(NULL) +{ + TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG); + SetShapeList(TS); +} + + + + + + +void INFO_LINE::Update (const char * tx) +{ + if (tx != OldTxt) + { + word w = TS[0]->W, h = TS[0]->H; + byte * v = (byte near *) TS[0]->V; + word dsiz = w >> 2; // data size (1 plane line size) + word lsiz = 2 + dsiz + 2; // word for line header, word for gap + word psiz = h * lsiz; // - last gape, but + plane trailer + word size = 4 * psiz; // whole map size + + // claer whole rectangle + memset(v+2, TEXT_BG, dsiz); // data bytes + memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines + * (word *) (v + psiz - 2) = EOI; // plane trailer word + memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes + + // paint text line + if (tx) + { + byte * p = v + 2, * q = p + size; + + while (* tx) + { + word cw = Font.Wid[*tx], i; + byte far * fp = Font.Map + Font.Pos[*tx]; + + for (i = 0; i < cw; i ++) + { + register word b = fp[i]; + word n; + for (n = 0; n < FONT_HIG; n ++) + { + if (b & 1) *p = TEXT_FG; + b >>= 1; + p += lsiz; + } + if (p >= q) p = p - size + 1; + } + ++ tx; + } + } + OldTxt = tx; + } +} diff --git a/engines/cge/talk.h b/engines/cge/talk.h new file mode 100644 index 0000000000..12b0b94dde --- /dev/null +++ b/engines/cge/talk.h @@ -0,0 +1,81 @@ +#ifndef __TALK__ +#define __TALK__ + +#include "vga13h.h" +#include + + + +#define TEXT_FG DARK // foreground color +#define TEXT_BG GRAY // background color +#define TEXT_HM (6&~1) // EVEN horizontal margins! +#define TEXT_VM 5 // vertical margins +#define TEXT_LS 2 // line spacing +#define TEXT_RD 3 // rounded corners + +#define FONT_HIG 8 +#define FONT_EXT ".CFT" + + + + + +class FONT +{ + char Path[MAXPATH]; + void Load (void); +public: +// static byte Wid[256]; +// static word Pos[256]; +// static byte Map[256*8]; + byte far * Wid; + word far * Pos; + byte far * Map; + FONT (const char * name); + ~FONT (void); + word Width (const char * text); + void Save (void); +}; + + + + + +enum TBOX_STYLE { PURE, RECT, ROUND }; + + + +class TALK : public SPRITE +{ +protected: + TBOX_STYLE Mode; + BITMAP * TS[2]; + BITMAP * Box(word w, word h); +public: + static FONT Font; + TALK (const char * tx, TBOX_STYLE mode = PURE); + TALK (void); + //~TALK (void); + virtual void Update (const char * tx); + virtual void Update (void) {} + void PutLine (int line, const char * text); +}; + + + + + + + +class INFO_LINE : public TALK +{ + const char * OldTxt; +public: + INFO_LINE (word wid); + void Update (const char * tx); +}; + + + + +#endif \ No newline at end of file diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp new file mode 100644 index 0000000000..a18eec5baf --- /dev/null +++ b/engines/cge/text.cpp @@ -0,0 +1,291 @@ +#include +#include "text.h" +#include "talk.h" +#include "vol.h" +#include "bitmaps.h" +#include "game.h" +#include "snail.h" +#include +#include +#include +#include + + + + TEXT Text = ProgName(); + TALK * Talk = NULL; + + + + + +TEXT::TEXT (const char * fname, int size) +{ + Cache = new HAN[size]; + MergeExt(FileName, fname, SAY_EXT); + if (! INI_FILE::Exist(FileName)) + { + fputs("No talk\n", stderr); + _exit(1); + } + for (Size = 0; Size < size; Size ++) + { + Cache[Size].Ref = 0; + Cache[Size].Txt = NULL; + } +} + + + + +TEXT::~TEXT (void) +{ + Clear(); + delete[] Cache; +} + + + + + +void TEXT::Clear (int from, int upto) +{ + HAN * p, * q; + for (p = Cache, q = p+Size; p < q; p ++) + { + if (p->Ref && p->Ref >= from && p->Ref < upto) + { + p->Ref = 0; + delete p->Txt; + p->Txt = NULL; + } + } +} + + + + + +int TEXT::Find (int ref) +{ + HAN * p, * q; + int i = 0; + for (p = Cache, q = p+Size; p < q; p ++) + { + if (p->Ref == ref) break; + else ++ i; + } + return i; +} + + + + + + + + + + + +void TEXT::Preload (int from, int upto) +{ + INI_FILE tf = FileName; + if (! tf.Error) + { + HAN * CacheLim = Cache + Size; + char line[LINE_MAX+1]; + int n; + + while ((n = tf.Read(line)) != 0) + { + char * s; + int ref; + + if (line[n-1] == '\n') line[-- n] = '\0'; + if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; + if (! IsDigit(*s)) continue; + ref = atoi(s); + if (ref && ref >= from && ref < upto) + { + HAN * p; + + p = &Cache[Find(ref)]; + if (p < CacheLim) + { + delete[] p->Txt; + p->Txt = NULL; + } + else p = &Cache[Find(0)]; + if (p >= CacheLim) break; + s += strlen(s); + if (s < line + n) ++ s; + if ((p->Txt = new char[strlen(s) + 1]) == NULL) break; + p->Ref = ref; + strcpy(p->Txt, s); + } + } + } +} + + + + + +char * TEXT::Load (int idx, int ref) +{ + INI_FILE tf = FileName; + if (! tf.Error) + { + HAN * p = &Cache[idx]; + char line[LINE_MAX+1]; + int n; + + while ((n = tf.Read(line)) != 0) + { + char * s; + + if (line[n-1] == '\n') line[-- n] = '\0'; + if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; + if (! IsDigit(*s)) continue; + + int r = atoi(s); + if (r < ref) continue; + if (r > ref) break; + // (r == ref) + s += strlen(s); + if (s < line + n) ++ s; + p->Ref = ref; + if ((p->Txt = new char[strlen(s) + 1]) == NULL) return NULL; + return strcpy(p->Txt, s); + } + } + return NULL; +} + + + + +char * TEXT::operator [] (int ref) +{ + int i; + if ((i = Find(ref)) < Size) return Cache[i].Txt; + + if ((i = Find(0)) >= Size) + { + Clear(SYSTXT_MAX); // clear non-system + if ((i = Find(0)) >= Size) + { + Clear(); // clear all + i = 0; + } + } + return Load(i, ref); +} + + + + + + +void Say (const char * txt, SPRITE * spr) +{ + KillText(); + Talk = new TALK(txt, ROUND); + if (Talk) + { + Boolean east = spr->Flags.East; + int x = (east) ? (spr->X+spr->W-2) : (spr->X+2); + int y = spr->Y+2; + SPRITE * spike = new SPRITE(SP); + word sw = spike->W; + + if (east) + { + if (x + sw + TEXT_RD + 5 >= SCR_WID) east = FALSE; + } + else + { + if (x <= 5 + TEXT_RD + sw) east = TRUE; + } + x = (east) ? (spr->X+spr->W-2) : (spr->X+2-sw); + if (spr->Ref == 1) x += (east) ? -10 : 10; // Hero + + Talk->Flags.Kill = TRUE; + Talk->Flags.BDel = TRUE; + Talk->SetName(Text[SAY_NAME]); + Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H+1); + Talk->Z = 125; + Talk->Ref = SAY_REF; + + spike->Goto(x, Talk->Y + Talk->H - 1); + spike->Z = 126; + spike->Flags.Slav = TRUE; + spike->Flags.Kill = TRUE; + spike->SetName(Text[SAY_NAME]); + spike->Step(east); + spike->Ref = SAY_REF; + + VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last()); + VGA::ShowQ.Insert(spike, VGA::ShowQ.Last()); + } +} + + + + + + + +void Inf (const char * txt) +{ + KillText(); + Talk = new TALK(txt, RECT); + if (Talk) + { + Talk->Flags.Kill = TRUE; + Talk->Flags.BDel = TRUE; + Talk->SetName(Text[INF_NAME]); + Talk->Center(); + Talk->Goto(Talk->X, Talk->Y - 20); + Talk->Z = 126; + Talk->Ref = INF_REF; + VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last()); + } +} + + + + + + + +void SayTime (SPRITE * spr) +{ + static char t[] = "00:00"; + struct time ti; + gettime(&ti); + wtom(ti.ti_hour, t+0, 10, 2); + wtom(ti.ti_min, t+3, 10, 2); + Say((*t == '0') ? (t+1) : t, spr); +} + + + + + + +void KillText (void) +{ + if (Talk) + { + SNPOST_(SNKILL, -1, 0, Talk); + Talk = NULL; + } +} + + + + + +//------------------------------------------------------------------------- diff --git a/engines/cge/text.h b/engines/cge/text.h new file mode 100644 index 0000000000..d960fbef91 --- /dev/null +++ b/engines/cge/text.h @@ -0,0 +1,60 @@ +#ifndef __TEXT__ +#define __TEXT__ + +#include "talk.h" +#include +#include + + + + +#ifndef SYSTXT_MAX + #define SYSTXT_MAX 1000 +#endif + +#define SAY_EXT ".SAY" + +#define NOT_VGA_TEXT 90 +#define BAD_CHIP_TEXT 91 +#define BAD_DOS_TEXT 92 +#define NO_CORE_TEXT 93 +#define BAD_MIPS_TEXT 94 +#define NO_MOUSE_TEXT 95 + + +#define INF_NAME 101 +#define SAY_NAME 102 + +#define INF_REF 301 +#define SAY_REF 302 + + +class TEXT +{ + struct HAN { int Ref; char * Txt; } * Cache; + int Size; + char FileName[MAXPATH]; + char * Load (int idx, int ref); + int Find (int ref); +public: + TEXT (const char * fname, int size = 128); + ~TEXT (void); + void Clear (int from = 1, int upto = 0x7FFF); + void Preload (int from = 1, int upto = 0x7FFF); + char * operator[] (int ref); +}; + + + +extern TALK * Talk; +extern TEXT Text; + + +void Say (const char * txt, SPRITE * spr); +void SayTime (SPRITE * spr); +void Inf (const char * txt); +void KillText (void); + + + +#endif \ No newline at end of file diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp new file mode 100644 index 0000000000..227304668b --- /dev/null +++ b/engines/cge/vga13h.cpp @@ -0,0 +1,1775 @@ +#include +#include "vga13h.h" +#include "bitmap.h" +#include "vol.h" +#include "text.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +#define REPORT +#endif + +#define OK(f) ((f).Error==0) +#define FADE_STEP 2 + +#define TMR_DIV ((0x8000/TMR_RATE)*2) + + +//-------------------------------------------------------------------------- + +#ifdef REPORT +static char Report[] = "NearHeap=..... FarHeap=......\n"; +#define NREP 9 +#define FREP 24 +#endif + + + +static VgaRegBlk VideoMode[] = { + + { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode + + { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 + { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 + { 0x06, VGAGRA, 0x02, 0x00 }, // misc + + { 0x14, VGACRT, 0x40, 0x00 }, // underline + { 0x13, VGACRT, 0xFF, 0x28 }, // screen width + { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control + + { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end + { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line + + { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode + +// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end +// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb +// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr + + { 0x00 } }; + + + Boolean SpeedTest = FALSE; + SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; + SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; + SPRITE * Sys = NULL; + +extern "C" void SNDMIDIPlay (void); + + + + + + +char * NumStr (char * str, int num) +{ + char * p = strchr(str, '#'); + if (p) wtom(num, p, 10, 5); + return str; +} + + + + + + + + +static void Video (void) +{ + static word SP_S; + + asm push bx + asm push bp + asm push si + asm push di + asm push es + asm xor bx,bx // video page #0 + SP_S = _SP; + asm int VIDEO + _SP = SP_S; + asm pop es + asm pop di + asm pop si + asm pop bp + asm pop bx +} + + + + + + +word far * SaveScreen (void) +{ + word cxy, cur, siz, far * scr = NULL, far * sav; + + // horizontal size of text mode screen + asm mov ah,0x0F // get current video mode + Video(); // BIOS video service + asm xchg ah,al // answer in ah + asm push ax // preserve width + + // vertical size of text mode screen + asm mov dl,24 // last row on std screen + asm xor bx,bx // valid request in BH + asm mov ax,0x1130 // get EGA's last row # + Video(); // BIOS video service + asm inc dl // # of rows = last+1 + + // compute screen size in words + asm pop ax // restore width + asm mul dl // width * height + + siz = _AX; + + asm mov ax,0x40 // system data segment + asm mov es,ax + asm mov ax,0B000H // Mono + asm cmp byte ptr es:[0x49],0x07 + asm je sto + asm mov ax,0B800H // Color + sto: // store screen address + asm mov word ptr scr+2,ax + + _AH = 0x0F; Video(); // active page + + // take cursor shape + _AH = 0x03; Video(); // get cursor size + cur = _CX; + + // take cursor position + _DH = 0; + _AH = 0x03; Video(); // get cursor + cxy = _DX; + + sav = farnew(word, siz+3); // +3 extra words for size and cursor + if (sav) + { + sav[0] = siz; + sav[1] = cur; + sav[2] = cxy; + _fmemcpy(sav+3, scr, siz * 2); + } + return sav; +} + + + + + +void RestoreScreen (word far * &sav) +{ + word far * scr = NULL; + + asm mov ax,0x40 // system data segment + asm mov es,ax + asm mov ax,0B000H // Mono + asm cmp byte ptr es:[0x49],0x07 + asm je sto + asm mov ax,0B800H // Color + sto: // store screen address + asm mov word ptr scr+2,ax + + _fmemcpy(scr, sav+3, sav[0] * 2); + + _AH = 0x0F; Video(); // active page + + // set cursor shape + _CX = sav[1]; + _AH = 0x01; Video(); // set cursor size + + // set cursor position + _DX = sav[2]; + _AH = 0x02; Video(); // set cursor + + farfree(sav); + sav = NULL; +} + + + + + + +DAC MkDAC (byte r, byte g, byte b) +{ + static DAC x; + x.R = r; + x.G = g; + x.B = b; + return x; +} + + + + +RGB MkRGB (byte r, byte g, byte b) +{ + static TRGB x; + x.dac.R = r; + x.dac.G = g; + x.dac.B = b; + return x.rgb; +} + + + + + + +SPRITE * Locate (int ref) +{ + SPRITE * spr = VGA::ShowQ.Locate(ref); + return (spr) ? spr : VGA::SpareQ.Locate(ref); +} + + + + + +//-------------------------------------------------------------------------- + + +Boolean HEART::Enable = FALSE; +word * HEART::XTimer = NULL; + + + + +HEART::HEART (void) +: ENGINE(TMR_DIV) +{ +} + + +/* +extern "C" void TimerProc (void) +{ + static SPRITE * spr; + static byte run = 0; + + // decrement external timer word + if (HEART::XTimer) + if (*HEART::XTimer) -- *HEART::XTimer; + else HEART::XTimer = NULL; + + if (! run && HEART::Enable) // check overrun flag + { + static word oldSP, oldSS; + + ++ run; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 + + // system pseudo-sprite + if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); + + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) + { + if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); + } + asm mov ss,oldSS + asm mov sp,oldSP + -- run; + } +} +*/ + + +void interrupt ENGINE::NewTimer (...) +{ + static SPRITE * spr; + static byte run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; + + ___1152_Hz___: + + SNDMIDIPlay(); + asm dec cntr1 + asm jz ___72_Hz___ + asm mov al,0x20 // send... + asm out 0x020,al // ...e-o-i + return; + + ___72_Hz___: + + asm mov cntr1,TMR_RATE1 + asm dec cntr2 + asm jnz my_eoi + + ___18_Hz___: + + OldTimer(); + asm mov cntr2,TMR_RATE2 + asm jmp short my_int + + // send E-O-I + my_eoi: + asm mov al,0x20 + asm out 0x020,al + asm sti // enable interrupts + + my_int: //------72Hz-------// + + // decrement external timer word + if (HEART::XTimer) + if (*HEART::XTimer) -- *HEART::XTimer; + else HEART::XTimer = NULL; + + if (! run && HEART::Enable) // check overrun flag + { + static word oldSP, oldSS; + + ++ run; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 + + // system pseudo-sprite + if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); + + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) + { + if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); + } + asm mov ss,oldSS + asm mov sp,oldSP + -- run; + } +} + + + + + +void HEART::SetXTimer (word * ptr) +{ + if (XTimer && ptr != XTimer) *XTimer = 0; + XTimer = ptr; +} + + + + +void HEART::SetXTimer (word * ptr, word time) +{ + SetXTimer(ptr); + *ptr = time; +} + + + + +//-------------------------------------------------------------------------- + + + + + + + +SPRITE::SPRITE (BMP_PTR * shp) +: X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), + Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), + Ext(NULL), Ref(-1), Cave(0) +{ + memset(File, 0, sizeof(File)); + *((word *)&Flags) = 0; + SetShapeList(shp); +} + + + + + + +SPRITE::~SPRITE (void) +{ + Contract(); +} + + + + +BMP_PTR SPRITE::Shp (void) +{ + register SPREXT * e = Ext; + if (e) if (e->Seq) + { + int i = e->Seq[SeqPtr].Now; + #ifdef DEBUG + if (i >= ShpCnt) + { + //char s[256]; + //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", + // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); + //VGA::Exit(s, File); + VGA::Exit("Invalid PHASE in SPRITE::Shp()", File); + } + #endif + return e->ShpList[i]; + } + return NULL; +} + + + + + +BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) +{ + BMP_PTR * r = (Ext) ? Ext->ShpList : NULL; + + ShpCnt = 0; + W = 0; + H = 0; + + if (shp) + { + BMP_PTR * p; + for (p = shp; *p; p ++) + { + BMP_PTR b = (*p); // ->Code(); + if (b->W > W) W = b->W; + if (b->H > H) H = b->H; + ++ ShpCnt; + } + Expand(); + Ext->ShpList = shp; + if (! Ext->Seq) SetSeq((ShpCnt < 2) ? Seq1 : Seq2); + } + return r; +} + + + + + +void SPRITE::MoveShapes (byte far * buf) +{ + BMP_PTR * p; + for (p = Ext->ShpList; *p; p ++) + { + buf += (*p)->MoveVmap(buf); + } +} + + + + + +Boolean SPRITE::Works (SPRITE * spr) +{ + if (spr) if (spr->Ext) + { + SNAIL::COM * c = spr->Ext->Take; + if (c != NULL) + { + c += spr->TakePtr; + if (c->Ref == Ref) + if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) + return TRUE; + } + } + return FALSE; +} + + + + + +SEQ * SPRITE::SetSeq (SEQ * seq) +{ + Expand(); + register SEQ * s = Ext->Seq; + Ext->Seq = seq; + if (SeqPtr == NO_SEQ) Step(0); + else + if (Time == 0) Step(SeqPtr); + return s; +} + + + + + + +Boolean SPRITE::SeqTest (int n) +{ + if (n >= 0) return (SeqPtr == n); + if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); + return TRUE; +} + + + + + + +SNAIL::COM * SPRITE::SnList (SNLIST type) +{ + register SPREXT * e = Ext; + if (e) return (type == NEAR) ? e->Near : e->Take; + return NULL; +} + + + + + + +void SPRITE::SetName (char * n) +{ + if (Ext) + { + if (Ext->Name) + { + delete[] Ext->Name; + Ext->Name = NULL; + } + if (n) + { + if ((Ext->Name = new char[strlen(n)+1]) != NULL) strcpy(Ext->Name, n); + else VGA::Exit("No core", n); + } + } +} + + + + + +SPRITE * SPRITE::Expand (void) +{ + if (! Ext) + { + Boolean enbl = HEART::Enable; + HEART::Enable = FALSE; + if ((Ext = new SPREXT) == NULL) DROP("No core", NULL); + if (*File) + { + static char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; + char line[LINE_MAX], fname[MAXPATH]; + BMP_PTR * shplist = new BMP_PTR [ShpCnt+1]; + SEQ * seq = NULL; + int shpcnt = 0, + seqcnt = 0, + neacnt = 0, + takcnt = 0, + maxnow = 0, + maxnxt = 0, + lcnt = 0, + len; + + SNAIL::COM * nea = NULL; + SNAIL::COM * tak = NULL; + MergeExt(fname, File, SPR_EXT); + if (INI_FILE::Exist(fname)) // sprite description file exist + { + INI_FILE sprf(fname); + if (! OK(sprf)) + { + VGA::Exit("Bad SPR", fname); + } + + while ((len = sprf.Read(line)) != 0) + { + ++ lcnt; + if (len && line[len-1] == '\n') line[-- len] = '\0'; + if (len == 0 || *line == '.') continue; + + switch (TakeEnum(Comd, strtok(line, " =\t"))) + { + case 0 : // Name + SetName(strtok(NULL, "")); break; + case 1 : // Phase + shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); + break; + case 2 : // Seq + seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + if (seq == NULL) + VGA::Exit("No core", fname); + SEQ * s = &seq[seqcnt ++]; + s->Now = atoi(strtok(NULL, " \t,;/")); + if (s->Now > maxnow) maxnow = s->Now; + s->Next = atoi(strtok(NULL, " \t,;/")); + switch (s->Next) + { + case 0xFF : s->Next = seqcnt; break; + case 0xFE : s->Next = seqcnt-1; break; + } + if (s->Next > maxnxt) maxnxt = s->Next; + s->Dx = atoi(strtok(NULL, " \t,;/")); + s->Dy = atoi(strtok(NULL, " \t,;/")); + s->Dly = atoi(strtok(NULL, " \t,;/")); + break; + case 3 : // Near + if (NearPtr != NO_PTR) + { + nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); + if (nea == NULL) VGA::Exit("No core", fname); + else + { + SNAIL::COM * c = &nea[neacnt ++]; + if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + VGA::Exit(NumStr("Bad NEAR in ######", lcnt), fname); + c->Ref = atoi(strtok(NULL, " \t,;/")); + c->Val = atoi(strtok(NULL, " \t,;/")); + c->Ptr = NULL; + } + } + break; + case 4 : // Take + if (TakePtr != NO_PTR) + { + tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); + if (tak == NULL) VGA::Exit("No core", fname); + else + { + SNAIL::COM * c = &tak[takcnt ++]; + if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + VGA::Exit(NumStr("Bad NEAR in ######", lcnt), fname); + c->Ref = atoi(strtok(NULL, " \t,;/")); + c->Val = atoi(strtok(NULL, " \t,;/")); + c->Ptr = NULL; + } + } + break; + } + } + } + else // no sprite description: try to read immediately from .BMP + { + shplist[shpcnt ++] = new BITMAP(File); + } + shplist[shpcnt] = NULL; + if (seq) + { + if (maxnow >= shpcnt) VGA::Exit("Bad PHASE in SEQ", fname); + if (maxnxt >= seqcnt) VGA::Exit("Bad JUMP in SEQ", fname); + SetSeq(seq); + } + else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); + disable(); + + SetShapeList(shplist); + enable(); + if (nea) nea[neacnt-1].Ptr = Ext->Near = nea; else NearPtr = NO_PTR; + if (tak) tak[takcnt-1].Ptr = Ext->Take = tak; else TakePtr = NO_PTR; + } + HEART::Enable = enbl; + } + return this; +} + + + + +SPRITE * SPRITE::Contract (void) +{ + register SPREXT * e = Ext; + if (e) + { + if (e->Name) delete[] e->Name; + if (Flags.BDel && e->ShpList) + { + int i; + for (i = 0; e->ShpList[i]; i ++) delete e->ShpList[i]; + if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; + } + if (MemType(e->Seq) == NEAR_MEM) free(e->Seq); + if (e->Near) free(e->Near); + if (e->Take) free(e->Take); + delete e; + Ext = NULL; + } + return this; +} + + + + + + +SPRITE * SPRITE::BackShow (Boolean fast) +{ + Expand(); + Show(2); + Show(1); + if (fast) Show(0); + Contract(); + return this; +} + + + + + + + + +void SPRITE::Step (int nr) +{ + if (nr >= 0) SeqPtr = nr; + if (Ext) + { + SEQ * seq; + if (nr < 0) SeqPtr = Ext->Seq[SeqPtr].Next; + seq = Ext->Seq + SeqPtr; + if (seq->Dly >= 0) + { + Goto(X + (seq->Dx), Y + (seq->Dy)); + Time = seq->Dly; + } + } +} + + + + + + +void SPRITE::Tick (void) +{ + Step(); +} + + + + + +void SPRITE::MakeXlat (byte far * x) +{ + if (Ext) + { + BMP_PTR * b; + + if (Flags.Xlat) KillXlat(); + for (b = Ext->ShpList; *b; b ++) (*b)->M = x; + Flags.Xlat = TRUE; + } +} + + + + + +void SPRITE::KillXlat (void) +{ + if (Flags.Xlat && Ext) + { + BMP_PTR * b; + byte far * m = (*Ext->ShpList)->M; + + switch (MemType(m)) + { + case NEAR_MEM : delete[] (byte *) m; break; + case FAR_MEM : farfree(m); break; + } + for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; + Flags.Xlat = FALSE; + } +} + + + + + +void SPRITE::Goto (int x, int y) +{ + int xo = X, yo = Y; + if (W < SCR_WID) + { + if (x < 0) x = 0; + if (x + W > SCR_WID) x = (SCR_WID - W); + X = x; + } + if (H < SCR_HIG) + { + if (y < 0) y = 0; + if (y + H > SCR_HIG) y = (SCR_HIG - H); + Y = y; + } + if (Next) if (Next->Flags.Slav) Next->Goto(Next->X-xo+X, Next->Y-yo+Y); + if (Flags.Shad) Prev->Goto(Prev->X-xo+X, Prev->Y-yo+Y); +} + + + + + + + + + + + + +void SPRITE::Center (void) +{ + Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); +} + + + + + + + + +void SPRITE::Show (void) +{ + register SPREXT * e; + asm cli // critic section... + e = Ext; + e->x0 = e->x1; + e->y0 = e->y1; + e->b0 = e->b1; + e->x1 = X; + e->y1 = Y; + e->b1 = Shp(); + asm sti // ...done! + if (! Flags.Hide) + { + if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); + else e->b1->Show(e->x1, e->y1); + } +} + + + + + + + +void SPRITE::Show (word pg) +{ + byte far * a = VGA::Page[1]; + VGA::Page[1] = VGA::Page[pg & 3]; + Shp()->Show(X, Y); + VGA::Page[1] = a; +} + + + + + + + + +void SPRITE::Hide (void) +{ + register SPREXT * e = Ext; + if (e->b0) e->b0->Hide(e->x0, e->y0); +} + + + + +BMP_PTR SPRITE::Ghost (void) +{ + register SPREXT * e = Ext; + if (e->b1) + { + BMP_PTR bmp = new BITMAP(0, 0, (byte far *)NULL); + if (bmp == NULL) VGA::Exit("No core"); + bmp->W = e->b1->W; + bmp->H = e->b1->H; + if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); + bmp->V = (byte far *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + bmp->M = (byte far *) MK_FP(e->y1, e->x1); + return bmp; + } + return NULL; +} + + + + + + +SPRITE * SpriteAt (int x, int y) +{ + SPRITE * spr = NULL, * tail = VGA::ShowQ.Last(); + if (tail) + { + for (spr = tail->Prev; spr; spr = spr->Prev) + if (! spr->Flags.Hide && ! spr->Flags.Tran) + if (spr->Shp()->SolidAt(x-spr->X, y-spr->Y)) + break; + } + return spr; +} + + + + + +//-------------------------------------------------------------------------- + + + + + + +QUEUE::QUEUE (Boolean show) +: Head(NULL), Tail(NULL), Show(show) +{ +} + + + + +QUEUE::~QUEUE (void) +{ + Clear(); +} + + + + +void QUEUE::Clear (void) +{ + while (Head) + { + SPRITE * s = Remove(Head); + if (s->Flags.Kill) delete s; + } +} + + + + +void QUEUE::ForAll (void (*fun)(SPRITE *)) +{ + SPRITE * s = Head; + while (s) + { + SPRITE * n = s->Next; + fun(s); + s = n; + } +} + + + + + +void QUEUE::Append (SPRITE * spr) +{ + if (Tail) + { + spr->Prev = Tail; + Tail->Next = spr; + } + else Head = spr; + Tail = spr; + if (Show) spr->Expand(); + else spr->Contract(); +} + + + + + +void QUEUE::Insert (SPRITE * spr, SPRITE * nxt) +{ + if (nxt == Head) + { + spr->Next = Head; + Head = spr; + if (! Tail) Tail = spr; + } + else + { + spr->Next = nxt; + spr->Prev = nxt->Prev; + if (spr->Prev) spr->Prev->Next = spr; + } + if (spr->Next) spr->Next->Prev = spr; + if (Show) spr->Expand(); + else spr->Contract(); +} + + + + + +void QUEUE::Insert (SPRITE * spr) +{ + SPRITE * s; + for (s = Head; s; s = s->Next) + if (s->Z > spr->Z) + break; + if (s) Insert(spr, s); + else Append(spr); + if (Show) spr->Expand(); + else spr->Contract(); +} + + + + + +SPRITE * QUEUE::Remove (SPRITE * spr) +{ + if (spr == Head) Head = spr->Next; + if (spr == Tail) Tail = spr->Prev; + if (spr->Next) spr->Next->Prev = spr->Prev; + if (spr->Prev) spr->Prev->Next = spr->Next; + spr->Prev = NULL; + spr->Next = NULL; + return spr; +} + + + + + +SPRITE * QUEUE::Locate (int ref) +{ + SPRITE * spr; + for (spr = Head; spr; spr = spr->Next) if (spr->Ref == ref) return spr; + return NULL; +} + + + + + +//-------------------------------------------------------------------------- + + + + +word VGA::StatAdr = VGAST1_; +word VGA::OldMode = 0; +word far * VGA::OldScreen = NULL; +const char * VGA::Msg = NULL; +const char * VGA::Nam = NULL; +DAC far * VGA::OldColors = NULL; +DAC far * VGA::NewColors = NULL; +Boolean VGA::SetPal = FALSE; +int VGA::Mono = 0; +QUEUE VGA::ShowQ = TRUE, VGA::SpareQ = FALSE; +byte far * VGA::Page[4] = { (byte far *) MK_FP(SCR_SEG, 0x0000), + (byte far *) MK_FP(SCR_SEG, 0x4000), + (byte far *) MK_FP(SCR_SEG, 0x8000), + (byte far *) MK_FP(SCR_SEG, 0xC000) }; + + + + +VGA::VGA (int mode) +: FrmCnt(0) +{ + extern const char Copr[]; + Boolean std = TRUE; + int i; + for (i = 10; i < 20; i ++) + { + char * txt = Text[i]; + if (txt) + { + puts(txt); + #ifndef DEBUG + std = FALSE; + #endif + } + } + if (std) puts(Copr); + SetStatAdr(); + if (StatAdr != VGAST1_) ++ Mono; + if (IsVga()) + { + OldColors = farnew(DAC, 256); + NewColors = farnew(DAC, 256); + OldScreen = SaveScreen(); + GetColors(OldColors); + Sunset(); + OldMode = SetMode(mode); + SetColors(); + Setup(VideoMode); + Clear(); + } +} + + + + + +VGA::~VGA (void) +{ + Mono = 0; + if (IsVga()) + { + Clear(); + SetMode(OldMode); + SetColors(); + RestoreScreen(OldScreen); + Sunrise(OldColors); + if (OldColors) farfree(OldColors); + if (NewColors) farfree(NewColors); + if (Msg) fputs(Msg, stderr); + if (Nam) + { + fputs(" [", stderr); + fputs(Nam, stderr); + fputc(']', stderr); + } + if (Msg || Nam) fputc('\n', stderr); + #ifdef REPORT + fputs(Report, stderr); + #endif + } +} + + + + + +void VGA::SetStatAdr (void) +{ + asm mov dx,VGAMIr_ + asm in al,dx + asm test al,1 // CGA addressing mode flag + asm mov ax,VGAST1_ // CGA addressing + asm jnz set_mode_adr + asm xor al,0x60 // MDA addressing + set_mode_adr: + StatAdr = _AX; +} + + + + + + +#pragma argsused +void VGA::WaitVR (Boolean on) +{ + _DX = StatAdr; + _AH = (on) ? 0x00 : 0x08; + + asm mov cx,2 + // wait for vertical retrace on (off) + wait: + asm in al,dx + asm xor al,ah + asm test al,0x08 + asm jnz wait + asm xor ah,0x08 + asm loop wait +} + + + + + + +void VGA::Setup (VgaRegBlk * vrb) +{ + WaitVR(); // *--LOOK!--* resets VGAATR logic + asm cld + asm mov si, vrb // take address of parameter table + asm mov dh,0x03 // higher byte of I/O address is always 3 + + s: + asm lodsw // take lower byte of I/O address and index + asm or ah,ah // 0 = end of table + asm jz xit // no more: exit + asm or al,al // indexed register? + asm js single // 7th bit set means single register + asm mov dl,ah // complete I/O address + asm out dx,al // put index into control register + asm inc dx // data register is next to control + asm in al,dx // take old data + + write: + asm mov cl,al // preserve old data + asm lodsw // take 2 masks from table + asm xor al,0xFF // invert mask bits + asm and al,cl // clear bits with "clr" mask + asm or al,ah // set bits with "set" mask + asm cmp dl,0xC1 // special case? + asm jne std2 // no: standard job, otherwise... + asm dec dx // data out reg shares address with index + std2: + asm out dx,al // write new value to register + asm jmp s + + single: // read address in al, write address in ah + asm mov dl,al // complete I/O read address + asm in al,dx // take old data + asm mov dl,ah // complete I/O write address + asm jmp write // continue standard routine + + xit: +} + + + + + + +int VGA::SetMode (int mode) +{ + Clear(); + // get current mode + asm mov ah,0x0F + Video(); // BIOS video service + asm xor ah,ah + asm push ax + + // wait for v-retrace + WaitVR(); + + // set mode + asm xor ah,ah + asm mov al,byte ptr mode + Video(); // BIOS video service + SetStatAdr(); + // return previous mode + asm pop ax + return _AX; +} + + + + + + +void VGA::GetColors (DAC far * tab) +{ + asm cld + asm les di,tab // color table + asm mov dx,0x3C7 // PEL address read mode register + asm xor al,al // start from address 0 + asm out dx,al // put address + asm mov cx,256*3 // # of colors + asm mov dl,0xC9 // PEL data register + +// asm rep insb // very fast! + + gc: // much slower: + asm in al,dx // take 1 color + asm jmp sto // little delay + sto: + asm stosb // store 1 color + asm loop gc // next one? +} + + + + +void VGA::SetColors (DAC far * tab, int lum) +{ + DAC far * des = NewColors; + asm push ds + + asm les di,des + asm lds si,tab + asm mov cx,256*3 + asm xor bx,bx + asm mov dx,lum + + copcol: + asm mov al,[si+bx] + asm mul dl + asm shr ax,6 + asm mov es:[di+bx],al + asm inc bx + asm cmp bx,cx + asm jb copcol + + asm pop ds + + if (Mono) + { + asm add cx,di + mono: + asm xor dx,dx + asm mov al,77 // 30% R + asm mul byte ptr es:[di].0 + asm add dx,ax + asm mov al,151 // 59% G + asm mul byte ptr es:[di].1 + asm add dx,ax + asm mov al,28 // 11% B + asm mul byte ptr es:[di].2 + asm add dx,ax + + asm mov es:[di].0,dh + asm mov es:[di].1,dh + asm mov es:[di].2,dh + + asm add di,3 + asm cmp di,cx + asm jb mono + } + SetPal = TRUE; +} + + + + + + +void VGA::SetColors (void) +{ + _fmemset(NewColors, 0, PAL_SIZ); + UpdateColors(); +} + + + + + + +void VGA::Sunrise (DAC far * tab) +{ + int i; + for (i = 0; i <= 64; i += FADE_STEP) + { + SetColors(tab, i); + WaitVR(); + UpdateColors(); + } +} + + + + + + +void VGA::Sunset (void) +{ + DAC tab[256]; + int i; + GetColors(tab); + for (i = 64; i >= 0; i -= FADE_STEP) + { + SetColors(tab, i); + WaitVR(); + UpdateColors(); + } +} + + + + + + + + + +void VGA::Show (void) +{ + SPRITE * spr = ShowQ.First(); + + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Show(); + Update(); + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Hide(); + + ++ FrmCnt; +} + + + + +void VGA::UpdateColors (void) +{ + DAC far * tab = NewColors; + + asm push ds + asm cld + asm lds si,tab // color table + asm mov dx,0x3C8 // PEL address write mode register + asm xor al,al // start from address 0 + asm out dx,al // put address + asm mov cx,256*3 // # of colors + asm mov dl,0xC9 // PEL data register + +// asm rep outsb // very fast! + + // the slower version of above: + sc: + asm lodsb // take 1/3 color + asm out dx,al // put 1/3 color + asm jmp loop // little delay + loop: + asm loop sc // next one? + + + asm pop ds +} + + + + + + + +void VGA::Update (void) +{ + byte far * p = Page[1]; + Page[1] = Page[0]; + Page[0] = p; + + asm mov dx,VGACRT_ + asm mov al,0x0D + asm mov ah,byte ptr p + asm out dx,ax + asm dec al + asm mov ah,byte ptr p+1 + asm out dx,ax + + if (! SpeedTest) WaitVR(); + + if (SetPal) + { + UpdateColors(); + SetPal = FALSE; + } +} + + + + + + + + +void VGA::Clear (byte color) +{ + byte far * a = (byte far *) MK_FP(SCR_SEG, 0); + + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // map mask register - enable all planes + asm out dx,ax + asm les di,a + asm cld + + asm mov cx,0xFFFF + asm mov al,color + asm rep stosb + asm stosb +} + + + + + + +void VGA::CopyPage (word d, word s) +{ + byte far * S = Page[s & 3], far * D = Page[d & 3]; + + asm mov dx,VGAGRA_ + asm mov al,0x05 // R/W mode + asm out dx,al + asm inc dx + asm in al,dx + asm and al,0xF4 + asm push ax + asm push dx + asm or al,0x01 + asm out dx,al + + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // map mask register - enable all planes + asm out dx,ax + + asm push ds + + asm les di,D + asm lds si,S + asm cld + asm mov cx,0x4000 + asm rep movsb + + asm pop ds + + asm pop dx + asm pop ax + asm out dx,al // end of copy mode +} + + + + + + + +void VGA::Exit (const char * txt, const char * name) +{ + Msg = txt; + Nam = name; + #ifdef REPORT + wtom(coreleft(), Report + NREP, 10, 5); + dwtom(farcoreleft(), Report + FREP, 10, 6); + #endif + exit(0); +} + + + + +void VGA::Exit (int tref, const char * name) +{ + Exit(Text[tref], name); +} + + + + +//-------------------------------------------------------------------------- + + + + +void BITMAP::XShow (int x, int y) +{ + byte rmsk = x % 4, + mask = 1 << rmsk, + far * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + byte near * m = (char *) M; + byte far * v = V; + + asm push bx + asm push si + asm push ds + + asm cld + asm les di,scr + asm lds si,v + asm mov bx,m + + + + asm mov al,0x02 // map mask register + asm mov ah,mask + + plane: + // enable output plane + asm mov dx,VGASEQ_ + asm out dx,ax + asm push ax + + // select input plane + asm mov dx,VGAGRA_ + asm mov al,0x04 // read map select register + asm mov ah,rmsk + asm out dx,ax + + asm push di + + block: + asm lodsw + asm mov cx,ax + asm and ch,0x3F + asm test ah,0xC0 + asm jz endpl + asm jns skip + asm jnp incsi // replicate? + asm add si,cx // skip over data block + asm dec si // fix it before following inc + + incsi: + asm inc si + tint: + asm mov al,es:[di] + //----------------------------------------------- + // asm xlat ss:0 // unsupported with BASM! + __emit__(0x36, 0xD7); // this stands for above! + //----------------------------------------------- + asm stosb + asm loop tint + asm jmp block + + skip: + asm add di,cx + asm jmp block + + endpl: + asm pop di + asm pop ax + asm inc rmsk + asm shl ah,1 + asm test ah,0x10 + asm jz x_chk + asm mov ah,0x01 + asm mov rmsk,0 + asm inc di + x_chk: + asm cmp ah,mask + asm jne plane + asm pop ds + asm pop si + asm pop bx +} + + + + + + +void BITMAP::Show (int x, int y) +{ + byte mask = 1 << (x & 3), + far * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); + byte far * v = V; + + asm push ds // preserve DS + + asm cld // normal direction + asm les di,scr // screen address + asm lds si,v // picture address + asm mov dx,VGASEQ_ // VGA reg + asm mov al,0x02 + asm mov ah,mask + + plane: + asm out dx,ax + asm push ax + asm push di + + block: + asm mov cx,[si] // with ADD faster then LODSW + asm add si,2 + asm test ch,0xC0 + asm jns skip // 1 (SKP) or 0 (EOI) + asm jpo repeat // 2 (REP) + + copy: // 3 (CPY) + asm and ch,0x3F + asm shr cx,1 + asm rep movsw + asm jnc block + asm movsb + asm jmp block + + repeat: + asm and ch,0x3F + asm mov al,[si] + asm inc si + asm mov ah,al + asm shr cx,1 + asm rep stosw + asm jnc block + asm mov es:[di],al + asm inc di + asm jmp block + + skip: + asm jz endpl + asm and ch,0x3F + asm add di,cx + asm jmp block + + endpl: + asm pop di + asm pop ax + asm shl ah,1 + asm test ah,0x10 + asm jz x_chk + asm mov ah,0x01 + asm inc di + x_chk: + asm cmp ah,mask + asm jne plane + asm pop ds +} + + + + + +void BITMAP::Hide (int x, int y) +{ + byte far * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + word d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); + HideDesc far * b = B; + word extra = ((x & 3) != 0); + word h = H; + +// asm push bx + asm push si + asm push ds + + asm cld + asm les di,scr + asm mov si,di + asm add si,d // take bytes from background page + asm lds bx,b + + asm mov dx,VGAGRA_ + asm mov al,0x05 // R/W mode + asm out dx,al + asm inc dx + asm in al,dx + asm and al,0xF4 + asm push ax + asm push dx + asm or al,0x01 + asm out dx,al + + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // enable all planes + asm out dx,ax + + asm mov dx,ds // save DS + + row: +// skip block + asm mov cx,[bx] + asm add si,cx + asm add di,cx + asm mov cx,[bx+2] + asm add bx,4 + asm add cx,extra + + asm push es + asm pop ds // set DS to video seg + asm rep movsb // move bytes fast + asm sub si,extra + asm sub di,extra + asm mov ds,dx // restore DS + + asm dec h + asm jnz row + + asm pop dx + asm pop ax + asm out dx,al // end of copy mode + + + asm pop ds + asm pop si +// asm pop bx +} + + + + + + + +//-------------------------------------------------------------------------- + + + diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h new file mode 100644 index 0000000000..f3c17fa73e --- /dev/null +++ b/engines/cge/vga13h.h @@ -0,0 +1,310 @@ +#ifndef __VGA13H__ +#define __VGA13H__ + +#include +#include +#include +#include "bitmap.h" +#include "snail.h" + + +#define TMR_RATE1 16 +#define TMR_RATE2 4 +#define TMR_RATE (TMR_RATE1*TMR_RATE2) + +#define MAX_NAME 20 +#define VIDEO 0x10 + +#define NO_CLEAR 0x80 +#define TEXT_MODE 0x03 +#define M13H 0x13 + +#ifndef SCR_WID + #define SCR_WID 320 +#endif + +#ifndef SCR_HIG + #define SCR_HIG 200 +#endif + + +#if 0 + #define LIGHT 0xFF + #define DARK 0x00 + #define DGRAY 0xF6 + #define GRAY 0xFC + #define LGRAY 0xFF +#else + #define LIGHT 0xFF + #define DARK 207 + #define DGRAY 225 /*219*/ + #define GRAY 231 + #define LGRAY 237 +#endif + +#define NO_SEQ (-1) +#define NO_PTR ((byte)-1) + +#define SPR_EXT ".SPR" + +#define IsFile(s) (access(s,0)==0) +#define IsWrit(s) (access(s,2)==0) + + + +typedef struct { word r : 2; word R : 6; + word g : 2; word G : 6; + word b : 2; word B : 6; + } RGB; + +typedef union { + DAC dac; + RGB rgb; + } TRGB; + +typedef struct { byte idx, adr; byte clr, set; } VgaRegBlk; + +typedef struct { byte Now, Next; signed char Dx, Dy; int Dly; } SEQ; + +extern SEQ Seq1[]; +extern SEQ Seq2[]; +//extern SEQ * Compass[]; +//extern SEQ TurnToS[]; + + +#define PAL_CNT 256 +#define PAL_SIZ (PAL_CNT*sizeof(DAC)) + +#define VGAATR_ 0x3C0 +#define VGAMIw_ 0x3C0 +#define VGASEQ_ 0x3C4 +#define VGAMIr_ 0x3CC +#define VGAGRA_ 0x3CE +#define VGACRT_ 0x3D4 +#define VGAST1_ 0x3DA +#define VGAATR (VGAATR_ & 0xFF) +#define VGAMIw (VGAMIw_ & 0xFF) +#define VGASEQ (VGASEQ_ & 0xFF) +#define VGAMIr (VGAMIr_ & 0xFF) +#define VGAGRA (VGAGRA_ & 0xFF) +#define VGACRT (VGACRT_ & 0xFF) +#define VGAST1 (VGAST1_ & 0xFF) + + + + + + +class HEART : public ENGINE +{ + friend ENGINE; +public: + static Boolean Enable; + static word * XTimer; + static void SetXTimer (word * ptr); + static void SetXTimer (word * ptr, word time); + HEART (void); +}; + + + + + +class SPREXT +{ +public: + int x0, y0; + int x1, y1; + BMP_PTR b0, b1; + BMP_PTR * ShpList; + SEQ * Seq; + char * Name; + SNAIL::COM * Near, * Take; + SPREXT (void) : + x0(0), y0(0), + x1(0), y1(0), + b0(NULL), b1(NULL), + ShpList(NULL), Seq(NULL), + Name(NULL), Near(NULL), Take(NULL) + {} +}; + + + + +class SPRITE +{ +protected: + SPREXT * Ext; +public: + int Ref; + signed char Cave; + struct FLAGS { word Hide : 1; // general visibility switch + word Near : 1; // Near action lock + word Drag : 1; // sprite is moveable + word Hold : 1; // sprite is held with mouse + word ____ : 1; // intrrupt driven animation + word Slav : 1; // slave object + word Syst : 1; // system object + word Kill : 1; // dispose memory after remove + word Xlat : 1; // 2nd way display: xlat table + word Port : 1; // portable + word Kept : 1; // kept in pocket + word East : 1; // talk to east (in opposite to west) + word Shad : 1; // shadow + word Back : 1; // 'send to background' request + word BDel : 1; // delete bitmaps in ~SPRITE + word Tran : 1; // transparent (untouchable) + } Flags; + int X, Y; + signed char Z; + word W, H; + word Time; + byte NearPtr, TakePtr; + int SeqPtr; + int ShpCnt; + char File[MAXFILE]; + SPRITE * Prev, * Next; + Boolean Works (SPRITE * spr); + Boolean SeqTest (int n); + inline Boolean Active (void) { return Ext != NULL; } + SPRITE (BMP_PTR * shp); + virtual ~SPRITE (void); + BMP_PTR Shp (void); + BMP_PTR * SetShapeList (BMP_PTR * shp); + void MoveShapes (byte far * buf); + SPRITE * Expand (void); + SPRITE * Contract (void); + SPRITE * BackShow (Boolean fast = FALSE); + void SetName(char * n); + inline char * Name(void) { return (Ext) ? Ext->Name : NULL; } + void Goto (int x, int y); + void Center (void); + void Show (void); + void Hide (void); + BMP_PTR Ghost (void); + void Show (word pg); + void MakeXlat (byte far * x); + void KillXlat (void); + void Step (int nr = -1); + SEQ * SetSeq (SEQ * seq); + SNAIL::COM * SnList(SNLIST type); + virtual void Touch (word mask, int x, int y); + virtual void Tick (void); +}; + + + + + + +class QUEUE +{ + SPRITE * Head, * Tail; +public: + Boolean Show; + QUEUE (Boolean show = FALSE); + ~QUEUE (void); + void Append (SPRITE * spr); + void Insert (SPRITE * spr, SPRITE * nxt); + void Insert (SPRITE * spr); + SPRITE * Remove (SPRITE * spr); + void ForAll (void (*fun)(SPRITE *)); + SPRITE * First (void) { return Head; } + SPRITE * Last (void) { return Tail; } + SPRITE * Locate (int ref); + void Clear (void); +}; + + + + + + +class VGA +{ + static word OldMode; + static word far * OldScreen; + static word StatAdr; + static Boolean SetPal; + static DAC far * OldColors, far * NewColors; + static int SetMode (int mode); + static void UpdateColors (void); + static void SetColors (void); + static const char * Msg; + static const char * Nam; + static void SetStatAdr (void); + static void WaitVR (Boolean on = TRUE); +public: + dword FrmCnt; + static QUEUE ShowQ, SpareQ; + static int Mono; + static byte far * Page[4]; + VGA (int mode = M13H); + ~VGA (void); + void Setup (VgaRegBlk * vrb); + static void GetColors (DAC far * tab); + static void SetColors (DAC far * tab, int lum); + static void Clear (byte color = 0); + static void Exit (const char * txt = NULL, const char * name = NULL); + static void Exit (int tref, const char * name = NULL); + static void CopyPage (word d, word s = 3); + static void Sunrise (DAC far * tab); + static void Sunset (void); + void Show (void); + void Update (void); +}; + + + +DAC MkDAC (byte r, byte g, byte b); +RGB MkRGB (byte r, byte g, byte b); + + + + +template +byte Closest (CBLK far * pal, CBLK x) +{ + #define f(col,lum) ((((word)(col))<<8)/lum) + word i, dif = 0xFFFF, found; + word L = x.R + x.G + x.B; if (! L) ++ L; + word R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); + for (i = 0; i < 256; i ++) + { + word l = pal[i].R + pal[i].G + pal[i].B; if (! l) ++ l; + int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l); + word D = ((r > R) ? (r - R) : (R - r)) + + ((g > G) ? (g - G) : (G - g)) + + ((b > B) ? (b - B) : (B - b)) + + ((l > L) ? (l - L) : (L - l)) * 10 ; + + if (D < dif) + { + found = i; + dif = D; + if (D == 0) break; // exact! + } + } + return found; + #undef f +}; + + + + + + + + char * NumStr (char * str, int num); + void Video (void); + word far * SaveScreen (void); + void RestoreScreen (word far * &sav); + SPRITE * SpriteAt (int x, int y); + SPRITE * Locate (int ref); + +extern Boolean SpeedTest; + + +#endif + \ No newline at end of file diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp new file mode 100644 index 0000000000..5dd3efb191 --- /dev/null +++ b/engines/cge/vmenu.cpp @@ -0,0 +1,149 @@ +#include "vmenu.h" +#include "mouse.h" +#include +#include + +//-------------------------------------------------------------------------- + + +#define RELIEF 1 +#if RELIEF + #define MB_LT LGRAY + #define MB_RB DGRAY +#else + #define MB_LT DGRAY + #define MB_RB LGRAY +#endif + + + + +MENU_BAR::MENU_BAR (word w) +{ + int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; + byte far * p = farnew(byte, i), far * p1, far * p2; + + _fmemset(p+w, TRANS, i-2*w); + _fmemset(p, MB_LT, w); + _fmemset(p+i-w, MB_RB, w); + p1 = p; + p2 = p+i-1; + for (i = 0; i < h; i ++) + { + * p1 = MB_LT; + * p2 = MB_RB; + p1 += w; + p2 -= w; + } + TS[0] = new BITMAP(w, h, p); + SetShapeList(TS); + Flags.Slav = TRUE; + Flags.Tran = TRUE; + Flags.Kill = TRUE; + Flags.BDel = TRUE; +} + + + +//-------------------------------------------------------------------------- + +static char * vmgt; + + + +char * VMGather (CHOICE * list) +{ + CHOICE * cp; + int len = 0, h = 0; + + for (cp = list; cp->Text; cp ++) + { + len += strlen(cp->Text); + ++ h; + } + vmgt = new byte[len+h]; + if (vmgt) + { + *vmgt = '\0'; + for (cp = list; cp->Text; cp ++) + { + if (*vmgt) strcat(vmgt, "|"); + strcat(vmgt, cp->Text); + ++ h; + } + } + return vmgt; +} + + + + +VMENU * VMENU::Addr = NULL; +int VMENU::Recent = -1; + + + + +VMENU::VMENU (CHOICE * list, int x, int y) +: TALK(VMGather(list), RECT), Menu(list), Bar(NULL) +{ + CHOICE * cp; + + Addr = this; + delete[] vmgt; + Items = 0; + for (cp = list; cp->Text; cp ++) ++ Items; + Flags.BDel = TRUE; + Flags.Kill = TRUE; + if (x < 0 || y < 0) Center(); + else Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); + VGA::ShowQ.Insert(this, VGA::ShowQ.Last()); + Bar = new MENU_BAR(W - 2 * TEXT_HM); + Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM); + VGA::ShowQ.Insert(Bar, VGA::ShowQ.Last()); +} + + + + +VMENU::~VMENU (void) +{ + Addr = NULL; +} + + + + +void VMENU::Touch (word mask, int x, int y) +{ +#define h (FONT_HIG+TEXT_LS) + int n = 0; + Boolean ok = FALSE; + + if (Items) + { + SPRITE::Touch(mask, x, y); + + y -= TEXT_VM-1; + //if + if (y >= 0) + { + n = y / h; + if (n < Items) ok = (x >= TEXT_HM && x < W - TEXT_HM/* && y % h < FONT_HIG*/); + else n = Items-1; + } + + Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM + n * h - MB_VM); + + if (ok && (mask & L_UP)) + { + Items = 0; + SNPOST_(SNKILL, -1, 0, this); + Menu[Recent = n].Proc(); + } + } +#undef h +} + + + diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h new file mode 100644 index 0000000000..c4d3a8df18 --- /dev/null +++ b/engines/cge/vmenu.h @@ -0,0 +1,45 @@ +#ifndef __VMENU__ +#define __VMENU__ + +#include "talk.h" + +#define MB_VM 1 +#define MB_HM 3 + + + +typedef struct { char * Text; void (* Proc)(void); } CHOICE; + + + + + + +class MENU_BAR : public TALK +{ +public: + MENU_BAR (word w); +}; + + + + + + + +class VMENU : public TALK +{ + word Items; + CHOICE * Menu; +public: + static VMENU * Addr; + static int Recent; + MENU_BAR * Bar; + VMENU (CHOICE * list, int x, int y); + ~VMENU (void); + void Touch (word mask, int x, int y); +}; + + + +#endif diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp new file mode 100644 index 0000000000..d0d8dce35c --- /dev/null +++ b/engines/cge/vol.cpp @@ -0,0 +1,79 @@ +#include "vol.h" +#include +#include +#include +#include + +#ifdef DROP_H + #include "drop.h" +#else + #include + #define DROP(m,n) { printf("%s [%s]\n", (m), (n)); _exit(1); } +#endif + + + + +#ifdef VOL_UPD +BTFILE VFILE::Cat(CAT_NAME, UPD, CRP); +VOLBASE DAT::File(DAT_NAME, UPD, CRP); +#else +BTFILE VFILE::Cat(CAT_NAME, REA, CRP); +VOLBASE DAT::File(DAT_NAME, REA, CRP); +#endif +DAT VFILE::Dat; +VFILE * VFILE::Recent = NULL; + + + + + +VFILE::VFILE (const char * name, IOMODE mode) +: IOBUF(mode) +{ + if (mode == REA) + { + if (Dat.File.Error || Cat.Error) DROP("Bad volume data", NULL); + BT_KEYPACK far * kp = Cat.Find(name); + if (_fstricmp(kp->Key, name) != 0) Error = ENOFILE; + EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; + } + #ifdef VOL_UPD + else Make(name); + #endif +} + + + + + +VFILE::~VFILE (void) +{ + if (Recent == this) Recent = NULL; +} + + + + + +Boolean VFILE::Exist (const char * name) +{ + return _fstricmp(Cat.Find(name)->Key, name) == 0; +} + + + + +void VFILE::ReadBuff (void) +{ + if (Recent != this) + { + Dat.File.Seek(BufMark + Lim); + Recent = this; + } + BufMark = Dat.File.Mark(); + long n = EndMark - BufMark; + if (n > IOBUF_SIZE) n = IOBUF_SIZE; + Lim = Dat.File.Read(Buff, (word) n); + Ptr = 0; +} diff --git a/engines/cge/vol.h b/engines/cge/vol.h new file mode 100644 index 0000000000..347b0b48fe --- /dev/null +++ b/engines/cge/vol.h @@ -0,0 +1,64 @@ +#ifndef __VOL__ +#define __VOL__ + + +#include +#include "btfile.h" +#include "cfile.h" + +#define CAT_NAME "VOL.CAT" +#define DAT_NAME "VOL.DAT" + +#ifndef CRP + #define CRP XCrypt +#endif + +#define XMASK 0xA5 + +#ifdef VOL_UPD +#define VOLBASE IOHAND +#else +#define VOLBASE CFILE +#endif + + + +class DAT +{ + friend VFILE; + static VOLBASE File; +public: + static Boolean Append (byte far * buf, word len); + static Boolean Write (CFILE& f); + static Boolean Read (long org, word len, byte far * buf); +}; + + + + + + + +class VFILE : public IOBUF +{ + static DAT Dat; + static BTFILE Cat; + static VFILE * Recent; + long BegMark, EndMark; + void ReadBuff (void); + void WriteBuff (void) { } + void Make(const char * fspec); +public: + VFILE (const char * name, IOMODE mode = REA); + ~VFILE (void); + static Boolean Exist (const char * name); + static const char * Next (void); + long Mark (void) { return (BufMark+Ptr) - BegMark; } + long Size (void) { return EndMark - BegMark; } + long Seek (long pos) { Recent = NULL; Lim = 0; return (BufMark = BegMark+pos); } +}; + + + + +#endif diff --git a/engines/cge/wav.h b/engines/cge/wav.h new file mode 100644 index 0000000000..c32178420c --- /dev/null +++ b/engines/cge/wav.h @@ -0,0 +1,109 @@ +#ifndef __WAV__ +#define __WAV__ + +#include +#include + +#define WAVE_FORMAT_PCM 0x0001 +#define IBM_FORMAT_MULAW 0x0101 +#define IBM_FORMAT_ALAW 0x0102 +#define IBM_FORMAT_ADPCM 0x0103 + + + +typedef char FOURCC[4]; // Four-character code +typedef dword CKSIZE; // 32-bit unsigned size + + +class CKID // Chunk type identifier +{ + union { FOURCC Tx; dword Id; }; +protected: + static XFILE * ckFile; +public: + CKID (FOURCC t) { memcpy(Tx, t, sizeof(Tx)); } + CKID (dword d) { Id = d; } + CKID (XFILE * xf) { (ckFile = xf)->Read(Tx, sizeof(Tx)); } + Boolean operator !=(CKID& X) { return Id != X.Id; } + Boolean operator ==(CKID& X) { return Id == X.Id; } + const char * Name (void); +}; + + + + +class CKHEA : public CKID +{ +protected: + CKSIZE ckSize; // Chunk size field (size of ckData) +public: + CKHEA (XFILE * xf) : CKID(xf) { XRead(xf, &ckSize); } + CKHEA (char id[]) : CKID(id), ckSize(0) { } + void Skip (void); + CKSIZE Size (void) { return ckSize; } +}; + + + + + +class FMTCK : public CKHEA +{ + struct WAV + { + word wFormatTag; // Format category + word wChannels; // Number of channels + dword dwSamplesPerSec; // Sampling rate + dword dwAvgBytesPerSec; // For buffer estimation + word wBlockAlign; // Data block size + } Wav; + + union + { + struct PCM + { + word wBitsPerSample; // Sample size + } Pcm; + }; +public: + FMTCK (CKHEA& hea); + inline word Channels (void) { return Wav.wChannels; } + inline dword SmplRate (void) { return Wav.dwSamplesPerSec; } + inline dword ByteRate (void) { return Wav.dwAvgBytesPerSec; } + inline word BlckSize (void) { return Wav.wBlockAlign; } + inline word SmplSize (void) { return Pcm.wBitsPerSample; } +}; + + + + + +class DATACK : public CKHEA +{ + Boolean e; + union + { + byte far * Buf; + EMS * EBuf; + }; +public: + DATACK (CKHEA& hea); + DATACK (CKHEA& hea, EMM * emm); + DATACK (int first, int last); + ~DATACK (void); + inline byte far * Addr (void) { return Buf; } + inline EMS * EAddr (void) { return EBuf; } +}; + + + +extern CKID RIFF; +extern CKID WAVE; +extern CKID FMT; +extern CKID DATA; + + +DATACK * LoadWave (XFILE * file, EMM * emm = NULL); + + +#endif -- cgit v1.2.3 From 03c540abffe39a7ea32173c2cf8f5e70d371588b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 07:45:18 +0200 Subject: CGE: Add default header, fix some includes --- engines/cge/bitmap.cpp | 35 +++++++++++++++++++++++--- engines/cge/bitmap.h | 29 ++++++++++++++++++++- engines/cge/bitmaps.cpp | 29 ++++++++++++++++++++- engines/cge/bitmaps.h | 29 ++++++++++++++++++++- engines/cge/boot.h | 29 ++++++++++++++++++++- engines/cge/cfile.cpp | 29 ++++++++++++++++++++- engines/cge/cfile.h | 29 ++++++++++++++++++++- engines/cge/cge_main.cpp | 65 ++++++++++++++++++++++++++++++++++-------------- engines/cge/cge_main.h | 27 ++++++++++++++++++++ engines/cge/drop.h | 29 ++++++++++++++++++++- engines/cge/game.cpp | 31 +++++++++++++++++++++-- engines/cge/game.h | 31 +++++++++++++++++++++-- engines/cge/general.h | 37 +++++++++++++++++++++++---- engines/cge/gettext.cpp | 33 +++++++++++++++++++++--- engines/cge/gettext.h | 31 +++++++++++++++++++++-- engines/cge/ident.h | 27 ++++++++++++++++++++ engines/cge/jbw.h | 29 ++++++++++++++++++++- engines/cge/keybd.cpp | 31 +++++++++++++++++++++-- engines/cge/keybd.h | 31 +++++++++++++++++++++-- engines/cge/mixer.cpp | 35 +++++++++++++++++++++++--- engines/cge/mixer.h | 29 ++++++++++++++++++++- engines/cge/mouse.cpp | 31 +++++++++++++++++++++-- engines/cge/mouse.h | 31 +++++++++++++++++++++-- engines/cge/snail.cpp | 45 ++++++++++++++++++++++++++------- engines/cge/snail.h | 29 ++++++++++++++++++++- engines/cge/snddrv.h | 27 ++++++++++++++++++++ engines/cge/sound.cpp | 41 ++++++++++++++++++++++++------ engines/cge/sound.h | 31 +++++++++++++++++++++-- engines/cge/startup.cpp | 39 ++++++++++++++++++++++++----- engines/cge/startup.h | 29 ++++++++++++++++++++- engines/cge/talk.cpp | 37 +++++++++++++++++++++++---- engines/cge/talk.h | 29 ++++++++++++++++++++- engines/cge/text.cpp | 41 ++++++++++++++++++++++++------ engines/cge/text.h | 31 +++++++++++++++++++++-- engines/cge/vga13h.cpp | 37 +++++++++++++++++++++++---- engines/cge/vga13h.h | 33 +++++++++++++++++++++--- engines/cge/vmenu.cpp | 31 +++++++++++++++++++++-- engines/cge/vmenu.h | 29 ++++++++++++++++++++- engines/cge/vol.cpp | 31 +++++++++++++++++++++-- engines/cge/vol.h | 31 +++++++++++++++++++++-- engines/cge/wav.h | 29 ++++++++++++++++++++- 41 files changed, 1222 insertions(+), 115 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index f3a7f85331..d493f29f56 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -1,12 +1,39 @@ -#include "bitmap.h" -#include +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/bitmap.h" +#include "cge/cfile.h" #ifdef VOL - #include "vol.h" + #include "cge/vol.h" #endif #ifdef DROP_H - #include "drop.h" + #include "cge/drop.h" #endif diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 10d85430dc..a6a3dc7539 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __BITMAP__ #define __BITMAP__ -#include +#include "cge/general.h" #define EOI 0x0000 #define SKP 0x4000 diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp index 2f79599c87..4749430c5b 100644 --- a/engines/cge/bitmaps.cpp +++ b/engines/cge/bitmaps.cpp @@ -1,4 +1,31 @@ -#include "bitmaps.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/bitmaps.h" /* #define W 255, diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h index ef02c034e1..65f586a355 100644 --- a/engines/cge/bitmaps.h +++ b/engines/cge/bitmaps.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __BITMAPS__ #define __BITMAPS__ -#include "vga13h.h" +#include "cge/vga13h.h" #ifdef DEBUG extern BITMAP * MB[]; diff --git a/engines/cge/boot.h b/engines/cge/boot.h index 18c7cd2499..6b9b2c88ec 100644 --- a/engines/cge/boot.h +++ b/engines/cge/boot.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __BOOT__ #define __BOOT__ -#include +#include "cge/jbw.h" #define BOOTSECT_SIZ 512 #define BOOTHEAD_SIZ 62 diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 53b845b89f..03df303245 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -1,3 +1,30 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #include #include #include @@ -5,7 +32,7 @@ #include #ifdef DROP_H - #include "drop.h" + #include "cge/drop.h" #else #include #include diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 57ff38831c..56a249d9c0 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __CFILE__ #define __CFILE__ -#include +#include "cge/general.h" #include diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 23865ec386..bc19156ad5 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1,22 +1,49 @@ -#include "cge\general.h" -#include "cge\boot.h" -#include "cge\ident.h" -#include "cge\sound.h" -#include "cge\startup.h" -#include "cge\config.h" -#include "cge\vga13h.h" -#include "cge\snail.h" -#include "cge\text.h" -#include "cge\game.h" -#include "cge\mouse.h" -#include "cge\keybd.h" -#include "cge\cfile.h" -#include "cge\vol.h" -#include "cge\talk.h" -#include "cge\vmenu.h" -#include "cge\gettext.h" -#include "cge\mixer.h" -#include "cge\cge_main.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" +#include "cge/boot.h" +#include "cge/ident.h" +#include "cge/sound.h" +#include "cge/startup.h" +#include "cge/config.h" +#include "cge/vga13h.h" +#include "cge/snail.h" +#include "cge/text.h" +#include "cge/game.h" +#include "cge/mouse.h" +#include "cge/keybd.h" +#include "cge/cfile.h" +#include "cge/vol.h" +#include "cge/talk.h" +#include "cge/vmenu.h" +#include "cge/gettext.h" +#include "cge/mixer.h" +#include "cge/cge_main.h" #include #include #include diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index f5c104600a..7a213429b1 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -1,3 +1,30 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __CGE__ #define __CGE__ diff --git a/engines/cge/drop.h b/engines/cge/drop.h index e79b2eb899..bdd08b6810 100644 --- a/engines/cge/drop.h +++ b/engines/cge/drop.h @@ -1 +1,28 @@ -#include "vga13h.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/vga13h.h" diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 4ac27651b7..bf7bd850f5 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -1,5 +1,32 @@ -#include "game.h" -#include "mouse.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/game.h" +#include "cge/mouse.h" #include #include diff --git a/engines/cge/game.h b/engines/cge/game.h index 92ad49b2a4..e675d15a7c 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -1,8 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __GAME__ #define __GAME__ -#include "vga13h.h" -#include "bitmaps.h" +#include "cge/vga13h.h" +#include "cge/bitmaps.h" diff --git a/engines/cge/general.h b/engines/cge/general.h index 7e9551e076..71d9d96bdf 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -1,3 +1,30 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __GENERAL__ #define __GENERAL__ @@ -24,7 +51,7 @@ typedef struct { byte R, G, B; } DAC; -typedef word CRYPT (void far * buf, word siz, word seed); +typedef word CRYPT (void *buf, word siz, word seed); @@ -206,7 +233,7 @@ CRYPT XCrypt; CRYPT RXCrypt; CRYPT RCrypt; -MEM_TYPE MemType (void far * mem); +MEM_TYPE MemType (void *mem); unsigned FastRand (void); unsigned FastRand (unsigned s); CPU Cpu (void); @@ -220,7 +247,7 @@ void StdLog (const char *msg, const char *nam = NULL); void StdLog (const char *msg, word w); void StdLog (const char *msg, dword d); int TakeEnum (const char ** tab, const char * txt); -word ChkSum (void far * m, word n); +word ChkSum (void *m, word n); long Timer (void); long TimerLimit (word t); Boolean TimerLimitGone (long t); @@ -233,8 +260,8 @@ int DriveRemote (unsigned drv); int DriveCD (unsigned drv); Boolean IsVga (void); -EC void _fqsort (void far *base, word nelem, word width, - int (*fcmp)(const void far *, const void far *)); +EC void _fqsort (void *base, word nelem, word width, + int (*fcmp)(const void*, const void*)); diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 69350b5fc8..5d6c8ce1bf 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -1,6 +1,33 @@ -#include "gettext.h" -#include "keybd.h" -#include "mouse.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/gettext.h" +#include "cge/keybd.h" +#include "cge/mouse.h" #include diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index 8d4e15c6cb..2fbd6f5da6 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -1,8 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __GETTEXT__ #define __GETTEXT__ -#include -#include "talk.h" +#include "cge/general.h" +#include "cge/talk.h" #define GTMAX 24 diff --git a/engines/cge/ident.h b/engines/cge/ident.h index 5370b9638c..fa3011b49c 100644 --- a/engines/cge/ident.h +++ b/engines/cge/ident.h @@ -1,3 +1,30 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __IDENT__ #define __IDENT__ diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 98ce9e27b5..cb2cb54fec 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -1,3 +1,30 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __JBW__ #define __JBW__ @@ -34,7 +61,7 @@ typedef int Boolean; typedef unsigned char byte; typedef unsigned int word; typedef unsigned long dword; -typedef void (far _loadds MouseFunType)(void); +typedef void (_loadds MouseFunType)(void); #define Lo(d) (((int *) &d)[0]) #define Hi(d) (((int *) &d)[1]) diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index 9986ad0b5d..37a1e1d798 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -1,5 +1,32 @@ -#include "keybd.h" -#include "mouse.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/keybd.h" +#include "cge/mouse.h" #include diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h index 744dc8c8ac..42c80f88e1 100644 --- a/engines/cge/keybd.h +++ b/engines/cge/keybd.h @@ -1,8 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __KEYBD__ #define __KEYBD__ -#include -#include "vga13h.h" +#include "cge/jbw.h" +#include "cge/vga13h.h" #define KEYBD_INT 9 diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 7a494d0b90..1e7aa7a181 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -1,7 +1,34 @@ -#include "mixer.h" -#include "text.h" -#include "snail.h" -#include "mouse.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/mixer.h" +#include "cge/text.h" +#include "cge/snail.h" +#include "cge/mouse.h" #include #include #include diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index 8ee2bb6f80..bf5d79b67f 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __MIXER__ #define __MIXER__ -#include "vga13h.h" +#include "cge/vga13h.h" #define MIX_MAX 16 // count of Leds #define MIX_Z 64 // mixer Z position diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 703fd80f65..b9a0386801 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -1,5 +1,32 @@ -#include "mouse.h" -#include "text.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/mouse.h" +#include "cge/text.h" #include diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index 9f51456baf..f3b83f3f2e 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -1,8 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __MOUSE__ #define __MOUSE__ -#include "game.h" -#include "talk.h" +#include "cge/game.h" +#include "cge/talk.h" #define EVT_MAX 256 diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index d6b2528310..82f9416af7 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -1,18 +1,45 @@ -#include -#include "sound.h" -#include "snail.h" -#include "vga13h.h" -#include "bitmaps.h" -#include "text.h" -#include "mouse.h" -#include "cge.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" +#include "cge/sound.h" +#include "cge/snail.h" +#include "cge/vga13h.h" +#include "cge/bitmaps.h" +#include "cge/text.h" +#include "cge/mouse.h" +#include "cge/cge_main.h" #include #include #include #include #include -#include "keybd.h" +#include "cge/keybd.h" int MaxCave = 0; diff --git a/engines/cge/snail.h b/engines/cge/snail.h index f1b0ab762f..66a40e8382 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __SNAIL__ #define __SNAIL__ -#include +#include "cge/jbw.h" #define POCKET_X 174 #define POCKET_Y 176 diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 69ea3c2b15..910148c71e 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -1,3 +1,30 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + // ****************************************************** // * Sound Driver by Hedges (c) 1995 LK AVALON * // * Ver 1.00: 01-Mar-95 * diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index f4fc27ddd7..cd0101204d 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -1,18 +1,45 @@ -#include -#include "startup.h" -#include "sound.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" +#include "cge/startup.h" +#include "cge/sound.h" #ifdef DROP_H - #include "drop.h" + #include "cge/drop.h" #else #include #include #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } #endif -#include "text.h" -#include -#include "vol.h" +#include "cge/text.h" +#include "cge/cfile.h" +#include "cge/vol.h" #include diff --git a/engines/cge/sound.h b/engines/cge/sound.h index b4efd99808..b43a85dd41 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -1,8 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __SOUND__ #define __SOUND__ -#include -#include +#include "cge/wav.h" +#include "cge/snddrv.h" #define BAD_SND_TEXT 97 diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 3557891a03..a92e899ee2 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -1,9 +1,36 @@ -#include "startup.h" -#include "text.h" -#include "sound.h" -#include "ident.h" -#include -#include +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/startup.h" +#include "cge/text.h" +#include "cge/sound.h" +#include "cge/ident.h" +#include "cge/cfile.h" +#include "cge/snddrv.h" #include #include #include diff --git a/engines/cge/startup.h b/engines/cge/startup.h index 6db566a781..bdb2647ab1 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -1,8 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __STARTUP__ #define __STARTUP__ -#include +#include "cge/general.h" #define GAME_ID 45 #define CDINI_FNAME 46 diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index a018761000..3a4ea5bbc2 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -1,8 +1,35 @@ -#include -#include "talk.h" -#include "vol.h" -#include "game.h" -#include "mouse.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" +#include "cge/talk.h" +#include "cge/vol.h" +#include "cge/game.h" +#include "cge/mouse.h" #include #include #include diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 12b0b94dde..8129b01bd9 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __TALK__ #define __TALK__ -#include "vga13h.h" +#include "cge/vga13h.h" #include diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index a18eec5baf..b4b6e9b23c 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -1,10 +1,37 @@ -#include -#include "text.h" -#include "talk.h" -#include "vol.h" -#include "bitmaps.h" -#include "game.h" -#include "snail.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" +#include "cge/text.h" +#include "cge/talk.h" +#include "cge/vol.h" +#include "cge/bitmaps.h" +#include "cge/game.h" +#include "cge/snail.h" #include #include #include diff --git a/engines/cge/text.h b/engines/cge/text.h index d960fbef91..c6e6a1491e 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -1,8 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __TEXT__ #define __TEXT__ -#include "talk.h" -#include +#include "cge/talk.h" +#include "cge/jbw.h" #include diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 227304668b..404b4f8bf8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1,8 +1,35 @@ -#include -#include "vga13h.h" -#include "bitmap.h" -#include "vol.h" -#include "text.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" +#include "cge/vga13h.h" +#include "cge/bitmap.h" +#include "cge/vol.h" +#include "cge/text.h" #include #include #include diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index f3c17fa73e..a749b482b7 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -1,11 +1,38 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __VGA13H__ #define __VGA13H__ -#include +#include "cge/general.h" #include #include -#include "bitmap.h" -#include "snail.h" +#include "cge/bitmap.h" +#include "cge/snail.h" #define TMR_RATE1 16 diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 5dd3efb191..ccfe273923 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -1,5 +1,32 @@ -#include "vmenu.h" -#include "mouse.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/vmenu.h" +#include "cge/mouse.h" #include #include diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index c4d3a8df18..23c354b504 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __VMENU__ #define __VMENU__ -#include "talk.h" +#include "cge/talk.h" #define MB_VM 1 #define MB_HM 3 diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index d0d8dce35c..6816f2de90 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -1,11 +1,38 @@ -#include "vol.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/vol.h" #include #include #include #include #ifdef DROP_H - #include "drop.h" + #include "cge/drop.h" #else #include #define DROP(m,n) { printf("%s [%s]\n", (m), (n)); _exit(1); } diff --git a/engines/cge/vol.h b/engines/cge/vol.h index 347b0b48fe..80cd759a47 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -1,10 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __VOL__ #define __VOL__ #include -#include "btfile.h" -#include "cfile.h" +#include "cge/btfile.h" +#include "cge/cfile.h" #define CAT_NAME "VOL.CAT" #define DAT_NAME "VOL.DAT" diff --git a/engines/cge/wav.h b/engines/cge/wav.h index c32178420c..22dd79c4f5 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -1,7 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + #ifndef __WAV__ #define __WAV__ -#include +#include "cge/general.h" #include #define WAVE_FORMAT_PCM 0x0001 -- cgit v1.2.3 From a5c569eff2c4e2f30ef0523169ab22ed92f9894a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 09:14:43 +0200 Subject: CGE: Remove far and near keywords --- engines/cge/bitmap.cpp | 66 ++++++++++++++++++++++++------------------------ engines/cge/bitmap.h | 8 +++--- engines/cge/cfile.cpp | 22 ++++++++-------- engines/cge/cfile.h | 14 +++++----- engines/cge/cge_main.cpp | 24 +++++++++--------- engines/cge/game.cpp | 4 +-- engines/cge/game.h | 4 +-- engines/cge/general.h | 18 ++++++------- engines/cge/jbw.h | 12 ++++----- engines/cge/keybd.cpp | 2 +- engines/cge/keybd.h | 2 +- engines/cge/mouse.h | 2 +- engines/cge/snail.cpp | 10 ++++---- engines/cge/snail.h | 4 +-- engines/cge/snddrv.h | 4 +-- engines/cge/sound.cpp | 12 ++++----- engines/cge/talk.cpp | 18 ++++++------- engines/cge/talk.h | 6 ++--- engines/cge/vga13h.cpp | 66 ++++++++++++++++++++++++------------------------ engines/cge/vga13h.h | 22 ++++++++-------- engines/cge/vmenu.cpp | 2 +- engines/cge/vol.cpp | 2 +- engines/cge/vol.h | 4 +-- engines/cge/wav.h | 4 +-- 24 files changed, 166 insertions(+), 166 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index d493f29f56..697eb4a9e3 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -48,7 +48,7 @@ -DAC far * BITMAP::Pal = NULL; +DAC * BITMAP::Pal = NULL; @@ -97,7 +97,7 @@ BITMAP::BITMAP (const char * fname, Boolean rem) -BITMAP::BITMAP (word w, word h, byte far * map) +BITMAP::BITMAP (word w, word h, byte * map) : W(w), H(h), M(map), V(NULL) { if (map) Code(); @@ -147,15 +147,15 @@ BITMAP::BITMAP (const BITMAP& bmp) : W(bmp.W), H(bmp.H), M(NULL), V(NULL) { - byte far * v0 = bmp.V; + byte * v0 = bmp.V; if (v0) { word vsiz = FP_OFF(bmp.B) - FP_OFF(v0); word siz = vsiz + H * sizeof(HideDesc); - byte far * v1 = farnew(byte, siz); + byte * v1 = farnew(byte, siz); if (v1 == NULL) DROP("No core", NULL); _fmemcpy(v1, v0, siz); - B = (HideDesc far *) ((V = v1) + vsiz); + B = (HideDesc *) ((V = v1) + vsiz); } } @@ -180,7 +180,7 @@ BITMAP::~BITMAP (void) BITMAP& BITMAP::operator = (const BITMAP& bmp) { - byte far * v0 = bmp.V; + byte * v0 = bmp.V; W = bmp.W; H = bmp.H; M = NULL; @@ -190,10 +190,10 @@ BITMAP& BITMAP::operator = (const BITMAP& bmp) { word vsiz = FP_OFF(bmp.B) - FP_OFF(v0); word siz = vsiz + H * sizeof(HideDesc); - byte far * v1 = farnew(byte, siz); + byte * v1 = farnew(byte, siz); if (v1 == NULL) DROP("No core", NULL); _fmemcpy(v1, v0, siz); - B = (HideDesc far *) ((V = v1) + vsiz); + B = (HideDesc *) ((V = v1) + vsiz); } return *this; } @@ -202,7 +202,7 @@ BITMAP& BITMAP::operator = (const BITMAP& bmp) -word BITMAP::MoveVmap (byte far * buf) +word BITMAP::MoveVmap (byte * buf) { if (V) { @@ -210,7 +210,7 @@ word BITMAP::MoveVmap (byte far * buf) word siz = vsiz + H * sizeof(HideDesc); _fmemcpy(buf, V, siz); if (MemType(V) == FAR_MEM) farfree(V); - B = (HideDesc far *) ((V = buf) + vsiz); + B = (HideDesc *) ((V = buf) + vsiz); return siz; } return 0; @@ -240,8 +240,8 @@ BMP_PTR BITMAP::Code (void) while (TRUE) // at most 2 times: for (V == NULL) & for allocated block; { - byte far * im = V+2; - word far * cp = (word far *) V; + byte * im = V+2; + word * cp = (word *) V; int bpl; if (V) // 2nd pass - fill the hide table @@ -254,7 +254,7 @@ BMP_PTR BITMAP::Code (void) } for (bpl = 0; bpl < 4; bpl ++) // once per each bitplane { - byte far * bm = M; + byte * bm = M; Boolean skip = (bm[bpl] == TRANS); word j; @@ -277,7 +277,7 @@ BMP_PTR BITMAP::Code (void) { *cp = cnt; // store block description word } - cp = (word far *) im; + cp = (word *) im; im += 2; skip = (pix == TRANS); cnt = 0; @@ -304,7 +304,7 @@ BMP_PTR BITMAP::Code (void) { *cp = cnt; } - cp = (word far *) im; + cp = (word *) im; im += 2; skip = TRUE; cnt = (SCR_WID - j + 3) / 4; @@ -318,11 +318,11 @@ BMP_PTR BITMAP::Code (void) { *cp = cnt; } - cp = (word far *) im; + cp = (word *) im; im += 2; } if (V) *cp = EOI; - cp = (word far *) im; + cp = (word *) im; im += 2; } if (V) break; @@ -332,7 +332,7 @@ BMP_PTR BITMAP::Code (void) { DROP("No core", NULL); } - B = (HideDesc far *) (V + sizV); + B = (HideDesc *) (V + sizV); } cnt = 0; for (i = 0; i < H; i ++) @@ -362,7 +362,7 @@ BMP_PTR BITMAP::Code (void) Boolean BITMAP::SolidAt (int x, int y) { - byte far * m; + byte * m; word r, n, n0; if (x >= W || y >= H) return FALSE; @@ -375,7 +375,7 @@ Boolean BITMAP::SolidAt (int x, int y) { word w, t; - w = * (word far *) m; + w = * (word *) m; m += 2; t = w & 0xC000; w &= 0x3FFF; @@ -393,7 +393,7 @@ Boolean BITMAP::SolidAt (int x, int y) { word w, t; - w = * (word far *) m; + w = * (word *) m; m += 2; t = w & 0xC000; w &= 0x3FFF; @@ -419,12 +419,12 @@ Boolean BITMAP::SolidAt (int x, int y) Boolean BITMAP::VBMSave (XFILE * f) { word p = (Pal != NULL), - n = ((word) (((byte far *)B) - V)) + H * sizeof(HideDesc); - if (f->Error == 0) f->Write((byte far *)&p, sizeof(p)); - if (f->Error == 0) f->Write((byte far *)&n, sizeof(n)); - if (f->Error == 0) f->Write((byte far *)&W, sizeof(W)); - if (f->Error == 0) f->Write((byte far *)&H, sizeof(H)); - if (f->Error == 0) if (p) f->Write((byte far *)Pal, 256 * sizeof(DAC)); + n = ((word) (((byte *)B) - V)) + H * sizeof(HideDesc); + if (f->Error == 0) f->Write((byte *)&p, sizeof(p)); + if (f->Error == 0) f->Write((byte *)&n, sizeof(n)); + if (f->Error == 0) f->Write((byte *)&W, sizeof(W)); + if (f->Error == 0) f->Write((byte *)&H, sizeof(H)); + if (f->Error == 0) if (p) f->Write((byte *)Pal, 256 * sizeof(DAC)); if (f->Error == 0) f->Write(V, n); return (f->Error == 0); } @@ -436,21 +436,21 @@ Boolean BITMAP::VBMSave (XFILE * f) Boolean BITMAP::VBMLoad (XFILE * f) { word p, n; - if (f->Error == 0) f->Read((byte far *)&p, sizeof(p)); - if (f->Error == 0) f->Read((byte far *)&n, sizeof(n)); - if (f->Error == 0) f->Read((byte far *)&W, sizeof(W)); - if (f->Error == 0) f->Read((byte far *)&H, sizeof(H)); + if (f->Error == 0) f->Read((byte *)&p, sizeof(p)); + if (f->Error == 0) f->Read((byte *)&n, sizeof(n)); + if (f->Error == 0) f->Read((byte *)&W, sizeof(W)); + if (f->Error == 0) f->Read((byte *)&H, sizeof(H)); if (f->Error == 0) { if (p) { - if (Pal) f->Read((byte far *)Pal, 256 * sizeof(DAC)); + if (Pal) f->Read((byte *)Pal, 256 * sizeof(DAC)); else f->Seek(f->Mark() + 256 * sizeof(DAC)); } } if ((V = farnew(byte, n)) == NULL) return FALSE; if (f->Error == 0) f->Read(V, n); - B = (HideDesc far *) (V + n - H * sizeof(HideDesc)); + B = (HideDesc *) (V + n - H * sizeof(HideDesc)); return (f->Error == 0); } diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index a6a3dc7539..738b3ab4ef 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -58,11 +58,11 @@ class BITMAP Boolean BMPLoad (XFILE * f); Boolean VBMLoad (XFILE * f); public: - static DAC far * Pal; + static DAC * Pal; word W, H; - byte far * M, far * V; HideDesc far * B; + byte * M, * V; HideDesc * B; BITMAP (const char * fname, Boolean rem = TRUE); - BITMAP (word w, word h, byte far * map); + BITMAP (word w, word h, byte * map); BITMAP (word w, word h, byte fill); BITMAP (const BITMAP& bmp); ~BITMAP (void); @@ -74,7 +74,7 @@ public: void XShow (int x, int y); Boolean SolidAt (int x, int y); Boolean VBMSave (XFILE * f); - word MoveVmap (byte far * buf); + word MoveVmap (byte * buf); }; diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 03df303245..0aa7c20a89 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -114,7 +114,7 @@ void IOBUF::WriteBuff (void) -word IOBUF::Read (void far * buf, word len) +word IOBUF::Read (void *buf, word len) { word total = 0; while (len) @@ -125,7 +125,7 @@ word IOBUF::Read (void far * buf, word len) { if (len < n) n = len; _fmemcpy(buf, Buff+Ptr, n); - (byte far *) buf += n; + (byte *) buf += n; len -= n; total += n; Ptr += n; @@ -140,21 +140,21 @@ word IOBUF::Read (void far * buf, word len) -word IOBUF::Read (byte far * buf) +word IOBUF::Read (byte * buf) { word total = 0; while (total < LINE_MAX-2) { if (Ptr >= Lim) ReadBuff(); - byte far * p = Buff + Ptr; + byte * p = Buff + Ptr; word n = Lim - Ptr; if (n) { if (total + n >= LINE_MAX-2) n = LINE_MAX-2 - total; - byte far * eol = (byte far *) _fmemchr(p, '\r', n); + byte * eol = (byte *) _fmemchr(p, '\r', n); if (eol) n = (word) (eol - p); - byte far * eof = (byte far *) _fmemchr(p, '\32', n); + byte * eof = (byte *) _fmemchr(p, '\32', n); if (eof) // end-of-file { n = (word) (eof - p); @@ -187,7 +187,7 @@ word IOBUF::Read (byte far * buf) -word IOBUF::Write (void far * buf, word len) +word IOBUF::Write (void * buf, word len) { word tot = 0; while (len) @@ -199,7 +199,7 @@ word IOBUF::Write (void far * buf, word len) _fmemcpy(Buff+Lim, buf, n); Lim += n; len -= n; - (byte far *) buf += n; + (byte *) buf += n; tot += n; } else WriteBuff(); @@ -212,12 +212,12 @@ word IOBUF::Write (void far * buf, word len) -word IOBUF::Write (byte far * buf) +word IOBUF::Write (byte * buf) { word len = 0; if (buf) { - len = _fstrlen((const char far *) buf); + len = _fstrlen((const char *) buf); if (len) if (buf[len-1] == '\n') -- len; len = Write(buf, len); if (len) @@ -273,7 +273,7 @@ void IOBUF::Write (byte b) -CFILE::CFILE (const char near * name, IOMODE mode, CRYPT * crpt) +CFILE::CFILE (const char * name, IOMODE mode, CRYPT * crpt) : IOBUF(name, mode, crpt) { } diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 56a249d9c0..5903d605ed 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -38,7 +38,7 @@ #define IOBUF_SIZE K(2) #endif -#define CFREAD(x) Read((byte far *)(x),sizeof(*(x))) +#define CFREAD(x) Read((byte *)(x),sizeof(*(x))) @@ -46,7 +46,7 @@ class IOBUF : public IOHAND { protected: - byte far * Buff; + byte * Buff; word Ptr, Lim; long BufMark; word Seed; @@ -57,11 +57,11 @@ public: IOBUF (IOMODE mode, CRYPT * crpt = NULL); IOBUF (const char * name, IOMODE mode, CRYPT * crpt = NULL); virtual ~IOBUF (void); - word Read (void far * buf, word len); - word Read (char far * buf); + word Read (void * buf, word len); + word Read (char * buf); int Read (void); - word Write (void far * buf, word len); - word Write (byte far * buf); + word Write (void * buf, word len); + word Write (byte * buf); void Write (byte b); }; @@ -71,7 +71,7 @@ class CFILE : public IOBUF { public: static word MaxLineLen; - CFILE (const char near * name, IOMODE mode = REA, CRYPT * crpt = NULL); + CFILE (const char * name, IOMODE mode = REA, CRYPT * crpt = NULL); virtual ~CFILE (void); void Flush (void); long Mark (void); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index bc19156ad5..2bb7ac5c65 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -285,10 +285,10 @@ static void LoadGame (XFILE& file, Boolean tiny = FALSE) for (st = SavTab; st->Ptr; st ++) { if (file.Error) VGA::Exit("Bad SVG"); - file.Read((byte far *) ((tiny || st->Flg) ? st->Ptr : &i), st->Len); + file.Read((byte *) ((tiny || st->Flg) ? st->Ptr : &i), st->Len); } - file.Read((byte far *) &i, sizeof(i)); + file.Read((byte *) &i, sizeof(i)); if (i != SVGCHKSUM) VGA::Exit(BADSVG_TEXT); if (STARTUP::Core < CORE_HIG) Music = FALSE; if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) @@ -303,7 +303,7 @@ static void LoadGame (XFILE& file, Boolean tiny = FALSE) while (! file.Error) { SPRITE S(NULL); - word n = file.Read((byte far *) &S, sizeof(S)); + word n = file.Read((byte *) &S, sizeof(S)); if (n != sizeof(S)) break; S.Prev = S.Next = NULL; @@ -354,14 +354,14 @@ static void SaveGame (XFILE& file) for (st = SavTab; st->Ptr; st ++) { if (file.Error) VGA::Exit("Bad SVG"); - file.Write((byte far *) st->Ptr, st->Len); + file.Write((byte *) st->Ptr, st->Len); } - file.Write((byte far *) &(i = SVGCHKSUM), sizeof(i)); + file.Write((byte *) &(i = SVGCHKSUM), sizeof(i)); for (spr = VGA::SpareQ.First(); spr; spr = spr->Next) if (spr->Ref >= 1000) - if (!file.Error) file.Write((byte far *)spr, sizeof(*spr)); + if (!file.Error) file.Write((byte *)spr, sizeof(*spr)); } @@ -435,7 +435,7 @@ static void LoadMapping (void) { memset(CLUSTER::Map, 0, sizeof(CLUSTER::Map)); cf.Seek((Now - 1) * sizeof(CLUSTER::Map)); - cf.Read((byte far *) CLUSTER::Map, sizeof(CLUSTER::Map)); + cf.Read((byte *) CLUSTER::Map, sizeof(CLUSTER::Map)); } } } @@ -850,7 +850,7 @@ int SYSTEM::FunDel = HEROFUN0; void SYSTEM::SetPal (void) { int i; - DAC far * p = SysPal + 256-ArrayCount(StdPal); + DAC * p = SysPal + 256-ArrayCount(StdPal); for (i = 0; i < ArrayCount(StdPal); i ++) { p[i].R = StdPal[i].R >> 2; @@ -1426,7 +1426,7 @@ static void SaveMapping (void) if (! cf.Error) { cf.Seek((Now-1) * sizeof(CLUSTER::Map)); - cf.Write((byte far *) CLUSTER::Map, sizeof(CLUSTER::Map)); + cf.Write((byte *) CLUSTER::Map, sizeof(CLUSTER::Map)); } } { @@ -1435,7 +1435,7 @@ static void SaveMapping (void) { HeroXY[Now-1].X = Hero->X; HeroXY[Now-1].Y = Hero->Y; - cf.Write((byte far *) HeroXY, sizeof(HeroXY)); + cf.Write((byte *) HeroXY, sizeof(HeroXY)); } } } @@ -1998,7 +1998,7 @@ static void RunGame (void) if (Mini && INI_FILE::Exist("MINI.SPR")) { - byte far * ptr = (byte far *) &*Mini; + byte * ptr = (byte *) &*Mini; if (ptr != NULL) { LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); @@ -2217,7 +2217,7 @@ Boolean ShowTitle (const char * name) void StkDump (void) { CFILE f("!STACK.DMP", BFW); - f.Write((byte far *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2); + f.Write((byte *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2); } #endif */ diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index bf7bd850f5..620e988c36 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -34,7 +34,7 @@ -byte * Glass (DAC far * pal, byte r, byte g, byte b) +byte * Glass (DAC * pal, byte r, byte g, byte b) { byte * x = new byte[256]; if (x) @@ -54,7 +54,7 @@ byte * Glass (DAC far * pal, byte r, byte g, byte b) -byte * Mark (DAC far * pal) +byte * Mark (DAC * pal) { #define f(c) (c ^ 63) byte * x = new byte[256]; diff --git a/engines/cge/game.h b/engines/cge/game.h index e675d15a7c..7a5efd9844 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -44,8 +44,8 @@ extern SPRITE * Sys; int Sinus (long x); -byte * Glass (DAC far * pal, byte r, byte g, byte b); -byte * Mark (DAC far * pal); +byte * Glass (DAC * pal, byte r, byte g, byte b); +byte * Mark (DAC * pal); diff --git a/engines/cge/general.h b/engines/cge/general.h index 71d9d96bdf..0a73de98a2 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -38,7 +38,7 @@ #define SCR_WID ((word)SCR_WID_) #define SCR_HIG ((word)SCR_HIG_) #define SCR_SEG 0xA000 -#define SCR_ADR ((byte far *) MK_FP(SCR_SEG, 0)) +#define SCR_ADR ((byte *) MK_FP(SCR_SEG, 0)) @@ -83,7 +83,7 @@ public: class ENGINE { protected: - static void interrupt (far * OldTimer) (...); + static void interrupt (* OldTimer) (...); static void interrupt NewTimer (...); public: ENGINE (word tdiv); @@ -128,7 +128,7 @@ class EMS EMS * Nxt; public: EMS (void); - void far * operator & () const; + void * operator & () const; word Size (void); }; @@ -184,8 +184,8 @@ public: word Error; XFILE (void) : Mode(REA), Error(0) { } XFILE (IOMODE mode) : Mode(mode), Error(0) { } - virtual word Read (void far * buf, word len) = 0; - virtual word Write (void far * buf, word len) = 0; + virtual word Read (void * buf, word len) = 0; + virtual word Write (void * buf, word len) = 0; virtual long Mark (void) = 0; virtual long Size (void) = 0; virtual long Seek (long pos) = 0; @@ -198,7 +198,7 @@ public: template inline word XRead (XFILE * xf, T * t) { - return xf->Read((byte far *) t, sizeof(*t)); + return xf->Read((byte *) t, sizeof(*t)); }; @@ -212,12 +212,12 @@ protected: word Seed; CRYPT * Crypt; public: - IOHAND (const char near * name, IOMODE mode = REA, CRYPT crypt = NULL); + IOHAND (const char * name, IOMODE mode = REA, CRYPT crypt = NULL); IOHAND (IOMODE mode = REA, CRYPT * crpt = NULL); virtual ~IOHAND (void); static Boolean Exist (const char * name); - word Read (void far * buf, word len); - word Write (void far * buf, word len); + word Read (void * buf, word len); + word Write (void * buf, word len); long Mark (void); long Size (void); long Seek (long pos); diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index cb2cb54fec..99e87a3820 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -49,7 +49,7 @@ #define IsAlNum(c) (IsAlpha(c) || IsDigit(c)) #define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) -#define farnew(t,n) ((t far *) farmalloc(sizeof(t) * (n))) +#define farnew(t,n) ((t *) farmalloc(sizeof(t) * (n))) #define ArrayCount(a) (sizeof(a)/sizeof((a)[0])) #define MAX_TIMER 0x1800B0L @@ -138,11 +138,11 @@ struct KeyStatStruct #define CGA_Cursor 0x0607 #define OFF_Cursor 0x2000 -#define TimerCount (* ((volatile long far *) ((void _seg *) 0x40 + (void near *) 0x6C))) -#define KeyStat (* ((volatile struct KeyStatStruct far *) ((void _seg *) 0x40 + (void near *) 0x17))) -#define BreakFlag (* ((volatile byte far *) ((void _seg *) 0x40 + (void near *) 0x71))) -#define PostFlag (* ((volatile word far *) ((void _seg *) 0x40 + (void near *) 0x72))) -#define POST ((void far (*)(void)) ((void _seg *) 0xF000 + (void near *) 0xFFF0)) +#define TimerCount (* ((volatile long *) ((void _seg *) 0x40 + (void *) 0x6C))) +#define KeyStat (* ((volatile struct KeyStatStruct *) ((void _seg *) 0x40 + (void *) 0x17))) +#define BreakFlag (* ((volatile byte *) ((void _seg *) 0x40 + (void *) 0x71))) +#define PostFlag (* ((volatile word *) ((void _seg *) 0x40 + (void *) 0x72))) +#define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0)) #define SLIF if (KeyStat.ScrollLock) #define FOR(i,n) for(i=0;i<(n);i++) diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index 37a1e1d798..63a37a348e 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -45,7 +45,7 @@ word KEYBOARD::Code[0x60] = { 0,Esc,'1','2','3','4','5','6','7','8','9','0', 0*0x54,0*0x55,0*0x56,F11,F12,0*0x59,0*0x5A, 0*0x5B,0*0x5C,0*0x5D,0*0x5E,0*0x5F }; -void interrupt (far * KEYBOARD::OldKeyboard) (...); +void interrupt (* KEYBOARD::OldKeyboard) (...); diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h index 42c80f88e1..7aa93b232f 100644 --- a/engines/cge/keybd.h +++ b/engines/cge/keybd.h @@ -41,7 +41,7 @@ class KEYBOARD { - static void interrupt (far * OldKeyboard) (...); + static void interrupt (* OldKeyboard) (...); static void interrupt NewKeyboard (...); static word Code[0x60]; static word Current; diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index f3b83f3f2e..8e69232c5c 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -51,7 +51,7 @@ struct EVENT { word Msk; }; extern EVENT Evt[EVT_MAX]; extern word EvtHead, EvtTail; -typedef void (far MOUSE_FUN) (void); +typedef void (MOUSE_FUN) (void); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 82f9416af7..4c041653a4 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -63,7 +63,7 @@ extern SPRITE * Pocket[]; extern int PocPtr; //------------------------------------------------------------------------- -extern DAC far * SysPal; +extern DAC * SysPal; extern MOUSE Mouse; @@ -512,7 +512,7 @@ SNAIL::~SNAIL (void) void SNAIL::AddCom (SNCOM com, int ref, int val, void * ptr) { _disable(); - COM far * snc = &SNList[Head ++]; + COM * snc = &SNList[Head ++]; snc->Com = com; snc->Ref = ref; snc->Val = val; @@ -531,7 +531,7 @@ void SNAIL::AddCom (SNCOM com, int ref, int val, void * ptr) void SNAIL::InsCom (SNCOM com, int ref, int val, void * ptr) { - COM far * snc; + COM * snc; _disable(); if (Busy) @@ -1094,7 +1094,7 @@ void SNFlash (Boolean on) { if (on) { - DAC far * pal = farnew(DAC, PAL_CNT); + DAC * pal = farnew(DAC, PAL_CNT); if (pal) { int i; @@ -1181,7 +1181,7 @@ void SNAIL::RunCom (void) byte tmphea = Head; while (Tail != tmphea) { - COM far * snc = &SNList[Tail]; + COM * snc = &SNList[Tail]; if (! Turbo) // only for the slower one { diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 66a40e8382..309f9b5a29 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -52,7 +52,7 @@ typedef struct { byte Horz, Vert; } BAR; struct SCB { - byte far * Ptr; + byte * Ptr; word Siz; SCB * Nxt; }; @@ -81,7 +81,7 @@ enum SNLIST { NEAR, TAKE }; class SNAIL { - struct COM { SNCOM Com; int Ref; int Val; void * Ptr; } far * SNList; + struct COM { SNCOM Com; int Ref; int Val; void * Ptr; } * SNList; byte Head, Tail; Boolean Turbo, Busy, TextDelay; word Pause; diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 910148c71e..a445465dc8 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -82,7 +82,7 @@ struct DRVINFO // sample info struct SMPINFO { - BYTE far * saddr; // address + BYTE * saddr; // address WORD slen; // length WORD span; // left/right pan (0-15) int sflag; // flag @@ -119,7 +119,7 @@ EC void SNDDigiStart (SMPINFO *PSmpInfo); EC void SNDDigiStop (SMPINFO *PSmpInfo); // Start MIDI File -EC void SNDMIDIStart (BYTE far *MIDFile); +EC void SNDMIDIStart (BYTE *MIDFile); // Stop MIDI File EC void SNDMIDIStop (void); diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index cd0101204d..e8b2a8f4cf 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -90,7 +90,7 @@ void SOUND::Play (DATACK * wav, int pan, int cnt) if (wav) { Stop(); - smpinf.saddr = (char far *) &*(wav->EAddr()); + smpinf.saddr = (char *) &*(wav->EAddr()); smpinf.slen = (word)wav->Size(); smpinf.span = pan; smpinf.sflag = cnt; @@ -246,7 +246,7 @@ DATACK * FX::operator [] (int ref) //------------------------------------------------------------------------- -static byte far * midi = NULL; +static byte * midi = NULL; @@ -275,7 +275,7 @@ void LoadMIDI (int ref) if (mid.Error == 0) { word siz = (word) mid.Size(); - midi = new far byte[siz]; + midi = new byte[siz]; if (midi) { mid.Read(midi, siz); @@ -294,9 +294,9 @@ void LoadMIDI (int ref) -EC void far * Patch (int pat) +EC void * Patch (int pat) { - void far * p = NULL; + void * p = NULL; static char fn[] = "PATCH000.SND"; wtom(pat, fn+5, 10, 3); @@ -304,7 +304,7 @@ EC void far * Patch (int pat) if (! snd.Error) { word siz = (word) snd.Size(); - p = (byte far *) farmalloc(siz); + p = (byte *) farmalloc(siz); if (p) { snd.Read(p, siz); diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 3a4ea5bbc2..2e247336ab 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -180,7 +180,7 @@ void TALK::Update (const char * tx) word hmarg = (Mode) ? TEXT_HM : 0; word mw, mh, ln = vmarg; const char * p; - byte far * m; + byte * m; if (! TS[0]) { @@ -210,10 +210,10 @@ void TALK::Update (const char * tx) else { int cw = Font.Wid[*tx], i; - char far * f = Font.Map + Font.Pos[*tx]; + char * f = Font.Map + Font.Pos[*tx]; for (i = 0; i < cw; i ++) { - char far * p = m; + char * p = m; word n; register word b = * (f ++); for (n = 0; n < FONT_HIG; n ++) @@ -236,7 +236,7 @@ void TALK::Update (const char * tx) BITMAP * TALK::Box (word w, word h) { - byte far * b, far * p, far * q; + byte * b, * p, * q; word n, r = (Mode == ROUND) ? TEXT_RD : 0; int i; @@ -287,7 +287,7 @@ void TALK::PutLine (int line, const char * text) // Note: (TS[0].W % 4) have to be 0 { word w = TS[0]->W, h = TS[0]->H; - byte far * v = TS[0]->V, far * p; + byte * v = TS[0]->V, * p; word dsiz = w >> 2; // data size (1 plane line size) word lsiz = 2 + dsiz + 2; // word for line header, word for gap word psiz = h * lsiz; // - last gap, but + plane trailer @@ -307,14 +307,14 @@ void TALK::PutLine (int line, const char * text) // paint text line if (text) { - byte far * q; + byte * q; p = v + 2 + TEXT_HM/4 + (TEXT_HM%4)*psiz; q = v + size; while (* text) { word cw = Font.Wid[*text], i; - byte far * fp = Font.Map + Font.Pos[*text]; + byte * fp = Font.Map + Font.Pos[*text]; for (i = 0; i < cw; i ++) { @@ -361,7 +361,7 @@ void INFO_LINE::Update (const char * tx) if (tx != OldTxt) { word w = TS[0]->W, h = TS[0]->H; - byte * v = (byte near *) TS[0]->V; + byte * v = (byte *) TS[0]->V; word dsiz = w >> 2; // data size (1 plane line size) word lsiz = 2 + dsiz + 2; // word for line header, word for gap word psiz = h * lsiz; // - last gape, but + plane trailer @@ -381,7 +381,7 @@ void INFO_LINE::Update (const char * tx) while (* tx) { word cw = Font.Wid[*tx], i; - byte far * fp = Font.Map + Font.Pos[*tx]; + byte * fp = Font.Map + Font.Pos[*tx]; for (i = 0; i < cw; i ++) { diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 8129b01bd9..c84891f7a0 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -55,9 +55,9 @@ public: // static byte Wid[256]; // static word Pos[256]; // static byte Map[256*8]; - byte far * Wid; - word far * Pos; - byte far * Map; + byte * Wid; + word * Pos; + byte * Map; FONT (const char * name); ~FONT (void); word Width (const char * text); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 404b4f8bf8..84dbd802fd 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -136,9 +136,9 @@ static void Video (void) -word far * SaveScreen (void) +word * SaveScreen (void) { - word cxy, cur, siz, far * scr = NULL, far * sav; + word cxy, cur, siz, * scr = NULL, * sav; // horizontal size of text mode screen asm mov ah,0x0F // get current video mode @@ -194,9 +194,9 @@ word far * SaveScreen (void) -void RestoreScreen (word far * &sav) +void RestoreScreen (word * &sav) { - word far * scr = NULL; + word * scr = NULL; asm mov ax,0x40 // system data segment asm mov es,ax @@ -486,7 +486,7 @@ BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) -void SPRITE::MoveShapes (byte far * buf) +void SPRITE::MoveShapes (byte * buf) { BMP_PTR * p; for (p = Ext->ShpList; *p; p ++) @@ -779,7 +779,7 @@ void SPRITE::Tick (void) -void SPRITE::MakeXlat (byte far * x) +void SPRITE::MakeXlat (byte * x) { if (Ext) { @@ -800,7 +800,7 @@ void SPRITE::KillXlat (void) if (Flags.Xlat && Ext) { BMP_PTR * b; - byte far * m = (*Ext->ShpList)->M; + byte * m = (*Ext->ShpList)->M; switch (MemType(m)) { @@ -885,7 +885,7 @@ void SPRITE::Show (void) void SPRITE::Show (word pg) { - byte far * a = VGA::Page[1]; + byte * a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; Shp()->Show(X, Y); VGA::Page[1] = a; @@ -912,13 +912,13 @@ BMP_PTR SPRITE::Ghost (void) register SPREXT * e = Ext; if (e->b1) { - BMP_PTR bmp = new BITMAP(0, 0, (byte far *)NULL); + BMP_PTR bmp = new BITMAP(0, 0, (byte *)NULL); if (bmp == NULL) VGA::Exit("No core"); bmp->W = e->b1->W; bmp->H = e->b1->H; if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); - bmp->V = (byte far *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); - bmp->M = (byte far *) MK_FP(e->y1, e->x1); + bmp->V = (byte *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + bmp->M = (byte *) MK_FP(e->y1, e->x1); return bmp; } return NULL; @@ -1085,18 +1085,18 @@ SPRITE * QUEUE::Locate (int ref) word VGA::StatAdr = VGAST1_; word VGA::OldMode = 0; -word far * VGA::OldScreen = NULL; +word * VGA::OldScreen = NULL; const char * VGA::Msg = NULL; const char * VGA::Nam = NULL; -DAC far * VGA::OldColors = NULL; -DAC far * VGA::NewColors = NULL; +DAC * VGA::OldColors = NULL; +DAC * VGA::NewColors = NULL; Boolean VGA::SetPal = FALSE; int VGA::Mono = 0; QUEUE VGA::ShowQ = TRUE, VGA::SpareQ = FALSE; -byte far * VGA::Page[4] = { (byte far *) MK_FP(SCR_SEG, 0x0000), - (byte far *) MK_FP(SCR_SEG, 0x4000), - (byte far *) MK_FP(SCR_SEG, 0x8000), - (byte far *) MK_FP(SCR_SEG, 0xC000) }; +byte * VGA::Page[4] = { (byte *) MK_FP(SCR_SEG, 0x0000), + (byte *) MK_FP(SCR_SEG, 0x4000), + (byte *) MK_FP(SCR_SEG, 0x8000), + (byte *) MK_FP(SCR_SEG, 0xC000) }; @@ -1280,7 +1280,7 @@ int VGA::SetMode (int mode) -void VGA::GetColors (DAC far * tab) +void VGA::GetColors (DAC * tab) { asm cld asm les di,tab // color table @@ -1303,9 +1303,9 @@ void VGA::GetColors (DAC far * tab) -void VGA::SetColors (DAC far * tab, int lum) +void VGA::SetColors (DAC * tab, int lum) { - DAC far * des = NewColors; + DAC * des = NewColors; asm push ds asm les di,des @@ -1367,7 +1367,7 @@ void VGA::SetColors (void) -void VGA::Sunrise (DAC far * tab) +void VGA::Sunrise (DAC * tab) { int i; for (i = 0; i <= 64; i += FADE_STEP) @@ -1420,7 +1420,7 @@ void VGA::Show (void) void VGA::UpdateColors (void) { - DAC far * tab = NewColors; + DAC * tab = NewColors; asm push ds asm cld @@ -1453,7 +1453,7 @@ void VGA::UpdateColors (void) void VGA::Update (void) { - byte far * p = Page[1]; + byte * p = Page[1]; Page[1] = Page[0]; Page[0] = p; @@ -1483,7 +1483,7 @@ void VGA::Update (void) void VGA::Clear (byte color) { - byte far * a = (byte far *) MK_FP(SCR_SEG, 0); + byte * a = (byte *) MK_FP(SCR_SEG, 0); asm mov dx,VGASEQ_ asm mov ax,0x0F02 // map mask register - enable all planes @@ -1504,7 +1504,7 @@ void VGA::Clear (byte color) void VGA::CopyPage (word d, word s) { - byte far * S = Page[s & 3], far * D = Page[d & 3]; + byte * S = Page[s & 3], * D = Page[d & 3]; asm mov dx,VGAGRA_ asm mov al,0x05 // R/W mode @@ -1573,9 +1573,9 @@ void BITMAP::XShow (int x, int y) { byte rmsk = x % 4, mask = 1 << rmsk, - far * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - byte near * m = (char *) M; - byte far * v = V; + * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + byte * m = (char *) M; + byte * v = V; asm push bx asm push si @@ -1658,8 +1658,8 @@ void BITMAP::XShow (int x, int y) void BITMAP::Show (int x, int y) { byte mask = 1 << (x & 3), - far * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - byte far * v = V; + * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); + byte * v = V; asm push ds // preserve DS @@ -1728,9 +1728,9 @@ void BITMAP::Show (int x, int y) void BITMAP::Hide (int x, int y) { - byte far * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + byte * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; word d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); - HideDesc far * b = B; + HideDesc * b = B; word extra = ((x & 3) != 0); word h = H; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index a749b482b7..4f172cb3ea 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -199,7 +199,7 @@ public: virtual ~SPRITE (void); BMP_PTR Shp (void); BMP_PTR * SetShapeList (BMP_PTR * shp); - void MoveShapes (byte far * buf); + void MoveShapes (byte * buf); SPRITE * Expand (void); SPRITE * Contract (void); SPRITE * BackShow (Boolean fast = FALSE); @@ -211,7 +211,7 @@ public: void Hide (void); BMP_PTR Ghost (void); void Show (word pg); - void MakeXlat (byte far * x); + void MakeXlat (byte * x); void KillXlat (void); void Step (int nr = -1); SEQ * SetSeq (SEQ * seq); @@ -251,10 +251,10 @@ public: class VGA { static word OldMode; - static word far * OldScreen; + static word * OldScreen; static word StatAdr; static Boolean SetPal; - static DAC far * OldColors, far * NewColors; + static DAC * OldColors, * NewColors; static int SetMode (int mode); static void UpdateColors (void); static void SetColors (void); @@ -266,17 +266,17 @@ public: dword FrmCnt; static QUEUE ShowQ, SpareQ; static int Mono; - static byte far * Page[4]; + static byte * Page[4]; VGA (int mode = M13H); ~VGA (void); void Setup (VgaRegBlk * vrb); - static void GetColors (DAC far * tab); - static void SetColors (DAC far * tab, int lum); + static void GetColors (DAC * tab); + static void SetColors (DAC * tab, int lum); static void Clear (byte color = 0); static void Exit (const char * txt = NULL, const char * name = NULL); static void Exit (int tref, const char * name = NULL); static void CopyPage (word d, word s = 3); - static void Sunrise (DAC far * tab); + static void Sunrise (DAC * tab); static void Sunset (void); void Show (void); void Update (void); @@ -291,7 +291,7 @@ RGB MkRGB (byte r, byte g, byte b); template -byte Closest (CBLK far * pal, CBLK x) +byte Closest (CBLK * pal, CBLK x) { #define f(col,lum) ((((word)(col))<<8)/lum) word i, dif = 0xFFFF, found; @@ -325,8 +325,8 @@ byte Closest (CBLK far * pal, CBLK x) char * NumStr (char * str, int num); void Video (void); - word far * SaveScreen (void); - void RestoreScreen (word far * &sav); + word * SaveScreen (void); + void RestoreScreen (word * &sav); SPRITE * SpriteAt (int x, int y); SPRITE * Locate (int ref); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index ccfe273923..4ca3708eac 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -48,7 +48,7 @@ MENU_BAR::MENU_BAR (word w) { int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; - byte far * p = farnew(byte, i), far * p1, far * p2; + byte * p = farnew(byte, i), * p1, * p2; _fmemset(p+w, TRANS, i-2*w); _fmemset(p, MB_LT, w); diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 6816f2de90..f0365867ee 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -61,7 +61,7 @@ VFILE::VFILE (const char * name, IOMODE mode) if (mode == REA) { if (Dat.File.Error || Cat.Error) DROP("Bad volume data", NULL); - BT_KEYPACK far * kp = Cat.Find(name); + BT_KEYPACK * kp = Cat.Find(name); if (_fstricmp(kp->Key, name) != 0) Error = ENOFILE; EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; } diff --git a/engines/cge/vol.h b/engines/cge/vol.h index 80cd759a47..74b4a2b648 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -55,9 +55,9 @@ class DAT friend VFILE; static VOLBASE File; public: - static Boolean Append (byte far * buf, word len); + static Boolean Append (byte * buf, word len); static Boolean Write (CFILE& f); - static Boolean Read (long org, word len, byte far * buf); + static Boolean Read (long org, word len, byte * buf); }; diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 22dd79c4f5..3266af95d5 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -110,7 +110,7 @@ class DATACK : public CKHEA Boolean e; union { - byte far * Buf; + byte * Buf; EMS * EBuf; }; public: @@ -118,7 +118,7 @@ public: DATACK (CKHEA& hea, EMM * emm); DATACK (int first, int last); ~DATACK (void); - inline byte far * Addr (void) { return Buf; } + inline byte * Addr (void) { return Buf; } inline EMS * EAddr (void) { return EBuf; } }; -- cgit v1.2.3 From 68f7ff111536c2d7f5a8869252ba8ad31507a380 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 13:06:03 +0200 Subject: CGE: Replace Boolean, TRUE and FALSE by bool, true, false --- engines/cge/bitmap.cpp | 26 +++++----- engines/cge/bitmap.h | 10 ++-- engines/cge/boot.h | 2 +- engines/cge/cfile.cpp | 2 +- engines/cge/cge_main.cpp | 128 +++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 4 +- engines/cge/general.h | 12 ++--- engines/cge/gettext.cpp | 4 +- engines/cge/jbw.h | 7 +-- engines/cge/mixer.cpp | 22 ++++---- engines/cge/mixer.h | 2 +- engines/cge/mouse.cpp | 4 +- engines/cge/mouse.h | 2 +- engines/cge/snail.cpp | 98 ++++++++++++++++++------------------ engines/cge/snail.h | 14 +++--- engines/cge/sound.cpp | 2 +- engines/cge/sound.h | 2 +- engines/cge/startup.cpp | 14 +++--- engines/cge/startup.h | 2 +- engines/cge/talk.cpp | 6 +-- engines/cge/text.cpp | 18 +++---- engines/cge/vga13h.cpp | 40 +++++++-------- engines/cge/vga13h.h | 20 ++++---- engines/cge/vmenu.cpp | 14 +++--- engines/cge/vol.cpp | 2 +- engines/cge/vol.h | 8 +-- engines/cge/wav.h | 6 +-- 27 files changed, 234 insertions(+), 237 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 697eb4a9e3..a9ded67e45 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -53,7 +53,7 @@ DAC * BITMAP::Pal = NULL; #pragma argsused -BITMAP::BITMAP (const char * fname, Boolean rem) +BITMAP::BITMAP (const char * fname, bool rem) : M(NULL), V(NULL) { char pat[MAXPATH]; @@ -238,7 +238,7 @@ BMP_PTR BITMAP::Code (void) V = NULL; } - while (TRUE) // at most 2 times: for (V == NULL) & for allocated block; + while (true) // at most 2 times: for (V == NULL) & for allocated block; { byte * im = V+2; word * cp = (word *) V; @@ -255,7 +255,7 @@ BMP_PTR BITMAP::Code (void) for (bpl = 0; bpl < 4; bpl ++) // once per each bitplane { byte * bm = M; - Boolean skip = (bm[bpl] == TRANS); + bool skip = (bm[bpl] == TRANS); word j; cnt = 0; @@ -306,7 +306,7 @@ BMP_PTR BITMAP::Code (void) } cp = (word *) im; im += 2; - skip = TRUE; + skip = true; cnt = (SCR_WID - j + 3) / 4; } } @@ -360,12 +360,12 @@ BMP_PTR BITMAP::Code (void) -Boolean BITMAP::SolidAt (int x, int y) +bool BITMAP::SolidAt (int x, int y) { byte * m; word r, n, n0; - if (x >= W || y >= H) return FALSE; + if (x >= W || y >= H) return false; m = V; r = x % 4; @@ -389,7 +389,7 @@ Boolean BITMAP::SolidAt (int x, int y) m += w; } - while (TRUE) + while (true) { word w, t; @@ -398,14 +398,14 @@ Boolean BITMAP::SolidAt (int x, int y) t = w & 0xC000; w &= 0x3FFF; - if (n > n0) return FALSE; + if (n > n0) return false; n += w; switch (t) { - case EOI : return FALSE; + case EOI : return false; case SKP : w = 0; break; case REP : - case CPY : if (n-w <= n0 && n > n0) return TRUE; break; + case CPY : if (n-w <= n0 && n > n0) return true; break; } m += (t == REP) ? 1 : w; } @@ -416,7 +416,7 @@ Boolean BITMAP::SolidAt (int x, int y) -Boolean BITMAP::VBMSave (XFILE * f) +bool BITMAP::VBMSave (XFILE * f) { word p = (Pal != NULL), n = ((word) (((byte *)B) - V)) + H * sizeof(HideDesc); @@ -433,7 +433,7 @@ Boolean BITMAP::VBMSave (XFILE * f) -Boolean BITMAP::VBMLoad (XFILE * f) +bool BITMAP::VBMLoad (XFILE * f) { word p, n; if (f->Error == 0) f->Read((byte *)&p, sizeof(p)); @@ -448,7 +448,7 @@ Boolean BITMAP::VBMLoad (XFILE * f) else f->Seek(f->Mark() + 256 * sizeof(DAC)); } } - if ((V = farnew(byte, n)) == NULL) return FALSE; + if ((V = farnew(byte, n)) == NULL) return false; if (f->Error == 0) f->Read(V, n); B = (HideDesc *) (V + n - H * sizeof(HideDesc)); return (f->Error == 0); diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 738b3ab4ef..de2214fd63 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -55,13 +55,13 @@ typedef struct { word skip; word hide; } HideDesc; class BITMAP { - Boolean BMPLoad (XFILE * f); - Boolean VBMLoad (XFILE * f); + bool BMPLoad (XFILE * f); + bool VBMLoad (XFILE * f); public: static DAC * Pal; word W, H; byte * M, * V; HideDesc * B; - BITMAP (const char * fname, Boolean rem = TRUE); + BITMAP (const char * fname, bool rem = true); BITMAP (word w, word h, byte * map); BITMAP (word w, word h, byte fill); BITMAP (const BITMAP& bmp); @@ -72,8 +72,8 @@ public: void Hide (int x, int y); void Show (int x, int y); void XShow (int x, int y); - Boolean SolidAt (int x, int y); - Boolean VBMSave (XFILE * f); + bool SolidAt (int x, int y); + bool VBMSave (XFILE * f); word MoveVmap (byte * buf); }; diff --git a/engines/cge/boot.h b/engines/cge/boot.h index 6b9b2c88ec..1715fd02ec 100644 --- a/engines/cge/boot.h +++ b/engines/cge/boot.h @@ -70,7 +70,7 @@ typedef struct { EC Boot * ReadBoot (int drive); EC byte CheckBoot (Boot * boot); -EC Boolean WriteBoot (int drive, Boot * boot); +EC bool WriteBoot (int drive, Boot * boot); #endif \ No newline at end of file diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 0aa7c20a89..7d222d101d 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -349,7 +349,7 @@ void CFILE::Append (CFILE& f) Seek(Size()); if (f.Error == 0) { - while (TRUE) + while (true) { if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) WriteBuff(); else break; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 2bb7ac5c65..1f621948c2 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -117,7 +117,7 @@ static int DemoText = DEMO_TEXT; //-------------------------------------------------------------------------- - Boolean JBW = FALSE; + bool JBW = false; DAC *SysPal = farnew(DAC, PAL_CNT); //------------------------------------------------------------------------- @@ -141,10 +141,10 @@ static EMS * Mini = MiniEmm.Alloc((word)MINI_EMM_SIZE); static BMP_PTR * MiniShpList = NULL; static BMP_PTR MiniShp[] = { NULL, NULL }; static KEYBOARD Keyboard; -static Boolean Finis = FALSE; +static bool Finis = false; static int Startup = 1; static int OffUseCount = atoi(Text[OFF_USE_COUNT]); - word * intStackPtr = FALSE; + word *intStackPtr = false; HXY HeroXY[CAVE_MAX] = {{0,0}}; @@ -184,9 +184,9 @@ byte & CLUSTER::Cell (void) -Boolean CLUSTER::Protected (void) +bool CLUSTER::Protected (void) { - if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return TRUE; + if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return true; _DX = (MAP_ZCNT << 8) + MAP_XCNT; _BX = (word) this; @@ -202,7 +202,7 @@ Boolean CLUSTER::Protected (void) asm cmp ch,dh asm jge xit -// if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return TRUE; +// if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true; asm mov al,dl asm mul ch @@ -276,7 +276,7 @@ CLUSTER XZ (COUPLE xy) -static void LoadGame (XFILE& file, Boolean tiny = FALSE) +static void LoadGame (XFILE& file, bool tiny = false) { SAVTAB * st; SPRITE * spr; @@ -290,7 +290,7 @@ static void LoadGame (XFILE& file, Boolean tiny = FALSE) file.Read((byte *) &i, sizeof(i)); if (i != SVGCHKSUM) VGA::Exit(BADSVG_TEXT); - if (STARTUP::Core < CORE_HIG) Music = FALSE; + if (STARTUP::Core < CORE_HIG) Music = false; if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) { SNDDrvInfo.VOL2.D = volume[0]; @@ -483,10 +483,10 @@ void WALK::Tick (void) if (! spr->Flags.Near) { FeedSnail(spr, NEAR); - spr->Flags.Near = TRUE; + spr->Flags.Near = true; } } - else spr->Flags.Near = FALSE; + else spr->Flags.Near = false; } } @@ -578,7 +578,7 @@ void WALK::Park (void) void WALK::FindWay (CLUSTER c) { - Boolean Find1Way(void); + bool Find1Way(void); extern word Target; if (c != Here) @@ -621,7 +621,7 @@ void WALK::FindWay (SPRITE * spr) -Boolean WALK::Lower (SPRITE * spr) +bool WALK::Lower (SPRITE * spr) { return (spr->Y > Y + (H * 3) / 5); } @@ -681,8 +681,8 @@ public: SQUARE::SQUARE (void) : SPRITE(MB) { - Flags.Kill = TRUE; - Flags.BDel = FALSE; + Flags.Kill = true; + Flags.BDel = false; } @@ -816,13 +816,13 @@ static void AltCtrlDel (void) static void MiniStep (int stp) { - if (stp < 0) MiniCave->Flags.Hide = TRUE; + if (stp < 0) MiniCave->Flags.Hide = true; else { &*Mini; *MiniShp[0] = *MiniShpList[stp]; if (Fx.Current) &*(Fx.Current->EAddr()); - MiniCave->Flags.Hide = FALSE; + MiniCave->Flags.Hide = false; } } @@ -927,7 +927,7 @@ static void CaveUp (void) // following 2 lines trims Hero's Z position! Hero->Tick(); Hero->Time = 1; - Hero->Flags.Hide = FALSE; + Hero->Flags.Hide = false; } if (! Dark) Vga.Sunset(); @@ -946,9 +946,9 @@ static void CaveUp (void) Vga.CopyPage(1, 0); Vga.Show(); Vga.Sunrise(SysPal); - Dark = FALSE; + Dark = false; if (! Startup) Mouse.On(); - HEART::Enable = TRUE; + HEART::Enable = true; } @@ -993,7 +993,7 @@ static void QGame (void) SaveSound(); SaveGame(CFILE(UsrPath(UsrFnam), WRI, RCrypt)); Vga.Sunset(); - Finis = TRUE; + Finis = true; } @@ -1003,7 +1003,7 @@ void SwitchCave (int cav) { if (cav != Now) { - HEART::Enable = FALSE; + HEART::Enable = false; if (cav < 0) { SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint @@ -1087,7 +1087,7 @@ void SYSTEM::Touch (word mask, int x, int y) case F7 : Hero->Step(TSEQ + 2); break; case F8 : Hero->Step(TSEQ + 3); break; case F9 : SYSTEM::FunDel = 1; break; - case 'X' : if (KEYBOARD::Key[ALT]) Finis = TRUE; break; + case 'X' : if (KEYBOARD::Key[ALT]) Finis = true; break; case '0' : case '1' : case '2' : @@ -1268,7 +1268,7 @@ static void SwitchMusic (void) if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); else { - SNPOST_(SNSEQ, 122, (Music = FALSE), NULL); + SNPOST_(SNSEQ, 122, (Music = false), NULL); SNPOST(SNEXEC, -1, 0, (void *) SelectSound); } } @@ -1355,8 +1355,8 @@ static void SwitchMapping (void) static void KillSprite (void) { - Sprite->Flags.Kill = TRUE; - Sprite->Flags.BDel = TRUE; + Sprite->Flags.Kill = true; + Sprite->Flags.BDel = true; SNPOST_(SNKILL, -1, 0, Sprite); Sprite = NULL; } @@ -1382,7 +1382,7 @@ static void PushSprite (void) static void PullSprite (void) { - Boolean ok = FALSE; + bool ok = false; SPRITE * spr = Sprite->Next; if (spr) { @@ -1554,7 +1554,7 @@ static void OptionTouch (int opt, word mask) if (mask & R_UP) if (! MIXER::Appear) { - MIXER::Appear = TRUE; + MIXER::Appear = true; new MIXER(BUTTON_X, BUTTON_Y); } break; @@ -1611,7 +1611,7 @@ void SPRITE::Touch (word mask, int x, int y) { SNPOST(SNREACH, -1, -1, this); SNPOST(SNKEEP, -1, -1, this); - Flags.Port = FALSE; + Flags.Port = false; } } else @@ -1674,9 +1674,9 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro int shpcnt = 0; int type = 0; // DEAD - Boolean east = FALSE; - Boolean port = FALSE; - Boolean tran = FALSE; + bool east = false; + bool port = false; + bool tran = false; int i, lcnt = 0; word len; @@ -1807,8 +1807,8 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro Sprite->Flags.East = east; Sprite->Flags.Port = port; Sprite->Flags.Tran = tran; - Sprite->Flags.Kill = TRUE; - Sprite->Flags.BDel = TRUE; + Sprite->Flags.Kill = true; + Sprite->Flags.BDel = true; fnsplit(fname, NULL, NULL, Sprite->File, NULL); Sprite->ShpCnt = shpcnt; VGA::SpareQ.Append(Sprite); @@ -1825,10 +1825,10 @@ static void LoadScript (const char *fname) char line[LINE_MAX]; char * SpN; int SpI, SpA, SpX, SpY, SpZ; - Boolean BkG = FALSE; + bool BkG = false; INI_FILE scrf(fname); int lcnt = 0; - Boolean ok = TRUE; + bool ok = true; if (scrf.Error) return; @@ -1839,7 +1839,7 @@ static void LoadScript (const char *fname) ++ lcnt; if (*line == 0 || *line == '\n' || *line == '.') continue; - ok = FALSE; // not OK if break + ok = false; // not OK if break // sprite ident number if ((p = strtok(line, " \t\n")) == NULL) break; SpI = atoi(p); @@ -1861,11 +1861,11 @@ static void LoadScript (const char *fname) if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; BkG = atoi(p) == 0; - ok = TRUE; // no break: OK + ok = true; // no break: OK Sprite = NULL; LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); - if (Sprite && BkG) Sprite->Flags.Back = TRUE; + if (Sprite && BkG) Sprite->Flags.Back = true; } if (! ok) { @@ -1947,7 +1947,7 @@ void LoadUser (void) else { LoadScript(ProgName(INI_EXT)); - Music = TRUE; + Music = true; SaveGame(CFILE(SVG0NAME, WRI)); VGA::Exit("Ok", SVG0NAME); } @@ -1965,9 +1965,9 @@ static void RunGame (void) Text.Preload(100, 1000); LoadHeroXY(); - CavLight.Flags.Tran = TRUE; + CavLight.Flags.Tran = true; VGA::ShowQ.Append(&CavLight); - CavLight.Flags.Hide = TRUE; + CavLight.Flags.Hide = true; static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 }, { 1, 2, 0, 0, 4 }, @@ -1978,7 +1978,7 @@ static void RunGame (void) { 0, 1, 0, 0, 16 }, }; PocLight.SetSeq(PocSeq); - PocLight.Flags.Tran = TRUE; + PocLight.Flags.Tran = true; PocLight.Time = 1; PocLight.Z = 120; VGA::ShowQ.Append(&PocLight); @@ -2005,7 +2005,7 @@ static void RunGame (void) ExpandSprite(MiniCave = Sprite); // NULL is ok if (MiniCave) { - MiniCave->Flags.Hide = TRUE; + MiniCave->Flags.Hide = true; MiniCave->MoveShapes(ptr); MiniShp[0] = new BITMAP(*MiniCave->Shp()); MiniShpList = MiniCave->SetShapeList(MiniShp); @@ -2024,15 +2024,15 @@ static void RunGame (void) if ((Shadow = Sprite) != NULL) { Shadow->Ref = 2; - Shadow->Flags.Tran = TRUE; - Hero->Flags.Shad = TRUE; + Shadow->Flags.Tran = true; + Hero->Flags.Shad = true; VGA::ShowQ.Insert(VGA::SpareQ.Remove(Shadow), Hero); } } } InfoLine.Goto(INFO_X, INFO_Y); - InfoLine.Flags.Tran = TRUE; + InfoLine.Flags.Tran = true; InfoLine.Update(NULL); VGA::ShowQ.Insert(&InfoLine); @@ -2064,7 +2064,7 @@ static void RunGame (void) } KEYBOARD::SetClient(NULL); - HEART::Enable = FALSE; + HEART::Enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); Mouse.Off(); @@ -2086,14 +2086,14 @@ void Movie (const char * ext) ExpandSprite(VGA::SpareQ.Locate(999)); FeedSnail(VGA::ShowQ.Locate(999), TAKE); VGA::ShowQ.Append(&Mouse); - HEART::Enable = TRUE; + HEART::Enable = true; KEYBOARD::SetClient(Sys); while (! Snail.Idle()) { MainLoop(); } KEYBOARD::SetClient(NULL); - HEART::Enable = FALSE; + HEART::Enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); VGA::ShowQ.Clear(); @@ -2106,16 +2106,16 @@ void Movie (const char * ext) -Boolean ShowTitle (const char * name) +bool ShowTitle (const char * name) { BITMAP::Pal = SysPal; BMP_PTR LB[] = { new BITMAP(name), NULL }; BITMAP::Pal = NULL; - Boolean usr_ok = FALSE; + bool usr_ok = false; SPRITE D(LB); - D.Flags.Kill = TRUE; - D.Flags.BDel = TRUE; + D.Flags.Kill = true; + D.Flags.BDel = true; D.Center(); D.Show(2); @@ -2136,11 +2136,11 @@ Boolean ShowTitle (const char * name) VGA::CopyPage(1, 2); VGA::CopyPage(0, 1); VGA::ShowQ.Append(&Mouse); - HEART::Enable = TRUE; + HEART::Enable = true; Mouse.On(); for (SelectSound(); ! Snail.Idle() || VMENU::Addr; ) MainLoop(); Mouse.Off(); - HEART::Enable = FALSE; + HEART::Enable = false; VGA::ShowQ.Clear(); VGA::CopyPage(0, 2); STARTUP::SoundOk = 2; @@ -2151,7 +2151,7 @@ Boolean ShowTitle (const char * name) { #ifdef DEMO strcpy(UsrFnam, ProgName(SVG_EXT)); - usr_ok = TRUE; + usr_ok = true; #else //----------------------------------------- #ifndef EVA @@ -2171,10 +2171,10 @@ Boolean ShowTitle (const char * name) VGA::CopyPage(0, 1); VGA::ShowQ.Append(&Mouse); //Mouse.On(); - HEART::Enable = TRUE; + HEART::Enable = true; for (TakeName(); GET_TEXT::Ptr; ) MainLoop(); - HEART::Enable = FALSE; - if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = TRUE; + HEART::Enable = false; + if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = true; if (usr_ok) strcat(UsrFnam, SVG_EXT); //Mouse.Off(); VGA::ShowQ.Clear(); @@ -2185,13 +2185,13 @@ Boolean ShowTitle (const char * name) const char *n = UsrPath(UsrFnam); if (CFILE::Exist(n)) { - LoadGame(CFILE(n, REA, RCrypt), TRUE); // only system vars + LoadGame(CFILE(n, REA, RCrypt), true); // only system vars VGA::SetColors(SysPal, 64); Vga.Update(); if (FINIS) { ++ STARTUP::Mode; - FINIS = FALSE; + FINIS = false; } } else ++ STARTUP::Mode; @@ -2203,7 +2203,7 @@ Boolean ShowTitle (const char * name) VGA::CopyPage(0, 2); #ifdef DEMO - return TRUE; + return true; #else return (STARTUP::Mode == 2 || usr_ok); #endif @@ -2237,8 +2237,8 @@ void cge_main (void) if (! Mouse.Exist) VGA::Exit(NO_MOUSE_TEXT); if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; - Debug( DebugLine.Flags.Hide = TRUE; ) - Debug( HorzLine.Flags.Hide = TRUE; ) + Debug( DebugLine.Flags.Hide = true; ) + Debug( HorzLine.Flags.Hide = true; ) srand((word) Timer()); Sys = new SYSTEM; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 7a213429b1..4f610897b1 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -167,7 +167,7 @@ public: byte &Cell (void); CLUSTER (void) : COUPLE () { } CLUSTER (int a, int b) : COUPLE (a, b) { } - Boolean Protected (void); + bool Protected (void); }; @@ -186,7 +186,7 @@ public: int Distance (SPRITE * spr); void Turn (DIR d); void Park (void); - Boolean Lower (SPRITE * spr); + bool Lower (SPRITE * spr); void Reach (SPRITE * spr, int mode = -1); }; diff --git a/engines/cge/general.h b/engines/cge/general.h index 0a73de98a2..03c34d7058 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -70,8 +70,8 @@ public: void operator += (COUPLE c) { A += c.A; B += c.B; } COUPLE operator - (COUPLE c) { return COUPLE(A-c.A, B-c.B); } void operator -= (COUPLE c) { A -= c.A; B -= c.B; } - Boolean operator == (COUPLE c) { return ((A - c.A) | (B - c.B)) == 0; } - Boolean operator != (COUPLE c) { return ! (operator == (c)); } + bool operator == (COUPLE c) { return ((A - c.A) | (B - c.B)) == 0; } + bool operator != (COUPLE c) { return ! (operator == (c)); } void Split (signed char& a, signed char& b) { a = A; b = B; } }; @@ -103,7 +103,7 @@ class EMS; class EMM { friend EMS; - Boolean Test (void); + bool Test (void); long Top, Lim; EMS * List; int Han; @@ -215,7 +215,7 @@ public: IOHAND (const char * name, IOMODE mode = REA, CRYPT crypt = NULL); IOHAND (IOMODE mode = REA, CRYPT * crpt = NULL); virtual ~IOHAND (void); - static Boolean Exist (const char * name); + static bool Exist (const char * name); word Read (void * buf, word len); word Write (void * buf, word len); long Mark (void); @@ -250,7 +250,7 @@ int TakeEnum (const char ** tab, const char * txt); word ChkSum (void *m, word n); long Timer (void); long TimerLimit (word t); -Boolean TimerLimitGone (long t); +bool TimerLimitGone (long t); char * MergeExt (char * buf, const char * nam, const char * ext); char * ForceExt (char * buf, const char * nam, const char * ext); inline const char * ProgPath (void); @@ -258,7 +258,7 @@ const char * ProgName (const char * ext = NULL); int DriveFixed (unsigned drv); int DriveRemote (unsigned drv); int DriveCD (unsigned drv); -Boolean IsVga (void); +bool IsVga (void); EC void _fqsort (void *base, word nelem, word width, int (*fcmp)(const void*, const void*)); diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 5d6c8ce1bf..ad9f885bb9 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -47,8 +47,8 @@ GET_TEXT::GET_TEXT (const char * info, char * text, int size, void (*click)(void Mode = RECT; TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); SetShapeList(TS); - Flags.BDel = TRUE; - Flags.Kill = TRUE; + Flags.BDel = true; + Flags.Kill = true; memcpy(Buff, text, Len); Buff[Len] = ' '; Buff[Len+1] = '\0'; diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 99e87a3820..22110bc832 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -36,10 +36,8 @@ #define CR 13 #define NULL 0 -#define TRUE (1==1) -#define FALSE (!TRUE) -#define OFF FALSE -#define ON TRUE +#define OFF false +#define ON true #define IsWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') #define IsUpper(c) ((c) >= 'A' && (c) <= 'Z') @@ -57,7 +55,6 @@ typedef unsigned char BYTE; typedef unsigned int WORD; typedef unsigned long DWORD; -typedef int Boolean; typedef unsigned char byte; typedef unsigned int word; typedef unsigned long dword; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 1e7aa7a181..56a8c5f335 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -29,7 +29,7 @@ #include "cge/text.h" #include "cge/snail.h" #include "cge/mouse.h" -#include +#include "cge/snddrv.h" #include #include @@ -38,7 +38,7 @@ extern MOUSE Mouse; - Boolean MIXER::Appear = FALSE; + bool MIXER::Appear = false; @@ -46,14 +46,14 @@ MIXER::MIXER (int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { int i; - Appear = TRUE; + Appear = true; mb[0] = new BITMAP("VOLUME"); mb[1] = NULL; SetShapeList(mb); SetName(Text[MIX_NAME]); - Flags.Syst = TRUE; - Flags.Kill = TRUE; - Flags.BDel = TRUE; + Flags.Syst = true; + Flags.Kill = true; + Flags.BDel = true; Goto(x, y); Z = MIX_Z; @@ -74,13 +74,13 @@ MIXER::MIXER (int x, int y) register SPRITE * spr = new SPRITE(lb); spr->SetSeq(ls); spr->Goto(x+2+12*i, y+8); - spr->Flags.Tran = TRUE; - spr->Flags.Kill = TRUE; - spr->Flags.BDel = FALSE; + spr->Flags.Tran = true; + spr->Flags.Kill = true; + spr->Flags.BDel = false; spr->Z = MIX_Z; Led[i] = spr; } - Led[ArrayCount(Led)-1]->Flags.BDel = TRUE; + Led[ArrayCount(Led)-1]->Flags.BDel = true; VGA::ShowQ.Insert(this); for (i = 0; i < ArrayCount(Led); i ++) VGA::ShowQ.Insert(Led[i]); @@ -101,7 +101,7 @@ MIXER::MIXER (int x, int y) MIXER::~MIXER (void) { - Appear = FALSE; + Appear = false; } diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index bf5d79b67f..e2377ff781 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -46,7 +46,7 @@ class MIXER : public SPRITE int Fall; void Update (void); public: - static Boolean Appear; + static bool Appear; MIXER (int x, int y); ~MIXER (void); void Touch (word mask, int x, int y); diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index b9a0386801..5fdaf08995 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -195,7 +195,7 @@ void MOUSE::Tick (void) Hold = e.Ptr; if (Hold) { - Hold->Flags.Hold = TRUE; + Hold->Flags.Hold = true; #ifndef DEBUG if (Hold->Flags.Drag) #endif @@ -210,7 +210,7 @@ void MOUSE::Tick (void) { if (Hold) { - Hold->Flags.Hold = FALSE; + Hold->Flags.Hold = false; Hold = NULL; } } diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index 8e69232c5c..e30abcaa94 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -67,7 +67,7 @@ class MOUSE : public SPRITE //void SetFun (void); //void ResetFun (void); public: - Boolean Exist; + bool Exist; int Buttons; SPRITE * Busy; //SPRITE * Touched; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 4c041653a4..06824c5b12 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -44,13 +44,13 @@ int MaxCave = 0; SCB Scb = { NULL, 0, NULL }; - Boolean Flag[4]; - Boolean Dark = FALSE; - Boolean Game = FALSE; + bool Flag[4]; + bool Dark = false; + bool Game = false; int Now = 1; int Lev = -1; - SNAIL Snail = FALSE; - SNAIL Snail_ = TRUE; + SNAIL Snail = false; + SNAIL Snail_ = true; extern SPRITE PocLight; @@ -176,7 +176,7 @@ static void SNGame (SPRITE * spr, int num) if (! Game) { SNPOST(SNSAY, buref, 16008, NULL); // zgadnij! - Game = TRUE; + Game = true; } #undef STEPS #undef DRESSED @@ -186,7 +186,7 @@ static void SNGame (SPRITE * spr, int num) { static SPRITE * k = NULL, * k1, * k2, * k3; static int count = 0; - Boolean hit; + bool hit; if (k == NULL) { @@ -199,7 +199,7 @@ static void SNGame (SPRITE * spr, int num) if (! Game) // init { SNPOST(SNGAME, 20002, 2, NULL); - Game = TRUE; + Game = true; } else // cont { @@ -233,7 +233,7 @@ static void SNGame (SPRITE * spr, int num) SNPOST(SNSEND, 20010, 20, NULL); // papier SNPOST(SNSOUND,20010, 20003, NULL); // papier! SNPOST(SNSAY, 20001, 20005, NULL); - Game = FALSE; + Game = false; return; } else k3->Step(random(5)); @@ -414,11 +414,11 @@ void FeedSnail (SPRITE * spr, SNLIST snq) if (p->Ptr) break; } } - while (TRUE) + while (true) { if (c->Com == SNTALK) { - if ((Snail.TalkEnable = (c->Val != 0)) == FALSE) KillText(); + if ((Snail.TalkEnable = (c->Val != 0)) == false) KillText(); } if (c->Com == SNNEXT) { @@ -487,9 +487,9 @@ char * SNAIL::ComTxt[] = { "LABEL", "PAUSE", "WAIT", "LEVEL", -SNAIL::SNAIL (Boolean turbo) -: Turbo(turbo), Busy(FALSE), TextDelay(FALSE), - Pause(0), TalkEnable(TRUE), +SNAIL::SNAIL (bool turbo) +: Turbo(turbo), Busy(false), TextDelay(false), + Pause(0), TalkEnable(true), Head(0), Tail(0), SNList(farnew(COM, 256)) { } @@ -604,9 +604,9 @@ static void SNZTrim (SPRITE * spr) { if (spr) if (spr->Active()) { - Boolean en = HEART::Enable; + bool en = HEART::Enable; SPRITE * s; - HEART::Enable = FALSE; + HEART::Enable = false; s = (spr->Flags.Shad) ? spr->Prev : NULL; VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr)); if (s) @@ -681,8 +681,8 @@ void SNSend (SPRITE * spr, int val) if (spr) { int was = spr->Cave; - Boolean was1 = (was == 0 || was == Now); - Boolean val1 = (val == 0 || val == Now); + bool was1 = (was == 0 || was == Now); + bool val1 = (val == 0 || val == Now); spr->Cave = val; if (val1 != was1) { @@ -695,12 +695,12 @@ void SNSend (SPRITE * spr, int val) } Hide1(spr); ContractSprite(spr); - spr->Flags.Slav = FALSE; + spr->Flags.Slav = false; } else { if (spr->Ref % 1000 == 0) BITMAP::Pal = SysPal; - if (spr->Flags.Back) spr->BackShow(TRUE); + if (spr->Flags.Back) spr->BackShow(true); else ExpandSprite(spr); BITMAP::Pal = NULL; } @@ -719,8 +719,8 @@ void SNSwap (SPRITE * spr, int xref) { int was = spr->Cave; int xwas = xspr->Cave; - Boolean was1 = (was == 0 || was == Now); - Boolean xwas1 = (xwas == 0 || xwas == Now); + bool was1 = (was == 0 || was == Now); + bool xwas1 = (xwas == 0 || xwas == Now); Swap(spr->Cave, xspr->Cave); Swap(spr->X, xspr->X); @@ -730,8 +730,8 @@ void SNSwap (SPRITE * spr, int xref) { int n = FindPocket(spr); if (n >= 0) Pocket[n] = xspr; - xspr->Flags.Kept = TRUE; - xspr->Flags.Port = FALSE; + xspr->Flags.Kept = true; + xspr->Flags.Port = false; } if (xwas1 != was1) { @@ -760,15 +760,15 @@ void SNCover (SPRITE * spr, int xref) SPRITE * xspr = Locate(xref); if (spr && xspr) { - spr->Flags.Hide = TRUE; + spr->Flags.Hide = true; xspr->Z = spr->Z; xspr->Cave = spr->Cave; xspr->Goto(spr->X, spr->Y); ExpandSprite(xspr); - if ((xspr->Flags.Shad = spr->Flags.Shad) == TRUE) + if ((xspr->Flags.Shad = spr->Flags.Shad) == true) { VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr); - spr->Flags.Shad = FALSE; + spr->Flags.Shad = false; } FeedSnail(xspr, NEAR); } @@ -782,13 +782,13 @@ void SNUncover (SPRITE * spr, SPRITE * xspr) { if (spr && xspr) { - spr->Flags.Hide = FALSE; + spr->Flags.Hide = false; spr->Cave = xspr->Cave; spr->Goto(xspr->X, xspr->Y); - if ((spr->Flags.Shad = xspr->Flags.Shad) == TRUE) + if ((spr->Flags.Shad = xspr->Flags.Shad) == true) { VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr); - xspr->Flags.Shad = FALSE; + xspr->Flags.Shad = false; } spr->Z = xspr->Z; SNSend(xspr, -1); @@ -913,7 +913,7 @@ void SNSlave (SPRITE * spr, int ref) if (spr->Active()) { SNSend(slv, spr->Cave); - slv->Flags.Slav = TRUE; + slv->Flags.Slav = true; slv->Z = spr->Z; VGA::ShowQ.Insert(VGA::ShowQ.Remove(slv), spr->Next); } @@ -997,7 +997,7 @@ void SNKeep (SPRITE * spr, int stp) SNSound(spr, 3, 1); Pocket[PocPtr] = spr; spr->Cave = 0; - spr->Flags.Kept = TRUE; + spr->Flags.Kept = true; spr->Goto(POCKET_X + POCKET_DX*PocPtr + POCKET_DX/2 - spr->W/2, POCKET_Y + POCKET_DY/2 - spr->H/2); if (stp >= 0) spr->Step(stp); @@ -1019,7 +1019,7 @@ void SNGive (SPRITE * spr, int stp) { Pocket[p] = NULL; spr->Cave = Now; - spr->Flags.Kept = FALSE; + spr->Flags.Kept = false; if (stp >= 0) spr->Step(stp); } } @@ -1034,7 +1034,7 @@ static void SNBackPt (SPRITE * spr, int stp) if (spr) { if (stp >= 0) spr->Step(stp); - spr->BackShow(TRUE); + spr->BackShow(true); } } @@ -1056,12 +1056,12 @@ static void SNLevel (SPRITE * spr, int lev) spr = VGA::SpareQ.Locate(100+Lev); if (spr) { - spr->BackShow(TRUE); + spr->BackShow(true); spr->Cave = 0; } } MaxCave = maxcav[Lev]; - if (spr) spr->Flags.Hide = FALSE; + if (spr) spr->Flags.Hide = false; } @@ -1069,7 +1069,7 @@ static void SNLevel (SPRITE * spr, int lev) -static void SNFlag (int fn, Boolean v) +static void SNFlag (int fn, bool v) { Flag[fn] = v; } @@ -1090,7 +1090,7 @@ static void SNSetRef (SPRITE * spr, int nr) -void SNFlash (Boolean on) +void SNFlash (bool on) { if (on) { @@ -1110,14 +1110,14 @@ void SNFlash (Boolean on) } } else VGA::SetColors(SysPal, 64); - Dark = FALSE; + Dark = false; } -static void SNLight (Boolean in) +static void SNLight (bool in) { if (in) VGA::Sunrise(SysPal); else VGA::Sunset(); @@ -1128,7 +1128,7 @@ static void SNLight (Boolean in) -static void SNBarrier (int cav, int bar, Boolean horz) +static void SNBarrier (int cav, int bar, bool horz) { ((byte *) (Barriers + ((cav > 0) ? cav : Now)))[horz] = bar; } @@ -1160,7 +1160,7 @@ static void SNReach (SPRITE * spr, int mode) -static void SNMouse (Boolean on) +static void SNMouse (bool on) { if (on) Mouse.On(); else Mouse.Off(); @@ -1177,7 +1177,7 @@ void SNAIL::RunCom (void) extern void SwitchCave(int); if (! Busy) { - Busy = TRUE; + Busy = true; byte tmphea = Head; while (Tail != tmphea) { @@ -1191,7 +1191,7 @@ void SNAIL::RunCom (void) if (TextDelay) { KillText(); - TextDelay = FALSE; + TextDelay = false; } } if (Talk && snc->Com != SNPAUSE) break; @@ -1203,7 +1203,7 @@ void SNAIL::RunCom (void) { case SNLABEL : break; case SNPAUSE : HEART::SetXTimer(&Pause, snc->Val); - if (Talk) TextDelay = TRUE; break; + if (Talk) TextDelay = true; break; case SNWAIT : if (sprel) { if (sprel->SeqTest(snc->Val) && @@ -1277,8 +1277,8 @@ void SNAIL::RunCom (void) case SNBACKPT : SNBackPt(sprel, snc->Val); break; case SNFLASH : SNFlash(snc->Val != 0); break; case SNLIGHT : SNLight(snc->Val != 0); break; - case SNSETHB : SNBarrier(snc->Ref, snc->Val, TRUE); break; - case SNSETVB : SNBarrier(snc->Ref, snc->Val, FALSE); break; + case SNSETHB : SNBarrier(snc->Ref, snc->Val, true); break; + case SNSETVB : SNBarrier(snc->Ref, snc->Val, false); break; case SNWALK : SNWalk(sprel, snc->Ref, snc->Val); break; case SNREACH : SNReach(sprel, snc->Val); break; case SNSOUND : SNSound(sprel, snc->Val, count); count = 1; break; @@ -1293,7 +1293,7 @@ void SNAIL::RunCom (void) if (! Turbo) break; } xit: - Busy = FALSE; + Busy = false; } } @@ -1301,7 +1301,7 @@ void SNAIL::RunCom (void) -Boolean SNAIL::Idle (void) +bool SNAIL::Idle (void) { return (Head == Tail); } diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 309f9b5a29..f7e19290e6 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -83,17 +83,17 @@ class SNAIL { struct COM { SNCOM Com; int Ref; int Val; void * Ptr; } * SNList; byte Head, Tail; - Boolean Turbo, Busy, TextDelay; + bool Turbo, Busy, TextDelay; word Pause; public: static char * ComTxt[]; - Boolean TalkEnable; - SNAIL (Boolean turbo = FALSE); + bool TalkEnable; + SNAIL (bool turbo = false); ~SNAIL (void); void RunCom (void); void AddCom (SNCOM com, int ref = 0, int val = 0, void * ptr = NULL); void InsCom (SNCOM com, int ref = 0, int val = 0, void * ptr = NULL); - Boolean Idle (void); + bool Idle (void); }; @@ -110,9 +110,9 @@ void PocFul (void); extern SCB Scb; -extern Boolean Flag[4]; -extern Boolean Game; -extern Boolean Dark; +extern bool Flag[4]; +extern bool Game; +extern bool Dark; extern SNAIL Snail; extern SNAIL Snail_; extern int Now; diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index e8b2a8f4cf..b3c13a0211 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -43,7 +43,7 @@ #include - Boolean Music = TRUE; + bool Music = true; FX Fx = 16; // must precede SOUND!! SOUND Sound; diff --git a/engines/cge/sound.h b/engines/cge/sound.h index b43a85dd41..993bd05fca 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -75,7 +75,7 @@ public: -extern Boolean Music; +extern bool Music; extern SOUND Sound; extern FX Fx; diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index a92e899ee2..5555c12b16 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -67,7 +67,7 @@ void quit_now (int ref) -Boolean STARTUP::get_parms (void) +bool STARTUP::get_parms (void) { int i = _argc; while (i > 1) @@ -89,7 +89,7 @@ Boolean STARTUP::get_parms (void) case 8 : SNDDrvInfo.DIRQ = p; break; case 9 : SNDDrvInfo.MBASE = p; SNDDrvInfo.MDEV = DEV_GM; break; - default: return FALSE; + default: return false; } if (n >= 2) SoundOk = 2; } @@ -112,7 +112,7 @@ Boolean STARTUP::get_parms (void) #endif #endif if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; - return TRUE; + return true; } @@ -132,7 +132,7 @@ STARTUP::STARTUP (void) if (Core < CORE_HIG) { SNDDrvInfo.MDEV = DEV_QUIET; - Music = FALSE; + Music = false; } #endif if (! get_parms()) quit_now(BAD_ARG_TEXT); @@ -160,7 +160,7 @@ const char *UsrPath (const char *nam) #if defined(CD) if (DriveCD(0)) { - Boolean ok = FALSE; + bool ok = false; CFILE ini = Text[CDINI_FNAME]; if (!ini.Error) { @@ -170,7 +170,7 @@ const char *UsrPath (const char *nam) { int j = strlen(buf); if (j) if (buf[--j] == '\n') buf[j] = '\0'; - if (memicmp(buf, key, i) == 0) ok = TRUE; + if (memicmp(buf, key, i) == 0) ok = true; } if (ok) { @@ -179,7 +179,7 @@ const char *UsrPath (const char *nam) if (*(p-1) != '\\') *(p++) = '\\'; strcpy(p, "NUL"); if (_dos_open(buf, 0, &i) == 0) _dos_close(i); - else ok = FALSE; + else ok = false; } } if (!ok) quit_now(BADCD_TEXT); diff --git a/engines/cge/startup.h b/engines/cge/startup.h index bdb2647ab1..27507a7122 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -59,7 +59,7 @@ class STARTUP { - static Boolean get_parms (void); + static bool get_parms (void); public: static int Mode; static int Core; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 2e247336ab..d941dba274 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -138,7 +138,7 @@ TALK::TALK (const char * tx, TBOX_STYLE mode) : SPRITE(NULL), Mode(mode) { TS[0] = TS[1] = NULL; - Flags.Syst = TRUE; + Flags.Syst = true; Update(tx); } @@ -150,7 +150,7 @@ TALK::TALK (void) : SPRITE(NULL), Mode(PURE) { TS[0] = TS[1] = NULL; - Flags.Syst = TRUE; + Flags.Syst = true; } @@ -163,7 +163,7 @@ TALK::~TALK (void) word i; for (i = 0; i < ShpCnt; i ++) { - if (FP_SEG(ShpList[i]) != _DS) // small model: always FALSE + if (FP_SEG(ShpList[i]) != _DS) // small model: always false { delete ShpList[i]; ShpList[i] = NULL; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index b4b6e9b23c..34b99ac7eb 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -221,7 +221,7 @@ void Say (const char * txt, SPRITE * spr) Talk = new TALK(txt, ROUND); if (Talk) { - Boolean east = spr->Flags.East; + bool east = spr->Flags.East; int x = (east) ? (spr->X+spr->W-2) : (spr->X+2); int y = spr->Y+2; SPRITE * spike = new SPRITE(SP); @@ -229,17 +229,17 @@ void Say (const char * txt, SPRITE * spr) if (east) { - if (x + sw + TEXT_RD + 5 >= SCR_WID) east = FALSE; + if (x + sw + TEXT_RD + 5 >= SCR_WID) east = false; } else { - if (x <= 5 + TEXT_RD + sw) east = TRUE; + if (x <= 5 + TEXT_RD + sw) east = true; } x = (east) ? (spr->X+spr->W-2) : (spr->X+2-sw); if (spr->Ref == 1) x += (east) ? -10 : 10; // Hero - Talk->Flags.Kill = TRUE; - Talk->Flags.BDel = TRUE; + Talk->Flags.Kill = true; + Talk->Flags.BDel = true; Talk->SetName(Text[SAY_NAME]); Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H+1); Talk->Z = 125; @@ -247,8 +247,8 @@ void Say (const char * txt, SPRITE * spr) spike->Goto(x, Talk->Y + Talk->H - 1); spike->Z = 126; - spike->Flags.Slav = TRUE; - spike->Flags.Kill = TRUE; + spike->Flags.Slav = true; + spike->Flags.Kill = true; spike->SetName(Text[SAY_NAME]); spike->Step(east); spike->Ref = SAY_REF; @@ -270,8 +270,8 @@ void Inf (const char * txt) Talk = new TALK(txt, RECT); if (Talk) { - Talk->Flags.Kill = TRUE; - Talk->Flags.BDel = TRUE; + Talk->Flags.Kill = true; + Talk->Flags.BDel = true; Talk->SetName(Text[INF_NAME]); Talk->Center(); Talk->Goto(Talk->X, Talk->Y - 20); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 84dbd802fd..386ccca140 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -85,7 +85,7 @@ static VgaRegBlk VideoMode[] = { { 0x00 } }; - Boolean SpeedTest = FALSE; + bool SpeedTest = false; SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; SPRITE * Sys = NULL; @@ -267,7 +267,7 @@ SPRITE * Locate (int ref) //-------------------------------------------------------------------------- -Boolean HEART::Enable = FALSE; +bool HEART::Enable = false; word * HEART::XTimer = NULL; @@ -499,7 +499,7 @@ void SPRITE::MoveShapes (byte * buf) -Boolean SPRITE::Works (SPRITE * spr) +bool SPRITE::Works (SPRITE * spr) { if (spr) if (spr->Ext) { @@ -509,10 +509,10 @@ Boolean SPRITE::Works (SPRITE * spr) c += spr->TakePtr; if (c->Ref == Ref) if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) - return TRUE; + return true; } } - return FALSE; + return false; } @@ -535,11 +535,11 @@ SEQ * SPRITE::SetSeq (SEQ * seq) -Boolean SPRITE::SeqTest (int n) +bool SPRITE::SeqTest (int n) { if (n >= 0) return (SeqPtr == n); if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); - return TRUE; + return true; } @@ -584,8 +584,8 @@ SPRITE * SPRITE::Expand (void) { if (! Ext) { - Boolean enbl = HEART::Enable; - HEART::Enable = FALSE; + bool enbl = HEART::Enable; + HEART::Enable = false; if ((Ext = new SPREXT) == NULL) DROP("No core", NULL); if (*File) { @@ -732,7 +732,7 @@ SPRITE * SPRITE::Contract (void) -SPRITE * SPRITE::BackShow (Boolean fast) +SPRITE * SPRITE::BackShow (bool fast) { Expand(); Show(2); @@ -787,7 +787,7 @@ void SPRITE::MakeXlat (byte * x) if (Flags.Xlat) KillXlat(); for (b = Ext->ShpList; *b; b ++) (*b)->M = x; - Flags.Xlat = TRUE; + Flags.Xlat = true; } } @@ -808,7 +808,7 @@ void SPRITE::KillXlat (void) case FAR_MEM : farfree(m); break; } for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; - Flags.Xlat = FALSE; + Flags.Xlat = false; } } @@ -953,7 +953,7 @@ SPRITE * SpriteAt (int x, int y) -QUEUE::QUEUE (Boolean show) +QUEUE::QUEUE (bool show) : Head(NULL), Tail(NULL), Show(show) { } @@ -1090,9 +1090,9 @@ const char * VGA::Msg = NULL; const char * VGA::Nam = NULL; DAC * VGA::OldColors = NULL; DAC * VGA::NewColors = NULL; -Boolean VGA::SetPal = FALSE; +bool VGA::SetPal = false; int VGA::Mono = 0; -QUEUE VGA::ShowQ = TRUE, VGA::SpareQ = FALSE; +QUEUE VGA::ShowQ = true, VGA::SpareQ = false; byte * VGA::Page[4] = { (byte *) MK_FP(SCR_SEG, 0x0000), (byte *) MK_FP(SCR_SEG, 0x4000), (byte *) MK_FP(SCR_SEG, 0x8000), @@ -1105,7 +1105,7 @@ VGA::VGA (int mode) : FrmCnt(0) { extern const char Copr[]; - Boolean std = TRUE; + bool std = true; int i; for (i = 10; i < 20; i ++) { @@ -1114,7 +1114,7 @@ VGA::VGA (int mode) { puts(txt); #ifndef DEBUG - std = FALSE; + std = false; #endif } } @@ -1187,7 +1187,7 @@ void VGA::SetStatAdr (void) #pragma argsused -void VGA::WaitVR (Boolean on) +void VGA::WaitVR (bool on) { _DX = StatAdr; _AH = (on) ? 0x00 : 0x08; @@ -1348,7 +1348,7 @@ void VGA::SetColors (DAC * tab, int lum) asm cmp di,cx asm jb mono } - SetPal = TRUE; + SetPal = true; } @@ -1470,7 +1470,7 @@ void VGA::Update (void) if (SetPal) { UpdateColors(); - SetPal = FALSE; + SetPal = false; } } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 4f172cb3ea..d7ef11f36d 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -126,7 +126,7 @@ class HEART : public ENGINE { friend ENGINE; public: - static Boolean Enable; + static bool Enable; static word * XTimer; static void SetXTimer (word * ptr); static void SetXTimer (word * ptr, word time); @@ -192,9 +192,9 @@ public: int ShpCnt; char File[MAXFILE]; SPRITE * Prev, * Next; - Boolean Works (SPRITE * spr); - Boolean SeqTest (int n); - inline Boolean Active (void) { return Ext != NULL; } + bool Works (SPRITE * spr); + bool SeqTest (int n); + inline bool Active (void) { return Ext != NULL; } SPRITE (BMP_PTR * shp); virtual ~SPRITE (void); BMP_PTR Shp (void); @@ -202,7 +202,7 @@ public: void MoveShapes (byte * buf); SPRITE * Expand (void); SPRITE * Contract (void); - SPRITE * BackShow (Boolean fast = FALSE); + SPRITE * BackShow (bool fast = false); void SetName(char * n); inline char * Name(void) { return (Ext) ? Ext->Name : NULL; } void Goto (int x, int y); @@ -229,8 +229,8 @@ class QUEUE { SPRITE * Head, * Tail; public: - Boolean Show; - QUEUE (Boolean show = FALSE); + bool Show; + QUEUE (bool show = false); ~QUEUE (void); void Append (SPRITE * spr); void Insert (SPRITE * spr, SPRITE * nxt); @@ -253,7 +253,7 @@ class VGA static word OldMode; static word * OldScreen; static word StatAdr; - static Boolean SetPal; + static bool SetPal; static DAC * OldColors, * NewColors; static int SetMode (int mode); static void UpdateColors (void); @@ -261,7 +261,7 @@ class VGA static const char * Msg; static const char * Nam; static void SetStatAdr (void); - static void WaitVR (Boolean on = TRUE); + static void WaitVR (bool on = true); public: dword FrmCnt; static QUEUE ShowQ, SpareQ; @@ -330,7 +330,7 @@ byte Closest (CBLK * pal, CBLK x) SPRITE * SpriteAt (int x, int y); SPRITE * Locate (int ref); -extern Boolean SpeedTest; +extern bool SpeedTest; #endif diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 4ca3708eac..f7314e18ea 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -64,10 +64,10 @@ MENU_BAR::MENU_BAR (word w) } TS[0] = new BITMAP(w, h, p); SetShapeList(TS); - Flags.Slav = TRUE; - Flags.Tran = TRUE; - Flags.Kill = TRUE; - Flags.BDel = TRUE; + Flags.Slav = true; + Flags.Tran = true; + Flags.Kill = true; + Flags.BDel = true; } @@ -120,8 +120,8 @@ VMENU::VMENU (CHOICE * list, int x, int y) delete[] vmgt; Items = 0; for (cp = list; cp->Text; cp ++) ++ Items; - Flags.BDel = TRUE; - Flags.Kill = TRUE; + Flags.BDel = true; + Flags.Kill = true; if (x < 0 || y < 0) Center(); else Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); VGA::ShowQ.Insert(this, VGA::ShowQ.Last()); @@ -145,7 +145,7 @@ void VMENU::Touch (word mask, int x, int y) { #define h (FONT_HIG+TEXT_LS) int n = 0; - Boolean ok = FALSE; + bool ok = false; if (Items) { diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index f0365867ee..503c6cab91 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -83,7 +83,7 @@ VFILE::~VFILE (void) -Boolean VFILE::Exist (const char * name) +bool VFILE::Exist (const char * name) { return _fstricmp(Cat.Find(name)->Key, name) == 0; } diff --git a/engines/cge/vol.h b/engines/cge/vol.h index 74b4a2b648..1357c24814 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -55,9 +55,9 @@ class DAT friend VFILE; static VOLBASE File; public: - static Boolean Append (byte * buf, word len); - static Boolean Write (CFILE& f); - static Boolean Read (long org, word len, byte * buf); + static bool Append (byte * buf, word len); + static bool Write (CFILE& f); + static bool Read (long org, word len, byte * buf); }; @@ -78,7 +78,7 @@ class VFILE : public IOBUF public: VFILE (const char * name, IOMODE mode = REA); ~VFILE (void); - static Boolean Exist (const char * name); + static bool Exist (const char * name); static const char * Next (void); long Mark (void) { return (BufMark+Ptr) - BegMark; } long Size (void) { return EndMark - BegMark; } diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 3266af95d5..1998672bed 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -51,8 +51,8 @@ public: CKID (FOURCC t) { memcpy(Tx, t, sizeof(Tx)); } CKID (dword d) { Id = d; } CKID (XFILE * xf) { (ckFile = xf)->Read(Tx, sizeof(Tx)); } - Boolean operator !=(CKID& X) { return Id != X.Id; } - Boolean operator ==(CKID& X) { return Id == X.Id; } + bool operator !=(CKID& X) { return Id != X.Id; } + bool operator ==(CKID& X) { return Id == X.Id; } const char * Name (void); }; @@ -107,7 +107,7 @@ public: class DATACK : public CKHEA { - Boolean e; + bool e; union { byte * Buf; -- cgit v1.2.3 From 7d88b9e4cde321ec210c5da022046639a316179b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 19:02:13 +0200 Subject: CGE: Suppress typedef for byte, word and dword. --- engines/cge/bitmap.cpp | 116 +++++++++++++++++++++++------------------------ engines/cge/bitmap.h | 26 +++++------ engines/cge/bitmaps.cpp | 20 ++++---- engines/cge/boot.h | 44 +++++++++--------- engines/cge/cfile.cpp | 50 ++++++++++---------- engines/cge/cfile.h | 20 ++++---- engines/cge/cge_main.cpp | 72 ++++++++++++++--------------- engines/cge/cge_main.h | 6 +-- engines/cge/game.cpp | 18 ++++---- engines/cge/game.h | 4 +- engines/cge/general.h | 52 ++++++++++----------- engines/cge/gettext.cpp | 2 +- engines/cge/gettext.h | 6 +-- engines/cge/jbw.h | 19 +++----- engines/cge/keybd.cpp | 14 +++--- engines/cge/keybd.h | 8 ++-- engines/cge/mixer.cpp | 4 +- engines/cge/mixer.h | 2 +- engines/cge/mouse.cpp | 6 +-- engines/cge/mouse.h | 8 ++-- engines/cge/snail.cpp | 10 ++-- engines/cge/snail.h | 10 ++-- engines/cge/snddrv.h | 32 ++++++------- engines/cge/sound.cpp | 12 ++--- engines/cge/startup.cpp | 8 ++-- engines/cge/startup.h | 2 +- engines/cge/talk.cpp | 92 ++++++++++++++++++------------------- engines/cge/talk.h | 18 ++++---- engines/cge/text.cpp | 2 +- engines/cge/vga13h.cpp | 96 +++++++++++++++++++-------------------- engines/cge/vga13h.h | 100 ++++++++++++++++++++-------------------- engines/cge/vmenu.cpp | 8 ++-- engines/cge/vmenu.h | 6 +-- engines/cge/vol.cpp | 2 +- engines/cge/vol.h | 4 +- engines/cge/wav.h | 32 ++++++------- 36 files changed, 462 insertions(+), 469 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index a9ded67e45..9845c4a2da 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -97,7 +97,7 @@ BITMAP::BITMAP (const char * fname, bool rem) -BITMAP::BITMAP (word w, word h, byte * map) +BITMAP::BITMAP (uint16 w, uint16 h, uint8 * map) : W(w), H(h), M(map), V(NULL) { if (map) Code(); @@ -110,23 +110,23 @@ BITMAP::BITMAP (word w, word h, byte * map) // immediately as VGA video chunks, in near memory as fast as possible, // especially for text line real time display -BITMAP::BITMAP (word w, word h, byte fill) -: W((w + 3) & ~3), // only full dwords allowed! +BITMAP::BITMAP (uint16 w, uint16 h, uint8 fill) +: W((w + 3) & ~3), // only full uint32 allowed! H(h), M(NULL) { - word dsiz = W >> 2; // data size (1 plane line size) - word lsiz = 2 + dsiz + 2; // word for line header, word for gap - word psiz = H * lsiz; // - last gape, but + plane trailer - byte * v = new byte[4 * psiz // the same for 4 planes + uint16 dsiz = W >> 2; // data size (1 plane line size) + uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap + uint16 psiz = H * lsiz; // - last gape, but + plane trailer + uint8 * v = new uint8[4 * psiz // the same for 4 planes + H * sizeof(*B)]; // + room for wash table if (v == NULL) DROP("No core", NULL); - * (word *) v = CPY | dsiz; // data chunk hader + * (uint16 *) v = CPY | dsiz; // data chunk hader memset(v+2, fill, dsiz); // data bytes - * (word *) (v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap + * (uint16 *) (v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines - * (word *) (v + psiz - 2) = EOI; // plane trailer word + * (uint16 *) (v + psiz - 2) = EOI; // plane trailer uint16 memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes HideDesc * b = (HideDesc *) (v + 4 * psiz); b->skip = (SCR_WID - W) >> 2; @@ -147,12 +147,12 @@ BITMAP::BITMAP (const BITMAP& bmp) : W(bmp.W), H(bmp.H), M(NULL), V(NULL) { - byte * v0 = bmp.V; + uint8 * v0 = bmp.V; if (v0) { - word vsiz = FP_OFF(bmp.B) - FP_OFF(v0); - word siz = vsiz + H * sizeof(HideDesc); - byte * v1 = farnew(byte, siz); + uint16 vsiz = FP_OFF(bmp.B) - FP_OFF(v0); + uint16 siz = vsiz + H * sizeof(HideDesc); + uint8 * v1 = farnew(uint8, siz); if (v1 == NULL) DROP("No core", NULL); _fmemcpy(v1, v0, siz); B = (HideDesc *) ((V = v1) + vsiz); @@ -171,7 +171,7 @@ BITMAP::~BITMAP (void) } switch (MemType(V)) { - case NEAR_MEM : delete[] (byte *) V; break; + case NEAR_MEM : delete[] (uint8 *) V; break; case FAR_MEM : farfree(V); break; } } @@ -180,7 +180,7 @@ BITMAP::~BITMAP (void) BITMAP& BITMAP::operator = (const BITMAP& bmp) { - byte * v0 = bmp.V; + uint8 * v0 = bmp.V; W = bmp.W; H = bmp.H; M = NULL; @@ -188,9 +188,9 @@ BITMAP& BITMAP::operator = (const BITMAP& bmp) if (v0 == NULL) V = NULL; else { - word vsiz = FP_OFF(bmp.B) - FP_OFF(v0); - word siz = vsiz + H * sizeof(HideDesc); - byte * v1 = farnew(byte, siz); + uint16 vsiz = FP_OFF(bmp.B) - FP_OFF(v0); + uint16 siz = vsiz + H * sizeof(HideDesc); + uint8 * v1 = farnew(uint8, siz); if (v1 == NULL) DROP("No core", NULL); _fmemcpy(v1, v0, siz); B = (HideDesc *) ((V = v1) + vsiz); @@ -202,12 +202,12 @@ BITMAP& BITMAP::operator = (const BITMAP& bmp) -word BITMAP::MoveVmap (byte * buf) +uint16 BITMAP::MoveVmap (uint8 * buf) { if (V) { - word vsiz = FP_OFF(B) - FP_OFF(V); - word siz = vsiz + H * sizeof(HideDesc); + uint16 vsiz = FP_OFF(B) - FP_OFF(V); + uint16 siz = vsiz + H * sizeof(HideDesc); _fmemcpy(buf, V, siz); if (MemType(V) == FAR_MEM) farfree(V); B = (HideDesc *) ((V = buf) + vsiz); @@ -226,13 +226,13 @@ BMP_PTR BITMAP::Code (void) { if (M) { - word i, cnt; + uint16 i, cnt; if (V) // old X-map exists, so remove it { switch (MemType(V)) { - case NEAR_MEM : delete[] (byte *) V; break; + case NEAR_MEM : delete[] (uint8 *) V; break; case FAR_MEM : farfree(V); break; } V = NULL; @@ -240,8 +240,8 @@ BMP_PTR BITMAP::Code (void) while (true) // at most 2 times: for (V == NULL) & for allocated block; { - byte * im = V+2; - word * cp = (word *) V; + uint8 * im = V+2; + uint16 * cp = (uint16 *) V; int bpl; if (V) // 2nd pass - fill the hide table @@ -254,14 +254,14 @@ BMP_PTR BITMAP::Code (void) } for (bpl = 0; bpl < 4; bpl ++) // once per each bitplane { - byte * bm = M; + uint8 * bm = M; bool skip = (bm[bpl] == TRANS); - word j; + uint16 j; cnt = 0; for (i = 0; i < H; i ++) // once per each line { - byte pix; + uint8 pix; for (j = bpl; j < W; j += 4) { pix = bm[j]; @@ -275,9 +275,9 @@ BMP_PTR BITMAP::Code (void) cnt |= (skip) ? SKP : CPY; if (V) { - *cp = cnt; // store block description word + *cp = cnt; // store block description uint16 } - cp = (word *) im; + cp = (uint16 *) im; im += 2; skip = (pix == TRANS); cnt = 0; @@ -304,7 +304,7 @@ BMP_PTR BITMAP::Code (void) { *cp = cnt; } - cp = (word *) im; + cp = (uint16 *) im; im += 2; skip = true; cnt = (SCR_WID - j + 3) / 4; @@ -318,16 +318,16 @@ BMP_PTR BITMAP::Code (void) { *cp = cnt; } - cp = (word *) im; + cp = (uint16 *) im; im += 2; } if (V) *cp = EOI; - cp = (word *) im; + cp = (uint16 *) im; im += 2; } if (V) break; - word sizV = (word) (im - 2 - V); - V = farnew(byte, sizV + H * sizeof(*B)); + uint16 sizV = (uint16) (im - 2 - V); + V = farnew(uint8, sizV + H * sizeof(*B)); if (! V) { DROP("No core", NULL); @@ -344,8 +344,8 @@ BMP_PTR BITMAP::Code (void) } else { - word s = B[i].skip & ~3; - word h = (B[i].hide + 3) & ~3; + uint16 s = B[i].skip & ~3; + uint16 h = (B[i].hide + 3) & ~3; B[i].skip = (cnt + s) >> 2; B[i].hide = (h - s) >> 2; cnt = SCR_WID - h; @@ -362,8 +362,8 @@ BMP_PTR BITMAP::Code (void) bool BITMAP::SolidAt (int x, int y) { - byte * m; - word r, n, n0; + uint8 * m; + uint16 r, n, n0; if (x >= W || y >= H) return false; @@ -373,9 +373,9 @@ bool BITMAP::SolidAt (int x, int y) while (r) { - word w, t; + uint16 w, t; - w = * (word *) m; + w = * (uint16 *) m; m += 2; t = w & 0xC000; w &= 0x3FFF; @@ -391,9 +391,9 @@ bool BITMAP::SolidAt (int x, int y) while (true) { - word w, t; + uint16 w, t; - w = * (word *) m; + w = * (uint16 *) m; m += 2; t = w & 0xC000; w &= 0x3FFF; @@ -418,13 +418,13 @@ bool BITMAP::SolidAt (int x, int y) bool BITMAP::VBMSave (XFILE * f) { - word p = (Pal != NULL), - n = ((word) (((byte *)B) - V)) + H * sizeof(HideDesc); - if (f->Error == 0) f->Write((byte *)&p, sizeof(p)); - if (f->Error == 0) f->Write((byte *)&n, sizeof(n)); - if (f->Error == 0) f->Write((byte *)&W, sizeof(W)); - if (f->Error == 0) f->Write((byte *)&H, sizeof(H)); - if (f->Error == 0) if (p) f->Write((byte *)Pal, 256 * sizeof(DAC)); + uint16 p = (Pal != NULL), + n = ((uint16) (((uint8 *)B) - V)) + H * sizeof(HideDesc); + if (f->Error == 0) f->Write((uint8 *)&p, sizeof(p)); + if (f->Error == 0) f->Write((uint8 *)&n, sizeof(n)); + if (f->Error == 0) f->Write((uint8 *)&W, sizeof(W)); + if (f->Error == 0) f->Write((uint8 *)&H, sizeof(H)); + if (f->Error == 0) if (p) f->Write((uint8 *)Pal, 256 * sizeof(DAC)); if (f->Error == 0) f->Write(V, n); return (f->Error == 0); } @@ -435,20 +435,20 @@ bool BITMAP::VBMSave (XFILE * f) bool BITMAP::VBMLoad (XFILE * f) { - word p, n; - if (f->Error == 0) f->Read((byte *)&p, sizeof(p)); - if (f->Error == 0) f->Read((byte *)&n, sizeof(n)); - if (f->Error == 0) f->Read((byte *)&W, sizeof(W)); - if (f->Error == 0) f->Read((byte *)&H, sizeof(H)); + uint16 p, n; + if (f->Error == 0) f->Read((uint8 *)&p, sizeof(p)); + if (f->Error == 0) f->Read((uint8 *)&n, sizeof(n)); + if (f->Error == 0) f->Read((uint8 *)&W, sizeof(W)); + if (f->Error == 0) f->Read((uint8 *)&H, sizeof(H)); if (f->Error == 0) { if (p) { - if (Pal) f->Read((byte *)Pal, 256 * sizeof(DAC)); + if (Pal) f->Read((uint8 *)Pal, 256 * sizeof(DAC)); else f->Seek(f->Mark() + 256 * sizeof(DAC)); } } - if ((V = farnew(byte, n)) == NULL) return false; + if ((V = farnew(uint8, n)) == NULL) return false; if (f->Error == 0) f->Read(V, n); B = (HideDesc *) (V + n - H * sizeof(HideDesc)); return (f->Error == 0); diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index de2214fd63..2ce849cc2b 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -38,17 +38,17 @@ #define TRANS 0xFE -typedef struct { word b : 2; - word B : 6; - word g : 2; - word G : 6; - word r : 2; - word R : 6; - word Z : 8; +typedef struct { uint16 b : 2; + uint16 B : 6; + uint16 g : 2; + uint16 G : 6; + uint16 r : 2; + uint16 R : 6; + uint16 Z : 8; } BGR4; -typedef struct { word skip; word hide; } HideDesc; +typedef struct { uint16 skip; uint16 hide; } HideDesc; @@ -59,11 +59,11 @@ class BITMAP bool VBMLoad (XFILE * f); public: static DAC * Pal; - word W, H; - byte * M, * V; HideDesc * B; + uint16 W, H; + uint8 * M, * V; HideDesc * B; BITMAP (const char * fname, bool rem = true); - BITMAP (word w, word h, byte * map); - BITMAP (word w, word h, byte fill); + BITMAP (uint16 w, uint16 h, uint8 * map); + BITMAP (uint16 w, uint16 h, uint8 fill); BITMAP (const BITMAP& bmp); ~BITMAP (void); BITMAP * FlipH (void); @@ -74,7 +74,7 @@ public: void XShow (int x, int y); bool SolidAt (int x, int y); bool VBMSave (XFILE * f); - word MoveVmap (byte * buf); + uint16 MoveVmap (uint8 * buf); }; diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp index 4749430c5b..0cdae18cab 100644 --- a/engines/cge/bitmaps.cpp +++ b/engines/cge/bitmaps.cpp @@ -36,7 +36,7 @@ #define G GRAY, #define D DGRAY, -static byte MCDesign0[]= { W W W W W W _ +static uint8 MCDesign0[]= { W W W W W W _ W W W W W o _ W W W W o _ _ W W W W W _ _ @@ -46,11 +46,11 @@ static byte MCDesign0[]= { W W W W W W _ _ _ _ _ _ o o }; -static byte MCDesign1[]= { _ }; +static uint8 MCDesign1[]= { _ }; -static byte SLDesign[] = { G G G G G G G G G _ _ _ _ _ _ +static uint8 SLDesign[] = { G G G G G G G G G _ _ _ _ _ _ L G G G G G G G G D _ _ _ _ _ _ L G G G G G G G D _ _ _ _ _ _ _ L G G G G G G G D _ _ _ _ @@ -68,7 +68,7 @@ static byte SLDesign[] = { G G G G G G G G G _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ D }; -static byte SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G +static uint8 SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G _ _ _ _ _ L G G G G G G G G D _ _ _ _ _ L G G G G G G G D _ _ _ _ _ L G G G G G G G D _ _ @@ -86,7 +86,7 @@ static byte SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G D _ _ _ _ _ _ _ _ _ _ _ _ _ _ }; -static byte MapBrick[] = { L L L L L L L G +static uint8 MapBrick[] = { L L L L L L L G L G G G G G G D L G G G G G G D G D D D D D D D @@ -110,7 +110,7 @@ static byte MapBrick[] = { L L L L L L L G #define D 219, #define E 231, -static byte PRDesign[] = { A E E E C C D A B +static uint8 PRDesign[] = { A E E E C C D A B C _ _ _ _ _ _ D A C _ _ _ _ _ _ D A C _ _ _ _ _ _ D A @@ -131,7 +131,7 @@ static byte PRDesign[] = { A E E E C C D A B #define E 231, #define F 237, -static byte PRDesign[] = { D D D D D D D D _ +static uint8 PRDesign[] = { D D D D D D D D _ D D D D D D D D _ D _ _ _ _ _ _ _ _ D _ _ _ _ _ _ _ _ @@ -159,7 +159,7 @@ static byte PRDesign[] = { D D D D D D D D _ #define A _ x _ x _ x _ x #define B A A A A A A A A -static byte HLDesign[] = { B B B B B }; +static uint8 HLDesign[] = { B B B B B }; #undef _ #undef x @@ -178,7 +178,7 @@ static byte HLDesign[] = { B B B B B }; #define D 226, #define E 255, -static byte LIDesign[][9] = { { A A A +static uint8 LIDesign[][9] = { { A A A A B A A A A }, @@ -206,7 +206,7 @@ static byte LIDesign[][9] = { { A A A #define G 0, //226, -static byte MEDesign[][9] = { { R R R R R R R R R }, // 0 +static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 { R R R R R R R R G }, // 1 { R R R R R R R G G }, // 2 { R R R R R R G G G }, // 3 diff --git a/engines/cge/boot.h b/engines/cge/boot.h index 1715fd02ec..3a22e89661 100644 --- a/engines/cge/boot.h +++ b/engines/cge/boot.h @@ -40,36 +40,36 @@ #endif typedef struct { - byte Jmp[3]; // NEAR jump machine code + uint8 Jmp[3]; // NEAR jump machine code char OEM_ID[8]; // OEM name and version - word SectSize; // bytes per sector - byte ClustSize; // sectors per cluster - word ResSecs; // sectors before 1st FAT - byte FatCnt; // number of FATs - word RootSize; // root directory entries - word TotSecs; // total sectors on disk - byte Media; // media descriptor byte - word FatSize; // sectors per FAT - word TrkSecs; // sectors per track - word HeadCnt; // number of sufraces - word HidnSecs; // special hidden sectors - word _; // (unknown: reserved?) - dword lTotSecs; // total number of sectors - word DriveNum; // physical drive number - byte XSign; // extended boot signature - dword Serial; // volume serial number + uint16 SectSize; // bytes per sector + uint8 ClustSize; // sectors per cluster + uint16 ResSecs; // sectors before 1st FAT + uint8 FatCnt; // number of FATs + uint16 RootSize; // root directory entries + uint16 TotSecs; // total sectors on disk + uint8 Media; // media descriptor byte + uint16 FatSize; // sectors per FAT + uint16 TrkSecs; // sectors per track + uint16 HeadCnt; // number of sufraces + uint16 HidnSecs; // special hidden sectors + uint16 _; // (unknown: reserved?) + uint32 lTotSecs; // total number of sectors + uint16 DriveNum; // physical drive number + uint8 XSign; // extended boot signature + uint32 Serial; // volume serial number char Label[11]; // volume label char FileSysID[8]; // file system ID char Code[BOOTCODE_SIZ-8]; // 8 = length of following - dword Secret; // long secret number - byte BootCheck; // boot sector checksum - byte BootFlags; // secret flags - word BootSig; // boot signature 0xAA55 + uint32 Secret; // long secret number + uint8 BootCheck; // boot sector checksum + uint8 BootFlags; // secret flags + uint16 BootSig; // boot signature 0xAA55 } Boot; EC Boot * ReadBoot (int drive); -EC byte CheckBoot (Boot * boot); +EC uint8 CheckBoot (Boot * boot); EC bool WriteBoot (int drive, Boot * boot); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 7d222d101d..efc922b232 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -48,7 +48,7 @@ IOBUF::IOBUF (IOMODE mode, CRYPT * crpt) Ptr(0), Lim(0) { - Buff = farnew(byte, IOBUF_SIZE); + Buff = farnew(uint8, IOBUF_SIZE); if (Buff == NULL) DROP("No core for I/O", NULL); } @@ -66,7 +66,7 @@ IOBUF::IOBUF (const char * name, IOMODE mode, CRYPT * crpt) Ptr(0), Lim(0) { - Buff = farnew(byte, IOBUF_SIZE); + Buff = farnew(uint8, IOBUF_SIZE); if (Buff == NULL) DROP("No core for I/O", name); } @@ -114,18 +114,18 @@ void IOBUF::WriteBuff (void) -word IOBUF::Read (void *buf, word len) +uint16 IOBUF::Read (void *buf, uint16 len) { - word total = 0; + uint16 total = 0; while (len) { if (Ptr >= Lim) ReadBuff(); - word n = Lim - Ptr; + uint16 n = Lim - Ptr; if (n) { if (len < n) n = len; _fmemcpy(buf, Buff+Ptr, n); - (byte *) buf += n; + (uint8 *) buf += n; len -= n; total += n; Ptr += n; @@ -140,25 +140,25 @@ word IOBUF::Read (void *buf, word len) -word IOBUF::Read (byte * buf) +uint16 IOBUF::Read (uint8 * buf) { - word total = 0; + uint16 total = 0; while (total < LINE_MAX-2) { if (Ptr >= Lim) ReadBuff(); - byte * p = Buff + Ptr; - word n = Lim - Ptr; + uint8 * p = Buff + Ptr; + uint16 n = Lim - Ptr; if (n) { if (total + n >= LINE_MAX-2) n = LINE_MAX-2 - total; - byte * eol = (byte *) _fmemchr(p, '\r', n); - if (eol) n = (word) (eol - p); - byte * eof = (byte *) _fmemchr(p, '\32', n); + uint8 * eol = (uint8 *) _fmemchr(p, '\r', n); + if (eol) n = (uint16) (eol - p); + uint8 * eof = (uint8 *) _fmemchr(p, '\32', n); if (eof) // end-of-file { - n = (word) (eof - p); - Ptr = (word) (eof - Buff); + n = (uint16) (eof - p); + Ptr = (uint16) (eof - Buff); } if (n) _fmemcpy(buf, p, n); buf += n; @@ -187,19 +187,19 @@ word IOBUF::Read (byte * buf) -word IOBUF::Write (void * buf, word len) +uint16 IOBUF::Write (void * buf, uint16 len) { - word tot = 0; + uint16 tot = 0; while (len) { - word n = IOBUF_SIZE - Lim; + uint16 n = IOBUF_SIZE - Lim; if (n > len) n = len; if (n) { _fmemcpy(Buff+Lim, buf, n); Lim += n; len -= n; - (byte *) buf += n; + (uint8 *) buf += n; tot += n; } else WriteBuff(); @@ -212,9 +212,9 @@ word IOBUF::Write (void * buf, word len) -word IOBUF::Write (byte * buf) +uint16 IOBUF::Write (uint8 * buf) { - word len = 0; + uint16 len = 0; if (buf) { len = _fstrlen((const char *) buf); @@ -223,7 +223,7 @@ word IOBUF::Write (byte * buf) if (len) { static char EOL[] = "\r\n"; - word n = Write(EOL, sizeof(EOL)-1); + uint16 n = Write(EOL, sizeof(EOL)-1); len += n; } } @@ -250,7 +250,7 @@ int IOBUF::Read (void) -void IOBUF::Write (byte b) +void IOBUF::Write (uint8 b) { if (Lim >= IOBUF_SIZE) { @@ -264,7 +264,7 @@ void IOBUF::Write (byte b) - word CFILE::MaxLineLen = LINE_MAX; + uint16 CFILE::MaxLineLen = LINE_MAX; @@ -321,7 +321,7 @@ long CFILE::Seek (long pos) { if (pos >= BufMark && pos < BufMark + Lim) { - ((Mode == REA) ? Ptr : Lim) = (word) (pos - BufMark); + ((Mode == REA) ? Ptr : Lim) = (uint16) (pos - BufMark); return pos; } else diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 5903d605ed..bbb45a9e85 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -38,7 +38,7 @@ #define IOBUF_SIZE K(2) #endif -#define CFREAD(x) Read((byte *)(x),sizeof(*(x))) +#define CFREAD(x) Read((uint8 *)(x),sizeof(*(x))) @@ -46,10 +46,10 @@ class IOBUF : public IOHAND { protected: - byte * Buff; - word Ptr, Lim; + uint8 * Buff; + uint16 Ptr, Lim; long BufMark; - word Seed; + uint16 Seed; CRYPT * Crypt; virtual void ReadBuff (void); virtual void WriteBuff (void); @@ -57,12 +57,12 @@ public: IOBUF (IOMODE mode, CRYPT * crpt = NULL); IOBUF (const char * name, IOMODE mode, CRYPT * crpt = NULL); virtual ~IOBUF (void); - word Read (void * buf, word len); - word Read (char * buf); + uint16 Read (void * buf, uint16 len); + uint16 Read (char * buf); int Read (void); - word Write (void * buf, word len); - word Write (byte * buf); - void Write (byte b); + uint16 Write (void * buf, uint16 len); + uint16 Write (uint8 * buf); + void Write (uint8 b); }; @@ -70,7 +70,7 @@ public: class CFILE : public IOBUF { public: - static word MaxLineLen; + static uint16 MaxLineLen; CFILE (const char * name, IOMODE mode = REA, CRYPT * crpt = NULL); virtual ~CFILE (void); void Flush (void); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 1f621948c2..d8829247a4 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -74,7 +74,7 @@ #define SVG0FILE INI_FILE #endif -extern word _stklen = (STACK_SIZ * 2); +extern uint16 _stklen = (STACK_SIZ * 2); // 0.75 - 17II95 - full sound support // 0.76 - 18II95 - small MiniEMS in DEMO, @@ -137,14 +137,14 @@ static SPRITE * MiniCave = NULL; static SPRITE * Shadow = NULL; static VGA Vga = M13H; -static EMS * Mini = MiniEmm.Alloc((word)MINI_EMM_SIZE); +static EMS * Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE); static BMP_PTR * MiniShpList = NULL; static BMP_PTR MiniShp[] = { NULL, NULL }; static KEYBOARD Keyboard; static bool Finis = false; static int Startup = 1; static int OffUseCount = atoi(Text[OFF_USE_COUNT]); - word *intStackPtr = false; + uint16 *intStackPtr = false; HXY HeroXY[CAVE_MAX] = {{0,0}}; @@ -168,11 +168,11 @@ void FeedSnail (SPRITE * spr, SNLIST snq); // defined in SNAIL -byte CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; +uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; -byte & CLUSTER::Cell (void) +uint8 & CLUSTER::Cell (void) { return Map[B][A]; } @@ -189,7 +189,7 @@ bool CLUSTER::Protected (void) if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return true; _DX = (MAP_ZCNT << 8) + MAP_XCNT; - _BX = (word) this; + _BX = (uint16) this; asm mov ax,1 asm mov cl,[bx].(COUPLE)A @@ -209,7 +209,7 @@ bool CLUSTER::Protected (void) asm xor ch,ch asm add ax,cx asm mov bx,ax - _BX += (word) Map; + _BX += (uint16) Map; //asm add bx,offset CLUSTER::Map asm mov al,[bx] asm and ax,0xFF @@ -252,8 +252,8 @@ CLUSTER XZ (COUPLE xy) int pocref[POCKET_NX]; - byte volume[2]; - struct SAVTAB { void * Ptr; int Len; byte Flg; } SavTab[] = + uint8 volume[2]; + struct SAVTAB { void * Ptr; int Len; uint8 Flg; } SavTab[] = {{ &Now, sizeof(Now), 1 }, { &OldLev, sizeof(OldLev), 1 }, { &DemoText, sizeof(DemoText), 1 }, @@ -285,10 +285,10 @@ static void LoadGame (XFILE& file, bool tiny = false) for (st = SavTab; st->Ptr; st ++) { if (file.Error) VGA::Exit("Bad SVG"); - file.Read((byte *) ((tiny || st->Flg) ? st->Ptr : &i), st->Len); + file.Read((uint8 *) ((tiny || st->Flg) ? st->Ptr : &i), st->Len); } - file.Read((byte *) &i, sizeof(i)); + file.Read((uint8 *) &i, sizeof(i)); if (i != SVGCHKSUM) VGA::Exit(BADSVG_TEXT); if (STARTUP::Core < CORE_HIG) Music = false; if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) @@ -303,7 +303,7 @@ static void LoadGame (XFILE& file, bool tiny = false) while (! file.Error) { SPRITE S(NULL); - word n = file.Read((byte *) &S, sizeof(S)); + uint16 n = file.Read((uint8 *) &S, sizeof(S)); if (n != sizeof(S)) break; S.Prev = S.Next = NULL; @@ -354,14 +354,14 @@ static void SaveGame (XFILE& file) for (st = SavTab; st->Ptr; st ++) { if (file.Error) VGA::Exit("Bad SVG"); - file.Write((byte *) st->Ptr, st->Len); + file.Write((uint8 *) st->Ptr, st->Len); } - file.Write((byte *) &(i = SVGCHKSUM), sizeof(i)); + file.Write((uint8 *) &(i = SVGCHKSUM), sizeof(i)); for (spr = VGA::SpareQ.First(); spr; spr = spr->Next) if (spr->Ref >= 1000) - if (!file.Error) file.Write((byte *)spr, sizeof(*spr)); + if (!file.Error) file.Write((uint8 *)spr, sizeof(*spr)); } @@ -435,7 +435,7 @@ static void LoadMapping (void) { memset(CLUSTER::Map, 0, sizeof(CLUSTER::Map)); cf.Seek((Now - 1) * sizeof(CLUSTER::Map)); - cf.Read((byte *) CLUSTER::Map, sizeof(CLUSTER::Map)); + cf.Read((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); } } } @@ -579,7 +579,7 @@ void WALK::Park (void) void WALK::FindWay (CLUSTER c) { bool Find1Way(void); - extern word Target; + extern uint16 Target; if (c != Here) { @@ -670,7 +670,7 @@ class SQUARE : public SPRITE { public: SQUARE (void); - void Touch (word mask, int x, int y); + void Touch (uint16 mask, int x, int y); }; @@ -692,7 +692,7 @@ SQUARE::SQUARE (void) -void SQUARE::Touch (word mask, int x, int y) +void SQUARE::Touch (uint16 mask, int x, int y) { SPRITE::Touch(mask, x, y); if (mask & L_UP) @@ -865,7 +865,7 @@ void SYSTEM::SetPal (void) void SYSTEM::FunTouch (void) { - word n = (PAIN) ? HEROFUN1 : HEROFUN0; + uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0; if (Talk == NULL || n > FunDel) FunDel = n; } @@ -1038,7 +1038,7 @@ void SwitchCave (int cav) -void SYSTEM::Touch (word mask, int x, int y) +void SYSTEM::Touch (uint16 mask, int x, int y) { static int pp = 0; void SwitchCave (int cav); @@ -1426,7 +1426,7 @@ static void SaveMapping (void) if (! cf.Error) { cf.Seek((Now-1) * sizeof(CLUSTER::Map)); - cf.Write((byte *) CLUSTER::Map, sizeof(CLUSTER::Map)); + cf.Write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); } } { @@ -1435,7 +1435,7 @@ static void SaveMapping (void) { HeroXY[Now-1].X = Hero->X; HeroXY[Now-1].Y = Hero->Y; - cf.Write((byte *) HeroXY, sizeof(HeroXY)); + cf.Write((uint8 *) HeroXY, sizeof(HeroXY)); } } } @@ -1490,8 +1490,8 @@ static void SayDebug (void) if (t1 - t >= 18) { - static dword old = 0L; - dword now = Vga.FrmCnt; + static uint32 old = 0L; + uint32 now = Vga.FrmCnt; dwtom(now - old, FRPS, 10, 4); old = now; t = t1; @@ -1503,7 +1503,7 @@ static void SayDebug (void) dwtom(farcoreleft(), FFRE, 10, 6); // sprite queue size - word n = 0; + uint16 n = 0; SPRITE * spr; for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { @@ -1517,7 +1517,7 @@ static void SayDebug (void) dwtom(Sprite->Z, SP_Z, 10, 3); dwtom(Sprite->W, SP_W, 10, 3); dwtom(Sprite->H, SP_H, 10, 3); - dwtom(*(word *) (&Sprite->Flags), SP_F, 16, 2); + dwtom(*(uint16 *) (&Sprite->Flags), SP_F, 16, 2); } } dwtom(n, SP_S, 10, 2); @@ -1544,7 +1544,7 @@ static void SwitchDebug (void) -static void OptionTouch (int opt, word mask) +static void OptionTouch (int opt, uint16 mask) { switch (opt) { @@ -1567,7 +1567,7 @@ static void OptionTouch (int opt, word mask) #pragma argsused -void SPRITE::Touch (word mask, int x, int y) +void SPRITE::Touch (uint16 mask, int x, int y) { SYSTEM::FunTouch(); if ((mask & ATTN) == 0) @@ -1678,7 +1678,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro bool port = false; bool tran = false; int i, lcnt = 0; - word len; + uint16 len; MergeExt(line, fname, SPR_EXT); if (INI_FILE::Exist(line)) // sprite description file exist @@ -1910,7 +1910,7 @@ static void MainLoop (void) #ifdef DEMO #define TIM ((182L*6L) * 5L) - static dword tc = 0; + static uint32 tc = 0; if (TimerCount - tc >= TIM && Talk == NULL && Snail.Idle()) { if (Text[DemoText]) @@ -1998,7 +1998,7 @@ static void RunGame (void) if (Mini && INI_FILE::Exist("MINI.SPR")) { - byte * ptr = (byte *) &*Mini; + uint8 * ptr = (uint8 *) &*Mini; if (ptr != NULL) { LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); @@ -2159,7 +2159,7 @@ bool ShowTitle (const char * name) STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; #else Boot * b = ReadBoot(getdisk()); - dword sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; + uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; free(b); sn -= ((IDENT *)Copr)->disk; STARTUP::Summa |= Lo(sn) | Hi(sn); @@ -2217,7 +2217,7 @@ bool ShowTitle (const char * name) void StkDump (void) { CFILE f("!STACK.DMP", BFW); - f.Write((byte *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2); + f.Write((uint8 *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2); } #endif */ @@ -2227,7 +2227,7 @@ void StkDump (void) void cge_main (void) { - word intStack[STACK_SIZ/2]; + uint16 intStack[STACK_SIZ/2]; intStackPtr = intStack; //Debug( memset((void *) (-K(2)), 0, K(1)); ) @@ -2240,7 +2240,7 @@ void cge_main (void) Debug( DebugLine.Flags.Hide = true; ) Debug( HorzLine.Flags.Hide = true; ) - srand((word) Timer()); + srand((uint16) Timer()); Sys = new SYSTEM; if (Music && STARTUP::SoundOk) LoadMIDI(0); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 4f610897b1..c1155eb650 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -148,7 +148,7 @@ public: static void SetPal (void); static void FunTouch (void); SYSTEM (void) : SPRITE(NULL) { SetPal(); Tick(); } - void Touch (word mask, int x, int y); + void Touch (uint16 mask, int x, int y); void Tick (void); }; @@ -163,8 +163,8 @@ public: class CLUSTER : public COUPLE { public: - static byte Map[MAP_ZCNT][MAP_XCNT]; - byte &Cell (void); + static uint8 Map[MAP_ZCNT][MAP_XCNT]; + uint8 &Cell (void); CLUSTER (void) : COUPLE () { } CLUSTER (int a, int b) : COUPLE (a, b) { } bool Protected (void); diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 620e988c36..cc80a8f7fa 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -34,17 +34,17 @@ -byte * Glass (DAC * pal, byte r, byte g, byte b) +uint8 * Glass (DAC * pal, uint8 r, uint8 g, uint8 b) { - byte * x = new byte[256]; + uint8 * x = new uint8[256]; if (x) { - word i; + uint16 i; for (i = 0; i < 256; i ++) { - x[i] = Closest(pal, MkDAC(((word)(pal[i].R) * r) / 255, - ((word)(pal[i].G) * g) / 255, - ((word)(pal[i].B) * b) / 255)); + x[i] = Closest(pal, MkDAC(((uint16)(pal[i].R) * r) / 255, + ((uint16)(pal[i].G) * g) / 255, + ((uint16)(pal[i].B) * b) / 255)); } } return x; @@ -54,13 +54,13 @@ byte * Glass (DAC * pal, byte r, byte g, byte b) -byte * Mark (DAC * pal) +uint8 * Mark (DAC * pal) { #define f(c) (c ^ 63) - byte * x = new byte[256]; + uint8 * x = new uint8[256]; if (x) { - word i; + uint16 i; for (i = 0; i < 256; i ++) { x[i] = Closest(pal, MkDAC(f(pal[i].R), diff --git a/engines/cge/game.h b/engines/cge/game.h index 7a5efd9844..cda24512e3 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -44,8 +44,8 @@ extern SPRITE * Sys; int Sinus (long x); -byte * Glass (DAC * pal, byte r, byte g, byte b); -byte * Mark (DAC * pal); +uint8 * Glass (DAC * pal, uint8 r, uint8 g, uint8 b); +uint8 * Mark (DAC * pal); diff --git a/engines/cge/general.h b/engines/cge/general.h index 03c34d7058..75f754d0a3 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -35,10 +35,10 @@ #define SCR_WID_ 320 #define SCR_HIG_ 200 -#define SCR_WID ((word)SCR_WID_) -#define SCR_HIG ((word)SCR_HIG_) +#define SCR_WID ((uint16)SCR_WID_) +#define SCR_HIG ((uint16)SCR_HIG_) #define SCR_SEG 0xA000 -#define SCR_ADR ((byte *) MK_FP(SCR_SEG, 0)) +#define SCR_ADR ((uint8 *) MK_FP(SCR_SEG, 0)) @@ -48,10 +48,10 @@ enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT }; enum IOMODE { REA, WRI, UPD }; typedef struct { - byte R, G, B; + uint8 R, G, B; } DAC; -typedef word CRYPT (void *buf, word siz, word seed); +typedef uint16 CRYPT (void *buf, uint16 siz, uint16 seed); @@ -86,7 +86,7 @@ protected: static void interrupt (* OldTimer) (...); static void interrupt NewTimer (...); public: - ENGINE (word tdiv); + ENGINE (uint16 tdiv); ~ENGINE (void); }; @@ -111,7 +111,7 @@ class EMM public: EMM::EMM (long size = 0); EMM::~EMM (void); - EMS * Alloc (word siz); + EMS * Alloc (uint16 siz); void Release (void); }; @@ -124,12 +124,12 @@ class EMS friend EMM; EMM * Emm; long Ptr; - word Siz; + uint16 Siz; EMS * Nxt; public: EMS (void); void * operator & () const; - word Size (void); + uint16 Size (void); }; @@ -181,11 +181,11 @@ class XFILE { public: IOMODE Mode; - word Error; + uint16 Error; XFILE (void) : Mode(REA), Error(0) { } XFILE (IOMODE mode) : Mode(mode), Error(0) { } - virtual word Read (void * buf, word len) = 0; - virtual word Write (void * buf, word len) = 0; + virtual uint16 Read (void * buf, uint16 len) = 0; + virtual uint16 Write (void * buf, uint16 len) = 0; virtual long Mark (void) = 0; virtual long Size (void) = 0; virtual long Seek (long pos) = 0; @@ -196,9 +196,9 @@ public: template -inline word XRead (XFILE * xf, T * t) +inline uint16 XRead (XFILE * xf, T * t) { - return xf->Read((byte *) t, sizeof(*t)); + return xf->Read((uint8 *) t, sizeof(*t)); }; @@ -209,15 +209,15 @@ class IOHAND : public XFILE { protected: int Handle; - word Seed; + uint16 Seed; CRYPT * Crypt; public: IOHAND (const char * name, IOMODE mode = REA, CRYPT crypt = NULL); IOHAND (IOMODE mode = REA, CRYPT * crpt = NULL); virtual ~IOHAND (void); static bool Exist (const char * name); - word Read (void * buf, word len); - word Write (void * buf, word len); + uint16 Read (void * buf, uint16 len); + uint16 Write (void * buf, uint16 len); long Mark (void); long Size (void); long Seek (long pos); @@ -238,18 +238,18 @@ unsigned FastRand (void); unsigned FastRand (unsigned s); CPU Cpu (void); ALLOC_MODE SetAllocMode (ALLOC_MODE am); -word atow (const char * a); -word xtow (const char * x); -char * wtom (word val, char * str, int radix, int len); -char * dwtom (dword val, char * str, int radix, int len); +uint16 atow (const char * a); +uint16 xtow (const char * x); +char * wtom (uint16 val, char * str, int radix, int len); +char * dwtom (uint32 val, char * str, int radix, int len); char * DateTimeString (void); void StdLog (const char *msg, const char *nam = NULL); -void StdLog (const char *msg, word w); -void StdLog (const char *msg, dword d); +void StdLog (const char *msg, uint16 w); +void StdLog (const char *msg, uint32 d); int TakeEnum (const char ** tab, const char * txt); -word ChkSum (void *m, word n); +uint16 ChkSum (void *m, uint16 n); long Timer (void); -long TimerLimit (word t); +long TimerLimit (uint16 t); bool TimerLimitGone (long t); char * MergeExt (char * buf, const char * nam, const char * ext); char * ForceExt (char * buf, const char * nam, const char * ext); @@ -260,7 +260,7 @@ int DriveRemote (unsigned drv); int DriveCD (unsigned drv); bool IsVga (void); -EC void _fqsort (void *base, word nelem, word width, +EC void _fqsort (void *base, uint16 nelem, uint16 width, int (*fcmp)(const void*, const void*)); diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index ad9f885bb9..623374fe7d 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -86,7 +86,7 @@ void GET_TEXT::Tick (void) -void GET_TEXT::Touch (word mask, int x, int y) +void GET_TEXT::Touch (uint16 mask, int x, int y) { static char ogon[] = "•œ¥£˜ ¡"; static char bezo[] = "ACELNOSXZ"; diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index 2fbd6f5da6..d08e09a5bb 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -45,15 +45,15 @@ class GET_TEXT : public TALK { char Buff[GTMAX+2], * Text; - word Size, Len; - word Cntr; + uint16 Size, Len; + uint16 Cntr; SPRITE * OldKeybClient; void (*Click)(void); public: static GET_TEXT * Ptr; GET_TEXT (const char * info, char * text, int size, void (*click)(void) = NULL); ~GET_TEXT (void); - void Touch (word mask, int x, int y); + void Touch (uint16 mask, int x, int y); void Tick (void); }; diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 22110bc832..8776004273 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -51,19 +51,12 @@ #define ArrayCount(a) (sizeof(a)/sizeof((a)[0])) #define MAX_TIMER 0x1800B0L -typedef unsigned char BYTE; -typedef unsigned int WORD; -typedef unsigned long DWORD; - -typedef unsigned char byte; -typedef unsigned int word; -typedef unsigned long dword; typedef void (_loadds MouseFunType)(void); #define Lo(d) (((int *) &d)[0]) #define Hi(d) (((int *) &d)[1]) -#define LoWord(d) ((word) Lo(d)) -#define HiWord(d) ((word) Hi(d)) +#define LoWord(d) ((uint16) Lo(d)) +#define HiWord(d) ((uint16) Hi(d)) #define K(n) (1024*(n)) #define MASK(n) ((1<= H-MIX_BHIG) { if (*vol > 0x00) *vol -= 0x11; } Update(); diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index e2377ff781..c770f0a794 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -49,7 +49,7 @@ public: static bool Appear; MIXER (int x, int y); ~MIXER (void); - void Touch (word mask, int x, int y); + void Touch (uint16 mask, int x, int y); void Tick (void); }; diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 5fdaf08995..3c17e3632c 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -33,11 +33,11 @@ EVENT Evt[EVT_MAX]; - word EvtHead = 0, EvtTail = 0; + uint16 EvtHead = 0, EvtTail = 0; //-------------------------------------------------------------------------- MOUSE_FUN * MOUSE::OldMouseFun = NULL; -word MOUSE::OldMouseMask = 0; +uint16 MOUSE::OldMouseMask = 0; @@ -151,7 +151,7 @@ void MOUSE::ClrEvt (SPRITE * spr) { if (spr) { - word e; + uint16 e; for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) if (Evt[e].Ptr == spr) Evt[e].Msk = 0; } diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index e30abcaa94..42a6bf6c21 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -45,12 +45,12 @@ extern TALK * Talk; -struct EVENT { word Msk; - word X, Y; +struct EVENT { uint16 Msk; + uint16 X, Y; SPRITE * Ptr; }; extern EVENT Evt[EVT_MAX]; -extern word EvtHead, EvtTail; +extern uint16 EvtHead, EvtTail; typedef void (MOUSE_FUN) (void); @@ -61,7 +61,7 @@ class MOUSE : public SPRITE { static MOUSE_FUN * OldMouseFun; static MOUSE_FUN NewMouseFun; - static word OldMouseMask; + static uint16 OldMouseMask; SPRITE * Hold; int hx, hy; //void SetFun (void); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 06824c5b12..4c15dc6a0c 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -394,7 +394,7 @@ void FeedSnail (SPRITE * spr, SNLIST snq) { if (spr) if (spr->Active()) { - byte ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; + uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; if (ptr != NO_PTR) { @@ -425,7 +425,7 @@ void FeedSnail (SPRITE * spr, SNLIST snq) SPRITE * s = (c->Ref < 0) ? spr : Locate(c->Ref); if (s) { - byte * idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr; + uint8 * idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr; if (*idx != NO_PTR) { int v; @@ -818,7 +818,7 @@ void SNSetY0 (int cav, int y0) -void SNSetXY (SPRITE * spr, word xy) +void SNSetXY (SPRITE * spr, uint16 xy) { if (spr) { @@ -1130,7 +1130,7 @@ static void SNLight (bool in) static void SNBarrier (int cav, int bar, bool horz) { - ((byte *) (Barriers + ((cav > 0) ? cav : Now)))[horz] = bar; + ((uint8 *) (Barriers + ((cav > 0) ? cav : Now)))[horz] = bar; } @@ -1178,7 +1178,7 @@ void SNAIL::RunCom (void) if (! Busy) { Busy = true; - byte tmphea = Head; + uint8 tmphea = Head; while (Tail != tmphea) { COM * snc = &SNList[Tail]; diff --git a/engines/cge/snail.h b/engines/cge/snail.h index f7e19290e6..b3268341d8 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -46,14 +46,14 @@ -typedef struct { byte Horz, Vert; } BAR; +typedef struct { uint8 Horz, Vert; } BAR; struct SCB { - byte * Ptr; - word Siz; + uint8 * Ptr; + uint16 Siz; SCB * Nxt; }; @@ -82,9 +82,9 @@ enum SNLIST { NEAR, TAKE }; class SNAIL { struct COM { SNCOM Com; int Ref; int Val; void * Ptr; } * SNList; - byte Head, Tail; + uint8 Head, Tail; bool Turbo, Busy, TextDelay; - word Pause; + uint16 Pause; public: static char * ComTxt[]; bool TalkEnable; diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index a445465dc8..809f73c3a7 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -58,23 +58,23 @@ struct DRVINFO { DEV_TYPE DDEV; // digi device DEV_TYPE MDEV; // midi device - WORD DBASE; // digi base port - WORD DDMA; // digi dma no - WORD DIRQ; // digi irq no - WORD MBASE; // midi base port + uint16 DBASE; // digi base port + uint16 DDMA; // digi dma no + uint16 DIRQ; // digi irq no + uint16 MBASE; // midi base port union { struct { - WORD DR : 4; - WORD DL : 4; - WORD MR : 4; - WORD ML : 4; + uint16 DR : 4; + uint16 DL : 4; + uint16 MR : 4; + uint16 ML : 4; } VOL4; struct { - BYTE D; // digi volume - BYTE M; // midi volume + uint8 D; // digi volume + uint8 M; // midi volume } VOL2; }; }; @@ -82,9 +82,9 @@ struct DRVINFO // sample info struct SMPINFO { - BYTE * saddr; // address - WORD slen; // length - WORD span; // left/right pan (0-15) + uint8 * saddr; // address + uint16 slen; // length + uint16 span; // left/right pan (0-15) int sflag; // flag }; @@ -95,10 +95,10 @@ struct SMPINFO extern DRVINFO SNDDrvInfo; // midi player flag (1 means we are playing) -extern WORD MIDIPlayFlag; +extern uint16 MIDIPlayFlag; // midi song end flag (1 means we have crossed end mark) -extern WORD MIDIEndFlag; +extern uint16 MIDIEndFlag; // ****************************************************** // * Driver Code * @@ -119,7 +119,7 @@ EC void SNDDigiStart (SMPINFO *PSmpInfo); EC void SNDDigiStop (SMPINFO *PSmpInfo); // Start MIDI File -EC void SNDMIDIStart (BYTE *MIDFile); +EC void SNDMIDIStart (uint8 *MIDFile); // Stop MIDI File EC void SNDMIDIStop (void); diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index b3c13a0211..03ba231fec 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -91,7 +91,7 @@ void SOUND::Play (DATACK * wav, int pan, int cnt) { Stop(); smpinf.saddr = (char *) &*(wav->EAddr()); - smpinf.slen = (word)wav->Size(); + smpinf.slen = (uint16)wav->Size(); smpinf.span = pan; smpinf.sflag = cnt; SNDDigiStart(&smpinf); @@ -246,7 +246,7 @@ DATACK * FX::operator [] (int ref) //------------------------------------------------------------------------- -static byte * midi = NULL; +static uint8 * midi = NULL; @@ -274,8 +274,8 @@ void LoadMIDI (int ref) INI_FILE mid = fn; if (mid.Error == 0) { - word siz = (word) mid.Size(); - midi = new byte[siz]; + uint16 siz = (uint16) mid.Size(); + midi = new uint8[siz]; if (midi) { mid.Read(midi, siz); @@ -303,8 +303,8 @@ EC void * Patch (int pat) INI_FILE snd = fn; if (! snd.Error) { - word siz = (word) snd.Size(); - p = (byte *) farmalloc(siz); + uint16 siz = (uint16) snd.Size(); + p = (uint8 *) farmalloc(siz); if (p) { snd.Read(p, siz); diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 5555c12b16..18fd06d1ec 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -54,7 +54,7 @@ static STARTUP StartUp; int STARTUP::Mode = 0; int STARTUP::Core; int STARTUP::SoundOk = 0; - word STARTUP::Summa; + uint16 STARTUP::Summa; @@ -75,7 +75,7 @@ bool STARTUP::get_parms (void) static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", "P", "D", "I", "M" }; int n = TakeEnum(PrmTab, strtok(_argv[--i], " =:(")); - word p = xtow(strtok(NULL, " h,)")); + uint16 p = xtow(strtok(NULL, " h,)")); switch (n) { case 0 : if (Mode != 2) Mode = 1; break; @@ -99,7 +99,7 @@ bool STARTUP::get_parms (void) #else #ifdef EVA { - union { dosdate_t d; dword n; } today; + union { dosdate_t d; uint32 n; } today; _dos_getdate(&today.d); id.disk += (id.disk < today.n); } @@ -120,7 +120,7 @@ bool STARTUP::get_parms (void) STARTUP::STARTUP (void) { - dword m = farcoreleft() >> 10; + uint32 m = farcoreleft() >> 10; if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF; if (! IsVga()) quit_now(NOT_VGA_TEXT); diff --git a/engines/cge/startup.h b/engines/cge/startup.h index 27507a7122..1c946508b5 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -64,7 +64,7 @@ public: static int Mode; static int Core; static int SoundOk; - static word Summa; + static uint16 Summa; STARTUP (void); }; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index d941dba274..822bc18de3 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -43,9 +43,9 @@ -//byte FONT::Wid[WID_SIZ]; -//word FONT::Pos[POS_SIZ]; -//byte FONT::Map[MAP_SIZ]; +//uint8 FONT::Wid[WID_SIZ]; +//uint16 FONT::Pos[POS_SIZ]; +//uint8 FONT::Map[MAP_SIZ]; @@ -55,9 +55,9 @@ FONT::FONT (const char * name) { - Map = farnew(byte, MAP_SIZ); - Pos = farnew(word, POS_SIZ); - Wid = farnew(byte, WID_SIZ); + Map = farnew(uint8, MAP_SIZ); + Pos = farnew(uint16, POS_SIZ); + Wid = farnew(uint8, WID_SIZ); if (Map == NULL || Pos == NULL || Wid == NULL) DROP("No core", NULL); MergeExt(Path, name, FONT_EXT); Load(); @@ -84,7 +84,7 @@ void FONT::Load (void) f.Read(Wid, WID_SIZ); if (! f.Error) { - word i, p = 0; + uint16 i, p = 0; for (i = 0; i < POS_SIZ; i ++) { Pos[i] = p; @@ -99,9 +99,9 @@ void FONT::Load (void) -word FONT::Width (const char * text) +uint16 FONT::Width (const char * text) { - word w = 0; + uint16 w = 0; if (text) while (* text) w += Wid[*(text ++)]; return w; } @@ -160,7 +160,7 @@ TALK::TALK (void) /* TALK::~TALK (void) { - word i; + uint16 i; for (i = 0; i < ShpCnt; i ++) { if (FP_SEG(ShpList[i]) != _DS) // small model: always false @@ -176,15 +176,15 @@ TALK::~TALK (void) void TALK::Update (const char * tx) { - word vmarg = (Mode) ? TEXT_VM : 0; - word hmarg = (Mode) ? TEXT_HM : 0; - word mw, mh, ln = vmarg; + uint16 vmarg = (Mode) ? TEXT_VM : 0; + uint16 hmarg = (Mode) ? TEXT_HM : 0; + uint16 mw, mh, ln = vmarg; const char * p; - byte * m; + uint8 * m; if (! TS[0]) { - word k = 2 * hmarg; + uint16 k = 2 * hmarg; mh = 2 * vmarg + FONT_HIG; mw = 0; for (p = tx; *p; p ++) @@ -214,8 +214,8 @@ void TALK::Update (const char * tx) for (i = 0; i < cw; i ++) { char * p = m; - word n; - register word b = * (f ++); + uint16 n; + register uint16 b = * (f ++); for (n = 0; n < FONT_HIG; n ++) { if (b & 1) * p = TEXT_FG; @@ -234,15 +234,15 @@ void TALK::Update (const char * tx) -BITMAP * TALK::Box (word w, word h) +BITMAP * TALK::Box (uint16 w, uint16 h) { - byte * b, * p, * q; - word n, r = (Mode == ROUND) ? TEXT_RD : 0; + uint8 * b, * p, * q; + uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0; int i; if (w < 8) w = 8; if (h < 8) h = 8; - b = farnew(byte, n = w * h); + b = farnew(uint8, n = w * h); if (! b) VGA::Exit("No core"); _fmemset(b, TEXT_BG, n); @@ -286,13 +286,13 @@ BITMAP * TALK::Box (word w, word h) void TALK::PutLine (int line, const char * text) // Note: (TS[0].W % 4) have to be 0 { - word w = TS[0]->W, h = TS[0]->H; - byte * v = TS[0]->V, * p; - word dsiz = w >> 2; // data size (1 plane line size) - word lsiz = 2 + dsiz + 2; // word for line header, word for gap - word psiz = h * lsiz; // - last gap, but + plane trailer - word size = 4 * psiz; // whole map size - word rsiz = FONT_HIG * lsiz; // length of whole text row map + uint16 w = TS[0]->W, h = TS[0]->H; + uint8 * v = TS[0]->V, * p; + uint16 dsiz = w >> 2; // data size (1 plane line size) + uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap + uint16 psiz = h * lsiz; // - last gap, but + plane trailer + uint16 size = 4 * psiz; // whole map size + uint16 rsiz = FONT_HIG * lsiz; // length of whole text row map // set desired line pointer v += (TEXT_VM + (FONT_HIG + TEXT_LS) * line) * lsiz; @@ -307,19 +307,19 @@ void TALK::PutLine (int line, const char * text) // paint text line if (text) { - byte * q; + uint8 * q; p = v + 2 + TEXT_HM/4 + (TEXT_HM%4)*psiz; q = v + size; while (* text) { - word cw = Font.Wid[*text], i; - byte * fp = Font.Map + Font.Pos[*text]; + uint16 cw = Font.Wid[*text], i; + uint8 * fp = Font.Map + Font.Pos[*text]; for (i = 0; i < cw; i ++) { - register word b = fp[i]; - word n; + register uint16 b = fp[i]; + uint16 n; for (n = 0; n < FONT_HIG; n ++) { if (b & 1) *p = TEXT_FG; @@ -344,7 +344,7 @@ void TALK::PutLine (int line, const char * text) -INFO_LINE::INFO_LINE (word w) +INFO_LINE::INFO_LINE (uint16 w) : OldTxt(NULL) { TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG); @@ -360,33 +360,33 @@ void INFO_LINE::Update (const char * tx) { if (tx != OldTxt) { - word w = TS[0]->W, h = TS[0]->H; - byte * v = (byte *) TS[0]->V; - word dsiz = w >> 2; // data size (1 plane line size) - word lsiz = 2 + dsiz + 2; // word for line header, word for gap - word psiz = h * lsiz; // - last gape, but + plane trailer - word size = 4 * psiz; // whole map size + uint16 w = TS[0]->W, h = TS[0]->H; + uint8 * v = (uint8 *) TS[0]->V; + uint16 dsiz = w >> 2; // data size (1 plane line size) + uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap + uint16 psiz = h * lsiz; // - last gape, but + plane trailer + uint16 size = 4 * psiz; // whole map size // claer whole rectangle memset(v+2, TEXT_BG, dsiz); // data bytes memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines - * (word *) (v + psiz - 2) = EOI; // plane trailer word + * (uint16 *) (v + psiz - 2) = EOI; // plane trailer uint16 memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes // paint text line if (tx) { - byte * p = v + 2, * q = p + size; + uint8 * p = v + 2, * q = p + size; while (* tx) { - word cw = Font.Wid[*tx], i; - byte * fp = Font.Map + Font.Pos[*tx]; + uint16 cw = Font.Wid[*tx], i; + uint8 * fp = Font.Map + Font.Pos[*tx]; for (i = 0; i < cw; i ++) { - register word b = fp[i]; - word n; + register uint16 b = fp[i]; + uint16 n; for (n = 0; n < FONT_HIG; n ++) { if (b & 1) *p = TEXT_FG; diff --git a/engines/cge/talk.h b/engines/cge/talk.h index c84891f7a0..dff61eaf4b 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -52,15 +52,15 @@ class FONT char Path[MAXPATH]; void Load (void); public: -// static byte Wid[256]; -// static word Pos[256]; -// static byte Map[256*8]; - byte * Wid; - word * Pos; - byte * Map; +// static uint8 Wid[256]; +// static uint16 Pos[256]; +// static uint8 Map[256*8]; + uint8 * Wid; + uint16 * Pos; + uint8 * Map; FONT (const char * name); ~FONT (void); - word Width (const char * text); + uint16 Width (const char * text); void Save (void); }; @@ -77,7 +77,7 @@ class TALK : public SPRITE protected: TBOX_STYLE Mode; BITMAP * TS[2]; - BITMAP * Box(word w, word h); + BITMAP * Box(uint16 w, uint16 h); public: static FONT Font; TALK (const char * tx, TBOX_STYLE mode = PURE); @@ -98,7 +98,7 @@ class INFO_LINE : public TALK { const char * OldTxt; public: - INFO_LINE (word wid); + INFO_LINE (uint16 wid); void Update (const char * tx); }; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 34b99ac7eb..bb4757e541 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -225,7 +225,7 @@ void Say (const char * txt, SPRITE * spr) int x = (east) ? (spr->X+spr->W-2) : (spr->X+2); int y = spr->Y+2; SPRITE * spike = new SPRITE(SP); - word sw = spike->W; + uint16 sw = spike->W; if (east) { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 386ccca140..e2588b74f5 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -113,7 +113,7 @@ char * NumStr (char * str, int num) static void Video (void) { - static word SP_S; + static uint16 SP_S; asm push bx asm push bp @@ -136,9 +136,9 @@ static void Video (void) -word * SaveScreen (void) +uint16 * SaveScreen (void) { - word cxy, cur, siz, * scr = NULL, * sav; + uint16 cxy, cur, siz, * scr = NULL, * sav; // horizontal size of text mode screen asm mov ah,0x0F // get current video mode @@ -179,7 +179,7 @@ word * SaveScreen (void) _AH = 0x03; Video(); // get cursor cxy = _DX; - sav = farnew(word, siz+3); // +3 extra words for size and cursor + sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor if (sav) { sav[0] = siz; @@ -194,9 +194,9 @@ word * SaveScreen (void) -void RestoreScreen (word * &sav) +void RestoreScreen (uint16 * &sav) { - word * scr = NULL; + uint16 * scr = NULL; asm mov ax,0x40 // system data segment asm mov es,ax @@ -228,7 +228,7 @@ void RestoreScreen (word * &sav) -DAC MkDAC (byte r, byte g, byte b) +DAC MkDAC (uint8 r, uint8 g, uint8 b) { static DAC x; x.R = r; @@ -240,7 +240,7 @@ DAC MkDAC (byte r, byte g, byte b) -RGB MkRGB (byte r, byte g, byte b) +RGB MkRGB (uint8 r, uint8 g, uint8 b) { static TRGB x; x.dac.R = r; @@ -268,7 +268,7 @@ SPRITE * Locate (int ref) bool HEART::Enable = false; -word * HEART::XTimer = NULL; +uint16 * HEART::XTimer = NULL; @@ -283,16 +283,16 @@ HEART::HEART (void) extern "C" void TimerProc (void) { static SPRITE * spr; - static byte run = 0; + static uint8 run = 0; - // decrement external timer word + // decrement external timer uint16 if (HEART::XTimer) if (*HEART::XTimer) -- *HEART::XTimer; else HEART::XTimer = NULL; if (! run && HEART::Enable) // check overrun flag { - static word oldSP, oldSS; + static uint16 oldSP, oldSS; ++ run; // disable 2nd call until current lasts asm mov ax,ds @@ -319,7 +319,7 @@ extern "C" void TimerProc (void) void interrupt ENGINE::NewTimer (...) { static SPRITE * spr; - static byte run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; + static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; ___1152_Hz___: @@ -350,14 +350,14 @@ void interrupt ENGINE::NewTimer (...) my_int: //------72Hz-------// - // decrement external timer word + // decrement external timer uint16 if (HEART::XTimer) if (*HEART::XTimer) -- *HEART::XTimer; else HEART::XTimer = NULL; if (! run && HEART::Enable) // check overrun flag { - static word oldSP, oldSS; + static uint16 oldSP, oldSS; ++ run; // disable 2nd call until current lasts asm mov ax,ds @@ -383,7 +383,7 @@ void interrupt ENGINE::NewTimer (...) -void HEART::SetXTimer (word * ptr) +void HEART::SetXTimer (uint16 * ptr) { if (XTimer && ptr != XTimer) *XTimer = 0; XTimer = ptr; @@ -392,7 +392,7 @@ void HEART::SetXTimer (word * ptr) -void HEART::SetXTimer (word * ptr, word time) +void HEART::SetXTimer (uint16 * ptr, uint16 time) { SetXTimer(ptr); *ptr = time; @@ -415,7 +415,7 @@ SPRITE::SPRITE (BMP_PTR * shp) Ext(NULL), Ref(-1), Cave(0) { memset(File, 0, sizeof(File)); - *((word *)&Flags) = 0; + *((uint16 *)&Flags) = 0; SetShapeList(shp); } @@ -486,7 +486,7 @@ BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) -void SPRITE::MoveShapes (byte * buf) +void SPRITE::MoveShapes (uint8 * buf) { BMP_PTR * p; for (p = Ext->ShpList; *p; p ++) @@ -779,7 +779,7 @@ void SPRITE::Tick (void) -void SPRITE::MakeXlat (byte * x) +void SPRITE::MakeXlat (uint8 * x) { if (Ext) { @@ -800,11 +800,11 @@ void SPRITE::KillXlat (void) if (Flags.Xlat && Ext) { BMP_PTR * b; - byte * m = (*Ext->ShpList)->M; + uint8 * m = (*Ext->ShpList)->M; switch (MemType(m)) { - case NEAR_MEM : delete[] (byte *) m; break; + case NEAR_MEM : delete[] (uint8 *) m; break; case FAR_MEM : farfree(m); break; } for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; @@ -883,9 +883,9 @@ void SPRITE::Show (void) -void SPRITE::Show (word pg) +void SPRITE::Show (uint16 pg) { - byte * a = VGA::Page[1]; + uint8 * a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; Shp()->Show(X, Y); VGA::Page[1] = a; @@ -912,13 +912,13 @@ BMP_PTR SPRITE::Ghost (void) register SPREXT * e = Ext; if (e->b1) { - BMP_PTR bmp = new BITMAP(0, 0, (byte *)NULL); + BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); if (bmp == NULL) VGA::Exit("No core"); bmp->W = e->b1->W; bmp->H = e->b1->H; if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); - bmp->V = (byte *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); - bmp->M = (byte *) MK_FP(e->y1, e->x1); + bmp->V = (uint8 *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + bmp->M = (uint8 *) MK_FP(e->y1, e->x1); return bmp; } return NULL; @@ -1083,9 +1083,9 @@ SPRITE * QUEUE::Locate (int ref) -word VGA::StatAdr = VGAST1_; -word VGA::OldMode = 0; -word * VGA::OldScreen = NULL; +uint16 VGA::StatAdr = VGAST1_; +uint16 VGA::OldMode = 0; +uint16 * VGA::OldScreen = NULL; const char * VGA::Msg = NULL; const char * VGA::Nam = NULL; DAC * VGA::OldColors = NULL; @@ -1093,10 +1093,10 @@ DAC * VGA::NewColors = NULL; bool VGA::SetPal = false; int VGA::Mono = 0; QUEUE VGA::ShowQ = true, VGA::SpareQ = false; -byte * VGA::Page[4] = { (byte *) MK_FP(SCR_SEG, 0x0000), - (byte *) MK_FP(SCR_SEG, 0x4000), - (byte *) MK_FP(SCR_SEG, 0x8000), - (byte *) MK_FP(SCR_SEG, 0xC000) }; +uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), + (uint8 *) MK_FP(SCR_SEG, 0x4000), + (uint8 *) MK_FP(SCR_SEG, 0x8000), + (uint8 *) MK_FP(SCR_SEG, 0xC000) }; @@ -1453,7 +1453,7 @@ void VGA::UpdateColors (void) void VGA::Update (void) { - byte * p = Page[1]; + uint8 * p = Page[1]; Page[1] = Page[0]; Page[0] = p; @@ -1481,9 +1481,9 @@ void VGA::Update (void) -void VGA::Clear (byte color) +void VGA::Clear (uint8 color) { - byte * a = (byte *) MK_FP(SCR_SEG, 0); + uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); asm mov dx,VGASEQ_ asm mov ax,0x0F02 // map mask register - enable all planes @@ -1502,9 +1502,9 @@ void VGA::Clear (byte color) -void VGA::CopyPage (word d, word s) +void VGA::CopyPage (uint16 d, uint16 s) { - byte * S = Page[s & 3], * D = Page[d & 3]; + uint8 * S = Page[s & 3], * D = Page[d & 3]; asm mov dx,VGAGRA_ asm mov al,0x05 // R/W mode @@ -1571,11 +1571,11 @@ void VGA::Exit (int tref, const char * name) void BITMAP::XShow (int x, int y) { - byte rmsk = x % 4, + uint8 rmsk = x % 4, mask = 1 << rmsk, * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - byte * m = (char *) M; - byte * v = V; + uint8 * m = (char *) M; + uint8 * v = V; asm push bx asm push si @@ -1657,9 +1657,9 @@ void BITMAP::XShow (int x, int y) void BITMAP::Show (int x, int y) { - byte mask = 1 << (x & 3), + uint8 mask = 1 << (x & 3), * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - byte * v = V; + uint8 * v = V; asm push ds // preserve DS @@ -1728,11 +1728,11 @@ void BITMAP::Show (int x, int y) void BITMAP::Hide (int x, int y) { - byte * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - word d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); + uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); HideDesc * b = B; - word extra = ((x & 3) != 0); - word h = H; + uint16 extra = ((x & 3) != 0); + uint16 h = H; // asm push bx asm push si diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index d7ef11f36d..b3b411096e 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -70,7 +70,7 @@ #endif #define NO_SEQ (-1) -#define NO_PTR ((byte)-1) +#define NO_PTR ((uint8)-1) #define SPR_EXT ".SPR" @@ -79,9 +79,9 @@ -typedef struct { word r : 2; word R : 6; - word g : 2; word G : 6; - word b : 2; word B : 6; +typedef struct { uint16 r : 2; uint16 R : 6; + uint16 g : 2; uint16 G : 6; + uint16 b : 2; uint16 B : 6; } RGB; typedef union { @@ -89,9 +89,9 @@ typedef union { RGB rgb; } TRGB; -typedef struct { byte idx, adr; byte clr, set; } VgaRegBlk; +typedef struct { uint8 idx, adr; uint8 clr, set; } VgaRegBlk; -typedef struct { byte Now, Next; signed char Dx, Dy; int Dly; } SEQ; +typedef struct { uint8 Now, Next; signed char Dx, Dy; int Dly; } SEQ; extern SEQ Seq1[]; extern SEQ Seq2[]; @@ -127,9 +127,9 @@ class HEART : public ENGINE friend ENGINE; public: static bool Enable; - static word * XTimer; - static void SetXTimer (word * ptr); - static void SetXTimer (word * ptr, word time); + static uint16 * XTimer; + static void SetXTimer (uint16 * ptr); + static void SetXTimer (uint16 * ptr, uint16 time); HEART (void); }; @@ -166,28 +166,28 @@ protected: public: int Ref; signed char Cave; - struct FLAGS { word Hide : 1; // general visibility switch - word Near : 1; // Near action lock - word Drag : 1; // sprite is moveable - word Hold : 1; // sprite is held with mouse - word ____ : 1; // intrrupt driven animation - word Slav : 1; // slave object - word Syst : 1; // system object - word Kill : 1; // dispose memory after remove - word Xlat : 1; // 2nd way display: xlat table - word Port : 1; // portable - word Kept : 1; // kept in pocket - word East : 1; // talk to east (in opposite to west) - word Shad : 1; // shadow - word Back : 1; // 'send to background' request - word BDel : 1; // delete bitmaps in ~SPRITE - word Tran : 1; // transparent (untouchable) + struct FLAGS { uint16 Hide : 1; // general visibility switch + uint16 Near : 1; // Near action lock + uint16 Drag : 1; // sprite is moveable + uint16 Hold : 1; // sprite is held with mouse + uint16 ____ : 1; // intrrupt driven animation + uint16 Slav : 1; // slave object + uint16 Syst : 1; // system object + uint16 Kill : 1; // dispose memory after remove + uint16 Xlat : 1; // 2nd way display: xlat table + uint16 Port : 1; // portable + uint16 Kept : 1; // kept in pocket + uint16 East : 1; // talk to east (in opposite to west) + uint16 Shad : 1; // shadow + uint16 Back : 1; // 'send to background' request + uint16 BDel : 1; // delete bitmaps in ~SPRITE + uint16 Tran : 1; // transparent (untouchable) } Flags; int X, Y; signed char Z; - word W, H; - word Time; - byte NearPtr, TakePtr; + uint16 W, H; + uint16 Time; + uint8 NearPtr, TakePtr; int SeqPtr; int ShpCnt; char File[MAXFILE]; @@ -199,7 +199,7 @@ public: virtual ~SPRITE (void); BMP_PTR Shp (void); BMP_PTR * SetShapeList (BMP_PTR * shp); - void MoveShapes (byte * buf); + void MoveShapes (uint8 * buf); SPRITE * Expand (void); SPRITE * Contract (void); SPRITE * BackShow (bool fast = false); @@ -210,13 +210,13 @@ public: void Show (void); void Hide (void); BMP_PTR Ghost (void); - void Show (word pg); - void MakeXlat (byte * x); + void Show (uint16 pg); + void MakeXlat (uint8 * x); void KillXlat (void); void Step (int nr = -1); SEQ * SetSeq (SEQ * seq); SNAIL::COM * SnList(SNLIST type); - virtual void Touch (word mask, int x, int y); + virtual void Touch (uint16 mask, int x, int y); virtual void Tick (void); }; @@ -250,9 +250,9 @@ public: class VGA { - static word OldMode; - static word * OldScreen; - static word StatAdr; + static uint16 OldMode; + static uint16 * OldScreen; + static uint16 StatAdr; static bool SetPal; static DAC * OldColors, * NewColors; static int SetMode (int mode); @@ -263,19 +263,19 @@ class VGA static void SetStatAdr (void); static void WaitVR (bool on = true); public: - dword FrmCnt; + uint32 FrmCnt; static QUEUE ShowQ, SpareQ; static int Mono; - static byte * Page[4]; + static uint8 * Page[4]; VGA (int mode = M13H); ~VGA (void); void Setup (VgaRegBlk * vrb); static void GetColors (DAC * tab); static void SetColors (DAC * tab, int lum); - static void Clear (byte color = 0); + static void Clear (uint8 color = 0); static void Exit (const char * txt = NULL, const char * name = NULL); static void Exit (int tref, const char * name = NULL); - static void CopyPage (word d, word s = 3); + static void CopyPage (uint16 d, uint16 s = 3); static void Sunrise (DAC * tab); static void Sunset (void); void Show (void); @@ -284,24 +284,24 @@ public: -DAC MkDAC (byte r, byte g, byte b); -RGB MkRGB (byte r, byte g, byte b); +DAC MkDAC (uint8 r, uint8 g, uint8 b); +RGB MkRGB (uint8 r, uint8 g, uint8 b); template -byte Closest (CBLK * pal, CBLK x) +uint8 Closest (CBLK * pal, CBLK x) { - #define f(col,lum) ((((word)(col))<<8)/lum) - word i, dif = 0xFFFF, found; - word L = x.R + x.G + x.B; if (! L) ++ L; - word R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); + #define f(col,lum) ((((uint16)(col))<<8)/lum) + uint16 i, dif = 0xFFFF, found; + uint16 L = x.R + x.G + x.B; if (! L) ++ L; + uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); for (i = 0; i < 256; i ++) { - word l = pal[i].R + pal[i].G + pal[i].B; if (! l) ++ l; + uint16 l = pal[i].R + pal[i].G + pal[i].B; if (! l) ++ l; int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l); - word D = ((r > R) ? (r - R) : (R - r)) + + uint16 D = ((r > R) ? (r - R) : (R - r)) + ((g > G) ? (g - G) : (G - g)) + ((b > B) ? (b - B) : (B - b)) + ((l > L) ? (l - L) : (L - l)) * 10 ; @@ -325,8 +325,8 @@ byte Closest (CBLK * pal, CBLK x) char * NumStr (char * str, int num); void Video (void); - word * SaveScreen (void); - void RestoreScreen (word * &sav); + uint16 * SaveScreen (void); + void RestoreScreen (uint16 * &sav); SPRITE * SpriteAt (int x, int y); SPRITE * Locate (int ref); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index f7314e18ea..1459314ba0 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -45,10 +45,10 @@ -MENU_BAR::MENU_BAR (word w) +MENU_BAR::MENU_BAR (uint16 w) { int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; - byte * p = farnew(byte, i), * p1, * p2; + uint8 * p = farnew(uint8, i), * p1, * p2; _fmemset(p+w, TRANS, i-2*w); _fmemset(p, MB_LT, w); @@ -88,7 +88,7 @@ char * VMGather (CHOICE * list) len += strlen(cp->Text); ++ h; } - vmgt = new byte[len+h]; + vmgt = new uint8[len+h]; if (vmgt) { *vmgt = '\0'; @@ -141,7 +141,7 @@ VMENU::~VMENU (void) -void VMENU::Touch (word mask, int x, int y) +void VMENU::Touch (uint16 mask, int x, int y) { #define h (FONT_HIG+TEXT_LS) int n = 0; diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 23c354b504..d2b70145df 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -45,7 +45,7 @@ typedef struct { char * Text; void (* Proc)(void); } CHOICE; class MENU_BAR : public TALK { public: - MENU_BAR (word w); + MENU_BAR (uint16 w); }; @@ -56,7 +56,7 @@ public: class VMENU : public TALK { - word Items; + uint16 Items; CHOICE * Menu; public: static VMENU * Addr; @@ -64,7 +64,7 @@ public: MENU_BAR * Bar; VMENU (CHOICE * list, int x, int y); ~VMENU (void); - void Touch (word mask, int x, int y); + void Touch (uint16 mask, int x, int y); }; diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 503c6cab91..b0cf1c068c 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -101,6 +101,6 @@ void VFILE::ReadBuff (void) BufMark = Dat.File.Mark(); long n = EndMark - BufMark; if (n > IOBUF_SIZE) n = IOBUF_SIZE; - Lim = Dat.File.Read(Buff, (word) n); + Lim = Dat.File.Read(Buff, (uint16) n); Ptr = 0; } diff --git a/engines/cge/vol.h b/engines/cge/vol.h index 1357c24814..99284fddd5 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -55,9 +55,9 @@ class DAT friend VFILE; static VOLBASE File; public: - static bool Append (byte * buf, word len); + static bool Append (uint8 * buf, uint16 len); static bool Write (CFILE& f); - static bool Read (long org, word len, byte * buf); + static bool Read (long org, uint16 len, uint8 * buf); }; diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 1998672bed..0fc2ab4d0d 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -39,17 +39,17 @@ typedef char FOURCC[4]; // Four-character code -typedef dword CKSIZE; // 32-bit unsigned size +typedef uint32 CKSIZE; // 32-bit unsigned size class CKID // Chunk type identifier { - union { FOURCC Tx; dword Id; }; + union { FOURCC Tx; uint32 Id; }; protected: static XFILE * ckFile; public: CKID (FOURCC t) { memcpy(Tx, t, sizeof(Tx)); } - CKID (dword d) { Id = d; } + CKID (uint32 d) { Id = d; } CKID (XFILE * xf) { (ckFile = xf)->Read(Tx, sizeof(Tx)); } bool operator !=(CKID& X) { return Id != X.Id; } bool operator ==(CKID& X) { return Id == X.Id; } @@ -78,27 +78,27 @@ class FMTCK : public CKHEA { struct WAV { - word wFormatTag; // Format category - word wChannels; // Number of channels - dword dwSamplesPerSec; // Sampling rate - dword dwAvgBytesPerSec; // For buffer estimation - word wBlockAlign; // Data block size + uint16 wFormatTag; // Format category + uint16 wChannels; // Number of channels + uint32 dwSamplesPerSec; // Sampling rate + uint32 dwAvgBytesPerSec; // For buffer estimation + uint16 wBlockAlign; // Data block size } Wav; union { struct PCM { - word wBitsPerSample; // Sample size + uint16 wBitsPerSample; // Sample size } Pcm; }; public: FMTCK (CKHEA& hea); - inline word Channels (void) { return Wav.wChannels; } - inline dword SmplRate (void) { return Wav.dwSamplesPerSec; } - inline dword ByteRate (void) { return Wav.dwAvgBytesPerSec; } - inline word BlckSize (void) { return Wav.wBlockAlign; } - inline word SmplSize (void) { return Pcm.wBitsPerSample; } + inline uint16 Channels (void) { return Wav.wChannels; } + inline uint32 SmplRate (void) { return Wav.dwSamplesPerSec; } + inline uint32 ByteRate (void) { return Wav.dwAvgBytesPerSec; } + inline uint16 BlckSize (void) { return Wav.wBlockAlign; } + inline uint16 SmplSize (void) { return Pcm.wBitsPerSample; } }; @@ -110,7 +110,7 @@ class DATACK : public CKHEA bool e; union { - byte * Buf; + uint8 * Buf; EMS * EBuf; }; public: @@ -118,7 +118,7 @@ public: DATACK (CKHEA& hea, EMM * emm); DATACK (int first, int last); ~DATACK (void); - inline byte * Addr (void) { return Buf; } + inline uint8 * Addr (void) { return Buf; } inline EMS * EAddr (void) { return EBuf; } }; -- cgit v1.2.3 From 29065d302a9bf8bcaa18c4225e27b218bde67242 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 22:57:09 +0200 Subject: CGE: Add namespaces --- engines/cge/bitmap.cpp | 6 ++---- engines/cge/bitmap.h | 6 ++++-- engines/cge/bitmaps.cpp | 4 ++++ engines/cge/bitmaps.h | 4 +++- engines/cge/boot.h | 5 ++++- engines/cge/cfile.cpp | 10 +++++++--- engines/cge/cfile.h | 2 ++ engines/cge/cge_main.cpp | 4 ++++ engines/cge/cge_main.h | 3 ++- engines/cge/game.cpp | 2 ++ engines/cge/game.h | 5 +++-- engines/cge/general.h | 5 +++++ engines/cge/gettext.cpp | 6 +++--- engines/cge/gettext.h | 8 ++------ engines/cge/ident.h | 2 ++ engines/cge/jbw.h | 3 +++ engines/cge/keybd.cpp | 3 +++ engines/cge/keybd.h | 2 ++ engines/cge/mixer.cpp | 5 +++-- engines/cge/mixer.h | 4 +++- engines/cge/mouse.cpp | 7 ++----- engines/cge/mouse.h | 5 +++-- engines/cge/snail.cpp | 5 ++++- engines/cge/snail.h | 12 ++++-------- engines/cge/snddrv.h | 4 ++++ engines/cge/sound.cpp | 8 +++++++- engines/cge/sound.h | 2 ++ engines/cge/startup.cpp | 7 +++---- engines/cge/startup.h | 3 +++ engines/cge/talk.cpp | 4 ++++ engines/cge/talk.h | 4 ++-- engines/cge/text.cpp | 8 ++------ engines/cge/text.h | 5 ++--- engines/cge/vga13h.cpp | 13 +++---------- engines/cge/vga13h.h | 3 ++- engines/cge/vmenu.cpp | 6 +++--- engines/cge/vmenu.h | 14 +++----------- engines/cge/vol.cpp | 7 ++++++- engines/cge/vol.h | 4 +++- engines/cge/wav.h | 4 ++++ 40 files changed, 129 insertions(+), 85 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 9845c4a2da..e9a9bbe220 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -36,12 +36,12 @@ #include "cge/drop.h" #endif - #include #include #include #include +namespace CGE { //-------------------------------------------------------------------------- @@ -455,6 +455,4 @@ bool BITMAP::VBMLoad (XFILE * f) } - - - +} // End of namespace CGE diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 2ce849cc2b..90f94b1b32 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -30,6 +30,8 @@ #include "cge/general.h" +namespace CGE { + #define EOI 0x0000 #define SKP 0x4000 #define REP 0x8000 @@ -82,6 +84,6 @@ public: typedef BITMAP * BMP_PTR; +} // End of namespace CGE - -#endif \ No newline at end of file +#endif diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp index 0cdae18cab..1eba1b55ea 100644 --- a/engines/cge/bitmaps.cpp +++ b/engines/cge/bitmaps.cpp @@ -222,6 +222,8 @@ static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 #undef G */ +namespace CGE { + #ifdef DEBUG BMP_PTR MB[] = { new BITMAP("BRICK"), NULL }; BMP_PTR HL[] = { new BITMAP("HLINE"), NULL }; @@ -239,3 +241,5 @@ static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 new BITMAP("LITE2"), new BITMAP("LITE3"), NULL }; + +} // End of namespace CGE diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h index 65f586a355..3ca2bababd 100644 --- a/engines/cge/bitmaps.h +++ b/engines/cge/bitmaps.h @@ -30,6 +30,8 @@ #include "cge/vga13h.h" +namespace CGE { + #ifdef DEBUG extern BITMAP * MB[]; extern BITMAP * HL[]; @@ -40,6 +42,6 @@ extern BITMAP * PR[]; extern BITMAP * SP[]; extern BITMAP * LI[]; +} // End of namespace CGE #endif - \ No newline at end of file diff --git a/engines/cge/boot.h b/engines/cge/boot.h index 3a22e89661..d09afb6d1b 100644 --- a/engines/cge/boot.h +++ b/engines/cge/boot.h @@ -30,6 +30,8 @@ #include "cge/jbw.h" +namespace CGE { + #define BOOTSECT_SIZ 512 #define BOOTHEAD_SIZ 62 #define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ @@ -72,5 +74,6 @@ EC Boot * ReadBoot (int drive); EC uint8 CheckBoot (Boot * boot); EC bool WriteBoot (int drive, Boot * boot); +// End of namespace CGE -#endif \ No newline at end of file +#endif diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index efc922b232..499a7033ac 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -25,7 +25,7 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include +#include "cge/cfile.h" #include #include #include @@ -36,11 +36,13 @@ #else #include #include - #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } #endif +namespace CGE { - +#ifndef DROP_H + #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } +#endif IOBUF::IOBUF (IOMODE mode, CRYPT * crpt) : IOHAND(mode, crpt), @@ -357,3 +359,5 @@ void CFILE::Append (CFILE& f) } } } + +} // End of namespace CGE diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index bbb45a9e85..b08dc833b0 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -31,6 +31,7 @@ #include "cge/general.h" #include +namespace CGE { #define LINE_MAX 512 @@ -79,5 +80,6 @@ public: void Append (CFILE& f); }; +} // End of namespace CGE #endif diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index d8829247a4..36053d926c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -55,6 +55,8 @@ #include #include +namespace CGE { + #define STACK_SIZ (K(2)) #define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText) @@ -2257,3 +2259,5 @@ void cge_main (void) else Vga.Sunset(); VGA::Exit(EXIT_OK_TEXT+FINIS); } + +} // End of namespace CGE diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index c1155eb650..8605d17c55 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -204,5 +204,6 @@ extern WALK * Hero; void ContractSprite (SPRITE * spr); void cge_main(void); -} // End of CGE +} // End of namespace CGE + #endif diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index cc80a8f7fa..d9bcf916bb 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -31,6 +31,7 @@ #include +namespace CGE { @@ -116,3 +117,4 @@ void FLY::Tick (void) //-------------------------------------------------------------------------- +} // End of namespace CGE diff --git a/engines/cge/game.h b/engines/cge/game.h index cda24512e3..1f45667b6b 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -31,6 +31,7 @@ #include "cge/vga13h.h" #include "cge/bitmaps.h" +namespace CGE { #define PAN_HIG 40 @@ -62,6 +63,6 @@ public: +} // End of namespace CGE - -#endif \ No newline at end of file +#endif diff --git a/engines/cge/general.h b/engines/cge/general.h index 75f754d0a3..ac45f4b4ad 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -28,9 +28,13 @@ #ifndef __GENERAL__ #define __GENERAL__ +#include "common/system.h" + #include "cge\jbw.h" #include +namespace CGE { + #define SEED 0xA5 #define SCR_WID_ 320 @@ -264,5 +268,6 @@ EC void _fqsort (void *base, uint16 nelem, uint16 width, int (*fcmp)(const void*, const void*)); +} // End of namespace CGE #endif diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 623374fe7d..f8de84f5fc 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -30,9 +30,7 @@ #include "cge/mouse.h" #include - - - +namespace CGE { GET_TEXT * GET_TEXT::Ptr = NULL; @@ -135,3 +133,5 @@ void GET_TEXT::Touch (uint16 mask, int x, int y) } else SPRITE::Touch(mask, x, y); } + +} // End of namespace CGE diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index d08e09a5bb..02dbabe9c6 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -31,17 +31,13 @@ #include "cge/general.h" #include "cge/talk.h" +namespace CGE { #define GTMAX 24 #define GTBLINK 6 #define GTTIME 6 - - - - - class GET_TEXT : public TALK { char Buff[GTMAX+2], * Text; @@ -57,6 +53,6 @@ public: void Tick (void); }; - +} // End of namespace CGE #endif diff --git a/engines/cge/ident.h b/engines/cge/ident.h index fa3011b49c..96e04f4e20 100644 --- a/engines/cge/ident.h +++ b/engines/cge/ident.h @@ -28,6 +28,7 @@ #ifndef __IDENT__ #define __IDENT__ +namespace CGE { struct IDENT { @@ -37,5 +38,6 @@ struct IDENT unsigned char cork; }; +} // End of namespace CGE #endif diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 8776004273..236a2e6ddb 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -28,6 +28,8 @@ #ifndef __JBW__ #define __JBW__ +namespace CGE { + #define BEL 7 #define BS 8 #define HT 9 @@ -162,5 +164,6 @@ struct KeyStatStruct extern uint16 _stklen; extern uint16 _heaplen; +} // End of namespace CGE #endif diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index c644473c53..dbbc06bcb2 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -29,6 +29,7 @@ #include "cge/mouse.h" #include +namespace CGE { SPRITE * KEYBOARD::Client = NULL; uint8 KEYBOARD::Key[0x60] = { 0 }; @@ -139,3 +140,5 @@ void interrupt KEYBOARD::NewKeyboard (...) asm mov al,20h // send End-Of-Interrupt asm out 20h,al // to the 8259 IC } + +} // End of namespace CGE diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h index dfbd439805..b38481f7d3 100644 --- a/engines/cge/keybd.h +++ b/engines/cge/keybd.h @@ -31,6 +31,7 @@ #include "cge/jbw.h" #include "cge/vga13h.h" +namespace CGE { #define KEYBD_INT 9 #define LSHIFT 42 @@ -54,5 +55,6 @@ public: ~KEYBOARD (void); }; +} // End of namespace CGE #endif diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 25d6eed32a..2ebede93be 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -33,8 +33,7 @@ #include #include -//-------------------------------------------------------------------------- - +namespace CGE { extern MOUSE Mouse; @@ -154,3 +153,5 @@ void MIXER::Update (void) Led[1]->Step(SNDDrvInfo.VOL4.DL); SNPOST_(SNEXEC, -1, 0, SNDSetVolume); } + +} // End of namespace CGE diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index c770f0a794..30beaf2f5d 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -30,6 +30,8 @@ #include "cge/vga13h.h" +namespace CGE { + #define MIX_MAX 16 // count of Leds #define MIX_Z 64 // mixer Z position #define MIX_DELAY 12 // 6/s @@ -53,6 +55,6 @@ public: void Tick (void); }; - +} // End of namespace CGE #endif diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 3c17e3632c..94f7cbf0ac 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -29,7 +29,7 @@ #include "cge/text.h" #include - +namespace CGE { EVENT Evt[EVT_MAX]; @@ -228,7 +228,4 @@ void MOUSE::Tick (void) Hold->Goto(X-hx, Y-hy); } - - -//-------------------------------------------------------------------------- - +} // End of namespace CGE diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index 42a6bf6c21..20015b058f 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -31,8 +31,9 @@ #include "cge/game.h" #include "cge/talk.h" -#define EVT_MAX 256 +namespace CGE { +#define EVT_MAX 256 #define ROLL 0x01 #define L_DN 0x02 #define L_UP 0x04 @@ -80,6 +81,6 @@ public: }; - +} // End of namespace CGE #endif diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 4c15dc6a0c..67a16a8563 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -38,9 +38,10 @@ #include #include #include - #include "cge/keybd.h" +namespace CGE { + int MaxCave = 0; SCB Scb = { NULL, 0, NULL }; @@ -1305,3 +1306,5 @@ bool SNAIL::Idle (void) { return (Head == Tail); } + +} // End of namespace CGE diff --git a/engines/cge/snail.h b/engines/cge/snail.h index b3268341d8..bf47fa13d4 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -30,6 +30,8 @@ #include "cge/jbw.h" +namespace CGE { + #define POCKET_X 174 #define POCKET_Y 176 #define POCKET_DX 18 @@ -97,18 +99,10 @@ public: }; - - - void SelectPocket (int n); void PocFul (void); - - - - - extern SCB Scb; extern bool Flag[4]; extern bool Game; @@ -122,4 +116,6 @@ extern int PocPtr; extern BAR Barriers[]; extern struct HXY { int X; int Y; } HeroXY[]; +} // End of namespace CGE + #endif diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 809f73c3a7..662d480778 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -37,6 +37,8 @@ #ifndef __SNDDRV__ #define __SNDDRV__ +namespace CGE { + // ****************************************************** // * Constants * // ****************************************************** @@ -128,4 +130,6 @@ EC void SNDMIDIStop (void); // WARNING: Uses ALL registers! EC void SNDMIDIPlay (void); +// End of namespace CGE + #endif diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 03ba231fec..81dd457603 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -34,7 +34,6 @@ #else #include #include - #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } #endif #include "cge/text.h" @@ -43,6 +42,12 @@ #include +namespace CGE { + +#ifndef DROP_H + #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } +#endif + bool Music = true; FX Fx = 16; // must precede SOUND!! SOUND Sound; @@ -318,3 +323,4 @@ EC void * Patch (int pat) return p; } +} // End of namespace CGE diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 993bd05fca..79c9bf563d 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -31,6 +31,7 @@ #include "cge/wav.h" #include "cge/snddrv.h" +namespace CGE { #define BAD_SND_TEXT 97 #define BAD_MIDI_TEXT 98 @@ -83,6 +84,7 @@ extern FX Fx; void LoadMIDI (int ref); void KillMIDI (void); +} // End of namespace CGE #endif diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 18fd06d1ec..0e45e65b73 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -41,6 +41,8 @@ #include #endif +namespace CGE { + extern char Copr[]; #define id (*(IDENT*)Copr) @@ -189,7 +191,4 @@ const char *UsrPath (const char *nam) return buf; } - - - - +} // End of namespace CGE diff --git a/engines/cge/startup.h b/engines/cge/startup.h index 1c946508b5..2f1b5faa0b 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -31,6 +31,8 @@ #include "cge/general.h" +namespace CGE { + #define GAME_ID 45 #define CDINI_FNAME 46 @@ -75,5 +77,6 @@ extern EMM MiniEmm; const char *UsrPath (const char *nam); +} // End of namespace CGE #endif diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 822bc18de3..9c15ac1b65 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -34,6 +34,8 @@ #include #include +namespace CGE { + #define WID_SIZ 256 #define POS_SIZ 256 #define MAP_SIZ (256*8) @@ -401,3 +403,5 @@ void INFO_LINE::Update (const char * tx) OldTxt = tx; } } + +} // End of namespace CGE diff --git a/engines/cge/talk.h b/engines/cge/talk.h index dff61eaf4b..fb1d450f2d 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -31,7 +31,7 @@ #include "cge/vga13h.h" #include - +namespace CGE { #define TEXT_FG DARK // foreground color #define TEXT_BG GRAY // background color @@ -103,6 +103,6 @@ public: }; - +} // End of namespace CGE #endif \ No newline at end of file diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index bb4757e541..df8ca4cfe5 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -37,7 +37,7 @@ #include #include - +namespace CGE { TEXT Text = ProgName(); TALK * Talk = NULL; @@ -311,8 +311,4 @@ void KillText (void) } } - - - - -//------------------------------------------------------------------------- +} // End of namespace CGE diff --git a/engines/cge/text.h b/engines/cge/text.h index c6e6a1491e..7394e04b3f 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -32,8 +32,7 @@ #include "cge/jbw.h" #include - - +namespace CGE { #ifndef SYSTXT_MAX #define SYSTXT_MAX 1000 @@ -82,6 +81,6 @@ void SayTime (SPRITE * spr); void Inf (const char * txt); void KillText (void); - +} // End of namespace CGE #endif \ No newline at end of file diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e2588b74f5..415bff7225 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -41,6 +41,8 @@ #include #include +namespace CGE { + #ifdef DEBUG #define REPORT #endif @@ -1790,13 +1792,4 @@ void BITMAP::Hide (int x, int y) // asm pop bx } - - - - - - -//-------------------------------------------------------------------------- - - - +} // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index b3b411096e..d8e2273557 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -34,6 +34,7 @@ #include "cge/bitmap.h" #include "cge/snail.h" +namespace CGE { #define TMR_RATE1 16 #define TMR_RATE2 4 @@ -332,6 +333,6 @@ uint8 Closest (CBLK * pal, CBLK x) extern bool SpeedTest; +} // End if namespace CGE #endif - \ No newline at end of file diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 1459314ba0..8178868578 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -30,8 +30,9 @@ #include #include -//-------------------------------------------------------------------------- +namespace CGE { +//-------------------------------------------------------------------------- #define RELIEF 1 #if RELIEF @@ -172,5 +173,4 @@ void VMENU::Touch (uint16 mask, int x, int y) #undef h } - - +} // End of namespace CGE diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index d2b70145df..cdbabf9966 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -30,18 +30,15 @@ #include "cge/talk.h" +namespace CGE { + #define MB_VM 1 #define MB_HM 3 - typedef struct { char * Text; void (* Proc)(void); } CHOICE; - - - - class MENU_BAR : public TALK { public: @@ -49,11 +46,6 @@ public: }; - - - - - class VMENU : public TALK { uint16 Items; @@ -67,6 +59,6 @@ public: void Touch (uint16 mask, int x, int y); }; - +} // End of namespace CGE #endif diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index b0cf1c068c..8a94dbe8af 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -35,10 +35,13 @@ #include "cge/drop.h" #else #include - #define DROP(m,n) { printf("%s [%s]\n", (m), (n)); _exit(1); } #endif +namespace CGE { +#ifndef DROP_H + #define DROP(m,n) { printf("%s [%s]\n", (m), (n)); _exit(1); } +#endif #ifdef VOL_UPD @@ -104,3 +107,5 @@ void VFILE::ReadBuff (void) Lim = Dat.File.Read(Buff, (uint16) n); Ptr = 0; } + +} // End of namespace CGE diff --git a/engines/cge/vol.h b/engines/cge/vol.h index 99284fddd5..a98dbbeee2 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -33,6 +33,8 @@ #include "cge/btfile.h" #include "cge/cfile.h" +namespace CGE { + #define CAT_NAME "VOL.CAT" #define DAT_NAME "VOL.DAT" @@ -86,6 +88,6 @@ public: }; - +} // End of namespace CGE #endif diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 0fc2ab4d0d..0d1408ccf6 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -31,6 +31,8 @@ #include "cge/general.h" #include +namespace CGE { + #define WAVE_FORMAT_PCM 0x0001 #define IBM_FORMAT_MULAW 0x0101 #define IBM_FORMAT_ALAW 0x0102 @@ -133,4 +135,6 @@ extern CKID DATA; DATACK * LoadWave (XFILE * file, EMM * emm = NULL); +// End of namespace CGE + #endif -- cgit v1.2.3 From 15d98b2a5479967590c3eba82e349f642c4ca7cf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 11 Jun 2011 09:33:17 +0200 Subject: CGE: Add a couple of missing files --- engines/cge/bitmap.cpp | 7 +- engines/cge/btfile.cpp | 208 ++++++++++++++++++++++++++++++++ engines/cge/btfile.h | 99 +++++++++++++++ engines/cge/cfile.cpp | 3 +- engines/cge/config.cpp | 322 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/config.h | 37 ++++++ engines/cge/module.mk | 2 + engines/cge/talk.h | 2 +- engines/cge/vga13h.h | 2 +- engines/cge/vol.cpp | 3 +- engines/cge/vol.h | 2 +- 11 files changed, 679 insertions(+), 8 deletions(-) create mode 100644 engines/cge/btfile.cpp create mode 100644 engines/cge/btfile.h create mode 100644 engines/cge/config.cpp create mode 100644 engines/cge/config.h diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index e9a9bbe220..5c416500d6 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -36,10 +36,11 @@ #include "cge/drop.h" #endif -#include +//#include +//#include +//#include #include -#include -#include +#include "common/system.h" namespace CGE { diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp new file mode 100644 index 0000000000..4068f323a0 --- /dev/null +++ b/engines/cge/btfile.cpp @@ -0,0 +1,208 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/btfile.h" +//#include +#include "common/system.h" +#include + + + +#ifdef DROP_H + #include "cge/drop.h" +#else + #include + #include +#endif + +namespace CGE { + +#ifndef DROP_H + #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } +#endif + +#ifndef BT_SIZE + #define BT_SIZE K(1) +#endif + +#ifndef BT_KEYLEN + #define BT_KEYLEN 13 +#endif + + + + + +BTFILE::BTFILE (const char * name, IOMODE mode, CRYPT * crpt) +: IOHAND(name, mode, crpt) +{ + int i; + for (i = 0; i < BT_LEVELS; i ++) + { + Buff[i].Page = new BT_PAGE; + Buff[i].PgNo = BT_NONE; + Buff[i].Indx = -1; + Buff[i].Updt = FALSE; + if (Buff[i].Page == NULL) DROP("No core", NULL); + } +} + + + + + + + + + +BTFILE::~BTFILE (void) +{ + int i; + for (i = 0; i < BT_LEVELS; i ++) + { + PutPage(i); + delete Buff[i].Page; + } +} + + + + + + +void BTFILE::PutPage (int lev, bool hard) +{ + if (hard || Buff[lev].Updt) + { + Seek(Buff[lev].PgNo * sizeof(BT_PAGE)); + Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); + Buff[lev].Updt = FALSE; + } +} + + + + + + +BT_PAGE * BTFILE::GetPage (int lev, uint16 pgn) +{ + if (Buff[lev].PgNo != pgn) + { + uint32 pos = pgn * sizeof(BT_PAGE); + PutPage(lev); + Buff[lev].PgNo = pgn; + if (Size() > pos) + { + Seek((uint32) pgn * sizeof(BT_PAGE)); + Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); + Buff[lev].Updt = FALSE; + } + else + { + Buff[lev].Page->Hea.Count = 0; + Buff[lev].Page->Hea.Down = BT_NONE; + _fmemset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data)); + Buff[lev].Updt = TRUE; + } + Buff[lev].Indx = -1; + } + return Buff[lev].Page; +} + + + + + +BT_KEYPACK * BTFILE::Find (const uint8 * key) +{ + int lev = 0; + uint16 nxt = BT_ROOT; + while (! Error) + { + BT_PAGE * pg = GetPage(lev, nxt); + // search + if (pg->Hea.Down != BT_NONE) + { + int i; + for (i = 0; i < pg->Hea.Count; i ++) + if (_fmemicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) + break; + nxt = (i) ? pg->Inn[i-1].Down : pg->Hea.Down; + Buff[lev].Indx = i-1; + ++ lev; + } + else + { + int i; + for (i = 0; i < pg->Hea.Count-1; i ++) + if (_fstricmp(key, pg->Lea[i].Key) <= 0) + break; + Buff[lev].Indx = i; + return &pg->Lea[i]; + } + } + return NULL; +} + + + + +int keycomp (const void * k1, const void * k2) +{ + return _fmemicmp(k1, k2, BT_KEYLEN); +} + + + +void BTFILE::Make(BT_KEYPACK * keypack, uint16 count) +{ + #if BT_LEVELS != 2 + #error This tiny BTREE implementation works with exactly 2 levels! + #endif + _fqsort(keypack, count, sizeof(*keypack), keycomp); + uint16 n = 0; + BT_PAGE * Root = GetPage(0, n ++), + * Leaf = GetPage(1, n); + Root->Hea.Down = n; + PutPage(0, TRUE); + while (count --) + { + if (Leaf->Hea.Count >= ArrayCount(Leaf->Lea)) + { + PutPage(1, TRUE); // save filled page + Leaf = GetPage(1, ++n); // take empty page + _fmemcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); + Root->Inn[Root->Hea.Count ++].Down = n; + Buff[0].Updt = TRUE; + } + Leaf->Lea[Leaf->Hea.Count ++] = * (keypack ++); + Buff[1].Updt = TRUE; + } +} + +} // End of namespace CGE diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h new file mode 100644 index 0000000000..0599bee72a --- /dev/null +++ b/engines/cge/btfile.h @@ -0,0 +1,99 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#ifndef __BTFILE__ +#define __BTFILE__ + +#include "cge/general.h" + +namespace CGE { + +#define BT_SIZE K(1) +#define BT_KEYLEN 13 +#define BT_LEVELS 2 + +#define BT_NONE 0xFFFF +#define BT_ROOT 0 + + +struct BT_KEYPACK +{ + uint8 Key[BT_KEYLEN]; + uint32 Mark; + uint16 Size; +}; + + + +struct BT_PAGE +{ + struct HEA + { + uint16 Count; + uint16 Down; + } Hea; + union + { + // dummy filler to make proper size of union + uint8 Data[BT_SIZE-sizeof(HEA)]; + // inner version of data: key + word-sized page link + struct INNER + { + uint8 Key[BT_KEYLEN]; + uint16 Down; + } Inn[(BT_SIZE-sizeof(HEA))/sizeof(INNER)]; + // leaf version of data: key + all user data + BT_KEYPACK Lea[(BT_SIZE-sizeof(HEA))/sizeof(BT_KEYPACK)]; + }; +}; + + + + + +class BTFILE : public IOHAND +{ + struct + { + BT_PAGE * Page; + uint16 PgNo; + int Indx; + bool Updt; + } Buff[BT_LEVELS]; + void PutPage (int lev, bool hard = FALSE); + BT_PAGE * GetPage (int lev, uint16 pgn); +public: + BTFILE (const char * name, IOMODE mode = REA, CRYPT * crpt = NULL); + virtual ~BTFILE (void); + BT_KEYPACK * Find(const byte * key); + BT_KEYPACK * Next(void); + void Make(BT_KEYPACK * keypack, uint16 count); +}; + +} // End of namespace CGE + +#endif diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 499a7033ac..56383ca92e 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -29,7 +29,8 @@ #include #include #include -#include +//#include +#include "common/system.h" #ifdef DROP_H #include "cge/drop.h" diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp new file mode 100644 index 0000000000..4add18bd43 --- /dev/null +++ b/engines/cge/config.cpp @@ -0,0 +1,322 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/config.h" +#include "cge/sound.h" +#include "cge/vmenu.h" +#include "cge/text.h" +#include "cge/cge_main.h" + +namespace CGE { + +/* + 51=wska§ typ posiadanej karty d¦wi‘kowej + 52=wybierz numer portu dla karty d¦wi‘kowej + 53=wybierz numer przerwania dla karty d¦wi‘kowej + 54=wybierz numer kana’u DMA dla karty d¦wi‘kowej + 55=wybierz numer portu dla General MIDI + 55=konfiguracja karty d¦wi‘kowej +*/ +#define STYPE_TEXT 51 +#define SPORT_TEXT 52 +#define SIRQ_TEXT 53 +#define SDMA_TEXT 54 +#define MPORT_TEXT 55 +#define MENU_TEXT 56 + +#define NONE_TEXT 60 +#define SB_TEXT 61 +#define SBM_TEXT 62 +#define GUS_TEXT 63 +#define GUSM_TEXT 64 +#define MIDI_TEXT 65 +#define AUTO_TEXT 66 + +#define DETECT 0xFFFF + + +void NONE (void); +void SB (void); +void SBM (void); +void GUS (void); +void GUSM (void); +void MIDI (void); +void AUTO (void); +void SetPortD (void); +void SetPortM (void); +void SetIRQ (void); +void SetDMA (void); + + +static int DevName[] = { NONE_TEXT, SB_TEXT, SBM_TEXT, + GUS_TEXT, GUSM_TEXT, + MIDI_TEXT, AUTO_TEXT }; + +static CHOICE DevMenu[]={ { NULL, NONE }, + { NULL, SB }, + { NULL, SBM }, + { NULL, GUS }, + { NULL, GUSM }, + { NULL, MIDI }, + { NULL, AUTO }, + { NULL, NULL } }; + + +static CHOICE DigiPorts[]={ { " 210h", SetPortD }, + { " 220h", SetPortD }, + { " 230h", SetPortD }, + { " 240h", SetPortD }, + { " 250h", SetPortD }, + { " 260h", SetPortD }, + { "AUTO ", SetPortD }, + { NULL, NULL } }; + +static CHOICE MIDIPorts[]={ { " 220h", SetPortM }, + { " 230h", SetPortM }, + { " 240h", SetPortM }, + { " 250h", SetPortM }, + { " 300h", SetPortM }, + { " 320h", SetPortM }, + { " 330h", SetPortM }, + { " 340h", SetPortM }, + { " 350h", SetPortM }, + { " 360h", SetPortM }, + { "AUTO ", SetPortM }, + { NULL, NULL } }; + +static CHOICE BlsterIRQ[]={ { "IRQ 2", SetIRQ }, + { "IRQ 5", SetIRQ }, + { "IRQ 7", SetIRQ }, + { "IRQ 10", SetIRQ }, + { "AUTO ", SetIRQ }, + { NULL, NULL } }; + +static CHOICE GravisIRQ[]={ { "IRQ 2", SetIRQ }, + { "IRQ 5", SetIRQ }, + { "IRQ 7", SetIRQ }, + { "IRQ 11", SetIRQ }, + { "IRQ 12", SetIRQ }, + { "IRQ 15", SetIRQ }, + { "AUTO ", SetIRQ }, + { NULL, NULL } }; + +static CHOICE GravisDMA[]={ { "DMA 1", SetDMA }, + { "DMA 3", SetDMA }, + { "DMA 5", SetDMA }, + { "DMA 6", SetDMA }, + { "DMA 7", SetDMA }, + { "AUTO ", SetDMA }, + { NULL, NULL } }; + +static CHOICE BlsterDMA[]={ { "DMA 0", SetDMA }, + { "DMA 1", SetDMA }, + { "DMA 3", SetDMA }, + { "AUTO ", SetDMA }, + { NULL, NULL } }; + + + + +void SelectSound (void) +{ + int i; + Sound.Close(); + if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); + Inf(Text[STYPE_TEXT]); + Talk->Goto(Talk->X, FONT_HIG/2); + for (i = 0; i < ArrayCount(DevName); i ++) + DevMenu[i].Text = Text[DevName[i]]; + (new VMENU(DevMenu, SCR_WID/2, Talk->Y+Talk->H+TEXT_VM+FONT_HIG))->SetName(Text[MENU_TEXT]); +} + + + + +static void Reset (void) +{ + SNDDrvInfo.DBASE = SNDDrvInfo.DIRQ = SNDDrvInfo.DDMA = SNDDrvInfo.MBASE = DETECT; +} + + + + + +static uint16 deco (const char * str, uint16 (*dco)(const char *)) +{ + while (*str && ! IsDigit(*str)) ++ str; + if (*str) return dco(str); + else return DETECT; +} + + + + +static uint16 ddeco (const char * str) +{ + return deco(str, atow); +} + + + + +static uint16 xdeco (const char * str) +{ + return deco(str, xtow); +} + + + + +static CHOICE * Cho; +static int Hlp; + +static void SNSelect (void) +{ + Inf(Text[Hlp]); + Talk->Goto(Talk->X, FONT_HIG / 2); + (new VMENU(Cho, SCR_WID/2, Talk->Y+Talk->H+TEXT_VM+FONT_HIG))->SetName(Text[MENU_TEXT]); +} + + + + +static void Select (CHOICE * cho, int hlp) +{ + Cho = cho; + Hlp = hlp; + SNPOST(SNEXEC, -1, 0, (void *) SNSelect); +} + + + + + + +static void NONE (void) +{ + SNDDrvInfo.DDEV = DEV_QUIET; + SNDDrvInfo.MDEV = DEV_QUIET; + Sound.Open(); +} + + + +static void SB (void) +{ + SNDDrvInfo.DDEV = DEV_SB; + SNDDrvInfo.MDEV = DEV_SB; + Reset(); + Select(DigiPorts, SPORT_TEXT); +} + + + +static void SBM (void) +{ + SNDDrvInfo.DDEV = DEV_SB; + SNDDrvInfo.MDEV = DEV_GM; + Reset(); + Select(DigiPorts, SPORT_TEXT); +} + + +static void GUS (void) +{ + SNDDrvInfo.DDEV = DEV_GUS; + SNDDrvInfo.MDEV = DEV_GUS; + Reset(); + Select(DigiPorts, SPORT_TEXT); +} + + + +static void GUSM (void) +{ + SNDDrvInfo.DDEV = DEV_GUS; + SNDDrvInfo.MDEV = DEV_GM; + Reset(); + Select(DigiPorts, SPORT_TEXT); +} + + +static void MIDI (void) +{ + SNDDrvInfo.DDEV = DEV_QUIET; + SNDDrvInfo.MDEV = DEV_GM; + SNDDrvInfo.MBASE = DETECT; + Select(MIDIPorts, MPORT_TEXT); +} + + + +static void AUTO (void) +{ + SNDDrvInfo.DDEV = DEV_AUTO; + SNDDrvInfo.MDEV = DEV_AUTO; + Reset(); + Sound.Open(); +} + + + + + + +static void SetPortD (void) +{ + SNDDrvInfo.DBASE = xdeco(DigiPorts[VMENU::Recent].Text); + Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); +} + + + +static void SetPortM (void) +{ + SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text); + Sound.Open(); +} + + + + +static void SetIRQ (void) +{ + SNDDrvInfo.DIRQ = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); + Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); +} + + + + +static void SetDMA (void) +{ + SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); + if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) Select(MIDIPorts, MPORT_TEXT); + else Sound.Open(); +} + +} // End of namespace CGE diff --git a/engines/cge/config.h b/engines/cge/config.h new file mode 100644 index 0000000000..1e692afc4d --- /dev/null +++ b/engines/cge/config.h @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#ifndef __CONFIG__ +#define __CONFIG__ + +namespace CGE { + +void SelectSound (void); + +} // End of namespace CGE + +#endif diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 7424c8bc38..e028d7feb4 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -3,9 +3,11 @@ MODULE := engines/cge MODULE_OBJS := \ bitmap.o \ bitmaps.o \ + btfile.o \ cfile.o \ cge.o \ cge_main.o \ + config.o \ console.o \ detection.o \ game.o \ diff --git a/engines/cge/talk.h b/engines/cge/talk.h index fb1d450f2d..76539fbcf9 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -29,7 +29,7 @@ #define __TALK__ #include "cge/vga13h.h" -#include +//#include namespace CGE { diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index d8e2273557..e5c34d238f 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -30,7 +30,7 @@ #include "cge/general.h" #include -#include +//#include #include "cge/bitmap.h" #include "cge/snail.h" diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 8a94dbe8af..9f4391cc9a 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -26,7 +26,8 @@ */ #include "cge/vol.h" -#include +//#include +#include "common/system.h" #include #include #include diff --git a/engines/cge/vol.h b/engines/cge/vol.h index a98dbbeee2..b63b08e7a1 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -29,7 +29,7 @@ #define __VOL__ -#include +//#include #include "cge/btfile.h" #include "cge/cfile.h" -- cgit v1.2.3 From 11264a60a7dc8e3e04b5b73f6794269f097010ff Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 11 Jun 2011 22:35:21 +0200 Subject: CGE: Stubbing and cleanup made by SylvainTV --- engines/cge/bitmap.cpp | 36 +++++++----- engines/cge/boot.h | 2 +- engines/cge/btfile.cpp | 17 +++--- engines/cge/btfile.h | 4 +- engines/cge/cfile.cpp | 26 +++++---- engines/cge/cfile.h | 2 +- engines/cge/cge_main.cpp | 106 ++++++++++++++++++++++------------ engines/cge/cge_main.h | 1 + engines/cge/config.cpp | 25 ++++---- engines/cge/game.cpp | 10 ++-- engines/cge/general.h | 16 ++++-- engines/cge/gettext.cpp | 2 +- engines/cge/jbw.h | 18 +++++- engines/cge/keybd.cpp | 13 ++++- engines/cge/keybd.h | 8 +-- engines/cge/mixer.cpp | 6 +- engines/cge/mouse.cpp | 8 +++ engines/cge/snail.cpp | 32 ++++++----- engines/cge/snail.h | 4 +- engines/cge/snddrv.h | 3 +- engines/cge/sound.cpp | 14 +++-- engines/cge/startup.cpp | 15 +++-- engines/cge/talk.cpp | 28 ++++----- engines/cge/talk.h | 6 +- engines/cge/text.cpp | 16 +++--- engines/cge/text.h | 4 +- engines/cge/vga13h.cpp | 147 ++++++++++++++++++++++++++++++++++------------- engines/cge/vga13h.h | 2 +- engines/cge/vmenu.cpp | 10 ++-- engines/cge/vol.cpp | 10 +++- engines/cge/vol.h | 2 +- engines/cge/wav.h | 3 +- 32 files changed, 382 insertions(+), 214 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 5c416500d6..10f19029d6 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -27,19 +27,25 @@ #include "cge/bitmap.h" #include "cge/cfile.h" +#include "cge/jbw.h" #ifdef VOL #include "cge/vol.h" #endif -#ifdef DROP_H - #include "cge/drop.h" + +#ifndef DROP_H +// TODO replace printf by scummvm equivalent +#define DROP(m,n) {} +//#define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } #endif + //#include //#include //#include #include +#include "cge/cfile.h" #include "common/system.h" namespace CGE { @@ -51,7 +57,7 @@ namespace CGE { DAC * BITMAP::Pal = NULL; - +#define MAXPATH 128 #pragma argsused BITMAP::BITMAP (const char * fname, bool rem) @@ -82,7 +88,7 @@ BITMAP::BITMAP (const char * fname, bool rem) Code(); if (rem) { - farfree(M); + free(M); M = NULL; } } @@ -151,11 +157,11 @@ BITMAP::BITMAP (const BITMAP& bmp) uint8 * v0 = bmp.V; if (v0) { - uint16 vsiz = FP_OFF(bmp.B) - FP_OFF(v0); + uint16 vsiz = (uint8*)(bmp.B) - (uint8*)(v0); uint16 siz = vsiz + H * sizeof(HideDesc); uint8 * v1 = farnew(uint8, siz); if (v1 == NULL) DROP("No core", NULL); - _fmemcpy(v1, v0, siz); + memcpy(v1, v0, siz); B = (HideDesc *) ((V = v1) + vsiz); } } @@ -168,12 +174,12 @@ BITMAP::~BITMAP (void) { switch (MemType(M)) { - case FAR_MEM : farfree(M); break; + case FAR_MEM : free(M); break; } switch (MemType(V)) { case NEAR_MEM : delete[] (uint8 *) V; break; - case FAR_MEM : farfree(V); break; + case FAR_MEM : free(V); break; } } @@ -185,15 +191,15 @@ BITMAP& BITMAP::operator = (const BITMAP& bmp) W = bmp.W; H = bmp.H; M = NULL; - if (MemType(V) == FAR_MEM) farfree(V); + if (MemType(V) == FAR_MEM) free(V); if (v0 == NULL) V = NULL; else { - uint16 vsiz = FP_OFF(bmp.B) - FP_OFF(v0); + uint16 vsiz = (uint8*)bmp.B - (uint8*)v0; uint16 siz = vsiz + H * sizeof(HideDesc); uint8 * v1 = farnew(uint8, siz); if (v1 == NULL) DROP("No core", NULL); - _fmemcpy(v1, v0, siz); + memcpy(v1, v0, siz); B = (HideDesc *) ((V = v1) + vsiz); } return *this; @@ -207,10 +213,10 @@ uint16 BITMAP::MoveVmap (uint8 * buf) { if (V) { - uint16 vsiz = FP_OFF(B) - FP_OFF(V); + uint16 vsiz = (uint8*)B - (uint8*)V; uint16 siz = vsiz + H * sizeof(HideDesc); - _fmemcpy(buf, V, siz); - if (MemType(V) == FAR_MEM) farfree(V); + memcpy(buf, V, siz); + if (MemType(V) == FAR_MEM) free(V); B = (HideDesc *) ((V = buf) + vsiz); return siz; } @@ -234,7 +240,7 @@ BMP_PTR BITMAP::Code (void) switch (MemType(V)) { case NEAR_MEM : delete[] (uint8 *) V; break; - case FAR_MEM : farfree(V); break; + case FAR_MEM : free(V); break; } V = NULL; } diff --git a/engines/cge/boot.h b/engines/cge/boot.h index d09afb6d1b..bc78b0e7fb 100644 --- a/engines/cge/boot.h +++ b/engines/cge/boot.h @@ -74,6 +74,6 @@ EC Boot * ReadBoot (int drive); EC uint8 CheckBoot (Boot * boot); EC bool WriteBoot (int drive, Boot * boot); -// End of namespace CGE +} // End of namespace CGE #endif diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 4068f323a0..1851068e2d 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -28,6 +28,7 @@ #include "cge/btfile.h" //#include #include "common/system.h" +#include "common/str.h" #include @@ -42,7 +43,9 @@ namespace CGE { #ifndef DROP_H - #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } + // TODO replace printf by scummvm equivalent +#define DROP(m,n) + //#define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } #endif #ifndef BT_SIZE @@ -126,7 +129,7 @@ BT_PAGE * BTFILE::GetPage (int lev, uint16 pgn) { Buff[lev].Page->Hea.Count = 0; Buff[lev].Page->Hea.Down = BT_NONE; - _fmemset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data)); + memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data)); Buff[lev].Updt = TRUE; } Buff[lev].Indx = -1; @@ -138,7 +141,7 @@ BT_PAGE * BTFILE::GetPage (int lev, uint16 pgn) -BT_KEYPACK * BTFILE::Find (const uint8 * key) +BT_KEYPACK * BTFILE::Find (const char * key) { int lev = 0; uint16 nxt = BT_ROOT; @@ -150,7 +153,7 @@ BT_KEYPACK * BTFILE::Find (const uint8 * key) { int i; for (i = 0; i < pg->Hea.Count; i ++) - if (_fmemicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) + if (memicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) break; nxt = (i) ? pg->Inn[i-1].Down : pg->Hea.Down; Buff[lev].Indx = i-1; @@ -160,7 +163,7 @@ BT_KEYPACK * BTFILE::Find (const uint8 * key) { int i; for (i = 0; i < pg->Hea.Count-1; i ++) - if (_fstricmp(key, pg->Lea[i].Key) <= 0) + if (scumm_stricmp((const char*)key, (const char*)pg->Lea[i].Key) <= 0) break; Buff[lev].Indx = i; return &pg->Lea[i]; @@ -174,7 +177,7 @@ BT_KEYPACK * BTFILE::Find (const uint8 * key) int keycomp (const void * k1, const void * k2) { - return _fmemicmp(k1, k2, BT_KEYLEN); + return memicmp(k1, k2, BT_KEYLEN); } @@ -196,7 +199,7 @@ void BTFILE::Make(BT_KEYPACK * keypack, uint16 count) { PutPage(1, TRUE); // save filled page Leaf = GetPage(1, ++n); // take empty page - _fmemcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); + memcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); Root->Inn[Root->Hea.Count ++].Down = n; Buff[0].Updt = TRUE; } diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 0599bee72a..0df9636573 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -42,7 +42,7 @@ namespace CGE { struct BT_KEYPACK { - uint8 Key[BT_KEYLEN]; + char Key[BT_KEYLEN]; uint32 Mark; uint16 Size; }; @@ -89,7 +89,7 @@ class BTFILE : public IOHAND public: BTFILE (const char * name, IOMODE mode = REA, CRYPT * crpt = NULL); virtual ~BTFILE (void); - BT_KEYPACK * Find(const byte * key); + BT_KEYPACK * Find(const char * key); BT_KEYPACK * Next(void); void Make(BT_KEYPACK * keypack, uint16 count); }; diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 56383ca92e..4d555c979d 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -42,7 +42,9 @@ namespace CGE { #ifndef DROP_H - #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } + //TODO Replace by scummvm printf +#define DROP(m,n) {} + //#define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } #endif IOBUF::IOBUF (IOMODE mode, CRYPT * crpt) @@ -84,7 +86,7 @@ IOBUF::IOBUF (const char * name, IOMODE mode, CRYPT * crpt) IOBUF::~IOBUF (void) { if (Mode > REA) WriteBuff(); - if (Buff) farfree(Buff); + if (Buff) free(Buff); } @@ -127,8 +129,8 @@ uint16 IOBUF::Read (void *buf, uint16 len) if (n) { if (len < n) n = len; - _fmemcpy(buf, Buff+Ptr, n); - (uint8 *) buf += n; + memcpy(buf, Buff+Ptr, n); + buf = (uint8 *)buf + n; len -= n; total += n; Ptr += n; @@ -155,15 +157,15 @@ uint16 IOBUF::Read (uint8 * buf) if (n) { if (total + n >= LINE_MAX-2) n = LINE_MAX-2 - total; - uint8 * eol = (uint8 *) _fmemchr(p, '\r', n); + uint8 * eol = (uint8 *) memchr(p, '\r', n); if (eol) n = (uint16) (eol - p); - uint8 * eof = (uint8 *) _fmemchr(p, '\32', n); + uint8 * eof = (uint8 *) memchr(p, '\32', n); if (eof) // end-of-file { n = (uint16) (eof - p); Ptr = (uint16) (eof - Buff); } - if (n) _fmemcpy(buf, p, n); + if (n) memcpy(buf, p, n); buf += n; total += n; if (eof) break; @@ -199,10 +201,10 @@ uint16 IOBUF::Write (void * buf, uint16 len) if (n > len) n = len; if (n) { - _fmemcpy(Buff+Lim, buf, n); + memcpy(Buff+Lim, buf, n); Lim += n; len -= n; - (uint8 *) buf += n; + buf = (uint8 *)buf + n; tot += n; } else WriteBuff(); @@ -220,7 +222,7 @@ uint16 IOBUF::Write (uint8 * buf) uint16 len = 0; if (buf) { - len = _fstrlen((const char *) buf); + len = strlen((const char *) buf); if (len) if (buf[len-1] == '\n') -- len; len = Write(buf, len); if (len) @@ -302,9 +304,13 @@ void CFILE::Flush (void) { if (Mode > REA) WriteBuff(); else Lim = 0; + + // TODO replace by scummvm files. + /* _BX = Handle; _AH = 0x68; // Flush buffer asm int 0x21 + */ } diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index b08dc833b0..e8d494c2f9 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -59,7 +59,7 @@ public: IOBUF (const char * name, IOMODE mode, CRYPT * crpt = NULL); virtual ~IOBUF (void); uint16 Read (void * buf, uint16 len); - uint16 Read (char * buf); + uint16 Read (uint8 * buf); int Read (void); uint16 Write (void * buf, uint16 len); uint16 Write (uint8 * buf); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 36053d926c..ebf3f3f9fd 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -44,17 +44,19 @@ #include "cge/gettext.h" #include "cge/mixer.h" #include "cge/cge_main.h" -#include +//#include #include #include #include #include #include -#include +//#include #include -#include +//#include #include +#include "common/str.h" + namespace CGE { #define STACK_SIZ (K(2)) @@ -189,7 +191,8 @@ uint8 & CLUSTER::Cell (void) bool CLUSTER::Protected (void) { if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return true; - + // TODO AsM + /* _DX = (MAP_ZCNT << 8) + MAP_XCNT; _BX = (uint16) this; @@ -221,6 +224,8 @@ bool CLUSTER::Protected (void) // return Map[B][A] != 0; xit: return _AX; + */ + return TRUE; } @@ -309,7 +314,7 @@ static void LoadGame (XFILE& file, bool tiny = false) if (n != sizeof(S)) break; S.Prev = S.Next = NULL; - spr = (stricmp(S.File+2, "MUCHA") == 0) ? new FLY(NULL) + spr = (scumm_stricmp(S.File+2, "MUCHA") == 0) ? new FLY(NULL) : new SPRITE(NULL); if (spr == NULL) VGA::Exit("No core"); *spr = S; @@ -394,7 +399,7 @@ static void Trouble (int seq, int txt) static void OffUse (void) { - Trouble(OFF_USE, OFF_USE_TEXT+random(OffUseCount)); + Trouble(OFF_USE, OFF_USE_TEXT+new_random(OffUseCount)); } @@ -580,6 +585,8 @@ void WALK::Park (void) void WALK::FindWay (CLUSTER c) { + // TODO : Find1Way in ASM +/* bool Find1Way(void); extern uint16 Target; @@ -598,6 +605,7 @@ void WALK::FindWay (CLUSTER c) if (TracePtr < 0) NoWay(); Time = 1; } +*/ } @@ -732,17 +740,17 @@ static void SetMapBrick (int x, int z) //-------------------------------------------------------------------------- void dummy (void) { } -void SwitchMapping (void); -void SwitchColorMode (void); -void StartCountDown (void); -Debug( void SwitchDebug (void); ) -void SwitchMusic (void); -void KillSprite (void); -void PushSprite (void); -void PullSprite (void); -void BackPaint (void); -void NextStep (void); -void SaveMapping (void); +static void SwitchMapping (void); +static void SwitchColorMode (void); +static void StartCountDown (void); +Debug(static void SwitchDebug (void); ) +static void SwitchMusic (void); +static void KillSprite (void); +static void PushSprite (void); +static void PullSprite (void); +static void BackPaint (void); +static void NextStep (void); +static void SaveMapping (void); WALK * Hero = NULL; @@ -835,7 +843,8 @@ static void MiniStep (int stp) static void PostMiniStep (int stp) { static int recent = -2; - if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *) MiniStep); + //TODO Change the SNPOST message send to a special way to send function pointer + //if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep); } @@ -993,7 +1002,8 @@ static void QGame (void) CaveDown(); OldLev = Lev; SaveSound(); - SaveGame(CFILE(UsrPath(UsrFnam), WRI, RCrypt)); + CFILE file = CFILE(UsrPath(UsrFnam), WRI, RCrypt); + SaveGame(file); Vga.Sunset(); Finis = true; } @@ -1009,7 +1019,8 @@ void SwitchCave (int cav) if (cav < 0) { SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - SNPOST(SNEXEC, -1, 0, (void *) QGame); // switch cave + //TODO Change the SNPOST message send to a special way to send function pointer + //SNPOST(SNEXEC, -1, 0, (void *)&QGame); // switch cave } else { @@ -1030,7 +1041,8 @@ void SwitchCave (int cav) KillText(); if (! Startup) KeyClick(); SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - SNPOST(SNEXEC, 0, 0, (void *) XCave); // switch cave + //TODO Change the SNPOST message send to a special way to send function pointer + //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave } } } @@ -1198,7 +1210,7 @@ void SYSTEM::Tick (void) if (PAIN) HeroCover(9); else if (STARTUP::Core >= CORE_MID) { - int n = random(100); + int n = new_random(100); if (n > 96) HeroCover(6+(Hero->X+Hero->W/2 < SCR_WID/2)); else { @@ -1271,7 +1283,8 @@ static void SwitchMusic (void) else { SNPOST_(SNSEQ, 122, (Music = false), NULL); - SNPOST(SNEXEC, -1, 0, (void *) SelectSound); + //TODO Change the SNPOST message send to a special way to send function pointer + // SNPOST(SNEXEC, -1, 0, (void *)&SelectSound); } } else @@ -1665,12 +1678,12 @@ void SPRITE::Touch (uint16 mask, int x, int y) static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) { - static char * Comd[] = { "Name", "Type", "Phase", "East", + static const char * Comd[] = { "Name", "Type", "Phase", "East", "Left", "Right", "Top", "Bottom", "Seq", "Near", "Take", "Portable", "Transparent", NULL }; - static char * Type[] = { "DEAD", "AUTO", "WALK", "NEWTON", "LISSAJOUS", + static const char * Type[] = { "DEAD", "AUTO", "WALK", "NEWTON", "LISSAJOUS", "FLY", NULL }; char line[LINE_MAX]; @@ -1691,7 +1704,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro VGA::Exit("Bad SPR", line); } - while ((len = sprf.Read(line)) != 0) + while ((len = sprf.Read((uint8*)line)) != 0) { ++ lcnt; if (len && line[len-1] == '\n') line[-- len] = '\0'; @@ -1738,6 +1751,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro switch (type) { case 1 : // AUTO + { Sprite = new SPRITE(NULL); if (Sprite) { @@ -1745,7 +1759,9 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$ } break; + } case 2 : // WALK + { WALK * w = new WALK(NULL); if (w && ref == 1) { @@ -1758,6 +1774,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro } Sprite = w; break; + } /* case 3 : // NEWTON NEWTON * n = new NEWTON(NULL); @@ -1774,6 +1791,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro break; */ case 4 : // LISSAJOUS + { VGA::Exit("Bad type", fname); /* LISSAJOUS * l = new LISSAJOUS(NULL); @@ -1791,15 +1809,20 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro Sprite = l; */ break; + } case 5 : // FLY + { FLY * f = new FLY(NULL); Sprite = f; //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$ break; + } default: // DEAD + { Sprite = new SPRITE(NULL); if (Sprite) Sprite->Goto(col, row); break; + } } if (Sprite) { @@ -1811,8 +1834,10 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro Sprite->Flags.Tran = tran; Sprite->Flags.Kill = true; Sprite->Flags.BDel = true; - fnsplit(fname, NULL, NULL, Sprite->File, NULL); - Sprite->ShpCnt = shpcnt; + // TODO : Get Filename from entire path + //fnsplit(fname, NULL, NULL, Sprite->File, NULL); + + Sprite->ShpCnt = shpcnt; VGA::SpareQ.Append(Sprite); } } @@ -1834,7 +1859,7 @@ static void LoadScript (const char *fname) if (scrf.Error) return; - while (scrf.Read(line) != 0) + while (scrf.Read((uint8*)line) != 0) { char *p; @@ -1941,16 +1966,22 @@ void LoadUser (void) // set scene if (STARTUP::Mode == 0) // user .SVG file found { - LoadGame(CFILE(UsrPath(UsrFnam), REA, RCrypt)); + CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt); + LoadGame(cfile); } else { - if (STARTUP::Mode == 1) LoadGame(SVG0FILE(SVG0NAME)); + if (STARTUP::Mode == 1) + { + SVG0FILE file = SVG0FILE(SVG0NAME); + LoadGame(file); + } else { LoadScript(ProgName(INI_EXT)); Music = true; - SaveGame(CFILE(SVG0NAME, WRI)); + CFILE file = CFILE(SVG0NAME, WRI); + SaveGame(file); VGA::Exit("Ok", SVG0NAME); } } @@ -2061,7 +2092,8 @@ static void RunGame (void) // main loop while (! Finis) { - if (FINIS) SNPOST(SNEXEC, -1, 0, (void *) QGame); + //TODO Change the SNPOST message send to a special way to send function pointer + // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame); MainLoop(); } @@ -2160,7 +2192,8 @@ bool ShowTitle (const char * name) #ifdef CD STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; #else - Boot * b = ReadBoot(getdisk()); + // TODO : do good boot... + Boot * b = ReadBoot(0); //getdisk()); uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; free(b); sn -= ((IDENT *)Copr)->disk; @@ -2187,7 +2220,8 @@ bool ShowTitle (const char * name) const char *n = UsrPath(UsrFnam); if (CFILE::Exist(n)) { - LoadGame(CFILE(n, REA, RCrypt), true); // only system vars + CFILE file = CFILE(n, REA, RCrypt); + LoadGame(file, true); // only system vars VGA::SetColors(SysPal, 64); Vga.Update(); if (FINIS) @@ -2242,7 +2276,7 @@ void cge_main (void) Debug( DebugLine.Flags.Hide = true; ) Debug( HorzLine.Flags.Hide = true; ) - srand((uint16) Timer()); + //srand((uint16) Timer()); Sys = new SYSTEM; if (Music && STARTUP::SoundOk) LoadMIDI(0); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 8605d17c55..30a07dd67e 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -29,6 +29,7 @@ #define __CGE__ #include "cge\wav.h" +#include "cge\vga13h.h" namespace CGE { diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 4add18bd43..38da4cda58 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -59,17 +59,17 @@ namespace CGE { #define DETECT 0xFFFF -void NONE (void); -void SB (void); -void SBM (void); -void GUS (void); -void GUSM (void); -void MIDI (void); -void AUTO (void); -void SetPortD (void); -void SetPortM (void); -void SetIRQ (void); -void SetDMA (void); +static void NONE (void); +static void SB (void); +static void SBM (void); +static void GUS (void); +static void GUSM (void); +static void MIDI (void); +static void AUTO (void); +static void SetPortD (void); +static void SetPortM (void); +static void SetIRQ (void); +static void SetDMA (void); static int DevName[] = { NONE_TEXT, SB_TEXT, SBM_TEXT, @@ -208,7 +208,8 @@ static void Select (CHOICE * cho, int hlp) { Cho = cho; Hlp = hlp; - SNPOST(SNEXEC, -1, 0, (void *) SNSelect); + //TODO Change the SNPOST message send to a special way to send function pointer + //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect); } diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index d9bcf916bb..b6530323e4 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -91,8 +91,8 @@ int FLY::L = 20, FLY::FLY (BITMAP ** shpl) : SPRITE(shpl), Tx(0), Ty(0) { - Step(random(2)); - Goto(L+random(R-L-W), T+random(B-T-H)); + Step(new_random(2)); + Goto(L+new_random(R-L-W), T+new_random(B-T-H)); } @@ -103,10 +103,10 @@ void FLY::Tick (void) Step(); if (! Flags.Kept) { - if (random(10) < 1) + if (new_random(10) < 1) { - Tx = random(3) - 1; - Ty = random(3) - 1; + Tx = new_random(3) - 1; + Ty = new_random(3) - 1; } if (X + Tx < L || X + Tx + W > R) Tx = -Tx; if (Y + Ty < T || Y + Ty + H > B) Ty = -Ty; diff --git a/engines/cge/general.h b/engines/cge/general.h index ac45f4b4ad..4633ba2d3c 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -29,6 +29,9 @@ #define __GENERAL__ #include "common/system.h" +#include "common/random.h" +#include "common/textconsole.h" +#include "common/str.h" #include "cge\jbw.h" #include @@ -57,8 +60,9 @@ typedef struct { typedef uint16 CRYPT (void *buf, uint16 siz, uint16 seed); +extern Common::RandomSource randSrc; - +#define new_random(a) (randSrc.getRandomNumber(a)) @@ -87,8 +91,8 @@ public: class ENGINE { protected: - static void interrupt (* OldTimer) (...); - static void interrupt NewTimer (...); + static void (* OldTimer) (...); + static void NewTimer (...); public: ENGINE (uint16 tdiv); ~ENGINE (void); @@ -111,7 +115,7 @@ class EMM long Top, Lim; EMS * List; int Han; - static void _seg * Frame; + static void * Frame; public: EMM::EMM (long size = 0); EMM::~EMM (void); @@ -225,8 +229,8 @@ public: long Mark (void); long Size (void); long Seek (long pos); - ftime Time (void); - void SetTime (ftime t); + //timeb Time (void); + // void SetTime (timeb t); }; diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index f8de84f5fc..892ef5ee73 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -37,7 +37,7 @@ GET_TEXT * GET_TEXT::Ptr = NULL; GET_TEXT::GET_TEXT (const char * info, char * text, int size, void (*click)(void)) -: Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), +: Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)) { int i = 2 * TEXT_HM + Font.Width(info); diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 236a2e6ddb..8f6e0ea44e 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -28,8 +28,17 @@ #ifndef __JBW__ #define __JBW__ +#include "common/scummsys.h" + namespace CGE { +#define VOL +#define INI_FILE VFILE +#define PIC_FILE VFILE +#define BMP_MODE 0 +#define DROP {} // TODO error handling +#define DROP_H + #define BEL 7 #define BS 8 #define HT 9 @@ -37,6 +46,11 @@ namespace CGE { #define FF 12 #define CR 13 +#define TRUE 1 +#define FALSE 0 + +#define MAXFILE 128 + #define NULL 0 #define OFF false #define ON true @@ -49,11 +63,11 @@ namespace CGE { #define IsAlNum(c) (IsAlpha(c) || IsDigit(c)) #define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) -#define farnew(t,n) ((t *) farmalloc(sizeof(t) * (n))) +#define farnew(t,n) ((t *) malloc(sizeof(t) * (n))) #define ArrayCount(a) (sizeof(a)/sizeof((a)[0])) #define MAX_TIMER 0x1800B0L -typedef void (_loadds MouseFunType)(void); +typedef void (MouseFunType)(void); #define Lo(d) (((int *) &d)[0]) #define Hi(d) (((int *) &d)[1]) diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index dbbc06bcb2..e4858d1d04 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -46,15 +46,17 @@ uint16 KEYBOARD::Code[0x60] = { 0,Esc,'1','2','3','4','5','6','7','8','9','0', 0*0x54,0*0x55,0*0x56,F11,F12,0*0x59,0*0x5A, 0*0x5B,0*0x5C,0*0x5D,0*0x5E,0*0x5F }; -void interrupt (* KEYBOARD::OldKeyboard) (...); +void (* KEYBOARD::OldKeyboard) (...); KEYBOARD::KEYBOARD (void) { // steal keyboard interrupt + /* TODO replace totally by scummvm handling OldKeyboard = getvect(KEYBD_INT); setvect(KEYBD_INT, NewKeyboard); + */ } @@ -63,7 +65,9 @@ KEYBOARD::KEYBOARD (void) KEYBOARD::~KEYBOARD (void) { // bring back keyboard interrupt - setvect(KEYBD_INT, OldKeyboard); + /* TODO replace totally by scummvm handling + setvect(KEYBD_INT, OldKeyboard); + */ } @@ -79,9 +83,11 @@ SPRITE * KEYBOARD::SetClient (SPRITE * spr) -void interrupt KEYBOARD::NewKeyboard (...) +void KEYBOARD::NewKeyboard (...) { // table address + // TODO keyboard ASM + /* _SI = (uint16) Key; // take keyboard code @@ -139,6 +145,7 @@ void interrupt KEYBOARD::NewKeyboard (...) asm out 61h,al // write it back asm mov al,20h // send End-Of-Interrupt asm out 20h,al // to the 8259 IC + */ } } // End of namespace CGE diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h index b38481f7d3..5e6c9ac534 100644 --- a/engines/cge/keybd.h +++ b/engines/cge/keybd.h @@ -42,14 +42,14 @@ namespace CGE { class KEYBOARD { - static void interrupt (* OldKeyboard) (...); - static void interrupt NewKeyboard (...); +public: + static void (* OldKeyboard) (...); + static void NewKeyboard (...); static uint16 Code[0x60]; static uint16 Current; static SPRITE * Client; -public: static uint8 Key[0x60]; - static uint16 Last (void) { _AX = Current; Current = 0; return _AX; } + static uint16 Last (void) { uint16 cur = Current; Current = 0; return cur; } static SPRITE * SetClient (SPRITE * spr); KEYBOARD (void); ~KEYBOARD (void); diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 2ebede93be..346631b08a 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -31,7 +31,7 @@ #include "cge/mouse.h" #include "cge/snddrv.h" #include -#include +//#include namespace CGE { @@ -151,7 +151,9 @@ void MIXER::Update (void) { Led[0]->Step(SNDDrvInfo.VOL4.ML); Led[1]->Step(SNDDrvInfo.VOL4.DL); - SNPOST_(SNEXEC, -1, 0, SNDSetVolume); + + //TODO Change the SNPOST message send to a special way to send function pointer + //SNPOST_(SNEXEC, -1, 0, (void*)&SNDSetVolume); } } // End of namespace CGE diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 94f7cbf0ac..dff2a0ff8b 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -53,6 +53,7 @@ MOUSE::MOUSE (BITMAP ** shpl) static SEQ ms[] = { { 0,0,0,0,1 }, { 1,1,0,0,1 } }; SetSeq(ms); + /* TODO Mouse handling // Mouse reset _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work) __int__(0x33); @@ -62,6 +63,7 @@ MOUSE::MOUSE (BITMAP ** shpl) Goto(SCR_WID/2, SCR_HIG/2); Z = 127; Step(1); + */ } @@ -86,6 +88,8 @@ MOUSE::~MOUSE (void) void MOUSE::On (void) { + // TODO Mouse +/* if (SeqPtr && Exist) { _CX = X + X; // horizontal position @@ -117,6 +121,7 @@ void MOUSE::On (void) Step(0); if (Busy) Busy->Step(0); } +*/ } @@ -126,6 +131,8 @@ void MOUSE::On (void) void MOUSE::Off (void) { +//TODO MOuse ASM + /* if (SeqPtr == 0) { if (Exist) @@ -140,6 +147,7 @@ void MOUSE::Off (void) Step(1); if (Busy) Busy->Step(1); } + */ } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 67a16a8563..733acb2398 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -34,8 +34,8 @@ #include "cge/mouse.h" #include "cge/cge_main.h" #include -#include -#include +//#include +//#include #include #include #include "cge/keybd.h" @@ -102,12 +102,12 @@ static void SNGame (SPRITE * spr, int num) if (Game) // continue game { - int i = random(3), hand = (dup[0]->ShpCnt == 6); + int i = new_random(3), hand = (dup[0]->ShpCnt == 6); ++ Stage; if (hand && Stage > DRESSED) ++ hand; if ( Debug( i >= 0 || ) - dup[i] == spr && random(3) == 0) + dup[i] == spr && new_random(3) == 0) { SNPOST(SNSEQ, -1, 3, dup[0]); // yes SNPOST(SNSEQ, -1, 3, dup[1]); // yes @@ -204,9 +204,9 @@ static void SNGame (SPRITE * spr, int num) } else // cont { - k1->Step(random(6)); - k2->Step(random(6)); - k3->Step(random(6)); + k1->Step(new_random(6)); + k2->Step(new_random(6)); + k3->Step(new_random(6)); ///-------------------- if (spr->Ref == 1 && KEYBOARD::Key[ALT]) { @@ -237,7 +237,7 @@ static void SNGame (SPRITE * spr, int num) Game = false; return; } - else k3->Step(random(5)); + else k3->Step(new_random(5)); } if (count < 100) { @@ -383,7 +383,8 @@ void Hide1 (SPRITE * spr) void SNGhost (BITMAP * bmp) { - bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M)); + // TODO : Get x and y from M but not using segment / offset + //bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M)); bmp->M = NULL; delete bmp; } @@ -470,7 +471,7 @@ void FeedSnail (SPRITE * spr, SNLIST snq) //-------------------------------------------------------------------------- -char * SNAIL::ComTxt[] = { "LABEL", "PAUSE", "WAIT", "LEVEL", +const char * SNAIL::ComTxt[] = { "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", "SAY", "INF", "TIME", "CAVE", "KILL", "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", "GIVE", @@ -502,7 +503,7 @@ SNAIL::SNAIL (bool turbo) SNAIL::~SNAIL (void) { - if (SNList) farfree(SNList); + if (SNList) free(SNList); } @@ -766,7 +767,7 @@ void SNCover (SPRITE * spr, int xref) xspr->Cave = spr->Cave; xspr->Goto(spr->X, spr->Y); ExpandSprite(xspr); - if ((xspr->Flags.Shad = spr->Flags.Shad) == true) + if ((xspr->Flags.Shad = spr->Flags.Shad) == TRUE) { VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr); spr->Flags.Shad = false; @@ -786,7 +787,7 @@ void SNUncover (SPRITE * spr, SPRITE * xspr) spr->Flags.Hide = false; spr->Cave = xspr->Cave; spr->Goto(xspr->X, xspr->Y); - if ((spr->Flags.Shad = xspr->Flags.Shad) == true) + if ((spr->Flags.Shad = xspr->Flags.Shad) == TRUE) { VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr); xspr->Flags.Shad = false; @@ -1099,7 +1100,7 @@ void SNFlash (bool on) if (pal) { int i; - _fmemcpy(pal, SysPal, PAL_SIZ); + memcpy(pal, SysPal, PAL_SIZ); for (i = 0; i < PAL_CNT; i ++) { register int c; @@ -1285,7 +1286,8 @@ void SNAIL::RunCom (void) case SNSOUND : SNSound(sprel, snc->Val, count); count = 1; break; case SNCOUNT : count = snc->Val; break; - case SNEXEC : ((void(*)(int)) (snc->Ptr))(snc->Val); break; + // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST + //case SNEXEC : ((void(*)(int)) (snc->Ptr))(snc->Val); break; case SNSTEP : sprel->Step(); break; case SNZTRIM : SNZTrim(sprel); break; case SNGHOST : SNGhost((BITMAP *) snc->Ptr); break; diff --git a/engines/cge/snail.h b/engines/cge/snail.h index bf47fa13d4..88bb5f09dd 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -83,12 +83,12 @@ enum SNLIST { NEAR, TAKE }; class SNAIL { +public: struct COM { SNCOM Com; int Ref; int Val; void * Ptr; } * SNList; uint8 Head, Tail; bool Turbo, Busy, TextDelay; uint16 Pause; -public: - static char * ComTxt[]; + static const char * ComTxt[]; bool TalkEnable; SNAIL (bool turbo = false); ~SNAIL (void); diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 662d480778..8d29a807d7 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -130,6 +130,7 @@ EC void SNDMIDIStop (void); // WARNING: Uses ALL registers! EC void SNDMIDIPlay (void); -// End of namespace CGE +} // End of namespace CGE + #endif diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 81dd457603..11385c12e3 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -39,7 +39,7 @@ #include "cge/text.h" #include "cge/cfile.h" #include "cge/vol.h" -#include +//#include namespace CGE { @@ -95,7 +95,7 @@ void SOUND::Play (DATACK * wav, int pan, int cnt) if (wav) { Stop(); - smpinf.saddr = (char *) &*(wav->EAddr()); + smpinf.saddr = (uint8 *) &*(wav->EAddr()); smpinf.slen = (uint16)wav->Size(); smpinf.span = pan; smpinf.sflag = cnt; @@ -196,7 +196,8 @@ void FX::Preload (int ref0) { static char fname[] = "FX00000.WAV"; wtom(ref, fname+2, 10, 5); - DATACK * wav = LoadWave(&INI_FILE(fname), &Emm); + INI_FILE file = INI_FILE(fname); + DATACK * wav = LoadWave(&file, &Emm); if (wav) { HAN * p = &Cache[Find(0)]; @@ -216,7 +217,8 @@ DATACK * FX::Load (int idx, int ref) static char fname[] = "FX00000.WAV"; wtom(ref, fname+2, 10, 5); - DATACK * wav = LoadWave(&INI_FILE(fname), &Emm); + INI_FILE file = INI_FILE(fname); + DATACK * wav = LoadWave(&file, &Emm); if (wav) { HAN * p = &Cache[idx]; @@ -309,13 +311,13 @@ EC void * Patch (int pat) if (! snd.Error) { uint16 siz = (uint16) snd.Size(); - p = (uint8 *) farmalloc(siz); + p = (uint8 *) malloc(siz); if (p) { snd.Read(p, siz); if (snd.Error) { - farfree(p); + free(p); p = NULL; } } diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 0e45e65b73..7e5ac71782 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +//#include #include #ifdef DEBUG @@ -60,17 +60,16 @@ static STARTUP StartUp; -void quit_now (int ref) -{ - fputs(Text[ref], stderr); - fputc('\n', stderr); - _exit(1); +void quit_now(int ref){ + error("%d\n", Text[ref]); } bool STARTUP::get_parms (void) { + // TODO do params + /* int i = _argc; while (i > 1) { @@ -114,6 +113,7 @@ bool STARTUP::get_parms (void) #endif #endif if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; + */ return true; } @@ -122,6 +122,8 @@ bool STARTUP::get_parms (void) STARTUP::STARTUP (void) { + //TOdO startup in scummvm + /* uint32 m = farcoreleft() >> 10; if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF; @@ -149,6 +151,7 @@ STARTUP::STARTUP (void) if (! cfg.Error) STARTUP::SoundOk = 1; } } + */ } diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 9c15ac1b65..d305d1d27e 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -31,8 +31,8 @@ #include "cge/game.h" #include "cge/mouse.h" #include -#include -#include +//#include +//#include namespace CGE { @@ -70,9 +70,9 @@ FONT::FONT (const char * name) FONT::~FONT (void) { - farfree(Map); - farfree(Pos); - farfree(Wid); + free(Map); + free(Pos); + free(Wid); } @@ -212,10 +212,10 @@ void TALK::Update (const char * tx) else { int cw = Font.Wid[*tx], i; - char * f = Font.Map + Font.Pos[*tx]; + uint8 * f = Font.Map + Font.Pos[*tx]; for (i = 0; i < cw; i ++) { - char * p = m; + uint8 * p = m; uint16 n; register uint16 b = * (f ++); for (n = 0; n < FONT_HIG; n ++) @@ -246,13 +246,13 @@ BITMAP * TALK::Box (uint16 w, uint16 h) if (h < 8) h = 8; b = farnew(uint8, n = w * h); if (! b) VGA::Exit("No core"); - _fmemset(b, TEXT_BG, n); + memset(b, TEXT_BG, n); if (Mode) { p = b; q = b + n - w; - _fmemset(p, LGRAY, w); - _fmemset(q, DGRAY, w); + memset(p, LGRAY, w); + memset(q, DGRAY, w); while (p < q) { p += w; @@ -301,10 +301,10 @@ void TALK::PutLine (int line, const char * text) // clear whole rectangle p = v; // assume blanked line above text - _fmemcpy(p, p-lsiz, rsiz); p += psiz; // tricky replicate lines for plane 0 - _fmemcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 1 - _fmemcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 2 - _fmemcpy(p, p-lsiz, rsiz); // same for plane 3 + memcpy(p, p-lsiz, rsiz); p += psiz; // tricky replicate lines for plane 0 + memcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 1 + memcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 2 + memcpy(p, p-lsiz, rsiz); // same for plane 3 // paint text line if (text) diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 76539fbcf9..aab6834c28 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -29,6 +29,8 @@ #define __TALK__ #include "cge/vga13h.h" +#include "cge/general.h" +#include "cge/jbw.h" //#include namespace CGE { @@ -45,7 +47,7 @@ namespace CGE { - +#define MAXPATH 128 class FONT { @@ -105,4 +107,4 @@ public: } // End of namespace CGE -#endif \ No newline at end of file +#endif diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index df8ca4cfe5..9ee6244f22 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -50,11 +50,10 @@ TEXT::TEXT (const char * fname, int size) { Cache = new HAN[size]; MergeExt(FileName, fname, SAY_EXT); - if (! INI_FILE::Exist(FileName)) - { - fputs("No talk\n", stderr); - _exit(1); - } + if (! INI_FILE::Exist(FileName)) { + error("No talk\n"); + } + for (Size = 0; Size < size; Size ++) { Cache[Size].Ref = 0; @@ -124,7 +123,7 @@ void TEXT::Preload (int from, int upto) char line[LINE_MAX+1]; int n; - while ((n = tf.Read(line)) != 0) + while ((n = tf.Read((uint8*)line)) != 0) { char * s; int ref; @@ -168,7 +167,7 @@ char * TEXT::Load (int idx, int ref) char line[LINE_MAX+1]; int n; - while ((n = tf.Read(line)) != 0) + while ((n = tf.Read((uint8*)line)) != 0) { char * s; @@ -289,12 +288,15 @@ void Inf (const char * txt) void SayTime (SPRITE * spr) { +//TODO Get Time +/* static char t[] = "00:00"; struct time ti; gettime(&ti); wtom(ti.ti_hour, t+0, 10, 2); wtom(ti.ti_min, t+3, 10, 2); Say((*t == '0') ? (t+1) : t, spr); + */ } diff --git a/engines/cge/text.h b/engines/cge/text.h index 7394e04b3f..222a3abf7d 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -30,7 +30,7 @@ #include "cge/talk.h" #include "cge/jbw.h" -#include +//#include namespace CGE { @@ -83,4 +83,4 @@ void KillText (void); } // End of namespace CGE -#endif \ No newline at end of file +#endif diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 415bff7225..86b04bfe0c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -30,15 +30,15 @@ #include "cge/bitmap.h" #include "cge/vol.h" #include "cge/text.h" -#include +//#include #include #include #include #include #include -#include +//#include #include -#include +//#include #include namespace CGE { @@ -112,11 +112,13 @@ char * NumStr (char * str, int num) - +// TODO Video ASM +/* static void Video (void) { static uint16 SP_S; + asm push bx asm push bp asm push si @@ -131,8 +133,9 @@ static void Video (void) asm pop si asm pop bp asm pop bx -} +} + */ @@ -140,6 +143,7 @@ static void Video (void) uint16 * SaveScreen (void) { + /* TODO ASM uint16 cxy, cur, siz, * scr = NULL, * sav; // horizontal size of text mode screen @@ -187,9 +191,11 @@ uint16 * SaveScreen (void) sav[0] = siz; sav[1] = cur; sav[2] = cxy; - _fmemcpy(sav+3, scr, siz * 2); + memcpy(sav+3, scr, siz * 2); } return sav; + */ + return 0; } @@ -198,6 +204,8 @@ uint16 * SaveScreen (void) void RestoreScreen (uint16 * &sav) { + // TODO RestoreScreen ASM + /* uint16 * scr = NULL; asm mov ax,0x40 // system data segment @@ -209,7 +217,7 @@ void RestoreScreen (uint16 * &sav) sto: // store screen address asm mov word ptr scr+2,ax - _fmemcpy(scr, sav+3, sav[0] * 2); + memcpy(scr, sav+3, sav[0] * 2); _AH = 0x0F; Video(); // active page @@ -221,8 +229,9 @@ void RestoreScreen (uint16 * &sav) _DX = sav[2]; _AH = 0x02; Video(); // set cursor - farfree(sav); + free(sav); sav = NULL; + */ } @@ -318,11 +327,12 @@ extern "C" void TimerProc (void) */ -void interrupt ENGINE::NewTimer (...) +void ENGINE::NewTimer (...) { static SPRITE * spr; static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - + // TODO Timer ASM + /* ___1152_Hz___: SNDMIDIPlay(); @@ -379,6 +389,8 @@ void interrupt ENGINE::NewTimer (...) asm mov sp,oldSP -- run; } + + */ } @@ -591,7 +603,7 @@ SPRITE * SPRITE::Expand (void) if ((Ext = new SPREXT) == NULL) DROP("No core", NULL); if (*File) { - static char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; + static const char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; BMP_PTR * shplist = new BMP_PTR [ShpCnt+1]; SEQ * seq = NULL; @@ -615,7 +627,7 @@ SPRITE * SPRITE::Expand (void) VGA::Exit("Bad SPR", fname); } - while ((len = sprf.Read(line)) != 0) + while ((len = sprf.Read((uint8*)line)) != 0) { ++ lcnt; if (len && line[len-1] == '\n') line[-- len] = '\0'; @@ -624,11 +636,16 @@ SPRITE * SPRITE::Expand (void) switch (TakeEnum(Comd, strtok(line, " =\t"))) { case 0 : // Name + { SetName(strtok(NULL, "")); break; + } case 1 : // Phase + { shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); break; + } case 2 : // Seq + { seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); if (seq == NULL) VGA::Exit("No core", fname); @@ -646,7 +663,9 @@ SPRITE * SPRITE::Expand (void) s->Dy = atoi(strtok(NULL, " \t,;/")); s->Dly = atoi(strtok(NULL, " \t,;/")); break; + } case 3 : // Near + { if (NearPtr != NO_PTR) { nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); @@ -661,8 +680,10 @@ SPRITE * SPRITE::Expand (void) c->Ptr = NULL; } } + } break; case 4 : // Take + { if (TakePtr != NO_PTR) { tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); @@ -678,6 +699,7 @@ SPRITE * SPRITE::Expand (void) } } break; + } } } } @@ -693,10 +715,10 @@ SPRITE * SPRITE::Expand (void) SetSeq(seq); } else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); - disable(); + //disable(); // disable interupt SetShapeList(shplist); - enable(); + //enable(); // enable interupt if (nea) nea[neacnt-1].Ptr = Ext->Near = nea; else NearPtr = NO_PTR; if (tak) tak[takcnt-1].Ptr = Ext->Take = tak; else TakePtr = NO_PTR; } @@ -807,7 +829,7 @@ void SPRITE::KillXlat (void) switch (MemType(m)) { case NEAR_MEM : delete[] (uint8 *) m; break; - case FAR_MEM : farfree(m); break; + case FAR_MEM : free(m); break; } for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; Flags.Xlat = false; @@ -863,7 +885,7 @@ void SPRITE::Center (void) void SPRITE::Show (void) { register SPREXT * e; - asm cli // critic section... + // asm cli // critic section... e = Ext; e->x0 = e->x1; e->y0 = e->y1; @@ -871,7 +893,7 @@ void SPRITE::Show (void) e->x1 = X; e->y1 = Y; e->b1 = Shp(); - asm sti // ...done! +// asm sti // ...done! if (! Flags.Hide) { if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); @@ -919,8 +941,9 @@ BMP_PTR SPRITE::Ghost (void) bmp->W = e->b1->W; bmp->H = e->b1->H; if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); - bmp->V = (uint8 *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); - bmp->M = (uint8 *) MK_FP(e->y1, e->x1); + bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment + //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); return bmp; } return NULL; @@ -1095,11 +1118,16 @@ DAC * VGA::NewColors = NULL; bool VGA::SetPal = false; int VGA::Mono = 0; QUEUE VGA::ShowQ = true, VGA::SpareQ = false; + +// TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that +uint8 * VGA::Page[4] = { 0, 0, 0, 0 }; + +/* uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), (uint8 *) MK_FP(SCR_SEG, 0x4000), (uint8 *) MK_FP(SCR_SEG, 0x8000), (uint8 *) MK_FP(SCR_SEG, 0xC000) }; - +*/ @@ -1114,13 +1142,16 @@ VGA::VGA (int mode) char * txt = Text[i]; if (txt) { - puts(txt); - #ifndef DEBUG +// puts(txt); + warning(txt); + #ifndef DEBUG std = false; #endif } } - if (std) puts(Copr); + if (std) +// puts(Copr); + warning(Copr); SetStatAdr(); if (StatAdr != VGAST1_) ++ Mono; if (IsVga()) @@ -1146,33 +1177,27 @@ VGA::~VGA (void) Mono = 0; if (IsVga()) { + Common::String buffer = ""; Clear(); SetMode(OldMode); SetColors(); RestoreScreen(OldScreen); Sunrise(OldColors); - if (OldColors) farfree(OldColors); - if (NewColors) farfree(NewColors); - if (Msg) fputs(Msg, stderr); + if (OldColors) free(OldColors); + if (NewColors) free(NewColors); + if (Msg) + buffer = Common::String(Msg); if (Nam) - { - fputs(" [", stderr); - fputs(Nam, stderr); - fputc(']', stderr); - } - if (Msg || Nam) fputc('\n', stderr); - #ifdef REPORT - fputs(Report, stderr); - #endif + buffer = buffer + " [" + Nam + "]"; + + warning(buffer.c_str()); } } - - - void VGA::SetStatAdr (void) { + /* TODO SetStatADR ASM asm mov dx,VGAMIr_ asm in al,dx asm test al,1 // CGA addressing mode flag @@ -1181,6 +1206,7 @@ void VGA::SetStatAdr (void) asm xor al,0x60 // MDA addressing set_mode_adr: StatAdr = _AX; + */ } @@ -1191,6 +1217,8 @@ void VGA::SetStatAdr (void) #pragma argsused void VGA::WaitVR (bool on) { + // TODO Wait vertical retrace ASM +/* _DX = StatAdr; _AH = (on) ? 0x00 : 0x08; @@ -1203,6 +1231,7 @@ void VGA::WaitVR (bool on) asm jnz wait asm xor ah,0x08 asm loop wait + */ } @@ -1212,6 +1241,7 @@ void VGA::WaitVR (bool on) void VGA::Setup (VgaRegBlk * vrb) { +/* TODO VGA setup WaitVR(); // *--LOOK!--* resets VGAATR logic asm cld asm mov si, vrb // take address of parameter table @@ -1248,6 +1278,7 @@ void VGA::Setup (VgaRegBlk * vrb) asm jmp write // continue standard routine xit: + */ } @@ -1257,6 +1288,8 @@ void VGA::Setup (VgaRegBlk * vrb) int VGA::SetMode (int mode) { + /* TODO VGA Set Mode + Clear(); // get current mode asm mov ah,0x0F @@ -1275,6 +1308,8 @@ int VGA::SetMode (int mode) // return previous mode asm pop ax return _AX; + */ + return 0; } @@ -1284,6 +1319,7 @@ int VGA::SetMode (int mode) void VGA::GetColors (DAC * tab) { + /* TODO GetColors ASM asm cld asm les di,tab // color table asm mov dx,0x3C7 // PEL address read mode register @@ -1300,6 +1336,8 @@ void VGA::GetColors (DAC * tab) sto: asm stosb // store 1 color asm loop gc // next one? + + */ } @@ -1307,6 +1345,9 @@ void VGA::GetColors (DAC * tab) void VGA::SetColors (DAC * tab, int lum) { + + /* TODO SetColors + DAC * des = NewColors; asm push ds @@ -1350,6 +1391,7 @@ void VGA::SetColors (DAC * tab, int lum) asm cmp di,cx asm jb mono } + */ SetPal = true; } @@ -1360,7 +1402,7 @@ void VGA::SetColors (DAC * tab, int lum) void VGA::SetColors (void) { - _fmemset(NewColors, 0, PAL_SIZ); + memset(NewColors, 0, PAL_SIZ); UpdateColors(); } @@ -1422,6 +1464,7 @@ void VGA::Show (void) void VGA::UpdateColors (void) { + /* TODO UpdateColors ASM DAC * tab = NewColors; asm push ds @@ -1445,6 +1488,7 @@ void VGA::UpdateColors (void) asm pop ds + */ } @@ -1455,6 +1499,8 @@ void VGA::UpdateColors (void) void VGA::Update (void) { + // TODO VGA Update + /* uint8 * p = Page[1]; Page[1] = Page[0]; Page[0] = p; @@ -1466,7 +1512,7 @@ void VGA::Update (void) asm dec al asm mov ah,byte ptr p+1 asm out dx,ax - +*/ if (! SpeedTest) WaitVR(); if (SetPal) @@ -1485,6 +1531,7 @@ void VGA::Update (void) void VGA::Clear (uint8 color) { + /* TODO Clear ASM uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); asm mov dx,VGASEQ_ @@ -1497,6 +1544,7 @@ void VGA::Clear (uint8 color) asm mov al,color asm rep stosb asm stosb + */ } @@ -1506,6 +1554,7 @@ void VGA::Clear (uint8 color) void VGA::CopyPage (uint16 d, uint16 s) { + /* TODO CopyPage uint8 * S = Page[s & 3], * D = Page[d & 3]; asm mov dx,VGAGRA_ @@ -1536,6 +1585,7 @@ void VGA::CopyPage (uint16 d, uint16 s) asm pop dx asm pop ax asm out dx,al // end of copy mode + */ } @@ -1546,13 +1596,17 @@ void VGA::CopyPage (uint16 d, uint16 s) void VGA::Exit (const char * txt, const char * name) { + // TODO Properly exit + /* Msg = txt; Nam = name; - #ifdef REPORT + + #ifdef REPORT wtom(coreleft(), Report + NREP, 10, 5); dwtom(farcoreleft(), Report + FREP, 10, 6); #endif exit(0); + */ } @@ -1573,6 +1627,8 @@ void VGA::Exit (int tref, const char * name) void BITMAP::XShow (int x, int y) { + // TODO XShow ASM + /* uint8 rmsk = x % 4, mask = 1 << rmsk, * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; @@ -1650,6 +1706,8 @@ void BITMAP::XShow (int x, int y) asm pop ds asm pop si asm pop bx + + */ } @@ -1659,6 +1717,9 @@ void BITMAP::XShow (int x, int y) void BITMAP::Show (int x, int y) { + + // TODO Show ASM + /* uint8 mask = 1 << (x & 3), * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); uint8 * v = V; @@ -1722,6 +1783,7 @@ void BITMAP::Show (int x, int y) asm cmp ah,mask asm jne plane asm pop ds + */ } @@ -1730,6 +1792,8 @@ void BITMAP::Show (int x, int y) void BITMAP::Hide (int x, int y) { + // TODO Bitmap Hide ASM + /* uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); HideDesc * b = B; @@ -1790,6 +1854,7 @@ void BITMAP::Hide (int x, int y) asm pop ds asm pop si // asm pop bx +*/ } } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index e5c34d238f..40dfc41a12 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -325,7 +325,7 @@ uint8 Closest (CBLK * pal, CBLK x) char * NumStr (char * str, int num); - void Video (void); + //static void Video (void); uint16 * SaveScreen (void); void RestoreScreen (uint16 * &sav); SPRITE * SpriteAt (int x, int y); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 8178868578..46bb45e9c9 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -28,7 +28,7 @@ #include "cge/vmenu.h" #include "cge/mouse.h" #include -#include +//#include namespace CGE { @@ -51,9 +51,9 @@ MENU_BAR::MENU_BAR (uint16 w) int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; uint8 * p = farnew(uint8, i), * p1, * p2; - _fmemset(p+w, TRANS, i-2*w); - _fmemset(p, MB_LT, w); - _fmemset(p+i-w, MB_RB, w); + memset(p+w, TRANS, i-2*w); + memset(p, MB_LT, w); + memset(p+i-w, MB_RB, w); p1 = p; p2 = p+i-1; for (i = 0; i < h; i ++) @@ -89,7 +89,7 @@ char * VMGather (CHOICE * list) len += strlen(cp->Text); ++ h; } - vmgt = new uint8[len+h]; + vmgt = new char[len+h]; if (vmgt) { *vmgt = '\0'; diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 9f4391cc9a..40490f2271 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -28,6 +28,7 @@ #include "cge/vol.h" //#include #include "common/system.h" +#include "common/str.h" #include #include #include @@ -41,7 +42,10 @@ namespace CGE { #ifndef DROP_H - #define DROP(m,n) { printf("%s [%s]\n", (m), (n)); _exit(1); } + // TODO Replace printf by scummvm equivalent + + #define DROP(m,n) { } + //#define DROP(m,n) { printf("%s [%s]\n", (m), (n)); _exit(1); } #endif @@ -66,7 +70,7 @@ VFILE::VFILE (const char * name, IOMODE mode) { if (Dat.File.Error || Cat.Error) DROP("Bad volume data", NULL); BT_KEYPACK * kp = Cat.Find(name); - if (_fstricmp(kp->Key, name) != 0) Error = ENOFILE; + if (scumm_stricmp(kp->Key, name) != 0) Error = 1; EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; } #ifdef VOL_UPD @@ -89,7 +93,7 @@ VFILE::~VFILE (void) bool VFILE::Exist (const char * name) { - return _fstricmp(Cat.Find(name)->Key, name) == 0; + return scumm_stricmp(Cat.Find(name)->Key, name) == 0; } diff --git a/engines/cge/vol.h b/engines/cge/vol.h index b63b08e7a1..421bd7593c 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -54,7 +54,7 @@ namespace CGE { class DAT { - friend VFILE; + friend class VFILE; static VOLBASE File; public: static bool Append (uint8 * buf, uint16 len); diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 0d1408ccf6..a8da4f9e72 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -135,6 +135,7 @@ extern CKID DATA; DATACK * LoadWave (XFILE * file, EMM * emm = NULL); -// End of namespace CGE +} // End of namespace CGE + #endif -- cgit v1.2.3 From 92076d464148d2d6ecab544076bc10718a463c7b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 11 Jun 2011 23:27:27 +0200 Subject: CGE: Remove DROP() macro --- engines/cge/bitmap.cpp | 31 ++++++++++++------------------- engines/cge/btfile.cpp | 18 ++---------------- engines/cge/cfile.cpp | 20 ++++---------------- engines/cge/drop.h | 28 ---------------------------- engines/cge/jbw.h | 2 -- engines/cge/snail.cpp | 4 ++-- engines/cge/sound.cpp | 12 ------------ engines/cge/talk.cpp | 6 +++--- engines/cge/vga13h.cpp | 3 ++- engines/cge/vga13h.h | 2 +- engines/cge/vol.cpp | 18 ++---------------- 11 files changed, 28 insertions(+), 116 deletions(-) delete mode 100644 engines/cge/drop.h diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 10f19029d6..1201b84fc6 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -33,17 +33,6 @@ #include "cge/vol.h" #endif - -#ifndef DROP_H -// TODO replace printf by scummvm equivalent -#define DROP(m,n) {} -//#define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } -#endif - - -//#include -//#include -//#include #include #include "cge/cfile.h" #include "common/system.h" @@ -73,7 +62,7 @@ BITMAP::BITMAP (const char * fname, bool rem) PIC_FILE file(pat); if (file.Error == 0) if (! VBMLoad(&file)) - DROP("Bad VBM", fname); + error("Bad VBM [%s]", fname); } else #endif @@ -92,10 +81,11 @@ BITMAP::BITMAP (const char * fname, bool rem) M = NULL; } } - else DROP("Bad BMP", fname); + else + error("Bad BMP [%s]", fname); } #else - DROP("Bad VBM", fname); + error("Bad VBM [%s]", fname); #endif } } @@ -127,7 +117,8 @@ BITMAP::BITMAP (uint16 w, uint16 h, uint8 fill) uint16 psiz = H * lsiz; // - last gape, but + plane trailer uint8 * v = new uint8[4 * psiz // the same for 4 planes + H * sizeof(*B)]; // + room for wash table - if (v == NULL) DROP("No core", NULL); + if (v == NULL) + error("No core"); * (uint16 *) v = CPY | dsiz; // data chunk hader memset(v+2, fill, dsiz); // data bytes @@ -160,7 +151,8 @@ BITMAP::BITMAP (const BITMAP& bmp) uint16 vsiz = (uint8*)(bmp.B) - (uint8*)(v0); uint16 siz = vsiz + H * sizeof(HideDesc); uint8 * v1 = farnew(uint8, siz); - if (v1 == NULL) DROP("No core", NULL); + if (v1 == NULL) + error("No core"); memcpy(v1, v0, siz); B = (HideDesc *) ((V = v1) + vsiz); } @@ -198,7 +190,8 @@ BITMAP& BITMAP::operator = (const BITMAP& bmp) uint16 vsiz = (uint8*)bmp.B - (uint8*)v0; uint16 siz = vsiz + H * sizeof(HideDesc); uint8 * v1 = farnew(uint8, siz); - if (v1 == NULL) DROP("No core", NULL); + if (v1 == NULL) + error("No core"); memcpy(v1, v0, siz); B = (HideDesc *) ((V = v1) + vsiz); } @@ -337,7 +330,7 @@ BMP_PTR BITMAP::Code (void) V = farnew(uint8, sizV + H * sizeof(*B)); if (! V) { - DROP("No core", NULL); + error("No core"); } B = (HideDesc *) (V + sizV); } @@ -442,7 +435,7 @@ bool BITMAP::VBMSave (XFILE * f) bool BITMAP::VBMLoad (XFILE * f) { - uint16 p, n; + uint16 p = 0, n = 0; if (f->Error == 0) f->Read((uint8 *)&p, sizeof(p)); if (f->Error == 0) f->Read((uint8 *)&n, sizeof(n)); if (f->Error == 0) f->Read((uint8 *)&W, sizeof(W)); diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 1851068e2d..7c61157eba 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -31,23 +31,8 @@ #include "common/str.h" #include - - -#ifdef DROP_H - #include "cge/drop.h" -#else - #include - #include -#endif - namespace CGE { -#ifndef DROP_H - // TODO replace printf by scummvm equivalent -#define DROP(m,n) - //#define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } -#endif - #ifndef BT_SIZE #define BT_SIZE K(1) #endif @@ -70,7 +55,8 @@ BTFILE::BTFILE (const char * name, IOMODE mode, CRYPT * crpt) Buff[i].PgNo = BT_NONE; Buff[i].Indx = -1; Buff[i].Updt = FALSE; - if (Buff[i].Page == NULL) DROP("No core", NULL); + if (Buff[i].Page == NULL) + error("No core"); } } diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 4d555c979d..1a23c3d0f9 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -29,24 +29,10 @@ #include #include #include -//#include #include "common/system.h" -#ifdef DROP_H - #include "cge/drop.h" -#else - #include - #include -#endif - namespace CGE { -#ifndef DROP_H - //TODO Replace by scummvm printf -#define DROP(m,n) {} - //#define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } -#endif - IOBUF::IOBUF (IOMODE mode, CRYPT * crpt) : IOHAND(mode, crpt), BufMark(0), @@ -54,7 +40,8 @@ IOBUF::IOBUF (IOMODE mode, CRYPT * crpt) Lim(0) { Buff = farnew(uint8, IOBUF_SIZE); - if (Buff == NULL) DROP("No core for I/O", NULL); + if (Buff == NULL) + error("No core for I/O"); } @@ -72,7 +59,8 @@ IOBUF::IOBUF (const char * name, IOMODE mode, CRYPT * crpt) Lim(0) { Buff = farnew(uint8, IOBUF_SIZE); - if (Buff == NULL) DROP("No core for I/O", name); + if (Buff == NULL) + error("No core for I/O [%s]", name); } diff --git a/engines/cge/drop.h b/engines/cge/drop.h deleted file mode 100644 index bdd08b6810..0000000000 --- a/engines/cge/drop.h +++ /dev/null @@ -1,28 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/vga13h.h" diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 8f6e0ea44e..bb01017d00 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -36,8 +36,6 @@ namespace CGE { #define INI_FILE VFILE #define PIC_FILE VFILE #define BMP_MODE 0 -#define DROP {} // TODO error handling -#define DROP_H #define BEL 7 #define BS 8 diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 733acb2398..c63ba824b4 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -82,8 +82,8 @@ static void SNGame (SPRITE * spr, int num) #define STAGES 8 #define DRESSED 3 static SPRITE * dup[3] = { NULL, NULL, NULL }; - int buref; - int Stage; + int buref = 0; + int Stage = 0; for (dup[0] = VGA::ShowQ.First(); dup[0]; dup[0] = dup[0]->Next) { diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 11385c12e3..d40789beee 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -29,25 +29,13 @@ #include "cge/startup.h" #include "cge/sound.h" -#ifdef DROP_H - #include "cge/drop.h" -#else - #include - #include -#endif - #include "cge/text.h" #include "cge/cfile.h" #include "cge/vol.h" -//#include namespace CGE { -#ifndef DROP_H - #define DROP(m,n) { printf("%s [%s]\n", m, n); _exit(1); } -#endif - bool Music = true; FX Fx = 16; // must precede SOUND!! SOUND Sound; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index d305d1d27e..851b96cf99 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -60,7 +60,8 @@ FONT::FONT (const char * name) Map = farnew(uint8, MAP_SIZ); Pos = farnew(uint16, POS_SIZ); Wid = farnew(uint8, WID_SIZ); - if (Map == NULL || Pos == NULL || Wid == NULL) DROP("No core", NULL); + if (Map == NULL || Pos == NULL || Wid == NULL) + error("No core"); MergeExt(Path, name, FONT_EXT); Load(); } @@ -180,7 +181,7 @@ void TALK::Update (const char * tx) { uint16 vmarg = (Mode) ? TEXT_VM : 0; uint16 hmarg = (Mode) ? TEXT_HM : 0; - uint16 mw, mh, ln = vmarg; + uint16 mw = 0, mh, ln = vmarg; const char * p; uint8 * m; @@ -188,7 +189,6 @@ void TALK::Update (const char * tx) { uint16 k = 2 * hmarg; mh = 2 * vmarg + FONT_HIG; - mw = 0; for (p = tx; *p; p ++) { if (*p == '|' || *p == '\n') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 86b04bfe0c..d95be1d94c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -600,7 +600,8 @@ SPRITE * SPRITE::Expand (void) { bool enbl = HEART::Enable; HEART::Enable = false; - if ((Ext = new SPREXT) == NULL) DROP("No core", NULL); + if ((Ext = new SPREXT) == NULL) + error("No core"); if (*File) { static const char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 40dfc41a12..0b9fa8596d 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -295,7 +295,7 @@ template uint8 Closest (CBLK * pal, CBLK x) { #define f(col,lum) ((((uint16)(col))<<8)/lum) - uint16 i, dif = 0xFFFF, found; + uint16 i, dif = 0xFFFF, found = 0; uint16 L = x.R + x.G + x.B; if (! L) ++ L; uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); for (i = 0; i < 256; i ++) diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 40490f2271..9af2efe8f3 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -26,29 +26,14 @@ */ #include "cge/vol.h" -//#include #include "common/system.h" #include "common/str.h" #include #include #include -#ifdef DROP_H - #include "cge/drop.h" -#else - #include -#endif - namespace CGE { -#ifndef DROP_H - // TODO Replace printf by scummvm equivalent - - #define DROP(m,n) { } - //#define DROP(m,n) { printf("%s [%s]\n", (m), (n)); _exit(1); } -#endif - - #ifdef VOL_UPD BTFILE VFILE::Cat(CAT_NAME, UPD, CRP); VOLBASE DAT::File(DAT_NAME, UPD, CRP); @@ -68,7 +53,8 @@ VFILE::VFILE (const char * name, IOMODE mode) { if (mode == REA) { - if (Dat.File.Error || Cat.Error) DROP("Bad volume data", NULL); + if (Dat.File.Error || Cat.Error) + error("Bad volume data"); BT_KEYPACK * kp = Cat.Find(name); if (scumm_stricmp(kp->Key, name) != 0) Error = 1; EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; -- cgit v1.2.3 From 3bef49c003a888b935dc2aeaf2aa00e66249e71c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 12 Jun 2011 01:13:44 +0200 Subject: CGE: Suppress VGA::Exit, some cleanup, add one missing source --- engines/cge/cge_main.cpp | 56 ++++++++++++++--------------- engines/cge/general.h | 4 +-- engines/cge/module.mk | 1 + engines/cge/stdpal.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/talk.cpp | 3 +- engines/cge/vga13h.cpp | 66 ++++++++++------------------------ engines/cge/vga13h.h | 2 -- 7 files changed, 142 insertions(+), 82 deletions(-) create mode 100644 engines/cge/stdpal.cpp diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index ebf3f3f9fd..4c3611650c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -44,15 +44,12 @@ #include "cge/gettext.h" #include "cge/mixer.h" #include "cge/cge_main.h" -//#include #include #include #include #include #include -//#include #include -//#include #include #include "common/str.h" @@ -191,7 +188,7 @@ uint8 & CLUSTER::Cell (void) bool CLUSTER::Protected (void) { if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return true; - // TODO AsM + warning("STUB: CLUSTER::Protected()"); /* _DX = (MAP_ZCNT << 8) + MAP_XCNT; _BX = (uint16) this; @@ -291,12 +288,14 @@ static void LoadGame (XFILE& file, bool tiny = false) for (st = SavTab; st->Ptr; st ++) { - if (file.Error) VGA::Exit("Bad SVG"); + if (file.Error) + error("Bad SVG"); file.Read((uint8 *) ((tiny || st->Flg) ? st->Ptr : &i), st->Len); } file.Read((uint8 *) &i, sizeof(i)); - if (i != SVGCHKSUM) VGA::Exit(BADSVG_TEXT); + if (i != SVGCHKSUM) + error(Text[BADSVG_TEXT]); if (STARTUP::Core < CORE_HIG) Music = false; if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) { @@ -316,7 +315,8 @@ static void LoadGame (XFILE& file, bool tiny = false) S.Prev = S.Next = NULL; spr = (scumm_stricmp(S.File+2, "MUCHA") == 0) ? new FLY(NULL) : new SPRITE(NULL); - if (spr == NULL) VGA::Exit("No core"); + if (spr == NULL) + error("No core"); *spr = S; VGA::SpareQ.Append(spr); } @@ -360,7 +360,8 @@ static void SaveGame (XFILE& file) for (st = SavTab; st->Ptr; st ++) { - if (file.Error) VGA::Exit("Bad SVG"); + if (file.Error) + error("Bad SVG"); file.Write((uint8 *) st->Ptr, st->Len); } @@ -585,7 +586,7 @@ void WALK::Park (void) void WALK::FindWay (CLUSTER c) { - // TODO : Find1Way in ASM + warning("STUB: Find1Way"); /* bool Find1Way(void); extern uint16 Target; @@ -845,6 +846,7 @@ static void PostMiniStep (int stp) static int recent = -2; //TODO Change the SNPOST message send to a special way to send function pointer //if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep); + warning("STUB: PostMiniStep()"); } @@ -1021,6 +1023,7 @@ void SwitchCave (int cav) SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST(SNEXEC, -1, 0, (void *)&QGame); // switch cave + warning("SwitchCave() - SNPOST"); } else { @@ -1043,6 +1046,7 @@ void SwitchCave (int cav) SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave + warning("SwitchCave() - SNPOST"); } } } @@ -1285,6 +1289,7 @@ static void SwitchMusic (void) SNPOST_(SNSEQ, 122, (Music = false), NULL); //TODO Change the SNPOST message send to a special way to send function pointer // SNPOST(SNEXEC, -1, 0, (void *)&SelectSound); + warning("SwitchMusic() - SNPOST"); } } else @@ -1699,9 +1704,8 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro if (INI_FILE::Exist(line)) // sprite description file exist { INI_FILE sprf(line); - if (sprf.Error) - { - VGA::Exit("Bad SPR", line); + if (sprf.Error) { + error("Bad SPR [%s]", line); } while ((len = sprf.Read((uint8*)line)) != 0) @@ -1710,9 +1714,8 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro if (len && line[len-1] == '\n') line[-- len] = '\0'; if (len == 0 || *line == '.') continue; - if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) - { - VGA::Exit(NumStr("Bad line ######", lcnt), fname); + if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) { + error("%s [%s]", NumStr("Bad line ######", lcnt), fname); } switch (i) @@ -1721,7 +1724,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro break; case 1 : // Type if ((type = TakeEnum(Type, strtok(NULL, " \t,;/"))) < 0) - VGA::Exit(NumStr("Bad line ######", lcnt), fname); + error("%s [%s]", NumStr("Bad line ######", lcnt), fname); break; case 2 : // Phase ++ shpcnt; @@ -1738,9 +1741,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro } } if (! shpcnt) - { - VGA::Exit("No shapes", fname); - } + error("No shapes [%s]", fname); } else // no sprite description: mono-shaped sprite with only .BMP file { @@ -1767,9 +1768,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro { w->Goto(col, row); if (Hero) - { - VGA::Exit("2nd HERO", fname); - } + error("2nd HERO [%s]", fname); Hero = w; } Sprite = w; @@ -1792,7 +1791,7 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro */ case 4 : // LISSAJOUS { - VGA::Exit("Bad type", fname); + error("Bad type [%s]", fname); /* LISSAJOUS * l = new LISSAJOUS(NULL); if (l) @@ -1895,9 +1894,7 @@ static void LoadScript (const char *fname) if (Sprite && BkG) Sprite->Flags.Back = true; } if (! ok) - { - VGA::Exit(NumStr("Bad INI line ######", lcnt), fname); - } + error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname); } @@ -1982,7 +1979,7 @@ void LoadUser (void) Music = true; CFILE file = CFILE(SVG0NAME, WRI); SaveGame(file); - VGA::Exit("Ok", SVG0NAME); + error("Ok [%s]", SVG0NAME); } } LoadScript(ProgName(IN0_EXT)); @@ -2270,7 +2267,8 @@ void cge_main (void) //Debug( memset((void *) (-K(4)), 0, K(1)); ) memset(Barriers, 0xFF, sizeof(Barriers)); - if (! Mouse.Exist) VGA::Exit(NO_MOUSE_TEXT); + if (! Mouse.Exist) + error("%s", Text[NO_MOUSE_TEXT]); if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; Debug( DebugLine.Flags.Hide = true; ) @@ -2291,7 +2289,7 @@ void cge_main (void) if (FINIS) Movie("X03"); } else Vga.Sunset(); - VGA::Exit(EXIT_OK_TEXT+FINIS); + error("%s", Text[EXIT_OK_TEXT+FINIS]); } } // End of namespace CGE diff --git a/engines/cge/general.h b/engines/cge/general.h index 4633ba2d3c..0d06d9b93d 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -49,7 +49,7 @@ namespace CGE { -enum CPU { _8086, _80186, _80286, _80386, _80486 }; +//enum CPU { _8086, _80186, _80286, _80386, _80486 }; enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM }; enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT }; enum IOMODE { REA, WRI, UPD }; @@ -244,7 +244,7 @@ CRYPT RCrypt; MEM_TYPE MemType (void *mem); unsigned FastRand (void); unsigned FastRand (unsigned s); -CPU Cpu (void); +//CPU Cpu (void); ALLOC_MODE SetAllocMode (ALLOC_MODE am); uint16 atow (const char * a); uint16 xtow (const char * x); diff --git a/engines/cge/module.mk b/engines/cge/module.mk index e028d7feb4..a74eb1a469 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -18,6 +18,7 @@ MODULE_OBJS := \ snail.o \ sound.o \ startup.o \ + stdpal.o \ talk.o \ text.o \ vga13h.o \ diff --git a/engines/cge/stdpal.cpp b/engines/cge/stdpal.cpp new file mode 100644 index 0000000000..8ceeddae3c --- /dev/null +++ b/engines/cge/stdpal.cpp @@ -0,0 +1,92 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" + +namespace CGE { + + DAC StdPal[] = {// R G B + { 0, 60, 0}, // 198 + { 0, 104, 0}, // 199 + { 20, 172, 0}, // 200 + { 82, 82, 0}, // 201 + { 0, 132, 82}, // 202 + { 132, 173, 82}, // 203 + { 82, 0, 0}, // 204 + { 206, 0, 24}, // 205 + { 255, 33, 33}, // 206 + { 123, 41, 0}, // 207 + { 0, 41, 0}, // 208 + { 0, 0, 82}, // 209 + { 132, 0, 0}, // 210 + { 255, 0, 0}, // 211 + { 255, 66, 66}, // 212 + { 148, 66, 16}, // 213 + { 0, 82, 0}, // 214 + { 0, 0,132}, // 215 + { 173, 0, 0}, // 216 + { 255, 49, 0}, // 217 + { 255, 99, 99}, // 218 + { 181, 107, 49}, // 219 + { 0, 132, 0}, // 220 + { 0, 0,255}, // 221 + { 173, 41, 0}, // 222 + { 255, 82, 0}, // 223 + { 255, 132,132}, // 224 + { 214, 148, 74}, // 225 + { 41, 214, 0}, // 226 + { 0, 82,173}, // 227 + { 255, 214, 0}, // 228 + { 247, 132, 49}, // 229 + { 255, 165,165}, // 230 + { 239, 198,123}, // 231 + { 173, 214, 0}, // 232 + { 0, 132,214}, // 233 + { 57, 57, 57}, // 234 + { 247, 189, 74}, // 235 + { 255, 198,198}, // 236 + { 255, 239,173}, // 237 + { 214, 255,173}, // 238 + { 82, 173,255}, // 239 + { 107, 107,107}, // 240 + { 247, 222, 99}, // 241 + { 255, 0,255}, // 242 + { 255, 132,255}, // 243 + { 132, 132,173}, // 244 + { 148, 247,255}, // 245 + { 148, 148,148}, // 246 + { 82, 0, 82}, // 247 + { 112, 68,112}, // 248 + { 176, 88,144}, // 249 + { 214, 132,173}, // 250 + { 206, 247,255}, // 251 + { 198, 198,198}, // 252 + { 0, 214,255}, // 253 + { 96, 224,96 }, // 254 + { 255, 255,255}, // 255 + }; +} // End of namespace CGE diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 851b96cf99..9fd32ab7d2 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -245,7 +245,8 @@ BITMAP * TALK::Box (uint16 w, uint16 h) if (w < 8) w = 8; if (h < 8) h = 8; b = farnew(uint8, n = w * h); - if (! b) VGA::Exit("No core"); + if (! b) + error("No core"); memset(b, TEXT_BG, n); if (Mode) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d95be1d94c..6e08a9790d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -585,7 +585,8 @@ void SPRITE::SetName (char * n) if (n) { if ((Ext->Name = new char[strlen(n)+1]) != NULL) strcpy(Ext->Name, n); - else VGA::Exit("No core", n); + else + error("No core [%s]", n); } } } @@ -624,9 +625,7 @@ SPRITE * SPRITE::Expand (void) { INI_FILE sprf(fname); if (! OK(sprf)) - { - VGA::Exit("Bad SPR", fname); - } + error("Bad SPR [%s]", fname); while ((len = sprf.Read((uint8*)line)) != 0) { @@ -649,7 +648,7 @@ SPRITE * SPRITE::Expand (void) { seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); if (seq == NULL) - VGA::Exit("No core", fname); + error("No core [%s]", fname); SEQ * s = &seq[seqcnt ++]; s->Now = atoi(strtok(NULL, " \t,;/")); if (s->Now > maxnow) maxnow = s->Now; @@ -670,12 +669,13 @@ SPRITE * SPRITE::Expand (void) if (NearPtr != NO_PTR) { nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - if (nea == NULL) VGA::Exit("No core", fname); + if (nea == NULL) + error("No core [%s]", fname); else { SNAIL::COM * c = &nea[neacnt ++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - VGA::Exit(NumStr("Bad NEAR in ######", lcnt), fname); + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); c->Ptr = NULL; @@ -688,12 +688,13 @@ SPRITE * SPRITE::Expand (void) if (TakePtr != NO_PTR) { tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - if (tak == NULL) VGA::Exit("No core", fname); + if (tak == NULL) + error("No core [%s]", fname); else { SNAIL::COM * c = &tak[takcnt ++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - VGA::Exit(NumStr("Bad NEAR in ######", lcnt), fname); + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); c->Ptr = NULL; @@ -711,8 +712,10 @@ SPRITE * SPRITE::Expand (void) shplist[shpcnt] = NULL; if (seq) { - if (maxnow >= shpcnt) VGA::Exit("Bad PHASE in SEQ", fname); - if (maxnxt >= seqcnt) VGA::Exit("Bad JUMP in SEQ", fname); + if (maxnow >= shpcnt) + error("Bad PHASE in SEQ [%s]", fname); + if (maxnxt >= seqcnt) + error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); } else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); @@ -938,10 +941,12 @@ BMP_PTR SPRITE::Ghost (void) if (e->b1) { BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); - if (bmp == NULL) VGA::Exit("No core"); + if (bmp == NULL) + error("No core"); bmp->W = e->b1->W; bmp->H = e->b1->H; - if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); + if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) + error("No Core"); bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); @@ -1589,43 +1594,8 @@ void VGA::CopyPage (uint16 d, uint16 s) */ } - - - - - - -void VGA::Exit (const char * txt, const char * name) -{ - // TODO Properly exit - /* - Msg = txt; - Nam = name; - - #ifdef REPORT - wtom(coreleft(), Report + NREP, 10, 5); - dwtom(farcoreleft(), Report + FREP, 10, 6); - #endif - exit(0); - */ -} - - - - -void VGA::Exit (int tref, const char * name) -{ - Exit(Text[tref], name); -} - - - - //-------------------------------------------------------------------------- - - - void BITMAP::XShow (int x, int y) { // TODO XShow ASM diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 0b9fa8596d..f1a4b498c4 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -274,8 +274,6 @@ public: static void GetColors (DAC * tab); static void SetColors (DAC * tab, int lum); static void Clear (uint8 color = 0); - static void Exit (const char * txt = NULL, const char * name = NULL); - static void Exit (int tref, const char * name = NULL); static void CopyPage (uint16 d, uint16 s = 3); static void Sunrise (DAC * tab); static void Sunset (void); -- cgit v1.2.3 From b1df7ca7340ccf43817894eedcaea6d211eeb6dd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 12 Jun 2011 22:06:44 +0200 Subject: CGE: Add missing file, and STUB some missing functions in general.cpp --- engines/cge/cge_main.cpp | 3 +- engines/cge/ems.cpp | 240 ++++++++++++++++++++++++++++++++ engines/cge/game.cpp | 2 +- engines/cge/general.cpp | 346 +++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/general.h | 29 ++-- engines/cge/module.mk | 3 +- engines/cge/snddrv.h | 6 +- engines/cge/stdpal.cpp | 92 ------------- engines/cge/vga13h.cpp | 10 +- engines/cge/vol.cpp | 8 +- 10 files changed, 613 insertions(+), 126 deletions(-) create mode 100644 engines/cge/ems.cpp create mode 100644 engines/cge/general.cpp delete mode 100644 engines/cge/stdpal.cpp diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4c3611650c..9a2ce931f0 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -297,8 +297,7 @@ static void LoadGame (XFILE& file, bool tiny = false) if (i != SVGCHKSUM) error(Text[BADSVG_TEXT]); if (STARTUP::Core < CORE_HIG) Music = false; - if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) - { + if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) { SNDDrvInfo.VOL2.D = volume[0]; SNDDrvInfo.VOL2.M = volume[1]; SNDSetVolume(); diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp new file mode 100644 index 0000000000..abf118bda2 --- /dev/null +++ b/engines/cge/ems.cpp @@ -0,0 +1,240 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" + +namespace CGE { + +#define EMS_INT 0x67 +#define PAGE_MASK 0x3FFF +#define SIZ(n) ((n) ? ((long)n) : (0x10000L)) + + +enum EMM_FUN { GET_STATUS = 0x40, + GET_FRAME, + GET_SIZE, + OPEN_HANDLE, + MAP_PAGE, + CLOSE_HANDLE, + GET_VER, + SAVE_CONTEXT, + REST_CONTEXT, + GET_PAGES = 0x4B, + GET_HANDLES, + GET_INFO, + CONTROL }; + + +void *EMM::Frame = NULL; + + +EMM::EMM (long size): Han(-1), Top(0), Lim(0), List(NULL) { +/* + if (Test()) + { + asm mov ah,GET_FRAME // get EMS frame segment + asm int EMS_INT // do it! + asm or ah,ah // see status + asm jnz xit // abort on error + Frame = (void _seg *) _BX; // save frame segment + + if (size == 0) + { + asm mov ah,GET_SIZE // get EMS memory size + asm int EMS_INT // do it! + asm or ah,ah // see status + asm jnz xit // abort on error + asm or bx,bx // test page count + asm jz xit // abort if no free pages + // number of available pages in BX is ready to use by OPEN + } + else _BX = (uint16) ((size + PAGE_MASK) >> 14); + asm mov ah,OPEN_HANDLE // open EMM handle + asm int EMS_INT // do it! + asm or ah,ah // see status + asm jnz xit // abort on error + Han = _DX; + Lim = _BX; + Lim <<= 14; + _DX = Han; + asm mov ah,SAVE_CONTEXT // save mapping context + asm int EMS_INT // do it! + } + xit: +*/ + warning("STUB: EMM:EMM"); +} + + +EMM::~EMM(void) { +/* + Release(); + if (Han >= 0) + { + _DX = Han; + asm mov ah,REST_CONTEXT + asm int EMS_INT + asm mov ah,CLOSE_HANDLE + asm int EMS_INT + } +*/ + warning("STUB: EMM::~EMM"); +} + + + +bool EMM::Test(void) { +/* + static char e[] = "EMMXXXX0"; + + asm mov ax,0x3D40 + asm mov dx,offset e + asm int 0x21 + asm jc fail + + asm push ax + asm mov bx,ax + asm mov ax,0x4407 + asm int 0x21 + + asm pop bx + asm push ax + asm mov ax,0x3E00 + asm int 0x21 + asm pop ax + + asm cmp al,0x00 + asm je fail + + success: + return TRUE; + fail: + return FALSE; +*/ + warning("EMM::Test"); + return FALSE; +} + + +EMS * EMM::Alloc (uint16 siz) { +/* + long size = SIZ(siz), + top = Top; + + uint16 pgn = (uint16) (top >> 14), + cnt = (uint16) ((top + size + PAGE_MASK) >> 14) - pgn; + + if (cnt > 4) + { + top = (top + PAGE_MASK) & 0xFFFFC000L; + ++ pgn; + -- cnt; + } + + if (size <= Lim - top) + { + EMS * e = new EMS, * f; + + if (e) + { + Top = (e->Ptr = top) + (e->Siz = siz); + e->Emm = this; + + if (List) + { + for (f = List; f->Nxt; f = f->Nxt); + return (f->Nxt = e); // existing list: link to the end + } + else + { + return (List = e); // empty list: link to the head + } + } + } + fail: return NULL; +*/ + warning("STUB: EMM::Alloc"); + return NULL; +} + + +void EMM::Release (void) { + while (List) + { + EMS * e = List; + List = e->Nxt; + delete e; + } + Top = 0; +} + + +EMS::EMS (void) +: Ptr(0), Siz(0), Nxt(NULL) +{ +} + + +void * EMS::operator & () const +{ +/* + uint16 pgn = (uint16) (Ptr >> 14), + off = (uint16) Ptr & PAGE_MASK, + cnt = (uint16) ((Ptr + SIZ(Siz) + PAGE_MASK) >> 14) - pgn, + cmd = MAP_PAGE << 8; + + _DX = Emm->Han; // take EMM handle + asm dec cnt // prapare for deferred checking + asm or dx,dx // see if valid + asm jns more // negative handle = unavailable + + fail: return NULL; + + more: + asm mov ax,cmd // command + page frame index + asm mov bx,pgn // logical page number + asm int EMS_INT // do it! + asm or ah,ah // check error code + asm jnz fail // exit on error + asm inc cmd // advance page frame index + asm inc pgn // advance logical page number + asm cmp al,byte ptr cnt // all pages? + asm jb more + + return (void *) (EMM::Frame + (void *) off); +*/ + warning("STUB: EMS::operator &"); + return NULL; +} + + +uint16 EMS::Size (void) +{ + return Siz; +} + +} // End of namespace CGE diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index b6530323e4..86e1324e0b 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -92,7 +92,7 @@ FLY::FLY (BITMAP ** shpl) : SPRITE(shpl), Tx(0), Ty(0) { Step(new_random(2)); - Goto(L+new_random(R-L-W), T+new_random(B-T-H)); + Goto(L + new_random(R - L - W), T + new_random(B - T - H)); } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp new file mode 100644 index 0000000000..f023bb1e0f --- /dev/null +++ b/engines/cge/general.cpp @@ -0,0 +1,346 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/boot.h" +#include "cge/general.h" +#include "cge/snddrv.h" +#include "cge/wav.h" + +namespace CGE { + + DAC StdPal[] = {// R G B + { 0, 60, 0}, // 198 + { 0, 104, 0}, // 199 + { 20, 172, 0}, // 200 + { 82, 82, 0}, // 201 + { 0, 132, 82}, // 202 + { 132, 173, 82}, // 203 + { 82, 0, 0}, // 204 + { 206, 0, 24}, // 205 + { 255, 33, 33}, // 206 + { 123, 41, 0}, // 207 + { 0, 41, 0}, // 208 + { 0, 0, 82}, // 209 + { 132, 0, 0}, // 210 + { 255, 0, 0}, // 211 + { 255, 66, 66}, // 212 + { 148, 66, 16}, // 213 + { 0, 82, 0}, // 214 + { 0, 0,132}, // 215 + { 173, 0, 0}, // 216 + { 255, 49, 0}, // 217 + { 255, 99, 99}, // 218 + { 181, 107, 49}, // 219 + { 0, 132, 0}, // 220 + { 0, 0,255}, // 221 + { 173, 41, 0}, // 222 + { 255, 82, 0}, // 223 + { 255, 132,132}, // 224 + { 214, 148, 74}, // 225 + { 41, 214, 0}, // 226 + { 0, 82,173}, // 227 + { 255, 214, 0}, // 228 + { 247, 132, 49}, // 229 + { 255, 165,165}, // 230 + { 239, 198,123}, // 231 + { 173, 214, 0}, // 232 + { 0, 132,214}, // 233 + { 57, 57, 57}, // 234 + { 247, 189, 74}, // 235 + { 255, 198,198}, // 236 + { 255, 239,173}, // 237 + { 214, 255,173}, // 238 + { 82, 173,255}, // 239 + { 107, 107,107}, // 240 + { 247, 222, 99}, // 241 + { 255, 0,255}, // 242 + { 255, 132,255}, // 243 + { 132, 132,173}, // 244 + { 148, 247,255}, // 245 + { 148, 148,148}, // 246 + { 82, 0, 82}, // 247 + { 112, 68,112}, // 248 + { 176, 88,144}, // 249 + { 214, 132,173}, // 250 + { 206, 247,255}, // 251 + { 198, 198,198}, // 252 + { 0, 214,255}, // 253 + { 96, 224,96 }, // 254 + { 255, 255,255}, // 255 + }; + +EC void _fqsort (void *base, uint16 nelem, uint16 width, int (*fcmp)(const void*, const void*)) { + warning("STUB: _fqsort"); +} + +const char * ProgName (const char * ext) { + warning("STUB: ProgName"); + return NULL; +} + +char *MergeExt (char *buf, const char *nam, const char *ext) { +// char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; +// fnmerge(buf, dr, di, na, (fnsplit(nam, dr, di, na, ex) & EXTENSION) ? ex : ext); +// return buf; + warning("STUB: MergeExt"); + return buf; +} + +char *ForceExt (char *buf, const char *nam, const char* ext) { +// char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; +// fnsplit(nam, dr, di, na, ex); +// fnmerge(buf, dr, di, na, ext); +// return buf; + warning("STUB: ForceExt"); + return buf; +} + + +#define BUF ((uint8 *) buf) +static unsigned Seed = 1; + +unsigned FastRand (void) { return Seed = 257 * Seed + 817; } +unsigned FastRand (unsigned s) { return Seed = 257 * s + 817; } + +uint16 RCrypt (void * buf, uint16 siz, uint16 seed) { +/* + if (buf && siz) { + uint8 * q = BUF + (siz-1); + seed = FastRand(seed); + * (BUF ++) ^= seed; + while (buf < q) * (BUF ++) ^= FastRand(); + if (buf == q) * BUF ^= (seed = FastRand()); + } + return seed; +*/ + warning("STUB: RCrypt"); + return 0; +} + +uint16 XCrypt (void *buf, uint16 siz, uint16 seed) { +// for (uint16 i = 0; i < siz; i ++) +// *(BUF ++) ^= seed; + warning("STUB: XCrypt"); + return seed; +} + +uint16 atow (const char *a) { + uint16 w = 0; + if (a) + while (IsDigit(*a)) + w = (10 * w) + (*(a ++) & 0xF); + return w; +} + +uint16 xtow (const char *x) { + uint16 w = 0; + if (x) { + while (IsHxDig(*x)) { + register uint16 d = * (x ++); + if (d > '9') + d -= 'A' - ('9' + 1); + w = (w << 4) | (d & 0xF); + } + } + return w; +} + +char *wtom (uint16 val, char *str, int radix, int len) { + while (-- len >= 0) { + uint16 w = val % radix; + if (w > 9) w += ('A' - ('9'+1)); + str[len] = '0' + w; + val /= radix; + } + return str; +} + +IOHAND::IOHAND (IOMODE mode, CRYPT * crpt) +: XFILE(mode), Handle(-1), Crypt(crpt), Seed(SEED) +{ +} + +IOHAND::IOHAND (const char *name, IOMODE mode, CRYPT *crpt) +: XFILE(mode), Crypt(crpt), Seed(SEED) +{ +/* switch (mode) + { + case REA : Error = _dos_open(name, O_RDONLY | O_DENYNONE, &Handle); break; + case WRI : Error = _dos_creat(name, FA_ARCH, &Handle); break; + case UPD : Error = _dos_open(name, O_RDWR | O_DENYALL, &Handle); break; + } + if (Error) Handle = -1; +*/ + warning("STUB: IOHAND::IOHAND"); +} + +IOHAND::~IOHAND(void) { +/* + if (Handle != -1) + { + Error = _dos_close(Handle); + Handle = -1; + } +*/ + warning("STUB: IOHAND::~IOHAND"); +} + +uint16 IOHAND::Read(void *buf, uint16 len) { +/* + if (Mode == WRI || Handle < 0) return 0; + if (len) Error = _dos_read(Handle, buf, len, &len); + if (Crypt) Seed = Crypt(buf, len, Seed); + return len; +*/ + warning("STUB: IOHAND::Read"); + return 0; +} + +uint16 IOHAND::Write(void *buf, uint16 len) { +/* + if (len) { + if (Mode == REA || Handle < 0) return 0; + if (Crypt) Seed = Crypt(buf, len, Seed); + Error = _dos_write(Handle, buf, len, &len); + if (Crypt) Seed = Crypt(buf, len, Seed); //------$$$$$$$ + } + return len; +*/ + warning("STUB: IOHAND::Write"); + return 0; +} + +long IOHAND::Mark (void) +{ + return (Handle < 0) ? 0 : tell(Handle); +} + +long IOHAND::Seek (long pos) +{ + if (Handle < 0) return 0; + lseek(Handle, pos, SEEK_SET); + return tell(Handle); +} + +long IOHAND::Size (void) +{ + if (Handle < 0) return 0; + return filelength(Handle); +} + +bool IOHAND::Exist (const char * name) { + return access(name, 0) == 0; +} + +//#define EMS_ADR(a) (FP_SEG(a) > 0xA000) +//#define HNODE_OK(p) (heapchecknode(p)==4) + +MEM_TYPE MemType (void *mem) { +/* if (FP_SEG(mem) == _DS) { + if (heapchecknode((void *)mem)==4) + return NEAR_MEM; + } else { + if (FP_SEG(mem) > 0xA000) + return EMS_MEM; + else if (farheapchecknode(mem)==4) + return FAR_MEM; + } + return BAD_MEM; +*/ + warning("STUB: MemType"); + return FAR_MEM; +} + +bool IsVga() { + return true; +} + +EC void SNDInit() { + warning("STUB: SNDInit"); +} + +EC void SNDDone() { + warning("STUB: SNDDone"); +} + +EC void SNDSetVolume() { + warning("STUB: SNDSetVolume"); +} + +EC void SNDDigiStart(SMPINFO *PSmpInfo) { + warning("STUB: SNDDigitStart"); +} + +EC void SNDDigiStop(SMPINFO *PSmpInfo) { + warning("STUB: SNDDigiStop"); +} + +EC void SNDMIDIStart(uint8 *MIDFile) { + warning("STUB: SNDMIDIStart"); +} + +EC void SNDMIDIStop() { + warning("STUB: SNDMIDIStop"); +} + +DATACK *LoadWave(XFILE * file, EMM * emm) { + warning("STUB: LoadWave"); + return NULL; +} + +int TakeEnum(const char **tab, const char *txt) { + const char **e; + if (txt) + { + for (e = tab; *e; e ++) + { + if (scumm_stricmp(txt, *e) == 0) + { + return e - tab; + } + } + } + return -1; +} + +Boot *ReadBoot(int drive) { +/* + struct fatinfo fi; Boot *b; + getfat(drive+1, &fi); + if (fi.fi_sclus & 0x80) return NULL; + if ((b = malloc(fi.fi_bysec)) == NULL) return NULL; + // read boot sector + if (absread(drive, 1, 0L, b) == 0) return b; + free(b); + return NULL; +*/ + warning("STUB: ReadBoot"); + return NULL; +} + +} // End of namespace CGE + diff --git a/engines/cge/general.h b/engines/cge/general.h index 0d06d9b93d..62919328ed 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -64,8 +64,6 @@ extern Common::RandomSource randSrc; #define new_random(a) (randSrc.getRandomNumber(a)) - - class COUPLE { protected: @@ -238,39 +236,32 @@ public: CRYPT XCrypt; -CRYPT RXCrypt; CRYPT RCrypt; MEM_TYPE MemType (void *mem); -unsigned FastRand (void); -unsigned FastRand (unsigned s); -//CPU Cpu (void); -ALLOC_MODE SetAllocMode (ALLOC_MODE am); uint16 atow (const char * a); uint16 xtow (const char * x); char * wtom (uint16 val, char * str, int radix, int len); char * dwtom (uint32 val, char * str, int radix, int len); -char * DateTimeString (void); -void StdLog (const char *msg, const char *nam = NULL); -void StdLog (const char *msg, uint16 w); -void StdLog (const char *msg, uint32 d); int TakeEnum (const char ** tab, const char * txt); uint16 ChkSum (void *m, uint16 n); long Timer (void); -long TimerLimit (uint16 t); -bool TimerLimitGone (long t); char * MergeExt (char * buf, const char * nam, const char * ext); char * ForceExt (char * buf, const char * nam, const char * ext); -inline const char * ProgPath (void); -const char * ProgName (const char * ext = NULL); -int DriveFixed (unsigned drv); -int DriveRemote (unsigned drv); int DriveCD (unsigned drv); bool IsVga (void); -EC void _fqsort (void *base, uint16 nelem, uint16 width, - int (*fcmp)(const void*, const void*)); +// MISSING FUNCTIONS +EC void _fqsort (void *base, uint16 nelem, uint16 width, int (*fcmp)(const void*, const void*)); +const char *ProgName (const char *ext = NULL); +char *MergeExt (char *buf, const char *nam, const char *ext); +char *ForceExt (char *buf, const char *nam, const char *ext); +unsigned FastRand (void); +unsigned FastRand (unsigned s); +uint16 RCrypt (void * buf, uint16 siz, uint16 seed); +uint16 atow (const char *a); +uint16 xtow (const char *x); } // End of namespace CGE diff --git a/engines/cge/module.mk b/engines/cge/module.mk index a74eb1a469..552cddb500 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -10,7 +10,9 @@ MODULE_OBJS := \ config.o \ console.o \ detection.o \ + ems.o \ game.o \ + general.o \ gettext.o \ keybd.o \ mixer.o \ @@ -18,7 +20,6 @@ MODULE_OBJS := \ snail.o \ sound.o \ startup.o \ - stdpal.o \ talk.o \ text.o \ vga13h.o \ diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 8d29a807d7..fc6c1aa143 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -94,13 +94,13 @@ struct SMPINFO // * Data * // ****************************************************** // driver info -extern DRVINFO SNDDrvInfo; +extern DRVINFO SNDDrvInfo; // midi player flag (1 means we are playing) -extern uint16 MIDIPlayFlag; +extern uint16 MIDIPlayFlag; // midi song end flag (1 means we have crossed end mark) -extern uint16 MIDIEndFlag; +extern uint16 MIDIEndFlag; // ****************************************************** // * Driver Code * diff --git a/engines/cge/stdpal.cpp b/engines/cge/stdpal.cpp deleted file mode 100644 index 8ceeddae3c..0000000000 --- a/engines/cge/stdpal.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/general.h" - -namespace CGE { - - DAC StdPal[] = {// R G B - { 0, 60, 0}, // 198 - { 0, 104, 0}, // 199 - { 20, 172, 0}, // 200 - { 82, 82, 0}, // 201 - { 0, 132, 82}, // 202 - { 132, 173, 82}, // 203 - { 82, 0, 0}, // 204 - { 206, 0, 24}, // 205 - { 255, 33, 33}, // 206 - { 123, 41, 0}, // 207 - { 0, 41, 0}, // 208 - { 0, 0, 82}, // 209 - { 132, 0, 0}, // 210 - { 255, 0, 0}, // 211 - { 255, 66, 66}, // 212 - { 148, 66, 16}, // 213 - { 0, 82, 0}, // 214 - { 0, 0,132}, // 215 - { 173, 0, 0}, // 216 - { 255, 49, 0}, // 217 - { 255, 99, 99}, // 218 - { 181, 107, 49}, // 219 - { 0, 132, 0}, // 220 - { 0, 0,255}, // 221 - { 173, 41, 0}, // 222 - { 255, 82, 0}, // 223 - { 255, 132,132}, // 224 - { 214, 148, 74}, // 225 - { 41, 214, 0}, // 226 - { 0, 82,173}, // 227 - { 255, 214, 0}, // 228 - { 247, 132, 49}, // 229 - { 255, 165,165}, // 230 - { 239, 198,123}, // 231 - { 173, 214, 0}, // 232 - { 0, 132,214}, // 233 - { 57, 57, 57}, // 234 - { 247, 189, 74}, // 235 - { 255, 198,198}, // 236 - { 255, 239,173}, // 237 - { 214, 255,173}, // 238 - { 82, 173,255}, // 239 - { 107, 107,107}, // 240 - { 247, 222, 99}, // 241 - { 255, 0,255}, // 242 - { 255, 132,255}, // 243 - { 132, 132,173}, // 244 - { 148, 247,255}, // 245 - { 148, 148,148}, // 246 - { 82, 0, 82}, // 247 - { 112, 68,112}, // 248 - { 176, 88,144}, // 249 - { 214, 132,173}, // 250 - { 206, 247,255}, // 251 - { 198, 198,198}, // 252 - { 0, 214,255}, // 253 - { 96, 224,96 }, // 254 - { 255, 255,255}, // 255 - }; -} // End of namespace CGE diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6e08a9790d..f771767c7b 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1137,10 +1137,11 @@ uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), +//extern const char Copr[]; + VGA::VGA (int mode) : FrmCnt(0) { - extern const char Copr[]; bool std = true; int i; for (i = 10; i < 20; i ++) @@ -1155,9 +1156,10 @@ VGA::VGA (int mode) #endif } } - if (std) -// puts(Copr); - warning(Copr); +// if (std) +// warning(Copr); + warning("TODO: Fix Copr"); + SetStatAdr(); if (StatAdr != VGAST1_) ++ Mono; if (IsVga()) diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 9af2efe8f3..4f39cd6186 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -25,12 +25,12 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/vol.h" +#include "cge/vol.h" #include "common/system.h" #include "common/str.h" -#include -#include -#include +#include +#include +#include namespace CGE { -- cgit v1.2.3 From ccd934e4bfaa2997bf2dcec6818e0c418a11624f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 00:40:19 +0200 Subject: CGE: Add a couple of STUB warnings --- engines/cge/cfile.cpp | 2 +- engines/cge/cge_main.cpp | 8 +- engines/cge/config.cpp | 1 + engines/cge/keybd.cpp | 4 +- engines/cge/mixer.cpp | 1 + engines/cge/snail.cpp | 2 + engines/cge/startup.cpp | 12 +- engines/cge/text.cpp | 2 +- engines/cge/vga13h.cpp | 314 +++++++---------------------------------------- 9 files changed, 61 insertions(+), 285 deletions(-) diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 1a23c3d0f9..fdbd6ad315 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -293,12 +293,12 @@ void CFILE::Flush (void) if (Mode > REA) WriteBuff(); else Lim = 0; - // TODO replace by scummvm files. /* _BX = Handle; _AH = 0x68; // Flush buffer asm int 0x21 */ + warning("FIXME: CFILE::Flush"); } diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 9a2ce931f0..cdbb94f785 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1832,8 +1832,8 @@ static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int ro Sprite->Flags.Tran = tran; Sprite->Flags.Kill = true; Sprite->Flags.BDel = true; - // TODO : Get Filename from entire path //fnsplit(fname, NULL, NULL, Sprite->File, NULL); + warning("LoadSprite: use of fnsplit"); Sprite->ShpCnt = shpcnt; VGA::SpareQ.Append(Sprite); @@ -2090,6 +2090,7 @@ static void RunGame (void) { //TODO Change the SNPOST message send to a special way to send function pointer // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame); + warning("RunGame: problematic use of SNPOST"); MainLoop(); } @@ -2188,8 +2189,9 @@ bool ShowTitle (const char * name) #ifdef CD STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; #else - // TODO : do good boot... - Boot * b = ReadBoot(0); //getdisk()); +// Boot * b = ReadBoot(getdisk()); + warning("ShowTitle: FIXME ReadBoot"); + Boot * b = ReadBoot(0); uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; free(b); sn -= ((IDENT *)Copr)->disk; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 38da4cda58..ee4d1771f9 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -210,6 +210,7 @@ static void Select (CHOICE * cho, int hlp) Hlp = hlp; //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect); + warning("STUB: Select"); } diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index e4858d1d04..95899bed55 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -57,6 +57,7 @@ KEYBOARD::KEYBOARD (void) OldKeyboard = getvect(KEYBD_INT); setvect(KEYBD_INT, NewKeyboard); */ + warning("STUB: KEYBOARD::KEYBOARD"); } @@ -68,6 +69,7 @@ KEYBOARD::~KEYBOARD (void) /* TODO replace totally by scummvm handling setvect(KEYBD_INT, OldKeyboard); */ + warning("STUB: KEYBOARD::~KEYBOARD"); } @@ -86,7 +88,6 @@ SPRITE * KEYBOARD::SetClient (SPRITE * spr) void KEYBOARD::NewKeyboard (...) { // table address - // TODO keyboard ASM /* _SI = (uint16) Key; @@ -146,6 +147,7 @@ void KEYBOARD::NewKeyboard (...) asm mov al,20h // send End-Of-Interrupt asm out 20h,al // to the 8259 IC */ + warning("STUB: KEYBOARD::NewKeyboard"); } } // End of namespace CGE diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 346631b08a..385634d4b8 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -154,6 +154,7 @@ void MIXER::Update (void) //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST_(SNEXEC, -1, 0, (void*)&SNDSetVolume); + warning("FIXME: MIXER::Update"); } } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index c63ba824b4..82ec4c596d 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -387,6 +387,7 @@ void SNGhost (BITMAP * bmp) //bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M)); bmp->M = NULL; delete bmp; + warning("STUB: SNGhost"); } @@ -1288,6 +1289,7 @@ void SNAIL::RunCom (void) // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST //case SNEXEC : ((void(*)(int)) (snc->Ptr))(snc->Val); break; + case SNEXEC : warning("STUB: SNEXEC code"); case SNSTEP : sprel->Step(); break; case SNZTRIM : SNZTrim(sprel); break; case SNGHOST : SNGhost((BITMAP *) snc->Ptr); break; diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 7e5ac71782..c2badee266 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -66,10 +66,9 @@ void quit_now(int ref){ -bool STARTUP::get_parms (void) +bool STARTUP::get_parms(void) { - // TODO do params - /* +/* int i = _argc; while (i > 1) { @@ -114,16 +113,16 @@ bool STARTUP::get_parms (void) #endif if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; */ + warning("STUB: STARTUP::get_parms"); return true; } -STARTUP::STARTUP (void) +STARTUP::STARTUP(void) { - //TOdO startup in scummvm - /* +/* uint32 m = farcoreleft() >> 10; if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF; @@ -152,6 +151,7 @@ STARTUP::STARTUP (void) } } */ + warning("STUB: STARTUP::STARTUP"); } diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 9ee6244f22..5b79131a26 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -288,7 +288,6 @@ void Inf (const char * txt) void SayTime (SPRITE * spr) { -//TODO Get Time /* static char t[] = "00:00"; struct time ti; @@ -297,6 +296,7 @@ void SayTime (SPRITE * spr) wtom(ti.ti_min, t+3, 10, 2); Say((*t == '0') ? (t+1) : t, spr); */ + warning("STUB: SayTime"); } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f771767c7b..01441c85a3 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -30,15 +30,12 @@ #include "cge/bitmap.h" #include "cge/vol.h" #include "cge/text.h" -//#include #include #include #include #include #include -//#include #include -//#include #include namespace CGE { @@ -143,7 +140,7 @@ static void Video (void) uint16 * SaveScreen (void) { - /* TODO ASM +/* uint16 cxy, cur, siz, * scr = NULL, * sav; // horizontal size of text mode screen @@ -195,17 +192,14 @@ uint16 * SaveScreen (void) } return sav; */ + warning("STUB: SaveScreen"); return 0; } - - - void RestoreScreen (uint16 * &sav) { - // TODO RestoreScreen ASM - /* +/* uint16 * scr = NULL; asm mov ax,0x40 // system data segment @@ -232,13 +226,10 @@ void RestoreScreen (uint16 * &sav) free(sav); sav = NULL; */ + warning("STUB: RestoreScreen"); } - - - - DAC MkDAC (uint8 r, uint8 g, uint8 b) { static DAC x; @@ -249,8 +240,6 @@ DAC MkDAC (uint8 r, uint8 g, uint8 b) } - - RGB MkRGB (uint8 r, uint8 g, uint8 b) { static TRGB x; @@ -261,10 +250,6 @@ RGB MkRGB (uint8 r, uint8 g, uint8 b) } - - - - SPRITE * Locate (int ref) { SPRITE * spr = VGA::ShowQ.Locate(ref); @@ -272,18 +257,10 @@ SPRITE * Locate (int ref) } - - - -//-------------------------------------------------------------------------- - - bool HEART::Enable = false; uint16 * HEART::XTimer = NULL; - - HEART::HEART (void) : ENGINE(TMR_DIV) { @@ -327,11 +304,10 @@ extern "C" void TimerProc (void) */ -void ENGINE::NewTimer (...) +void ENGINE::NewTimer(...) { static SPRITE * spr; static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - // TODO Timer ASM /* ___1152_Hz___: @@ -391,12 +367,10 @@ void ENGINE::NewTimer (...) } */ + warning("STUB: ENGINE::NewTimer"); } - - - void HEART::SetXTimer (uint16 * ptr) { if (XTimer && ptr != XTimer) *XTimer = 0; @@ -404,8 +378,6 @@ void HEART::SetXTimer (uint16 * ptr) } - - void HEART::SetXTimer (uint16 * ptr, uint16 time) { SetXTimer(ptr); @@ -413,16 +385,6 @@ void HEART::SetXTimer (uint16 * ptr, uint16 time) } - - -//-------------------------------------------------------------------------- - - - - - - - SPRITE::SPRITE (BMP_PTR * shp) : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), @@ -434,18 +396,12 @@ SPRITE::SPRITE (BMP_PTR * shp) } - - - - SPRITE::~SPRITE (void) { Contract(); } - - BMP_PTR SPRITE::Shp (void) { register SPREXT * e = Ext; @@ -459,7 +415,7 @@ BMP_PTR SPRITE::Shp (void) //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); //VGA::Exit(s, File); - VGA::Exit("Invalid PHASE in SPRITE::Shp()", File); + error("Invalid PHASE in SPRITE::Shp() %s", File); } #endif return e->ShpList[i]; @@ -468,9 +424,6 @@ BMP_PTR SPRITE::Shp (void) } - - - BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) { BMP_PTR * r = (Ext) ? Ext->ShpList : NULL; @@ -497,9 +450,6 @@ BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) } - - - void SPRITE::MoveShapes (uint8 * buf) { BMP_PTR * p; @@ -510,9 +460,6 @@ void SPRITE::MoveShapes (uint8 * buf) } - - - bool SPRITE::Works (SPRITE * spr) { if (spr) if (spr->Ext) @@ -530,9 +477,6 @@ bool SPRITE::Works (SPRITE * spr) } - - - SEQ * SPRITE::SetSeq (SEQ * seq) { Expand(); @@ -545,10 +489,6 @@ SEQ * SPRITE::SetSeq (SEQ * seq) } - - - - bool SPRITE::SeqTest (int n) { if (n >= 0) return (SeqPtr == n); @@ -557,10 +497,6 @@ bool SPRITE::SeqTest (int n) } - - - - SNAIL::COM * SPRITE::SnList (SNLIST type) { register SPREXT * e = Ext; @@ -569,10 +505,6 @@ SNAIL::COM * SPRITE::SnList (SNLIST type) } - - - - void SPRITE::SetName (char * n) { if (Ext) @@ -592,9 +524,6 @@ void SPRITE::SetName (char * n) } - - - SPRITE * SPRITE::Expand (void) { if (! Ext) @@ -732,8 +661,6 @@ SPRITE * SPRITE::Expand (void) } - - SPRITE * SPRITE::Contract (void) { register SPREXT * e = Ext; @@ -756,10 +683,6 @@ SPRITE * SPRITE::Contract (void) } - - - - SPRITE * SPRITE::BackShow (bool fast) { Expand(); @@ -771,12 +694,6 @@ SPRITE * SPRITE::BackShow (bool fast) } - - - - - - void SPRITE::Step (int nr) { if (nr >= 0) SeqPtr = nr; @@ -794,19 +711,12 @@ void SPRITE::Step (int nr) } - - - - void SPRITE::Tick (void) { Step(); } - - - void SPRITE::MakeXlat (uint8 * x) { if (Ext) @@ -820,9 +730,6 @@ void SPRITE::MakeXlat (uint8 * x) } - - - void SPRITE::KillXlat (void) { if (Flags.Xlat && Ext) @@ -841,9 +748,6 @@ void SPRITE::KillXlat (void) } - - - void SPRITE::Goto (int x, int y) { int xo = X, yo = Y; @@ -864,28 +768,12 @@ void SPRITE::Goto (int x, int y) } - - - - - - - - - - void SPRITE::Center (void) { Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); } - - - - - - void SPRITE::Show (void) { register SPREXT * e; @@ -906,11 +794,6 @@ void SPRITE::Show (void) } - - - - - void SPRITE::Show (uint16 pg) { uint8 * a = VGA::Page[1]; @@ -920,12 +803,6 @@ void SPRITE::Show (uint16 pg) } - - - - - - void SPRITE::Hide (void) { register SPREXT * e = Ext; @@ -933,8 +810,6 @@ void SPRITE::Hide (void) } - - BMP_PTR SPRITE::Ghost (void) { register SPREXT * e = Ext; @@ -956,10 +831,6 @@ BMP_PTR SPRITE::Ghost (void) } - - - - SPRITE * SpriteAt (int x, int y) { SPRITE * spr = NULL, * tail = VGA::ShowQ.Last(); @@ -974,32 +845,18 @@ SPRITE * SpriteAt (int x, int y) } - - - -//-------------------------------------------------------------------------- - - - - - - QUEUE::QUEUE (bool show) : Head(NULL), Tail(NULL), Show(show) { } - - QUEUE::~QUEUE (void) { Clear(); } - - void QUEUE::Clear (void) { while (Head) @@ -1010,8 +867,6 @@ void QUEUE::Clear (void) } - - void QUEUE::ForAll (void (*fun)(SPRITE *)) { SPRITE * s = Head; @@ -1024,9 +879,6 @@ void QUEUE::ForAll (void (*fun)(SPRITE *)) } - - - void QUEUE::Append (SPRITE * spr) { if (Tail) @@ -1041,9 +893,6 @@ void QUEUE::Append (SPRITE * spr) } - - - void QUEUE::Insert (SPRITE * spr, SPRITE * nxt) { if (nxt == Head) @@ -1064,9 +913,6 @@ void QUEUE::Insert (SPRITE * spr, SPRITE * nxt) } - - - void QUEUE::Insert (SPRITE * spr) { SPRITE * s; @@ -1080,9 +926,6 @@ void QUEUE::Insert (SPRITE * spr) } - - - SPRITE * QUEUE::Remove (SPRITE * spr) { if (spr == Head) Head = spr->Next; @@ -1095,9 +938,6 @@ SPRITE * QUEUE::Remove (SPRITE * spr) } - - - SPRITE * QUEUE::Locate (int ref) { SPRITE * spr; @@ -1106,14 +946,6 @@ SPRITE * QUEUE::Locate (int ref) } - - - -//-------------------------------------------------------------------------- - - - - uint16 VGA::StatAdr = VGAST1_; uint16 VGA::OldMode = 0; uint16 * VGA::OldScreen = NULL; @@ -1177,9 +1009,6 @@ VGA::VGA (int mode) } - - - VGA::~VGA (void) { Mono = 0; @@ -1205,7 +1034,7 @@ VGA::~VGA (void) void VGA::SetStatAdr (void) { - /* TODO SetStatADR ASM + /* asm mov dx,VGAMIr_ asm in al,dx asm test al,1 // CGA addressing mode flag @@ -1215,17 +1044,13 @@ void VGA::SetStatAdr (void) set_mode_adr: StatAdr = _AX; */ + warning("STUB: VGA::SetStatADR"); } - - - - #pragma argsused void VGA::WaitVR (bool on) { - // TODO Wait vertical retrace ASM /* _DX = StatAdr; _AH = (on) ? 0x00 : 0x08; @@ -1240,16 +1065,13 @@ void VGA::WaitVR (bool on) asm xor ah,0x08 asm loop wait */ + warning("STUB: VGA::WaitVR"); } - - - - void VGA::Setup (VgaRegBlk * vrb) { -/* TODO VGA setup +/* WaitVR(); // *--LOOK!--* resets VGAATR logic asm cld asm mov si, vrb // take address of parameter table @@ -1287,17 +1109,13 @@ void VGA::Setup (VgaRegBlk * vrb) xit: */ + warning("STUB: VGA::Setup"); } - - - - -int VGA::SetMode (int mode) +int VGA::SetMode(int mode) { - /* TODO VGA Set Mode - +/* Clear(); // get current mode asm mov ah,0x0F @@ -1317,17 +1135,14 @@ int VGA::SetMode (int mode) asm pop ax return _AX; */ + warning("STUB: VGA::SetMode"); return 0; } - - - - -void VGA::GetColors (DAC * tab) +void VGA::GetColors(DAC * tab) { - /* TODO GetColors ASM +/* asm cld asm les di,tab // color table asm mov dx,0x3C7 // PEL address read mode register @@ -1344,18 +1159,14 @@ void VGA::GetColors (DAC * tab) sto: asm stosb // store 1 color asm loop gc // next one? - */ + warning("STUB: VGA::GetColors"); } - - -void VGA::SetColors (DAC * tab, int lum) +void VGA::SetColors(DAC * tab, int lum) { - - /* TODO SetColors - +/* DAC * des = NewColors; asm push ds @@ -1401,13 +1212,10 @@ void VGA::SetColors (DAC * tab, int lum) } */ SetPal = true; + warning("STUB: VGA::SetColors"); } - - - - void VGA::SetColors (void) { memset(NewColors, 0, PAL_SIZ); @@ -1415,10 +1223,6 @@ void VGA::SetColors (void) } - - - - void VGA::Sunrise (DAC * tab) { int i; @@ -1431,10 +1235,6 @@ void VGA::Sunrise (DAC * tab) } - - - - void VGA::Sunset (void) { DAC tab[256]; @@ -1449,13 +1249,6 @@ void VGA::Sunset (void) } - - - - - - - void VGA::Show (void) { SPRITE * spr = ShowQ.First(); @@ -1468,11 +1261,9 @@ void VGA::Show (void) } - - -void VGA::UpdateColors (void) +void VGA::UpdateColors(void) { - /* TODO UpdateColors ASM +/* DAC * tab = NewColors; asm push ds @@ -1497,18 +1288,13 @@ void VGA::UpdateColors (void) asm pop ds */ + warning("STUB: VGA::UpdateColors"); } - - - - - -void VGA::Update (void) +void VGA::Update(void) { - // TODO VGA Update - /* +/* uint8 * p = Page[1]; Page[1] = Page[0]; Page[0] = p; @@ -1528,18 +1314,13 @@ void VGA::Update (void) UpdateColors(); SetPal = false; } + warning("STUB: VGA::Update"); } - - - - - - -void VGA::Clear (uint8 color) +void VGA::Clear(uint8 color) { - /* TODO Clear ASM +/* uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); asm mov dx,VGASEQ_ @@ -1553,16 +1334,13 @@ void VGA::Clear (uint8 color) asm rep stosb asm stosb */ + warning("STUB: VGA::Clear"); } - - - - -void VGA::CopyPage (uint16 d, uint16 s) +void VGA::CopyPage(uint16 d, uint16 s) { - /* TODO CopyPage +/* uint8 * S = Page[s & 3], * D = Page[d & 3]; asm mov dx,VGAGRA_ @@ -1594,14 +1372,14 @@ void VGA::CopyPage (uint16 d, uint16 s) asm pop ax asm out dx,al // end of copy mode */ + warning("STUB: VGA::CopyPage"); } //-------------------------------------------------------------------------- -void BITMAP::XShow (int x, int y) +void BITMAP::XShow(int x, int y) { - // TODO XShow ASM - /* +/* uint8 rmsk = x % 4, mask = 1 << rmsk, * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; @@ -1617,8 +1395,6 @@ void BITMAP::XShow (int x, int y) asm lds si,v asm mov bx,m - - asm mov al,0x02 // map mask register asm mov ah,mask @@ -1679,19 +1455,13 @@ void BITMAP::XShow (int x, int y) asm pop ds asm pop si asm pop bx - */ + warning("STUB: BITMAP::XShow"); } - - - - -void BITMAP::Show (int x, int y) +void BITMAP::Show(int x, int y) { - - // TODO Show ASM /* uint8 mask = 1 << (x & 3), * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); @@ -1757,16 +1527,13 @@ void BITMAP::Show (int x, int y) asm jne plane asm pop ds */ + warning("STUB: BITMAP::Show"); } - - - -void BITMAP::Hide (int x, int y) +void BITMAP::Hide(int x, int y) { - // TODO Bitmap Hide ASM - /* +/* uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); HideDesc * b = B; @@ -1828,6 +1595,7 @@ void BITMAP::Hide (int x, int y) asm pop si // asm pop bx */ + warning("STUB: BITMAP::Hide"); } } // End of namespace CGE -- cgit v1.2.3 From ffc2aa4e4f41aa679d773ccafdec87bf8d7b5e85 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 11:57:24 +0200 Subject: CGE: Format code --- engines/cge/bitmap.cpp | 673 ++++----- engines/cge/bitmap.h | 86 +- engines/cge/bitmaps.cpp | 371 ++--- engines/cge/bitmaps.h | 18 +- engines/cge/boot.h | 76 +- engines/cge/btfile.cpp | 226 ++- engines/cge/btfile.h | 95 +- engines/cge/cfile.cpp | 441 +++--- engines/cge/cfile.h | 71 +- engines/cge/cge.cpp | 31 +- engines/cge/cge.h | 20 +- engines/cge/cge_main.cpp | 3459 ++++++++++++++++++++------------------------- engines/cge/cge_main.h | 288 ++-- engines/cge/config.cpp | 433 +++--- engines/cge/config.h | 6 +- engines/cge/detection.cpp | 10 +- engines/cge/ems.cpp | 310 ++-- engines/cge/game.cpp | 118 +- engines/cge/game.h | 43 +- engines/cge/general.cpp | 417 +++--- engines/cge/general.h | 311 ++-- engines/cge/gettext.cpp | 174 ++- engines/cge/gettext.h | 38 +- engines/cge/ident.h | 17 +- engines/cge/jbw.h | 229 +-- engines/cge/keybd.cpp | 213 ++- engines/cge/keybd.h | 45 +- engines/cge/mixer.cpp | 203 ++- engines/cge/mixer.h | 45 +- engines/cge/module.mk | 7 +- engines/cge/mouse.cpp | 300 ++-- engines/cge/mouse.h | 82 +- engines/cge/snail.cpp | 1998 ++++++++++++-------------- engines/cge/snail.h | 144 +- engines/cge/snddrv.h | 86 +- engines/cge/sound.cpp | 360 ++--- engines/cge/sound.h | 76 +- engines/cge/startup.cpp | 276 ++-- engines/cge/startup.h | 61 +- engines/cge/talk.cpp | 548 +++---- engines/cge/talk.h | 92 +- engines/cge/text.cpp | 435 +++--- engines/cge/text.h | 76 +- engines/cge/vga13h.cpp | 2473 ++++++++++++++++---------------- engines/cge/vga13h.h | 505 ++++--- engines/cge/vmenu.cpp | 208 ++- engines/cge/vmenu.h | 39 +- engines/cge/vol.cpp | 89 +- engines/cge/vol.h | 84 +- engines/cge/wav.h | 175 +-- 50 files changed, 7666 insertions(+), 8915 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 1201b84fc6..1e5310a8e7 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -25,434 +25,389 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/bitmap.h" -#include "cge/cfile.h" -#include "cge/jbw.h" - -#ifdef VOL - #include "cge/vol.h" -#endif - -#include +#include "cge/bitmap.h" +#include "cge/cfile.h" +#include "cge/jbw.h" +#include "cge/vol.h" +#include #include "cge/cfile.h" #include "common/system.h" namespace CGE { -//-------------------------------------------------------------------------- - - - - -DAC * BITMAP::Pal = NULL; - +DAC *BITMAP::Pal = NULL; #define MAXPATH 128 #pragma argsused -BITMAP::BITMAP (const char * fname, bool rem) -: M(NULL), V(NULL) -{ - char pat[MAXPATH]; - - ForceExt(pat, fname, ".VBM"); - - #if (BMP_MODE < 2) - if (rem && PIC_FILE::Exist(pat)) - { - PIC_FILE file(pat); - if (file.Error == 0) - if (! VBMLoad(&file)) - error("Bad VBM [%s]", fname); - } - else - #endif - { - #if (BMP_MODE) - ForceExt(pat, fname, ".BMP"); - PIC_FILE file(pat); - if (file.Error == 0) +BITMAP::BITMAP(const char *fname, bool rem) : M(NULL), V(NULL) { + char pat[MAXPATH]; + ForceExt(pat, fname, ".VBM"); + +#if (BMP_MODE < 2) + if (rem && PIC_FILE::Exist(pat)) { + PIC_FILE file(pat); + if ((file.Error == 0) && (!VBMLoad(&file))) + error("Bad VBM [%s]", fname); + } else +#endif { - if (BMPLoad(&file)) - { - Code(); - if (rem) - { - free(M); - M = NULL; +#if (BMP_MODE) + ForceExt(pat, fname, ".BMP"); + PIC_FILE file(pat); + if (file.Error == 0) { + if (BMPLoad(&file)) { + Code(); + if (rem) { + free(M); + M = NULL; + } + } else + error("Bad BMP [%s]", fname); } - } - else - error("Bad BMP [%s]", fname); +#else + error("Bad VBM [%s]", fname); +#endif } - #else - error("Bad VBM [%s]", fname); - #endif - } } - - - -BITMAP::BITMAP (uint16 w, uint16 h, uint8 * map) -: W(w), H(h), M(map), V(NULL) -{ - if (map) Code(); +BITMAP::BITMAP(uint16 w, uint16 h, uint8 *map) : W(w), H(h), M(map), V(NULL) { + if (map) + Code(); } - - // following routine creates filled rectangle // immediately as VGA video chunks, in near memory as fast as possible, // especially for text line real time display - -BITMAP::BITMAP (uint16 w, uint16 h, uint8 fill) -: W((w + 3) & ~3), // only full uint32 allowed! - H(h), - M(NULL) -{ - uint16 dsiz = W >> 2; // data size (1 plane line size) - uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap - uint16 psiz = H * lsiz; // - last gape, but + plane trailer - uint8 * v = new uint8[4 * psiz // the same for 4 planes - + H * sizeof(*B)]; // + room for wash table - if (v == NULL) - error("No core"); - - * (uint16 *) v = CPY | dsiz; // data chunk hader - memset(v+2, fill, dsiz); // data bytes - * (uint16 *) (v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap - memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines - * (uint16 *) (v + psiz - 2) = EOI; // plane trailer uint16 - memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes - HideDesc * b = (HideDesc *) (v + 4 * psiz); - b->skip = (SCR_WID - W) >> 2; - b->hide = W >> 2; - memcpy(b+1, b, (H-1) * sizeof(*b)); // tricky fill entire table - b->skip = 0; // fix the first entry - V = v; - B = b; +BITMAP::BITMAP(uint16 w, uint16 h, uint8 fill) + : W((w + 3) & ~3), // only full uint32 allowed! + H(h), + M(NULL) { + uint16 dsiz = W >> 2; // data size (1 plane line size) + uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap + uint16 psiz = H * lsiz; // - last gape, but + plane trailer + uint8 *v = new uint8[4 * psiz + H * sizeof(*B)];// the same for 4 planes + // + room for wash table + if (v == NULL) + error("No core"); + + *(uint16 *) v = CPY | dsiz; // data chunk hader + memset(v + 2, fill, dsiz); // data bytes + *(uint16 *)(v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap + memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines + *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 + memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes + HideDesc *b = (HideDesc *)(v + 4 * psiz); + b->skip = (SCR_WID - W) >> 2; + b->hide = W >> 2; + memcpy(b + 1, b, (H - 1) * sizeof(*b)); // tricky fill entire table + b->skip = 0; // fix the first entry + V = v; + B = b; } - - - - - -BITMAP::BITMAP (const BITMAP& bmp) -: W(bmp.W), H(bmp.H), - M(NULL), V(NULL) -{ - uint8 * v0 = bmp.V; - if (v0) - { - uint16 vsiz = (uint8*)(bmp.B) - (uint8*)(v0); - uint16 siz = vsiz + H * sizeof(HideDesc); - uint8 * v1 = farnew(uint8, siz); - if (v1 == NULL) - error("No core"); - memcpy(v1, v0, siz); - B = (HideDesc *) ((V = v1) + vsiz); - } +BITMAP::BITMAP(const BITMAP &bmp) : W(bmp.W), H(bmp.H), M(NULL), V(NULL) { + uint8 *v0 = bmp.V; + if (v0) { + uint16 vsiz = (uint8 *)(bmp.B) - (uint8 *)(v0); + uint16 siz = vsiz + H * sizeof(HideDesc); + uint8 *v1 = farnew(uint8, siz); + if (v1 == NULL) + error("No core"); + memcpy(v1, v0, siz); + B = (HideDesc *)((V = v1) + vsiz); + } } - - - -BITMAP::~BITMAP (void) -{ - switch (MemType(M)) - { - case FAR_MEM : free(M); break; - } - switch (MemType(V)) - { - case NEAR_MEM : delete[] (uint8 *) V; break; - case FAR_MEM : free(V); break; - } +BITMAP::~BITMAP(void) { + if (MemType(M) == FAR_MEM) + free(M); + + switch (MemType(V)) { + case NEAR_MEM : + delete[](uint8 *) V; + break; + case FAR_MEM : + free(V); + break; + } } - -BITMAP& BITMAP::operator = (const BITMAP& bmp) -{ - uint8 * v0 = bmp.V; - W = bmp.W; - H = bmp.H; - M = NULL; - if (MemType(V) == FAR_MEM) free(V); - if (v0 == NULL) V = NULL; - else - { - uint16 vsiz = (uint8*)bmp.B - (uint8*)v0; - uint16 siz = vsiz + H * sizeof(HideDesc); - uint8 * v1 = farnew(uint8, siz); - if (v1 == NULL) - error("No core"); - memcpy(v1, v0, siz); - B = (HideDesc *) ((V = v1) + vsiz); - } - return *this; +BITMAP &BITMAP::operator = (const BITMAP &bmp) { + uint8 *v0 = bmp.V; + W = bmp.W; + H = bmp.H; + M = NULL; + if (MemType(V) == FAR_MEM) + free(V); + if (v0 == NULL) + V = NULL; + else { + uint16 vsiz = (uint8 *)bmp.B - (uint8 *)v0; + uint16 siz = vsiz + H * sizeof(HideDesc); + uint8 *v1 = farnew(uint8, siz); + if (v1 == NULL) + error("No core"); + memcpy(v1, v0, siz); + B = (HideDesc *)((V = v1) + vsiz); + } + return *this; } - - - -uint16 BITMAP::MoveVmap (uint8 * buf) -{ - if (V) - { - uint16 vsiz = (uint8*)B - (uint8*)V; - uint16 siz = vsiz + H * sizeof(HideDesc); - memcpy(buf, V, siz); - if (MemType(V) == FAR_MEM) free(V); - B = (HideDesc *) ((V = buf) + vsiz); - return siz; - } - return 0; +uint16 BITMAP::MoveVmap(uint8 *buf) { + if (V) { + uint16 vsiz = (uint8 *)B - (uint8 *)V; + uint16 siz = vsiz + H * sizeof(HideDesc); + memcpy(buf, V, siz); + if (MemType(V) == FAR_MEM) + free(V); + B = (HideDesc *)((V = buf) + vsiz); + return siz; + } + return 0; } +BMP_PTR BITMAP::Code(void) { + if (M) { + uint16 i, cnt; + if (V) { // old X-map exists, so remove it + switch (MemType(V)) { + case NEAR_MEM : + delete[](uint8 *) V; + break; + case FAR_MEM : + free(V); + break; + } + V = NULL; + } + while (true) { // at most 2 times: for (V == NULL) & for allocated block; + uint8 *im = V + 2; + uint16 *cp = (uint16 *) V; + int bpl; + if (V) { // 2nd pass - fill the hide table + for (i = 0; i < H; i ++) { + B[i].skip = 0xFFFF; + B[i].hide = 0x0000; + } + } + for (bpl = 0; bpl < 4; bpl ++) { // once per each bitplane + uint8 *bm = M; + bool skip = (bm[bpl] == TRANS); + uint16 j; + + cnt = 0; + for (i = 0; i < H; i ++) { // once per each line + uint8 pix; + for (j = bpl; j < W; j += 4) { + pix = bm[j]; + if (V && pix != TRANS) { + if (j < B[i].skip) + B[i].skip = j; + + if (j >= B[i].hide) + B[i].hide = j + 1; + } + if ((pix == TRANS) != skip || cnt >= 0x3FF0) { // end of block + cnt |= (skip) ? SKP : CPY; + if (V) + *cp = cnt; // store block description uint16 + + cp = (uint16 *) im; + im += 2; + skip = (pix == TRANS); + cnt = 0; + } + if (! skip) { + if (V) + *im = pix; + ++ im; + } + ++ cnt; + } + + bm += W; + if (W < SCR_WID) { + if (skip) { + cnt += (SCR_WID - j + 3) / 4; + } else { + cnt |= CPY; + if (V) + *cp = cnt; + + cp = (uint16 *) im; + im += 2; + skip = true; + cnt = (SCR_WID - j + 3) / 4; + } + } + } + if (cnt && ! skip) { + cnt |= CPY; + if (V) + *cp = cnt; + + cp = (uint16 *) im; + im += 2; + } + if (V) + *cp = EOI; + cp = (uint16 *) im; + im += 2; + } + if (V) + break; + uint16 sizV = (uint16)(im - 2 - V); + V = farnew(uint8, sizV + H * sizeof(*B)); + if (! V) + error("No core"); -BMP_PTR BITMAP::Code (void) -{ - if (M) - { - uint16 i, cnt; - - if (V) // old X-map exists, so remove it - { - switch (MemType(V)) - { - case NEAR_MEM : delete[] (uint8 *) V; break; - case FAR_MEM : free(V); break; - } - V = NULL; - } - - while (true) // at most 2 times: for (V == NULL) & for allocated block; - { - uint8 * im = V+2; - uint16 * cp = (uint16 *) V; - int bpl; - - if (V) // 2nd pass - fill the hide table - { - for (i = 0; i < H; i ++) - { - B[i].skip = 0xFFFF; - B[i].hide = 0x0000; + B = (HideDesc *)(V + sizV); } - } - for (bpl = 0; bpl < 4; bpl ++) // once per each bitplane - { - uint8 * bm = M; - bool skip = (bm[bpl] == TRANS); - uint16 j; - - cnt = 0; - for (i = 0; i < H; i ++) // once per each line - { - uint8 pix; - for (j = bpl; j < W; j += 4) - { - pix = bm[j]; - if (V && pix != TRANS) - { - if (j < B[i].skip) B[i].skip = j; - if (j >= B[i].hide) B[i].hide = j+1; + cnt = 0; + for (i = 0; i < H; i ++) { + if (B[i].skip == 0xFFFF) { // whole line is skipped + B[i].skip = (cnt + SCR_WID) >> 2; + cnt = 0; + } else { + uint16 s = B[i].skip & ~3; + uint16 h = (B[i].hide + 3) & ~3; + B[i].skip = (cnt + s) >> 2; + B[i].hide = (h - s) >> 2; + cnt = SCR_WID - h; } - if ((pix == TRANS) != skip || cnt >= 0x3FF0) // end of block - { - cnt |= (skip) ? SKP : CPY; - if (V) - { - *cp = cnt; // store block description uint16 - } - cp = (uint16 *) im; - im += 2; - skip = (pix == TRANS); - cnt = 0; - } - if (! skip) - { - if (V) * im = pix; - ++ im; - } - ++ cnt; - } - - bm += W; - if (W < SCR_WID) - { - if (skip) - { - cnt += (SCR_WID - j + 3) / 4; - } - else - { - cnt |= CPY; - if (V) - { - *cp = cnt; - } - cp = (uint16 *) im; - im += 2; - skip = true; - cnt = (SCR_WID - j + 3) / 4; - } - } } - if (cnt && ! skip) - { - cnt |= CPY; - if (V) - { - *cp = cnt; - } - cp = (uint16 *) im; - im += 2; - } - if (V) *cp = EOI; - cp = (uint16 *) im; - im += 2; - } - if (V) break; - uint16 sizV = (uint16) (im - 2 - V); - V = farnew(uint8, sizV + H * sizeof(*B)); - if (! V) - { - error("No core"); - } - B = (HideDesc *) (V + sizV); - } - cnt = 0; - for (i = 0; i < H; i ++) - { - if (B[i].skip == 0xFFFF) // whole line is skipped - { - B[i].skip = (cnt + SCR_WID) >> 2; - cnt = 0; - } - else - { - uint16 s = B[i].skip & ~3; - uint16 h = (B[i].hide + 3) & ~3; - B[i].skip = (cnt + s) >> 2; - B[i].hide = (h - s) >> 2; - cnt = SCR_WID - h; - } } - } - return this; + return this; } +bool BITMAP::SolidAt(int x, int y) { + uint8 *m; + uint16 r, n, n0; + if ((x >= W) || (y >= H)) + return false; + m = V; + r = x % 4; + n0 = (SCR_WID * y + x) / 4, n = 0; + while (r) { + uint16 w, t; -bool BITMAP::SolidAt (int x, int y) -{ - uint8 * m; - uint16 r, n, n0; - - if (x >= W || y >= H) return false; + w = *(uint16 *) m; + m += 2; + t = w & 0xC000; + w &= 0x3FFF; - m = V; - r = x % 4; - n0 = (SCR_WID * y + x) / 4, n = 0; - - while (r) - { - uint16 w, t; - - w = * (uint16 *) m; - m += 2; - t = w & 0xC000; - w &= 0x3FFF; - - switch (t) - { - case EOI : -- r; - case SKP : w = 0; break; - case REP : w = 1; break; + switch (t) { + case EOI : + -- r; + case SKP : + w = 0; + break; + case REP : + w = 1; + break; + } + m += w; } - m += w; - } - - while (true) - { - uint16 w, t; - w = * (uint16 *) m; - m += 2; - t = w & 0xC000; - w &= 0x3FFF; - - if (n > n0) return false; - n += w; - switch (t) - { - case EOI : return false; - case SKP : w = 0; break; - case REP : - case CPY : if (n-w <= n0 && n > n0) return true; break; + while (true) { + uint16 w, t; + + w = * (uint16 *) m; + m += 2; + t = w & 0xC000; + w &= 0x3FFF; + + if (n > n0) + return false; + + n += w; + switch (t) { + case EOI : + return false; + case SKP : + w = 0; + break; + case REP : + case CPY : + if (n - w <= n0 && n > n0) + return true; + break; + } + m += (t == REP) ? 1 : w; } - m += (t == REP) ? 1 : w; - } } +bool BITMAP::VBMSave(XFILE *f) { + uint16 p = (Pal != NULL), + n = ((uint16)(((uint8 *)B) - V)) + H * sizeof(HideDesc); + if (f->Error == 0) + f->Write((uint8 *)&p, sizeof(p)); + + if (f->Error == 0) + f->Write((uint8 *)&n, sizeof(n)); + if (f->Error == 0) + f->Write((uint8 *)&W, sizeof(W)); + if (f->Error == 0) + f->Write((uint8 *)&H, sizeof(H)); + if (f->Error == 0) + if (p) + f->Write((uint8 *)Pal, 256 * sizeof(DAC)); -bool BITMAP::VBMSave (XFILE * f) -{ - uint16 p = (Pal != NULL), - n = ((uint16) (((uint8 *)B) - V)) + H * sizeof(HideDesc); - if (f->Error == 0) f->Write((uint8 *)&p, sizeof(p)); - if (f->Error == 0) f->Write((uint8 *)&n, sizeof(n)); - if (f->Error == 0) f->Write((uint8 *)&W, sizeof(W)); - if (f->Error == 0) f->Write((uint8 *)&H, sizeof(H)); - if (f->Error == 0) if (p) f->Write((uint8 *)Pal, 256 * sizeof(DAC)); - if (f->Error == 0) f->Write(V, n); - return (f->Error == 0); + if (f->Error == 0) + f->Write(V, n); + + return (f->Error == 0); } +bool BITMAP::VBMLoad(XFILE *f) { + uint16 p = 0, n = 0; + if (f->Error == 0) + f->Read((uint8 *)&p, sizeof(p)); + if (f->Error == 0) + f->Read((uint8 *)&n, sizeof(n)); + if (f->Error == 0) + f->Read((uint8 *)&W, sizeof(W)); -bool BITMAP::VBMLoad (XFILE * f) -{ - uint16 p = 0, n = 0; - if (f->Error == 0) f->Read((uint8 *)&p, sizeof(p)); - if (f->Error == 0) f->Read((uint8 *)&n, sizeof(n)); - if (f->Error == 0) f->Read((uint8 *)&W, sizeof(W)); - if (f->Error == 0) f->Read((uint8 *)&H, sizeof(H)); - if (f->Error == 0) - { - if (p) - { - if (Pal) f->Read((uint8 *)Pal, 256 * sizeof(DAC)); - else f->Seek(f->Mark() + 256 * sizeof(DAC)); + if (f->Error == 0) + f->Read((uint8 *)&H, sizeof(H)); + + if (f->Error == 0) { + if (p) { + if (Pal) + f->Read((uint8 *)Pal, 256 * sizeof(DAC)); + else + f->Seek(f->Mark() + 256 * sizeof(DAC)); + } } - } - if ((V = farnew(uint8, n)) == NULL) return false; - if (f->Error == 0) f->Read(V, n); - B = (HideDesc *) (V + n - H * sizeof(HideDesc)); - return (f->Error == 0); -} + if ((V = farnew(uint8, n)) == NULL) + return false; + if (f->Error == 0) + f->Read(V, n); + B = (HideDesc *)(V + n - H * sizeof(HideDesc)); + return (f->Error == 0); +} } // End of namespace CGE diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 90f94b1b32..eca3be70e8 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -25,64 +25,64 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __BITMAP__ -#define __BITMAP__ +#ifndef __BITMAP__ +#define __BITMAP__ -#include "cge/general.h" +#include "cge/general.h" namespace CGE { -#define EOI 0x0000 -#define SKP 0x4000 -#define REP 0x8000 -#define CPY 0xC000 +#define EOI 0x0000 +#define SKP 0x4000 +#define REP 0x8000 +#define CPY 0xC000 -#define TRANS 0xFE +#define TRANS 0xFE -typedef struct { uint16 b : 2; - uint16 B : 6; - uint16 g : 2; - uint16 G : 6; - uint16 r : 2; - uint16 R : 6; - uint16 Z : 8; - } BGR4; +typedef struct { + uint16 b : 2; + uint16 B : 6; + uint16 g : 2; + uint16 G : 6; + uint16 r : 2; + uint16 R : 6; + uint16 Z : 8; +} BGR4; -typedef struct { uint16 skip; uint16 hide; } HideDesc; +typedef struct { + uint16 skip; + uint16 hide; +} HideDesc; - - -class BITMAP -{ - bool BMPLoad (XFILE * f); - bool VBMLoad (XFILE * f); +class BITMAP { + bool BMPLoad(XFILE *f); + bool VBMLoad(XFILE *f); public: - static DAC * Pal; - uint16 W, H; - uint8 * M, * V; HideDesc * B; - BITMAP (const char * fname, bool rem = true); - BITMAP (uint16 w, uint16 h, uint8 * map); - BITMAP (uint16 w, uint16 h, uint8 fill); - BITMAP (const BITMAP& bmp); - ~BITMAP (void); - BITMAP * FlipH (void); - BITMAP * Code (); - BITMAP& operator = (const BITMAP& bmp); - void Hide (int x, int y); - void Show (int x, int y); - void XShow (int x, int y); - bool SolidAt (int x, int y); - bool VBMSave (XFILE * f); - uint16 MoveVmap (uint8 * buf); + static DAC *Pal; + uint16 W, H; + uint8 *M, * V; + HideDesc *B; + BITMAP(const char *fname, bool rem = true); + BITMAP(uint16 w, uint16 h, uint8 *map); + BITMAP(uint16 w, uint16 h, uint8 fill); + BITMAP(const BITMAP &bmp); + ~BITMAP(void); + BITMAP *FlipH(void); + BITMAP *Code(); + BITMAP &operator = (const BITMAP &bmp); + void Hide(int x, int y); + void Show(int x, int y); + void XShow(int x, int y); + bool SolidAt(int x, int y); + bool VBMSave(XFILE *f); + uint16 MoveVmap(uint8 *buf); }; - -typedef BITMAP * BMP_PTR; - +typedef BITMAP *BMP_PTR; } // End of namespace CGE diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp index 1eba1b55ea..8e1b7ce5e9 100644 --- a/engines/cge/bitmaps.cpp +++ b/engines/cge/bitmaps.cpp @@ -25,146 +25,146 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/bitmaps.h" +#include "cge/bitmaps.h" /* -#define W 255, -#define x 252, -#define _ TRANS, -#define o 0, -#define L LGRAY, -#define G GRAY, -#define D DGRAY, - -static uint8 MCDesign0[]= { W W W W W W _ - W W W W W o _ - W W W W o _ _ - W W W W W _ _ - W W o W W W _ - W o _ o W W W - o _ _ _ o W W - _ _ _ _ _ o o }; - - -static uint8 MCDesign1[]= { _ }; - - - -static uint8 SLDesign[] = { G G G G G G G G G _ _ _ _ _ _ - L G G G G G G G G D _ _ _ _ _ - _ L G G G G G G G D _ _ _ _ _ - _ _ L G G G G G G G D _ _ _ _ - _ _ _ L G G G G G G D _ _ _ _ - _ _ _ _ L G G G G G D _ _ _ _ - _ _ _ _ _ L G G G G G D _ _ _ - _ _ _ _ _ _ L G G G G D _ _ _ - _ _ _ _ _ _ _ L G G G D _ _ _ - _ _ _ _ _ _ _ _ L G G G D _ _ - _ _ _ _ _ _ _ _ _ L G G D _ _ - _ _ _ _ _ _ _ _ _ _ L G D _ _ - _ _ _ _ _ _ _ _ _ _ _ L G D _ - _ _ _ _ _ _ _ _ _ _ _ _ L D _ - _ _ _ _ _ _ _ _ _ _ _ _ _ L D - _ _ _ _ _ _ _ _ _ _ _ _ _ _ D - }; - -static uint8 SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G - _ _ _ _ _ L G G G G G G G G D - _ _ _ _ _ L G G G G G G G D _ - _ _ _ _ L G G G G G G G D _ _ - _ _ _ _ L G G G G G G D _ _ _ - _ _ _ _ L G G G G G D _ _ _ _ - _ _ _ L G G G G G D _ _ _ _ _ - _ _ _ L G G G G D _ _ _ _ _ _ - _ _ _ L G G G D _ _ _ _ _ _ _ - _ _ L G G G D _ _ _ _ _ _ _ _ - _ _ L G G D _ _ _ _ _ _ _ _ _ - _ _ L G D _ _ _ _ _ _ _ _ _ _ - _ L G D _ _ _ _ _ _ _ _ _ _ _ - _ L D _ _ _ _ _ _ _ _ _ _ _ _ - L D _ _ _ _ _ _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ _ _ _ _ _ _ - }; - -static uint8 MapBrick[] = { L L L L L L L G - L G G G G G G D - L G G G G G G D - G D D D D D D D - }; - -#undef W -#undef _ -#undef x -#undef o -#undef L -#undef G -#undef D +#define W 255, +#define x 252, +#define _ TRANS, +#define o 0, +#define L LGRAY, +#define G GRAY, +#define D DGRAY, + +static uint8 MCDesign0[]= { W W W W W W _ + W W W W W o _ + W W W W o _ _ + W W W W W _ _ + W W o W W W _ + W o _ o W W W + o _ _ _ o W W + _ _ _ _ _ o o }; + + +static uint8 MCDesign1[]= { _ }; + + + +static uint8 SLDesign[] = { G G G G G G G G G _ _ _ _ _ _ + L G G G G G G G G D _ _ _ _ _ + _ L G G G G G G G D _ _ _ _ _ + _ _ L G G G G G G G D _ _ _ _ + _ _ _ L G G G G G G D _ _ _ _ + _ _ _ _ L G G G G G D _ _ _ _ + _ _ _ _ _ L G G G G G D _ _ _ + _ _ _ _ _ _ L G G G G D _ _ _ + _ _ _ _ _ _ _ L G G G D _ _ _ + _ _ _ _ _ _ _ _ L G G G D _ _ + _ _ _ _ _ _ _ _ _ L G G D _ _ + _ _ _ _ _ _ _ _ _ _ L G D _ _ + _ _ _ _ _ _ _ _ _ _ _ L G D _ + _ _ _ _ _ _ _ _ _ _ _ _ L D _ + _ _ _ _ _ _ _ _ _ _ _ _ _ L D + _ _ _ _ _ _ _ _ _ _ _ _ _ _ D + }; + +static uint8 SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G + _ _ _ _ _ L G G G G G G G G D + _ _ _ _ _ L G G G G G G G D _ + _ _ _ _ L G G G G G G G D _ _ + _ _ _ _ L G G G G G G D _ _ _ + _ _ _ _ L G G G G G D _ _ _ _ + _ _ _ L G G G G G D _ _ _ _ _ + _ _ _ L G G G G D _ _ _ _ _ _ + _ _ _ L G G G D _ _ _ _ _ _ _ + _ _ L G G G D _ _ _ _ _ _ _ _ + _ _ L G G D _ _ _ _ _ _ _ _ _ + _ _ L G D _ _ _ _ _ _ _ _ _ _ + _ L G D _ _ _ _ _ _ _ _ _ _ _ + _ L D _ _ _ _ _ _ _ _ _ _ _ _ + L D _ _ _ _ _ _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ _ _ _ _ _ _ + }; + +static uint8 MapBrick[] = { L L L L L L L G + L G G G G G G D + L G G G G G G D + G D D D D D D D + }; + +#undef W +#undef _ +#undef x +#undef o +#undef L +#undef G +#undef D #if 0 -#define _ TRANS, -#define A 213, -#define B 207, -#define C 225, -#define D 219, -#define E 231, - -static uint8 PRDesign[] = { A E E E C C D A B - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - B A A A A A A A B - B B B B B B B B B - }; +#define _ TRANS, +#define A 213, +#define B 207, +#define C 225, +#define D 219, +#define E 231, + +static uint8 PRDesign[] = { A E E E C C D A B + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + C _ _ _ _ _ _ D A + B A A A A A A A B + B B B B B B B B B + }; #else -#define _ TRANS, -#define A 213, -#define B 207, -#define C 225, // DGRAY -#define D 219, -#define E 231, -#define F 237, - -static uint8 PRDesign[] = { D D D D D D D D _ - D D D D D D D D _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ C _ - D C C C C C C C _ - _ _ _ _ _ _ _ _ _ - }; +#define _ TRANS, +#define A 213, +#define B 207, +#define C 225, // DGRAY +#define D 219, +#define E 231, +#define F 237, + +static uint8 PRDesign[] = { D D D D D D D D _ + D D D D D D D D _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ _ _ + D _ _ _ _ _ _ C _ + D C C C C C C C _ + _ _ _ _ _ _ _ _ _ + }; #endif -#undef _ -#undef A -#undef B -#undef C -#undef D -#undef E +#undef _ +#undef A +#undef B +#undef C +#undef D +#undef E -#define _ 0x00, -#define x 0xFF, -#define A _ x _ x _ x _ x -#define B A A A A A A A A +#define _ 0x00, +#define x 0xFF, +#define A _ x _ x _ x _ x +#define B A A A A A A A A -static uint8 HLDesign[] = { B B B B B }; +static uint8 HLDesign[] = { B B B B B }; -#undef _ -#undef x -#undef A -#undef B +#undef _ +#undef x +#undef A +#undef B // 228 yellow @@ -172,74 +172,93 @@ static uint8 HLDesign[] = { B B B B B }; // 226 light green // 221 blue -#define A 208, -#define B 214, -#define C 220, -#define D 226, -#define E 255, +#define A 208, +#define B 214, +#define C 220, +#define D 226, +#define E 255, -static uint8 LIDesign[][9] = { { A A A - A B A - A A A }, +static uint8 LIDesign[][9] = { { A A A + A B A + A A A }, - { A B A - B C B - A B A }, + { A B A + B C B + A B A }, - { B C B - C D C - B C B }, + { B C B + C D C + B C B }, - { C D C - D E D - C D C }, - }; + { C D C + D E D + C D C }, + }; -#undef A -#undef B -#undef C -#undef D -#undef E +#undef A +#undef B +#undef C +#undef D +#undef E -#define R 211, -#define G 0, +#define R 211, +#define G 0, //226, -static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 - { R R R R R R R R G }, // 1 - { R R R R R R R G G }, // 2 - { R R R R R R G G G }, // 3 - { R R R R R G G G G }, // 4 - { R R R R G G G G G }, // 5 - { R R R G G G G G G }, // 6 - { R R G G G G G G G }, // 7 - { R G G G G G G G G }, // 8 - { G G G G G G G G G }, // 9 - }; - -#undef R -#undef G +static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 + { R R R R R R R R G }, // 1 + { R R R R R R R G G }, // 2 + { R R R R R R G G G }, // 3 + { R R R R R G G G G }, // 4 + { R R R R G G G G G }, // 5 + { R R R G G G G G G }, // 6 + { R R G G G G G G G }, // 7 + { R G G G G G G G G }, // 8 + { G G G G G G G G G }, // 9 + }; + +#undef R +#undef G */ namespace CGE { #ifdef DEBUG - BMP_PTR MB[] = { new BITMAP("BRICK"), NULL }; - BMP_PTR HL[] = { new BITMAP("HLINE"), NULL }; +BMP_PTR MB[] = { + new BITMAP("BRICK"), + NULL +}; + +BMP_PTR HL[] = { + new BITMAP("HLINE"), + NULL +}; #endif - BMP_PTR MC[] = { new BITMAP("MOUSE"), - new BITMAP("DUMMY"), - NULL }; - BMP_PTR PR[] = { new BITMAP("PRESS"), NULL }; - BMP_PTR SP[] = { new BITMAP("SPK_L"), - new BITMAP("SPK_R"), - NULL }; - BMP_PTR LI[] = { new BITMAP("LITE0"), - new BITMAP("LITE1"), - new BITMAP("LITE2"), - new BITMAP("LITE3"), - NULL }; +BMP_PTR MC[] = { + new BITMAP("MOUSE"), + new BITMAP("DUMMY"), + NULL +}; + +BMP_PTR PR[] = { + new BITMAP("PRESS"), + NULL +}; + +BMP_PTR SP[] = { + new BITMAP("SPK_L"), + new BITMAP("SPK_R"), + NULL +}; + +BMP_PTR LI[] = { + new BITMAP("LITE0"), + new BITMAP("LITE1"), + new BITMAP("LITE2"), + new BITMAP("LITE3"), + NULL +}; } // End of namespace CGE diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h index 3ca2bababd..5023c2e657 100644 --- a/engines/cge/bitmaps.h +++ b/engines/cge/bitmaps.h @@ -25,22 +25,22 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __BITMAPS__ -#define __BITMAPS__ +#ifndef __BITMAPS__ +#define __BITMAPS__ -#include "cge/vga13h.h" +#include "cge/vga13h.h" namespace CGE { #ifdef DEBUG - extern BITMAP * MB[]; - extern BITMAP * HL[]; +extern BITMAP *MB[]; +extern BITMAP *HL[]; #endif -extern BITMAP * MC[]; -extern BITMAP * PR[]; -extern BITMAP * SP[]; -extern BITMAP * LI[]; +extern BITMAP *MC[]; +extern BITMAP *PR[]; +extern BITMAP *SP[]; +extern BITMAP *LI[]; } // End of namespace CGE diff --git a/engines/cge/boot.h b/engines/cge/boot.h index bc78b0e7fb..ab4dcde0e2 100644 --- a/engines/cge/boot.h +++ b/engines/cge/boot.h @@ -25,54 +25,54 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __BOOT__ -#define __BOOT__ +#ifndef __BOOT__ +#define __BOOT__ -#include "cge/jbw.h" +#include "cge/jbw.h" namespace CGE { -#define BOOTSECT_SIZ 512 -#define BOOTHEAD_SIZ 62 -#define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ -#define FreeBoot(b) free(b) +#define BOOTSECT_SIZ 512 +#define BOOTHEAD_SIZ 62 +#define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ +#define FreeBoot(b) free(b) -#ifndef EC - #define EC +#ifndef EC +#define EC #endif typedef struct { - uint8 Jmp[3]; // NEAR jump machine code - char OEM_ID[8]; // OEM name and version - uint16 SectSize; // bytes per sector - uint8 ClustSize; // sectors per cluster - uint16 ResSecs; // sectors before 1st FAT - uint8 FatCnt; // number of FATs - uint16 RootSize; // root directory entries - uint16 TotSecs; // total sectors on disk - uint8 Media; // media descriptor byte - uint16 FatSize; // sectors per FAT - uint16 TrkSecs; // sectors per track - uint16 HeadCnt; // number of sufraces - uint16 HidnSecs; // special hidden sectors - uint16 _; // (unknown: reserved?) - uint32 lTotSecs; // total number of sectors - uint16 DriveNum; // physical drive number - uint8 XSign; // extended boot signature - uint32 Serial; // volume serial number - char Label[11]; // volume label - char FileSysID[8]; // file system ID - char Code[BOOTCODE_SIZ-8]; // 8 = length of following - uint32 Secret; // long secret number - uint8 BootCheck; // boot sector checksum - uint8 BootFlags; // secret flags - uint16 BootSig; // boot signature 0xAA55 - } Boot; + uint8 Jmp[3]; // NEAR jump machine code + char OEM_ID[8]; // OEM name and version + uint16 SectSize; // bytes per sector + uint8 ClustSize; // sectors per cluster + uint16 ResSecs; // sectors before 1st FAT + uint8 FatCnt; // number of FATs + uint16 RootSize; // root directory entries + uint16 TotSecs; // total sectors on disk + uint8 Media; // media descriptor byte + uint16 FatSize; // sectors per FAT + uint16 TrkSecs; // sectors per track + uint16 HeadCnt; // number of sufraces + uint16 HidnSecs; // special hidden sectors + uint16 _; // (unknown: reserved?) + uint32 lTotSecs; // total number of sectors + uint16 DriveNum; // physical drive number + uint8 XSign; // extended boot signature + uint32 Serial; // volume serial number + char Label[11]; // volume label + char FileSysID[8]; // file system ID + char Code[BOOTCODE_SIZ - 8]; // 8 = length of following + uint32 Secret; // long secret number + uint8 BootCheck; // boot sector checksum + uint8 BootFlags; // secret flags + uint16 BootSig; // boot signature 0xAA55 +} Boot; -EC Boot * ReadBoot (int drive); -EC uint8 CheckBoot (Boot * boot); -EC bool WriteBoot (int drive, Boot * boot); +EC Boot *ReadBoot(int drive); +EC uint8 CheckBoot(Boot *boot); +EC bool WriteBoot(int drive, Boot *boot); } // End of namespace CGE diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 7c61157eba..b5e59e0988 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -25,173 +25,125 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/btfile.h" -//#include +#include "cge/btfile.h" #include "common/system.h" #include "common/str.h" -#include +#include namespace CGE { -#ifndef BT_SIZE - #define BT_SIZE K(1) +#ifndef BT_SIZE +#define BT_SIZE K(1) #endif -#ifndef BT_KEYLEN - #define BT_KEYLEN 13 +#ifndef BT_KEYLEN +#define BT_KEYLEN 13 #endif - - - - -BTFILE::BTFILE (const char * name, IOMODE mode, CRYPT * crpt) -: IOHAND(name, mode, crpt) -{ - int i; - for (i = 0; i < BT_LEVELS; i ++) - { - Buff[i].Page = new BT_PAGE; - Buff[i].PgNo = BT_NONE; - Buff[i].Indx = -1; - Buff[i].Updt = FALSE; - if (Buff[i].Page == NULL) - error("No core"); - } +BTFILE::BTFILE(const char *name, IOMODE mode, CRYPT *crpt) + : IOHAND(name, mode, crpt) { + for (int i = 0; i < BT_LEVELS; i ++) { + Buff[i].Page = new BT_PAGE; + Buff[i].PgNo = BT_NONE; + Buff[i].Indx = -1; + Buff[i].Updt = FALSE; + if (Buff[i].Page == NULL) + error("No core"); + } } - - - - - - - -BTFILE::~BTFILE (void) -{ - int i; - for (i = 0; i < BT_LEVELS; i ++) - { - PutPage(i); - delete Buff[i].Page; - } +BTFILE::~BTFILE(void) { + for (int i = 0; i < BT_LEVELS; i ++) { + PutPage(i); + delete Buff[i].Page; + } } - - - - -void BTFILE::PutPage (int lev, bool hard) -{ - if (hard || Buff[lev].Updt) - { - Seek(Buff[lev].PgNo * sizeof(BT_PAGE)); - Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); - Buff[lev].Updt = FALSE; - } +void BTFILE::PutPage(int lev, bool hard) { + if (hard || Buff[lev].Updt) { + Seek(Buff[lev].PgNo * sizeof(BT_PAGE)); + Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); + Buff[lev].Updt = FALSE; + } } - - - - -BT_PAGE * BTFILE::GetPage (int lev, uint16 pgn) -{ - if (Buff[lev].PgNo != pgn) - { - uint32 pos = pgn * sizeof(BT_PAGE); - PutPage(lev); - Buff[lev].PgNo = pgn; - if (Size() > pos) - { - Seek((uint32) pgn * sizeof(BT_PAGE)); - Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); - Buff[lev].Updt = FALSE; +BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) { + if (Buff[lev].PgNo != pgn) { + uint32 pos = pgn * sizeof(BT_PAGE); + PutPage(lev); + Buff[lev].PgNo = pgn; + if (Size() > pos) { + Seek((uint32) pgn * sizeof(BT_PAGE)); + Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); + Buff[lev].Updt = FALSE; + } else { + Buff[lev].Page->Hea.Count = 0; + Buff[lev].Page->Hea.Down = BT_NONE; + memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data)); + Buff[lev].Updt = TRUE; + } + Buff[lev].Indx = -1; } - else - { - Buff[lev].Page->Hea.Count = 0; - Buff[lev].Page->Hea.Down = BT_NONE; - memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data)); - Buff[lev].Updt = TRUE; - } - Buff[lev].Indx = -1; - } - return Buff[lev].Page; + return Buff[lev].Page; } - - - -BT_KEYPACK * BTFILE::Find (const char * key) -{ - int lev = 0; - uint16 nxt = BT_ROOT; - while (! Error) - { - BT_PAGE * pg = GetPage(lev, nxt); - // search - if (pg->Hea.Down != BT_NONE) - { - int i; - for (i = 0; i < pg->Hea.Count; i ++) - if (memicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) - break; - nxt = (i) ? pg->Inn[i-1].Down : pg->Hea.Down; - Buff[lev].Indx = i-1; - ++ lev; +BT_KEYPACK *BTFILE::Find(const char *key) { + int lev = 0; + uint16 nxt = BT_ROOT; + while (! Error) { + BT_PAGE *pg = GetPage(lev, nxt); + // search + if (pg->Hea.Down != BT_NONE) { + int i; + for (i = 0; i < pg->Hea.Count; i ++) + if (memicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) + break; + nxt = (i) ? pg->Inn[i - 1].Down : pg->Hea.Down; + Buff[lev].Indx = i - 1; + ++ lev; + } else { + int i; + for (i = 0; i < pg->Hea.Count - 1; i ++) + if (scumm_stricmp((const char *)key, (const char *)pg->Lea[i].Key) <= 0) + break; + Buff[lev].Indx = i; + return &pg->Lea[i]; + } } - else - { - int i; - for (i = 0; i < pg->Hea.Count-1; i ++) - if (scumm_stricmp((const char*)key, (const char*)pg->Lea[i].Key) <= 0) - break; - Buff[lev].Indx = i; - return &pg->Lea[i]; - } - } - return NULL; + return NULL; } - - -int keycomp (const void * k1, const void * k2) -{ - return memicmp(k1, k2, BT_KEYLEN); +int keycomp(const void *k1, const void *k2) { + return memicmp(k1, k2, BT_KEYLEN); } - -void BTFILE::Make(BT_KEYPACK * keypack, uint16 count) -{ - #if BT_LEVELS != 2 - #error This tiny BTREE implementation works with exactly 2 levels! - #endif - _fqsort(keypack, count, sizeof(*keypack), keycomp); - uint16 n = 0; - BT_PAGE * Root = GetPage(0, n ++), - * Leaf = GetPage(1, n); - Root->Hea.Down = n; - PutPage(0, TRUE); - while (count --) - { - if (Leaf->Hea.Count >= ArrayCount(Leaf->Lea)) - { - PutPage(1, TRUE); // save filled page - Leaf = GetPage(1, ++n); // take empty page - memcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); - Root->Inn[Root->Hea.Count ++].Down = n; - Buff[0].Updt = TRUE; +void BTFILE::Make(BT_KEYPACK *keypack, uint16 count) { +#if BT_LEVELS != 2 +#error This tiny BTREE implementation works with exactly 2 levels! +#endif + _fqsort(keypack, count, sizeof(*keypack), keycomp); + uint16 n = 0; + BT_PAGE *Root = GetPage(0, n++), + *Leaf = GetPage(1, n); + Root->Hea.Down = n; + PutPage(0, TRUE); + while (count --) { + if (Leaf->Hea.Count >= ArrayCount(Leaf->Lea)) { + PutPage(1, TRUE); // save filled page + Leaf = GetPage(1, ++n); // take empty page + memcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); + Root->Inn[Root->Hea.Count ++].Down = n; + Buff[0].Updt = TRUE; + } + Leaf->Lea[Leaf->Hea.Count ++] = * (keypack ++); + Buff[1].Updt = TRUE; } - Leaf->Lea[Leaf->Hea.Count ++] = * (keypack ++); - Buff[1].Updt = TRUE; - } } } // End of namespace CGE diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 0df9636573..c55891cae4 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -25,73 +25,62 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __BTFILE__ -#define __BTFILE__ +#ifndef __BTFILE__ +#define __BTFILE__ -#include "cge/general.h" +#include "cge/general.h" namespace CGE { -#define BT_SIZE K(1) -#define BT_KEYLEN 13 -#define BT_LEVELS 2 +#define BT_SIZE K(1) +#define BT_KEYLEN 13 +#define BT_LEVELS 2 -#define BT_NONE 0xFFFF -#define BT_ROOT 0 +#define BT_NONE 0xFFFF +#define BT_ROOT 0 -struct BT_KEYPACK -{ - char Key[BT_KEYLEN]; - uint32 Mark; - uint16 Size; +struct BT_KEYPACK { + char Key[BT_KEYLEN]; + uint32 Mark; + uint16 Size; }; - -struct BT_PAGE -{ - struct HEA - { - uint16 Count; - uint16 Down; - } Hea; - union - { - // dummy filler to make proper size of union - uint8 Data[BT_SIZE-sizeof(HEA)]; - // inner version of data: key + word-sized page link - struct INNER - { - uint8 Key[BT_KEYLEN]; - uint16 Down; - } Inn[(BT_SIZE-sizeof(HEA))/sizeof(INNER)]; - // leaf version of data: key + all user data - BT_KEYPACK Lea[(BT_SIZE-sizeof(HEA))/sizeof(BT_KEYPACK)]; - }; +struct BT_PAGE { + struct HEA { + uint16 Count; + uint16 Down; + } Hea; + union { + // dummy filler to make proper size of union + uint8 Data[BT_SIZE - sizeof(HEA)]; + // inner version of data: key + word-sized page link + struct INNER { + uint8 Key[BT_KEYLEN]; + uint16 Down; + } Inn[(BT_SIZE - sizeof(HEA)) / sizeof(INNER)]; + // leaf version of data: key + all user data + BT_KEYPACK Lea[(BT_SIZE - sizeof(HEA)) / sizeof(BT_KEYPACK)]; + }; }; - - - -class BTFILE : public IOHAND -{ - struct - { - BT_PAGE * Page; - uint16 PgNo; - int Indx; - bool Updt; - } Buff[BT_LEVELS]; - void PutPage (int lev, bool hard = FALSE); - BT_PAGE * GetPage (int lev, uint16 pgn); +class BTFILE : public IOHAND { + struct { + BT_PAGE *Page; + uint16 PgNo; + int Indx; + bool Updt; + } Buff[BT_LEVELS]; + void PutPage(int lev, bool hard = FALSE); + BT_PAGE *GetPage(int lev, uint16 pgn); public: - BTFILE (const char * name, IOMODE mode = REA, CRYPT * crpt = NULL); - virtual ~BTFILE (void); - BT_KEYPACK * Find(const char * key); - BT_KEYPACK * Next(void); - void Make(BT_KEYPACK * keypack, uint16 count); + BTFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); + virtual ~BTFILE(void); + BT_KEYPACK *Find(const char *key); + BT_KEYPACK *Next(void); + void Make(BT_KEYPACK *keypack, uint16 count); }; } // End of namespace CGE diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index fdbd6ad315..7c4f689e30 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -25,334 +25,239 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/cfile.h" -#include -#include -#include +#include "cge/cfile.h" +#include +#include +#include #include "common/system.h" namespace CGE { -IOBUF::IOBUF (IOMODE mode, CRYPT * crpt) -: IOHAND(mode, crpt), - BufMark(0), - Ptr(0), - Lim(0) -{ - Buff = farnew(uint8, IOBUF_SIZE); - if (Buff == NULL) - error("No core for I/O"); +IOBUF::IOBUF(IOMODE mode, CRYPT *crpt) + : IOHAND(mode, crpt), + BufMark(0), + Ptr(0), + Lim(0) { + Buff = farnew(uint8, IOBUF_SIZE); + if (Buff == NULL) + error("No core for I/O"); } - - - - - - - -IOBUF::IOBUF (const char * name, IOMODE mode, CRYPT * crpt) -: IOHAND(name, mode, crpt), - BufMark(0), - Ptr(0), - Lim(0) -{ - Buff = farnew(uint8, IOBUF_SIZE); - if (Buff == NULL) - error("No core for I/O [%s]", name); +IOBUF::IOBUF(const char *name, IOMODE mode, CRYPT *crpt) + : IOHAND(name, mode, crpt), + BufMark(0), + Ptr(0), + Lim(0) { + Buff = farnew(uint8, IOBUF_SIZE); + if (Buff == NULL) + error("No core for I/O [%s]", name); } - - - - - - - - -IOBUF::~IOBUF (void) -{ - if (Mode > REA) WriteBuff(); - if (Buff) free(Buff); +IOBUF::~IOBUF(void) { + if (Mode > REA) + WriteBuff(); + if (Buff) + free(Buff); } - - - - -void IOBUF::ReadBuff (void) -{ - BufMark = IOHAND::Mark(); - Lim = IOHAND::Read(Buff, IOBUF_SIZE); - Ptr = 0; +void IOBUF::ReadBuff(void) { + BufMark = IOHAND::Mark(); + Lim = IOHAND::Read(Buff, IOBUF_SIZE); + Ptr = 0; } - - - -void IOBUF::WriteBuff (void) -{ - if (Lim) - { - IOHAND::Write(Buff, Lim); - BufMark = IOHAND::Mark(); - Lim = 0; - } +void IOBUF::WriteBuff(void) { + if (Lim) { + IOHAND::Write(Buff, Lim); + BufMark = IOHAND::Mark(); + Lim = 0; + } } - - - -uint16 IOBUF::Read (void *buf, uint16 len) -{ - uint16 total = 0; - while (len) - { - if (Ptr >= Lim) ReadBuff(); - uint16 n = Lim - Ptr; - if (n) - { - if (len < n) n = len; - memcpy(buf, Buff+Ptr, n); - buf = (uint8 *)buf + n; - len -= n; - total += n; - Ptr += n; +uint16 IOBUF::Read(void *buf, uint16 len) { + uint16 total = 0; + while (len) { + if (Ptr >= Lim) + ReadBuff(); + uint16 n = Lim - Ptr; + if (n) { + if (len < n) + n = len; + memcpy(buf, Buff + Ptr, n); + buf = (uint8 *)buf + n; + len -= n; + total += n; + Ptr += n; + } else + break; } - else break; - } - return total; + return total; } - - - - -uint16 IOBUF::Read (uint8 * buf) -{ - uint16 total = 0; - - while (total < LINE_MAX-2) - { - if (Ptr >= Lim) ReadBuff(); - uint8 * p = Buff + Ptr; - uint16 n = Lim - Ptr; - if (n) - { - if (total + n >= LINE_MAX-2) n = LINE_MAX-2 - total; - uint8 * eol = (uint8 *) memchr(p, '\r', n); - if (eol) n = (uint16) (eol - p); - uint8 * eof = (uint8 *) memchr(p, '\32', n); - if (eof) // end-of-file - { - n = (uint16) (eof - p); - Ptr = (uint16) (eof - Buff); - } - if (n) memcpy(buf, p, n); - buf += n; - total += n; - if (eof) break; - Ptr += n; - if (eol) - { - ++ Ptr; - * (buf ++) = '\n'; - ++ total; - if (Ptr >= Lim) ReadBuff(); - if (Ptr < Lim) if (Buff[Ptr] == '\n') ++ Ptr; - break; - } +uint16 IOBUF::Read(uint8 *buf) { + uint16 total = 0; + + while (total < LINE_MAX - 2) { + if (Ptr >= Lim) + ReadBuff(); + uint8 *p = Buff + Ptr; + uint16 n = Lim - Ptr; + if (n) { + if (total + n >= LINE_MAX - 2) + n = LINE_MAX - 2 - total; + uint8 *eol = (uint8 *) memchr(p, '\r', n); + if (eol) + n = (uint16)(eol - p); + uint8 *eof = (uint8 *) memchr(p, '\32', n); + if (eof) { // end-of-file + n = (uint16)(eof - p); + Ptr = (uint16)(eof - Buff); + } + if (n) + memcpy(buf, p, n); + buf += n; + total += n; + if (eof) + break; + Ptr += n; + if (eol) { + ++ Ptr; + * (buf ++) = '\n'; + ++ total; + if (Ptr >= Lim) + ReadBuff(); + if (Ptr < Lim) + if (Buff[Ptr] == '\n') + ++Ptr; + break; + } + } else + break; } - else break; - } - *buf = '\0'; - return total; + *buf = '\0'; + return total; } - - - - - -uint16 IOBUF::Write (void * buf, uint16 len) -{ - uint16 tot = 0; - while (len) - { - uint16 n = IOBUF_SIZE - Lim; - if (n > len) n = len; - if (n) - { - memcpy(Buff+Lim, buf, n); - Lim += n; - len -= n; - buf = (uint8 *)buf + n; - tot += n; +uint16 IOBUF::Write(void *buf, uint16 len) { + uint16 tot = 0; + while (len) { + uint16 n = IOBUF_SIZE - Lim; + if (n > len) + n = len; + if (n) { + memcpy(Buff + Lim, buf, n); + Lim += n; + len -= n; + buf = (uint8 *)buf + n; + tot += n; + } else + WriteBuff(); } - else WriteBuff(); - } - return tot; + return tot; } - - - - -uint16 IOBUF::Write (uint8 * buf) -{ - uint16 len = 0; - if (buf) - { - len = strlen((const char *) buf); - if (len) if (buf[len-1] == '\n') -- len; - len = Write(buf, len); - if (len) - { - static char EOL[] = "\r\n"; - uint16 n = Write(EOL, sizeof(EOL)-1); - len += n; +uint16 IOBUF::Write(uint8 *buf) { + uint16 len = 0; + if (buf) { + len = strlen((const char *) buf); + if (len) + if (buf[len - 1] == '\n') + --len; + len = Write(buf, len); + if (len) { + static char EOL[] = "\r\n"; + uint16 n = Write(EOL, sizeof(EOL) - 1); + len += n; + } } - } - return len; + return len; } - - - - -int IOBUF::Read (void) -{ - if (Ptr >= Lim) - { - ReadBuff(); - if (Lim == 0) return -1; - } - return Buff[Ptr ++]; +int IOBUF::Read(void) { + if (Ptr >= Lim) { + ReadBuff(); + if (Lim == 0) + return -1; + } + return Buff[Ptr ++]; } - - - - -void IOBUF::Write (uint8 b) -{ - if (Lim >= IOBUF_SIZE) - { - WriteBuff(); - } - Buff[Lim ++] = b; +void IOBUF::Write(uint8 b) { + if (Lim >= IOBUF_SIZE) + WriteBuff(); + Buff[Lim ++] = b; } +uint16 CFILE::MaxLineLen = LINE_MAX; - - - uint16 CFILE::MaxLineLen = LINE_MAX; - - - - - - - - -CFILE::CFILE (const char * name, IOMODE mode, CRYPT * crpt) -: IOBUF(name, mode, crpt) -{ +CFILE::CFILE(const char *name, IOMODE mode, CRYPT *crpt) + : IOBUF(name, mode, crpt) { } - - - - - - - -CFILE::~CFILE (void) -{ +CFILE::~CFILE(void) { } +void CFILE::Flush(void) { + if (Mode > REA) + WriteBuff(); + else + Lim = 0; - - - -void CFILE::Flush (void) -{ - if (Mode > REA) WriteBuff(); - else Lim = 0; - - /* - _BX = Handle; - _AH = 0x68; // Flush buffer - asm int 0x21 - */ - warning("FIXME: CFILE::Flush"); + /* + _BX = Handle; + _AH = 0x68; // Flush buffer + asm int 0x21 + */ + warning("FIXME: CFILE::Flush"); } - - - -long CFILE::Mark (void) -{ - return BufMark + ((Mode > REA) ? Lim : Ptr); +long CFILE::Mark(void) { + return BufMark + ((Mode > REA) ? Lim : Ptr); } - - - -long CFILE::Seek (long pos) -{ - if (pos >= BufMark && pos < BufMark + Lim) - { - ((Mode == REA) ? Ptr : Lim) = (uint16) (pos - BufMark); - return pos; - } - else - { - if (Mode > REA) - { - WriteBuff(); +long CFILE::Seek(long pos) { + if (pos >= BufMark && pos < BufMark + Lim) { + ((Mode == REA) ? Ptr : Lim) = (uint16)(pos - BufMark); + return pos; + } else { + if (Mode > REA) + WriteBuff(); + else + Lim = 0; + + Ptr = 0; + return BufMark = IOHAND::Seek(pos); } - else - { - Lim = 0; - } - Ptr = 0; - return BufMark = IOHAND::Seek(pos); - } } - - - - -void CFILE::Append (CFILE& f) -{ - Seek(Size()); - if (f.Error == 0) - { - while (true) - { - if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) WriteBuff(); - else break; - if ((Error = f.Error) != 0) break; +void CFILE::Append(CFILE &f) { + Seek(Size()); + if (f.Error == 0) { + while (true) { + if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) + WriteBuff(); + else + break; + if ((Error = f.Error) != 0) + break; + } } - } } } // End of namespace CGE diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index e8d494c2f9..d2d5320ae5 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -25,59 +25,54 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CFILE__ -#define __CFILE__ +#ifndef __CFILE__ +#define __CFILE__ -#include "cge/general.h" -#include +#include "cge/general.h" +#include namespace CGE { -#define LINE_MAX 512 +#define LINE_MAX 512 -#ifndef IOBUF_SIZE - #define IOBUF_SIZE K(2) +#ifndef IOBUF_SIZE +#define IOBUF_SIZE K(2) #endif -#define CFREAD(x) Read((uint8 *)(x),sizeof(*(x))) +#define CFREAD(x) Read((uint8 *)(x),sizeof(*(x))) - - -class IOBUF : public IOHAND -{ +class IOBUF : public IOHAND { protected: - uint8 * Buff; - uint16 Ptr, Lim; - long BufMark; - uint16 Seed; - CRYPT * Crypt; - virtual void ReadBuff (void); - virtual void WriteBuff (void); + uint8 *Buff; + uint16 Ptr, Lim; + long BufMark; + uint16 Seed; + CRYPT *Crypt; + virtual void ReadBuff(void); + virtual void WriteBuff(void); public: - IOBUF (IOMODE mode, CRYPT * crpt = NULL); - IOBUF (const char * name, IOMODE mode, CRYPT * crpt = NULL); - virtual ~IOBUF (void); - uint16 Read (void * buf, uint16 len); - uint16 Read (uint8 * buf); - int Read (void); - uint16 Write (void * buf, uint16 len); - uint16 Write (uint8 * buf); - void Write (uint8 b); + IOBUF(IOMODE mode, CRYPT *crpt = NULL); + IOBUF(const char *name, IOMODE mode, CRYPT *crpt = NULL); + virtual ~IOBUF(void); + uint16 Read(void *buf, uint16 len); + uint16 Read(uint8 *buf); + int Read(void); + uint16 Write(void *buf, uint16 len); + uint16 Write(uint8 *buf); + void Write(uint8 b); }; - -class CFILE : public IOBUF -{ +class CFILE : public IOBUF { public: - static uint16 MaxLineLen; - CFILE (const char * name, IOMODE mode = REA, CRYPT * crpt = NULL); - virtual ~CFILE (void); - void Flush (void); - long Mark (void); - long Seek (long pos); - void Append (CFILE& f); + static uint16 MaxLineLen; + CFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); + virtual ~CFILE(void); + void Flush(void); + long Mark(void); + long Seek(long pos); + void Append(CFILE &f); }; } // End of namespace CGE diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 5613c3bb68..0d0df4ea9c 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -21,7 +21,6 @@ */ #include "common/scummsys.h" - #include "common/config-manager.h" #include "common/debug.h" #include "common/debug-channels.h" @@ -29,43 +28,41 @@ #include "common/EventRecorder.h" #include "common/file.h" #include "common/fs.h" - #include "engines/util.h" - #include "cge/cge.h" #include "cge/cge_main.h" - + namespace CGE { - + CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) - : Engine(syst), _gameDescription(gameDescription) { - + : Engine(syst), _gameDescription(gameDescription) { + DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); - _console = new CGEConsole(this); + _console = new CGEConsole(this); debug("CGEEngine::CGEEngine"); } - + CGEEngine::~CGEEngine() { debug("CGEEngine::~CGEEngine"); - + // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); } - + Common::Error CGEEngine::run() { // Initialize graphics using following: initGraphics(320, 200, false); - - // Create debugger console. It requires GFX to be initialized + + // Create debugger console. It requires GFX to be initialized _console = new CGEConsole(this); - + // Additional setup. debug("CGEEngine::init"); - + cge_main(); - + return Common::kNoError; } - + } // End of namespace CGE diff --git a/engines/cge/cge.h b/engines/cge/cge.h index cb2c507ffa..c6d9a099bf 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -22,7 +22,7 @@ #ifndef CGE_H #define CGE_H - + #include "common/random.h" #include "engines/engine.h" #include "gui/debugger.h" @@ -33,12 +33,12 @@ #define CGE_SAVEGAME_VERSION 1 namespace CGE { - + class Console; - + // our engine debug channels enum { - kCGEDebug = 1 << 0 + kCGEDebug = 1 << 0 }; class CGEEngine : public Engine { @@ -49,19 +49,21 @@ public: const ADGameDescription *_gameDescription; virtual Common::Error run(); - GUI::Debugger *getDebugger() { return _console; } - + GUI::Debugger *getDebugger() { + return _console; + } + private: CGEConsole *_console; }; - + // Example console class class Console : public GUI::Debugger { public: Console(CGEEngine *vm) {} virtual ~Console(void) {} }; - + } // End of namespace CGE - + #endif diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index cdbb94f785..62936e8c9c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -25,57 +25,57 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/general.h" -#include "cge/boot.h" -#include "cge/ident.h" -#include "cge/sound.h" -#include "cge/startup.h" -#include "cge/config.h" -#include "cge/vga13h.h" -#include "cge/snail.h" -#include "cge/text.h" -#include "cge/game.h" -#include "cge/mouse.h" -#include "cge/keybd.h" -#include "cge/cfile.h" -#include "cge/vol.h" -#include "cge/talk.h" -#include "cge/vmenu.h" -#include "cge/gettext.h" -#include "cge/mixer.h" -#include "cge/cge_main.h" -#include -#include -#include -#include -#include -#include -#include +#include "cge/general.h" +#include "cge/boot.h" +#include "cge/ident.h" +#include "cge/sound.h" +#include "cge/startup.h" +#include "cge/config.h" +#include "cge/vga13h.h" +#include "cge/snail.h" +#include "cge/text.h" +#include "cge/game.h" +#include "cge/mouse.h" +#include "cge/keybd.h" +#include "cge/cfile.h" +#include "cge/vol.h" +#include "cge/talk.h" +#include "cge/vmenu.h" +#include "cge/gettext.h" +#include "cge/mixer.h" +#include "cge/cge_main.h" +#include +#include +#include +#include +#include +#include +#include #include "common/str.h" namespace CGE { -#define STACK_SIZ (K(2)) -#define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText) +#define STACK_SIZ (K(2)) +#define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText) -#ifdef DEMO - #ifdef DEBUG - #define SVG0NAME ("{{INIT}}" SVG_EXT) - #else - #define SVG0NAME (ProgName(SVG_EXT)) - #endif +#ifdef DEMO +#ifdef DEBUG +#define SVG0NAME ("{{INIT}}" SVG_EXT) +#else +#define SVG0NAME (ProgName(SVG_EXT)) +#endif #else - #define SVG0NAME ("{{INIT}}" SVG_EXT) +#define SVG0NAME ("{{INIT}}" SVG_EXT) #endif -#ifdef DEBUG - #define SVG0FILE CFILE +#ifdef DEBUG +#define SVG0FILE CFILE #else - #define SVG0FILE INI_FILE +#define SVG0FILE INI_FILE #endif -extern uint16 _stklen = (STACK_SIZ * 2); +extern uint16 _stklen = (STACK_SIZ * 2); // 0.75 - 17II95 - full sound support // 0.76 - 18II95 - small MiniEMS in DEMO, @@ -86,2166 +86,1817 @@ extern uint16 _stklen = (STACK_SIZ * 2); // coditionals EVA for 2-month evaluation version /* - char Copr[] = "Common Game Engine " - #ifdef EVA - "ú" - #else - #ifdef CD - "ù" - #else - " " - #endif - #endif - " version 1.05 [" - #if sizeof(INI_FILE) == sizeof(VFILE) - "I" - #else - "i" - #endif - #if sizeof(PIC_FILE) == sizeof(VFILE) - "B" - #else - "b" - #endif - "]\n" - "Copyright (c) 1994 by Janusz B. Wi$niewski"; + char Copr[] = "Common Game Engine " + #ifdef EVA + "ú" + #else + #ifdef CD + "ù" + #else + " " + #endif + #endif + " version 1.05 [" + #if sizeof(INI_FILE) == sizeof(VFILE) + "I" + #else + "i" + #endif + #if sizeof(PIC_FILE) == sizeof(VFILE) + "B" + #else + "b" + #endif + "]\n" + "Copyright (c) 1994 by Janusz B. Wi$niewski"; */ - char Copr[] = "To be fixed - Copr[]"; +char Copr[] = "To be fixed - Copr[]"; -static char UsrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; -static int OldLev = 0; -static int DemoText = DEMO_TEXT; +static char UsrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; +static int OldLev = 0; +static int DemoText = DEMO_TEXT; //-------------------------------------------------------------------------- - bool JBW = false; - DAC *SysPal = farnew(DAC, PAL_CNT); +bool JBW = false; +DAC *SysPal = farnew(DAC, PAL_CNT); //------------------------------------------------------------------------- - SPRITE PocLight = LI; - SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, }; - int PocPtr = 0; -//------------------------------------------------------------------------- -//extern SPRITE * PocLight; -//extern SPRITE * Pocket[]; -//extern int PocPtr; -//------------------------------------------------------------------------- +SPRITE PocLight = LI; +SPRITE *Pocket[POCKET_NX] = { NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + }; +int PocPtr = 0; - MOUSE Mouse; -static SPRITE * Sprite = NULL; -static SPRITE * MiniCave = NULL; -static SPRITE * Shadow = NULL; +MOUSE Mouse; +static SPRITE *Sprite = NULL; +static SPRITE *MiniCave = NULL; +static SPRITE *Shadow = NULL; -static VGA Vga = M13H; -static EMS * Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE); -static BMP_PTR * MiniShpList = NULL; -static BMP_PTR MiniShp[] = { NULL, NULL }; -static KEYBOARD Keyboard; -static bool Finis = false; -static int Startup = 1; -static int OffUseCount = atoi(Text[OFF_USE_COUNT]); - uint16 *intStackPtr = false; +static VGA Vga = M13H; +static EMS *Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE); +static BMP_PTR *MiniShpList = NULL; +static BMP_PTR MiniShp[] = { NULL, NULL }; +static KEYBOARD Keyboard; +static bool Finis = false; +static int Startup = 1; +static int OffUseCount = atoi(Text[OFF_USE_COUNT]); +uint16 *intStackPtr = false; - HXY HeroXY[CAVE_MAX] = {{0,0}}; - BAR Barriers[1+CAVE_MAX] = { { 0xFF, 0xFF } }; +HXY HeroXY[CAVE_MAX] = {{0, 0}}; +BAR Barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; -extern int FindPocket (SPRITE *); +extern int FindPocket(SPRITE *); -extern DAC StdPal[58]; +extern DAC StdPal[58]; -#ifdef DEBUG -static SPRITE HorzLine = HL; +#ifdef DEBUG +static SPRITE HorzLine = HL; #endif +void FeedSnail(SPRITE *spr, SNLIST snq); // defined in SNAIL +uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; -void FeedSnail (SPRITE * spr, SNLIST snq); // defined in SNAIL - -//-------------------------------------------------------------------------- - - - - -uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; - - - -uint8 & CLUSTER::Cell (void) -{ - return Map[B][A]; +uint8 &CLUSTER::Cell(void) { + return Map[B][A]; } +bool CLUSTER::Protected(void) { +/* + if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) + return true; + _DX = (MAP_ZCNT << 8) + MAP_XCNT; + _BX = (uint16) this; + asm mov ax,1 + asm mov cl,[bx].(COUPLE)A + asm mov ch,[bx].(COUPLE)B + asm test cx,0x8080 // (A < 0) || (B < 0) + asm jnz xit + asm cmp cl,dl + asm jge xit + asm cmp ch,dh + asm jge xit + // if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true; + asm mov al,dl + asm mul ch + asm xor ch,ch + asm add ax,cx + asm mov bx,ax + _BX += (uint16) Map; + //asm add bx,offset CLUSTER::Map + asm mov al,[bx] + asm and ax,0xFF + asm jz xit + asm mov ax,1 -bool CLUSTER::Protected (void) -{ - if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return true; - warning("STUB: CLUSTER::Protected()"); - /* - _DX = (MAP_ZCNT << 8) + MAP_XCNT; - _BX = (uint16) this; - - asm mov ax,1 - asm mov cl,[bx].(COUPLE)A - asm mov ch,[bx].(COUPLE)B - asm test cx,0x8080 // (A < 0) || (B < 0) - asm jnz xit - - asm cmp cl,dl - asm jge xit - asm cmp ch,dh - asm jge xit - -// if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true; - - asm mov al,dl - asm mul ch - asm xor ch,ch - asm add ax,cx - asm mov bx,ax - _BX += (uint16) Map; - //asm add bx,offset CLUSTER::Map - asm mov al,[bx] - asm and ax,0xFF - asm jz xit - asm mov ax,1 + // return Map[B][A] != 0; -// return Map[B][A] != 0; + xit: return _AX; + */ - xit: return _AX; - */ - return TRUE; + warning("STUB: CLUSTER::Protected()"); + return TRUE; } +CLUSTER XZ(int x, int y) { + if (y < MAP_TOP) + y = MAP_TOP; + if (y > MAP_TOP + MAP_HIG - MAP_ZGRID) + y = MAP_TOP + MAP_HIG - MAP_ZGRID; - -CLUSTER XZ (int x, int y) -{ - if (y < MAP_TOP) y = MAP_TOP; - if (y > MAP_TOP + MAP_HIG - MAP_ZGRID) y = MAP_TOP + MAP_HIG - MAP_ZGRID; - return CLUSTER(x / MAP_XGRID, (y-MAP_TOP) / MAP_ZGRID); + return CLUSTER(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID); } - - -CLUSTER XZ (COUPLE xy) -{ - signed char x, y; - xy.Split(x, y); - return XZ(x, y); +CLUSTER XZ(COUPLE xy) { + signed char x, y; + xy.Split(x, y); + return XZ(x, y); } +int pocref[POCKET_NX]; +uint8 volume[2]; +struct SAVTAB { + void *Ptr; + int Len; + uint8 Flg; +} SavTab[] = { + { &Now, sizeof(Now), 1 }, + { &OldLev, sizeof(OldLev), 1 }, + { &DemoText, sizeof(DemoText), 1 }, + { &Game, sizeof(Game), 1 }, + { &Game, sizeof(Game), 1 }, // spare 1 + { &Game, sizeof(Game), 1 }, // spare 2 + { &Game, sizeof(Game), 1 }, // spare 3 + { &Game, sizeof(Game), 1 }, // spare 4 + { &VGA::Mono, sizeof(VGA::Mono), 0 }, + { &Music, sizeof(Music), 1 }, + { volume, sizeof(volume), 1 }, + { Flag, sizeof(Flag), 1 }, + { HeroXY, sizeof(HeroXY), 1 }, + { Barriers, sizeof(Barriers), 1 }, + { pocref, sizeof(pocref), 1 }, + { NULL, 0, 0 } +}; +static void LoadGame(XFILE &file, bool tiny = false) { + SAVTAB *st; + SPRITE *spr; + int i; + for (st = SavTab; st->Ptr; st ++) { + if (file.Error) + error("Bad SVG"); + file.Read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len); + } -//-------------------------------------------------------------------------- - - - int pocref[POCKET_NX]; - uint8 volume[2]; - struct SAVTAB { void * Ptr; int Len; uint8 Flg; } SavTab[] = - {{ &Now, sizeof(Now), 1 }, - { &OldLev, sizeof(OldLev), 1 }, - { &DemoText, sizeof(DemoText), 1 }, - { &Game, sizeof(Game), 1 }, - { &Game, sizeof(Game), 1 }, // spare 1 - { &Game, sizeof(Game), 1 }, // spare 2 - { &Game, sizeof(Game), 1 }, // spare 3 - { &Game, sizeof(Game), 1 }, // spare 4 - { &VGA::Mono, sizeof(VGA::Mono), 0 }, - { &Music, sizeof(Music), 1 }, - { volume, sizeof(volume), 1 }, - - { Flag, sizeof(Flag), 1 }, - { HeroXY, sizeof(HeroXY), 1 }, - { Barriers, sizeof(Barriers), 1 }, - { pocref, sizeof(pocref), 1 }, - { NULL, 0, 0 } }; - - - + file.Read((uint8 *) &i, sizeof(i)); + if (i != SVGCHKSUM) + error(Text[BADSVG_TEXT]); + if (STARTUP::Core < CORE_HIG) + Music = false; -static void LoadGame (XFILE& file, bool tiny = false) -{ - SAVTAB * st; - SPRITE * spr; - int i; - - for (st = SavTab; st->Ptr; st ++) - { - if (file.Error) - error("Bad SVG"); - file.Read((uint8 *) ((tiny || st->Flg) ? st->Ptr : &i), st->Len); - } - - file.Read((uint8 *) &i, sizeof(i)); - if (i != SVGCHKSUM) - error(Text[BADSVG_TEXT]); - if (STARTUP::Core < CORE_HIG) Music = false; - if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) { - SNDDrvInfo.VOL2.D = volume[0]; - SNDDrvInfo.VOL2.M = volume[1]; - SNDSetVolume(); - } - - if (! tiny) // load sprites & pocket - { - while (! file.Error) - { - SPRITE S(NULL); - uint16 n = file.Read((uint8 *) &S, sizeof(S)); - - if (n != sizeof(S)) break; - S.Prev = S.Next = NULL; - spr = (scumm_stricmp(S.File+2, "MUCHA") == 0) ? new FLY(NULL) - : new SPRITE(NULL); - if (spr == NULL) - error("No core"); - *spr = S; - VGA::SpareQ.Append(spr); + if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) { + SNDDrvInfo.VOL2.D = volume[0]; + SNDDrvInfo.VOL2.M = volume[1]; + SNDSetVolume(); } - for (i = 0; i < POCKET_NX; i ++) - { - register int r = pocref[i]; - Pocket[i] = (r < 0) ? NULL : VGA::SpareQ.Locate(r); + if (! tiny) { // load sprites & pocket + while (! file.Error) { + SPRITE S(NULL); + uint16 n = file.Read((uint8 *) &S, sizeof(S)); + + if (n != sizeof(S)) + break; + + S.Prev = S.Next = NULL; + spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(NULL) + : new SPRITE(NULL); + if (spr == NULL) + error("No core"); + *spr = S; + VGA::SpareQ.Append(spr); + } + + for (i = 0; i < POCKET_NX; i ++) { + register int r = pocref[i]; + Pocket[i] = (r < 0) ? NULL : VGA::SpareQ.Locate(r); + } } - } } - - -static void SaveSound (void) -{ - CFILE cfg(UsrPath(ProgName(CFG_EXT)), WRI); - if (! cfg.Error) cfg.Write(&SNDDrvInfo,sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); +static void SaveSound(void) { + CFILE cfg(UsrPath(ProgName(CFG_EXT)), WRI); + if (! cfg.Error) cfg.Write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2)); } +static void SaveGame(XFILE &file) { + SAVTAB *st; + SPRITE *spr; + int i; + for (i = 0; i < POCKET_NX; i ++) { + register SPRITE *s = Pocket[i]; + pocref[i] = (s) ? s->Ref : -1; + } + volume[0] = SNDDrvInfo.VOL2.D; + volume[1] = SNDDrvInfo.VOL2.M; + for (st = SavTab; st->Ptr; st ++) { + if (file.Error) + error("Bad SVG"); + file.Write((uint8 *) st->Ptr, st->Len); + } -static void SaveGame (XFILE& file) -{ - SAVTAB * st; - SPRITE * spr; - int i; - - for (i = 0; i < POCKET_NX; i ++) - { - register SPRITE * s = Pocket[i]; - pocref[i] = (s) ? s->Ref : -1; - } - - volume[0] = SNDDrvInfo.VOL2.D; - volume[1] = SNDDrvInfo.VOL2.M; - - for (st = SavTab; st->Ptr; st ++) - { - if (file.Error) - error("Bad SVG"); - file.Write((uint8 *) st->Ptr, st->Len); - } - - file.Write((uint8 *) &(i = SVGCHKSUM), sizeof(i)); + file.Write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); - for (spr = VGA::SpareQ.First(); spr; spr = spr->Next) - if (spr->Ref >= 1000) - if (!file.Error) file.Write((uint8 *)spr, sizeof(*spr)); + for (spr = VGA::SpareQ.First(); spr; spr = spr->Next) + if (spr->Ref >= 1000) + if (!file.Error) + file.Write((uint8 *)spr, sizeof(*spr)); } - - - - - -static void HeroCover (int cvr) -{ - SNPOST(SNCOVER, 1, cvr, NULL); +static void HeroCover(int cvr) { + SNPOST(SNCOVER, 1, cvr, NULL); } - - -static void Trouble (int seq, int txt) -{ - Hero->Park(); - SNPOST(SNWAIT, -1, -1, Hero); - SNPOST(SNSEQ, -1, seq, Hero); - SNPOST(SNSOUND, -1, 2, Hero); - SNPOST(SNWAIT, -1, -1, Hero); - SNPOST(SNSAY, 1, txt, Hero); +static void Trouble(int seq, int txt) { + Hero->Park(); + SNPOST(SNWAIT, -1, -1, Hero); + SNPOST(SNSEQ, -1, seq, Hero); + SNPOST(SNSOUND, -1, 2, Hero); + SNPOST(SNWAIT, -1, -1, Hero); + SNPOST(SNSAY, 1, txt, Hero); } - -static void OffUse (void) -{ - Trouble(OFF_USE, OFF_USE_TEXT+new_random(OffUseCount)); +static void OffUse(void) { + Trouble(OFF_USE, OFF_USE_TEXT + new_random(OffUseCount)); } +static void TooFar(void) { + Trouble(TOO_FAR, TOO_FAR_TEXT); +} -static void TooFar (void) -{ - Trouble(TOO_FAR, TOO_FAR_TEXT); +static void NoWay(void) { + Trouble(NO_WAY, NO_WAY_TEXT); } +static void LoadHeroXY(void) { + INI_FILE cf(ProgName(".HXY")); + memset(HeroXY, 0, sizeof(HeroXY)); + if (! cf.Error) + cf.CFREAD(&HeroXY); +} -static void NoWay (void) -{ - Trouble(NO_WAY, NO_WAY_TEXT); +static void LoadMapping(void) { + if (Now <= CAVE_MAX) { + INI_FILE cf(ProgName(".TAB")); + if (! cf.Error) { + memset(CLUSTER::Map, 0, sizeof(CLUSTER::Map)); + cf.Seek((Now - 1) * sizeof(CLUSTER::Map)); + cf.Read((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); + } + } } +CLUSTER Trace[MAX_FIND_LEVEL]; +int FindLevel; - -static void LoadHeroXY (void) -{ - INI_FILE cf(ProgName(".HXY")); - memset(HeroXY, 0, sizeof(HeroXY)); - if (! cf.Error) cf.CFREAD(&HeroXY); +WALK::WALK(BMP_PTR *shpl) + : SPRITE(shpl), Dir(NO_DIR), TracePtr(-1) { } +void WALK::Tick(void) { + if (Flags.Hide) + return; + Here = XZ(X + W / 2, Y + H); + if (Dir != NO_DIR) { + SPRITE *spr; + SYSTEM::FunTouch(); + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { + if (Distance(spr) < 2) { + if (! spr->Flags.Near) { + FeedSnail(spr, NEAR); + spr->Flags.Near = true; + } + } else spr->Flags.Near = false; + } + } -static void LoadMapping (void) -{ - if (Now <= CAVE_MAX) - { - INI_FILE cf(ProgName(".TAB")); - if (! cf.Error) - { - memset(CLUSTER::Map, 0, sizeof(CLUSTER::Map)); - cf.Seek((Now - 1) * sizeof(CLUSTER::Map)); - cf.Read((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); + if (Flags.Hold || TracePtr < 0) + Park(); + else { + if (Here == Trace[TracePtr]) { + if (-- TracePtr < 0) + Park(); + } else { + signed char dx, dz; + (Trace[TracePtr] - Here).Split(dx, dz); + DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN); + Turn(d); + } + } + Step(); + if ((Dir == WW && X <= 0) || + (Dir == EE && X + W >= SCR_WID) || + (Dir == SS && Y + W >= WORLD_HIG - 2)) + Park(); + else { + signed char x; // dummy var + Here.Split(x, Z); // take current Z position + SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue } - } } +int WALK::Distance(SPRITE *spr) { + int dx, dz; + dx = spr->X - (X + W - WALKSIDE); + if (dx < 0) + dx = (X + WALKSIDE) - (spr->X + spr->W); + if (dx < 0) + dx = 0; + dx /= MAP_XGRID; + dz = spr->Z - Z; + if (dz < 0) + dz = - dz; + dx = dx * dx + dz * dz; + for (dz = 1; dz * dz < dx; dz ++) + ; -//-------------------------------------------------------------------------- - -CLUSTER Trace[MAX_FIND_LEVEL]; -int FindLevel; - + return dz - 1; +} +void WALK::Turn(DIR d) { + DIR dir = (Dir == NO_DIR) ? SS : Dir; + if (d != Dir) { + Step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); + Dir = d; + } +} +void WALK::Park(void) { + if (Time == 0) + ++Time; + if (Dir != NO_DIR) { + Step(9 + 4 * Dir + Dir); + Dir = NO_DIR; + TracePtr = -1; + } +} -WALK::WALK (BMP_PTR * shpl) -: SPRITE(shpl), Dir(NO_DIR), TracePtr(-1) -{ +void WALK::FindWay(CLUSTER c) { + warning("STUB: Find1Way"); + /* + bool Find1Way(void); + extern uint16 Target; + + if (c != Here) { + for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel ++) { + signed char x, z; + Here.Split(x, z); + Target = (z << 8) | x; + c.Split(x, z); + _CX = (z << 8) | x; + if (Find1Way()) + break; + } + TracePtr = (FindLevel > MAX_FIND_LEVEL) ? -1 : (FindLevel - 1); + if (TracePtr < 0) + NoWay(); + Time = 1; + } +*/ } +void WALK::FindWay(SPRITE *spr) { + if (spr && spr != this) { + int x = spr->X, z = spr->Z; + if (spr->Flags.East) + x += spr->W + W / 2 - WALKSIDE; + else + x -= W / 2 - WALKSIDE; + FindWay(CLUSTER((x / MAP_XGRID), + ((z < MAP_ZCNT - MAX_DISTANCE) ? (z + 1) + : (z - 1)))); + } +} +bool WALK::Lower(SPRITE *spr) { + return (spr->Y > Y + (H * 3) / 5); +} -void WALK::Tick (void) -{ - if (Flags.Hide) return; - - Here = XZ(X+W/2, Y+H); - if (Dir != NO_DIR) - { - SPRITE * spr; - SYSTEM::FunTouch(); - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) - { - if (Distance(spr) < 2) - { - if (! spr->Flags.Near) - { - FeedSnail(spr, NEAR); - spr->Flags.Near = true; +void WALK::Reach(SPRITE *spr, int mode) { + if (spr) { + Hero->FindWay(spr); + if (mode < 0) { + mode = spr->Flags.East; + if (Lower(spr)) + mode += 2; } - } - else spr->Flags.Near = false; - } - } - - if (Flags.Hold || TracePtr < 0) Park(); - else - { - if (Here == Trace[TracePtr]) - { - if (-- TracePtr < 0) Park(); } - else - { - signed char dx, dz; - (Trace[TracePtr] - Here).Split(dx, dz); - DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN); - Turn(d); + // note: insert SNAIL commands in reverse order + SNINSERT(SNPAUSE, -1, 64, NULL); + SNINSERT(SNSEQ, -1, TSEQ + mode, this); + if (spr) { + SNINSERT(SNWAIT, -1, -1, Hero); /////--------$$$$$$$ + //SNINSERT(SNWALK, -1, -1, spr); } - } - Step(); - if ((Dir == WW && X <= 0) || - (Dir == EE && X + W >= SCR_WID) || - (Dir == SS && Y + W >= WORLD_HIG-2)) Park(); - else - { - signed char x; // dummy var - Here.Split(x, Z); // take current Z position - SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue - } + // sequence is not finished, + // now it is just at sprite appear (disappear) point } +#ifdef DEBUG +class SQUARE : public SPRITE { +public: + SQUARE(void); + void Touch(uint16 mask, int x, int y); +}; - -int WALK::Distance (SPRITE * spr) -{ - int dx, dz; - dx = spr->X - (X+W-WALKSIDE); - if (dx < 0) dx = (X+WALKSIDE) - (spr->X+spr->W); - if (dx < 0) dx = 0; - dx /= MAP_XGRID; - dz = spr->Z - Z; - if (dz < 0) dz = - dz; - dx = dx * dx + dz * dz; - for (dz = 1; dz * dz < dx; dz ++) ; - return dz-1; +SQUARE::SQUARE(void) + : SPRITE(MB) { + Flags.Kill = true; + Flags.BDel = false; } +void SQUARE::Touch(uint16 mask, int x, int y) { + SPRITE::Touch(mask, x, y); + if (mask & L_UP) { + XZ(X + x, Y + y).Cell() = 0; + SNPOST_(SNKILL, -1, 0, this); + } +} - - - - - - -void WALK::Turn (DIR d) -{ - DIR dir = (Dir == NO_DIR) ? SS : Dir; - if (d != Dir) - { - Step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); - Dir = d; - } +static void SetMapBrick(int x, int z) { + SQUARE *s = new SQUARE; + if (s) { + static char n[] = "00:00"; + s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); + wtom(x, n + 0, 10, 2); + wtom(z, n + 3, 10, 2); + CLUSTER::Map[z][x] = 1; + s->SetName(n); + VGA::ShowQ.Insert(s, VGA::ShowQ.First()); + } } +#endif +void dummy(void) {} +static void SwitchMapping(void); +static void SwitchColorMode(void); +static void StartCountDown(void); +Debug(static void SwitchDebug(void);) +static void SwitchMusic(void); +static void KillSprite(void); +static void PushSprite(void); +static void PullSprite(void); +static void BackPaint(void); +static void NextStep(void); +static void SaveMapping(void); -void WALK::Park (void) -{ - if (Time == 0) ++ Time; - if (Dir != NO_DIR) - { - Step(9 + 4 * Dir + Dir); - Dir = NO_DIR; - TracePtr = -1; - } -} - +WALK *Hero = NULL; +static INFO_LINE InfoLine = INFO_W; +static HEART Heart; +static SPRITE CavLight = PR; +static void KeyClick(void) { + SNPOST_(SNSOUND, -1, 5, NULL); +} +static void ResetQSwitch(void) { + SNPOST_(SNSEQ, 123, 0, NULL); + KeyClick(); +} -void WALK::FindWay (CLUSTER c) -{ - warning("STUB: Find1Way"); -/* - bool Find1Way(void); - extern uint16 Target; +static void Quit(void) { + static CHOICE QuitMenu[] = { { NULL, StartCountDown }, + { NULL, ResetQSwitch }, + { NULL, dummy } + }; - if (c != Here) - { - for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel ++) - { - signed char x, z; - Here.Split(x, z); - Target = (z << 8) | x; - c.Split(x, z); - _CX = (z << 8) | x; - if (Find1Way()) break; + if (Snail.Idle() && ! Hero->Flags.Hide) { + if (VMENU::Addr) { + SNPOST_(SNKILL, -1, 0, VMENU::Addr); + ResetQSwitch(); + } else { + QuitMenu[0].Text = Text[QUIT_TEXT]; + QuitMenu[1].Text = Text[NOQUIT_TEXT]; + (new VMENU(QuitMenu, -1, -1))->SetName(Text[QUIT_TITLE]); + SNPOST_(SNSEQ, 123, 1, NULL); + KeyClick(); + } } - TracePtr = (FindLevel > MAX_FIND_LEVEL) ? -1 : (FindLevel - 1); - if (TracePtr < 0) NoWay(); - Time = 1; - } -*/ } +static void AltCtrlDel(void) { +#if 0 + //def DEBUG + if (KEYBOARD::Key[LSHIFT] || KEYBOARD::Key[RSHIFT]) { + PostFlag = 0x1234; + POST(); + } else +#endif + SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero); +} +static void MiniStep(int stp) { + if (stp < 0) + MiniCave->Flags.Hide = true; + else { + &*Mini; + *MiniShp[0] = *MiniShpList[stp]; + if (Fx.Current) + &*(Fx.Current->EAddr()); - -void WALK::FindWay (SPRITE * spr) -{ - if (spr && spr != this) - { - int x = spr->X, z = spr->Z; - if (spr->Flags.East) x += spr->W + W/2 - WALKSIDE; - else x -= W/2 - WALKSIDE; - FindWay(CLUSTER((x/MAP_XGRID), - ((z < MAP_ZCNT-MAX_DISTANCE) ? (z+1) - : (z-1)))); - } + MiniCave->Flags.Hide = false; + } } +static void PostMiniStep(int stp) { + static int recent = -2; + //TODO Change the SNPOST message send to a special way to send function pointer + //if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep); + warning("STUB: PostMiniStep()"); +} +int SYSTEM::FunDel = HEROFUN0; -bool WALK::Lower (SPRITE * spr) -{ - return (spr->Y > Y + (H * 3) / 5); +void SYSTEM::SetPal(void) { + int i; + DAC *p = SysPal + 256 - ArrayCount(StdPal); + for (i = 0; i < ArrayCount(StdPal); i ++) { + p[i].R = StdPal[i].R >> 2; + p[i].G = StdPal[i].G >> 2; + p[i].B = StdPal[i].B >> 2; + } } +void SYSTEM::FunTouch(void) { + uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0; + if (Talk == NULL || n > FunDel) + FunDel = n; +} - - -void WALK::Reach (SPRITE * spr, int mode) -{ - if (spr) - { - Hero->FindWay(spr); - if (mode < 0) - { - mode = spr->Flags.East; - if (Lower(spr)) mode += 2; +static void ShowBak(int ref) { + SPRITE *spr = VGA::SpareQ.Locate(ref); + if (spr) { + BITMAP::Pal = SysPal; + spr->Expand(); + BITMAP::Pal = NULL; + spr->Show(2); + VGA::CopyPage(1, 2); + SYSTEM::SetPal(); + spr->Contract(); } - } - // note: insert SNAIL commands in reverse order - SNINSERT(SNPAUSE, -1, 64, NULL); - SNINSERT(SNSEQ, -1, TSEQ + mode, this); - if (spr) - { - SNINSERT(SNWAIT, -1, -1, Hero); /////--------$$$$$$$ - //SNINSERT(SNWALK, -1, -1, spr); - } - // sequence is not finished, - // now it is just at sprite appear (disappear) point } +static void CaveUp(void) { + int BakRef = 1000 * Now; + if (Music) + LoadMIDI(Now); + + ShowBak(BakRef); + LoadMapping(); + Text.Preload(BakRef, BakRef + 1000); + SPRITE *spr = VGA::SpareQ.First(); + while (spr) { + SPRITE *n = spr->Next; + if (spr->Cave == Now || spr->Cave == 0) + if (spr->Ref != BakRef) { + if (spr->Flags.Back) + spr->BackShow(); + else + ExpandSprite(spr); + } + spr = n; + } + if (SNDDrvInfo.DDEV) { + Sound.Stop(); + Fx.Clear(); + Fx.Preload(0); + Fx.Preload(BakRef); + } + if (Hero) { + Hero->Goto(HeroXY[Now - 1].X, HeroXY[Now - 1].Y); + // following 2 lines trims Hero's Z position! + Hero->Tick(); + Hero->Time = 1; + Hero->Flags.Hide = false; + } + if (! Dark) + Vga.Sunset(); + VGA::CopyPage(0, 1); + SelectPocket(-1); + if (Hero) + VGA::ShowQ.Insert(VGA::ShowQ.Remove(Hero)); -//-------------------------------------------------------------------------- + if (Shadow) { + VGA::ShowQ.Remove(Shadow); + Shadow->MakeXlat(Glass(SysPal, 204, 204, 204)); + VGA::ShowQ.Insert(Shadow, Hero); + Shadow->Z = Hero->Z; + } + FeedSnail(VGA::ShowQ.Locate(BakRef + 999), TAKE); + Vga.Show(); + Vga.CopyPage(1, 0); + Vga.Show(); + Vga.Sunrise(SysPal); + Dark = false; + if (! Startup) + Mouse.On(); + HEART::Enable = true; +} -#ifdef DEBUG +static void CaveDown(void) { + SPRITE *spr; + Debug(if (! HorzLine.Flags.Hide) SwitchMapping();) + for (spr = VGA::ShowQ.First(); spr;) { + SPRITE *n = spr->Next; + if (spr->Ref >= 1000 /*&& spr->Cave*/) { + if (spr->Ref % 1000 == 999) + FeedSnail(spr, TAKE); -class SQUARE : public SPRITE -{ -public: - SQUARE (void); - void Touch (uint16 mask, int x, int y); -}; + VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); + } + spr = n; + } + Text.Clear(1000); +} +static void XCave(void) { + CaveDown(); + CaveUp(); +} +static void QGame(void) { + CaveDown(); + OldLev = Lev; + SaveSound(); + CFILE file = CFILE(UsrPath(UsrFnam), WRI, RCrypt); + SaveGame(file); + Vga.Sunset(); + Finis = true; +} -SQUARE::SQUARE (void) -: SPRITE(MB) -{ - Flags.Kill = true; - Flags.BDel = false; +void SwitchCave(int cav) { + if (cav != Now) { + HEART::Enable = false; + if (cav < 0) { + SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint + //TODO Change the SNPOST message send to a special way to send function pointer + //SNPOST(SNEXEC, -1, 0, (void *)&QGame); // switch cave + warning("SwitchCave() - SNPOST"); + } else { + Now = cav; + Mouse.Off(); + if (Hero) { + Hero->Park(); + Hero->Step(0); +#ifndef DEMO + ///// protection: auto-destruction on! ---------------------- + VGA::SpareQ.Show = STARTUP::Summa * (cav <= CAVE_MAX); + /////-------------------------------------------------------- +#endif + } + CavLight.Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); + KillText(); + if (! Startup) KeyClick(); + SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint + //TODO Change the SNPOST message send to a special way to send function pointer + //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave + warning("SwitchCave() - SNPOST"); + } + } } +void SYSTEM::Touch(uint16 mask, int x, int y) { + static int pp = 0; + void SwitchCave(int cav); + int cav = 0; + FunTouch(); + + if (mask & KEYB) { + int pp0; + KeyClick(); + KillText(); + if (Startup == 1) { + SNPOST(SNCLEAR, -1, 0, NULL); + return; + } + pp0 = pp; + switch (x) { + case Del: + if (KEYBOARD::Key[ALT] && + KEYBOARD::Key[CTRL]) AltCtrlDel(); + Debug(else KillSprite();) + break; + case 'F': + if (KEYBOARD::Key[ALT]) { + SPRITE *m = VGA::ShowQ.Locate(17001); + if (m) { + m->Step(1); + m->Time = 216; // 3s + } + } + break; +#ifdef DEBUG + case PgUp: + PushSprite(); + break; + case PgDn: + PullSprite(); + break; + case '+': + NextStep(); + break; + case '`': + if (KEYBOARD::Key[ALT]) + SaveMapping(); + else + SwitchMapping(); + break; + case F1: + SwitchDebug(); + break; + case F3: + Hero->Step(TSEQ + 4); + break; + case F4: + Hero->Step(TSEQ + 5); + break; + case F5: + Hero->Step(TSEQ + 0); + break; + case F6: + Hero->Step(TSEQ + 1); + break; + case F7: + Hero->Step(TSEQ + 2); + break; + case F8: + Hero->Step(TSEQ + 3); + break; + case F9: + SYSTEM::FunDel = 1; + break; + case 'X': + if (KEYBOARD::Key[ALT]) + Finis = true; + break; + case '0': + case '1': + case '2': + case '3': + case '4': + if (KEYBOARD::Key[ALT]) { + SNPOST(SNLEVEL, -1, x - '0', NULL); + break; + } + case '5': + case '6': + case '7': + case '8': + case '9': + if (Sprite) + Sprite->Step(x - '0'); + break; +#else + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + SelectPocket(x - '1'); + break; +#endif + case F10 : + if (Snail.Idle() && ! Hero->Flags.Hide) + StartCountDown(); + break; + case 'J': + if (pp == 0) + ++pp; + break; + case 'B': + if (pp == 1) + ++pp; + break; + case 'W': + if (pp == 2) + JBW = !JBW; + break; + } + if (pp == pp0) + pp = 0; + } else { + if (Startup) + return; + + InfoLine.Update(NULL); + if (y >= WORLD_HIG) { + if (x < BUTTON_X) { // select cave? + if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && + x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && ! Game) { + cav = ((y - CAVE_Y) / CAVE_DY) * CAVE_NX + (x - CAVE_X) / CAVE_DX + 1; + if (cav > MaxCave) + cav = 0; + } else { + cav = 0; + } + } else if (mask & L_UP) { + if (y >= POCKET_Y && y < POCKET_Y + POCKET_NY * POCKET_DY && + x >= POCKET_X && x < POCKET_X + POCKET_NX * POCKET_DX) { + int n = ((y - POCKET_Y) / POCKET_DY) * POCKET_NX + (x - POCKET_X) / POCKET_DX; + SelectPocket(n); + } + } + } + PostMiniStep(cav - 1); + if (mask & L_UP) { + if (cav && Snail.Idle() && Hero->TracePtr < 0) + SwitchCave(cav); -void SQUARE::Touch (uint16 mask, int x, int y) -{ - SPRITE::Touch(mask, x, y); - if (mask & L_UP) - { - XZ(X+x, Y+y).Cell() = 0; - SNPOST_(SNKILL, -1, 0, this); - } +#ifdef DEBUG + if (!HorzLine.Flags.Hide) { + if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { + signed char x1, z1; + XZ(x, y).Split(x1, z1); + CLUSTER::Map[z1][x1] = 1; + SetMapBrick(x1, z1); + } + } else +#endif + { + if (! Talk && Snail.Idle() && Hero + && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && ! Game) { + Hero->FindWay(XZ(x, y)); + } + } + } + } } +void SYSTEM::Tick(void) { + if (! Startup) if (-- FunDel == 0) { + KillText(); + if (Snail.Idle()) { + if (PAIN) + HeroCover(9); + else if (STARTUP::Core >= CORE_MID) { + int n = new_random(100); + if (n > 96) + HeroCover(6 + (Hero->X + Hero->W / 2 < SCR_WID / 2)); + else { + if (n > 90) + HeroCover(5); + else { + if (n > 60) + HeroCover(4); + else + HeroCover(3); + } + } + } + } + FunTouch(); + } + Time = SYSTIMERATE; +} +/* +static void SpkOpen(void) { + asm in al,0x61 + asm or al,0x03 + asm out 0x61,al + asm mov al,0x90 + asm out 0x43,al +} -static void SetMapBrick (int x, int z) -{ - SQUARE * s = new SQUARE; - if (s) - { - static char n[] = "00:00"; - s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); - wtom(x, n+0, 10, 2); - wtom(z, n+3, 10, 2); - CLUSTER::Map[z][x] = 1; - s->SetName(n); - VGA::ShowQ.Insert(s, VGA::ShowQ.First()); - } +static void SpkClose(void) { + asm in al,0x61 + asm and al,0xFC + asm out 0x61,al } - -#endif +*/ +static void SwitchColorMode(void) { + SNPOST_(SNSEQ, 121, VGA::Mono = ! VGA::Mono, NULL); + KeyClick(); + VGA::SetColors(SysPal, 64); +} -//-------------------------------------------------------------------------- -void dummy (void) { } -static void SwitchMapping (void); -static void SwitchColorMode (void); -static void StartCountDown (void); -Debug(static void SwitchDebug (void); ) -static void SwitchMusic (void); -static void KillSprite (void); -static void PushSprite (void); -static void PullSprite (void); -static void BackPaint (void); -static void NextStep (void); -static void SaveMapping (void); +static void SwitchMusic(void) { + if (KEYBOARD::Key[ALT]) { + if (VMENU::Addr) + SNPOST_(SNKILL, -1, 0, VMENU::Addr); + else { + SNPOST_(SNSEQ, 122, (Music = false), NULL); + //TODO Change the SNPOST message send to a special way to send function pointer + // SNPOST(SNEXEC, -1, 0, (void *)&SelectSound); + warning("SwitchMusic() - SNPOST"); + } + } else { + if (STARTUP::Core < CORE_HIG) + SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL); + else { + SNPOST_(SNSEQ, 122, (Music = ! Music), NULL); + KeyClick(); + } + } + if (Music) + LoadMIDI(Now); + else + KillMIDI(); +} - WALK * Hero = NULL; -static INFO_LINE InfoLine = INFO_W; -static HEART Heart; +static void StartCountDown(void) { + //SNPOST(SNSEQ, 123, 0, NULL); + SwitchCave(-1); +} -static SPRITE CavLight = PR; +#ifndef DEMO +static void TakeName(void) { + if (GET_TEXT::Ptr) + SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr); + else { + GET_TEXT *tn = new GET_TEXT(Text[GETNAME_PROMPT], UsrFnam, 8, KeyClick); + if (tn) { + tn->SetName(Text[GETNAME_TITLE]); + tn->Center(); + tn->Goto(tn->X, tn->Y - 10); + tn->Z = 126; + VGA::ShowQ.Insert(tn); + } + } +} +#endif +#ifdef DEBUG +static void SwitchMapping(void) { + if (HorzLine.Flags.Hide) { + int i; + for (i = 0; i < MAP_ZCNT; i ++) { + int j; + for (j = 0; j < MAP_XCNT; j ++) { + if (CLUSTER::Map[i][j]) + SetMapBrick(j, i); + } + } + } else { + SPRITE *s; + for (s = VGA::ShowQ.First(); s; s = s->Next) + if (s->W == MAP_XGRID && s->H == MAP_ZGRID) + SNPOST_(SNKILL, -1, 0, s); + } + HorzLine.Flags.Hide = ! HorzLine.Flags.Hide; +} -static void KeyClick (void) -{ - SNPOST_(SNSOUND, -1, 5, NULL); +static void KillSprite(void) { + Sprite->Flags.Kill = true; + Sprite->Flags.BDel = true; + SNPOST_(SNKILL, -1, 0, Sprite); + Sprite = NULL; } - -static void ResetQSwitch (void) -{ - SNPOST_(SNSEQ, 123, 0, NULL); - KeyClick(); +static void PushSprite(void) { + SPRITE *spr = Sprite->Prev; + if (spr) { + VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr); + while (Sprite->Z > Sprite->Next->Z) + --Sprite->Z; + } else + SNPOST_(SNSOUND, -1, 2, NULL); } +static void PullSprite(void) { + bool ok = false; + SPRITE *spr = Sprite->Next; + if (spr) { + spr = spr->Next; + if (spr) + ok = (!spr->Flags.Slav); + } + if (ok) { + VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr); + if (Sprite->Prev) + while (Sprite->Z < Sprite->Prev->Z) + ++Sprite->Z; + } else + SNPOST_(SNSOUND, -1, 2, NULL); +} + +static void NextStep(void) { + SNPOST_(SNSTEP, 0, 0, Sprite); +} -static void Quit (void) -{ - static CHOICE QuitMenu[]={ { NULL, StartCountDown }, - { NULL, ResetQSwitch }, - { NULL, dummy } }; - if (Snail.Idle() && ! Hero->Flags.Hide) - { - if (VMENU::Addr) +static void SaveMapping(void) { { - SNPOST_(SNKILL, -1, 0, VMENU::Addr); - ResetQSwitch(); + IOHAND cf(ProgName(".TAB"), UPD); + if (!cf.Error) { + cf.Seek((Now - 1) * sizeof(CLUSTER::Map)); + cf.Write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); + } } - else { - QuitMenu[0].Text = Text[QUIT_TEXT]; - QuitMenu[1].Text = Text[NOQUIT_TEXT]; - (new VMENU(QuitMenu, -1, -1))->SetName(Text[QUIT_TITLE]); - SNPOST_(SNSEQ, 123, 1, NULL); - KeyClick(); + IOHAND cf(ProgName(".HXY"), WRI); + if (!cf.Error) { + HeroXY[Now - 1].X = Hero->X; + HeroXY[Now - 1].Y = Hero->Y; + cf.Write((uint8 *) HeroXY, sizeof(HeroXY)); + } } - } } +#endif +#ifdef DEBUG +// 1111111111222222222233333333 334444444444555555555566666666667777777777 +// 01234567890123456789012345678901234567 890123456789012345678901234567890123456789 +static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 000:000:000 000:000 00 "; + +#define NFRE (DebugText + 3) +#define FFRE (DebugText + 11) +#define ABSX (DebugText + 20) +#define ABSY (DebugText + 26) +#define FRPS (DebugText + 34) +#define XSPR (DebugText + 38) +#define SP_N (DebugText + 41) +#define SP_S (DebugText + 44) + +#define SP_X (DebugText + 47) +#define SP_Y (DebugText + 51) +#define SP_Z (DebugText + 55) +#define SP_W (DebugText + 59) +#define SP_H (DebugText + 63) +#define SP_F (DebugText + 67) +#define SP__ (DebugText + 70) -static void AltCtrlDel (void) -{ - #if 0 - //def DEBUG - if (KEYBOARD::Key[LSHIFT] || KEYBOARD::Key[RSHIFT]) - { - PostFlag = 0x1234; - POST(); - } - else - #endif - SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero); -} - +INFO_LINE DebugLine(SCR_WID); +static void SayDebug(void) { + if (!DebugLine.Flags.Hide) { + static long t = -1L; + long t1 = Timer(); + if (t1 - t >= 18) { + static uint32 old = 0L; + uint32 now = Vga.FrmCnt; + dwtom(now - old, FRPS, 10, 4); + old = now; + t = t1; + } -static void MiniStep (int stp) -{ - if (stp < 0) MiniCave->Flags.Hide = true; - else - { - &*Mini; - *MiniShp[0] = *MiniShpList[stp]; - if (Fx.Current) &*(Fx.Current->EAddr()); - MiniCave->Flags.Hide = false; - } + dwtom(Mouse.X, ABSX, 10, 3); + dwtom(Mouse.Y, ABSY, 10, 3); +// dwtom(coreleft(), NFRE, 10, 5); +// dwtom(farcoreleft(), FFRE, 10, 6); + + // sprite queue size + uint16 n = 0; + SPRITE *spr; + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { + ++ n; + if (spr == Sprite) { + *XSPR = ' '; + dwtom(n, SP_N, 10, 2); + dwtom(Sprite->X, SP_X, 10, 3); + dwtom(Sprite->Y, SP_Y, 10, 3); + dwtom(Sprite->Z, SP_Z, 10, 3); + dwtom(Sprite->W, SP_W, 10, 3); + dwtom(Sprite->H, SP_H, 10, 3); + dwtom(*(uint16 *)(&Sprite->Flags), SP_F, 16, 2); + } + } + dwtom(n, SP_S, 10, 2); +// *SP__ = (heapcheck() < 0) ? '!' : ' '; + DebugLine.Update(DebugText); + } } - - - -static void PostMiniStep (int stp) -{ - static int recent = -2; - //TODO Change the SNPOST message send to a special way to send function pointer - //if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep); - warning("STUB: PostMiniStep()"); -} - - - -//-------------------------------------------------------------------------- - - - -int SYSTEM::FunDel = HEROFUN0; - - - - -void SYSTEM::SetPal (void) -{ - int i; - DAC * p = SysPal + 256-ArrayCount(StdPal); - for (i = 0; i < ArrayCount(StdPal); i ++) - { - p[i].R = StdPal[i].R >> 2; - p[i].G = StdPal[i].G >> 2; - p[i].B = StdPal[i].B >> 2; - } -} - - - - - -void SYSTEM::FunTouch (void) -{ - uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0; - if (Talk == NULL || n > FunDel) FunDel = n; +static void SwitchDebug(void) { + DebugLine.Flags.Hide = ! DebugLine.Flags.Hide; } +#endif - - - -static void ShowBak (int ref) -{ - SPRITE * spr = VGA::SpareQ.Locate(ref); - if (spr) - { - BITMAP::Pal = SysPal; - spr->Expand(); - BITMAP::Pal = NULL; - spr->Show(2); - VGA::CopyPage(1, 2); - SYSTEM::SetPal(); - spr->Contract(); - } -} - - - - - - -static void CaveUp (void) -{ - int BakRef = 1000 * Now; - if (Music) LoadMIDI(Now); - ShowBak(BakRef); - LoadMapping(); - Text.Preload(BakRef, BakRef+1000); - SPRITE * spr = VGA::SpareQ.First(); - while (spr) - { - SPRITE * n = spr->Next; - if (spr->Cave == Now || spr->Cave == 0) - if (spr->Ref != BakRef) - { - if (spr->Flags.Back) spr->BackShow(); - else ExpandSprite(spr); - } - spr = n; - } - if (SNDDrvInfo.DDEV) - { - Sound.Stop(); - Fx.Clear(); - Fx.Preload(0); - Fx.Preload(BakRef); - } - - if (Hero) - { - Hero->Goto(HeroXY[Now-1].X, HeroXY[Now-1].Y); - // following 2 lines trims Hero's Z position! - Hero->Tick(); - Hero->Time = 1; - Hero->Flags.Hide = false; - } - - if (! Dark) Vga.Sunset(); - VGA::CopyPage(0, 1); - SelectPocket(-1); - if (Hero) VGA::ShowQ.Insert(VGA::ShowQ.Remove(Hero)); - if (Shadow) - { - VGA::ShowQ.Remove(Shadow); - Shadow->MakeXlat(Glass(SysPal, 204, 204, 204)); - VGA::ShowQ.Insert(Shadow, Hero); - Shadow->Z = Hero->Z; - } - FeedSnail(VGA::ShowQ.Locate(BakRef+999), TAKE); - Vga.Show(); - Vga.CopyPage(1, 0); - Vga.Show(); - Vga.Sunrise(SysPal); - Dark = false; - if (! Startup) Mouse.On(); - HEART::Enable = true; -} - - - - - -static void CaveDown (void) -{ - SPRITE * spr; - Debug( if (! HorzLine.Flags.Hide) SwitchMapping(); ) - - for (spr = VGA::ShowQ.First(); spr; ) - { - SPRITE * n = spr->Next; - if (spr->Ref >= 1000 /*&& spr->Cave*/) - { - if (spr->Ref % 1000 == 999) FeedSnail(spr, TAKE); - VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); - } - spr = n; - } - Text.Clear(1000); -} - - - - - -static void XCave (void) -{ - CaveDown(); - CaveUp(); -} - - - - -static void QGame (void) -{ - CaveDown(); - OldLev = Lev; - SaveSound(); - CFILE file = CFILE(UsrPath(UsrFnam), WRI, RCrypt); - SaveGame(file); - Vga.Sunset(); - Finis = true; -} - - - - -void SwitchCave (int cav) -{ - if (cav != Now) - { - HEART::Enable = false; - if (cav < 0) - { - SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST(SNEXEC, -1, 0, (void *)&QGame); // switch cave - warning("SwitchCave() - SNPOST"); - } - else - { - Now = cav; - Mouse.Off(); - if (Hero) - { - Hero->Park(); - Hero->Step(0); - #ifndef DEMO - ///// protection: auto-destruction on! ---------------------- - VGA::SpareQ.Show = STARTUP::Summa * (cav <= CAVE_MAX); - /////-------------------------------------------------------- - #endif - } - CavLight.Goto(CAVE_X + ((Now-1) % CAVE_NX) * CAVE_DX + CAVE_SX, - CAVE_Y + ((Now-1) / CAVE_NX) * CAVE_DY + CAVE_SY); - KillText(); - if (! Startup) KeyClick(); - SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave - warning("SwitchCave() - SNPOST"); +static void OptionTouch(int opt, uint16 mask) { + switch (opt) { + case 1 : + if (mask & L_UP) + SwitchColorMode(); + break; + case 2 : + if (mask & L_UP) + SwitchMusic(); + else if (mask & R_UP) + if (! MIXER::Appear) { + MIXER::Appear = true; + new MIXER(BUTTON_X, BUTTON_Y); + } + break; + case 3 : + if (mask & L_UP) + Quit(); + break; } - } } - - - - -void SYSTEM::Touch (uint16 mask, int x, int y) -{ - static int pp = 0; - void SwitchCave (int cav); - int cav = 0; - - FunTouch(); - - if (mask & KEYB) - { - int pp0; - KeyClick(); - KillText(); - if (Startup == 1) - { - SNPOST(SNCLEAR, -1, 0, NULL); - return; - } - pp0 = pp; - switch (x) - { - case Del : if (KEYBOARD::Key[ALT] && - KEYBOARD::Key[CTRL]) AltCtrlDel(); - Debug ( else KillSprite(); ) - break; - case 'F' : if (KEYBOARD::Key[ALT]) - { - SPRITE * m = VGA::ShowQ.Locate(17001); - if (m) - { - m->Step(1); - m->Time = 216; // 3s - } - } - break; - - #ifdef DEBUG - case PgUp : PushSprite(); break; - case PgDn : PullSprite(); break; - case '+' : NextStep(); break; - case '`' : if (KEYBOARD::Key[ALT]) SaveMapping(); else SwitchMapping(); break; - case F1 : SwitchDebug(); break; - case F3 : Hero->Step(TSEQ + 4); break; - case F4 : Hero->Step(TSEQ + 5); break; - case F5 : Hero->Step(TSEQ + 0); break; - case F6 : Hero->Step(TSEQ + 1); break; - case F7 : Hero->Step(TSEQ + 2); break; - case F8 : Hero->Step(TSEQ + 3); break; - case F9 : SYSTEM::FunDel = 1; break; - case 'X' : if (KEYBOARD::Key[ALT]) Finis = true; break; - case '0' : - case '1' : - case '2' : - case '3' : - case '4' : if (KEYBOARD::Key[ALT]) { SNPOST(SNLEVEL, -1, x - '0', NULL); break; } - case '5' : - case '6' : - case '7' : - case '8' : - case '9' : if (Sprite) Sprite->Step(x - '0'); break; - #else - case '1' : - case '2' : - case '3' : - case '4' : - case '5' : - case '6' : - case '7' : - case '8' : SelectPocket(x - '1'); break; - #endif - - case F10 : if (Snail.Idle() && ! Hero->Flags.Hide) - StartCountDown(); - break; - case 'J' : if (pp == 0) ++ pp; break; - case 'B' : if (pp == 1) ++ pp; break; - case 'W' : if (pp == 2) JBW = !JBW; break; - } - if (pp == pp0) pp = 0; - } - else - { - if (Startup) return; - InfoLine.Update(NULL); - if (y >= WORLD_HIG) - { - if (x < BUTTON_X) // select cave? - { - if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && - x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && ! Game) - { - cav = ((y-CAVE_Y) / CAVE_DY) * CAVE_NX + (x-CAVE_X) / CAVE_DX + 1; - if (cav > MaxCave) cav = 0; - } - else - { - cav = 0; - } - } - else if (mask & L_UP) - { - if (y >= POCKET_Y && y < POCKET_Y + POCKET_NY * POCKET_DY && - x >= POCKET_X && x < POCKET_X + POCKET_NX * POCKET_DX) - { - int n = ((y-POCKET_Y) / POCKET_DY) * POCKET_NX + (x-POCKET_X) / POCKET_DX; - SelectPocket(n); +#pragma argsused +void SPRITE::Touch(uint16 mask, int x, int y) { + SYSTEM::FunTouch(); + if ((mask & ATTN) == 0) { + InfoLine.Update(Name()); + if (mask & (R_DN | L_DN)) + Sprite = this; // DEBUG mode only? + if (Ref / 10 == 12) { + OptionTouch(Ref % 10, mask); + return; } - } - } - - PostMiniStep(cav-1); - - if (mask & L_UP) - { - if (cav && Snail.Idle() && Hero->TracePtr < 0) - { - SwitchCave(cav); - } - #ifdef DEBUG - if (! HorzLine.Flags.Hide) - { - if (y >= MAP_TOP && y < MAP_TOP+MAP_HIG) - { - signed char x1, z1; - XZ(x, y).Split(x1, z1); - CLUSTER::Map[z1][x1] = 1; - SetMapBrick(x1, z1); + if (Flags.Syst) + return; // cannot access system sprites + if (Game) if (mask & L_UP) { + mask &= ~L_UP; + mask |= R_UP; + } + if ((mask & R_UP) && Snail.Idle()) { + SPRITE *ps = (PocLight.SeqPtr) ? Pocket[PocPtr] : NULL; + if (ps) { + if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) { + if (Works(ps)) { + FeedSnail(ps, TAKE); + } else + OffUse(); + SelectPocket(-1); + } else + TooFar(); + } else { + if (Flags.Kept) + mask |= L_UP; + else { + if (Hero->Distance(this) < MAX_DISTANCE) { + /// + if (Flags.Port) { + if (FindPocket(NULL) < 0) + PocFul(); + else { + SNPOST(SNREACH, -1, -1, this); + SNPOST(SNKEEP, -1, -1, this); + Flags.Port = false; + } + } else { + if (TakePtr != NO_PTR) { + if (SnList(TAKE)[TakePtr].Com == SNNEXT) + OffUse(); + else + FeedSnail(this, TAKE); + } else + OffUse(); + } + }/// + else + TooFar(); + } + } } - } - else - #endif - { - if (! Talk && Snail.Idle() && Hero - && y >= MAP_TOP && y < MAP_TOP+MAP_HIG && ! Game) - { - Hero->FindWay(XZ(x, y)); + if ((mask & L_UP) && Snail.Idle()) { + if (Flags.Kept) { + int n; + for (n = 0; n < POCKET_NX; n ++) { + if (Pocket[n] == this) { + SelectPocket(n); + break; + } + } + } else + SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this); } - } } - } } - - - - - -void SYSTEM::Tick (void) -{ - if (! Startup) if (-- FunDel == 0) - { - KillText(); - if (Snail.Idle()) - { - if (PAIN) HeroCover(9); - else if (STARTUP::Core >= CORE_MID) - { - int n = new_random(100); - if (n > 96) HeroCover(6+(Hero->X+Hero->W/2 < SCR_WID/2)); - else - { - if (n > 90) HeroCover(5); - else - { - if (n > 60) HeroCover(4); - else HeroCover(3); - } +static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) { + static const char *Comd[] = { "Name", "Type", "Phase", "East", + "Left", "Right", "Top", "Bottom", + "Seq", "Near", "Take", + "Portable", "Transparent", + NULL + }; + static const char *Type[] = { "DEAD", "AUTO", "WALK", "NEWTON", "LISSAJOUS", + "FLY", NULL + }; + char line[LINE_MAX]; + + int shpcnt = 0; + int type = 0; // DEAD + bool east = false; + bool port = false; + bool tran = false; + int i, lcnt = 0; + uint16 len; + + MergeExt(line, fname, SPR_EXT); + if (INI_FILE::Exist(line)) { // sprite description file exist + INI_FILE sprf(line); + if (sprf.Error) + error("Bad SPR [%s]", line); + + while ((len = sprf.Read((uint8 *)line)) != 0) { + ++ lcnt; + if (len && line[len - 1] == '\n') + line[-- len] = '\0'; + if (len == 0 || *line == '.') + continue; + + if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) + error("%s [%s]", NumStr("Bad line ######", lcnt), fname); + + + switch (i) { + case 0 : // Name - will be taken in Expand routine + break; + case 1 : // Type + if ((type = TakeEnum(Type, strtok(NULL, " \t,;/"))) < 0) + error("%s [%s]", NumStr("Bad line ######", lcnt), fname); + break; + case 2 : // Phase + ++ shpcnt; + break; + case 3 : // East + east = (atoi(strtok(NULL, " \t,;/")) != 0); + break; + case 11 : // Portable + port = (atoi(strtok(NULL, " \t,;/")) != 0); + break; + case 12 : // Transparent + tran = (atoi(strtok(NULL, " \t,;/")) != 0); + break; + } } - } - } - FunTouch(); - } - Time = SYSTIMERATE; -} - - - - - - - - - - -//-------------------------------------------------------------------------- - - - -/* -static void SpkOpen (void) -{ - asm in al,0x61 - asm or al,0x03 - asm out 0x61,al - asm mov al,0x90 - asm out 0x43,al -} - - - - - -static void SpkClose (void) -{ - asm in al,0x61 - asm and al,0xFC - asm out 0x61,al -} - -*/ - - - -static void SwitchColorMode (void) -{ - SNPOST_(SNSEQ, 121, VGA::Mono = ! VGA::Mono, NULL); - KeyClick(); - VGA::SetColors(SysPal, 64); -} - - - -static void SwitchMusic (void) -{ - if (KEYBOARD::Key[ALT]) - { - if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); - else - { - SNPOST_(SNSEQ, 122, (Music = false), NULL); - //TODO Change the SNPOST message send to a special way to send function pointer - // SNPOST(SNEXEC, -1, 0, (void *)&SelectSound); - warning("SwitchMusic() - SNPOST"); - } - } - else - { - if (STARTUP::Core < CORE_HIG) SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL); - else - { - SNPOST_(SNSEQ, 122, (Music = ! Music), NULL); - KeyClick(); - } - } - if (Music) LoadMIDI(Now); - else KillMIDI(); -} - - - - - -static void StartCountDown (void) -{ - //SNPOST(SNSEQ, 123, 0, NULL); - SwitchCave(-1); -} - - - - -#ifndef DEMO -static void TakeName (void) -{ - if (GET_TEXT::Ptr) SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr); - else - { - GET_TEXT * tn = new GET_TEXT(Text[GETNAME_PROMPT], UsrFnam, 8, KeyClick); - if (tn) - { - tn->SetName(Text[GETNAME_TITLE]); - tn->Center(); - tn->Goto(tn->X, tn->Y - 10); - tn->Z = 126; - VGA::ShowQ.Insert(tn); + if (! shpcnt) + error("No shapes [%s]", fname); + } else { // no sprite description: mono-shaped sprite with only .BMP file + ++shpcnt; } - } -} -#endif - - - - -#ifdef DEBUG - - -static void SwitchMapping (void) -{ - if (HorzLine.Flags.Hide) - { - int i; - for (i = 0; i < MAP_ZCNT; i ++) - { - int j; - for (j = 0; j < MAP_XCNT; j ++) - { - if (CLUSTER::Map[i][j]) - SetMapBrick(j, i); - } + // make sprite of choosen type + switch (type) { + case 1 : { // AUTO + Sprite = new SPRITE(NULL); + if (Sprite) { + Sprite->Goto(col, row); + //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$ + } + break; } - } - else - { - SPRITE * s; - for (s = VGA::ShowQ.First(); s; s = s->Next) - if (s->W == MAP_XGRID && s->H == MAP_ZGRID) - SNPOST_(SNKILL, -1, 0, s); - } - HorzLine.Flags.Hide = ! HorzLine.Flags.Hide; -} - - - - - -static void KillSprite (void) -{ - Sprite->Flags.Kill = true; - Sprite->Flags.BDel = true; - SNPOST_(SNKILL, -1, 0, Sprite); - Sprite = NULL; -} - - - - - -static void PushSprite (void) -{ - SPRITE * spr = Sprite->Prev; - if (spr) - { - VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr); - while (Sprite->Z > Sprite->Next->Z) -- Sprite->Z; - } - else SNPOST_(SNSOUND, -1, 2, NULL); -} - - - - - -static void PullSprite (void) -{ - bool ok = false; - SPRITE * spr = Sprite->Next; - if (spr) - { - spr = spr->Next; - if (spr) - { - ok = (! spr->Flags.Slav); + case 2 : { // WALK + WALK *w = new WALK(NULL); + if (w && ref == 1) { + w->Goto(col, row); + if (Hero) + error("2nd HERO [%s]", fname); + Hero = w; + } + Sprite = w; + break; } - } - if (ok) - { - VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr); - if (Sprite->Prev) - while (Sprite->Z < Sprite->Prev->Z) ++ Sprite->Z; - } - else SNPOST_(SNSOUND, -1, 2, NULL); -} - - - - - - -static void NextStep (void) -{ - SNPOST_(SNSTEP, 0, 0, Sprite); -} - - - - - - - - - -static void SaveMapping (void) -{ - { - IOHAND cf(ProgName(".TAB"), UPD); - if (! cf.Error) - { - cf.Seek((Now-1) * sizeof(CLUSTER::Map)); - cf.Write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); - } - } - { - IOHAND cf(ProgName(".HXY"), WRI); - if (! cf.Error) - { - HeroXY[Now-1].X = Hero->X; - HeroXY[Now-1].Y = Hero->Y; - cf.Write((uint8 *) HeroXY, sizeof(HeroXY)); - } - } -} - -#endif - - - -//-------------------------------------------------------------------------- - - - - - - - - - -#ifdef DEBUG - - - - // 1111111111222222222233333333 334444444444555555555566666666667777777777 - // 01234567890123456789012345678901234567 890123456789012345678901234567890123456789 -static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 000:000:000 000:000 00 "; - -#define NFRE (DebugText + 3) -#define FFRE (DebugText + 11) -#define ABSX (DebugText + 20) -#define ABSY (DebugText + 26) -#define FRPS (DebugText + 34) -#define XSPR (DebugText + 38) -#define SP_N (DebugText + 41) -#define SP_S (DebugText + 44) - -#define SP_X (DebugText + 47) -#define SP_Y (DebugText + 51) -#define SP_Z (DebugText + 55) -#define SP_W (DebugText + 59) -#define SP_H (DebugText + 63) -#define SP_F (DebugText + 67) -#define SP__ (DebugText + 70) - -INFO_LINE DebugLine(SCR_WID); - -static void SayDebug (void) -{ - if (! DebugLine.Flags.Hide) - { - static long t = -1L; - long t1 = Timer(); - - if (t1 - t >= 18) + /* + case 3 : // NEWTON + NEWTON * n = new NEWTON(NULL); + if (n) { - static uint32 old = 0L; - uint32 now = Vga.FrmCnt; - dwtom(now - old, FRPS, 10, 4); - old = now; - t = t1; + n->Ay = (bottom-n->H); + n->By = 90; + n->Cy = 3; + n->Bx = 99; + n->Cx = 3; + n->Goto(col, row); + } + Sprite = n; + break; + */ + case 4 : { // LISSAJOUS + error("Bad type [%s]", fname); + /* + LISSAJOUS * l = new LISSAJOUS(NULL); + if (l) + { + l->Ax = SCR_WID/2; + l->Ay = SCR_HIG/2; + l->Bx = 7; + l->By = 13; + l->Cx = 300; + l->Cy = 500; + * (long *) &l->Dx = 0; // movex * cnt + l->Goto(col, row); + } + Sprite = l; + */ + break; } - - dwtom(Mouse.X, ABSX, 10, 3); - dwtom(Mouse.Y, ABSY, 10, 3); - dwtom(coreleft(), NFRE, 10, 5); - dwtom(farcoreleft(), FFRE, 10, 6); - - // sprite queue size - uint16 n = 0; - SPRITE * spr; - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) - { - ++ n; - if (spr == Sprite) - { - *XSPR = ' '; - dwtom(n, SP_N, 10, 2); - dwtom(Sprite->X, SP_X, 10, 3); - dwtom(Sprite->Y, SP_Y, 10, 3); - dwtom(Sprite->Z, SP_Z, 10, 3); - dwtom(Sprite->W, SP_W, 10, 3); - dwtom(Sprite->H, SP_H, 10, 3); - dwtom(*(uint16 *) (&Sprite->Flags), SP_F, 16, 2); - } + case 5 : { // FLY + FLY *f = new FLY(NULL); + Sprite = f; + //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$ + break; } - dwtom(n, SP_S, 10, 2); - *SP__ = (heapcheck() < 0) ? '!' : ' '; - DebugLine.Update(DebugText); - } -} - - - - - -static void SwitchDebug (void) -{ - DebugLine.Flags.Hide = ! DebugLine.Flags.Hide; -} - - - -#endif - - - - - - -static void OptionTouch (int opt, uint16 mask) -{ - switch (opt) - { - case 1 : if (mask & L_UP) SwitchColorMode(); break; - case 2 : if (mask & L_UP) SwitchMusic(); - else - if (mask & R_UP) - if (! MIXER::Appear) - { - MIXER::Appear = true; - new MIXER(BUTTON_X, BUTTON_Y); - } - break; - case 3 : if (mask & L_UP) Quit(); break; - } -} - - - - - -#pragma argsused -void SPRITE::Touch (uint16 mask, int x, int y) -{ - SYSTEM::FunTouch(); - if ((mask & ATTN) == 0) - { - InfoLine.Update(Name()); - if (mask & (R_DN | L_DN)) Sprite = this; // DEBUG mode only? - if (Ref/10 == 12) - { - OptionTouch(Ref % 10, mask); - return; + default: { // DEAD + Sprite = new SPRITE(NULL); + if (Sprite) + Sprite->Goto(col, row); + break; } - if (Flags.Syst) return; // cannot access system sprites - if (Game) if (mask & L_UP) { mask &= ~L_UP; mask |= R_UP; } - if ((mask & R_UP) && Snail.Idle()) - { - SPRITE * ps = (PocLight.SeqPtr) ? Pocket[PocPtr] : NULL; - if (ps) - { - if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) - { - if (Works(ps)) - { - FeedSnail(ps, TAKE); - } - else OffUse(); - SelectPocket(-1); - } - else TooFar(); - } - else - { - if (Flags.Kept) mask |= L_UP; - else - { - if (Hero->Distance(this) < MAX_DISTANCE) - {/// - if (Flags.Port) - { - if (FindPocket(NULL) < 0) PocFul(); - else - { - SNPOST(SNREACH, -1, -1, this); - SNPOST(SNKEEP, -1, -1, this); - Flags.Port = false; - } - } - else - { - if (TakePtr != NO_PTR) - { - if (SnList(TAKE)[TakePtr].Com == SNNEXT) OffUse(); - else FeedSnail(this, TAKE); - } - else OffUse(); - } - }/// - else TooFar(); - } - } } - if ((mask & L_UP) && Snail.Idle()) - { - if (Flags.Kept) - { - int n; - for (n = 0; n < POCKET_NX; n ++) - { - if (Pocket[n] == this) - { - SelectPocket(n); - break; - } - } - } - else SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this); + if (Sprite) { + Sprite->Ref = ref; + Sprite->Cave = cav; + Sprite->Z = pos; + Sprite->Flags.East = east; + Sprite->Flags.Port = port; + Sprite->Flags.Tran = tran; + Sprite->Flags.Kill = true; + Sprite->Flags.BDel = true; + //fnsplit(fname, NULL, NULL, Sprite->File, NULL); + warning("LoadSprite: use of fnsplit"); + + Sprite->ShpCnt = shpcnt; + VGA::SpareQ.Append(Sprite); } - } } +static void LoadScript(const char *fname) { + char line[LINE_MAX]; + char *SpN; + int SpI, SpA, SpX, SpY, SpZ; + bool BkG = false; + INI_FILE scrf(fname); + int lcnt = 0; + bool ok = true; + if (scrf.Error) + return; + while (scrf.Read((uint8 *)line) != 0) { + char *p; + ++lcnt; + if (*line == 0 || *line == '\n' || *line == '.') + continue; - -//-------------------------------------------------------------------------- -//-------------------------------------------------------------------------- - - - - - - -static void LoadSprite (const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) -{ - static const char * Comd[] = { "Name", "Type", "Phase", "East", - "Left", "Right", "Top", "Bottom", - "Seq", "Near", "Take", - "Portable", "Transparent", - NULL }; - static const char * Type[] = { "DEAD", "AUTO", "WALK", "NEWTON", "LISSAJOUS", - "FLY", NULL }; - char line[LINE_MAX]; - - int shpcnt = 0; - int type = 0; // DEAD - bool east = false; - bool port = false; - bool tran = false; - int i, lcnt = 0; - uint16 len; - - MergeExt(line, fname, SPR_EXT); - if (INI_FILE::Exist(line)) // sprite description file exist - { - INI_FILE sprf(line); - if (sprf.Error) { - error("Bad SPR [%s]", line); - } - - while ((len = sprf.Read((uint8*)line)) != 0) - { - ++ lcnt; - if (len && line[len-1] == '\n') line[-- len] = '\0'; - if (len == 0 || *line == '.') continue; - - if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) { - error("%s [%s]", NumStr("Bad line ######", lcnt), fname); - } - - switch (i) - { - case 0 : // Name - will be taken in Expand routine + ok = false; // not OK if break + // sprite ident number + if ((p = strtok(line, " \t\n")) == NULL) break; - case 1 : // Type - if ((type = TakeEnum(Type, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad line ######", lcnt), fname); + SpI = atoi(p); + // sprite file name + if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) break; - case 2 : // Phase - ++ shpcnt; + // sprite cave + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - case 3 : // East - east = (atoi(strtok(NULL, " \t,;/")) != 0); + SpA = atoi(p); + // sprite column + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - case 11 : // Portable - port = (atoi(strtok(NULL, " \t,;/")) != 0); + SpX = atoi(p); + // sprite row + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - case 12 : // Transparent - tran = (atoi(strtok(NULL, " \t,;/")) != 0); + SpY = atoi(p); + // sprite Z pos + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - } - } - if (! shpcnt) - error("No shapes [%s]", fname); - } - else // no sprite description: mono-shaped sprite with only .BMP file - { - ++ shpcnt; - } - - // make sprite of choosen type - switch (type) - { - case 1 : // AUTO - { - Sprite = new SPRITE(NULL); - if (Sprite) - { - Sprite->Goto(col, row); - //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$ - } - break; - } - case 2 : // WALK - { - WALK * w = new WALK(NULL); - if (w && ref == 1) - { - w->Goto(col, row); - if (Hero) - error("2nd HERO [%s]", fname); - Hero = w; - } - Sprite = w; - break; - } - /* - case 3 : // NEWTON - NEWTON * n = new NEWTON(NULL); - if (n) - { - n->Ay = (bottom-n->H); - n->By = 90; - n->Cy = 3; - n->Bx = 99; - n->Cx = 3; - n->Goto(col, row); - } - Sprite = n; - break; - */ - case 4 : // LISSAJOUS - { - error("Bad type [%s]", fname); - /* - LISSAJOUS * l = new LISSAJOUS(NULL); - if (l) - { - l->Ax = SCR_WID/2; - l->Ay = SCR_HIG/2; - l->Bx = 7; - l->By = 13; - l->Cx = 300; - l->Cy = 500; - * (long *) &l->Dx = 0; // movex * cnt - l->Goto(col, row); - } - Sprite = l; - */ - break; - } - case 5 : // FLY - { - FLY * f = new FLY(NULL); - Sprite = f; - //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$ - break; - } - default: // DEAD - { - Sprite = new SPRITE(NULL); - if (Sprite) Sprite->Goto(col, row); - break; - } - } - if (Sprite) - { - Sprite->Ref = ref; - Sprite->Cave = cav; - Sprite->Z = pos; - Sprite->Flags.East = east; - Sprite->Flags.Port = port; - Sprite->Flags.Tran = tran; - Sprite->Flags.Kill = true; - Sprite->Flags.BDel = true; - //fnsplit(fname, NULL, NULL, Sprite->File, NULL); - warning("LoadSprite: use of fnsplit"); - - Sprite->ShpCnt = shpcnt; - VGA::SpareQ.Append(Sprite); - } -} - - - - - - -static void LoadScript (const char *fname) -{ - char line[LINE_MAX]; - char * SpN; - int SpI, SpA, SpX, SpY, SpZ; - bool BkG = false; - INI_FILE scrf(fname); - int lcnt = 0; - bool ok = true; - - if (scrf.Error) return; - - while (scrf.Read((uint8*)line) != 0) - { - char *p; - - ++ lcnt; - if (*line == 0 || *line == '\n' || *line == '.') continue; - - ok = false; // not OK if break - // sprite ident number - if ((p = strtok(line, " \t\n")) == NULL) break; - SpI = atoi(p); - // sprite file name - if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) break; - // sprite cave - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - SpA = atoi(p); - // sprite column - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - SpX = atoi(p); - // sprite row - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - SpY = atoi(p); - // sprite Z pos - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - SpZ = atoi(p); - // sprite life - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - BkG = atoi(p) == 0; - - ok = true; // no break: OK - - Sprite = NULL; - LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); - if (Sprite && BkG) Sprite->Flags.Back = true; - } - if (! ok) - error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname); -} - - - - -static void MainLoop (void) -{ -#if 0 -//def DEBUG - static VgaRegBlk Mode[] = { - - { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode - - { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 - { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 - { 0x06, VGAGRA, 0x02, 0x00 }, // misc + SpZ = atoi(p); + // sprite life + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + break; + BkG = atoi(p) == 0; - { 0x14, VGACRT, 0x40, 0x00 }, // underline - { 0x13, VGACRT, 0xFF, 0x28 }, // screen width - { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control + ok = true; // no break: OK - { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end - { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line + Sprite = NULL; + LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); + if (Sprite && BkG) + Sprite->Flags.Back = true; + } + if (! ok) + error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname); +} - { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode -// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end -// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb -// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr +static void MainLoop(void) { +#if 0 +//def DEBUG + static VgaRegBlk Mode[] = { - { 0x00 } }; + { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode - Vga.Setup(Mode); -#endif + { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 + { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 + { 0x06, VGAGRA, 0x02, 0x00 }, // misc - Debug( SayDebug(); ) + { 0x14, VGACRT, 0x40, 0x00 }, // underline + { 0x13, VGACRT, 0xFF, 0x28 }, // screen width + { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control - #ifdef DEMO - #define TIM ((182L*6L) * 5L) - static uint32 tc = 0; - if (TimerCount - tc >= TIM && Talk == NULL && Snail.Idle()) - { - if (Text[DemoText]) - { - SNPOST(SNSOUND, -1, 4, NULL); // drumla - SNPOST(SNINF, -1, DemoText, NULL); - SNPOST(SNLABEL, -1, -1, NULL); - if (Text[++ DemoText] == NULL) DemoText = DEMO_TEXT + 1; - } - tc = TimerCount; - } - #undef TIM - #endif + { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end + { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line - Vga.Show(); - Snail_.RunCom(); - Snail.RunCom(); -} + { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode +// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end +// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb +// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr + { 0x00 } + }; + Vga.Setup(Mode); +#endif + Debug(SayDebug();) + +#ifdef DEMO +#define TIM ((182L*6L) * 5L) + static uint32 tc = 0; + if (TimerCount - tc >= TIM && Talk == NULL && Snail.Idle()) { + if (Text[DemoText]) { + SNPOST(SNSOUND, -1, 4, NULL); // drumla + SNPOST(SNINF, -1, DemoText, NULL); + SNPOST(SNLABEL, -1, -1, NULL); + if (Text[++ DemoText] == NULL) DemoText = DEMO_TEXT + 1; + } + tc = TimerCount; + } +#undef TIM +#endif -void LoadUser (void) -{ - // set scene - if (STARTUP::Mode == 0) // user .SVG file found - { - CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt); - LoadGame(cfile); - } - else - { - if (STARTUP::Mode == 1) - { - SVG0FILE file = SVG0FILE(SVG0NAME); - LoadGame(file); - } - else - { - LoadScript(ProgName(INI_EXT)); - Music = true; - CFILE file = CFILE(SVG0NAME, WRI); - SaveGame(file); - error("Ok [%s]", SVG0NAME); + Vga.Show(); + Snail_.RunCom(); + Snail.RunCom(); +} + + +void LoadUser(void) { + // set scene + if (STARTUP::Mode == 0) { // user .SVG file found + CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt); + LoadGame(cfile); + } else { + if (STARTUP::Mode == 1) { + SVG0FILE file = SVG0FILE(SVG0NAME); + LoadGame(file); + } else { + LoadScript(ProgName(INI_EXT)); + Music = true; + CFILE file = CFILE(SVG0NAME, WRI); + SaveGame(file); + error("Ok [%s]", SVG0NAME); + } } - } - LoadScript(ProgName(IN0_EXT)); + LoadScript(ProgName(IN0_EXT)); } +static void RunGame(void) { + Text.Clear(); + Text.Preload(100, 1000); + LoadHeroXY(); + CavLight.Flags.Tran = true; + VGA::ShowQ.Append(&CavLight); + CavLight.Flags.Hide = true; + static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 }, + { 1, 2, 0, 0, 4 }, + { 2, 3, 0, 0, 4 }, + { 3, 4, 0, 0, 16 }, + { 2, 5, 0, 0, 4 }, + { 1, 6, 0, 0, 4 }, + { 0, 1, 0, 0, 16 }, + }; + PocLight.SetSeq(PocSeq); + PocLight.Flags.Tran = true; + PocLight.Time = 1; + PocLight.Z = 120; + VGA::ShowQ.Append(&PocLight); + SelectPocket(-1); -static void RunGame (void) -{ - Text.Clear(); - Text.Preload(100, 1000); - LoadHeroXY(); - - CavLight.Flags.Tran = true; - VGA::ShowQ.Append(&CavLight); - CavLight.Flags.Hide = true; - - static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 }, - { 1, 2, 0, 0, 4 }, - { 2, 3, 0, 0, 4 }, - { 3, 4, 0, 0, 16 }, - { 2, 5, 0, 0, 4 }, - { 1, 6, 0, 0, 4 }, - { 0, 1, 0, 0, 16 }, - }; - PocLight.SetSeq(PocSeq); - PocLight.Flags.Tran = true; - PocLight.Time = 1; - PocLight.Z = 120; - VGA::ShowQ.Append(&PocLight); - SelectPocket(-1); - - VGA::ShowQ.Append(&Mouse); + VGA::ShowQ.Append(&Mouse); // ___________ - LoadUser(); + LoadUser(); // ~~~~~~~~~~~ - if ((Sprite = VGA::SpareQ.Locate(121)) != NULL) - SNPOST_(SNSEQ, -1, VGA::Mono, Sprite); - if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) Sprite->Step(Music); - SNPOST_(SNSEQ, -1, Music, Sprite); - if (! Music) KillMIDI(); - - if (Mini && INI_FILE::Exist("MINI.SPR")) - { - uint8 * ptr = (uint8 *) &*Mini; - if (ptr != NULL) - { - LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); - ExpandSprite(MiniCave = Sprite); // NULL is ok - if (MiniCave) - { - MiniCave->Flags.Hide = true; - MiniCave->MoveShapes(ptr); - MiniShp[0] = new BITMAP(*MiniCave->Shp()); - MiniShpList = MiniCave->SetShapeList(MiniShp); - PostMiniStep(-1); - } + if ((Sprite = VGA::SpareQ.Locate(121)) != NULL) + SNPOST_(SNSEQ, -1, VGA::Mono, Sprite); + if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) + Sprite->Step(Music); + SNPOST_(SNSEQ, -1, Music, Sprite); + if (! Music) + KillMIDI(); + + if (Mini && INI_FILE::Exist("MINI.SPR")) { + uint8 *ptr = (uint8 *) &*Mini; + if (ptr != NULL) { + LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); + ExpandSprite(MiniCave = Sprite); // NULL is ok + if (MiniCave) { + MiniCave->Flags.Hide = true; + MiniCave->MoveShapes(ptr); + MiniShp[0] = new BITMAP(*MiniCave->Shp()); + MiniShpList = MiniCave->SetShapeList(MiniShp); + PostMiniStep(-1); + } + } } - } - if (Hero) - { - ExpandSprite(Hero); - Hero->Goto(HeroXY[Now-1].X, HeroXY[Now-1].Y); - if (INI_FILE::Exist("00SHADOW.SPR")) - { - LoadSprite("00SHADOW", -1, 0, Hero->X + 14, Hero->Y + 51); - if ((Shadow = Sprite) != NULL) - { - Shadow->Ref = 2; - Shadow->Flags.Tran = true; - Hero->Flags.Shad = true; - VGA::ShowQ.Insert(VGA::SpareQ.Remove(Shadow), Hero); - } + if (Hero) { + ExpandSprite(Hero); + Hero->Goto(HeroXY[Now - 1].X, HeroXY[Now - 1].Y); + if (INI_FILE::Exist("00SHADOW.SPR")) { + LoadSprite("00SHADOW", -1, 0, Hero->X + 14, Hero->Y + 51); + if ((Shadow = Sprite) != NULL) { + Shadow->Ref = 2; + Shadow->Flags.Tran = true; + Hero->Flags.Shad = true; + VGA::ShowQ.Insert(VGA::SpareQ.Remove(Shadow), Hero); + } + } } - } - - InfoLine.Goto(INFO_X, INFO_Y); - InfoLine.Flags.Tran = true; - InfoLine.Update(NULL); - VGA::ShowQ.Insert(&InfoLine); - - #ifdef DEBUG - DebugLine.Z = 126; - VGA::ShowQ.Insert(&DebugLine); - - HorzLine.Y = MAP_TOP - (MAP_TOP > 0); - HorzLine.Z = 126; - VGA::ShowQ.Insert(&HorzLine); - #endif - Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF); - if (Mouse.Busy) ExpandSprite(Mouse.Busy); + InfoLine.Goto(INFO_X, INFO_Y); + InfoLine.Flags.Tran = true; + InfoLine.Update(NULL); + VGA::ShowQ.Insert(&InfoLine); - Startup = 0; - - SNPOST(SNLEVEL, -1, OldLev, &CavLight); - CavLight.Goto(CAVE_X + ((Now-1) % CAVE_NX) * CAVE_DX + CAVE_SX, - CAVE_Y + ((Now-1) / CAVE_NX) * CAVE_DY + CAVE_SY); - CaveUp(); +#ifdef DEBUG + DebugLine.Z = 126; + VGA::ShowQ.Insert(&DebugLine); - KEYBOARD::SetClient(Sys); - // main loop - while (! Finis) - { - //TODO Change the SNPOST message send to a special way to send function pointer - // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame); - warning("RunGame: problematic use of SNPOST"); - MainLoop(); - } + HorzLine.Y = MAP_TOP - (MAP_TOP > 0); + HorzLine.Z = 126; + VGA::ShowQ.Insert(&HorzLine); +#endif - KEYBOARD::SetClient(NULL); - HEART::Enable = false; - SNPOST(SNCLEAR, -1, 0, NULL); - SNPOST_(SNCLEAR, -1, 0, NULL); - Mouse.Off(); - VGA::ShowQ.Clear(); - VGA::SpareQ.Clear(); - Hero = NULL; - Shadow = NULL; -} + Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF); + if (Mouse.Busy) + ExpandSprite(Mouse.Busy); + Startup = 0; + SNPOST(SNLEVEL, -1, OldLev, &CavLight); + CavLight.Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); + CaveUp(); + KEYBOARD::SetClient(Sys); + // main loop + while (! Finis) { + //TODO Change the SNPOST message send to a special way to send function pointer + // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame); + warning("RunGame: problematic use of SNPOST"); + MainLoop(); + } -void Movie (const char * ext) -{ - const char * fn = ProgName(ext); - if (INI_FILE::Exist(fn)) - { - LoadScript(fn); - ExpandSprite(VGA::SpareQ.Locate(999)); - FeedSnail(VGA::ShowQ.Locate(999), TAKE); - VGA::ShowQ.Append(&Mouse); - HEART::Enable = true; - KEYBOARD::SetClient(Sys); - while (! Snail.Idle()) - { - MainLoop(); + KEYBOARD::SetClient(NULL); + HEART::Enable = false; + SNPOST(SNCLEAR, -1, 0, NULL); + SNPOST_(SNCLEAR, -1, 0, NULL); + Mouse.Off(); + VGA::ShowQ.Clear(); + VGA::SpareQ.Clear(); + Hero = NULL; + Shadow = NULL; +} + + +void Movie(const char *ext) { + const char *fn = ProgName(ext); + if (INI_FILE::Exist(fn)) { + LoadScript(fn); + ExpandSprite(VGA::SpareQ.Locate(999)); + FeedSnail(VGA::ShowQ.Locate(999), TAKE); + VGA::ShowQ.Append(&Mouse); + HEART::Enable = true; + KEYBOARD::SetClient(Sys); + while (! Snail.Idle()) { + MainLoop(); + } + KEYBOARD::SetClient(NULL); + HEART::Enable = false; + SNPOST(SNCLEAR, -1, 0, NULL); + SNPOST_(SNCLEAR, -1, 0, NULL); + VGA::ShowQ.Clear(); + VGA::SpareQ.Clear(); } - KEYBOARD::SetClient(NULL); - HEART::Enable = false; - SNPOST(SNCLEAR, -1, 0, NULL); - SNPOST_(SNCLEAR, -1, 0, NULL); - VGA::ShowQ.Clear(); - VGA::SpareQ.Clear(); - } } +bool ShowTitle(const char *name) { + BITMAP::Pal = SysPal; + BMP_PTR LB[] = { new BITMAP(name), NULL }; + BITMAP::Pal = NULL; + bool usr_ok = false; + SPRITE D(LB); + D.Flags.Kill = true; + D.Flags.BDel = true; + D.Center(); + D.Show(2); + if (STARTUP::Mode == 2) { + Inf(SVG0NAME); + Talk->Show(2); + } + Vga.Sunset(); + VGA::CopyPage(1, 2); + VGA::CopyPage(0, 1); + SelectPocket(-1); + Vga.Sunrise(SysPal); + + if (STARTUP::Mode < 2 && ! STARTUP::SoundOk) { + VGA::CopyPage(1, 2); + VGA::CopyPage(0, 1); + VGA::ShowQ.Append(&Mouse); + HEART::Enable = true; + Mouse.On(); + for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) + MainLoop(); + Mouse.Off(); + HEART::Enable = false; + VGA::ShowQ.Clear(); + VGA::CopyPage(0, 2); + STARTUP::SoundOk = 2; + if (Music) + LoadMIDI(0); + } -bool ShowTitle (const char * name) -{ - BITMAP::Pal = SysPal; - BMP_PTR LB[] = { new BITMAP(name), NULL }; - BITMAP::Pal = NULL; - bool usr_ok = false; - - SPRITE D(LB); - D.Flags.Kill = true; - D.Flags.BDel = true; - D.Center(); - D.Show(2); - - if (STARTUP::Mode == 2) - { - Inf(SVG0NAME); - Talk->Show(2); - } - - Vga.Sunset(); - VGA::CopyPage(1, 2); - VGA::CopyPage(0, 1); - SelectPocket(-1); - Vga.Sunrise(SysPal); - - if (STARTUP::Mode < 2 && ! STARTUP::SoundOk) - { - VGA::CopyPage(1, 2); - VGA::CopyPage(0, 1); - VGA::ShowQ.Append(&Mouse); - HEART::Enable = true; - Mouse.On(); - for (SelectSound(); ! Snail.Idle() || VMENU::Addr; ) MainLoop(); - Mouse.Off(); - HEART::Enable = false; - VGA::ShowQ.Clear(); - VGA::CopyPage(0, 2); - STARTUP::SoundOk = 2; - if (Music) LoadMIDI(0); - } - - if (STARTUP::Mode < 2) - { - #ifdef DEMO - strcpy(UsrFnam, ProgName(SVG_EXT)); - usr_ok = true; - #else - //----------------------------------------- - #ifndef EVA - #ifdef CD - STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; - #else + if (STARTUP::Mode < 2) { +#ifdef DEMO + strcpy(UsrFnam, ProgName(SVG_EXT)); + usr_ok = true; +#else + //----------------------------------------- +#ifndef EVA +#ifdef CD + STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; +#else // Boot * b = ReadBoot(getdisk()); warning("ShowTitle: FIXME ReadBoot"); - Boot * b = ReadBoot(0); - uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; - free(b); - sn -= ((IDENT *)Copr)->disk; - STARTUP::Summa |= Lo(sn) | Hi(sn); - #endif - #endif - //----------------------------------------- - Movie("X00"); // paylist - VGA::CopyPage(1, 2); - VGA::CopyPage(0, 1); - VGA::ShowQ.Append(&Mouse); - //Mouse.On(); - HEART::Enable = true; - for (TakeName(); GET_TEXT::Ptr; ) MainLoop(); - HEART::Enable = false; - if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = true; - if (usr_ok) strcat(UsrFnam, SVG_EXT); - //Mouse.Off(); - VGA::ShowQ.Clear(); - VGA::CopyPage(0, 2); - #endif - if (usr_ok && STARTUP::Mode == 0) - { - const char *n = UsrPath(UsrFnam); - if (CFILE::Exist(n)) - { - CFILE file = CFILE(n, REA, RCrypt); - LoadGame(file, true); // only system vars - VGA::SetColors(SysPal, 64); - Vga.Update(); - if (FINIS) - { - ++ STARTUP::Mode; - FINIS = false; + Boot *b = ReadBoot(0); + uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; + free(b); + sn -= ((IDENT *)Copr)->disk; + STARTUP::Summa |= Lo(sn) | Hi(sn); +#endif +#endif + //----------------------------------------- + Movie("X00"); // paylist + VGA::CopyPage(1, 2); + VGA::CopyPage(0, 1); + VGA::ShowQ.Append(&Mouse); + //Mouse.On(); + HEART::Enable = true; + for (TakeName(); GET_TEXT::Ptr;) + MainLoop(); + HEART::Enable = false; + if (KEYBOARD::Last() == Enter && *UsrFnam) + usr_ok = true; + if (usr_ok) + strcat(UsrFnam, SVG_EXT); + //Mouse.Off(); + VGA::ShowQ.Clear(); + VGA::CopyPage(0, 2); +#endif + if (usr_ok && STARTUP::Mode == 0) { + const char *n = UsrPath(UsrFnam); + if (CFILE::Exist(n)) { + CFILE file = CFILE(n, REA, RCrypt); + LoadGame(file, true); // only system vars + VGA::SetColors(SysPal, 64); + Vga.Update(); + if (FINIS) { + ++ STARTUP::Mode; + FINIS = false; + } + } else + ++STARTUP::Mode; } - } - else ++ STARTUP::Mode; } - } - if (STARTUP::Mode < 2) Movie("X01"); // wink + if (STARTUP::Mode < 2) + Movie("X01"); // wink - VGA::CopyPage(0, 2); + VGA::CopyPage(0, 2); - #ifdef DEMO - return true; - #else - return (STARTUP::Mode == 2 || usr_ok); - #endif +#ifdef DEMO + return true; +#else + return (STARTUP::Mode == 2 || usr_ok); +#endif } - - /* #ifdef DEBUG void StkDump (void) @@ -2257,40 +1908,40 @@ void StkDump (void) */ +void cge_main(void) { + uint16 intStack[STACK_SIZ / 2]; + intStackPtr = intStack; + //Debug( memset((void *) (-K(2)), 0, K(1)); ) + //Debug( memset((void *) (-K(4)), 0, K(1)); ) + memset(Barriers, 0xFF, sizeof(Barriers)); -void cge_main (void) -{ - uint16 intStack[STACK_SIZ/2]; - intStackPtr = intStack; - - //Debug( memset((void *) (-K(2)), 0, K(1)); ) - //Debug( memset((void *) (-K(4)), 0, K(1)); ) - memset(Barriers, 0xFF, sizeof(Barriers)); - - if (! Mouse.Exist) - error("%s", Text[NO_MOUSE_TEXT]); - if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; - - Debug( DebugLine.Flags.Hide = true; ) - Debug( HorzLine.Flags.Hide = true; ) - - //srand((uint16) Timer()); - Sys = new SYSTEM; - - if (Music && STARTUP::SoundOk) LoadMIDI(0); - if (STARTUP::Mode < 2) Movie(LGO_EXT); - if (ShowTitle("WELCOME")) - { - #ifndef DEMO - if (STARTUP::Mode == 1) Movie("X02"); // intro - #endif - RunGame(); - Startup = 2; - if (FINIS) Movie("X03"); - } - else Vga.Sunset(); - error("%s", Text[EXIT_OK_TEXT+FINIS]); + if (! Mouse.Exist) + error("%s", Text[NO_MOUSE_TEXT]); + if (! SVG0FILE::Exist(SVG0NAME)) + STARTUP::Mode = 2; + + Debug(DebugLine.Flags.Hide = true;) + Debug(HorzLine.Flags.Hide = true;) + + //srand((uint16) Timer()); + Sys = new SYSTEM; + + if (Music && STARTUP::SoundOk) + LoadMIDI(0); + if (STARTUP::Mode < 2) + Movie(LGO_EXT); + if (ShowTitle("WELCOME")) { +#ifndef DEMO + if (STARTUP::Mode == 1) Movie("X02"); // intro +#endif + RunGame(); + Startup = 2; + if (FINIS) + Movie("X03"); + } else + Vga.Sunset(); + error("%s", Text[EXIT_OK_TEXT + FINIS]); } } // End of namespace CGE diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 30a07dd67e..a67cd29000 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -25,185 +25,163 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE__ -#define __CGE__ +#ifndef __CGE__ +#define __CGE__ -#include "cge\wav.h" -#include "cge\vga13h.h" +#include "cge\wav.h" +#include "cge\vga13h.h" namespace CGE { -#define TSEQ 96 -#define HTALK (TSEQ+4) -#define TOO_FAR (TSEQ+5) -#define NO_WAY (TSEQ+5) -#define POC_FUL (TSEQ+5) -#define OFF_USE (TSEQ+6) - -#define EXIT_OK_TEXT 40 -#define NOMUSIC_TEXT 98 -#define BADSVG_TEXT 99 -#define OFF_USE_COUNT 600 -#define OFF_USE_TEXT 601 -#define NO_WAY_TEXT 671 -#define TOO_FAR_TEXT 681 -#define POC_FUL_TEXT 691 -#define A_C_D_TEXT 777 - -#define GETNAME_PROMPT 50 -#define GETNAME_TITLE 51 - -#define QUIT_TITLE 200 -#define QUIT_TEXT 201 -#define NOQUIT_TEXT 202 -#define DEMO_TEXT 300 -#define NOSOUND_TEXT 310 - -#define PAN_HIG 40 -#define WORLD_HIG (SCR_HIG-PAN_HIG) - -#define INFO_X 177 -#define INFO_Y 164 -#define INFO_W 140 +#define TSEQ 96 +#define HTALK (TSEQ+4) +#define TOO_FAR (TSEQ+5) +#define NO_WAY (TSEQ+5) +#define POC_FUL (TSEQ+5) +#define OFF_USE (TSEQ+6) + +#define EXIT_OK_TEXT 40 +#define NOMUSIC_TEXT 98 +#define BADSVG_TEXT 99 +#define OFF_USE_COUNT 600 +#define OFF_USE_TEXT 601 +#define NO_WAY_TEXT 671 +#define TOO_FAR_TEXT 681 +#define POC_FUL_TEXT 691 +#define A_C_D_TEXT 777 + +#define GETNAME_PROMPT 50 +#define GETNAME_TITLE 51 + +#define QUIT_TITLE 200 +#define QUIT_TEXT 201 +#define NOQUIT_TEXT 202 +#define DEMO_TEXT 300 +#define NOSOUND_TEXT 310 + +#define PAN_HIG 40 +#define WORLD_HIG (SCR_HIG-PAN_HIG) + +#define INFO_X 177 +#define INFO_Y 164 +#define INFO_W 140 #if defined(DEMO) - #define CAVE_X 4 - #define CAVE_Y 166 - #define CAVE_SX 0 - #define CAVE_SY 0 - #define CAVE_DX 23 - #define CAVE_DY 29 - #define CAVE_NX 3 - #define CAVE_NY 1 -#else - #define CAVE_X 4 - #define CAVE_Y 166 - #define CAVE_SX 0 - #define CAVE_SY 0 - #define CAVE_DX 9 - #define CAVE_DY 10 - #define CAVE_NX 8 - #define CAVE_NY 3 +#define CAVE_X 4 +#define CAVE_Y 166 +#define CAVE_SX 0 +#define CAVE_SY 0 +#define CAVE_DX 23 +#define CAVE_DY 29 +#define CAVE_NX 3 +#define CAVE_NY 1 +#else +#define CAVE_X 4 +#define CAVE_Y 166 +#define CAVE_SX 0 +#define CAVE_SY 0 +#define CAVE_DX 9 +#define CAVE_DY 10 +#define CAVE_NX 8 +#define CAVE_NY 3 #endif -#define BUTTON_X 151 -#define BUTTON_Y 164 -#define BUTTON_DX 19 -#define BUTTON_DY 11 -#define BUTTON_NX 1 -#define BUTTON_NY 3 - -#define MINI_X 86 -#define MINI_Y 162 - -//#define MAP_XCNT 16 -//#define MAP_ZCNT 4 -#define MAP_XCNT 40 -#define MAP_ZCNT 20 -#define MAP_TOP 80 -#define MAP_HIG 80 -#define MAP_XGRID (SCR_WID / MAP_XCNT) -#define MAP_ZGRID (MAP_HIG / MAP_ZCNT) - -//#if SCR_WID % MAP_XGRID -// #error Illegal horizontal grid size or count -//#endif - -//#if MAP_HIG % MAP_ZGRID -// #error Illegal vertical grid size or count -//#endif - -#define LINE_MAX 512 -#define USER_MAX 100 -#define SHP_MAX 1024 -#define STD_DELAY 3 -#define LEV_MAX 5 -#define CAVE_MAX (CAVE_NX*CAVE_NY) -#define MAX_FIND_LEVEL 3 -#define MAX_DISTANCE 3 - -#define INI_EXT ".INI" -#define IN0_EXT ".IN0" -#define LGO_EXT ".LGO" -#define SVG_EXT ".SVG" - -#define WALKSIDE 10 - -#define BUSY_REF 500 - -#define SYSTIMERATE 6 // 12 Hz -#define HEROFUN0 (40*12) -#define HEROFUN1 ( 2*12) -#define PAIN (Flag[0]) -#define FINIS (Flag[3]) - - -//-------------------------------------------------------------------------- - - -class SYSTEM : public SPRITE -{ - int lum; +#define BUTTON_X 151 +#define BUTTON_Y 164 +#define BUTTON_DX 19 +#define BUTTON_DY 11 +#define BUTTON_NX 1 +#define BUTTON_NY 3 + +#define MINI_X 86 +#define MINI_Y 162 + +//#define MAP_XCNT 16 +//#define MAP_ZCNT 4 +#define MAP_XCNT 40 +#define MAP_ZCNT 20 +#define MAP_TOP 80 +#define MAP_HIG 80 +#define MAP_XGRID (SCR_WID / MAP_XCNT) +#define MAP_ZGRID (MAP_HIG / MAP_ZCNT) + +#define LINE_MAX 512 +#define USER_MAX 100 +#define SHP_MAX 1024 +#define STD_DELAY 3 +#define LEV_MAX 5 +#define CAVE_MAX (CAVE_NX*CAVE_NY) +#define MAX_FIND_LEVEL 3 +#define MAX_DISTANCE 3 + +#define INI_EXT ".INI" +#define IN0_EXT ".IN0" +#define LGO_EXT ".LGO" +#define SVG_EXT ".SVG" + +#define WALKSIDE 10 + +#define BUSY_REF 500 + +#define SYSTIMERATE 6 // 12 Hz +#define HEROFUN0 (40*12) +#define HEROFUN1 ( 2*12) +#define PAIN (Flag[0]) +#define FINIS (Flag[3]) + + +class SYSTEM : public SPRITE { + int lum; public: - static int FunDel; - static void SetPal (void); - static void FunTouch (void); - SYSTEM (void) : SPRITE(NULL) { SetPal(); Tick(); } - void Touch (uint16 mask, int x, int y); - void Tick (void); + static int FunDel; + static void SetPal(void); + static void FunTouch(void); + SYSTEM(void) : SPRITE(NULL) { + SetPal(); + Tick(); + } + void Touch(uint16 mask, int x, int y); + void Tick(void); }; - - -//-------------------------------------------------------------------------- - - - - -class CLUSTER : public COUPLE -{ +class CLUSTER : public COUPLE { public: - static uint8 Map[MAP_ZCNT][MAP_XCNT]; - uint8 &Cell (void); - CLUSTER (void) : COUPLE () { } - CLUSTER (int a, int b) : COUPLE (a, b) { } - bool Protected (void); + static uint8 Map[MAP_ZCNT][MAP_XCNT]; + uint8 &Cell(void); + CLUSTER(void) : COUPLE() { } + CLUSTER(int a, int b) : COUPLE(a, b) { } + bool Protected(void); }; - - -class WALK : public SPRITE -{ +class WALK : public SPRITE { public: - CLUSTER Here; - enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; - int TracePtr; - WALK (BMP_PTR * shpl); - void Tick (void); - void FindWay(CLUSTER c); - void FindWay(SPRITE * spr); - int Distance (SPRITE * spr); - void Turn (DIR d); - void Park (void); - bool Lower (SPRITE * spr); - void Reach (SPRITE * spr, int mode = -1); + CLUSTER Here; + enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; + int TracePtr; + WALK(BMP_PTR *shpl); + void Tick(void); + void FindWay(CLUSTER c); + void FindWay(SPRITE *spr); + int Distance(SPRITE *spr); + void Turn(DIR d); + void Park(void); + bool Lower(SPRITE *spr); + void Reach(SPRITE *spr, int mode = -1); }; +CLUSTER XZ(int x, int y); +CLUSTER XZ(COUPLE xy); - CLUSTER XZ (int x, int y); - CLUSTER XZ (COUPLE xy); - - -extern WALK * Hero; +extern WALK *Hero; - void ExpandSprite (SPRITE * spr); - void ContractSprite (SPRITE * spr); - void cge_main(void); +void ExpandSprite(SPRITE *spr); +void ContractSprite(SPRITE *spr); +void cge_main(void); } // End of namespace CGE diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index ee4d1771f9..c1e9ae4762 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -25,11 +25,11 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/config.h" -#include "cge/sound.h" -#include "cge/vmenu.h" -#include "cge/text.h" -#include "cge/cge_main.h" +#include "cge/config.h" +#include "cge/sound.h" +#include "cge/vmenu.h" +#include "cge/text.h" +#include "cge/cge_main.h" namespace CGE { @@ -41,284 +41,255 @@ namespace CGE { 55=wybierz numer portu dla General MIDI 55=konfiguracja karty d¦wi‘kowej */ -#define STYPE_TEXT 51 -#define SPORT_TEXT 52 -#define SIRQ_TEXT 53 -#define SDMA_TEXT 54 -#define MPORT_TEXT 55 -#define MENU_TEXT 56 - -#define NONE_TEXT 60 -#define SB_TEXT 61 -#define SBM_TEXT 62 -#define GUS_TEXT 63 -#define GUSM_TEXT 64 -#define MIDI_TEXT 65 -#define AUTO_TEXT 66 - -#define DETECT 0xFFFF - - -static void NONE (void); -static void SB (void); -static void SBM (void); -static void GUS (void); -static void GUSM (void); -static void MIDI (void); -static void AUTO (void); -static void SetPortD (void); -static void SetPortM (void); -static void SetIRQ (void); -static void SetDMA (void); - - -static int DevName[] = { NONE_TEXT, SB_TEXT, SBM_TEXT, - GUS_TEXT, GUSM_TEXT, - MIDI_TEXT, AUTO_TEXT }; - -static CHOICE DevMenu[]={ { NULL, NONE }, - { NULL, SB }, - { NULL, SBM }, - { NULL, GUS }, - { NULL, GUSM }, - { NULL, MIDI }, - { NULL, AUTO }, - { NULL, NULL } }; - - -static CHOICE DigiPorts[]={ { " 210h", SetPortD }, - { " 220h", SetPortD }, - { " 230h", SetPortD }, - { " 240h", SetPortD }, - { " 250h", SetPortD }, - { " 260h", SetPortD }, - { "AUTO ", SetPortD }, - { NULL, NULL } }; - -static CHOICE MIDIPorts[]={ { " 220h", SetPortM }, - { " 230h", SetPortM }, - { " 240h", SetPortM }, - { " 250h", SetPortM }, - { " 300h", SetPortM }, - { " 320h", SetPortM }, - { " 330h", SetPortM }, - { " 340h", SetPortM }, - { " 350h", SetPortM }, - { " 360h", SetPortM }, - { "AUTO ", SetPortM }, - { NULL, NULL } }; - -static CHOICE BlsterIRQ[]={ { "IRQ 2", SetIRQ }, - { "IRQ 5", SetIRQ }, - { "IRQ 7", SetIRQ }, - { "IRQ 10", SetIRQ }, - { "AUTO ", SetIRQ }, - { NULL, NULL } }; - -static CHOICE GravisIRQ[]={ { "IRQ 2", SetIRQ }, - { "IRQ 5", SetIRQ }, - { "IRQ 7", SetIRQ }, - { "IRQ 11", SetIRQ }, - { "IRQ 12", SetIRQ }, - { "IRQ 15", SetIRQ }, - { "AUTO ", SetIRQ }, - { NULL, NULL } }; - -static CHOICE GravisDMA[]={ { "DMA 1", SetDMA }, - { "DMA 3", SetDMA }, - { "DMA 5", SetDMA }, - { "DMA 6", SetDMA }, - { "DMA 7", SetDMA }, - { "AUTO ", SetDMA }, - { NULL, NULL } }; - -static CHOICE BlsterDMA[]={ { "DMA 0", SetDMA }, - { "DMA 1", SetDMA }, - { "DMA 3", SetDMA }, - { "AUTO ", SetDMA }, - { NULL, NULL } }; - - - - -void SelectSound (void) -{ - int i; - Sound.Close(); - if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); - Inf(Text[STYPE_TEXT]); - Talk->Goto(Talk->X, FONT_HIG/2); - for (i = 0; i < ArrayCount(DevName); i ++) - DevMenu[i].Text = Text[DevName[i]]; - (new VMENU(DevMenu, SCR_WID/2, Talk->Y+Talk->H+TEXT_VM+FONT_HIG))->SetName(Text[MENU_TEXT]); +#define STYPE_TEXT 51 +#define SPORT_TEXT 52 +#define SIRQ_TEXT 53 +#define SDMA_TEXT 54 +#define MPORT_TEXT 55 +#define MENU_TEXT 56 + +#define NONE_TEXT 60 +#define SB_TEXT 61 +#define SBM_TEXT 62 +#define GUS_TEXT 63 +#define GUSM_TEXT 64 +#define MIDI_TEXT 65 +#define AUTO_TEXT 66 + +#define DETECT 0xFFFF + + +static void NONE(void); +static void SB(void); +static void SBM(void); +static void GUS(void); +static void GUSM(void); +static void MIDI(void); +static void AUTO(void); +static void SetPortD(void); +static void SetPortM(void); +static void SetIRQ(void); +static void SetDMA(void); + + +static int DevName[] = { + NONE_TEXT, SB_TEXT, SBM_TEXT, GUS_TEXT, GUSM_TEXT, + MIDI_TEXT, AUTO_TEXT +}; + +static CHOICE DevMenu[] = { + { NULL, NONE }, + { NULL, SB }, + { NULL, SBM }, + { NULL, GUS }, + { NULL, GUSM }, + { NULL, MIDI }, + { NULL, AUTO }, + { NULL, NULL } +}; + + +static CHOICE DigiPorts[] = { + { " 210h", SetPortD }, + { " 220h", SetPortD }, + { " 230h", SetPortD }, + { " 240h", SetPortD }, + { " 250h", SetPortD }, + { " 260h", SetPortD }, + { "AUTO ", SetPortD }, + { NULL, NULL } +}; + +static CHOICE MIDIPorts[] = { + { " 220h", SetPortM }, + { " 230h", SetPortM }, + { " 240h", SetPortM }, + { " 250h", SetPortM }, + { " 300h", SetPortM }, + { " 320h", SetPortM }, + { " 330h", SetPortM }, + { " 340h", SetPortM }, + { " 350h", SetPortM }, + { " 360h", SetPortM }, + { "AUTO ", SetPortM }, + { NULL, NULL } +}; + +static CHOICE BlsterIRQ[] = { + { "IRQ 2", SetIRQ }, + { "IRQ 5", SetIRQ }, + { "IRQ 7", SetIRQ }, + { "IRQ 10", SetIRQ }, + { "AUTO ", SetIRQ }, + { NULL, NULL } +}; + +static CHOICE GravisIRQ[] = { + { "IRQ 2", SetIRQ }, + { "IRQ 5", SetIRQ }, + { "IRQ 7", SetIRQ }, + { "IRQ 11", SetIRQ }, + { "IRQ 12", SetIRQ }, + { "IRQ 15", SetIRQ }, + { "AUTO ", SetIRQ }, + { NULL, NULL } +}; + +static CHOICE GravisDMA[] = { + { "DMA 1", SetDMA }, + { "DMA 3", SetDMA }, + { "DMA 5", SetDMA }, + { "DMA 6", SetDMA }, + { "DMA 7", SetDMA }, + { "AUTO ", SetDMA }, + { NULL, NULL } +}; + +static CHOICE BlsterDMA[] = { + { "DMA 0", SetDMA }, + { "DMA 1", SetDMA }, + { "DMA 3", SetDMA }, + { "AUTO ", SetDMA }, + { NULL, NULL } +}; + + +void SelectSound(void) { + int i; + Sound.Close(); + if (VMENU::Addr) + SNPOST_(SNKILL, -1, 0, VMENU::Addr); + Inf(Text[STYPE_TEXT]); + Talk->Goto(Talk->X, FONT_HIG / 2); + for (i = 0; i < ArrayCount(DevName); i ++) + DevMenu[i].Text = Text[DevName[i]]; + (new VMENU(DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text[MENU_TEXT]); } - - -static void Reset (void) -{ - SNDDrvInfo.DBASE = SNDDrvInfo.DIRQ = SNDDrvInfo.DDMA = SNDDrvInfo.MBASE = DETECT; +static void Reset(void) { + SNDDrvInfo.DBASE = SNDDrvInfo.DIRQ = SNDDrvInfo.DDMA = SNDDrvInfo.MBASE = DETECT; } - - - -static uint16 deco (const char * str, uint16 (*dco)(const char *)) -{ - while (*str && ! IsDigit(*str)) ++ str; - if (*str) return dco(str); - else return DETECT; +static uint16 deco(const char *str, uint16(*dco)(const char *)) { + while (*str && ! IsDigit(*str)) + ++str; + if (*str) + return dco(str); + else + return DETECT; } - - -static uint16 ddeco (const char * str) -{ - return deco(str, atow); +static uint16 ddeco(const char *str) { + return deco(str, atow); } - - -static uint16 xdeco (const char * str) -{ - return deco(str, xtow); +static uint16 xdeco(const char *str) { + return deco(str, xtow); } +static CHOICE *Cho; +static int Hlp; - -static CHOICE * Cho; -static int Hlp; - -static void SNSelect (void) -{ - Inf(Text[Hlp]); - Talk->Goto(Talk->X, FONT_HIG / 2); - (new VMENU(Cho, SCR_WID/2, Talk->Y+Talk->H+TEXT_VM+FONT_HIG))->SetName(Text[MENU_TEXT]); +static void SNSelect(void) { + Inf(Text[Hlp]); + Talk->Goto(Talk->X, FONT_HIG / 2); + (new VMENU(Cho, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text[MENU_TEXT]); } - - -static void Select (CHOICE * cho, int hlp) -{ - Cho = cho; - Hlp = hlp; - //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect); - warning("STUB: Select"); +static void Select(CHOICE *cho, int hlp) { + Cho = cho; + Hlp = hlp; + //TODO Change the SNPOST message send to a special way to send function pointer + //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect); + warning("STUB: Select"); } - - - - -static void NONE (void) -{ - SNDDrvInfo.DDEV = DEV_QUIET; - SNDDrvInfo.MDEV = DEV_QUIET; - Sound.Open(); +static void NONE(void) { + SNDDrvInfo.DDEV = DEV_QUIET; + SNDDrvInfo.MDEV = DEV_QUIET; + Sound.Open(); } - -static void SB (void) -{ - SNDDrvInfo.DDEV = DEV_SB; - SNDDrvInfo.MDEV = DEV_SB; - Reset(); - Select(DigiPorts, SPORT_TEXT); +static void SB(void) { + SNDDrvInfo.DDEV = DEV_SB; + SNDDrvInfo.MDEV = DEV_SB; + Reset(); + Select(DigiPorts, SPORT_TEXT); } - -static void SBM (void) -{ - SNDDrvInfo.DDEV = DEV_SB; - SNDDrvInfo.MDEV = DEV_GM; - Reset(); - Select(DigiPorts, SPORT_TEXT); +static void SBM(void) { + SNDDrvInfo.DDEV = DEV_SB; + SNDDrvInfo.MDEV = DEV_GM; + Reset(); + Select(DigiPorts, SPORT_TEXT); } -static void GUS (void) -{ - SNDDrvInfo.DDEV = DEV_GUS; - SNDDrvInfo.MDEV = DEV_GUS; - Reset(); - Select(DigiPorts, SPORT_TEXT); +static void GUS(void) { + SNDDrvInfo.DDEV = DEV_GUS; + SNDDrvInfo.MDEV = DEV_GUS; + Reset(); + Select(DigiPorts, SPORT_TEXT); } - -static void GUSM (void) -{ - SNDDrvInfo.DDEV = DEV_GUS; - SNDDrvInfo.MDEV = DEV_GM; - Reset(); - Select(DigiPorts, SPORT_TEXT); +static void GUSM(void) { + SNDDrvInfo.DDEV = DEV_GUS; + SNDDrvInfo.MDEV = DEV_GM; + Reset(); + Select(DigiPorts, SPORT_TEXT); } -static void MIDI (void) -{ - SNDDrvInfo.DDEV = DEV_QUIET; - SNDDrvInfo.MDEV = DEV_GM; - SNDDrvInfo.MBASE = DETECT; - Select(MIDIPorts, MPORT_TEXT); +static void MIDI(void) { + SNDDrvInfo.DDEV = DEV_QUIET; + SNDDrvInfo.MDEV = DEV_GM; + SNDDrvInfo.MBASE = DETECT; + Select(MIDIPorts, MPORT_TEXT); } - -static void AUTO (void) -{ - SNDDrvInfo.DDEV = DEV_AUTO; - SNDDrvInfo.MDEV = DEV_AUTO; - Reset(); - Sound.Open(); +static void AUTO(void) { + SNDDrvInfo.DDEV = DEV_AUTO; + SNDDrvInfo.MDEV = DEV_AUTO; + Reset(); + Sound.Open(); } - - - - -static void SetPortD (void) -{ - SNDDrvInfo.DBASE = xdeco(DigiPorts[VMENU::Recent].Text); - Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); +static void SetPortD(void) { + SNDDrvInfo.DBASE = xdeco(DigiPorts[VMENU::Recent].Text); + Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); } - -static void SetPortM (void) -{ - SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text); - Sound.Open(); +static void SetPortM(void) { + SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text); + Sound.Open(); } - - -static void SetIRQ (void) -{ - SNDDrvInfo.DIRQ = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); - Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); +static void SetIRQ(void) { + SNDDrvInfo.DIRQ = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); + Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); } - - -static void SetDMA (void) -{ - SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); - if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) Select(MIDIPorts, MPORT_TEXT); - else Sound.Open(); +static void SetDMA(void) { + SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); + if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) + Select(MIDIPorts, MPORT_TEXT); + else + Sound.Open(); } } // End of namespace CGE diff --git a/engines/cge/config.h b/engines/cge/config.h index 1e692afc4d..e3fe094681 100644 --- a/engines/cge/config.h +++ b/engines/cge/config.h @@ -25,12 +25,12 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CONFIG__ -#define __CONFIG__ +#ifndef __CONFIG__ +#define __CONFIG__ namespace CGE { -void SelectSound (void); +void SelectSound(void); } // End of namespace CGE diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index 7d7a82a82b..f522f872c9 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -52,7 +52,7 @@ static const ADGameDescription gameDescriptions[] = { "soltys", "Soltys Freeware", { {"vol.cat", 0, "0c33e2c304821a2444d297fc5e2d67c6", 50176}, - {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8437676}, + {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8437676}, AD_LISTEND }, Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE @@ -145,7 +145,9 @@ void CGEMetaEngine::removeSaveState(const char *target, int slot) const { g_system->getSavefileManager()->removeSavefile(fileName); } -int CGEMetaEngine::getMaximumSaveSlot() const { return 99; } +int CGEMetaEngine::getMaximumSaveSlot() const { + return 99; +} SaveStateList CGEMetaEngine::listSaves(const char *target) const { Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); @@ -249,7 +251,7 @@ bool CGEMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameD } #if PLUGIN_ENABLED_DYNAMIC(CGE) - REGISTER_PLUGIN_DYNAMIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine); +REGISTER_PLUGIN_DYNAMIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine); #else - REGISTER_PLUGIN_STATIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine); +REGISTER_PLUGIN_STATIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine); #endif diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index abf118bda2..b654000553 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -24,217 +24,203 @@ * This code is based on original Soltys source code * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ - + #include "cge/general.h" namespace CGE { -#define EMS_INT 0x67 -#define PAGE_MASK 0x3FFF -#define SIZ(n) ((n) ? ((long)n) : (0x10000L)) +#define EMS_INT 0x67 +#define PAGE_MASK 0x3FFF +#define SIZ(n) ((n) ? ((long)n) : (0x10000L)) -enum EMM_FUN { GET_STATUS = 0x40, - GET_FRAME, - GET_SIZE, - OPEN_HANDLE, - MAP_PAGE, - CLOSE_HANDLE, - GET_VER, - SAVE_CONTEXT, - REST_CONTEXT, - GET_PAGES = 0x4B, - GET_HANDLES, - GET_INFO, - CONTROL }; +enum EMM_FUN { + GET_STATUS = 0x40, GET_FRAME, GET_SIZE, OPEN_HANDLE, MAP_PAGE, + CLOSE_HANDLE, GET_VER, SAVE_CONTEXT, REST_CONTEXT, GET_PAGES = 0x4B, + GET_HANDLES, GET_INFO, CONTROL +}; void *EMM::Frame = NULL; -EMM::EMM (long size): Han(-1), Top(0), Lim(0), List(NULL) { -/* - if (Test()) - { - asm mov ah,GET_FRAME // get EMS frame segment - asm int EMS_INT // do it! - asm or ah,ah // see status - asm jnz xit // abort on error - Frame = (void _seg *) _BX; // save frame segment - - if (size == 0) - { - asm mov ah,GET_SIZE // get EMS memory size - asm int EMS_INT // do it! - asm or ah,ah // see status - asm jnz xit // abort on error - asm or bx,bx // test page count - asm jz xit // abort if no free pages - // number of available pages in BX is ready to use by OPEN - } - else _BX = (uint16) ((size + PAGE_MASK) >> 14); - asm mov ah,OPEN_HANDLE // open EMM handle - asm int EMS_INT // do it! - asm or ah,ah // see status - asm jnz xit // abort on error - Han = _DX; - Lim = _BX; - Lim <<= 14; - _DX = Han; - asm mov ah,SAVE_CONTEXT // save mapping context - asm int EMS_INT // do it! - } - xit: -*/ +EMM::EMM(long size): Han(-1), Top(0), Lim(0), List(NULL) { + /* + if (Test()) + { + asm mov ah,GET_FRAME // get EMS frame segment + asm int EMS_INT // do it! + asm or ah,ah // see status + asm jnz xit // abort on error + Frame = (void _seg *) _BX; // save frame segment + + if (size == 0) + { + asm mov ah,GET_SIZE // get EMS memory size + asm int EMS_INT // do it! + asm or ah,ah // see status + asm jnz xit // abort on error + asm or bx,bx // test page count + asm jz xit // abort if no free pages + // number of available pages in BX is ready to use by OPEN + } + else _BX = (uint16) ((size + PAGE_MASK) >> 14); + asm mov ah,OPEN_HANDLE // open EMM handle + asm int EMS_INT // do it! + asm or ah,ah // see status + asm jnz xit // abort on error + Han = _DX; + Lim = _BX; + Lim <<= 14; + _DX = Han; + asm mov ah,SAVE_CONTEXT // save mapping context + asm int EMS_INT // do it! + } + xit: + */ warning("STUB: EMM:EMM"); } EMM::~EMM(void) { -/* - Release(); - if (Han >= 0) - { - _DX = Han; - asm mov ah,REST_CONTEXT - asm int EMS_INT - asm mov ah,CLOSE_HANDLE - asm int EMS_INT - } -*/ + /* + Release(); + if (Han >= 0) + { + _DX = Han; + asm mov ah,REST_CONTEXT + asm int EMS_INT + asm mov ah,CLOSE_HANDLE + asm int EMS_INT + } + */ warning("STUB: EMM::~EMM"); } - bool EMM::Test(void) { -/* - static char e[] = "EMMXXXX0"; - - asm mov ax,0x3D40 - asm mov dx,offset e - asm int 0x21 - asm jc fail - - asm push ax - asm mov bx,ax - asm mov ax,0x4407 - asm int 0x21 - - asm pop bx - asm push ax - asm mov ax,0x3E00 - asm int 0x21 - asm pop ax - - asm cmp al,0x00 - asm je fail - - success: - return TRUE; - fail: - return FALSE; -*/ + /* + static char e[] = "EMMXXXX0"; + + asm mov ax,0x3D40 + asm mov dx,offset e + asm int 0x21 + asm jc fail + + asm push ax + asm mov bx,ax + asm mov ax,0x4407 + asm int 0x21 + + asm pop bx + asm push ax + asm mov ax,0x3E00 + asm int 0x21 + asm pop ax + + asm cmp al,0x00 + asm je fail + + success: + return TRUE; + fail: + return FALSE; + */ warning("EMM::Test"); return FALSE; } -EMS * EMM::Alloc (uint16 siz) { -/* - long size = SIZ(siz), - top = Top; - - uint16 pgn = (uint16) (top >> 14), - cnt = (uint16) ((top + size + PAGE_MASK) >> 14) - pgn; +EMS *EMM::Alloc(uint16 siz) { + /* + long size = SIZ(siz), + top = Top; - if (cnt > 4) - { - top = (top + PAGE_MASK) & 0xFFFFC000L; - ++ pgn; - -- cnt; - } + uint16 pgn = (uint16) (top >> 14), + cnt = (uint16) ((top + size + PAGE_MASK) >> 14) - pgn; - if (size <= Lim - top) - { - EMS * e = new EMS, * f; + if (cnt > 4) + { + top = (top + PAGE_MASK) & 0xFFFFC000L; + ++ pgn; + -- cnt; + } - if (e) - { - Top = (e->Ptr = top) + (e->Siz = siz); - e->Emm = this; + if (size <= Lim - top) + { + EMS * e = new EMS, * f; - if (List) + if (e) { - for (f = List; f->Nxt; f = f->Nxt); - return (f->Nxt = e); // existing list: link to the end + Top = (e->Ptr = top) + (e->Siz = siz); + e->Emm = this; + + if (List) + { + for (f = List; f->Nxt; f = f->Nxt); + return (f->Nxt = e); // existing list: link to the end + } + else + { + return (List = e); // empty list: link to the head + } } - else - { - return (List = e); // empty list: link to the head } - } - } - fail: return NULL; -*/ + fail: return NULL; + */ warning("STUB: EMM::Alloc"); return NULL; } -void EMM::Release (void) { - while (List) - { - EMS * e = List; - List = e->Nxt; - delete e; - } - Top = 0; +void EMM::Release(void) { + while (List) { + EMS *e = List; + List = e->Nxt; + delete e; + } + Top = 0; } -EMS::EMS (void) -: Ptr(0), Siz(0), Nxt(NULL) -{ +EMS::EMS(void) : Ptr(0), Siz(0), Nxt(NULL) { } -void * EMS::operator & () const -{ -/* - uint16 pgn = (uint16) (Ptr >> 14), - off = (uint16) Ptr & PAGE_MASK, - cnt = (uint16) ((Ptr + SIZ(Siz) + PAGE_MASK) >> 14) - pgn, - cmd = MAP_PAGE << 8; - - _DX = Emm->Han; // take EMM handle - asm dec cnt // prapare for deferred checking - asm or dx,dx // see if valid - asm jns more // negative handle = unavailable - - fail: return NULL; - - more: - asm mov ax,cmd // command + page frame index - asm mov bx,pgn // logical page number - asm int EMS_INT // do it! - asm or ah,ah // check error code - asm jnz fail // exit on error - asm inc cmd // advance page frame index - asm inc pgn // advance logical page number - asm cmp al,byte ptr cnt // all pages? - asm jb more - - return (void *) (EMM::Frame + (void *) off); -*/ +void *EMS::operator & () const { + /* + uint16 pgn = (uint16) (Ptr >> 14), + off = (uint16) Ptr & PAGE_MASK, + cnt = (uint16) ((Ptr + SIZ(Siz) + PAGE_MASK) >> 14) - pgn, + cmd = MAP_PAGE << 8; + + _DX = Emm->Han; // take EMM handle + asm dec cnt // prapare for deferred checking + asm or dx,dx // see if valid + asm jns more // negative handle = unavailable + + fail: return NULL; + + more: + asm mov ax,cmd // command + page frame index + asm mov bx,pgn // logical page number + asm int EMS_INT // do it! + asm or ah,ah // check error code + asm jnz fail // exit on error + asm inc cmd // advance page frame index + asm inc pgn // advance logical page number + asm cmp al,byte ptr cnt // all pages? + asm jb more + + return (void *) (EMM::Frame + (void *) off); + */ warning("STUB: EMS::operator &"); return NULL; } -uint16 EMS::Size (void) -{ - return Siz; +uint16 EMS::Size(void) { + return Siz; } } // End of namespace CGE diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 86e1324e0b..25af315d98 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -25,96 +25,70 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/game.h" -#include "cge/mouse.h" -#include -#include +#include "cge/game.h" +#include "cge/mouse.h" +#include +#include namespace CGE { - - -uint8 * Glass (DAC * pal, uint8 r, uint8 g, uint8 b) -{ - uint8 * x = new uint8[256]; - if (x) - { - uint16 i; - for (i = 0; i < 256; i ++) - { - x[i] = Closest(pal, MkDAC(((uint16)(pal[i].R) * r) / 255, - ((uint16)(pal[i].G) * g) / 255, - ((uint16)(pal[i].B) * b) / 255)); +uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b) { + uint8 *x = new uint8[256]; + if (x) { + uint16 i; + for (i = 0; i < 256; i ++) { + x[i] = Closest(pal, MkDAC(((uint16)(pal[i].R) * r) / 255, + ((uint16)(pal[i].G) * g) / 255, + ((uint16)(pal[i].B) * b) / 255)); + } } - } - return x; + return x; } - - - -uint8 * Mark (DAC * pal) -{ - #define f(c) (c ^ 63) - uint8 * x = new uint8[256]; - if (x) - { - uint16 i; - for (i = 0; i < 256; i ++) - { - x[i] = Closest(pal, MkDAC(f(pal[i].R), - f(pal[i].G), - f(pal[i].B)) ); +uint8 *Mark(DAC *pal) { +#define f(c) (c ^ 63) + uint8 *x = new uint8[256]; + if (x) { + uint16 i; + for (i = 0; i < 256; i ++) { + x[i] = Closest(pal, MkDAC(f(pal[i].R), + f(pal[i].G), + f(pal[i].B))); + } } - } - return x; - #undef f + return x; +#undef f } +int FLY::L = 20, + FLY::T = 40, + FLY::R = 110, + FLY::B = 100; - -//-------------------------------------------------------------------------- - - - -int FLY::L = 20, - FLY::T = 40, - FLY::R = 110, - FLY::B = 100; - - - -FLY::FLY (BITMAP ** shpl) -: SPRITE(shpl), Tx(0), Ty(0) -{ - Step(new_random(2)); - Goto(L + new_random(R - L - W), T + new_random(B - T - H)); +FLY::FLY(BITMAP **shpl) + : SPRITE(shpl), Tx(0), Ty(0) { + Step(new_random(2)); + Goto(L + new_random(R - L - W), T + new_random(B - T - H)); } - - -void FLY::Tick (void) -{ - Step(); - if (! Flags.Kept) - { - if (new_random(10) < 1) - { - Tx = new_random(3) - 1; - Ty = new_random(3) - 1; +void FLY::Tick(void) { + Step(); + if (! Flags.Kept) { + if (new_random(10) < 1) { + Tx = new_random(3) - 1; + Ty = new_random(3) - 1; + } + if (X + Tx < L || X + Tx + W > R) + Tx = -Tx; + if (Y + Ty < T || Y + Ty + H > B) + Ty = -Ty; + Goto(X + Tx, Y + Ty); } - if (X + Tx < L || X + Tx + W > R) Tx = -Tx; - if (Y + Ty < T || Y + Ty + H > B) Ty = -Ty; - Goto(X + Tx, Y + Ty); - } } - -//-------------------------------------------------------------------------- - } // End of namespace CGE diff --git a/engines/cge/game.h b/engines/cge/game.h index 1f45667b6b..1bc24e1fd9 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -25,44 +25,37 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __GAME__ -#define __GAME__ +#ifndef __GAME__ +#define __GAME__ -#include "cge/vga13h.h" -#include "cge/bitmaps.h" +#include "cge/vga13h.h" +#include "cge/bitmaps.h" namespace CGE { -#define PAN_HIG 40 -#define LBound(s) (s->X <= 0) -#define RBound(s) (s->X+s->W >= SCR_WID) -#define TBound(s) (s->Y <= 0) -#define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG) +#define PAN_HIG 40 +#define LBound(s) (s->X <= 0) +#define RBound(s) (s->X+s->W >= SCR_WID) +#define TBound(s) (s->Y <= 0) +#define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG) +extern SPRITE *Sys; -extern SPRITE * Sys; +int Sinus(long x); +uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b); +uint8 *Mark(DAC *pal); -int Sinus (long x); -uint8 * Glass (DAC * pal, uint8 r, uint8 g, uint8 b); -uint8 * Mark (DAC * pal); - - - - -class FLY : public SPRITE -{ - static int L, T, R, B; +class FLY : public SPRITE { + static int L, T, R, B; public: - int Tx, Ty; - FLY (BITMAP ** shpl); - void Tick (void); + int Tx, Ty; + FLY(BITMAP **shpl); + void Tick(void); }; - - } // End of namespace CGE #endif diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index f023bb1e0f..3a0114c672 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -32,77 +32,77 @@ namespace CGE { - DAC StdPal[] = {// R G B - { 0, 60, 0}, // 198 - { 0, 104, 0}, // 199 - { 20, 172, 0}, // 200 - { 82, 82, 0}, // 201 - { 0, 132, 82}, // 202 - { 132, 173, 82}, // 203 - { 82, 0, 0}, // 204 - { 206, 0, 24}, // 205 - { 255, 33, 33}, // 206 - { 123, 41, 0}, // 207 - { 0, 41, 0}, // 208 - { 0, 0, 82}, // 209 - { 132, 0, 0}, // 210 - { 255, 0, 0}, // 211 - { 255, 66, 66}, // 212 - { 148, 66, 16}, // 213 - { 0, 82, 0}, // 214 - { 0, 0,132}, // 215 - { 173, 0, 0}, // 216 - { 255, 49, 0}, // 217 - { 255, 99, 99}, // 218 - { 181, 107, 49}, // 219 - { 0, 132, 0}, // 220 - { 0, 0,255}, // 221 - { 173, 41, 0}, // 222 - { 255, 82, 0}, // 223 - { 255, 132,132}, // 224 - { 214, 148, 74}, // 225 - { 41, 214, 0}, // 226 - { 0, 82,173}, // 227 - { 255, 214, 0}, // 228 - { 247, 132, 49}, // 229 - { 255, 165,165}, // 230 - { 239, 198,123}, // 231 - { 173, 214, 0}, // 232 - { 0, 132,214}, // 233 - { 57, 57, 57}, // 234 - { 247, 189, 74}, // 235 - { 255, 198,198}, // 236 - { 255, 239,173}, // 237 - { 214, 255,173}, // 238 - { 82, 173,255}, // 239 - { 107, 107,107}, // 240 - { 247, 222, 99}, // 241 - { 255, 0,255}, // 242 - { 255, 132,255}, // 243 - { 132, 132,173}, // 244 - { 148, 247,255}, // 245 - { 148, 148,148}, // 246 - { 82, 0, 82}, // 247 - { 112, 68,112}, // 248 - { 176, 88,144}, // 249 - { 214, 132,173}, // 250 - { 206, 247,255}, // 251 - { 198, 198,198}, // 252 - { 0, 214,255}, // 253 - { 96, 224,96 }, // 254 - { 255, 255,255}, // 255 - }; - -EC void _fqsort (void *base, uint16 nelem, uint16 width, int (*fcmp)(const void*, const void*)) { +DAC StdPal[] = {// R G B + { 0, 60, 0}, // 198 + { 0, 104, 0}, // 199 + { 20, 172, 0}, // 200 + { 82, 82, 0}, // 201 + { 0, 132, 82}, // 202 + { 132, 173, 82}, // 203 + { 82, 0, 0}, // 204 + { 206, 0, 24}, // 205 + { 255, 33, 33}, // 206 + { 123, 41, 0}, // 207 + { 0, 41, 0}, // 208 + { 0, 0, 82}, // 209 + { 132, 0, 0}, // 210 + { 255, 0, 0}, // 211 + { 255, 66, 66}, // 212 + { 148, 66, 16}, // 213 + { 0, 82, 0}, // 214 + { 0, 0, 132}, // 215 + { 173, 0, 0}, // 216 + { 255, 49, 0}, // 217 + { 255, 99, 99}, // 218 + { 181, 107, 49}, // 219 + { 0, 132, 0}, // 220 + { 0, 0, 255}, // 221 + { 173, 41, 0}, // 222 + { 255, 82, 0}, // 223 + { 255, 132, 132}, // 224 + { 214, 148, 74}, // 225 + { 41, 214, 0}, // 226 + { 0, 82, 173}, // 227 + { 255, 214, 0}, // 228 + { 247, 132, 49}, // 229 + { 255, 165, 165}, // 230 + { 239, 198, 123}, // 231 + { 173, 214, 0}, // 232 + { 0, 132, 214}, // 233 + { 57, 57, 57}, // 234 + { 247, 189, 74}, // 235 + { 255, 198, 198}, // 236 + { 255, 239, 173}, // 237 + { 214, 255, 173}, // 238 + { 82, 173, 255}, // 239 + { 107, 107, 107}, // 240 + { 247, 222, 99}, // 241 + { 255, 0, 255}, // 242 + { 255, 132, 255}, // 243 + { 132, 132, 173}, // 244 + { 148, 247, 255}, // 245 + { 148, 148, 148}, // 246 + { 82, 0, 82}, // 247 + { 112, 68, 112}, // 248 + { 176, 88, 144}, // 249 + { 214, 132, 173}, // 250 + { 206, 247, 255}, // 251 + { 198, 198, 198}, // 252 + { 0, 214, 255}, // 253 + { 96, 224, 96 }, // 254 + { 255, 255, 255}, // 255 +}; + +EC void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) { warning("STUB: _fqsort"); } -const char * ProgName (const char * ext) { +const char *ProgName(const char *ext) { warning("STUB: ProgName"); return NULL; } -char *MergeExt (char *buf, const char *nam, const char *ext) { +char *MergeExt(char *buf, const char *nam, const char *ext) { // char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; // fnmerge(buf, dr, di, na, (fnsplit(nam, dr, di, na, ex) & EXTENSION) ? ex : ext); // return buf; @@ -110,7 +110,7 @@ char *MergeExt (char *buf, const char *nam, const char *ext) { return buf; } -char *ForceExt (char *buf, const char *nam, const char* ext) { +char *ForceExt(char *buf, const char *nam, const char *ext) { // char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; // fnsplit(nam, dr, di, na, ex); // fnmerge(buf, dr, di, na, ext); @@ -120,157 +120,168 @@ char *ForceExt (char *buf, const char *nam, const char* ext) { } -#define BUF ((uint8 *) buf) -static unsigned Seed = 1; +#define BUF ((uint8 *) buf) +static unsigned Seed = 1; -unsigned FastRand (void) { return Seed = 257 * Seed + 817; } -unsigned FastRand (unsigned s) { return Seed = 257 * s + 817; } +unsigned FastRand(void) { + return Seed = 257 * Seed + 817; +} +unsigned FastRand(unsigned s) { + return Seed = 257 * s + 817; +} -uint16 RCrypt (void * buf, uint16 siz, uint16 seed) { -/* - if (buf && siz) { - uint8 * q = BUF + (siz-1); - seed = FastRand(seed); - * (BUF ++) ^= seed; - while (buf < q) * (BUF ++) ^= FastRand(); - if (buf == q) * BUF ^= (seed = FastRand()); - } - return seed; -*/ +uint16 RCrypt(void *buf, uint16 siz, uint16 seed) { + /* + if (buf && siz) { + uint8 * q = BUF + (siz-1); + seed = FastRand(seed); + * (BUF ++) ^= seed; + while (buf < q) * (BUF ++) ^= FastRand(); + if (buf == q) * BUF ^= (seed = FastRand()); + } + return seed; + */ warning("STUB: RCrypt"); return 0; } -uint16 XCrypt (void *buf, uint16 siz, uint16 seed) { -// for (uint16 i = 0; i < siz; i ++) +uint16 XCrypt(void *buf, uint16 siz, uint16 seed) { +// for (uint16 i = 0; i < siz; i ++) // *(BUF ++) ^= seed; warning("STUB: XCrypt"); return seed; } -uint16 atow (const char *a) { - uint16 w = 0; +uint16 atow(const char *a) { + uint16 w = 0; if (a) while (IsDigit(*a)) w = (10 * w) + (*(a ++) & 0xF); - return w; -} - -uint16 xtow (const char *x) { - uint16 w = 0; - if (x) { - while (IsHxDig(*x)) { - register uint16 d = * (x ++); - if (d > '9') - d -= 'A' - ('9' + 1); - w = (w << 4) | (d & 0xF); - } - } - return w; -} - -char *wtom (uint16 val, char *str, int radix, int len) { - while (-- len >= 0) { - uint16 w = val % radix; - if (w > 9) w += ('A' - ('9'+1)); - str[len] = '0' + w; - val /= radix; - } - return str; -} - -IOHAND::IOHAND (IOMODE mode, CRYPT * crpt) -: XFILE(mode), Handle(-1), Crypt(crpt), Seed(SEED) -{ -} - -IOHAND::IOHAND (const char *name, IOMODE mode, CRYPT *crpt) -: XFILE(mode), Crypt(crpt), Seed(SEED) -{ -/* switch (mode) - { - case REA : Error = _dos_open(name, O_RDONLY | O_DENYNONE, &Handle); break; - case WRI : Error = _dos_creat(name, FA_ARCH, &Handle); break; - case UPD : Error = _dos_open(name, O_RDWR | O_DENYALL, &Handle); break; - } - if (Error) Handle = -1; -*/ + return w; +} + +uint16 xtow(const char *x) { + uint16 w = 0; + if (x) { + while (IsHxDig(*x)) { + register uint16 d = * (x ++); + if (d > '9') + d -= 'A' - ('9' + 1); + w = (w << 4) | (d & 0xF); + } + } + return w; +} + +char *wtom(uint16 val, char *str, int radix, int len) { + while (--len >= 0) { + uint16 w = val % radix; + if (w > 9) + w += ('A' - ('9' + 1)); + str[len] = '0' + w; + val /= radix; + } + return str; +} + +char *dwtom(uint32 val, char *str, int radix, int len) { + while (--len >= 0) { + uint16 w = (uint16) (val % radix); + if (w > 9) + w += ('A' - ('9' + 1)); + str[len] = '0' + w; + val /= radix; + } + return str; +} + +IOHAND::IOHAND(IOMODE mode, CRYPT *crpt) + : XFILE(mode), Handle(-1), Crypt(crpt), Seed(SEED) { +} + +IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt) + : XFILE(mode), Crypt(crpt), Seed(SEED) { + /* switch (mode) + { + case REA : Error = _dos_open(name, O_RDONLY | O_DENYNONE, &Handle); break; + case WRI : Error = _dos_creat(name, FA_ARCH, &Handle); break; + case UPD : Error = _dos_open(name, O_RDWR | O_DENYALL, &Handle); break; + } + if (Error) Handle = -1; + */ warning("STUB: IOHAND::IOHAND"); } IOHAND::~IOHAND(void) { -/* - if (Handle != -1) - { - Error = _dos_close(Handle); - Handle = -1; - } -*/ + /* + if (Handle != -1) + { + Error = _dos_close(Handle); + Handle = -1; + } + */ warning("STUB: IOHAND::~IOHAND"); } uint16 IOHAND::Read(void *buf, uint16 len) { -/* - if (Mode == WRI || Handle < 0) return 0; - if (len) Error = _dos_read(Handle, buf, len, &len); - if (Crypt) Seed = Crypt(buf, len, Seed); - return len; -*/ + /* + if (Mode == WRI || Handle < 0) return 0; + if (len) Error = _dos_read(Handle, buf, len, &len); + if (Crypt) Seed = Crypt(buf, len, Seed); + return len; + */ warning("STUB: IOHAND::Read"); return 0; } uint16 IOHAND::Write(void *buf, uint16 len) { -/* - if (len) { - if (Mode == REA || Handle < 0) return 0; - if (Crypt) Seed = Crypt(buf, len, Seed); - Error = _dos_write(Handle, buf, len, &len); - if (Crypt) Seed = Crypt(buf, len, Seed); //------$$$$$$$ - } - return len; -*/ + /* + if (len) { + if (Mode == REA || Handle < 0) return 0; + if (Crypt) Seed = Crypt(buf, len, Seed); + Error = _dos_write(Handle, buf, len, &len); + if (Crypt) Seed = Crypt(buf, len, Seed); //------$$$$$$$ + } + return len; + */ warning("STUB: IOHAND::Write"); return 0; } -long IOHAND::Mark (void) -{ - return (Handle < 0) ? 0 : tell(Handle); +long IOHAND::Mark(void) { + return (Handle < 0) ? 0 : tell(Handle); } -long IOHAND::Seek (long pos) -{ - if (Handle < 0) return 0; - lseek(Handle, pos, SEEK_SET); - return tell(Handle); +long IOHAND::Seek(long pos) { + if (Handle < 0) return 0; + lseek(Handle, pos, SEEK_SET); + return tell(Handle); } -long IOHAND::Size (void) -{ - if (Handle < 0) return 0; - return filelength(Handle); +long IOHAND::Size(void) { + if (Handle < 0) return 0; + return filelength(Handle); } -bool IOHAND::Exist (const char * name) { - return access(name, 0) == 0; +bool IOHAND::Exist(const char *name) { + return access(name, 0) == 0; } -//#define EMS_ADR(a) (FP_SEG(a) > 0xA000) -//#define HNODE_OK(p) (heapchecknode(p)==4) - -MEM_TYPE MemType (void *mem) { -/* if (FP_SEG(mem) == _DS) { - if (heapchecknode((void *)mem)==4) - return NEAR_MEM; - } else { - if (FP_SEG(mem) > 0xA000) - return EMS_MEM; - else if (farheapchecknode(mem)==4) - return FAR_MEM; - } - return BAD_MEM; -*/ +//#define EMS_ADR(a) (FP_SEG(a) > 0xA000) +//#define HNODE_OK(p) (heapchecknode(p)==4) + +MEM_TYPE MemType(void *mem) { + /* if (FP_SEG(mem) == _DS) { + if (heapchecknode((void *)mem)==4) + return NEAR_MEM; + } else { + if (FP_SEG(mem) > 0xA000) + return EMS_MEM; + else if (farheapchecknode(mem)==4) + return FAR_MEM; + } + return BAD_MEM; + */ warning("STUB: MemType"); return FAR_MEM; } @@ -307,40 +318,48 @@ EC void SNDMIDIStop() { warning("STUB: SNDMIDIStop"); } -DATACK *LoadWave(XFILE * file, EMM * emm) { +DATACK *LoadWave(XFILE *file, EMM *emm) { warning("STUB: LoadWave"); return NULL; } int TakeEnum(const char **tab, const char *txt) { - const char **e; - if (txt) - { - for (e = tab; *e; e ++) - { - if (scumm_stricmp(txt, *e) == 0) - { - return e - tab; - } + const char **e; + if (txt) { + for (e = tab; *e; e ++) { + if (scumm_stricmp(txt, *e) == 0) { + return e - tab; + } + } } - } - return -1; + return -1; } Boot *ReadBoot(int drive) { -/* - struct fatinfo fi; Boot *b; - getfat(drive+1, &fi); - if (fi.fi_sclus & 0x80) return NULL; - if ((b = malloc(fi.fi_bysec)) == NULL) return NULL; - // read boot sector - if (absread(drive, 1, 0L, b) == 0) return b; - free(b); - return NULL; -*/ + /* + struct fatinfo fi; Boot *b; + getfat(drive+1, &fi); + if (fi.fi_sclus & 0x80) return NULL; + if ((b = malloc(fi.fi_bysec)) == NULL) return NULL; + // read boot sector + if (absread(drive, 1, 0L, b) == 0) return b; + free(b); + return NULL; + */ warning("STUB: ReadBoot"); return NULL; } +long Timer(void) { +/* + asm mov ax,0x40 + asm mov es,ax + asm mov cx,es:[0x6C] + asm mov dx,es:[0x6E] + return ((long) _DX << 16) | _CX; +*/ + warning("STUB: Timer"); + return 0; +} } // End of namespace CGE diff --git a/engines/cge/general.h b/engines/cge/general.h index 62919328ed..7c0bd7f762 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -25,243 +25,218 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __GENERAL__ -#define __GENERAL__ +#ifndef __GENERAL__ +#define __GENERAL__ #include "common/system.h" #include "common/random.h" #include "common/textconsole.h" #include "common/str.h" - -#include "cge\jbw.h" -#include +#include "cge/jbw.h" +#include +#include "cge/boot.h" namespace CGE { -#define SEED 0xA5 +#define SEED 0xA5 -#define SCR_WID_ 320 -#define SCR_HIG_ 200 -#define SCR_WID ((uint16)SCR_WID_) -#define SCR_HIG ((uint16)SCR_HIG_) -#define SCR_SEG 0xA000 -#define SCR_ADR ((uint8 *) MK_FP(SCR_SEG, 0)) +#define SCR_WID_ 320 +#define SCR_HIG_ 200 +#define SCR_WID ((uint16)SCR_WID_) +#define SCR_HIG ((uint16)SCR_HIG_) +#define SCR_SEG 0xA000 +#define SCR_ADR ((uint8 *) MK_FP(SCR_SEG, 0)) -//enum CPU { _8086, _80186, _80286, _80386, _80486 }; -enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM }; -enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT }; -enum IOMODE { REA, WRI, UPD }; +//enum CPU { _8086, _80186, _80286, _80386, _80486 }; +enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM }; +enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT }; +enum IOMODE { REA, WRI, UPD }; -typedef struct { - uint8 R, G, B; - } DAC; +typedef struct { + uint8 R, G, B; +} DAC; -typedef uint16 CRYPT (void *buf, uint16 siz, uint16 seed); +typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); extern Common::RandomSource randSrc; #define new_random(a) (randSrc.getRandomNumber(a)) -class COUPLE -{ +class COUPLE { protected: - signed char A; - signed char B; + signed char A; + signed char B; public: - COUPLE (void) { } - COUPLE (const signed char a, const signed char b) : A(a), B(b) { } - COUPLE operator + (COUPLE c) { return COUPLE(A+c.A, B+c.B); } - void operator += (COUPLE c) { A += c.A; B += c.B; } - COUPLE operator - (COUPLE c) { return COUPLE(A-c.A, B-c.B); } - void operator -= (COUPLE c) { A -= c.A; B -= c.B; } - bool operator == (COUPLE c) { return ((A - c.A) | (B - c.B)) == 0; } - bool operator != (COUPLE c) { return ! (operator == (c)); } - void Split (signed char& a, signed char& b) { a = A; b = B; } + COUPLE(void) { } + COUPLE(const signed char a, const signed char b) : A(a), B(b) { } + COUPLE operator + (COUPLE c) { + return COUPLE(A + c.A, B + c.B); + } + + void operator += (COUPLE c) { + A += c.A; + B += c.B; + } + + COUPLE operator - (COUPLE c) { + return COUPLE(A - c.A, B - c.B); + } + + void operator -= (COUPLE c) { + A -= c.A; + B -= c.B; + } + + bool operator == (COUPLE c) { + return ((A - c.A) | (B - c.B)) == 0; + } + + bool operator != (COUPLE c) { + return !(operator == (c)); + } + + void Split(signed char &a, signed char &b) { + a = A; + b = B; + } }; -//------------------------------------------------------------------------- - - - -class ENGINE -{ +class ENGINE { protected: - static void (* OldTimer) (...); - static void NewTimer (...); + static void (* OldTimer)(...); + static void NewTimer(...); public: - ENGINE (uint16 tdiv); - ~ENGINE (void); + ENGINE(uint16 tdiv); + ~ENGINE(void); }; - - -//------------------------------------------------------------------------- - - class EMS; - -class EMM -{ - friend EMS; - bool Test (void); - long Top, Lim; - EMS * List; - int Han; - static void * Frame; +class EMM { + friend EMS; + bool Test(void); + long Top, Lim; + EMS *List; + int Han; + static void *Frame; public: - EMM::EMM (long size = 0); - EMM::~EMM (void); - EMS * Alloc (uint16 siz); - void Release (void); + EMM::EMM(long size = 0); + EMM::~EMM(void); + EMS *Alloc(uint16 siz); + void Release(void); }; - - - -class EMS -{ - friend EMM; - EMM * Emm; - long Ptr; - uint16 Siz; - EMS * Nxt; +class EMS { + friend EMM; + EMM *Emm; + long Ptr; + uint16 Siz; + EMS *Nxt; public: - EMS (void); - void * operator & () const; - uint16 Size (void); + EMS(void); + void *operator & () const; + uint16 Size(void); }; - -//------------------------------------------------------------------------- - - - - template -void Swap (T& A, T& B) -{ - T a = A; - A = B; - B = a; +void Swap(T &A, T &B) { + T a = A; + A = B; + B = a; }; - - - #ifdef __cplusplus - - template -T max (T A, T B) -{ - return (A > B) ? A : B; +T max(T A, T B) { + return (A > B) ? A : B; }; - - template -T min (T A, T B) -{ - return (A < B) ? A : B; +T min(T A, T B) { + return (A < B) ? A : B; }; - - #endif - - - - - -class XFILE -{ +class XFILE { public: - IOMODE Mode; - uint16 Error; - XFILE (void) : Mode(REA), Error(0) { } - XFILE (IOMODE mode) : Mode(mode), Error(0) { } - virtual uint16 Read (void * buf, uint16 len) = 0; - virtual uint16 Write (void * buf, uint16 len) = 0; - virtual long Mark (void) = 0; - virtual long Size (void) = 0; - virtual long Seek (long pos) = 0; + IOMODE Mode; + uint16 Error; + XFILE(void) : Mode(REA), Error(0) { } + XFILE(IOMODE mode) : Mode(mode), Error(0) { } + virtual uint16 Read(void *buf, uint16 len) = 0; + virtual uint16 Write(void *buf, uint16 len) = 0; + virtual long Mark(void) = 0; + virtual long Size(void) = 0; + virtual long Seek(long pos) = 0; }; - - - template -inline uint16 XRead (XFILE * xf, T * t) -{ - return xf->Read((uint8 *) t, sizeof(*t)); +inline uint16 XRead(XFILE *xf, T *t) { + return xf->Read((uint8 *) t, sizeof(*t)); }; - - - -class IOHAND : public XFILE -{ +class IOHAND : public XFILE { protected: - int Handle; - uint16 Seed; - CRYPT * Crypt; + int Handle; + uint16 Seed; + CRYPT *Crypt; public: - IOHAND (const char * name, IOMODE mode = REA, CRYPT crypt = NULL); - IOHAND (IOMODE mode = REA, CRYPT * crpt = NULL); - virtual ~IOHAND (void); - static bool Exist (const char * name); - uint16 Read (void * buf, uint16 len); - uint16 Write (void * buf, uint16 len); - long Mark (void); - long Size (void); - long Seek (long pos); - //timeb Time (void); - // void SetTime (timeb t); + IOHAND(const char *name, IOMODE mode = REA, CRYPT crypt = NULL); + IOHAND(IOMODE mode = REA, CRYPT *crpt = NULL); + virtual ~IOHAND(void); + static bool Exist(const char *name); + uint16 Read(void *buf, uint16 len); + uint16 Write(void *buf, uint16 len); + long Mark(void); + long Size(void); + long Seek(long pos); + //timeb Time (void); +// void SetTime (timeb t); }; - - - -CRYPT XCrypt; -CRYPT RCrypt; - -MEM_TYPE MemType (void *mem); -uint16 atow (const char * a); -uint16 xtow (const char * x); -char * wtom (uint16 val, char * str, int radix, int len); -char * dwtom (uint32 val, char * str, int radix, int len); -int TakeEnum (const char ** tab, const char * txt); -uint16 ChkSum (void *m, uint16 n); -long Timer (void); -char * MergeExt (char * buf, const char * nam, const char * ext); -char * ForceExt (char * buf, const char * nam, const char * ext); -int DriveCD (unsigned drv); -bool IsVga (void); +CRYPT XCrypt; +CRYPT RCrypt; +MEM_TYPE MemType(void *mem); +uint16 atow(const char *a); +uint16 xtow(const char *x); +char *wtom(uint16 val, char *str, int radix, int len); +char *dwtom(uint32 val, char *str, int radix, int len); +int TakeEnum(const char **tab, const char *txt); +uint16 ChkSum(void *m, uint16 n); +long Timer(void); +char *MergeExt(char *buf, const char *nam, const char *ext); +char *ForceExt(char *buf, const char *nam, const char *ext); +int DriveCD(unsigned drv); +bool IsVga(void); // MISSING FUNCTIONS -EC void _fqsort (void *base, uint16 nelem, uint16 width, int (*fcmp)(const void*, const void*)); -const char *ProgName (const char *ext = NULL); -char *MergeExt (char *buf, const char *nam, const char *ext); -char *ForceExt (char *buf, const char *nam, const char *ext); -unsigned FastRand (void); -unsigned FastRand (unsigned s); -uint16 RCrypt (void * buf, uint16 siz, uint16 seed); -uint16 atow (const char *a); -uint16 xtow (const char *x); +EC void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)); +const char *ProgName(const char *ext = NULL); +char *MergeExt(char *buf, const char *nam, const char *ext); +char *ForceExt(char *buf, const char *nam, const char *ext); +unsigned FastRand(void); +unsigned FastRand(unsigned s); +uint16 RCrypt(void *buf, uint16 siz, uint16 seed); +uint16 atow(const char *a); +uint16 xtow(const char *x); +char *wtom(uint16 val, char *str, int radix, int len); +char *dwtom(uint32 val, char * str, int radix, int len); +int TakeEnum(const char **tab, const char *txt); +Boot *ReadBoot(int drive); +long Timer(void); } // End of namespace CGE diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 892ef5ee73..78cc0356a1 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -25,113 +25,97 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/gettext.h" -#include "cge/keybd.h" -#include "cge/mouse.h" -#include +#include "cge/gettext.h" +#include "cge/keybd.h" +#include "cge/mouse.h" +#include namespace CGE { -GET_TEXT * GET_TEXT::Ptr = NULL; - - - -GET_TEXT::GET_TEXT (const char * info, char * text, int size, void (*click)(void)) -: Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), - Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)) -{ - int i = 2 * TEXT_HM + Font.Width(info); - Ptr = this; - Mode = RECT; - TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); - SetShapeList(TS); - Flags.BDel = true; - Flags.Kill = true; - memcpy(Buff, text, Len); - Buff[Len] = ' '; - Buff[Len+1] = '\0'; - PutLine(0, info); - Tick(); +GET_TEXT *GET_TEXT::Ptr = NULL; + + +GET_TEXT::GET_TEXT(const char *info, char *text, int size, void (*click)(void)) + : Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), + Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)) { + int i = 2 * TEXT_HM + Font.Width(info); + Ptr = this; + Mode = RECT; + TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); + SetShapeList(TS); + Flags.BDel = true; + Flags.Kill = true; + memcpy(Buff, text, Len); + Buff[Len] = ' '; + Buff[Len + 1] = '\0'; + PutLine(0, info); + Tick(); } - - - - -GET_TEXT::~GET_TEXT (void) -{ - KEYBOARD::SetClient(OldKeybClient); - Ptr = NULL; +GET_TEXT::~GET_TEXT(void) { + KEYBOARD::SetClient(OldKeybClient); + Ptr = NULL; } - - - - -void GET_TEXT::Tick (void) -{ - if (++ Cntr >= GTBLINK) - { - Buff[Len] ^= (' ' ^ '_'); - Cntr = 0; - } - PutLine(1, Buff); - Time = GTTIME; +void GET_TEXT::Tick(void) { + if (++ Cntr >= GTBLINK) { + Buff[Len] ^= (' ' ^ '_'); + Cntr = 0; + } + PutLine(1, Buff); + Time = GTTIME; } - - -void GET_TEXT::Touch (uint16 mask, int x, int y) -{ - static char ogon[] = "•œ¥£˜ ¡"; - static char bezo[] = "ACELNOSXZ"; - char * p; - - if (mask & KEYB) - { - if (Click) Click(); - switch (x) - { - case Enter : Buff[Len] = '\0'; strcpy(Text, Buff); - for (p = Text; *p; p ++) - { - char * q = strchr(ogon, *p); - if (q) *p = bezo[q-ogon]; - } - case Esc : SNPOST_(SNKILL, -1, 0, this); break; - case BSp : if (Len) - { - -- Len; - Buff[Len] = Buff[Len+1]; - Buff[Len+1] = Buff[Len+2]; - } - break; - default : if (x < 'A' || x > 'Z') - { - if (OldKeybClient) - OldKeybClient->Touch(mask, x, y); - } - else - { - if (KEYBOARD::Key[ALT]) - { - p = strchr(bezo, x); - if (p) x = ogon[p-bezo]; - } - if (Len < Size && 2 * TEXT_HM + Font.Width(Buff) + Font.Wid[x] <= W) - { - Buff[Len+2] = Buff[Len+1]; - Buff[Len+1] = Buff[Len]; - Buff[Len ++] = x; - } - } - break; - } - } - else SPRITE::Touch(mask, x, y); +void GET_TEXT::Touch(uint16 mask, int x, int y) { + static char ogon[] = "•œ¥£˜ ¡"; + static char bezo[] = "ACELNOSXZ"; + char *p; + + if (mask & KEYB) { + if (Click) + Click(); + switch (x) { + case Enter : + Buff[Len] = '\0'; + strcpy(Text, Buff); + for (p = Text; *p; p ++) { + char *q = strchr(ogon, *p); + if (q) + *p = bezo[q - ogon]; + } + case Esc : + SNPOST_(SNKILL, -1, 0, this); + break; + case BSp : + if (Len) { + --Len; + Buff[Len] = Buff[Len + 1]; + Buff[Len + 1] = Buff[Len + 2]; + } + break; + default : + if (x < 'A' || x > 'Z') { + if (OldKeybClient) + OldKeybClient->Touch(mask, x, y); + } else { + if (KEYBOARD::Key[ALT]) { + p = strchr(bezo, x); + if (p) + x = ogon[p - bezo]; + } + if (Len < Size && 2 * TEXT_HM + Font.Width(Buff) + Font.Wid[x] <= W) { + Buff[Len + 2] = Buff[Len + 1]; + Buff[Len + 1] = Buff[Len]; + Buff[Len ++] = x; + } + } + break; + } + } else + SPRITE::Touch(mask, x, y); } } // End of namespace CGE diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index 02dbabe9c6..3fc7e4ff34 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -25,32 +25,30 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __GETTEXT__ -#define __GETTEXT__ +#ifndef __GETTEXT__ +#define __GETTEXT__ -#include "cge/general.h" -#include "cge/talk.h" +#include "cge/general.h" +#include "cge/talk.h" namespace CGE { -#define GTMAX 24 -#define GTBLINK 6 -#define GTTIME 6 +#define GTMAX 24 +#define GTBLINK 6 +#define GTTIME 6 - -class GET_TEXT : public TALK -{ - char Buff[GTMAX+2], * Text; - uint16 Size, Len; - uint16 Cntr; - SPRITE * OldKeybClient; - void (*Click)(void); +class GET_TEXT : public TALK { + char Buff[GTMAX + 2], * Text; + uint16 Size, Len; + uint16 Cntr; + SPRITE *OldKeybClient; + void (*Click)(void); public: - static GET_TEXT * Ptr; - GET_TEXT (const char * info, char * text, int size, void (*click)(void) = NULL); - ~GET_TEXT (void); - void Touch (uint16 mask, int x, int y); - void Tick (void); + static GET_TEXT *Ptr; + GET_TEXT(const char *info, char *text, int size, void (*click)(void) = NULL); + ~GET_TEXT(void); + void Touch(uint16 mask, int x, int y); + void Tick(void); }; } // End of namespace CGE diff --git a/engines/cge/ident.h b/engines/cge/ident.h index 96e04f4e20..da36bfa682 100644 --- a/engines/cge/ident.h +++ b/engines/cge/ident.h @@ -25,18 +25,17 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __IDENT__ -#define __IDENT__ +#ifndef __IDENT__ +#define __IDENT__ namespace CGE { -struct IDENT - { - char copr[83]; - char fill[8]; - unsigned long disk; - unsigned char cork; - }; +struct IDENT { + char copr[83]; + char fill[8]; + unsigned long disk; + unsigned char cork; +}; } // End of namespace CGE diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index bb01017d00..73131d71e3 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -32,149 +32,150 @@ namespace CGE { +// Defines found in cge.mak +#define DEBUG #define VOL -#define INI_FILE VFILE +#define INI_FILE VFILE // Or is it CFILE? #define PIC_FILE VFILE #define BMP_MODE 0 - -#define BEL 7 -#define BS 8 -#define HT 9 -#define LF 10 -#define FF 12 -#define CR 13 - -#define TRUE 1 -#define FALSE 0 - -#define MAXFILE 128 - -#define NULL 0 -#define OFF false -#define ON true - -#define IsWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') -#define IsUpper(c) ((c) >= 'A' && (c) <= 'Z') -#define IsLower(c) ((c) >= 'a' && (c) <= 'z') -#define IsDigit(c) ((c) >= '0' && (c) <= '9') -#define IsAlpha(c) (IsLower(c) || IsUpper(c) || (c) == '_') -#define IsAlNum(c) (IsAlpha(c) || IsDigit(c)) -#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) - -#define farnew(t,n) ((t *) malloc(sizeof(t) * (n))) -#define ArrayCount(a) (sizeof(a)/sizeof((a)[0])) -#define MAX_TIMER 0x1800B0L - -typedef void (MouseFunType)(void); - -#define Lo(d) (((int *) &d)[0]) -#define Hi(d) (((int *) &d)[1]) -#define LoWord(d) ((uint16) Lo(d)) -#define HiWord(d) ((uint16) Hi(d)) -#define K(n) (1024*(n)) -#define MASK(n) ((1<= 'A' && (c) <= 'Z') +#define IsLower(c) ((c) >= 'a' && (c) <= 'z') +#define IsDigit(c) ((c) >= '0' && (c) <= '9') +#define IsAlpha(c) (IsLower(c) || IsUpper(c) || (c) == '_') +#define IsAlNum(c) (IsAlpha(c) || IsDigit(c)) +#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) + +#define farnew(t,n) ((t *) malloc(sizeof(t) * (n))) +#define ArrayCount(a) (sizeof(a)/sizeof((a)[0])) +#define MAX_TIMER 0x1800B0L + +typedef void (MouseFunType)(void); + +#define Lo(d) (((int *) &d)[0]) +#define Hi(d) (((int *) &d)[1]) +#define LoWord(d) ((uint16) Lo(d)) +#define HiWord(d) ((uint16) Hi(d)) +#define K(n) (1024*(n)) +#define MASK(n) ((1< +#include "cge/keybd.h" +#include "cge/mouse.h" +#include namespace CGE { -SPRITE * KEYBOARD::Client = NULL; +SPRITE *KEYBOARD::Client = NULL; uint8 KEYBOARD::Key[0x60] = { 0 }; uint16 KEYBOARD::Current = 0; -uint16 KEYBOARD::Code[0x60] = { 0,Esc,'1','2','3','4','5','6','7','8','9','0', - '-','+',BSp,Tab,'Q','W','E','R','T','Y','U', - 'I','O','P','[',']',Enter,0/*Ctrl*/,'A','S', - 'D','F','G','H','J','K','L',';','\'','`', - 0/*LShift*/,'\\','Z','X','C','V','B','N','M', - ',','.','/',0/*RShift*/,'*',0/*Alt*/,' ', - 0/*Caps*/,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10, - 0/*NumLock*/,0/*ScrollLock*/,Home,Up,PgUp, - '-',Left,Ctr,Right,'+',End,Down,PgDn,Ins,Del, - 0*0x54,0*0x55,0*0x56,F11,F12,0*0x59,0*0x5A, - 0*0x5B,0*0x5C,0*0x5D,0*0x5E,0*0x5F - }; -void (* KEYBOARD::OldKeyboard) (...); - - - -KEYBOARD::KEYBOARD (void) -{ - // steal keyboard interrupt - /* TODO replace totally by scummvm handling - OldKeyboard = getvect(KEYBD_INT); - setvect(KEYBD_INT, NewKeyboard); - */ - warning("STUB: KEYBOARD::KEYBOARD"); +uint16 KEYBOARD::Code[0x60] = { + 0, Esc, '1', '2', '3', + '4', '5', '6', '7', '8', + '9', '0', '-', '+', BSp, + Tab, 'Q', 'W', 'E', 'R', + 'T', 'Y', 'U', 'I', 'O', + 'P', '[', ']', Enter, 0/*Ctrl*/, + 'A', 'S', 'D', 'F', 'G', + 'H', 'J', 'K', 'L', ';', + '\'', '`', 0/*LShift*/, '\\', 'Z', + 'X', 'C', 'V', 'B', 'N', + 'M', ',', '.', '/', 0/*RShift*/, + '*', 0/*Alt*/, ' ', 0/*Caps*/, F1, + F2, F3, F4, F5, F6, + F7, F8, F9, F10, 0/*NumLock*/, + 0/*ScrollLock*/, Home, Up, PgUp, '-', + Left, Ctr, Right, '+', End, + Down, PgDn, Ins, Del, 0 * 0x54, + 0 * 0x55, 0 * 0x56, F11, F12, 0 * 0x59, + 0 * 0x5A, 0 * 0x5B, 0 * 0x5C, 0 * 0x5D, 0 * 0x5E, + 0 * 0x5F +}; + +void (* KEYBOARD::OldKeyboard)(...); + + +KEYBOARD::KEYBOARD(void) { + // steal keyboard interrupt + /* TODO replace totally by scummvm handling + OldKeyboard = getvect(KEYBD_INT); + setvect(KEYBD_INT, NewKeyboard); + */ + warning("STUB: KEYBOARD::KEYBOARD"); } - - -KEYBOARD::~KEYBOARD (void) -{ - // bring back keyboard interrupt - /* TODO replace totally by scummvm handling +KEYBOARD::~KEYBOARD(void) { + // bring back keyboard interrupt + /* TODO replace totally by scummvm handling setvect(KEYBD_INT, OldKeyboard); - */ - warning("STUB: KEYBOARD::~KEYBOARD"); + */ + warning("STUB: KEYBOARD::~KEYBOARD"); } - - -SPRITE * KEYBOARD::SetClient (SPRITE * spr) -{ - Swap(Client, spr); - return spr; +SPRITE *KEYBOARD::SetClient(SPRITE *spr) { + Swap(Client, spr); + return spr; } - - - -void KEYBOARD::NewKeyboard (...) -{ - // table address +void KEYBOARD::NewKeyboard(...) { + // table address /* - _SI = (uint16) Key; - - // take keyboard code - asm in al,60h - asm mov bl,al - asm and bx,007Fh - asm cmp bl,60h - asm jae xit - asm cmp al,bl - asm je ok // key pressed - - // key released... - asm cmp [si+bx],bh // BH == 0 - asm jne ok - // ...but not pressed: call the original service - OldKeyboard(); - return; - - ok: - asm shl ax,1 - asm and ah,1 - asm xor ah,1 - asm mov [si+bx],ah - asm jz xit // released: exit - - // pressed: lock ASCII code - _SI = (uint16) Code; - asm add bx,bx // uint16 size - asm mov ax,[si+bx] - asm or ax,ax - asm jz xit // zero means NO KEY - Current = _AX; - - _SI = (uint16) Client; - asm or si,si - asm jz xit // if (Client) ... -//--- fill current event entry with mask, key code and sprite - asm mov bx,EvtHead // take queue head pointer - asm inc byte ptr EvtHead // update queue head pointer - asm shl bx,3 // * 8 - _AX = Current; - asm mov Evt[bx].(struct EVENT)X,ax // key code - asm mov ax,KEYB // event mask - asm mov Evt[bx].(struct EVENT)Msk,ax // event mask - //asm mov Evt[bx].(struct EVENT)Y,dx // row - asm mov Evt[bx].(struct EVENT)Ptr,si // SPRITE pointer - - xit: - - asm in al,61h // kbd control lines - asm push ax // save it - asm or al,80h // set the "enable kbd" bit - asm out 61h,al // and write it out - asm pop ax // original control port value - asm out 61h,al // write it back - asm mov al,20h // send End-Of-Interrupt - asm out 20h,al // to the 8259 IC - */ - warning("STUB: KEYBOARD::NewKeyboard"); + _SI = (uint16) Key; + + // take keyboard code + asm in al,60h + asm mov bl,al + asm and bx,007Fh + asm cmp bl,60h + asm jae xit + asm cmp al,bl + asm je ok // key pressed + + // key released... + asm cmp [si+bx],bh // BH == 0 + asm jne ok + // ...but not pressed: call the original service + OldKeyboard(); + return; + + ok: + asm shl ax,1 + asm and ah,1 + asm xor ah,1 + asm mov [si+bx],ah + asm jz xit // released: exit + + // pressed: lock ASCII code + _SI = (uint16) Code; + asm add bx,bx // uint16 size + asm mov ax,[si+bx] + asm or ax,ax + asm jz xit // zero means NO KEY + Current = _AX; + + _SI = (uint16) Client; + asm or si,si + asm jz xit // if (Client) ... + //--- fill current event entry with mask, key code and sprite + asm mov bx,EvtHead // take queue head pointer + asm inc byte ptr EvtHead // update queue head pointer + asm shl bx,3 // * 8 + _AX = Current; + asm mov Evt[bx].(struct EVENT)X,ax // key code + asm mov ax,KEYB // event mask + asm mov Evt[bx].(struct EVENT)Msk,ax // event mask + //asm mov Evt[bx].(struct EVENT)Y,dx // row + asm mov Evt[bx].(struct EVENT)Ptr,si // SPRITE pointer + + xit: + + asm in al,61h // kbd control lines + asm push ax // save it + asm or al,80h // set the "enable kbd" bit + asm out 61h,al // and write it out + asm pop ax // original control port value + asm out 61h,al // write it back + asm mov al,20h // send End-Of-Interrupt + asm out 20h,al // to the 8259 IC + */ + warning("STUB: KEYBOARD::NewKeyboard"); } } // End of namespace CGE diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h index 5e6c9ac534..f2fa595be2 100644 --- a/engines/cge/keybd.h +++ b/engines/cge/keybd.h @@ -25,34 +25,37 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __KEYBD__ -#define __KEYBD__ +#ifndef __KEYBD__ +#define __KEYBD__ -#include "cge/jbw.h" -#include "cge/vga13h.h" +#include "cge/jbw.h" +#include "cge/vga13h.h" namespace CGE { -#define KEYBD_INT 9 -#define LSHIFT 42 -#define RSHIFT 54 -#define CTRL 29 -#define ALT 56 +#define KEYBD_INT 9 +#define LSHIFT 42 +#define RSHIFT 54 +#define CTRL 29 +#define ALT 56 -class KEYBOARD -{ +class KEYBOARD { public: - static void (* OldKeyboard) (...); - static void NewKeyboard (...); - static uint16 Code[0x60]; - static uint16 Current; - static SPRITE * Client; - static uint8 Key[0x60]; - static uint16 Last (void) { uint16 cur = Current; Current = 0; return cur; } - static SPRITE * SetClient (SPRITE * spr); - KEYBOARD (void); - ~KEYBOARD (void); + static void (* OldKeyboard)(...); + static void NewKeyboard(...); + static uint16 Code[0x60]; + static uint16 Current; + static SPRITE *Client; + static uint8 Key[0x60]; + static uint16 Last(void) { + uint16 cur = Current; + Current = 0; + return cur; + } + static SPRITE *SetClient(SPRITE *spr); + KEYBOARD(void); + ~KEYBOARD(void); }; } // End of namespace CGE diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 385634d4b8..47a6e17fc9 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -25,136 +25,119 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/mixer.h" -#include "cge/text.h" -#include "cge/snail.h" -#include "cge/mouse.h" -#include "cge/snddrv.h" -#include -//#include +#include "cge/mixer.h" +#include "cge/text.h" +#include "cge/snail.h" +#include "cge/mouse.h" +#include "cge/snddrv.h" +#include namespace CGE { -extern MOUSE Mouse; - - bool MIXER::Appear = false; - - - -MIXER::MIXER (int x, int y) -: SPRITE(NULL), Fall(MIX_FALL) -{ - int i; - Appear = true; - mb[0] = new BITMAP("VOLUME"); - mb[1] = NULL; - SetShapeList(mb); - SetName(Text[MIX_NAME]); - Flags.Syst = true; - Flags.Kill = true; - Flags.BDel = true; - Goto(x, y); - Z = MIX_Z; - - // slaves - - for (i = 0; i < MIX_MAX; i ++) - { - static char fn[] = "V00"; - wtom(i, fn+1, 10, 2); - lb[i] = new BITMAP(fn); - ls[i].Now = ls[i].Next = i; - ls[i].Dx = ls[i].Dy = ls[i].Dly = 0; - } - lb[i] = NULL; - - for (i = 0; i < ArrayCount(Led); i ++) - { - register SPRITE * spr = new SPRITE(lb); - spr->SetSeq(ls); - spr->Goto(x+2+12*i, y+8); - spr->Flags.Tran = true; - spr->Flags.Kill = true; - spr->Flags.BDel = false; - spr->Z = MIX_Z; - Led[i] = spr; - } - Led[ArrayCount(Led)-1]->Flags.BDel = true; - - VGA::ShowQ.Insert(this); - for (i = 0; i < ArrayCount(Led); i ++) VGA::ShowQ.Insert(Led[i]); - - //--- reset balance - i = (SNDDrvInfo.VOL4.ML + SNDDrvInfo.VOL4.MR) / 2; - SNDDrvInfo.VOL4.ML = i; - SNDDrvInfo.VOL4.MR = i; - i = (SNDDrvInfo.VOL4.DL + SNDDrvInfo.VOL4.DR) / 2; - SNDDrvInfo.VOL4.DL = i; - SNDDrvInfo.VOL4.DR = i; - Update(); - Time = MIX_DELAY; -} +extern MOUSE Mouse; + +bool MIXER::Appear = false; +MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { + Appear = true; + mb[0] = new BITMAP("VOLUME"); + mb[1] = NULL; + SetShapeList(mb); + SetName(Text[MIX_NAME]); + Flags.Syst = true; + Flags.Kill = true; + Flags.BDel = true; + Goto(x, y); + Z = MIX_Z; + // slaves -MIXER::~MIXER (void) -{ - Appear = false; + int i; + for (i = 0; i < MIX_MAX; i ++) { + static char fn[] = "V00"; + wtom(i, fn + 1, 10, 2); + lb[i] = new BITMAP(fn); + ls[i].Now = ls[i].Next = i; + ls[i].Dx = ls[i].Dy = ls[i].Dly = 0; + } + lb[i] = NULL; + + for (i = 0; i < ArrayCount(Led); i ++) { + register SPRITE *spr = new SPRITE(lb); + spr->SetSeq(ls); + spr->Goto(x + 2 + 12 * i, y + 8); + spr->Flags.Tran = true; + spr->Flags.Kill = true; + spr->Flags.BDel = false; + spr->Z = MIX_Z; + Led[i] = spr; + } + Led[ArrayCount(Led) - 1]->Flags.BDel = true; + + VGA::ShowQ.Insert(this); + for (i = 0; i < ArrayCount(Led); i ++) + VGA::ShowQ.Insert(Led[i]); + + //--- reset balance + i = (SNDDrvInfo.VOL4.ML + SNDDrvInfo.VOL4.MR) / 2; + SNDDrvInfo.VOL4.ML = i; + SNDDrvInfo.VOL4.MR = i; + i = (SNDDrvInfo.VOL4.DL + SNDDrvInfo.VOL4.DR) / 2; + SNDDrvInfo.VOL4.DL = i; + SNDDrvInfo.VOL4.DR = i; + Update(); + Time = MIX_DELAY; } +MIXER::~MIXER(void) { + Appear = false; +} #pragma argsused -void MIXER::Touch (uint16 mask, int x, int y) -{ - SPRITE::Touch(mask, x, y); - if (mask & L_UP) - { - uint8 * vol = (&SNDDrvInfo.VOL2.D) + (x < W/2); - if (y < MIX_BHIG) { if (*vol < 0xFF) *vol += 0x11; } - else if (y >= H-MIX_BHIG) { if (*vol > 0x00) *vol -= 0x11; } - Update(); - } +void MIXER::Touch(uint16 mask, int x, int y) { + SPRITE::Touch(mask, x, y); + if (mask & L_UP) { + uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < W / 2); + if (y < MIX_BHIG) { + if (*vol < 0xFF) + *vol += 0x11; + } else if (y >= H - MIX_BHIG) { + if (*vol > 0x00) + *vol -= 0x11; + } + Update(); + } } - -void MIXER::Tick (void) -{ - int x = Mouse.X, y = Mouse.Y; - if (SpriteAt(x, y) == this) - { - Fall = MIX_FALL; - if (Flags.Hold) Touch(L_UP, x-X, y-Y); - } - else - { - if (Fall) -- Fall; - else - { - int i; - for (i = 0; i < ArrayCount(Led); i ++) - { - SNPOST_(SNKILL, -1, 0, Led[i]); - } - SNPOST_(SNKILL, -1, 0, this); +void MIXER::Tick(void) { + int x = Mouse.X, y = Mouse.Y; + if (SpriteAt(x, y) == this) { + Fall = MIX_FALL; + if (Flags.Hold) + Touch(L_UP, x - X, y - Y); + } else { + if (Fall) + --Fall; + else { + for (int i = 0; i < ArrayCount(Led); i ++) + SNPOST_(SNKILL, -1, 0, Led[i]); + SNPOST_(SNKILL, -1, 0, this); + } } - } - Time = MIX_DELAY; + Time = MIX_DELAY; } +void MIXER::Update(void) { + Led[0]->Step(SNDDrvInfo.VOL4.ML); + Led[1]->Step(SNDDrvInfo.VOL4.DL); - -void MIXER::Update (void) -{ - Led[0]->Step(SNDDrvInfo.VOL4.ML); - Led[1]->Step(SNDDrvInfo.VOL4.DL); - - //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST_(SNEXEC, -1, 0, (void*)&SNDSetVolume); - warning("FIXME: MIXER::Update"); + //TODO Change the SNPOST message send to a special way to send function pointer + //SNPOST_(SNEXEC, -1, 0, (void*)&SNDSetVolume); + warning("STUB: MIXER::Update"); } } // End of namespace CGE diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index 30beaf2f5d..81bc7c7cdf 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -25,34 +25,33 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __MIXER__ -#define __MIXER__ +#ifndef __MIXER__ +#define __MIXER__ -#include "cge/vga13h.h" +#include "cge/vga13h.h" namespace CGE { -#define MIX_MAX 16 // count of Leds -#define MIX_Z 64 // mixer Z position -#define MIX_DELAY 12 // 6/s -#define MIX_FALL 6 // in MIX_DELAY units -#define MIX_BHIG 6 // mixer button high -#define MIX_NAME 105 // sprite name - -class MIXER : public SPRITE -{ - BMP_PTR mb[2]; - BMP_PTR lb[MIX_MAX+1]; - SEQ ls[MIX_MAX]; - SPRITE * Led[2]; - int Fall; - void Update (void); +#define MIX_MAX 16 // count of Leds +#define MIX_Z 64 // mixer Z position +#define MIX_DELAY 12 // 6/s +#define MIX_FALL 6 // in MIX_DELAY units +#define MIX_BHIG 6 // mixer button high +#define MIX_NAME 105 // sprite name + +class MIXER : public SPRITE { + BMP_PTR mb[2]; + BMP_PTR lb[MIX_MAX + 1]; + SEQ ls[MIX_MAX]; + SPRITE *Led[2]; + int Fall; + void Update(void); public: - static bool Appear; - MIXER (int x, int y); - ~MIXER (void); - void Touch (uint16 mask, int x, int y); - void Tick (void); + static bool Appear; + MIXER(int x, int y); + ~MIXER(void); + void Touch(uint16 mask, int x, int y); + void Tick(void); }; } // End of namespace CGE diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 552cddb500..70967667a5 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -1,5 +1,5 @@ MODULE := engines/cge - + MODULE_OBJS := \ bitmap.o \ bitmaps.o \ @@ -28,11 +28,12 @@ MODULE_OBJS := \ MODULE_DIRS += \ engines/cge - + # This module can be built as a plugin ifeq ($(ENABLE_CGE), DYNAMIC_PLUGIN) PLUGIN := 1 endif - + # Include common rules include $(srcdir)/rules.mk + diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index dff2a0ff8b..d97a7eca7f 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -25,215 +25,177 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/mouse.h" -#include "cge/text.h" -#include +#include "cge/mouse.h" +#include "cge/text.h" +#include namespace CGE { - EVENT Evt[EVT_MAX]; +EVENT Evt[EVT_MAX]; - uint16 EvtHead = 0, EvtTail = 0; -//-------------------------------------------------------------------------- +uint16 EvtHead = 0, EvtTail = 0; -MOUSE_FUN * MOUSE::OldMouseFun = NULL; -uint16 MOUSE::OldMouseMask = 0; +MOUSE_FUN *MOUSE::OldMouseFun = NULL; +uint16 MOUSE::OldMouseMask = 0; +MOUSE::MOUSE(BITMAP **shpl) : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0) { + static SEQ ms[] = { + { 0, 0, 0, 0, 1 }, + { 1, 1, 0, 0, 1 } + }; -//-------------------------------------------------------------------------- + SetSeq(ms); + /* TODO Mouse handling + // Mouse reset + _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work) + __int__(0x33); + Exist = (_AX != 0); + Buttons = _BX; - - - -MOUSE::MOUSE (BITMAP ** shpl) - : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0) -{ - static SEQ ms[] = { { 0,0,0,0,1 }, { 1,1,0,0,1 } }; - SetSeq(ms); - - /* TODO Mouse handling - // Mouse reset - _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work) - __int__(0x33); - Exist = (_AX != 0); - Buttons = _BX; - - Goto(SCR_WID/2, SCR_HIG/2); - Z = 127; - Step(1); - */ + Goto(SCR_WID/2, SCR_HIG/2); + Z = 127; + Step(1); + */ + warning("STUB: MOUSE::MOUSE"); } - - -MOUSE::~MOUSE (void) -{ - Off(); +MOUSE::~MOUSE(void) { + Off(); } - - - //void MOUSE::SetFun (void) //{ //} - - - -void MOUSE::On (void) -{ - // TODO Mouse -/* - if (SeqPtr && Exist) - { - _CX = X + X; // horizontal position - _DX = Y; // vertical position - _AX = 0x0004; // Set Mouse Position - __int__(0x33); - // set new mouse fun - _ES = FP_SEG(NewMouseFun); - _DX = FP_OFF(NewMouseFun); - _CX = 0x001F; // 11111b = all events - _AX = 0x0014; // Swap User-Interrupt Vector - __int__(0x33); - // save old mouse fun - OldMouseMask = _CX; - OldMouseFun = (MOUSE_FUN *) MK_FP(_ES, _DX); - - // set X bounds - _DX = (SCR_WID - W) * 2; // right limit - _CX = 0; // left limit - _AX = 0x0007; // note: each pixel = 2 - __int__(0x33); - - // set Y bounds - _DX = SCR_HIG - H; // bottom limit - _CX = 0; // top limit - _AX = 0x0008; - __int__(0x33); - - Step(0); - if (Busy) Busy->Step(0); - } -*/ +void MOUSE::On(void) { + /* + if (SeqPtr && Exist) + { + _CX = X + X; // horizontal position + _DX = Y; // vertical position + _AX = 0x0004; // Set Mouse Position + __int__(0x33); + // set new mouse fun + _ES = FP_SEG(NewMouseFun); + _DX = FP_OFF(NewMouseFun); + _CX = 0x001F; // 11111b = all events + _AX = 0x0014; // Swap User-Interrupt Vector + __int__(0x33); + // save old mouse fun + OldMouseMask = _CX; + OldMouseFun = (MOUSE_FUN *) MK_FP(_ES, _DX); + + // set X bounds + _DX = (SCR_WID - W) * 2; // right limit + _CX = 0; // left limit + _AX = 0x0007; // note: each pixel = 2 + __int__(0x33); + + // set Y bounds + _DX = SCR_HIG - H; // bottom limit + _CX = 0; // top limit + _AX = 0x0008; + __int__(0x33); + + Step(0); + if (Busy) Busy->Step(0); + } + */ + warning("STUB: MOUSE::On"); } - - - - -void MOUSE::Off (void) -{ -//TODO MOuse ASM - /* - if (SeqPtr == 0) - { - if (Exist) +void MOUSE::Off(void) { +/* + if (SeqPtr == 0) + { + if (Exist) { // bring back old mouse fun _ES = FP_SEG(OldMouseFun); _DX = FP_OFF(OldMouseFun); _CX = OldMouseMask; - _AX = 0x0014; // Swap User-Interrupt Vector + _AX = 0x0014; // Swap User-Interrupt Vector __int__(0x33); } - Step(1); - if (Busy) Busy->Step(1); - } + Step(1); + if (Busy) Busy->Step(1); + } */ + warning("STUB: MOUSE::Off"); } - - - - -void MOUSE::ClrEvt (SPRITE * spr) -{ - if (spr) - { - uint16 e; - for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) - if (Evt[e].Ptr == spr) Evt[e].Msk = 0; - } - else EvtTail = EvtHead; +void MOUSE::ClrEvt(SPRITE *spr) { + if (spr) { + uint16 e; + for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) + if (Evt[e].Ptr == spr) + Evt[e].Msk = 0; + } else + EvtTail = EvtHead; } - - - - -void MOUSE::Tick (void) -{ - Step(); - while (EvtTail != EvtHead) - { - EVENT e = Evt[EvtTail]; - if (e.Msk) - { - if (Hold && e.Ptr != Hold) - { - Hold->Touch(e.Msk | ATTN, e.X - Hold->X, e.Y - Hold->Y); - } - - // update mouse cursor position - if (e.Msk & ROLL) - { - Goto(e.X, e.Y); - } - - // activate current touched SPRITE - if (e.Ptr) - { - if (e.Msk & KEYB) e.Ptr->Touch(e.Msk, e.X, e.Y); - else e.Ptr->Touch(e.Msk, e.X - e.Ptr->X, e.Y - e.Ptr->Y); - } - else if (Sys) Sys->Touch(e.Msk, e.X, e.Y); - - if (e.Msk & L_DN) - { - Hold = e.Ptr; - if (Hold) - { - Hold->Flags.Hold = true; - #ifndef DEBUG - if (Hold->Flags.Drag) - #endif - { - hx = e.X - Hold->X; - hy = e.Y - Hold->Y; - } +void MOUSE::Tick(void) { + Step(); + while (EvtTail != EvtHead) { + EVENT e = Evt[EvtTail]; + if (e.Msk) { + if (Hold && e.Ptr != Hold) + Hold->Touch(e.Msk | ATTN, e.X - Hold->X, e.Y - Hold->Y); + + // update mouse cursor position + if (e.Msk & ROLL) + Goto(e.X, e.Y); + + // activate current touched SPRITE + if (e.Ptr) { + if (e.Msk & KEYB) + e.Ptr->Touch(e.Msk, e.X, e.Y); + else + e.Ptr->Touch(e.Msk, e.X - e.Ptr->X, e.Y - e.Ptr->Y); + } else if (Sys) + Sys->Touch(e.Msk, e.X, e.Y); + + if (e.Msk & L_DN) { + Hold = e.Ptr; + if (Hold) { + Hold->Flags.Hold = true; +#ifndef DEBUG + if (Hold->Flags.Drag) +#endif + { + hx = e.X - Hold->X; + hy = e.Y - Hold->Y; + } + } + } + + if (e.Msk & L_UP) { + if (Hold) { + Hold->Flags.Hold = false; + Hold = NULL; + } + } + ///Touched = e.Ptr; + + // discard Text if button released + if (e.Msk & (L_UP | R_UP)) + KillText(); } - } - - if (e.Msk & L_UP) - { - if (Hold) - { - Hold->Flags.Hold = false; - Hold = NULL; - } - } - ///Touched = e.Ptr; - - // discard Text if button released - if (e.Msk & (L_UP | R_UP)) KillText(); + EvtTail = (EvtTail + 1) % EVT_MAX; } - EvtTail = (EvtTail + 1) % EVT_MAX; - } - if (Hold) - #ifndef DEBUG - if (Hold->Flags.Drag) - #endif - Hold->Goto(X-hx, Y-hy); + if (Hold) +#ifndef DEBUG + if (Hold->Flags.Drag) +#endif + Hold->Goto(X - hx, Y - hy); } } // End of namespace CGE diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index 20015b058f..78f43665cd 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -25,62 +25,58 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __MOUSE__ -#define __MOUSE__ +#ifndef __MOUSE__ +#define __MOUSE__ -#include "cge/game.h" -#include "cge/talk.h" +#include "cge/game.h" +#include "cge/talk.h" namespace CGE { -#define EVT_MAX 256 -#define ROLL 0x01 -#define L_DN 0x02 -#define L_UP 0x04 -#define R_DN 0x08 -#define R_UP 0x10 -#define ATTN 0x20 -// 0x40 -#define KEYB 0x80 +#define EVT_MAX 256 +#define ROLL 0x01 +#define L_DN 0x02 +#define L_UP 0x04 +#define R_DN 0x08 +#define R_UP 0x10 +#define ATTN 0x20 // 0x40 +#define KEYB 0x80 -extern TALK * Talk; - -struct EVENT { uint16 Msk; - uint16 X, Y; - SPRITE * Ptr; - }; -extern EVENT Evt[EVT_MAX]; -extern uint16 EvtHead, EvtTail; -typedef void (MOUSE_FUN) (void); - +extern TALK *Talk; +struct EVENT { + uint16 Msk; + uint16 X, Y; + SPRITE *Ptr; +}; +extern EVENT Evt[EVT_MAX]; +extern uint16 EvtHead, EvtTail; +typedef void (MOUSE_FUN)(void); -class MOUSE : public SPRITE -{ - static MOUSE_FUN * OldMouseFun; - static MOUSE_FUN NewMouseFun; - static uint16 OldMouseMask; - SPRITE * Hold; - int hx, hy; - //void SetFun (void); - //void ResetFun (void); +class MOUSE : public SPRITE { + static MOUSE_FUN *OldMouseFun; + static MOUSE_FUN NewMouseFun; + static uint16 OldMouseMask; + SPRITE *Hold; + int hx, hy; + //void SetFun (void); + //void ResetFun (void); public: - bool Exist; - int Buttons; - SPRITE * Busy; - //SPRITE * Touched; - MOUSE (BITMAP ** shpl = MC); - ~MOUSE (void); - void On (void); - void Off (void); - static void ClrEvt (SPRITE * spr = NULL); - void Tick (void); + bool Exist; + int Buttons; + SPRITE *Busy; + //SPRITE * Touched; + MOUSE(BITMAP **shpl = MC); + ~MOUSE(void); + void On(void); + void Off(void); + static void ClrEvt(SPRITE *spr = NULL); + void Tick(void); }; - } // End of namespace CGE #endif diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 82ec4c596d..952e032222 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -25,1290 +25,1108 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/general.h" -#include "cge/sound.h" -#include "cge/snail.h" -#include "cge/vga13h.h" -#include "cge/bitmaps.h" -#include "cge/text.h" -#include "cge/mouse.h" -#include "cge/cge_main.h" -#include -//#include -//#include -#include -#include -#include "cge/keybd.h" +#include "cge/general.h" +#include "cge/sound.h" +#include "cge/snail.h" +#include "cge/vga13h.h" +#include "cge/bitmaps.h" +#include "cge/text.h" +#include "cge/mouse.h" +#include "cge/cge_main.h" +#include +#include +#include +#include "cge/keybd.h" namespace CGE { - int MaxCave = 0; +int MaxCave = 0; - SCB Scb = { NULL, 0, NULL }; - bool Flag[4]; - bool Dark = false; - bool Game = false; - int Now = 1; - int Lev = -1; - SNAIL Snail = false; - SNAIL Snail_ = true; +SCB Scb = { NULL, 0, NULL }; +bool Flag[4]; +bool Dark = false; +bool Game = false; +int Now = 1; +int Lev = -1; +SNAIL Snail = false; +SNAIL Snail_ = true; -extern SPRITE PocLight; +extern SPRITE PocLight; //------------------------------------------------------------------------- -// SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, +// SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, // NULL, NULL, NULL, NULL, }; -// int PocPtr = 0; +// int PocPtr = 0; //------------------------------------------------------------------------- -extern SPRITE * Pocket[]; -extern int PocPtr; -//------------------------------------------------------------------------- - -extern DAC * SysPal; -extern MOUSE Mouse; - - - -//------------------------------------------------------------------------- - - -static void SNGame (SPRITE * spr, int num) -{ - switch (num) - { - //-------------------------------------------------------------------- - case 1 : - { - #define STAGES 8 - #define DRESSED 3 - static SPRITE * dup[3] = { NULL, NULL, NULL }; - int buref = 0; - int Stage = 0; - - for (dup[0] = VGA::ShowQ.First(); dup[0]; dup[0] = dup[0]->Next) - { - buref = dup[0]->Ref; - if (buref / 1000 == 16 && buref % 100 == 6) - { - Stage = (buref / 100) % 10; - break; - } - } - if (dup[1] == NULL) - { - dup[1] = VGA::ShowQ.Locate(16003); // pan - dup[2] = VGA::ShowQ.Locate(16004); // pani - } - - if (Game) // continue game - { - int i = new_random(3), hand = (dup[0]->ShpCnt == 6); - ++ Stage; - if (hand && Stage > DRESSED) ++ hand; - if ( - Debug( i >= 0 || ) - dup[i] == spr && new_random(3) == 0) - { - SNPOST(SNSEQ, -1, 3, dup[0]); // yes - SNPOST(SNSEQ, -1, 3, dup[1]); // yes - SNPOST(SNSEQ, -1, 3, dup[2]); // yes - SNPOST(SNTNEXT, -1, 0, dup[0]); // reset Take - SNPOST(SNTNEXT, -1, 0, dup[1]); // reset Take - SNPOST(SNTNEXT, -1, 0, dup[2]); // reset Take - SNPOST(SNNNEXT, -1, 0, dup[0]); // reset Near - SNPOST(SNPAUSE, -1, 72, NULL); // little rest - SNPOST(SNSAY, 1, 16009, NULL); // hura - SNPOST(SNSAY, buref, 16010, NULL); // siadaj - SNPOST(SNSAY, 1, 16011, NULL); // postoj‘ - - if (hand) - { - SNPOST(SNSEND, 16060+hand, 16, NULL); // dawaj r‘k‘ - SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie - SNPOST(SNSEQ, 16060+hand, 1, NULL); // ruch - SNPOST(SNSOUND, 16060+hand, 16002, NULL); // szelest - SNPOST(SNWAIT, 16060+hand, 3, NULL); // podniesie - SNPOST(SNSWAP, buref, buref+100, NULL); // rozdziana - SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa - SNPOST(SNSEND, 16060+hand, -1, NULL); // chowaj r‘k‘ - SNPOST(SNWAIT, 16060+hand, -1, NULL); // r‘ka zamar’a - } - else - { - SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie - SNPOST(SNSOUND, 16060+hand, 16002, NULL); // szelest - SNPOST(SNWAIT, buref, -1, NULL); // zdejmie - SNPOST(SNSWAP, buref, buref+100, NULL); // rozdziana - SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa - } - //SNPOST(SNSEQ, buref+100, 0, NULL); // reset - SNPOST(SNPAUSE, -1, 72, NULL); // chwilk‘... - - SNPOST(SNSEQ, -1, 0, dup[1]); // odstaw Go - SNPOST(SNSETXY, -1, 203 + SCR_WID * 49, dup[1]); - SNPOST(SNSETZ, -1, 7, dup[1]); - - SNPOST(SNSEQ, -1, 0, dup[2]); // odstaw J† - SNPOST(SNSETXY, -1, 182 + SCR_WID * 62, dup[2]); - SNPOST(SNSETZ, -1, 9, dup[2]); - Game = 0; - return; - } - else - { - SNPOST(SNSEQ, -1, 2, dup[0]); // no - SNPOST(SNSEQ, -1, 2, dup[1]); // no - SNPOST(SNSEQ, -1, 2, dup[2]); // no - SNPOST(SNPAUSE, -1, 72, NULL); // 1 sec +extern SPRITE *Pocket[]; +extern int PocPtr; +extern DAC *SysPal; +extern MOUSE Mouse; + + +static void SNGame(SPRITE *spr, int num) { + switch (num) { + case 1 : { +#define STAGES 8 +#define DRESSED 3 + static SPRITE *dup[3] = { NULL, NULL, NULL }; + int buref = 0; + int Stage = 0; + + for (dup[0] = VGA::ShowQ.First(); dup[0]; dup[0] = dup[0]->Next) { + buref = dup[0]->Ref; + if (buref / 1000 == 16 && buref % 100 == 6) { + Stage = (buref / 100) % 10; + break; + } } - } - SNPOST(SNWALK, 198, 134, NULL); // na miejsce - SNPOST(SNWAIT, 1, -1, NULL); // stoi - SNPOST(SNCOVER, 1, 16101, NULL); // ch’op do bicia - SNPOST(SNSEQ, 16101, 1, NULL); // wystaw - SNPOST(SNWAIT, 16101, 5, NULL); // czekaj - SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘ - SNPOST(SNSEQ, 16040, 1, NULL); // plask - SNPOST(SNSOUND, 16101, 16001, NULL); // plask! - SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘ - SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask - SNPOST(SNWAIT, 16101, -1, NULL); // stoi - SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS - if (! Game) - { - SNPOST(SNSAY, buref, 16008, NULL); // zgadnij! - Game = true; - } - #undef STEPS - #undef DRESSED - } break; - //-------------------------------------------------------------------- - case 2 : - { - static SPRITE * k = NULL, * k1, * k2, * k3; - static int count = 0; - bool hit; - - if (k == NULL) - { - k = VGA::ShowQ.Locate(20700); - k1 = VGA::ShowQ.Locate(20701); - k2 = VGA::ShowQ.Locate(20702); - k3 = VGA::ShowQ.Locate(20703); - } - - if (! Game) // init - { - SNPOST(SNGAME, 20002, 2, NULL); - Game = true; - } - else // cont - { - k1->Step(new_random(6)); - k2->Step(new_random(6)); - k3->Step(new_random(6)); - ///-------------------- - if (spr->Ref == 1 && KEYBOARD::Key[ALT]) - { - k1->Step(5); - k2->Step(5); - k3->Step(5); + if (dup[1] == NULL) { + dup[1] = VGA::ShowQ.Locate(16003); // pan + dup[2] = VGA::ShowQ.Locate(16004); // pani } - ///-------------------- - SNPOST(SNSETZ, 20700, 0, NULL); - hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15); - if (hit) - { - if (spr->Ref == 1) - { - SNPOST(SNSAY, 1, 20003, NULL); // hura! - SNPOST(SNSEQ, 20011, 2, NULL); // kamera won - SNPOST(SNSEND, 20701, -1, NULL); // k1 won - SNPOST(SNSEND, 20702, -1, NULL); // k2 won - SNPOST(SNSEND, 20703, -1, NULL); // k3 won - SNPOST(SNSEND, 20700, -1, NULL); // tv won - SNPOST(SNKEEP, 20007, 0, NULL); // do kieszeni - SNPOST(SNSEND, 20006, 20, NULL); // bilon - SNPOST(SNSOUND,20006, 20002, NULL); // bilon! - SNPOST(SNSAY, 20002, 20004, NULL); - SNPOST(SNSEND, 20010, 20, NULL); // papier - SNPOST(SNSOUND,20010, 20003, NULL); // papier! - SNPOST(SNSAY, 20001, 20005, NULL); - Game = false; - return; - } - else k3->Step(new_random(5)); + + if (Game) { // continue game + int i = new_random(3), hand = (dup[0]->ShpCnt == 6); + ++ Stage; + if (hand && Stage > DRESSED) + ++hand; + if (Debug(i >= 0 ||) + dup[i] == spr && new_random(3) == 0) { + SNPOST(SNSEQ, -1, 3, dup[0]); // yes + SNPOST(SNSEQ, -1, 3, dup[1]); // yes + SNPOST(SNSEQ, -1, 3, dup[2]); // yes + SNPOST(SNTNEXT, -1, 0, dup[0]); // reset Take + SNPOST(SNTNEXT, -1, 0, dup[1]); // reset Take + SNPOST(SNTNEXT, -1, 0, dup[2]); // reset Take + SNPOST(SNNNEXT, -1, 0, dup[0]); // reset Near + SNPOST(SNPAUSE, -1, 72, NULL); // little rest + SNPOST(SNSAY, 1, 16009, NULL); // hura + SNPOST(SNSAY, buref, 16010, NULL); // siadaj + SNPOST(SNSAY, 1, 16011, NULL); // postoj‘ + + if (hand) { + SNPOST(SNSEND, 16060 + hand, 16, NULL); // dawaj r‘k‘ + SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie + SNPOST(SNSEQ, 16060 + hand, 1, NULL); // ruch + SNPOST(SNSOUND, 16060 + hand, 16002, NULL); // szelest + SNPOST(SNWAIT, 16060 + hand, 3, NULL); // podniesie + SNPOST(SNSWAP, buref, buref + 100, NULL); // rozdziana + SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa + SNPOST(SNSEND, 16060 + hand, -1, NULL); // chowaj r‘k‘ + SNPOST(SNWAIT, 16060 + hand, -1, NULL); // r‘ka zamar’a + } else { + SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie + SNPOST(SNSOUND, 16060 + hand, 16002, NULL); // szelest + SNPOST(SNWAIT, buref, -1, NULL); // zdejmie + SNPOST(SNSWAP, buref, buref + 100, NULL); // rozdziana + SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa + } + //SNPOST(SNSEQ, buref+100, 0, NULL); // reset + SNPOST(SNPAUSE, -1, 72, NULL); // chwilk‘... + + SNPOST(SNSEQ, -1, 0, dup[1]); // odstaw Go + SNPOST(SNSETXY, -1, 203 + SCR_WID * 49, dup[1]); + SNPOST(SNSETZ, -1, 7, dup[1]); + + SNPOST(SNSEQ, -1, 0, dup[2]); // odstaw J† + SNPOST(SNSETXY, -1, 182 + SCR_WID * 62, dup[2]); + SNPOST(SNSETZ, -1, 9, dup[2]); + Game = 0; + return; + } else { + SNPOST(SNSEQ, -1, 2, dup[0]); // no + SNPOST(SNSEQ, -1, 2, dup[1]); // no + SNPOST(SNSEQ, -1, 2, dup[2]); // no + SNPOST(SNPAUSE, -1, 72, NULL); // 1 sec + } + } + SNPOST(SNWALK, 198, 134, NULL); // na miejsce + SNPOST(SNWAIT, 1, -1, NULL); // stoi + SNPOST(SNCOVER, 1, 16101, NULL); // ch’op do bicia + SNPOST(SNSEQ, 16101, 1, NULL); // wystaw + SNPOST(SNWAIT, 16101, 5, NULL); // czekaj + SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘ + SNPOST(SNSEQ, 16040, 1, NULL); // plask + SNPOST(SNSOUND, 16101, 16001, NULL); // plask! + SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘ + SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask + SNPOST(SNWAIT, 16101, -1, NULL); // stoi + SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS + if (! Game) { + SNPOST(SNSAY, buref, 16008, NULL); // zgadnij! + Game = true; } - if (count < 100) - { - switch (count) - { - case 15 : SNPOST(SNSAY, 20003, 20021, NULL); break; - case 30 : - case 45 : - case 60 : - case 75 : SNPOST(SNSAY, 20003, 20022, NULL); break; - } - ++ count; +#undef STEPS +#undef DRESSED + } + break; + //-------------------------------------------------------------------- + case 2 : { + static SPRITE *k = NULL, * k1, * k2, * k3; + static int count = 0; + bool hit; + + if (k == NULL) { + k = VGA::ShowQ.Locate(20700); + k1 = VGA::ShowQ.Locate(20701); + k2 = VGA::ShowQ.Locate(20702); + k3 = VGA::ShowQ.Locate(20703); } - switch (spr->Ref) - { - case 1 : SNPOST(SNSAY, 20001, 20011, NULL); // zapro - SNPOST(SNSEQ, 20001, 1, NULL); // rzu - SNPOST(SNWAIT, 20001, 1, NULL); // czekaj - SNPOST(SNSETZ, 20700, 2, NULL); // skryj k - SNPOST(SNHIDE, 20007, 1, NULL); // skryj k - SNPOST(SNWAIT, 20001, 16, NULL); // czekaj - SNPOST(SNSEQ, 20007, 1, NULL); // lec† - SNPOST(SNHIDE, 20007, 0, NULL); // poka§ - SNPOST(SNSOUND,20007, 20001, NULL); // grzech - SNPOST(SNWAIT, 20007, -1, NULL); // koniec - SNPOST(SNGAME, 20001, 2, NULL); // again! - break; - case 20001 : SNPOST(SNSAY, 20002, 20012, NULL); // zapro - SNPOST(SNSEQ, 20002, 1, NULL); // rzu - SNPOST(SNWAIT, 20002, 3, NULL); // czekaj - SNPOST(SNSETZ, 20700, 2, NULL); // skryj k - SNPOST(SNHIDE, 20007, 1, NULL); // skryj k - SNPOST(SNWAIT, 20002, 10, NULL); // czekaj - SNPOST(SNSEQ, 20007, 2, NULL); // lec† - SNPOST(SNHIDE, 20007, 0, NULL); // poka§ - SNPOST(SNSOUND,20007, 20001, NULL); // grzech - SNPOST(SNWAIT, 20007, -1, NULL); // koniec - SNPOST(SNGAME, 20002, 2, NULL); // again! - break; - case 20002 : SNPOST(SNSAY, 20002, 20010, NULL); // zapro - SNPOST(SNWALK, 20005, -1, NULL); // do stol - SNPOST(SNWAIT, 1, -1, NULL); // stoi - SNPOST(SNCOVER, 1, 20101, NULL); // grasol - SNPOST(SNSEQ, 20101, 1, NULL); // rzu - SNPOST(SNWAIT, 20101, 5, NULL); // czekaj - SNPOST(SNSETZ, 20700, 2, NULL); // skryj k - SNPOST(SNHIDE, 20007, 1, NULL); // skryj k - SNPOST(SNWAIT, 20101, 15, NULL); // czekaj - SNPOST(SNSEQ, 20007, 1, NULL); // lec† - SNPOST(SNHIDE, 20007, 0, NULL); // poka§ - SNPOST(SNSOUND,20007, 20001, NULL); // grzech - SNPOST(SNWAIT, 20101, -1, NULL); // koniec - SNPOST(SNUNCOVER, 1, 20101, NULL); // SDS - SNPOST(SNGAME, 1, 2, NULL); // again! - break; + + if (! Game) { // init + SNPOST(SNGAME, 20002, 2, NULL); + Game = true; + } else { // cont + k1->Step(new_random(6)); + k2->Step(new_random(6)); + k3->Step(new_random(6)); + ///-------------------- + if (spr->Ref == 1 && KEYBOARD::Key[ALT]) { + k1->Step(5); + k2->Step(5); + k3->Step(5); + } + ///-------------------- + SNPOST(SNSETZ, 20700, 0, NULL); + hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15); + if (hit) { + if (spr->Ref == 1) { + SNPOST(SNSAY, 1, 20003, NULL); // hura! + SNPOST(SNSEQ, 20011, 2, NULL); // kamera won + SNPOST(SNSEND, 20701, -1, NULL); // k1 won + SNPOST(SNSEND, 20702, -1, NULL); // k2 won + SNPOST(SNSEND, 20703, -1, NULL); // k3 won + SNPOST(SNSEND, 20700, -1, NULL); // tv won + SNPOST(SNKEEP, 20007, 0, NULL); // do kieszeni + SNPOST(SNSEND, 20006, 20, NULL); // bilon + SNPOST(SNSOUND, 20006, 20002, NULL); // bilon! + SNPOST(SNSAY, 20002, 20004, NULL); + SNPOST(SNSEND, 20010, 20, NULL); // papier + SNPOST(SNSOUND, 20010, 20003, NULL); // papier! + SNPOST(SNSAY, 20001, 20005, NULL); + Game = false; + return; + } else + k3->Step(new_random(5)); + } + if (count < 100) { + switch (count) { + case 15 : + SNPOST(SNSAY, 20003, 20021, NULL); + break; + case 30 : + case 45 : + case 60 : + case 75 : + SNPOST(SNSAY, 20003, 20022, NULL); + break; + } + ++ count; + } + switch (spr->Ref) { + case 1 : + SNPOST(SNSAY, 20001, 20011, NULL); // zapro + SNPOST(SNSEQ, 20001, 1, NULL); // rzu + SNPOST(SNWAIT, 20001, 1, NULL); // czekaj + SNPOST(SNSETZ, 20700, 2, NULL); // skryj k + SNPOST(SNHIDE, 20007, 1, NULL); // skryj k + SNPOST(SNWAIT, 20001, 16, NULL); // czekaj + SNPOST(SNSEQ, 20007, 1, NULL); // lec† + SNPOST(SNHIDE, 20007, 0, NULL); // poka§ + SNPOST(SNSOUND, 20007, 20001, NULL); // grzech + SNPOST(SNWAIT, 20007, -1, NULL); // koniec + SNPOST(SNGAME, 20001, 2, NULL); // again! + break; + case 20001 : + SNPOST(SNSAY, 20002, 20012, NULL); // zapro + SNPOST(SNSEQ, 20002, 1, NULL); // rzu + SNPOST(SNWAIT, 20002, 3, NULL); // czekaj + SNPOST(SNSETZ, 20700, 2, NULL); // skryj k + SNPOST(SNHIDE, 20007, 1, NULL); // skryj k + SNPOST(SNWAIT, 20002, 10, NULL); // czekaj + SNPOST(SNSEQ, 20007, 2, NULL); // lec† + SNPOST(SNHIDE, 20007, 0, NULL); // poka§ + SNPOST(SNSOUND, 20007, 20001, NULL); // grzech + SNPOST(SNWAIT, 20007, -1, NULL); // koniec + SNPOST(SNGAME, 20002, 2, NULL); // again! + break; + case 20002 : + SNPOST(SNSAY, 20002, 20010, NULL); // zapro + SNPOST(SNWALK, 20005, -1, NULL); // do stol + SNPOST(SNWAIT, 1, -1, NULL); // stoi + SNPOST(SNCOVER, 1, 20101, NULL); // grasol + SNPOST(SNSEQ, 20101, 1, NULL); // rzu + SNPOST(SNWAIT, 20101, 5, NULL); // czekaj + SNPOST(SNSETZ, 20700, 2, NULL); // skryj k + SNPOST(SNHIDE, 20007, 1, NULL); // skryj k + SNPOST(SNWAIT, 20101, 15, NULL); // czekaj + SNPOST(SNSEQ, 20007, 1, NULL); // lec† + SNPOST(SNHIDE, 20007, 0, NULL); // poka§ + SNPOST(SNSOUND, 20007, 20001, NULL); // grzech + SNPOST(SNWAIT, 20101, -1, NULL); // koniec + SNPOST(SNUNCOVER, 1, 20101, NULL); // SDS + SNPOST(SNGAME, 1, 2, NULL); // again! + break; + } } - } - } break; - //-------------------------------------------------------------------- - } + } + break; + } } -//------------------------------------------------------------------------- - - - - -void ExpandSprite (SPRITE * spr) -{ - if (spr) VGA::ShowQ.Insert(VGA::SpareQ.Remove(spr)); +void ExpandSprite(SPRITE *spr) { + if (spr) + VGA::ShowQ.Insert(VGA::SpareQ.Remove(spr)); } - - - -void ContractSprite (SPRITE * spr) -{ - if (spr) VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); +void ContractSprite(SPRITE *spr) { + if (spr) + VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); } - - - - - - -int FindPocket (SPRITE * spr) -{ - int i; - for (i = 0; i < POCKET_NX; i ++) if (Pocket[i] == spr) return i; - return -1; +int FindPocket(SPRITE *spr) { + for (int i = 0; i < POCKET_NX; i ++) + if (Pocket[i] == spr) + return i; + return -1; } - - - -void SelectPocket (int n) -{ - if (n < 0 || (PocLight.SeqPtr && PocPtr == n)) - { - PocLight.Step(0); - n = FindPocket(NULL); - if (n >= 0) PocPtr = n; - } - else - { - if (Pocket[n] != NULL) - { - PocPtr = n; - PocLight.Step(1); +void SelectPocket(int n) { + if (n < 0 || (PocLight.SeqPtr && PocPtr == n)) { + PocLight.Step(0); + n = FindPocket(NULL); + if (n >= 0) + PocPtr = n; + } else { + if (Pocket[n] != NULL) { + PocPtr = n; + PocLight.Step(1); + } } - } - PocLight.Goto(POCKET_X+PocPtr*POCKET_DX+POCKET_SX, POCKET_Y+POCKET_SY); + PocLight.Goto(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); } - - - -void PocFul (void) -{ - Hero->Park(); - SNPOST(SNWAIT, -1, -1, Hero); - SNPOST(SNSEQ, -1, POC_FUL, Hero); - SNPOST(SNSOUND, -1, 2, Hero); - SNPOST(SNWAIT, -1, -1, Hero); - SNPOST(SNSAY, 1, POC_FUL_TEXT, Hero); +void PocFul(void) { + Hero->Park(); + SNPOST(SNWAIT, -1, -1, Hero); + SNPOST(SNSEQ, -1, POC_FUL, Hero); + SNPOST(SNSOUND, -1, 2, Hero); + SNPOST(SNWAIT, -1, -1, Hero); + SNPOST(SNSAY, 1, POC_FUL_TEXT, Hero); } - - -void Hide1 (SPRITE * spr) -{ - SNPOST_(SNGHOST, -1, 0, spr->Ghost()); +void Hide1(SPRITE *spr) { + SNPOST_(SNGHOST, -1, 0, spr->Ghost()); } - - -void SNGhost (BITMAP * bmp) -{ - // TODO : Get x and y from M but not using segment / offset - //bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M)); - bmp->M = NULL; - delete bmp; - warning("STUB: SNGhost"); +void SNGhost(BITMAP *bmp) { + // TODO : Get x and y from M but not using segment / offset + //bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M)); + bmp->M = NULL; + delete bmp; + warning("STUB: SNGhost"); } - - -void FeedSnail (SPRITE * spr, SNLIST snq) -{ - if (spr) if (spr->Active()) - { - uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; - - if (ptr != NO_PTR) - { - SNAIL::COM * comtab = spr->SnList(snq); - SNAIL::COM * c = comtab + ptr; - - if (FindPocket(NULL) < 0) // no empty pockets? - { - SNAIL::COM * p; - for (p = c; p->Com != SNNEXT; p ++) // find KEEP command - { - if (p->Com == SNKEEP) - { - PocFul(); - return; - } - if (p->Ptr) break; - } - } - while (true) - { - if (c->Com == SNTALK) - { - if ((Snail.TalkEnable = (c->Val != 0)) == false) KillText(); - } - if (c->Com == SNNEXT) - { - SPRITE * s = (c->Ref < 0) ? spr : Locate(c->Ref); - if (s) - { - uint8 * idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr; - if (*idx != NO_PTR) - { - int v; - switch (c->Val) - { - case -1 : v = c - comtab + 1; break; - case -2 : v = c - comtab; break; - case -3 : v = -1; break; - default : v = c->Val; break; - } - if (v >= 0) *idx = v; +void FeedSnail(SPRITE *spr, SNLIST snq) { + if (spr) + if (spr->Active()) { + uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; + + if (ptr != NO_PTR) { + SNAIL::COM *comtab = spr->SnList(snq); + SNAIL::COM *c = comtab + ptr; + + if (FindPocket(NULL) < 0) { // no empty pockets? + SNAIL::COM *p; + for (p = c; p->Com != SNNEXT; p ++) { // find KEEP command + if (p->Com == SNKEEP) { + PocFul(); + return; + } + if (p->Ptr) + break; + } + } + while (true) { + if (c->Com == SNTALK) { + if ((Snail.TalkEnable = (c->Val != 0)) == false) + KillText(); + } + if (c->Com == SNNEXT) { + SPRITE *s = (c->Ref < 0) ? spr : Locate(c->Ref); + if (s) { + uint8 *idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr; + if (*idx != NO_PTR) { + int v; + switch (c->Val) { + case -1 : + v = c - comtab + 1; + break; + case -2 : + v = c - comtab; + break; + case -3 : + v = -1; + break; + default : + v = c->Val; + break; + } + if (v >= 0) + *idx = v; + } + } + if (s == spr) + break; + } + if (c->Com == SNIF) { + SPRITE *s = (c->Ref < 0) ? spr : Locate(c->Ref); + if (s) { // sprite extsts + if (! s->SeqTest(-1)) + c = comtab + c->Val; // not parked + else + ++c; + } else + ++c; + } else { + SNPOST(c->Com, c->Ref, c->Val, spr); + if (c->Ptr) + break; + else + ++c; + } + } } - } - if (s == spr) break; - } - if (c->Com == SNIF) - { - SPRITE * s = (c->Ref < 0) ? spr : Locate(c->Ref); - if (s) // sprite extsts - { - if (! s->SeqTest(-1)) c = comtab + c->Val; // not parked - else ++ c; - } - else ++ c; - } - else - { - SNPOST(c->Com, c->Ref, c->Val, spr); - if (c->Ptr) break; - else ++ c; } - } - } - } } - - - - -//-------------------------------------------------------------------------- - -const char * SNAIL::ComTxt[] = { "LABEL", "PAUSE", "WAIT", "LEVEL", - "HIDE", "SAY", "INF", "TIME", - "CAVE", "KILL", "RSEQ", - "SEQ", "SEND", "SWAP", "KEEP", "GIVE", - "IF", "GAME", "SETX0", "SETY0", "SLAVE", - "SETXY", "RELX", "RELY", "RELZ", - "SETX", "SETY", "SETZ", "TRANS", "PORT", - "NEXT","NNEXT", "TNEXT", "RNNEXT", "RTNEXT", - "RMNEAR", "RMTAKE", "FLAG", "SETREF", - "BACKPT", "FLASH", "LIGHT", - "SETHB", "SETVB", - "WALK", "REACH", "COVER", "UNCOVER", - "CLEAR", "TALK", "MOUSE", - "SOUND", "COUNT", - NULL }; - - - -SNAIL::SNAIL (bool turbo) -: Turbo(turbo), Busy(false), TextDelay(false), - Pause(0), TalkEnable(true), - Head(0), Tail(0), SNList(farnew(COM, 256)) -{ +const char *SNAIL::ComTxt[] = { + "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", + "SAY", "INF", "TIME", "CAVE", "KILL", + "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", + "GIVE", "IF", "GAME", "SETX0", "SETY0", + "SLAVE", "SETXY", "RELX", "RELY", "RELZ", + "SETX", "SETY", "SETZ", "TRANS", "PORT", + "NEXT", "NNEXT", "TNEXT", "RNNEXT", "RTNEXT", + "RMNEAR", "RMTAKE", "FLAG", "SETREF", "BACKPT", + "FLASH", "LIGHT", "SETHB", "SETVB", "WALK", + "REACH", "COVER", "UNCOVER", "CLEAR", "TALK", + "MOUSE", "SOUND", "COUNT", NULL +}; + + +SNAIL::SNAIL(bool turbo) + : Turbo(turbo), Busy(false), TextDelay(false), + Pause(0), TalkEnable(true), + Head(0), Tail(0), SNList(farnew(COM, 256)) { } - - - - -SNAIL::~SNAIL (void) -{ - if (SNList) free(SNList); +SNAIL::~SNAIL(void) { + if (SNList) + free(SNList); } - - - - -void SNAIL::AddCom (SNCOM com, int ref, int val, void * ptr) -{ - _disable(); - COM * snc = &SNList[Head ++]; - snc->Com = com; - snc->Ref = ref; - snc->Val = val; - snc->Ptr = ptr; - if (com == SNCLEAR) - { - Tail = Head; - KillText(); - Pause = 0; - } - _enable(); +void SNAIL::AddCom(SNCOM com, int ref, int val, void *ptr) { + _disable(); + COM *snc = &SNList[Head ++]; + snc->Com = com; + snc->Ref = ref; + snc->Val = val; + snc->Ptr = ptr; + if (com == SNCLEAR) { + Tail = Head; + KillText(); + Pause = 0; + } + _enable(); } - - -void SNAIL::InsCom (SNCOM com, int ref, int val, void * ptr) -{ - COM * snc; - - _disable(); - if (Busy) - { - SNList[(Tail-1)&0xFF] = SNList[Tail]; - snc = &SNList[Tail]; - } - else snc = &SNList[(Tail-1)&0xFF]; - -- Tail; - snc->Com = com; - snc->Ref = ref; - snc->Val = val; - snc->Ptr = ptr; - if (com == SNCLEAR) - { - Tail = Head; - KillText(); - Pause = 0; - } - _enable(); +void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { + COM *snc; + + _disable(); + if (Busy) { + SNList[(Tail - 1) & 0xFF] = SNList[Tail]; + snc = &SNList[Tail]; + } else + snc = &SNList[(Tail - 1) & 0xFF]; + --Tail; + snc->Com = com; + snc->Ref = ref; + snc->Val = val; + snc->Ptr = ptr; + if (com == SNCLEAR) { + Tail = Head; + KillText(); + Pause = 0; + } + _enable(); } - - - - - -static void SNNNext(SPRITE * sprel, int p) -{ - if (sprel) if (sprel->NearPtr != NO_PTR) sprel->NearPtr = p; +static void SNNNext(SPRITE *sprel, int p) { + if (sprel) + if (sprel->NearPtr != NO_PTR) + sprel->NearPtr = p; } - - - - -static void SNTNext(SPRITE * sprel, int p) -{ - if (sprel) if (sprel->TakePtr != NO_PTR) sprel->TakePtr = p; +static void SNTNext(SPRITE *sprel, int p) { + if (sprel) + if (sprel->TakePtr != NO_PTR) + sprel->TakePtr = p; } - - - - -static void SNRNNext(SPRITE * sprel, int p) -{ - if (sprel) if (sprel->NearPtr != NO_PTR) sprel->NearPtr += p; +static void SNRNNext(SPRITE *sprel, int p) { + if (sprel) + if (sprel->NearPtr != NO_PTR) + sprel->NearPtr += p; } - - - - -static void SNRTNext(SPRITE * sprel, int p) -{ - if (sprel) if (sprel->TakePtr != NO_PTR) sprel->TakePtr += p; +static void SNRTNext(SPRITE *sprel, int p) { + if (sprel) + if (sprel->TakePtr != NO_PTR) + sprel->TakePtr += p; } - - - - -static void SNZTrim (SPRITE * spr) -{ - if (spr) if (spr->Active()) - { - bool en = HEART::Enable; - SPRITE * s; - HEART::Enable = false; - s = (spr->Flags.Shad) ? spr->Prev : NULL; - VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr)); - if (s) - { - s->Z = spr->Z; - VGA::ShowQ.Insert(VGA::ShowQ.Remove(s), spr); - } - HEART::Enable = en; - } +static void SNZTrim(SPRITE *spr) { + if (spr) + if (spr->Active()) { + bool en = HEART::Enable; + SPRITE *s; + HEART::Enable = false; + s = (spr->Flags.Shad) ? spr->Prev : NULL; + VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr)); + if (s) { + s->Z = spr->Z; + VGA::ShowQ.Insert(VGA::ShowQ.Remove(s), spr); + } + HEART::Enable = en; + } } - - - - -static void SNHide (SPRITE * spr, int val) -{ - if (spr) - { - spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide); - if (spr->Flags.Shad) spr->Prev->Flags.Hide = spr->Flags.Hide; - } +static void SNHide(SPRITE *spr, int val) { + if (spr) { + spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide); + if (spr->Flags.Shad) + spr->Prev->Flags.Hide = spr->Flags.Hide; + } } - - - -static void SNRmNear (SPRITE * spr) -{ - if (spr) spr->NearPtr = NO_PTR; +static void SNRmNear(SPRITE *spr) { + if (spr) + spr->NearPtr = NO_PTR; } - - - -static void SNRmTake (SPRITE * spr) -{ - if (spr) spr->TakePtr = NO_PTR; +static void SNRmTake(SPRITE *spr) { + if (spr) + spr->TakePtr = NO_PTR; } - - - -void SNSeq (SPRITE * spr, int val) -{ - if (spr) - { - if (spr == Hero && val == 0) Hero->Park(); - else spr->Step(val); - } +void SNSeq(SPRITE *spr, int val) { + if (spr) { + if (spr == Hero && val == 0) + Hero->Park(); + else + spr->Step(val); + } } - - - -void SNRSeq (SPRITE * spr, int val) -{ - if (spr) SNSeq(spr, spr->SeqPtr + val); +void SNRSeq(SPRITE *spr, int val) { + if (spr) + SNSeq(spr, spr->SeqPtr + val); } - - - -void SNSend (SPRITE * spr, int val) -{ - if (spr) - { - int was = spr->Cave; - bool was1 = (was == 0 || was == Now); - bool val1 = (val == 0 || val == Now); - spr->Cave = val; - if (val1 != was1) - { - if (was1) - { - if (spr->Flags.Kept) - { - int n = FindPocket(spr); - if (n >= 0) Pocket[n] = NULL; +void SNSend(SPRITE *spr, int val) { + if (spr) { + int was = spr->Cave; + bool was1 = (was == 0 || was == Now); + bool val1 = (val == 0 || val == Now); + spr->Cave = val; + if (val1 != was1) { + if (was1) { + if (spr->Flags.Kept) { + int n = FindPocket(spr); + if (n >= 0) + Pocket[n] = NULL; + } + Hide1(spr); + ContractSprite(spr); + spr->Flags.Slav = false; + } else { + if (spr->Ref % 1000 == 0) + BITMAP::Pal = SysPal; + if (spr->Flags.Back) + spr->BackShow(true); + else + ExpandSprite(spr); + BITMAP::Pal = NULL; + } } - Hide1(spr); - ContractSprite(spr); - spr->Flags.Slav = false; - } - else - { - if (spr->Ref % 1000 == 0) BITMAP::Pal = SysPal; - if (spr->Flags.Back) spr->BackShow(true); - else ExpandSprite(spr); - BITMAP::Pal = NULL; - } } - } } - - - -void SNSwap (SPRITE * spr, int xref) -{ - SPRITE * xspr = Locate(xref); - if (spr && xspr) - { - int was = spr->Cave; - int xwas = xspr->Cave; - bool was1 = (was == 0 || was == Now); - bool xwas1 = (xwas == 0 || xwas == Now); - - Swap(spr->Cave, xspr->Cave); - Swap(spr->X, xspr->X); - Swap(spr->Y, xspr->Y); - Swap(spr->Z, xspr->Z); - if (spr->Flags.Kept) - { - int n = FindPocket(spr); - if (n >= 0) Pocket[n] = xspr; - xspr->Flags.Kept = true; - xspr->Flags.Port = false; - } - if (xwas1 != was1) - { - if (was1) - { - Hide1(spr); - ContractSprite(spr); - } - else ExpandSprite(spr); - if (xwas1) - { - Hide1(xspr); - ContractSprite(xspr); - } - else ExpandSprite(xspr); +void SNSwap(SPRITE *spr, int xref) { + SPRITE *xspr = Locate(xref); + if (spr && xspr) { + int was = spr->Cave; + int xwas = xspr->Cave; + bool was1 = (was == 0 || was == Now); + bool xwas1 = (xwas == 0 || xwas == Now); + + Swap(spr->Cave, xspr->Cave); + Swap(spr->X, xspr->X); + Swap(spr->Y, xspr->Y); + Swap(spr->Z, xspr->Z); + if (spr->Flags.Kept) { + int n = FindPocket(spr); + if (n >= 0) + Pocket[n] = xspr; + xspr->Flags.Kept = true; + xspr->Flags.Port = false; + } + if (xwas1 != was1) { + if (was1) { + Hide1(spr); + ContractSprite(spr); + } else + ExpandSprite(spr); + if (xwas1) { + Hide1(xspr); + ContractSprite(xspr); + } else + ExpandSprite(xspr); + } } - } } - - - -void SNCover (SPRITE * spr, int xref) -{ - SPRITE * xspr = Locate(xref); - if (spr && xspr) - { - spr->Flags.Hide = true; - xspr->Z = spr->Z; - xspr->Cave = spr->Cave; - xspr->Goto(spr->X, spr->Y); - ExpandSprite(xspr); - if ((xspr->Flags.Shad = spr->Flags.Shad) == TRUE) - { - VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr); - spr->Flags.Shad = false; +void SNCover(SPRITE *spr, int xref) { + SPRITE *xspr = Locate(xref); + if (spr && xspr) { + spr->Flags.Hide = true; + xspr->Z = spr->Z; + xspr->Cave = spr->Cave; + xspr->Goto(spr->X, spr->Y); + ExpandSprite(xspr); + if ((xspr->Flags.Shad = spr->Flags.Shad) == TRUE) { + VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr); + spr->Flags.Shad = false; + } + FeedSnail(xspr, NEAR); } - FeedSnail(xspr, NEAR); - } } - - - -void SNUncover (SPRITE * spr, SPRITE * xspr) -{ - if (spr && xspr) - { - spr->Flags.Hide = false; - spr->Cave = xspr->Cave; - spr->Goto(xspr->X, xspr->Y); - if ((spr->Flags.Shad = xspr->Flags.Shad) == TRUE) - { - VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr); - xspr->Flags.Shad = false; +void SNUncover(SPRITE *spr, SPRITE *xspr) { + if (spr && xspr) { + spr->Flags.Hide = false; + spr->Cave = xspr->Cave; + spr->Goto(xspr->X, xspr->Y); + if ((spr->Flags.Shad = xspr->Flags.Shad) == TRUE) { + VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr); + xspr->Flags.Shad = false; + } + spr->Z = xspr->Z; + SNSend(xspr, -1); + if (spr->Time == 0) + ++spr->Time; } - spr->Z = xspr->Z; - SNSend(xspr, -1); - if (spr->Time == 0) ++ spr->Time; - } } - - - -void SNSetX0 (int cav, int x0) -{ - HeroXY[cav-1].X = x0; +void SNSetX0(int cav, int x0) { + HeroXY[cav - 1].X = x0; } - - - -void SNSetY0 (int cav, int y0) -{ - HeroXY[cav-1].Y = y0; +void SNSetY0(int cav, int y0) { + HeroXY[cav - 1].Y = y0; } - - - -void SNSetXY (SPRITE * spr, uint16 xy) -{ - if (spr) - { - spr->Goto(xy % SCR_WID, xy / SCR_WID); - } +void SNSetXY(SPRITE *spr, uint16 xy) { + if (spr) + spr->Goto(xy % SCR_WID, xy / SCR_WID); } - - - -void SNRelX (SPRITE * spr, int x) -{ - if (spr && Hero) - { - spr->Goto(Hero->X + x, spr->Y); - } +void SNRelX(SPRITE *spr, int x) { + if (spr && Hero) + spr->Goto(Hero->X + x, spr->Y); } - - - -void SNRelY (SPRITE * spr, int y) -{ - if (spr && Hero) - { - spr->Goto(spr->X, Hero->Y + y); - } +void SNRelY(SPRITE *spr, int y) { + if (spr && Hero) + spr->Goto(spr->X, Hero->Y + y); } - - - -void SNRelZ (SPRITE * spr, int z) -{ - if (spr && Hero) - { - spr->Z = Hero->Z + z; - SNZTrim(spr); - } +void SNRelZ(SPRITE *spr, int z) { + if (spr && Hero) { + spr->Z = Hero->Z + z; + SNZTrim(spr); + } } - - - -void SNSetX (SPRITE * spr, int x) -{ - if (spr) - { - spr->Goto(x, spr->Y); - } +void SNSetX(SPRITE *spr, int x) { + if (spr) + spr->Goto(x, spr->Y); } - - - -void SNSetY (SPRITE * spr, int y) -{ - if (spr) - { - spr->Goto(spr->X, y); - } +void SNSetY(SPRITE *spr, int y) { + if (spr) + spr->Goto(spr->X, y); } - - - -void SNSetZ (SPRITE * spr, int z) -{ - if (spr) - { - spr->Z = z; - //SNPOST_(SNZTRIM, -1, 0, spr); - SNZTrim(spr); - } +void SNSetZ(SPRITE *spr, int z) { + if (spr) { + spr->Z = z; + //SNPOST_(SNZTRIM, -1, 0, spr); + SNZTrim(spr); + } } - - - -void SNSlave (SPRITE * spr, int ref) -{ - SPRITE * slv = Locate(ref); - if (spr && slv) - { - if (spr->Active()) - { - SNSend(slv, spr->Cave); - slv->Flags.Slav = true; - slv->Z = spr->Z; - VGA::ShowQ.Insert(VGA::ShowQ.Remove(slv), spr->Next); +void SNSlave(SPRITE *spr, int ref) { + SPRITE *slv = Locate(ref); + if (spr && slv) { + if (spr->Active()) { + SNSend(slv, spr->Cave); + slv->Flags.Slav = true; + slv->Z = spr->Z; + VGA::ShowQ.Insert(VGA::ShowQ.Remove(slv), spr->Next); + } } - } } - - - -void SNTrans (SPRITE * spr, int trans) -{ - if (spr) - { - spr->Flags.Tran = (trans < 0) ? !spr->Flags.Tran : (trans != 0); - } +void SNTrans(SPRITE *spr, int trans) { + if (spr) + spr->Flags.Tran = (trans < 0) ? !spr->Flags.Tran : (trans != 0); } - - - -void SNPort (SPRITE * spr, int port) -{ - if (spr) - { - spr->Flags.Port = (port < 0) ? !spr->Flags.Port : (port != 0); - } +void SNPort(SPRITE *spr, int port) { + if (spr) + spr->Flags.Port = (port < 0) ? !spr->Flags.Port : (port != 0); } - - - -void SNKill (SPRITE * spr) -{ - if (spr) - { - if (spr->Flags.Kept) - { - int n = FindPocket(spr); - if (n >= 0) Pocket[n] = NULL; - } - SPRITE * nx = spr->Next; - Hide1(spr); - VGA::ShowQ.Remove(spr); - MOUSE::ClrEvt(spr); - if (spr->Flags.Kill) delete spr; - else - { - spr->Cave = -1; - VGA::SpareQ.Append(spr); +void SNKill(SPRITE *spr) { + if (spr) { + if (spr->Flags.Kept) { + int n = FindPocket(spr); + if (n >= 0) + Pocket[n] = NULL; + } + SPRITE *nx = spr->Next; + Hide1(spr); + VGA::ShowQ.Remove(spr); + MOUSE::ClrEvt(spr); + if (spr->Flags.Kill) + delete spr; + else { + spr->Cave = -1; + VGA::SpareQ.Append(spr); + } + if (nx) + if (nx->Flags.Slav) + SNKill(nx); } - if (nx) if (nx->Flags.Slav) SNKill(nx); - } } - - - -static void SNSound (SPRITE * spr, int wav, int cnt) -{ - if (SNDDrvInfo.DDEV) - { - if (wav == -1) Sound.Stop(); - else - Sound.Play(Fx[wav], (spr) ? ((spr->X+spr->W/2)/(SCR_WID/16)) : 8, cnt); - } +static void SNSound(SPRITE *spr, int wav, int cnt) { + if (SNDDrvInfo.DDEV) { + if (wav == -1) + Sound.Stop(); + else + Sound.Play(Fx[wav], (spr) ? ((spr->X + spr->W / 2) / (SCR_WID / 16)) : 8, cnt); + } } - - - -void SNKeep (SPRITE * spr, int stp) -{ - SelectPocket(-1); - if (spr && ! spr->Flags.Kept && Pocket[PocPtr] == NULL) - { - SNSound(spr, 3, 1); - Pocket[PocPtr] = spr; - spr->Cave = 0; - spr->Flags.Kept = true; - spr->Goto(POCKET_X + POCKET_DX*PocPtr + POCKET_DX/2 - spr->W/2, - POCKET_Y + POCKET_DY/2 - spr->H/2); - if (stp >= 0) spr->Step(stp); - } - SelectPocket(-1); +void SNKeep(SPRITE *spr, int stp) { + SelectPocket(-1); + if (spr && ! spr->Flags.Kept && Pocket[PocPtr] == NULL) { + SNSound(spr, 3, 1); + Pocket[PocPtr] = spr; + spr->Cave = 0; + spr->Flags.Kept = true; + spr->Goto(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->W / 2, + POCKET_Y + POCKET_DY / 2 - spr->H / 2); + if (stp >= 0) + spr->Step(stp); + } + SelectPocket(-1); } - - - - -void SNGive (SPRITE * spr, int stp) -{ - if (spr) - { - int p = FindPocket(spr); - if (p >= 0) - { - Pocket[p] = NULL; - spr->Cave = Now; - spr->Flags.Kept = false; - if (stp >= 0) spr->Step(stp); +void SNGive(SPRITE *spr, int stp) { + if (spr) { + int p = FindPocket(spr); + if (p >= 0) { + Pocket[p] = NULL; + spr->Cave = Now; + spr->Flags.Kept = false; + if (stp >= 0) + spr->Step(stp); + } } - } - SelectPocket(-1); + SelectPocket(-1); } - - -static void SNBackPt (SPRITE * spr, int stp) -{ - if (spr) - { - if (stp >= 0) spr->Step(stp); - spr->BackShow(true); - } +static void SNBackPt(SPRITE *spr, int stp) { + if (spr) { + if (stp >= 0) + spr->Step(stp); + spr->BackShow(true); + } } - - - -static void SNLevel (SPRITE * spr, int lev) -{ - #ifdef DEMO - static int maxcav[] = { CAVE_MAX }; - #else - static int maxcav[] = { 1, 8, 16, 23, 24 }; - #endif - while (Lev < lev) - { - SPRITE * spr; - ++ Lev; - spr = VGA::SpareQ.Locate(100+Lev); - if (spr) - { - spr->BackShow(true); - spr->Cave = 0; +static void SNLevel(SPRITE *spr, int lev) { +#ifdef DEMO + static int maxcav[] = { CAVE_MAX }; +#else + static int maxcav[] = { 1, 8, 16, 23, 24 }; +#endif + while (Lev < lev) { + SPRITE *spr; + ++Lev; + spr = VGA::SpareQ.Locate(100 + Lev); + if (spr) { + spr->BackShow(true); + spr->Cave = 0; + } } - } - MaxCave = maxcav[Lev]; - if (spr) spr->Flags.Hide = false; + MaxCave = maxcav[Lev]; + if (spr) + spr->Flags.Hide = false; } - - - - -static void SNFlag (int fn, bool v) -{ - Flag[fn] = v; +static void SNFlag(int fn, bool v) { + Flag[fn] = v; } - - - - -static void SNSetRef (SPRITE * spr, int nr) -{ - if (spr) - { - spr->Ref = nr; - } +static void SNSetRef(SPRITE *spr, int nr) { + if (spr) + spr->Ref = nr; } - - -void SNFlash (bool on) -{ - if (on) - { - DAC * pal = farnew(DAC, PAL_CNT); - if (pal) - { - int i; - memcpy(pal, SysPal, PAL_SIZ); - for (i = 0; i < PAL_CNT; i ++) - { - register int c; - c = pal[i].R << 1; pal[i].R = (c < 64) ? c : 63; - c = pal[i].G << 1; pal[i].G = (c < 64) ? c : 63; - c = pal[i].B << 1; pal[i].B = (c < 64) ? c : 63; - } - VGA::SetColors(pal, 64); - } - } - else VGA::SetColors(SysPal, 64); - Dark = false; +void SNFlash(bool on) { + if (on) { + DAC *pal = farnew(DAC, PAL_CNT); + if (pal) { + memcpy(pal, SysPal, PAL_SIZ); + for (int i = 0; i < PAL_CNT; i ++) { + register int c; + c = pal[i].R << 1; + pal[i].R = (c < 64) ? c : 63; + c = pal[i].G << 1; + pal[i].G = (c < 64) ? c : 63; + c = pal[i].B << 1; + pal[i].B = (c < 64) ? c : 63; + } + VGA::SetColors(pal, 64); + } + } else + VGA::SetColors(SysPal, 64); + Dark = false; } - - - -static void SNLight (bool in) -{ - if (in) VGA::Sunrise(SysPal); - else VGA::Sunset(); - Dark = ! in; +static void SNLight(bool in) { + if (in) + VGA::Sunrise(SysPal); + else + VGA::Sunset(); + Dark = ! in; } - - - -static void SNBarrier (int cav, int bar, bool horz) -{ - ((uint8 *) (Barriers + ((cav > 0) ? cav : Now)))[horz] = bar; +static void SNBarrier(int cav, int bar, bool horz) { + ((uint8 *)(Barriers + ((cav > 0) ? cav : Now)))[horz] = bar; } - - - -static void SNWalk (SPRITE * spr, int x, int y) -{ - if (Hero) - { - if (spr && y < 0) Hero->FindWay(spr); - else Hero->FindWay(XZ(x, y)); - } +static void SNWalk(SPRITE *spr, int x, int y) { + if (Hero) { + if (spr && y < 0) + Hero->FindWay(spr); + else + Hero->FindWay(XZ(x, y)); + } } - - - -static void SNReach (SPRITE * spr, int mode) -{ - if (Hero) Hero->Reach(spr, mode); +static void SNReach(SPRITE *spr, int mode) { + if (Hero) + Hero->Reach(spr, mode); } - - - - -static void SNMouse (bool on) -{ - if (on) Mouse.On(); - else Mouse.Off(); +static void SNMouse(bool on) { + if (on) + Mouse.On(); + else + Mouse.Off(); } +void SNAIL::RunCom(void) { + static int count = 1; + extern void SwitchCave(int); + if (! Busy) { + Busy = true; + uint8 tmphea = Head; + while (Tail != tmphea) { + COM *snc = &SNList[Tail]; + + if (! Turbo) { // only for the slower one + if (Pause) + break; + else { + if (TextDelay) { + KillText(); + TextDelay = false; + } + } + if (Talk && snc->Com != SNPAUSE) + break; + } - - - -void SNAIL::RunCom (void) -{ - static int count = 1; - extern void SwitchCave(int); - if (! Busy) - { - Busy = true; - uint8 tmphea = Head; - while (Tail != tmphea) - { - COM * snc = &SNList[Tail]; - - if (! Turbo) // only for the slower one - { - if (Pause) break; - else - { - if (TextDelay) - { - KillText(); - TextDelay = false; - } - } - if (Talk && snc->Com != SNPAUSE) break; - } - - SPRITE * sprel = ((snc->Ref >= 0) ? Locate(snc->Ref) - : ((SPRITE *) snc->Ptr)); - switch (snc->Com) - { - case SNLABEL : break; - case SNPAUSE : HEART::SetXTimer(&Pause, snc->Val); - if (Talk) TextDelay = true; break; - case SNWAIT : if (sprel) - { - if (sprel->SeqTest(snc->Val) && - (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) - { - HEART::SetXTimer(&Pause, sprel->Time); - } - else goto xit; - } + SPRITE *sprel = ((snc->Ref >= 0) ? Locate(snc->Ref) : ((SPRITE *) snc->Ptr)); + switch (snc->Com) { + case SNLABEL : + break; + case SNPAUSE : + HEART::SetXTimer(&Pause, snc->Val); + if (Talk) + TextDelay = true; + break; + case SNWAIT : + if (sprel) { + if (sprel->SeqTest(snc->Val) && + (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) { + HEART::SetXTimer(&Pause, sprel->Time); + } else + goto xit; + } + break; + case SNLEVEL : + SNLevel(sprel, snc->Val); + break; + case SNHIDE : + SNHide(sprel, snc->Val); + break; + case SNSAY : + if (sprel && TalkEnable) { + if (sprel == Hero && sprel->SeqTest(-1)) + sprel->Step(HTALK); + Say(Text[snc->Val], sprel); + SYSTEM::FunDel = HEROFUN0; + } + break; + case SNINF : + if (TalkEnable) { + Inf(Text[snc->Val]); + SYSTEM::FunDel = HEROFUN0; + } + break; + case SNTIME : + if (sprel && TalkEnable) { + if (sprel == Hero && sprel->SeqTest(-1)) + sprel->Step(HTALK); + SayTime(sprel); + } + break; + case SNCAVE : + SwitchCave(snc->Val); + break; + case SNKILL : + SNKill(sprel); + break; + case SNSEQ : + SNSeq(sprel, snc->Val); + break; + case SNRSEQ : + SNRSeq(sprel, snc->Val); + break; + case SNSEND : + SNSend(sprel, snc->Val); + break; + case SNSWAP : + SNSwap(sprel, snc->Val); + break; + case SNCOVER : + SNCover(sprel, snc->Val); + break; + case SNUNCOVER : + SNUncover(sprel, (snc->Val >= 0) ? Locate(snc->Val) : ((SPRITE *) snc->Ptr)); + break; + case SNKEEP : + SNKeep(sprel, snc->Val); + break; + case SNGIVE : + SNGive(sprel, snc->Val); + break; + case SNGAME : + SNGame(sprel, snc->Val); + break; + case SNSETX0 : + SNSetX0(snc->Ref, snc->Val); + break; + case SNSETY0 : + SNSetY0(snc->Ref, snc->Val); break; - case SNLEVEL : SNLevel(sprel, snc->Val); break; - case SNHIDE : SNHide(sprel, snc->Val); break; - case SNSAY : if (sprel && TalkEnable) - { - if (sprel == Hero && sprel->SeqTest(-1)) - sprel->Step(HTALK); - Say(Text[snc->Val], sprel); - SYSTEM::FunDel = HEROFUN0; - } + case SNSETXY : + SNSetXY(sprel, snc->Val); break; - case SNINF : if (TalkEnable) - { - Inf(Text[snc->Val]); - SYSTEM::FunDel = HEROFUN0; - } + case SNRELX : + SNRelX(sprel, snc->Val); break; - case SNTIME : if (sprel && TalkEnable) - { - if (sprel == Hero && sprel->SeqTest(-1)) - sprel->Step(HTALK); - SayTime(sprel); - } + case SNRELY : + SNRelY(sprel, snc->Val); break; - case SNCAVE : SwitchCave(snc->Val); break; - case SNKILL : SNKill(sprel); break; - case SNSEQ : SNSeq(sprel, snc->Val); break; - case SNRSEQ : SNRSeq(sprel, snc->Val); break; - case SNSEND : SNSend(sprel, snc->Val); break; - case SNSWAP : SNSwap(sprel, snc->Val); break; - case SNCOVER : SNCover(sprel, snc->Val); break; - case SNUNCOVER : SNUncover(sprel, (snc->Val >= 0) ? Locate(snc->Val) - : ((SPRITE *) snc->Ptr)); + case SNRELZ : + SNRelZ(sprel, snc->Val); break; - case SNKEEP : SNKeep(sprel, snc->Val); break; - case SNGIVE : SNGive(sprel, snc->Val); break; - case SNGAME : SNGame(sprel, snc->Val); break; - case SNSETX0 : SNSetX0(snc->Ref, snc->Val); break; - case SNSETY0 : SNSetY0(snc->Ref, snc->Val); break; - case SNSETXY : SNSetXY(sprel, snc->Val); break; - case SNRELX : SNRelX(sprel, snc->Val); break; - case SNRELY : SNRelY(sprel, snc->Val); break; - case SNRELZ : SNRelZ(sprel, snc->Val); break; - case SNSETX : SNSetX(sprel, snc->Val); break; - case SNSETY : SNSetY(sprel, snc->Val); break; - case SNSETZ : SNSetZ(sprel, snc->Val); break; - case SNSLAVE : SNSlave(sprel, snc->Val); break; - case SNTRANS : SNTrans(sprel, snc->Val); break; - case SNPORT : SNPort(sprel, snc->Val); break; - case SNNEXT : break; - case SNIF : break; - case SNTALK : break; - case SNMOUSE : SNMouse(snc->Val != 0); break; - case SNNNEXT : SNNNext(sprel, snc->Val); break; - case SNTNEXT : SNTNext(sprel, snc->Val); break; - case SNRNNEXT : SNRNNext(sprel, snc->Val); break; - case SNRTNEXT : SNRTNext(sprel, snc->Val); break; - case SNRMNEAR : SNRmNear(sprel); break; - case SNRMTAKE : SNRmTake(sprel); break; - case SNFLAG : SNFlag(snc->Ref & 3, snc->Val != 0); break; - case SNSETREF : SNSetRef(sprel, snc->Val); break; - case SNBACKPT : SNBackPt(sprel, snc->Val); break; - case SNFLASH : SNFlash(snc->Val != 0); break; - case SNLIGHT : SNLight(snc->Val != 0); break; - case SNSETHB : SNBarrier(snc->Ref, snc->Val, true); break; - case SNSETVB : SNBarrier(snc->Ref, snc->Val, false); break; - case SNWALK : SNWalk(sprel, snc->Ref, snc->Val); break; - case SNREACH : SNReach(sprel, snc->Val); break; - case SNSOUND : SNSound(sprel, snc->Val, count); count = 1; break; - case SNCOUNT : count = snc->Val; break; - - // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST - //case SNEXEC : ((void(*)(int)) (snc->Ptr))(snc->Val); break; - case SNEXEC : warning("STUB: SNEXEC code"); - case SNSTEP : sprel->Step(); break; - case SNZTRIM : SNZTrim(sprel); break; - case SNGHOST : SNGhost((BITMAP *) snc->Ptr); break; - } - ++ Tail; - if (! Turbo) break; + case SNSETX : + SNSetX(sprel, snc->Val); + break; + case SNSETY : + SNSetY(sprel, snc->Val); + break; + case SNSETZ : + SNSetZ(sprel, snc->Val); + break; + case SNSLAVE : + SNSlave(sprel, snc->Val); + break; + case SNTRANS : + SNTrans(sprel, snc->Val); + break; + case SNPORT : + SNPort(sprel, snc->Val); + break; + case SNNEXT : + break; + case SNIF : + break; + case SNTALK : + break; + case SNMOUSE : + SNMouse(snc->Val != 0); + break; + case SNNNEXT : + SNNNext(sprel, snc->Val); + break; + case SNTNEXT : + SNTNext(sprel, snc->Val); + break; + case SNRNNEXT : + SNRNNext(sprel, snc->Val); + break; + case SNRTNEXT : + SNRTNext(sprel, snc->Val); + break; + case SNRMNEAR : + SNRmNear(sprel); + break; + case SNRMTAKE : + SNRmTake(sprel); + break; + case SNFLAG : + SNFlag(snc->Ref & 3, snc->Val != 0); + break; + case SNSETREF : + SNSetRef(sprel, snc->Val); + break; + case SNBACKPT : + SNBackPt(sprel, snc->Val); + break; + case SNFLASH : + SNFlash(snc->Val != 0); + break; + case SNLIGHT : + SNLight(snc->Val != 0); + break; + case SNSETHB : + SNBarrier(snc->Ref, snc->Val, true); + break; + case SNSETVB : + SNBarrier(snc->Ref, snc->Val, false); + break; + case SNWALK : + SNWalk(sprel, snc->Ref, snc->Val); + break; + case SNREACH : + SNReach(sprel, snc->Val); + break; + case SNSOUND : + SNSound(sprel, snc->Val, count); + count = 1; + break; + case SNCOUNT : + count = snc->Val; + break; + case SNEXEC : + // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST + // ((void(*)(int)) (snc->Ptr))(snc->Val); break; + warning("STUB: SNEXEC code"); + case SNSTEP : + sprel->Step(); + break; + case SNZTRIM : + SNZTrim(sprel); + break; + case SNGHOST : + SNGhost((BITMAP *) snc->Ptr); + break; + } + ++Tail; + if (!Turbo) + break; + } +xit: + Busy = false; } - xit: - Busy = false; - } } - - - -bool SNAIL::Idle (void) -{ - return (Head == Tail); +bool SNAIL::Idle(void) { + return (Head == Tail); } } // End of namespace CGE diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 88bb5f09dd..f9b969a554 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -25,96 +25,98 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __SNAIL__ -#define __SNAIL__ +#ifndef __SNAIL__ +#define __SNAIL__ -#include "cge/jbw.h" +#include "cge/jbw.h" namespace CGE { -#define POCKET_X 174 -#define POCKET_Y 176 -#define POCKET_DX 18 -#define POCKET_DY 22 -#define POCKET_NX 8 -#define POCKET_NY 1 +#define POCKET_X 174 +#define POCKET_Y 176 +#define POCKET_DX 18 +#define POCKET_DY 22 +#define POCKET_NX 8 +#define POCKET_NY 1 -#define POCKET_SX 8 -#define POCKET_SY 3 +#define POCKET_SX 8 +#define POCKET_SY 3 -#define SNINSERT(c,r,v,p) Snail.InsCom(c,r,v,p) -#define SNPOST(c,r,v,p) Snail.AddCom(c,r,v,p) -#define SNPOST_(c,r,v,p) Snail_.AddCom(c,r,v,p) +#define SNINSERT(c,r,v,p) Snail.InsCom(c,r,v,p) +#define SNPOST(c,r,v,p) Snail.AddCom(c,r,v,p) +#define SNPOST_(c,r,v,p) Snail_.AddCom(c,r,v,p) +typedef struct { + uint8 Horz, Vert; +} BAR; -typedef struct { uint8 Horz, Vert; } BAR; +struct SCB { + uint8 *Ptr; + uint16 Siz; + SCB *Nxt; +}; -struct SCB -{ - uint8 * Ptr; - uint16 Siz; - SCB * Nxt; +enum SNCOM { + SNLABEL, SNPAUSE, SNWAIT, SNLEVEL, SNHIDE, + SNSAY, SNINF, SNTIME, SNCAVE, SNKILL, + SNRSEQ, SNSEQ, SNSEND, SNSWAP, SNKEEP, + SNGIVE, SNIF, SNGAME, SNSETX0, SNSETY0, + SNSLAVE, SNSETXY, SNRELX, SNRELY, SNRELZ, + SNSETX, SNSETY, SNSETZ, SNTRANS, SNPORT, + SNNEXT, SNNNEXT, SNTNEXT, SNRNNEXT, SNRTNEXT, + SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, SNBACKPT, + SNFLASH, SNLIGHT, SNSETHB, SNSETVB, SNWALK, + SNREACH, SNCOVER, SNUNCOVER, SNCLEAR, SNTALK, + SNMOUSE, SNSOUND, SNCOUNT, SNEXEC, SNSTEP, + SNZTRIM, SNGHOST }; +enum SNLIST { NEAR, TAKE }; - -enum SNCOM { SNLABEL, SNPAUSE, SNWAIT, SNLEVEL, - SNHIDE, SNSAY, SNINF, SNTIME, - SNCAVE, SNKILL, SNRSEQ, - SNSEQ, SNSEND, SNSWAP, SNKEEP, SNGIVE, - SNIF, SNGAME, SNSETX0, SNSETY0, SNSLAVE, - SNSETXY, SNRELX, SNRELY, SNRELZ, - SNSETX, SNSETY, SNSETZ, SNTRANS, SNPORT, - SNNEXT, SNNNEXT, SNTNEXT, SNRNNEXT, SNRTNEXT, - SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, - SNBACKPT, SNFLASH, SNLIGHT, - SNSETHB, SNSETVB, - SNWALK, SNREACH, SNCOVER, SNUNCOVER, - SNCLEAR, SNTALK, SNMOUSE, - SNSOUND, SNCOUNT, - SNEXEC, SNSTEP, SNZTRIM, - SNGHOST - }; - -enum SNLIST { NEAR, TAKE }; - -class SNAIL -{ +class SNAIL { public: - struct COM { SNCOM Com; int Ref; int Val; void * Ptr; } * SNList; - uint8 Head, Tail; - bool Turbo, Busy, TextDelay; - uint16 Pause; - static const char * ComTxt[]; - bool TalkEnable; - SNAIL (bool turbo = false); - ~SNAIL (void); - void RunCom (void); - void AddCom (SNCOM com, int ref = 0, int val = 0, void * ptr = NULL); - void InsCom (SNCOM com, int ref = 0, int val = 0, void * ptr = NULL); - bool Idle (void); + struct COM { + SNCOM Com; + int Ref; + int Val; + void *Ptr; + } *SNList; + uint8 Head, Tail; + bool Turbo, Busy, TextDelay; + uint16 Pause; + static const char *ComTxt[]; + bool TalkEnable; + SNAIL(bool turbo = false); + ~SNAIL(void); + void RunCom(void); + void AddCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL); + void InsCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL); + bool Idle(void); }; -void SelectPocket (int n); -void PocFul (void); - - -extern SCB Scb; -extern bool Flag[4]; -extern bool Game; -extern bool Dark; -extern SNAIL Snail; -extern SNAIL Snail_; -extern int Now; -extern int Lev; -extern int MaxCave; -extern int PocPtr; -extern BAR Barriers[]; -extern struct HXY { int X; int Y; } HeroXY[]; +void SelectPocket(int n); +void PocFul(void); + + +extern SCB Scb; +extern bool Flag[4]; +extern bool Game; +extern bool Dark; +extern SNAIL Snail; +extern SNAIL Snail_; +extern int Now; +extern int Lev; +extern int MaxCave; +extern int PocPtr; +extern BAR Barriers[]; +extern struct HXY { + int X; + int Y; +} HeroXY[]; } // End of namespace CGE diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index fc6c1aa143..3d1658e1e0 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -44,50 +44,45 @@ namespace CGE { // ****************************************************** // available devices -enum DEV_TYPE { DEV_AUTO = -1, // auto-detect mode - DEV_QUIET, // disable sound - DEV_SB, // sb/pro/16/awe32 - DEV_GUS, // gus/max - DEV_GM // general midi +enum DEV_TYPE { DEV_AUTO = -1, // auto-detect mode + DEV_QUIET, // disable sound + DEV_SB, // sb/pro/16/awe32 + DEV_GUS, // gus/max + DEV_GM // general midi }; -#define SERR_OK 0 // no error -#define SERR_INITFAIL 1 // couldn't initialize -#define SERR_BADDDEV 128 // bad device +#define SERR_OK 0 // no error +#define SERR_INITFAIL 1 // couldn't initialize +#define SERR_BADDDEV 128 // bad device // driver info -struct DRVINFO -{ - DEV_TYPE DDEV; // digi device - DEV_TYPE MDEV; // midi device - uint16 DBASE; // digi base port - uint16 DDMA; // digi dma no - uint16 DIRQ; // digi irq no - uint16 MBASE; // midi base port - union - { - struct - { - uint16 DR : 4; - uint16 DL : 4; - uint16 MR : 4; - uint16 ML : 4; - } VOL4; - struct - { - uint8 D; // digi volume - uint8 M; // midi volume - } VOL2; - }; +struct DRVINFO { + DEV_TYPE DDEV; // digi device + DEV_TYPE MDEV; // midi device + uint16 DBASE; // digi base port + uint16 DDMA; // digi dma no + uint16 DIRQ; // digi irq no + uint16 MBASE; // midi base port + union { + struct { + uint16 DR : 4; + uint16 DL : 4; + uint16 MR : 4; + uint16 ML : 4; + } VOL4; + struct { + uint8 D; // digi volume + uint8 M; // midi volume + } VOL2; + }; }; // sample info -struct SMPINFO -{ - uint8 * saddr; // address - uint16 slen; // length - uint16 span; // left/right pan (0-15) - int sflag; // flag +struct SMPINFO { + uint8 *saddr; // address + uint16 slen; // length + uint16 span; // left/right pan (0-15) + int sflag; // flag }; // ****************************************************** @@ -106,31 +101,30 @@ extern uint16 MIDIEndFlag; // * Driver Code * // ****************************************************** // Init Digi Device -EC void SNDInit (void); +EC void SNDInit(void); // Close Digi Device -EC void SNDDone (void); +EC void SNDDone(void); // Set Volume -EC void SNDSetVolume (void); +EC void SNDSetVolume(void); // Start Digi -EC void SNDDigiStart (SMPINFO *PSmpInfo); +EC void SNDDigiStart(SMPINFO *PSmpInfo); // Stop Digi -EC void SNDDigiStop (SMPINFO *PSmpInfo); +EC void SNDDigiStop(SMPINFO *PSmpInfo); // Start MIDI File -EC void SNDMIDIStart (uint8 *MIDFile); +EC void SNDMIDIStart(uint8 *MIDFile); // Stop MIDI File -EC void SNDMIDIStop (void); +EC void SNDMIDIStop(void); // Play MIDI File (to be called while interrupting) // WARNING: Uses ALL registers! -EC void SNDMIDIPlay (void); +EC void SNDMIDIPlay(void); } // End of namespace CGE - #endif diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index d40789beee..397684849a 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -25,292 +25,204 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/general.h" -#include "cge/startup.h" -#include "cge/sound.h" - -#include "cge/text.h" -#include "cge/cfile.h" -#include "cge/vol.h" +#include "cge/general.h" +#include "cge/startup.h" +#include "cge/sound.h" +#include "cge/text.h" +#include "cge/cfile.h" +#include "cge/vol.h" namespace CGE { - bool Music = true; - FX Fx = 16; // must precede SOUND!! - SOUND Sound; - +bool Music = true; +FX Fx = 16; // must precede SOUND!! +SOUND Sound; -SOUND::SOUND (void) -{ - if (STARTUP::SoundOk) Open(); +SOUND::SOUND(void) { + if (STARTUP::SoundOk) + Open(); } - - -SOUND::~SOUND (void) -{ - Close(); +SOUND::~SOUND(void) { + Close(); } - - - -void SOUND::Close (void) -{ - KillMIDI(); - SNDDone(); +void SOUND::Close(void) { + KillMIDI(); + SNDDone(); } - - - -void SOUND::Open (void) -{ - SNDInit(); - Play(Fx[30000], 8); +void SOUND::Open(void) { + SNDInit(); + Play(Fx[30000], 8); } - - -void SOUND::Play (DATACK * wav, int pan, int cnt) -{ - if (wav) - { - Stop(); - smpinf.saddr = (uint8 *) &*(wav->EAddr()); - smpinf.slen = (uint16)wav->Size(); - smpinf.span = pan; - smpinf.sflag = cnt; - SNDDigiStart(&smpinf); - } +void SOUND::Play(DATACK *wav, int pan, int cnt) { + if (wav) { + Stop(); + smpinf.saddr = (uint8 *) &*(wav->EAddr()); + smpinf.slen = (uint16)wav->Size(); + smpinf.span = pan; + smpinf.sflag = cnt; + SNDDigiStart(&smpinf); + } } - - -void SOUND::Stop (void) -{ - SNDDigiStop(&smpinf); +void SOUND::Stop(void) { + SNDDigiStop(&smpinf); } -//------------------------------------------------------------------------ - - - - - - - - -FX::FX (int size) -: Emm(0L), Current(NULL) -{ - Cache = new HAN[size]; - for (Size = 0; Size < size; Size ++) - { - Cache[Size].Ref = 0; - Cache[Size].Wav = NULL; - } +FX::FX(int size) : Emm(0L), Current(NULL) { + Cache = new HAN[size]; + for (Size = 0; Size < size; Size ++) { + Cache[Size].Ref = 0; + Cache[Size].Wav = NULL; + } } - - -FX::~FX (void) -{ - Clear(); - delete[] Cache; +FX::~FX(void) { + Clear(); + delete[] Cache; } - - - -void FX::Clear (void) -{ - HAN * p, * q; - for (p = Cache, q = p+Size; p < q; p ++) - { - if (p->Ref) - { - p->Ref = 0; - delete p->Wav; - p->Wav = NULL; +void FX::Clear(void) { + HAN *p, * q; + for (p = Cache, q = p + Size; p < q; p ++) { + if (p->Ref) { + p->Ref = 0; + delete p->Wav; + p->Wav = NULL; + } } - } - Emm.Release(); - Current = NULL; + Emm.Release(); + Current = NULL; } - - - -int FX::Find (int ref) -{ - HAN * p, * q; - int i = 0; - for (p = Cache, q = p+Size; p < q; p ++) - { - if (p->Ref == ref) break; - else ++ i; - } - return i; +int FX::Find(int ref) { + HAN *p, * q; + int i = 0; + for (p = Cache, q = p + Size; p < q; p ++) { + if (p->Ref == ref) + break; + else + ++i; + } + return i; } +void FX::Preload(int ref0) { + HAN *CacheLim = Cache + Size; + int ref; - - - - - - - - -void FX::Preload (int ref0) -{ - HAN * CacheLim = Cache + Size; - int ref; - - for (ref = ref0; ref < ref0+10; ref ++) - { - static char fname[] = "FX00000.WAV"; - wtom(ref, fname+2, 10, 5); - INI_FILE file = INI_FILE(fname); - DATACK * wav = LoadWave(&file, &Emm); - if (wav) - { - HAN * p = &Cache[Find(0)]; - if (p >= CacheLim) break; - p->Wav = wav; - p->Ref = ref; + for (ref = ref0; ref < ref0 + 10; ref ++) { + static char fname[] = "FX00000.WAV"; + wtom(ref, fname + 2, 10, 5); + INI_FILE file = INI_FILE(fname); + DATACK *wav = LoadWave(&file, &Emm); + if (wav) { + HAN *p = &Cache[Find(0)]; + if (p >= CacheLim) + break; + p->Wav = wav; + p->Ref = ref; + } } - } } +DATACK *FX::Load(int idx, int ref) { + static char fname[] = "FX00000.WAV"; + wtom(ref, fname + 2, 10, 5); - - -DATACK * FX::Load (int idx, int ref) -{ - static char fname[] = "FX00000.WAV"; - wtom(ref, fname+2, 10, 5); - - INI_FILE file = INI_FILE(fname); - DATACK * wav = LoadWave(&file, &Emm); - if (wav) - { - HAN * p = &Cache[idx]; - p->Wav = wav; - p->Ref = ref; - } - return wav; + INI_FILE file = INI_FILE(fname); + DATACK *wav = LoadWave(&file, &Emm); + if (wav) { + HAN *p = &Cache[idx]; + p->Wav = wav; + p->Ref = ref; + } + return wav; } - - -DATACK * FX::operator [] (int ref) -{ - int i; - if ((i = Find(ref)) < Size) Current = Cache[i].Wav; - else - { - if ((i = Find(0)) >= Size) - { - Clear(); - i = 0; +DATACK *FX::operator [](int ref) { + int i; + if ((i = Find(ref)) < Size) + Current = Cache[i].Wav; + else { + if ((i = Find(0)) >= Size) { + Clear(); + i = 0; + } + Current = Load(i, ref); } - Current = Load(i, ref); - } - return Current; + return Current; } +static uint8 *midi = NULL; -//------------------------------------------------------------------------- - - -static uint8 * midi = NULL; - - - -void KillMIDI (void) -{ - SNDMIDIStop(); - if (midi) - { - delete[] midi; - midi = NULL; - } +void KillMIDI(void) { + SNDMIDIStop(); + if (midi) { + delete[] midi; + midi = NULL; + } } - - - -void LoadMIDI (int ref) -{ - static char fn[] = "00.MID"; - wtom(ref, fn, 10, 2); - if (INI_FILE::Exist(fn)) - { - KillMIDI(); - INI_FILE mid = fn; - if (mid.Error == 0) - { - uint16 siz = (uint16) mid.Size(); - midi = new uint8[siz]; - if (midi) - { - mid.Read(midi, siz); - if (mid.Error) KillMIDI(); - else - { - SNDMIDIStart(midi); +void LoadMIDI(int ref) { + static char fn[] = "00.MID"; + wtom(ref, fn, 10, 2); + if (INI_FILE::Exist(fn)) { + KillMIDI(); + INI_FILE mid = fn; + if (mid.Error == 0) { + uint16 siz = (uint16) mid.Size(); + midi = new uint8[siz]; + if (midi) { + mid.Read(midi, siz); + if (mid.Error) + KillMIDI(); + else + SNDMIDIStart(midi); + } } - } } - } } +EC void *Patch(int pat) { + void *p = NULL; + static char fn[] = "PATCH000.SND"; - - - -EC void * Patch (int pat) -{ - void * p = NULL; - static char fn[] = "PATCH000.SND"; - - wtom(pat, fn+5, 10, 3); - INI_FILE snd = fn; - if (! snd.Error) - { - uint16 siz = (uint16) snd.Size(); - p = (uint8 *) malloc(siz); - if (p) - { - snd.Read(p, siz); - if (snd.Error) - { - free(p); - p = NULL; - } + wtom(pat, fn + 5, 10, 3); + INI_FILE snd = fn; + if (! snd.Error) { + uint16 siz = (uint16) snd.Size(); + p = (uint8 *) malloc(siz); + if (p) { + snd.Read(p, siz); + if (snd.Error) { + free(p); + p = NULL; + } + } } - } - return p; + return p; } } // End of namespace CGE diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 79c9bf563d..b617891268 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -25,64 +25,56 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __SOUND__ -#define __SOUND__ +#ifndef __SOUND__ +#define __SOUND__ -#include "cge/wav.h" -#include "cge/snddrv.h" +#include "cge/wav.h" +#include "cge/snddrv.h" namespace CGE { -#define BAD_SND_TEXT 97 -#define BAD_MIDI_TEXT 98 +#define BAD_SND_TEXT 97 +#define BAD_MIDI_TEXT 98 - - -class SOUND -{ +class SOUND { public: - SMPINFO smpinf; - SOUND (void); - ~SOUND (void); - void Open (void); - void Close (void); - void Play (DATACK * wav, int pan, int cnt = 1); - void Stop (void); + SMPINFO smpinf; + SOUND(void); + ~SOUND(void); + void Open(void); + void Close(void); + void Play(DATACK *wav, int pan, int cnt = 1); + void Stop(void); }; - - - -class FX -{ - EMM Emm; - struct HAN { int Ref; DATACK * Wav; } * Cache; - int Size; - DATACK * Load (int idx, int ref); - int Find (int ref); +class FX { + EMM Emm; + struct HAN { + int Ref; + DATACK *Wav; + } *Cache; + int Size; + DATACK *Load(int idx, int ref); + int Find(int ref); public: - DATACK * Current; - FX (int size = 16); - ~FX (void); - void Clear (void); - void Preload (int ref0); - DATACK * operator[] (int ref); + DATACK *Current; + FX(int size = 16); + ~FX(void); + void Clear(void); + void Preload(int ref0); + DATACK *operator[](int ref); }; +extern bool Music; +extern SOUND Sound; +extern FX Fx; - - -extern bool Music; -extern SOUND Sound; -extern FX Fx; - - -void LoadMIDI (int ref); -void KillMIDI (void); +void LoadMIDI(int ref); +void KillMIDI(void); } // End of namespace CGE diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index c2badee266..2bed51af97 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -25,173 +25,165 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/startup.h" -#include "cge/text.h" -#include "cge/sound.h" -#include "cge/ident.h" -#include "cge/cfile.h" -#include "cge/snddrv.h" -#include -#include -#include -//#include -#include - -#ifdef DEBUG - #include +#include "cge/startup.h" +#include "cge/text.h" +#include "cge/sound.h" +#include "cge/ident.h" +#include "cge/cfile.h" +#include "cge/snddrv.h" +#include +#include +#include +#include + +#ifdef DEBUG +#include #endif namespace CGE { -extern char Copr[]; +extern char Copr[]; -#define id (*(IDENT*)Copr) +#define id (*(IDENT*)Copr) - EMM MiniEmm = MINI_EMM_SIZE; +EMM MiniEmm = MINI_EMM_SIZE; -static STARTUP StartUp; +static STARTUP StartUp; - int STARTUP::Mode = 0; - int STARTUP::Core; - int STARTUP::SoundOk = 0; - uint16 STARTUP::Summa; +int STARTUP::Mode = 0; +int STARTUP::Core; +int STARTUP::SoundOk = 0; +uint16 STARTUP::Summa; - -void quit_now(int ref){ - error("%d\n", Text[ref]); -} - - - -bool STARTUP::get_parms(void) -{ -/* - int i = _argc; - while (i > 1) - { - static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", - "P", "D", "I", "M" }; - int n = TakeEnum(PrmTab, strtok(_argv[--i], " =:(")); - uint16 p = xtow(strtok(NULL, " h,)")); - switch (n) - { - case 0 : if (Mode != 2) Mode = 1; break; - case 1 : Mode = 2; break; - case 2 : SNDDrvInfo.DDEV = DEV_QUIET; break; - case 3 : SNDDrvInfo.DDEV = DEV_SB; break; - case 4 : SNDDrvInfo.DDEV = DEV_GUS; break; - case 5 : SNDDrvInfo.MDEV = DEV_GM; break; - case 6 : SNDDrvInfo.DBASE = p; break; - case 7 : SNDDrvInfo.DDMA = p; break; - case 8 : SNDDrvInfo.DIRQ = p; break; - case 9 : SNDDrvInfo.MBASE = p; - SNDDrvInfo.MDEV = DEV_GM; break; - default: return false; - } - if (n >= 2) SoundOk = 2; - } - #ifdef DEMO - // protection disabled - Summa = 0; - #else - #ifdef EVA - { - union { dosdate_t d; uint32 n; } today; - _dos_getdate(&today.d); - id.disk += (id.disk < today.n); - } - #endif - #ifdef CD - Summa = 0; - #else - // disk signature checksum - Summa = ChkSum(Copr, sizeof(IDENT)); - #endif - #endif - if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; - */ - warning("STUB: STARTUP::get_parms"); - return true; +void quit_now(int ref) { + error("%d\n", Text[ref]); } - - -STARTUP::STARTUP(void) -{ -/* - uint32 m = farcoreleft() >> 10; - if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF; - - if (! IsVga()) quit_now(NOT_VGA_TEXT); - if (Cpu() < _80286) quit_now(BAD_CHIP_TEXT); - if (100 * _osmajor + _osminor < 330) quit_now(BAD_DOS_TEXT); - - #ifndef DEBUG - if (Core < CORE_LOW) quit_now(NO_CORE_TEXT); - if (Core < CORE_HIG) - { - SNDDrvInfo.MDEV = DEV_QUIET; - Music = false; - } - #endif - if (! get_parms()) quit_now(BAD_ARG_TEXT); - //--- load sound configuration - const char * fn = UsrPath(ProgName(CFG_EXT)); - if (! STARTUP::SoundOk && CFILE::Exist(fn)) - { - CFILE cfg(fn, REA); - if (! cfg.Error) - { - cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); - if (! cfg.Error) STARTUP::SoundOk = 1; - } - } - */ - warning("STUB: STARTUP::STARTUP"); +bool STARTUP::get_parms(void) { + /* + int i = _argc; + while (i > 1) + { + static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", + "P", "D", "I", "M" }; + int n = TakeEnum(PrmTab, strtok(_argv[--i], " =:(")); + uint16 p = xtow(strtok(NULL, " h,)")); + switch (n) + { + case 0 : if (Mode != 2) Mode = 1; break; + case 1 : Mode = 2; break; + case 2 : SNDDrvInfo.DDEV = DEV_QUIET; break; + case 3 : SNDDrvInfo.DDEV = DEV_SB; break; + case 4 : SNDDrvInfo.DDEV = DEV_GUS; break; + case 5 : SNDDrvInfo.MDEV = DEV_GM; break; + case 6 : SNDDrvInfo.DBASE = p; break; + case 7 : SNDDrvInfo.DDMA = p; break; + case 8 : SNDDrvInfo.DIRQ = p; break; + case 9 : SNDDrvInfo.MBASE = p; + SNDDrvInfo.MDEV = DEV_GM; break; + default: return false; + } + if (n >= 2) SoundOk = 2; + } + #ifdef DEMO + // protection disabled + Summa = 0; + #else + #ifdef EVA + { + union { dosdate_t d; uint32 n; } today; + _dos_getdate(&today.d); + id.disk += (id.disk < today.n); + } + #endif + #ifdef CD + Summa = 0; + #else + // disk signature checksum + Summa = ChkSum(Copr, sizeof(IDENT)); + #endif + #endif + if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; + return true; + */ + warning("STUB: STARTUP::get_parms"); + return true; } +STARTUP::STARTUP(void) { + /* + uint32 m = farcoreleft() >> 10; + if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF; + if (! IsVga()) quit_now(NOT_VGA_TEXT); + if (Cpu() < _80286) quit_now(BAD_CHIP_TEXT); + if (100 * _osmajor + _osminor < 330) quit_now(BAD_DOS_TEXT); - - -const char *UsrPath (const char *nam) -{ - static char buf[MAXPATH] = ".\\", *p = buf+2; - #if defined(CD) - if (DriveCD(0)) - { - bool ok = false; - CFILE ini = Text[CDINI_FNAME]; - if (!ini.Error) - { - char *key = Text[GAME_ID]; - int i = strlen(key); - while (ini.Read(buf) && !ok) + #ifndef DEBUG + if (Core < CORE_LOW) quit_now(NO_CORE_TEXT); + if (Core < CORE_HIG) { - int j = strlen(buf); - if (j) if (buf[--j] == '\n') buf[j] = '\0'; - if (memicmp(buf, key, i) == 0) ok = true; + SNDDrvInfo.MDEV = DEV_QUIET; + Music = false; } - if (ok) + #endif + if (! get_parms()) quit_now(BAD_ARG_TEXT); + //--- load sound configuration + const char * fn = UsrPath(ProgName(CFG_EXT)); + if (! STARTUP::SoundOk && CFILE::Exist(fn)) + { + CFILE cfg(fn, REA); + if (! cfg.Error) { - strcpy(buf, buf+i); - p = buf + strlen(buf); - if (*(p-1) != '\\') *(p++) = '\\'; - strcpy(p, "NUL"); - if (_dos_open(buf, 0, &i) == 0) _dos_close(i); - else ok = false; + cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); + if (! cfg.Error) STARTUP::SoundOk = 1; } + } + */ + warning("STUB: STARTUP::STARTUP"); +} + + +const char *UsrPath(const char *nam) { + static char buf[MAXPATH] = ".\\", *p = buf + 2; +#if defined(CD) + if (DriveCD(0)) { + bool ok = false; + CFILE ini = Text[CDINI_FNAME]; + if (!ini.Error) { + char *key = Text[GAME_ID]; + int i = strlen(key); + while (ini.Read(buf) && !ok) { + int j = strlen(buf); + if (j) + if (buf[--j] == '\n') + buf[j] = '\0'; + if (memicmp(buf, key, i) == 0) + ok = true; + } + if (ok) { + strcpy(buf, buf + i); + p = buf + strlen(buf); + if (*(p - 1) != '\\') + *(p++) = '\\'; + strcpy(p, "NUL"); + if (_dos_open(buf, 0, &i) == 0) + _dos_close(i); + else + ok = false; + } + } + if (!ok) + quit_now(BADCD_TEXT); } - if (!ok) quit_now(BADCD_TEXT); - } - #endif - strcpy(p, nam); - return buf; +#endif + strcpy(p, nam); + return buf; } } // End of namespace CGE diff --git a/engines/cge/startup.h b/engines/cge/startup.h index 2f1b5faa0b..5bfa9876d6 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -25,57 +25,54 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __STARTUP__ -#define __STARTUP__ +#ifndef __STARTUP__ +#define __STARTUP__ -#include "cge/general.h" +#include "cge/general.h" namespace CGE { -#define GAME_ID 45 -#define CDINI_FNAME 46 +#define GAME_ID 45 +#define CDINI_FNAME 46 -#define NOT_VGA_TEXT 90 -#define BAD_CHIP_TEXT 91 -#define BAD_DOS_TEXT 92 -#define NO_CORE_TEXT 93 -#define BAD_MIPS_TEXT 94 -#define NO_MOUSE_TEXT 95 -#define BAD_ARG_TEXT 96 -#define BADCD_TEXT 97 +#define NOT_VGA_TEXT 90 +#define BAD_CHIP_TEXT 91 +#define BAD_DOS_TEXT 92 +#define NO_CORE_TEXT 93 +#define BAD_MIPS_TEXT 94 +#define NO_MOUSE_TEXT 95 +#define BAD_ARG_TEXT 96 +#define BADCD_TEXT 97 -#define CFG_EXT ".CFG" +#define CFG_EXT ".CFG" #if defined(DEMO) - #define MINI_EMM_SIZE 0x00004000L - #define CORE_HIG 400 +#define MINI_EMM_SIZE 0x00004000L +#define CORE_HIG 400 #else - #define MINI_EMM_SIZE 0x00010000L - #define CORE_HIG 450 +#define MINI_EMM_SIZE 0x00010000L +#define CORE_HIG 450 #endif -#define CORE_MID (CORE_HIG-20) -#define CORE_LOW (CORE_MID-20) +#define CORE_MID (CORE_HIG - 20) +#define CORE_LOW (CORE_MID - 20) -class STARTUP -{ - static bool get_parms (void); +class STARTUP { + static bool get_parms(void); public: - static int Mode; - static int Core; - static int SoundOk; - static uint16 Summa; - STARTUP (void); + static int Mode; + static int Core; + static int SoundOk; + static uint16 Summa; + STARTUP(void); }; +extern EMM MiniEmm; - -extern EMM MiniEmm; - -const char *UsrPath (const char *nam); +const char *UsrPath(const char *nam); } // End of namespace CGE diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 9fd32ab7d2..1dbcbad98d 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -25,384 +25,304 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/general.h" -#include "cge/talk.h" -#include "cge/vol.h" -#include "cge/game.h" -#include "cge/mouse.h" -#include -//#include -//#include +#include "cge/general.h" +#include "cge/talk.h" +#include "cge/vol.h" +#include "cge/game.h" +#include "cge/mouse.h" +#include namespace CGE { -#define WID_SIZ 256 -#define POS_SIZ 256 -#define MAP_SIZ (256*8) +#define WID_SIZ 256 +#define POS_SIZ 256 +#define MAP_SIZ (256*8) +//uint8 FONT::Wid[WID_SIZ]; +//uint16 FONT::Pos[POS_SIZ]; +//uint8 FONT::Map[MAP_SIZ]; -//-------------------------------------------------------------------------- - - -//uint8 FONT::Wid[WID_SIZ]; -//uint16 FONT::Pos[POS_SIZ]; -//uint8 FONT::Map[MAP_SIZ]; - - - - - - - -FONT::FONT (const char * name) -{ - Map = farnew(uint8, MAP_SIZ); - Pos = farnew(uint16, POS_SIZ); - Wid = farnew(uint8, WID_SIZ); - if (Map == NULL || Pos == NULL || Wid == NULL) - error("No core"); - MergeExt(Path, name, FONT_EXT); - Load(); +FONT::FONT(const char *name) { + Map = farnew(uint8, MAP_SIZ); + Pos = farnew(uint16, POS_SIZ); + Wid = farnew(uint8, WID_SIZ); + if ((Map == NULL) || (Pos == NULL) || (Wid == NULL)) + error("No core"); + MergeExt(Path, name, FONT_EXT); + Load(); } - - -FONT::~FONT (void) -{ - free(Map); - free(Pos); - free(Wid); +FONT::~FONT(void) { + free(Map); + free(Pos); + free(Wid); } - - -void FONT::Load (void) -{ - INI_FILE f(Path); - if (! f.Error) - { - f.Read(Wid, WID_SIZ); - if (! f.Error) - { - uint16 i, p = 0; - for (i = 0; i < POS_SIZ; i ++) - { - Pos[i] = p; - p += Wid[i]; - } - f.Read(Map, p); +void FONT::Load(void) { + INI_FILE f(Path); + if (! f.Error) { + f.Read(Wid, WID_SIZ); + if (! f.Error) { + uint16 i, p = 0; + for (i = 0; i < POS_SIZ; i ++) { + Pos[i] = p; + p += Wid[i]; + } + f.Read(Map, p); + } } - } } - - - -uint16 FONT::Width (const char * text) -{ - uint16 w = 0; - if (text) while (* text) w += Wid[*(text ++)]; - return w; +uint16 FONT::Width(const char *text) { + uint16 w = 0; + if (text) + while (* text) + w += Wid[*(text ++)]; + return w; } - /* -void FONT::Save (void) -{ - CFILE f((const char *) Path, WRI); - if (! f.Error) - { - f.Write(Wid, WID_SIZ); - if (! f.Error) - { - f.Write(Map, Pos[POS_SIZ-1] + Wid[WID_SIZ-1]); +void FONT::Save(void) { + CFILE f((const char *) Path, WRI); + if (! f.Error) { + f.Write(Wid, WID_SIZ); + if (! f.Error) + f.Write(Map, Pos[POS_SIZ-1] + Wid[WID_SIZ-1]); } - } } */ +FONT TALK::Font(ProgName()); -//-------------------------------------------------------------------------- - - - -FONT TALK::Font(ProgName()); - - - -TALK::TALK (const char * tx, TBOX_STYLE mode) -: SPRITE(NULL), Mode(mode) -{ - TS[0] = TS[1] = NULL; - Flags.Syst = true; - Update(tx); +TALK::TALK(const char *tx, TBOX_STYLE mode) + : SPRITE(NULL), Mode(mode) { + TS[0] = TS[1] = NULL; + Flags.Syst = true; + Update(tx); } - - - -TALK::TALK (void) -: SPRITE(NULL), Mode(PURE) -{ - TS[0] = TS[1] = NULL; - Flags.Syst = true; +TALK::TALK(void) + : SPRITE(NULL), Mode(PURE) { + TS[0] = TS[1] = NULL; + Flags.Syst = true; } - - - /* -TALK::~TALK (void) -{ - uint16 i; - for (i = 0; i < ShpCnt; i ++) - { - if (FP_SEG(ShpList[i]) != _DS) // small model: always false - { - delete ShpList[i]; - ShpList[i] = NULL; +TALK::~TALK (void) { + for (uint16 i = 0; i < ShpCnt; i ++) { + if (FP_SEG(ShpList[i]) != _DS) { // small model: always false + delete ShpList[i]; + ShpList[i] = NULL; + } } - } } */ - -void TALK::Update (const char * tx) -{ - uint16 vmarg = (Mode) ? TEXT_VM : 0; - uint16 hmarg = (Mode) ? TEXT_HM : 0; - uint16 mw = 0, mh, ln = vmarg; - const char * p; - uint8 * m; - - if (! TS[0]) - { - uint16 k = 2 * hmarg; - mh = 2 * vmarg + FONT_HIG; - for (p = tx; *p; p ++) - { - if (*p == '|' || *p == '\n') - { - mh += FONT_HIG + TEXT_LS; - if (k > mw) mw = k; - k = 2 * hmarg; - } - else k += Font.Wid[*p]; +void TALK::Update(const char *tx) { + uint16 vmarg = (Mode) ? TEXT_VM : 0; + uint16 hmarg = (Mode) ? TEXT_HM : 0; + uint16 mw = 0, mh, ln = vmarg; + const char *p; + uint8 *m; + + if (!TS[0]) { + uint16 k = 2 * hmarg; + mh = 2 * vmarg + FONT_HIG; + for (p = tx; *p; p ++) { + if (*p == '|' || *p == '\n') { + mh += FONT_HIG + TEXT_LS; + if (k > mw) + mw = k; + k = 2 * hmarg; + } else + k += Font.Wid[*p]; + } + if (k > mw) + mw = k; + TS[0] = Box(mw, mh); } - if (k > mw) mw = k; - TS[0] = Box(mw, mh); - } - - m = TS[0]->M + ln * mw + hmarg; - - while (* tx) - { - if (*tx == '|' || *tx == '\n') - m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; - else - { - int cw = Font.Wid[*tx], i; - uint8 * f = Font.Map + Font.Pos[*tx]; - for (i = 0; i < cw; i ++) - { - uint8 * p = m; - uint16 n; - register uint16 b = * (f ++); - for (n = 0; n < FONT_HIG; n ++) - { - if (b & 1) * p = TEXT_FG; - b >>= 1; - p += mw; + + m = TS[0]->M + ln * mw + hmarg; + + while (* tx) { + if (*tx == '|' || *tx == '\n') + m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; + else { + int cw = Font.Wid[*tx], i; + uint8 *f = Font.Map + Font.Pos[*tx]; + for (i = 0; i < cw; i++) { + uint8 *p = m; + uint16 n; + register uint16 b = *(f++); + for (n = 0; n < FONT_HIG; n++) { + if (b & 1) + *p = TEXT_FG; + b >>= 1; + p += mw; + } + ++m; + } } - ++ m; - } + ++tx; } - ++ tx; - } - TS[0]->Code(); - SetShapeList(TS); + TS[0]->Code(); + SetShapeList(TS); } -BITMAP * TALK::Box (uint16 w, uint16 h) -{ - uint8 * b, * p, * q; - uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0; - int i; +BITMAP *TALK::Box(uint16 w, uint16 h) { + uint8 *b, * p, * q; + uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0; - if (w < 8) w = 8; - if (h < 8) h = 8; - b = farnew(uint8, n = w * h); - if (! b) - error("No core"); - memset(b, TEXT_BG, n); + if (w < 8) + w = 8; + if (h < 8) + h = 8; + b = farnew(uint8, n = w * h); + if (! b) + error("No core"); + memset(b, TEXT_BG, n); - if (Mode) - { - p = b; q = b + n - w; - memset(p, LGRAY, w); - memset(q, DGRAY, w); - while (p < q) - { - p += w; - * (p-1) = DGRAY; - * p = LGRAY; - } - p = b; - for (i = 0; i < r; i ++) - { - int j; - for (j = 0; j < r-i; j ++) - { - p[ j ] = TRANS; - p[w-j-1] = TRANS; - q[ j ] = TRANS; - q[w-j-1] = TRANS; - } - p[ j ] = LGRAY; - p[w-j-1] = DGRAY; - q[ j ] = LGRAY; - q[w-j-1] = DGRAY; - p += w; - q -= w; + if (Mode) { + p = b; + q = b + n - w; + memset(p, LGRAY, w); + memset(q, DGRAY, w); + while (p < q) { + p += w; + *(p - 1) = DGRAY; + *p = LGRAY; + } + p = b; + for (int i = 0; i < r; i ++) { + int j; + for (j = 0; j < r - i; j ++) { + p[j] = TRANS; + p[w - j - 1] = TRANS; + q[j] = TRANS; + q[w - j - 1] = TRANS; + } + p[j] = LGRAY; + p[w - j - 1] = DGRAY; + q[j] = LGRAY; + q[w - j - 1] = DGRAY; + p += w; + q -= w; + } } - } - return new BITMAP(w, h, b); + return new BITMAP(w, h, b); } - - - -void TALK::PutLine (int line, const char * text) +void TALK::PutLine(int line, const char *text) { // Note: (TS[0].W % 4) have to be 0 -{ - uint16 w = TS[0]->W, h = TS[0]->H; - uint8 * v = TS[0]->V, * p; - uint16 dsiz = w >> 2; // data size (1 plane line size) - uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap - uint16 psiz = h * lsiz; // - last gap, but + plane trailer - uint16 size = 4 * psiz; // whole map size - uint16 rsiz = FONT_HIG * lsiz; // length of whole text row map - - // set desired line pointer - v += (TEXT_VM + (FONT_HIG + TEXT_LS) * line) * lsiz; - - // clear whole rectangle - p = v; // assume blanked line above text - memcpy(p, p-lsiz, rsiz); p += psiz; // tricky replicate lines for plane 0 - memcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 1 - memcpy(p, p-lsiz, rsiz); p += psiz; // same for plane 2 - memcpy(p, p-lsiz, rsiz); // same for plane 3 - - // paint text line - if (text) - { - uint8 * q; - p = v + 2 + TEXT_HM/4 + (TEXT_HM%4)*psiz; - q = v + size; - - while (* text) - { - uint16 cw = Font.Wid[*text], i; - uint8 * fp = Font.Map + Font.Pos[*text]; - - for (i = 0; i < cw; i ++) - { - register uint16 b = fp[i]; - uint16 n; - for (n = 0; n < FONT_HIG; n ++) - { - if (b & 1) *p = TEXT_FG; - b >>= 1; - p += lsiz; + uint16 w = TS[0]->W, h = TS[0]->H; + uint8 *v = TS[0]->V, * p; + uint16 dsiz = w >> 2; // data size (1 plane line size) + uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap + uint16 psiz = h * lsiz; // - last gap, but + plane trailer + uint16 size = 4 * psiz; // whole map size + uint16 rsiz = FONT_HIG * lsiz; // length of whole text row map + + // set desired line pointer + v += (TEXT_VM + (FONT_HIG + TEXT_LS) * line) * lsiz; + + // clear whole rectangle + p = v; // assume blanked line above text + memcpy(p, p - lsiz, rsiz); + p += psiz; // tricky replicate lines for plane 0 + memcpy(p, p - lsiz, rsiz); + p += psiz; // same for plane 1 + memcpy(p, p - lsiz, rsiz); + p += psiz; // same for plane 2 + memcpy(p, p - lsiz, rsiz); // same for plane 3 + + // paint text line + if (text) { + uint8 *q; + p = v + 2 + TEXT_HM / 4 + (TEXT_HM % 4) * psiz; + q = v + size; + + while (* text) { + uint16 cw = Font.Wid[*text], i; + uint8 *fp = Font.Map + Font.Pos[*text]; + + for (i = 0; i < cw; i ++) { + register uint16 b = fp[i]; + uint16 n; + for (n = 0; n < FONT_HIG; n ++) { + if (b & 1) + *p = TEXT_FG; + b >>= 1; + p += lsiz; + } + p = p - rsiz + psiz; + if (p >= q) + p = p - size + 1; + } + ++text; } - p = p - rsiz + psiz; - if (p >= q) p = p - size + 1; - } - ++ text; } - } } - - - - -//-------------------------------------------------------------------------- - - - - -INFO_LINE::INFO_LINE (uint16 w) -: OldTxt(NULL) -{ - TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG); - SetShapeList(TS); +INFO_LINE::INFO_LINE(uint16 w) : OldTxt(NULL) { + TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG); + SetShapeList(TS); } - - - - -void INFO_LINE::Update (const char * tx) -{ - if (tx != OldTxt) - { - uint16 w = TS[0]->W, h = TS[0]->H; - uint8 * v = (uint8 *) TS[0]->V; - uint16 dsiz = w >> 2; // data size (1 plane line size) - uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap - uint16 psiz = h * lsiz; // - last gape, but + plane trailer - uint16 size = 4 * psiz; // whole map size - - // claer whole rectangle - memset(v+2, TEXT_BG, dsiz); // data bytes - memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines - * (uint16 *) (v + psiz - 2) = EOI; // plane trailer uint16 - memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes - - // paint text line - if (tx) - { - uint8 * p = v + 2, * q = p + size; - - while (* tx) - { - uint16 cw = Font.Wid[*tx], i; - uint8 * fp = Font.Map + Font.Pos[*tx]; - - for (i = 0; i < cw; i ++) - { - register uint16 b = fp[i]; - uint16 n; - for (n = 0; n < FONT_HIG; n ++) - { - if (b & 1) *p = TEXT_FG; - b >>= 1; - p += lsiz; - } - if (p >= q) p = p - size + 1; +void INFO_LINE::Update(const char *tx) { + if (tx != OldTxt) { + uint16 w = TS[0]->W, h = TS[0]->H; + uint8 *v = (uint8 *) TS[0]->V; + uint16 dsiz = w >> 2; // data size (1 plane line size) + uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap + uint16 psiz = h * lsiz; // - last gape, but + plane trailer + uint16 size = 4 * psiz; // whole map size + + // claer whole rectangle + memset(v + 2, TEXT_BG, dsiz); // data bytes + memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines + * (uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 + memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes + + // paint text line + if (tx) { + uint8 *p = v + 2, * q = p + size; + + while (*tx) { + uint16 cw = Font.Wid[*tx]; + uint8 *fp = Font.Map + Font.Pos[*tx]; + + for (uint16 i = 0; i < cw; i++) { + register uint16 b = fp[i]; + for (uint16 n = 0; n < FONT_HIG; n ++) { + if (b & 1) + *p = TEXT_FG; + b >>= 1; + p += lsiz; + } + if (p >= q) + p = p - size + 1; + } + ++tx; + } } - ++ tx; - } + OldTxt = tx; } - OldTxt = tx; - } } } // End of namespace CGE diff --git a/engines/cge/talk.h b/engines/cge/talk.h index aab6834c28..568fd82964 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -25,86 +25,72 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __TALK__ -#define __TALK__ +#ifndef __TALK__ +#define __TALK__ -#include "cge/vga13h.h" -#include "cge/general.h" -#include "cge/jbw.h" -//#include +#include "cge/vga13h.h" +#include "cge/general.h" +#include "cge/jbw.h" namespace CGE { -#define TEXT_FG DARK // foreground color -#define TEXT_BG GRAY // background color -#define TEXT_HM (6&~1) // EVEN horizontal margins! -#define TEXT_VM 5 // vertical margins -#define TEXT_LS 2 // line spacing -#define TEXT_RD 3 // rounded corners +#define TEXT_FG DARK // foreground color +#define TEXT_BG GRAY // background color +#define TEXT_HM (6&~1) // EVEN horizontal margins! +#define TEXT_VM 5 // vertical margins +#define TEXT_LS 2 // line spacing +#define TEXT_RD 3 // rounded corners -#define FONT_HIG 8 -#define FONT_EXT ".CFT" +#define FONT_HIG 8 +#define FONT_EXT ".CFT" #define MAXPATH 128 -class FONT -{ - char Path[MAXPATH]; - void Load (void); +class FONT { + char Path[MAXPATH]; + void Load(void); public: // static uint8 Wid[256]; // static uint16 Pos[256]; // static uint8 Map[256*8]; - uint8 * Wid; - uint16 * Pos; - uint8 * Map; - FONT (const char * name); - ~FONT (void); - uint16 Width (const char * text); - void Save (void); + uint8 *Wid; + uint16 *Pos; + uint8 *Map; + FONT(const char *name); + ~FONT(void); + uint16 Width(const char *text); + void Save(void); }; +enum TBOX_STYLE { PURE, RECT, ROUND }; - -enum TBOX_STYLE { PURE, RECT, ROUND }; - - - -class TALK : public SPRITE -{ +class TALK : public SPRITE { protected: - TBOX_STYLE Mode; - BITMAP * TS[2]; - BITMAP * Box(uint16 w, uint16 h); + TBOX_STYLE Mode; + BITMAP *TS[2]; + BITMAP *Box(uint16 w, uint16 h); public: - static FONT Font; - TALK (const char * tx, TBOX_STYLE mode = PURE); - TALK (void); - //~TALK (void); - virtual void Update (const char * tx); - virtual void Update (void) {} - void PutLine (int line, const char * text); + static FONT Font; + TALK(const char *tx, TBOX_STYLE mode = PURE); + TALK(void); + //~TALK (void); + virtual void Update(const char *tx); + virtual void Update(void) {} + void PutLine(int line, const char *text); }; - - - - - -class INFO_LINE : public TALK -{ - const char * OldTxt; +class INFO_LINE : public TALK { + const char *OldTxt; public: - INFO_LINE (uint16 wid); - void Update (const char * tx); + INFO_LINE(uint16 wid); + void Update(const char *tx); }; - } // End of namespace CGE #endif diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 5b79131a26..71f4f156d5 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -25,292 +25,235 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/general.h" -#include "cge/text.h" -#include "cge/talk.h" -#include "cge/vol.h" -#include "cge/bitmaps.h" -#include "cge/game.h" -#include "cge/snail.h" -#include -#include -#include -#include +#include "cge/general.h" +#include "cge/text.h" +#include "cge/talk.h" +#include "cge/vol.h" +#include "cge/bitmaps.h" +#include "cge/game.h" +#include "cge/snail.h" +#include +#include +#include +#include namespace CGE { - TEXT Text = ProgName(); - TALK * Talk = NULL; +TEXT Text = ProgName(); +TALK *Talk = NULL; +TEXT::TEXT(const char *fname, int size) { + Cache = new HAN[size]; + MergeExt(FileName, fname, SAY_EXT); + if (!INI_FILE::Exist(FileName)) + error("No talk\n"); - - - -TEXT::TEXT (const char * fname, int size) -{ - Cache = new HAN[size]; - MergeExt(FileName, fname, SAY_EXT); - if (! INI_FILE::Exist(FileName)) { - error("No talk\n"); - } - - for (Size = 0; Size < size; Size ++) - { - Cache[Size].Ref = 0; - Cache[Size].Txt = NULL; - } + for (Size = 0; Size < size; Size ++) { + Cache[Size].Ref = 0; + Cache[Size].Txt = NULL; + } } - - -TEXT::~TEXT (void) -{ - Clear(); - delete[] Cache; +TEXT::~TEXT(void) { + Clear(); + delete[] Cache; } - - - -void TEXT::Clear (int from, int upto) -{ - HAN * p, * q; - for (p = Cache, q = p+Size; p < q; p ++) - { - if (p->Ref && p->Ref >= from && p->Ref < upto) - { - p->Ref = 0; - delete p->Txt; - p->Txt = NULL; +void TEXT::Clear(int from, int upto) { + HAN *p, * q; + for (p = Cache, q = p + Size; p < q; p ++) { + if (p->Ref && p->Ref >= from && p->Ref < upto) { + p->Ref = 0; + delete p->Txt; + p->Txt = NULL; + } } - } } - - - -int TEXT::Find (int ref) -{ - HAN * p, * q; - int i = 0; - for (p = Cache, q = p+Size; p < q; p ++) - { - if (p->Ref == ref) break; - else ++ i; - } - return i; +int TEXT::Find(int ref) { + HAN *p, * q; + int i = 0; + for (p = Cache, q = p + Size; p < q; p ++) { + if (p->Ref == ref) + break; + else + ++i; + } + return i; } - - - - - - - - - -void TEXT::Preload (int from, int upto) -{ - INI_FILE tf = FileName; - if (! tf.Error) - { - HAN * CacheLim = Cache + Size; - char line[LINE_MAX+1]; - int n; - - while ((n = tf.Read((uint8*)line)) != 0) - { - char * s; - int ref; - - if (line[n-1] == '\n') line[-- n] = '\0'; - if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; - if (! IsDigit(*s)) continue; - ref = atoi(s); - if (ref && ref >= from && ref < upto) - { - HAN * p; - - p = &Cache[Find(ref)]; - if (p < CacheLim) - { - delete[] p->Txt; - p->Txt = NULL; +void TEXT::Preload(int from, int upto) { + INI_FILE tf = FileName; + if (! tf.Error) { + HAN *CacheLim = Cache + Size; + char line[LINE_MAX + 1]; + int n; + + while ((n = tf.Read((uint8 *)line)) != 0) { + char *s; + int ref; + + if (line[n - 1] == '\n') + line[-- n] = '\0'; + if ((s = strtok(line, " =,;/\t\n")) == NULL) + continue; + if (! IsDigit(*s)) + continue; + ref = atoi(s); + if (ref && ref >= from && ref < upto) { + HAN *p; + + p = &Cache[Find(ref)]; + if (p < CacheLim) { + delete[] p->Txt; + p->Txt = NULL; + } else + p = &Cache[Find(0)]; + if (p >= CacheLim) + break; + s += strlen(s); + if (s < line + n) + ++s; + if ((p->Txt = new char[strlen(s) + 1]) == NULL) + break; + p->Ref = ref; + strcpy(p->Txt, s); + } } - else p = &Cache[Find(0)]; - if (p >= CacheLim) break; - s += strlen(s); - if (s < line + n) ++ s; - if ((p->Txt = new char[strlen(s) + 1]) == NULL) break; - p->Ref = ref; - strcpy(p->Txt, s); - } } - } } - - - -char * TEXT::Load (int idx, int ref) -{ - INI_FILE tf = FileName; - if (! tf.Error) - { - HAN * p = &Cache[idx]; - char line[LINE_MAX+1]; - int n; - - while ((n = tf.Read((uint8*)line)) != 0) - { - char * s; - - if (line[n-1] == '\n') line[-- n] = '\0'; - if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; - if (! IsDigit(*s)) continue; - - int r = atoi(s); - if (r < ref) continue; - if (r > ref) break; - // (r == ref) - s += strlen(s); - if (s < line + n) ++ s; - p->Ref = ref; - if ((p->Txt = new char[strlen(s) + 1]) == NULL) return NULL; - return strcpy(p->Txt, s); +char *TEXT::Load(int idx, int ref) { + INI_FILE tf = FileName; + if (! tf.Error) { + HAN *p = &Cache[idx]; + char line[LINE_MAX + 1]; + int n; + + while ((n = tf.Read((uint8 *)line)) != 0) { + char *s; + + if (line[n - 1] == '\n') + line[-- n] = '\0'; + if ((s = strtok(line, " =,;/\t\n")) == NULL) + continue; + if (! IsDigit(*s)) + continue; + + int r = atoi(s); + if (r < ref) + continue; + if (r > ref) + break; + // (r == ref) + s += strlen(s); + if (s < line + n) + ++s; + p->Ref = ref; + if ((p->Txt = new char[strlen(s) + 1]) == NULL) + return NULL; + return strcpy(p->Txt, s); + } } - } - return NULL; + return NULL; } +char *TEXT::operator [](int ref) { + int i; + if ((i = Find(ref)) < Size) + return Cache[i].Txt; - -char * TEXT::operator [] (int ref) -{ - int i; - if ((i = Find(ref)) < Size) return Cache[i].Txt; - - if ((i = Find(0)) >= Size) - { - Clear(SYSTXT_MAX); // clear non-system - if ((i = Find(0)) >= Size) - { - Clear(); // clear all - i = 0; + if ((i = Find(0)) >= Size) { + Clear(SYSTXT_MAX); // clear non-system + if ((i = Find(0)) >= Size) { + Clear(); // clear all + i = 0; + } } - } - return Load(i, ref); + return Load(i, ref); } - - - - -void Say (const char * txt, SPRITE * spr) -{ - KillText(); - Talk = new TALK(txt, ROUND); - if (Talk) - { - bool east = spr->Flags.East; - int x = (east) ? (spr->X+spr->W-2) : (spr->X+2); - int y = spr->Y+2; - SPRITE * spike = new SPRITE(SP); - uint16 sw = spike->W; - - if (east) - { - if (x + sw + TEXT_RD + 5 >= SCR_WID) east = false; - } - else - { - if (x <= 5 + TEXT_RD + sw) east = true; +void Say(const char *txt, SPRITE *spr) { + KillText(); + Talk = new TALK(txt, ROUND); + if (Talk) { + bool east = spr->Flags.East; + int x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2); + int y = spr->Y + 2; + SPRITE *spike = new SPRITE(SP); + uint16 sw = spike->W; + + if (east) { + if (x + sw + TEXT_RD + 5 >= SCR_WID) + east = false; + } else { + if (x <= 5 + TEXT_RD + sw) + east = true; + } + x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2 - sw); + if (spr->Ref == 1) + x += (east) ? -10 : 10; // Hero + + Talk->Flags.Kill = true; + Talk->Flags.BDel = true; + Talk->SetName(Text[SAY_NAME]); + Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H + 1); + Talk->Z = 125; + Talk->Ref = SAY_REF; + + spike->Goto(x, Talk->Y + Talk->H - 1); + spike->Z = 126; + spike->Flags.Slav = true; + spike->Flags.Kill = true; + spike->SetName(Text[SAY_NAME]); + spike->Step(east); + spike->Ref = SAY_REF; + + VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last()); + VGA::ShowQ.Insert(spike, VGA::ShowQ.Last()); } - x = (east) ? (spr->X+spr->W-2) : (spr->X+2-sw); - if (spr->Ref == 1) x += (east) ? -10 : 10; // Hero - - Talk->Flags.Kill = true; - Talk->Flags.BDel = true; - Talk->SetName(Text[SAY_NAME]); - Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H+1); - Talk->Z = 125; - Talk->Ref = SAY_REF; - - spike->Goto(x, Talk->Y + Talk->H - 1); - spike->Z = 126; - spike->Flags.Slav = true; - spike->Flags.Kill = true; - spike->SetName(Text[SAY_NAME]); - spike->Step(east); - spike->Ref = SAY_REF; - - VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last()); - VGA::ShowQ.Insert(spike, VGA::ShowQ.Last()); - } } - - - - - - -void Inf (const char * txt) -{ - KillText(); - Talk = new TALK(txt, RECT); - if (Talk) - { - Talk->Flags.Kill = true; - Talk->Flags.BDel = true; - Talk->SetName(Text[INF_NAME]); - Talk->Center(); - Talk->Goto(Talk->X, Talk->Y - 20); - Talk->Z = 126; - Talk->Ref = INF_REF; - VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last()); - } +void Inf(const char *txt) { + KillText(); + Talk = new TALK(txt, RECT); + if (Talk) { + Talk->Flags.Kill = true; + Talk->Flags.BDel = true; + Talk->SetName(Text[INF_NAME]); + Talk->Center(); + Talk->Goto(Talk->X, Talk->Y - 20); + Talk->Z = 126; + Talk->Ref = INF_REF; + VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last()); + } } - - - - - -void SayTime (SPRITE * spr) -{ -/* - static char t[] = "00:00"; - struct time ti; - gettime(&ti); - wtom(ti.ti_hour, t+0, 10, 2); - wtom(ti.ti_min, t+3, 10, 2); - Say((*t == '0') ? (t+1) : t, spr); - */ - warning("STUB: SayTime"); +void SayTime(SPRITE *spr) { + /* + static char t[] = "00:00"; + struct time ti; + gettime(&ti); + wtom(ti.ti_hour, t+0, 10, 2); + wtom(ti.ti_min, t+3, 10, 2); + Say((*t == '0') ? (t+1) : t, spr); + */ + warning("STUB: SayTime"); } - - - - - -void KillText (void) -{ - if (Talk) - { - SNPOST_(SNKILL, -1, 0, Talk); - Talk = NULL; - } +void KillText(void) { + if (Talk) { + SNPOST_(SNKILL, -1, 0, Talk); + Talk = NULL; + } } } // End of namespace CGE diff --git a/engines/cge/text.h b/engines/cge/text.h index 222a3abf7d..fe740ffacd 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -25,61 +25,61 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __TEXT__ -#define __TEXT__ +#ifndef __TEXT__ +#define __TEXT__ -#include "cge/talk.h" -#include "cge/jbw.h" -//#include +#include "cge/talk.h" +#include "cge/jbw.h" namespace CGE { -#ifndef SYSTXT_MAX - #define SYSTXT_MAX 1000 +#ifndef SYSTXT_MAX +#define SYSTXT_MAX 1000 #endif -#define SAY_EXT ".SAY" +#define SAY_EXT ".SAY" -#define NOT_VGA_TEXT 90 -#define BAD_CHIP_TEXT 91 -#define BAD_DOS_TEXT 92 -#define NO_CORE_TEXT 93 -#define BAD_MIPS_TEXT 94 -#define NO_MOUSE_TEXT 95 +#define NOT_VGA_TEXT 90 +#define BAD_CHIP_TEXT 91 +#define BAD_DOS_TEXT 92 +#define NO_CORE_TEXT 93 +#define BAD_MIPS_TEXT 94 +#define NO_MOUSE_TEXT 95 -#define INF_NAME 101 -#define SAY_NAME 102 +#define INF_NAME 101 +#define SAY_NAME 102 + +#define INF_REF 301 +#define SAY_REF 302 -#define INF_REF 301 -#define SAY_REF 302 - -class TEXT -{ - struct HAN { int Ref; char * Txt; } * Cache; - int Size; - char FileName[MAXPATH]; - char * Load (int idx, int ref); - int Find (int ref); +class TEXT { + struct HAN { + int Ref; + char *Txt; + } *Cache; + int Size; + char FileName[MAXPATH]; + char *Load(int idx, int ref); + int Find(int ref); public: - TEXT (const char * fname, int size = 128); - ~TEXT (void); - void Clear (int from = 1, int upto = 0x7FFF); - void Preload (int from = 1, int upto = 0x7FFF); - char * operator[] (int ref); + TEXT(const char *fname, int size = 128); + ~TEXT(void); + void Clear(int from = 1, int upto = 0x7FFF); + void Preload(int from = 1, int upto = 0x7FFF); + char *operator[](int ref); }; - -extern TALK * Talk; -extern TEXT Text; +extern TALK *Talk; +extern TEXT Text; -void Say (const char * txt, SPRITE * spr); -void SayTime (SPRITE * spr); -void Inf (const char * txt); -void KillText (void); +void Say(const char *txt, SPRITE *spr); +void SayTime(SPRITE *spr); +void Inf(const char *txt); +void KillText(void); } // End of namespace CGE diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 01441c85a3..e7ed6d0402 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -25,245 +25,219 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/general.h" -#include "cge/vga13h.h" -#include "cge/bitmap.h" -#include "cge/vol.h" -#include "cge/text.h" -#include -#include -#include -#include -#include -#include -#include +#include "cge/general.h" +#include "cge/vga13h.h" +#include "cge/bitmap.h" +#include "cge/vol.h" +#include "cge/text.h" +#include +#include +#include +#include +#include +#include +#include namespace CGE { #ifdef DEBUG -#define REPORT +#define REPORT #endif -#define OK(f) ((f).Error==0) -#define FADE_STEP 2 +#define OK(f) ((f).Error==0) +#define FADE_STEP 2 -#define TMR_DIV ((0x8000/TMR_RATE)*2) +#define TMR_DIV ((0x8000/TMR_RATE)*2) //-------------------------------------------------------------------------- -#ifdef REPORT +#ifdef REPORT static char Report[] = "NearHeap=..... FarHeap=......\n"; -#define NREP 9 -#define FREP 24 +#define NREP 9 +#define FREP 24 #endif -static VgaRegBlk VideoMode[] = { +static VgaRegBlk VideoMode[] = { - { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode + { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode + { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 + { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 + { 0x06, VGAGRA, 0x02, 0x00 }, // misc + { 0x14, VGACRT, 0x40, 0x00 }, // underline + { 0x13, VGACRT, 0xFF, 0x28 }, // screen width + { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control + { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end + { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line + { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode +// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end +// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb +// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr + { 0x00 } +}; - { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 - { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 - { 0x06, VGAGRA, 0x02, 0x00 }, // misc - { 0x14, VGACRT, 0x40, 0x00 }, // underline - { 0x13, VGACRT, 0xFF, 0x28 }, // screen width - { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control +bool SpeedTest = false; +SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; +SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; +SPRITE *Sys = NULL; - { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end - { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line +extern "C" void SNDMIDIPlay(void); - { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode - -// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end -// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb -// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr - - { 0x00 } }; - - - bool SpeedTest = false; - SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; - SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; - SPRITE * Sys = NULL; - -extern "C" void SNDMIDIPlay (void); - - - - - - -char * NumStr (char * str, int num) -{ - char * p = strchr(str, '#'); - if (p) wtom(num, p, 10, 5); - return str; +char *NumStr(char *str, int num) { + char *p = strchr(str, '#'); + if (p) + wtom(num, p, 10, 5); + return str; } - - - - - -// TODO Video ASM -/* -static void Video (void) +static void Video(void) { +/* static uint16 SP_S; - - asm push bx - asm push bp - asm push si - asm push di - asm push es - asm xor bx,bx // video page #0 + asm push bx + asm push bp + asm push si + asm push di + asm push es + asm xor bx,bx // video page #0 SP_S = _SP; - asm int VIDEO + asm int VIDEO _SP = SP_S; - asm pop es - asm pop di - asm pop si - asm pop bp - asm pop bx - + asm pop es + asm pop di + asm pop si + asm pop bp + asm pop bx +*/ + warning("STUB: Video"); } - */ - - - -uint16 * SaveScreen (void) -{ -/* - uint16 cxy, cur, siz, * scr = NULL, * sav; - - // horizontal size of text mode screen - asm mov ah,0x0F // get current video mode - Video(); // BIOS video service - asm xchg ah,al // answer in ah - asm push ax // preserve width - - // vertical size of text mode screen - asm mov dl,24 // last row on std screen - asm xor bx,bx // valid request in BH - asm mov ax,0x1130 // get EGA's last row # - Video(); // BIOS video service - asm inc dl // # of rows = last+1 - - // compute screen size in words - asm pop ax // restore width - asm mul dl // width * height - - siz = _AX; - - asm mov ax,0x40 // system data segment - asm mov es,ax - asm mov ax,0B000H // Mono - asm cmp byte ptr es:[0x49],0x07 - asm je sto - asm mov ax,0B800H // Color - sto: // store screen address - asm mov word ptr scr+2,ax - - _AH = 0x0F; Video(); // active page - - // take cursor shape - _AH = 0x03; Video(); // get cursor size - cur = _CX; - - // take cursor position - _DH = 0; - _AH = 0x03; Video(); // get cursor - cxy = _DX; - - sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor - if (sav) - { - sav[0] = siz; - sav[1] = cur; - sav[2] = cxy; - memcpy(sav+3, scr, siz * 2); - } - return sav; - */ +uint16 *SaveScreen(void) { + /* + uint16 cxy, cur, siz, * scr = NULL, * sav; + + // horizontal size of text mode screen + asm mov ah,0x0F // get current video mode + Video(); // BIOS video service + asm xchg ah,al // answer in ah + asm push ax // preserve width + + // vertical size of text mode screen + asm mov dl,24 // last row on std screen + asm xor bx,bx // valid request in BH + asm mov ax,0x1130 // get EGA's last row # + Video(); // BIOS video service + asm inc dl // # of rows = last+1 + + // compute screen size in words + asm pop ax // restore width + asm mul dl // width * height + + siz = _AX; + + asm mov ax,0x40 // system data segment + asm mov es,ax + asm mov ax,0B000H // Mono + asm cmp byte ptr es:[0x49],0x07 + asm je sto + asm mov ax,0B800H // Color + sto: // store screen address + asm mov word ptr scr+2,ax + + _AH = 0x0F; Video(); // active page + + // take cursor shape + _AH = 0x03; Video(); // get cursor size + cur = _CX; + + // take cursor position + _DH = 0; + _AH = 0x03; Video(); // get cursor + cxy = _DX; + + sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor + if (sav) + { + sav[0] = siz; + sav[1] = cur; + sav[2] = cxy; + memcpy(sav+3, scr, siz * 2); + } + return sav; + */ warning("STUB: SaveScreen"); return 0; } -void RestoreScreen (uint16 * &sav) -{ -/* - uint16 * scr = NULL; +void RestoreScreen(uint16 * &sav) { + /* + uint16 * scr = NULL; - asm mov ax,0x40 // system data segment - asm mov es,ax - asm mov ax,0B000H // Mono - asm cmp byte ptr es:[0x49],0x07 - asm je sto - asm mov ax,0B800H // Color - sto: // store screen address - asm mov word ptr scr+2,ax + asm mov ax,0x40 // system data segment + asm mov es,ax + asm mov ax,0B000H // Mono + asm cmp byte ptr es:[0x49],0x07 + asm je sto + asm mov ax,0B800H // Color + sto: // store screen address + asm mov word ptr scr+2,ax - memcpy(scr, sav+3, sav[0] * 2); + memcpy(scr, sav+3, sav[0] * 2); - _AH = 0x0F; Video(); // active page + _AH = 0x0F; Video(); // active page - // set cursor shape - _CX = sav[1]; - _AH = 0x01; Video(); // set cursor size + // set cursor shape + _CX = sav[1]; + _AH = 0x01; Video(); // set cursor size - // set cursor position - _DX = sav[2]; - _AH = 0x02; Video(); // set cursor + // set cursor position + _DX = sav[2]; + _AH = 0x02; Video(); // set cursor - free(sav); - sav = NULL; - */ + free(sav); + sav = NULL; + */ warning("STUB: RestoreScreen"); } -DAC MkDAC (uint8 r, uint8 g, uint8 b) -{ - static DAC x; - x.R = r; - x.G = g; - x.B = b; - return x; +DAC MkDAC(uint8 r, uint8 g, uint8 b) { + static DAC x; + x.R = r; + x.G = g; + x.B = b; + return x; } -RGB MkRGB (uint8 r, uint8 g, uint8 b) -{ - static TRGB x; - x.dac.R = r; - x.dac.G = g; - x.dac.B = b; - return x.rgb; +RGB MkRGB(uint8 r, uint8 g, uint8 b) { + static TRGB x; + x.dac.R = r; + x.dac.G = g; + x.dac.B = b; + return x.rgb; } -SPRITE * Locate (int ref) -{ - SPRITE * spr = VGA::ShowQ.Locate(ref); - return (spr) ? spr : VGA::SpareQ.Locate(ref); +SPRITE *Locate(int ref) { + SPRITE *spr = VGA::ShowQ.Locate(ref); + return (spr) ? spr : VGA::SpareQ.Locate(ref); } -bool HEART::Enable = false; -uint16 * HEART::XTimer = NULL; +bool HEART::Enable = false; +uint16 *HEART::XTimer = NULL; -HEART::HEART (void) -: ENGINE(TMR_DIV) -{ +HEART::HEART(void) + : ENGINE(TMR_DIV) { } @@ -278,1323 +252,1284 @@ extern "C" void TimerProc (void) if (*HEART::XTimer) -- *HEART::XTimer; else HEART::XTimer = NULL; - if (! run && HEART::Enable) // check overrun flag + if (! run && HEART::Enable) // check overrun flag { static uint16 oldSP, oldSS; - ++ run; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 + ++ run; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 // system pseudo-sprite if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) - { - if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); - } - asm mov ss,oldSS - asm mov sp,oldSP + { + if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); + } + asm mov ss,oldSS + asm mov sp,oldSP -- run; } } */ -void ENGINE::NewTimer(...) -{ - static SPRITE * spr; - static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - /* - ___1152_Hz___: +void ENGINE::NewTimer(...) { + static SPRITE *spr; + static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; + /* + ___1152_Hz___: - SNDMIDIPlay(); - asm dec cntr1 - asm jz ___72_Hz___ - asm mov al,0x20 // send... - asm out 0x020,al // ...e-o-i - return; + SNDMIDIPlay(); + asm dec cntr1 + asm jz ___72_Hz___ + asm mov al,0x20 // send... + asm out 0x020,al // ...e-o-i + return; - ___72_Hz___: + ___72_Hz___: - asm mov cntr1,TMR_RATE1 - asm dec cntr2 - asm jnz my_eoi + asm mov cntr1,TMR_RATE1 + asm dec cntr2 + asm jnz my_eoi - ___18_Hz___: + ___18_Hz___: - OldTimer(); - asm mov cntr2,TMR_RATE2 - asm jmp short my_int + OldTimer(); + asm mov cntr2,TMR_RATE2 + asm jmp short my_int - // send E-O-I - my_eoi: - asm mov al,0x20 - asm out 0x020,al - asm sti // enable interrupts + // send E-O-I + my_eoi: + asm mov al,0x20 + asm out 0x020,al + asm sti // enable interrupts - my_int: //------72Hz-------// + my_int: //------72Hz-------// - // decrement external timer uint16 - if (HEART::XTimer) - if (*HEART::XTimer) -- *HEART::XTimer; - else HEART::XTimer = NULL; + // decrement external timer uint16 + if (HEART::XTimer) + if (*HEART::XTimer) -- *HEART::XTimer; + else HEART::XTimer = NULL; - if (! run && HEART::Enable) // check overrun flag - { - static uint16 oldSP, oldSS; + if (! run && HEART::Enable) // check overrun flag + { + static uint16 oldSP, oldSS; - ++ run; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 + ++ run; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 - // system pseudo-sprite - if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); + // system pseudo-sprite + if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); } - asm mov ss,oldSS - asm mov sp,oldSP - -- run; - } + asm mov ss,oldSS + asm mov sp,oldSP + -- run; + } */ warning("STUB: ENGINE::NewTimer"); } -void HEART::SetXTimer (uint16 * ptr) -{ - if (XTimer && ptr != XTimer) *XTimer = 0; - XTimer = ptr; +void HEART::SetXTimer(uint16 *ptr) { + if (XTimer && ptr != XTimer) + *XTimer = 0; + XTimer = ptr; } -void HEART::SetXTimer (uint16 * ptr, uint16 time) -{ - SetXTimer(ptr); - *ptr = time; +void HEART::SetXTimer(uint16 *ptr, uint16 time) { + SetXTimer(ptr); + *ptr = time; } -SPRITE::SPRITE (BMP_PTR * shp) -: X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), - Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), - Ext(NULL), Ref(-1), Cave(0) -{ - memset(File, 0, sizeof(File)); - *((uint16 *)&Flags) = 0; - SetShapeList(shp); +SPRITE::SPRITE(BMP_PTR *shp) + : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), + Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), + Ext(NULL), Ref(-1), Cave(0) { + memset(File, 0, sizeof(File)); + *((uint16 *)&Flags) = 0; + SetShapeList(shp); } -SPRITE::~SPRITE (void) -{ - Contract(); +SPRITE::~SPRITE(void) { + Contract(); } -BMP_PTR SPRITE::Shp (void) -{ - register SPREXT * e = Ext; - if (e) if (e->Seq) - { - int i = e->Seq[SeqPtr].Now; - #ifdef DEBUG - if (i >= ShpCnt) - { - //char s[256]; - //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", - // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); - //VGA::Exit(s, File); - error("Invalid PHASE in SPRITE::Shp() %s", File); - } - #endif - return e->ShpList[i]; - } - return NULL; +BMP_PTR SPRITE::Shp(void) { + register SPREXT *e = Ext; + if (e) + if (e->Seq) { + int i = e->Seq[SeqPtr].Now; +#ifdef DEBUG + if (i >= ShpCnt) { + //char s[256]; + //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", + // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); + //VGA::Exit(s, File); + error("Invalid PHASE in SPRITE::Shp() %s", File); + } +#endif + return e->ShpList[i]; + } + return NULL; } -BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) -{ - BMP_PTR * r = (Ext) ? Ext->ShpList : NULL; +BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { + BMP_PTR *r = (Ext) ? Ext->ShpList : NULL; - ShpCnt = 0; - W = 0; - H = 0; + ShpCnt = 0; + W = 0; + H = 0; - if (shp) - { - BMP_PTR * p; - for (p = shp; *p; p ++) - { - BMP_PTR b = (*p); // ->Code(); - if (b->W > W) W = b->W; - if (b->H > H) H = b->H; - ++ ShpCnt; + if (shp) { + BMP_PTR *p; + for (p = shp; *p; p++) { + BMP_PTR b = (*p); // ->Code(); + if (b->W > W) + W = b->W; + if (b->H > H) + H = b->H; + ++ShpCnt; + } + Expand(); + Ext->ShpList = shp; + if (! Ext->Seq) + SetSeq((ShpCnt < 2) ? Seq1 : Seq2); } - Expand(); - Ext->ShpList = shp; - if (! Ext->Seq) SetSeq((ShpCnt < 2) ? Seq1 : Seq2); - } - return r; -} - - -void SPRITE::MoveShapes (uint8 * buf) -{ - BMP_PTR * p; - for (p = Ext->ShpList; *p; p ++) - { - buf += (*p)->MoveVmap(buf); - } + return r; } -bool SPRITE::Works (SPRITE * spr) -{ - if (spr) if (spr->Ext) - { - SNAIL::COM * c = spr->Ext->Take; - if (c != NULL) - { - c += spr->TakePtr; - if (c->Ref == Ref) - if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) - return true; +void SPRITE::MoveShapes(uint8 *buf) { + BMP_PTR *p; + for (p = Ext->ShpList; *p; p ++) { + buf += (*p)->MoveVmap(buf); } - } - return false; } -SEQ * SPRITE::SetSeq (SEQ * seq) -{ - Expand(); - register SEQ * s = Ext->Seq; - Ext->Seq = seq; - if (SeqPtr == NO_SEQ) Step(0); - else - if (Time == 0) Step(SeqPtr); - return s; +bool SPRITE::Works(SPRITE *spr) { + if (spr) + if (spr->Ext) { + SNAIL::COM *c = spr->Ext->Take; + if (c != NULL) { + c += spr->TakePtr; + if (c->Ref == Ref) + if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) + return true; + } + } + return false; } -bool SPRITE::SeqTest (int n) -{ - if (n >= 0) return (SeqPtr == n); - if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); - return true; +SEQ *SPRITE::SetSeq(SEQ *seq) { + Expand(); + register SEQ *s = Ext->Seq; + Ext->Seq = seq; + if (SeqPtr == NO_SEQ) + Step(0); + else if (Time == 0) + Step(SeqPtr); + return s; } -SNAIL::COM * SPRITE::SnList (SNLIST type) -{ - register SPREXT * e = Ext; - if (e) return (type == NEAR) ? e->Near : e->Take; - return NULL; +bool SPRITE::SeqTest(int n) { + if (n >= 0) + return (SeqPtr == n); + if (Ext) + return (Ext->Seq[SeqPtr].Next == SeqPtr); + return true; } -void SPRITE::SetName (char * n) -{ - if (Ext) - { - if (Ext->Name) - { - delete[] Ext->Name; - Ext->Name = NULL; - } - if (n) - { - if ((Ext->Name = new char[strlen(n)+1]) != NULL) strcpy(Ext->Name, n); - else - error("No core [%s]", n); - } - } +SNAIL::COM *SPRITE::SnList(SNLIST type) { + register SPREXT *e = Ext; + if (e) + return (type == NEAR) ? e->Near : e->Take; + return NULL; } -SPRITE * SPRITE::Expand (void) -{ - if (! Ext) - { - bool enbl = HEART::Enable; - HEART::Enable = false; - if ((Ext = new SPREXT) == NULL) - error("No core"); - if (*File) - { - static const char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; - char line[LINE_MAX], fname[MAXPATH]; - BMP_PTR * shplist = new BMP_PTR [ShpCnt+1]; - SEQ * seq = NULL; - int shpcnt = 0, - seqcnt = 0, - neacnt = 0, - takcnt = 0, - maxnow = 0, - maxnxt = 0, - lcnt = 0, - len; - - SNAIL::COM * nea = NULL; - SNAIL::COM * tak = NULL; - MergeExt(fname, File, SPR_EXT); - if (INI_FILE::Exist(fname)) // sprite description file exist - { - INI_FILE sprf(fname); - if (! OK(sprf)) - error("Bad SPR [%s]", fname); - - while ((len = sprf.Read((uint8*)line)) != 0) - { - ++ lcnt; - if (len && line[len-1] == '\n') line[-- len] = '\0'; - if (len == 0 || *line == '.') continue; - - switch (TakeEnum(Comd, strtok(line, " =\t"))) - { - case 0 : // Name - { - SetName(strtok(NULL, "")); break; - } - case 1 : // Phase - { - shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); - break; - } - case 2 : // Seq - { - seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); - if (seq == NULL) - error("No core [%s]", fname); - SEQ * s = &seq[seqcnt ++]; - s->Now = atoi(strtok(NULL, " \t,;/")); - if (s->Now > maxnow) maxnow = s->Now; - s->Next = atoi(strtok(NULL, " \t,;/")); - switch (s->Next) - { - case 0xFF : s->Next = seqcnt; break; - case 0xFE : s->Next = seqcnt-1; break; - } - if (s->Next > maxnxt) maxnxt = s->Next; - s->Dx = atoi(strtok(NULL, " \t,;/")); - s->Dy = atoi(strtok(NULL, " \t,;/")); - s->Dly = atoi(strtok(NULL, " \t,;/")); - break; - } - case 3 : // Near - { - if (NearPtr != NO_PTR) - { - nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - if (nea == NULL) - error("No core [%s]", fname); - else - { - SNAIL::COM * c = &nea[neacnt ++]; - if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); - c->Ref = atoi(strtok(NULL, " \t,;/")); - c->Val = atoi(strtok(NULL, " \t,;/")); - c->Ptr = NULL; - } - } - } - break; - case 4 : // Take - { - if (TakePtr != NO_PTR) - { - tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - if (tak == NULL) - error("No core [%s]", fname); - else - { - SNAIL::COM * c = &tak[takcnt ++]; - if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); - c->Ref = atoi(strtok(NULL, " \t,;/")); - c->Val = atoi(strtok(NULL, " \t,;/")); - c->Ptr = NULL; - } - } - break; - } - } +void SPRITE::SetName(char *n) { + if (Ext) { + if (Ext->Name) { + delete[] Ext->Name; + Ext->Name = NULL; + } + if (n) { + if ((Ext->Name = new char[strlen(n) + 1]) != NULL) + strcpy(Ext->Name, n); + else + error("No core [%s]", n); } - } - else // no sprite description: try to read immediately from .BMP - { - shplist[shpcnt ++] = new BITMAP(File); - } - shplist[shpcnt] = NULL; - if (seq) - { - if (maxnow >= shpcnt) - error("Bad PHASE in SEQ [%s]", fname); - if (maxnxt >= seqcnt) - error("Bad JUMP in SEQ [%s]", fname); - SetSeq(seq); - } - else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); - //disable(); // disable interupt - - SetShapeList(shplist); - //enable(); // enable interupt - if (nea) nea[neacnt-1].Ptr = Ext->Near = nea; else NearPtr = NO_PTR; - if (tak) tak[takcnt-1].Ptr = Ext->Take = tak; else TakePtr = NO_PTR; } - HEART::Enable = enbl; - } - return this; } -SPRITE * SPRITE::Contract (void) -{ - register SPREXT * e = Ext; - if (e) - { - if (e->Name) delete[] e->Name; - if (Flags.BDel && e->ShpList) - { - int i; - for (i = 0; e->ShpList[i]; i ++) delete e->ShpList[i]; - if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; +SPRITE *SPRITE::Expand(void) { + if (! Ext) { + bool enbl = HEART::Enable; + HEART::Enable = false; + if ((Ext = new SPREXT) == NULL) + error("No core"); + if (*File) { + static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; + char line[LINE_MAX], fname[MAXPATH]; + BMP_PTR *shplist = new BMP_PTR [ShpCnt + 1]; + SEQ *seq = NULL; + int shpcnt = 0, + seqcnt = 0, + neacnt = 0, + takcnt = 0, + maxnow = 0, + maxnxt = 0, + lcnt = 0, + len; + + SNAIL::COM *nea = NULL; + SNAIL::COM *tak = NULL; + MergeExt(fname, File, SPR_EXT); + if (INI_FILE::Exist(fname)) { // sprite description file exist + INI_FILE sprf(fname); + if (! OK(sprf)) + error("Bad SPR [%s]", fname); + + while ((len = sprf.Read((uint8 *)line)) != 0) { + ++ lcnt; + if (len && line[len - 1] == '\n') + line[-- len] = '\0'; + if (len == 0 || *line == '.') + continue; + + switch (TakeEnum(Comd, strtok(line, " =\t"))) { + case 0 : { // Name + SetName(strtok(NULL, "")); + break; + } + case 1 : { // Phase + shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); + break; + } + case 2 : { // Seq + seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + if (seq == NULL) + error("No core [%s]", fname); + SEQ *s = &seq[seqcnt ++]; + s->Now = atoi(strtok(NULL, " \t,;/")); + if (s->Now > maxnow) + maxnow = s->Now; + s->Next = atoi(strtok(NULL, " \t,;/")); + switch (s->Next) { + case 0xFF : + s->Next = seqcnt; + break; + case 0xFE : + s->Next = seqcnt - 1; + break; + } + if (s->Next > maxnxt) + maxnxt = s->Next; + s->Dx = atoi(strtok(NULL, " \t,;/")); + s->Dy = atoi(strtok(NULL, " \t,;/")); + s->Dly = atoi(strtok(NULL, " \t,;/")); + break; + } + case 3 : { // Near + if (NearPtr != NO_PTR) { + nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); + if (nea == NULL) + error("No core [%s]", fname); + else { + SNAIL::COM *c = &nea[neacnt ++]; + if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); + c->Ref = atoi(strtok(NULL, " \t,;/")); + c->Val = atoi(strtok(NULL, " \t,;/")); + c->Ptr = NULL; + } + } + } + break; + case 4 : { // Take + if (TakePtr != NO_PTR) { + tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); + if (tak == NULL) + error("No core [%s]", fname); + else { + SNAIL::COM *c = &tak[takcnt ++]; + if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); + c->Ref = atoi(strtok(NULL, " \t,;/")); + c->Val = atoi(strtok(NULL, " \t,;/")); + c->Ptr = NULL; + } + } + break; + } + } + } + } else { // no sprite description: try to read immediately from .BMP + shplist[shpcnt ++] = new BITMAP(File); + } + shplist[shpcnt] = NULL; + if (seq) { + if (maxnow >= shpcnt) + error("Bad PHASE in SEQ [%s]", fname); + if (maxnxt >= seqcnt) + error("Bad JUMP in SEQ [%s]", fname); + SetSeq(seq); + } else + SetSeq((ShpCnt == 1) ? Seq1 : Seq2); + //disable(); // disable interupt + + SetShapeList(shplist); + //enable(); // enable interupt + if (nea) + nea[neacnt - 1].Ptr = Ext->Near = nea; + else + NearPtr = NO_PTR; + if (tak) + tak[takcnt - 1].Ptr = Ext->Take = tak; + else + TakePtr = NO_PTR; + } + HEART::Enable = enbl; } - if (MemType(e->Seq) == NEAR_MEM) free(e->Seq); - if (e->Near) free(e->Near); - if (e->Take) free(e->Take); - delete e; - Ext = NULL; - } - return this; + return this; } -SPRITE * SPRITE::BackShow (bool fast) -{ - Expand(); - Show(2); - Show(1); - if (fast) Show(0); - Contract(); - return this; -} - - -void SPRITE::Step (int nr) -{ - if (nr >= 0) SeqPtr = nr; - if (Ext) - { - SEQ * seq; - if (nr < 0) SeqPtr = Ext->Seq[SeqPtr].Next; - seq = Ext->Seq + SeqPtr; - if (seq->Dly >= 0) - { - Goto(X + (seq->Dx), Y + (seq->Dy)); - Time = seq->Dly; +SPRITE *SPRITE::Contract(void) { + register SPREXT *e = Ext; + if (e) { + if (e->Name) + delete[] e->Name; + if (Flags.BDel && e->ShpList) { + int i; + for (i = 0; e->ShpList[i]; i ++) + delete e->ShpList[i]; + if (MemType(e->ShpList) == NEAR_MEM) + delete[] e->ShpList; + } + if (MemType(e->Seq) == NEAR_MEM) + free(e->Seq); + if (e->Near) + free(e->Near); + if (e->Take) + free(e->Take); + delete e; + Ext = NULL; } - } + return this; } -void SPRITE::Tick (void) -{ - Step(); -} - - -void SPRITE::MakeXlat (uint8 * x) -{ - if (Ext) - { - BMP_PTR * b; - - if (Flags.Xlat) KillXlat(); - for (b = Ext->ShpList; *b; b ++) (*b)->M = x; - Flags.Xlat = true; - } +SPRITE *SPRITE::BackShow(bool fast) { + Expand(); + Show(2); + Show(1); + if (fast) + Show(0); + Contract(); + return this; } -void SPRITE::KillXlat (void) -{ - if (Flags.Xlat && Ext) - { - BMP_PTR * b; - uint8 * m = (*Ext->ShpList)->M; - - switch (MemType(m)) - { - case NEAR_MEM : delete[] (uint8 *) m; break; - case FAR_MEM : free(m); break; +void SPRITE::Step(int nr) { + if (nr >= 0) + SeqPtr = nr; + if (Ext) { + SEQ *seq; + if (nr < 0) + SeqPtr = Ext->Seq[SeqPtr].Next; + seq = Ext->Seq + SeqPtr; + if (seq->Dly >= 0) { + Goto(X + (seq->Dx), Y + (seq->Dy)); + Time = seq->Dly; + } } - for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; - Flags.Xlat = false; - } } -void SPRITE::Goto (int x, int y) -{ - int xo = X, yo = Y; - if (W < SCR_WID) - { - if (x < 0) x = 0; - if (x + W > SCR_WID) x = (SCR_WID - W); - X = x; - } - if (H < SCR_HIG) - { - if (y < 0) y = 0; - if (y + H > SCR_HIG) y = (SCR_HIG - H); - Y = y; - } - if (Next) if (Next->Flags.Slav) Next->Goto(Next->X-xo+X, Next->Y-yo+Y); - if (Flags.Shad) Prev->Goto(Prev->X-xo+X, Prev->Y-yo+Y); +void SPRITE::Tick(void) { + Step(); } -void SPRITE::Center (void) -{ - Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); -} - +void SPRITE::MakeXlat(uint8 *x) { + if (Ext) { + BMP_PTR *b; -void SPRITE::Show (void) -{ - register SPREXT * e; - // asm cli // critic section... - e = Ext; - e->x0 = e->x1; - e->y0 = e->y1; - e->b0 = e->b1; - e->x1 = X; - e->y1 = Y; - e->b1 = Shp(); -// asm sti // ...done! - if (! Flags.Hide) - { - if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); - else e->b1->Show(e->x1, e->y1); - } + if (Flags.Xlat) + KillXlat(); + for (b = Ext->ShpList; *b; b ++) + (*b)->M = x; + Flags.Xlat = true; + } } -void SPRITE::Show (uint16 pg) -{ - uint8 * a = VGA::Page[1]; - VGA::Page[1] = VGA::Page[pg & 3]; - Shp()->Show(X, Y); - VGA::Page[1] = a; -} - +void SPRITE::KillXlat(void) { + if (Flags.Xlat && Ext) { + BMP_PTR *b; + uint8 *m = (*Ext->ShpList)->M; -void SPRITE::Hide (void) -{ - register SPREXT * e = Ext; - if (e->b0) e->b0->Hide(e->x0, e->y0); + switch (MemType(m)) { + case NEAR_MEM : + delete[](uint8 *) m; + break; + case FAR_MEM : + free(m); + break; + } + for (b = Ext->ShpList; *b; b ++) + (*b)->M = NULL; + Flags.Xlat = false; + } } -BMP_PTR SPRITE::Ghost (void) -{ - register SPREXT * e = Ext; - if (e->b1) - { - BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); - if (bmp == NULL) - error("No core"); - bmp->W = e->b1->W; - bmp->H = e->b1->H; - if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) - error("No Core"); - bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); - // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment - //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); - return bmp; - } - return NULL; +void SPRITE::Goto(int x, int y) { + int xo = X, yo = Y; + if (W < SCR_WID) { + if (x < 0) + x = 0; + if (x + W > SCR_WID) + x = (SCR_WID - W); + X = x; + } + if (H < SCR_HIG) { + if (y < 0) + y = 0; + if (y + H > SCR_HIG) + y = (SCR_HIG - H); + Y = y; + } + if (Next) + if (Next->Flags.Slav) + Next->Goto(Next->X - xo + X, Next->Y - yo + Y); + if (Flags.Shad) + Prev->Goto(Prev->X - xo + X, Prev->Y - yo + Y); } -SPRITE * SpriteAt (int x, int y) -{ - SPRITE * spr = NULL, * tail = VGA::ShowQ.Last(); - if (tail) - { - for (spr = tail->Prev; spr; spr = spr->Prev) - if (! spr->Flags.Hide && ! spr->Flags.Tran) - if (spr->Shp()->SolidAt(x-spr->X, y-spr->Y)) - break; - } - return spr; +void SPRITE::Center(void) { + Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); } -QUEUE::QUEUE (bool show) -: Head(NULL), Tail(NULL), Show(show) -{ +void SPRITE::Show(void) { + register SPREXT *e; +// asm cli // critic section... + e = Ext; + e->x0 = e->x1; + e->y0 = e->y1; + e->b0 = e->b1; + e->x1 = X; + e->y1 = Y; + e->b1 = Shp(); +// asm sti // ...done! + if (! Flags.Hide) { + if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); + else e->b1->Show(e->x1, e->y1); + } } -QUEUE::~QUEUE (void) -{ - Clear(); +void SPRITE::Show(uint16 pg) { + uint8 *a = VGA::Page[1]; + VGA::Page[1] = VGA::Page[pg & 3]; + Shp()->Show(X, Y); + VGA::Page[1] = a; } -void QUEUE::Clear (void) -{ - while (Head) - { - SPRITE * s = Remove(Head); - if (s->Flags.Kill) delete s; - } +void SPRITE::Hide(void) { + register SPREXT *e = Ext; + if (e->b0) + e->b0->Hide(e->x0, e->y0); } -void QUEUE::ForAll (void (*fun)(SPRITE *)) -{ - SPRITE * s = Head; - while (s) - { - SPRITE * n = s->Next; - fun(s); - s = n; - } +BMP_PTR SPRITE::Ghost(void) { + register SPREXT *e = Ext; + if (e->b1) { + BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); + if (bmp == NULL) + error("No core"); + bmp->W = e->b1->W; + bmp->H = e->b1->H; + if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) + error("No Core"); + bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment + //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); + warning("FIXME: SPRITE::Ghost"); + return bmp; + } + return NULL; } -void QUEUE::Append (SPRITE * spr) -{ - if (Tail) - { - spr->Prev = Tail; - Tail->Next = spr; - } - else Head = spr; - Tail = spr; - if (Show) spr->Expand(); - else spr->Contract(); +SPRITE *SpriteAt(int x, int y) { + SPRITE *spr = NULL, * tail = VGA::ShowQ.Last(); + if (tail) { + for (spr = tail->Prev; spr; spr = spr->Prev) + if (! spr->Flags.Hide && ! spr->Flags.Tran) + if (spr->Shp()->SolidAt(x - spr->X, y - spr->Y)) + break; + } + return spr; } -void QUEUE::Insert (SPRITE * spr, SPRITE * nxt) -{ - if (nxt == Head) - { - spr->Next = Head; - Head = spr; - if (! Tail) Tail = spr; - } - else - { - spr->Next = nxt; - spr->Prev = nxt->Prev; - if (spr->Prev) spr->Prev->Next = spr; - } - if (spr->Next) spr->Next->Prev = spr; - if (Show) spr->Expand(); - else spr->Contract(); +QUEUE::QUEUE(bool show) : Head(NULL), Tail(NULL), Show(show) { } -void QUEUE::Insert (SPRITE * spr) -{ - SPRITE * s; - for (s = Head; s; s = s->Next) - if (s->Z > spr->Z) - break; - if (s) Insert(spr, s); - else Append(spr); - if (Show) spr->Expand(); - else spr->Contract(); +QUEUE::~QUEUE(void) { + Clear(); } -SPRITE * QUEUE::Remove (SPRITE * spr) -{ - if (spr == Head) Head = spr->Next; - if (spr == Tail) Tail = spr->Prev; - if (spr->Next) spr->Next->Prev = spr->Prev; - if (spr->Prev) spr->Prev->Next = spr->Next; - spr->Prev = NULL; - spr->Next = NULL; - return spr; +void QUEUE::Clear(void) { + while (Head) { + SPRITE *s = Remove(Head); + if (s->Flags.Kill) + delete s; + } } -SPRITE * QUEUE::Locate (int ref) -{ - SPRITE * spr; - for (spr = Head; spr; spr = spr->Next) if (spr->Ref == ref) return spr; - return NULL; +void QUEUE::ForAll(void (*fun)(SPRITE *)) { + SPRITE *s = Head; + while (s) { + SPRITE *n = s->Next; + fun(s); + s = n; + } } -uint16 VGA::StatAdr = VGAST1_; -uint16 VGA::OldMode = 0; -uint16 * VGA::OldScreen = NULL; -const char * VGA::Msg = NULL; -const char * VGA::Nam = NULL; -DAC * VGA::OldColors = NULL; -DAC * VGA::NewColors = NULL; -bool VGA::SetPal = false; -int VGA::Mono = 0; -QUEUE VGA::ShowQ = true, VGA::SpareQ = false; +void QUEUE::Append(SPRITE *spr) { + if (Tail) { + spr->Prev = Tail; + Tail->Next = spr; + } else + Head = spr; + Tail = spr; + if (Show) + spr->Expand(); + else + spr->Contract(); +} + + +void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { + if (nxt == Head) { + spr->Next = Head; + Head = spr; + if (! Tail) + Tail = spr; + } else { + spr->Next = nxt; + spr->Prev = nxt->Prev; + if (spr->Prev) + spr->Prev->Next = spr; + } + if (spr->Next) + spr->Next->Prev = spr; + if (Show) + spr->Expand(); + else + spr->Contract(); +} + + +void QUEUE::Insert(SPRITE *spr) { + SPRITE *s; + for (s = Head; s; s = s->Next) + if (s->Z > spr->Z) + break; + if (s) + Insert(spr, s); + else + Append(spr); + if (Show) + spr->Expand(); + else + spr->Contract(); +} + + +SPRITE *QUEUE::Remove(SPRITE *spr) { + if (spr == Head) + Head = spr->Next; + if (spr == Tail) + Tail = spr->Prev; + if (spr->Next) + spr->Next->Prev = spr->Prev; + if (spr->Prev) + spr->Prev->Next = spr->Next; + spr->Prev = NULL; + spr->Next = NULL; + return spr; +} + + +SPRITE *QUEUE::Locate(int ref) { + SPRITE *spr; + for (spr = Head; spr; spr = spr->Next) + if (spr->Ref == ref) + return spr; + return NULL; +} + + +uint16 VGA::StatAdr = VGAST1_; +uint16 VGA::OldMode = 0; +uint16 *VGA::OldScreen = NULL; +const char *VGA::Msg = NULL; +const char *VGA::Nam = NULL; +DAC *VGA::OldColors = NULL; +DAC *VGA::NewColors = NULL; +bool VGA::SetPal = false; +int VGA::Mono = 0; +QUEUE VGA::ShowQ = true, VGA::SpareQ = false; // TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that -uint8 * VGA::Page[4] = { 0, 0, 0, 0 }; +uint8 *VGA::Page[4] = { 0, 0, 0, 0 }; /* -uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), - (uint8 *) MK_FP(SCR_SEG, 0x4000), - (uint8 *) MK_FP(SCR_SEG, 0x8000), - (uint8 *) MK_FP(SCR_SEG, 0xC000) }; +uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), + (uint8 *) MK_FP(SCR_SEG, 0x4000), + (uint8 *) MK_FP(SCR_SEG, 0x8000), + (uint8 *) MK_FP(SCR_SEG, 0xC000) }; */ - - //extern const char Copr[]; -VGA::VGA (int mode) -: FrmCnt(0) -{ - bool std = true; - int i; - for (i = 10; i < 20; i ++) - { - char * txt = Text[i]; - if (txt) - { +VGA::VGA(int mode) + : FrmCnt(0) { + bool std = true; + int i; + for (i = 10; i < 20; i ++) { + char *txt = Text[i]; + if (txt) { // puts(txt); - warning(txt); - #ifndef DEBUG - std = false; - #endif + warning(txt); +#ifndef DEBUG + std = false; +#endif + } } - } -// if (std) +// if (std) // warning(Copr); - warning("TODO: Fix Copr"); - - SetStatAdr(); - if (StatAdr != VGAST1_) ++ Mono; - if (IsVga()) - { - OldColors = farnew(DAC, 256); - NewColors = farnew(DAC, 256); - OldScreen = SaveScreen(); - GetColors(OldColors); - Sunset(); - OldMode = SetMode(mode); - SetColors(); - Setup(VideoMode); - Clear(); - } + warning("TODO: Fix Copr"); + + SetStatAdr(); + if (StatAdr != VGAST1_) + ++Mono; + if (IsVga()) { + OldColors = farnew(DAC, 256); + NewColors = farnew(DAC, 256); + OldScreen = SaveScreen(); + GetColors(OldColors); + Sunset(); + OldMode = SetMode(mode); + SetColors(); + Setup(VideoMode); + Clear(); + } } -VGA::~VGA (void) -{ - Mono = 0; - if (IsVga()) - { - Common::String buffer = ""; - Clear(); - SetMode(OldMode); - SetColors(); - RestoreScreen(OldScreen); - Sunrise(OldColors); - if (OldColors) free(OldColors); - if (NewColors) free(NewColors); - if (Msg) - buffer = Common::String(Msg); - if (Nam) - buffer = buffer + " [" + Nam + "]"; - - warning(buffer.c_str()); - } +VGA::~VGA(void) { + Mono = 0; + if (IsVga()) { + Common::String buffer = ""; + Clear(); + SetMode(OldMode); + SetColors(); + RestoreScreen(OldScreen); + Sunrise(OldColors); + if (OldColors) + free(OldColors); + if (NewColors) + free(NewColors); + if (Msg) + buffer = Common::String(Msg); + if (Nam) + buffer = buffer + " [" + Nam + "]"; + + warning(buffer.c_str()); + } } -void VGA::SetStatAdr (void) -{ +void VGA::SetStatAdr(void) { /* - asm mov dx,VGAMIr_ - asm in al,dx - asm test al,1 // CGA addressing mode flag - asm mov ax,VGAST1_ // CGA addressing - asm jnz set_mode_adr - asm xor al,0x60 // MDA addressing - set_mode_adr: - StatAdr = _AX; - */ + asm mov dx,VGAMIr_ + asm in al,dx + asm test al,1 // CGA addressing mode flag + asm mov ax,VGAST1_ // CGA addressing + asm jnz set_mode_adr + asm xor al,0x60 // MDA addressing + set_mode_adr: + StatAdr = _AX; + */ warning("STUB: VGA::SetStatADR"); } #pragma argsused -void VGA::WaitVR (bool on) -{ -/* - _DX = StatAdr; - _AH = (on) ? 0x00 : 0x08; - - asm mov cx,2 - // wait for vertical retrace on (off) - wait: - asm in al,dx - asm xor al,ah - asm test al,0x08 - asm jnz wait - asm xor ah,0x08 - asm loop wait - */ +void VGA::WaitVR(bool on) { + /* + _DX = StatAdr; + _AH = (on) ? 0x00 : 0x08; + + asm mov cx,2 + // wait for vertical retrace on (off) + wait: + asm in al,dx + asm xor al,ah + asm test al,0x08 + asm jnz wait + asm xor ah,0x08 + asm loop wait + */ warning("STUB: VGA::WaitVR"); } -void VGA::Setup (VgaRegBlk * vrb) -{ -/* - WaitVR(); // *--LOOK!--* resets VGAATR logic - asm cld - asm mov si, vrb // take address of parameter table - asm mov dh,0x03 // higher byte of I/O address is always 3 - - s: - asm lodsw // take lower byte of I/O address and index - asm or ah,ah // 0 = end of table - asm jz xit // no more: exit - asm or al,al // indexed register? - asm js single // 7th bit set means single register - asm mov dl,ah // complete I/O address - asm out dx,al // put index into control register - asm inc dx // data register is next to control - asm in al,dx // take old data - - write: - asm mov cl,al // preserve old data - asm lodsw // take 2 masks from table - asm xor al,0xFF // invert mask bits - asm and al,cl // clear bits with "clr" mask - asm or al,ah // set bits with "set" mask - asm cmp dl,0xC1 // special case? - asm jne std2 // no: standard job, otherwise... - asm dec dx // data out reg shares address with index - std2: - asm out dx,al // write new value to register - asm jmp s - - single: // read address in al, write address in ah - asm mov dl,al // complete I/O read address - asm in al,dx // take old data - asm mov dl,ah // complete I/O write address - asm jmp write // continue standard routine - - xit: - */ +void VGA::Setup(VgaRegBlk *vrb) { + /* + WaitVR(); // *--LOOK!--* resets VGAATR logic + asm cld + asm mov si, vrb // take address of parameter table + asm mov dh,0x03 // higher byte of I/O address is always 3 + + s: + asm lodsw // take lower byte of I/O address and index + asm or ah,ah // 0 = end of table + asm jz xit // no more: exit + asm or al,al // indexed register? + asm js single // 7th bit set means single register + asm mov dl,ah // complete I/O address + asm out dx,al // put index into control register + asm inc dx // data register is next to control + asm in al,dx // take old data + + write: + asm mov cl,al // preserve old data + asm lodsw // take 2 masks from table + asm xor al,0xFF // invert mask bits + asm and al,cl // clear bits with "clr" mask + asm or al,ah // set bits with "set" mask + asm cmp dl,0xC1 // special case? + asm jne std2 // no: standard job, otherwise... + asm dec dx // data out reg shares address with index + std2: + asm out dx,al // write new value to register + asm jmp s + + single: // read address in al, write address in ah + asm mov dl,al // complete I/O read address + asm in al,dx // take old data + asm mov dl,ah // complete I/O write address + asm jmp write // continue standard routine + + xit: + */ warning("STUB: VGA::Setup"); } -int VGA::SetMode(int mode) -{ -/* - Clear(); - // get current mode - asm mov ah,0x0F - Video(); // BIOS video service - asm xor ah,ah - asm push ax - - // wait for v-retrace - WaitVR(); - - // set mode - asm xor ah,ah - asm mov al,byte ptr mode - Video(); // BIOS video service - SetStatAdr(); - // return previous mode - asm pop ax - return _AX; - */ - warning("STUB: VGA::SetMode"); +int VGA::SetMode(int mode) { + /* + Clear(); + // get current mode + asm mov ah,0x0F + Video(); // BIOS video service + asm xor ah,ah + asm push ax + + // wait for v-retrace + WaitVR(); + + // set mode + asm xor ah,ah + asm mov al,byte ptr mode + Video(); // BIOS video service + SetStatAdr(); + // return previous mode + asm pop ax + return _AX; + */ + warning("STUB: VGA::SetMode"); return 0; } -void VGA::GetColors(DAC * tab) -{ -/* - asm cld - asm les di,tab // color table - asm mov dx,0x3C7 // PEL address read mode register - asm xor al,al // start from address 0 - asm out dx,al // put address - asm mov cx,256*3 // # of colors - asm mov dl,0xC9 // PEL data register - -// asm rep insb // very fast! - - gc: // much slower: - asm in al,dx // take 1 color - asm jmp sto // little delay - sto: - asm stosb // store 1 color - asm loop gc // next one? - */ +void VGA::GetColors(DAC *tab) { + /* + asm cld + asm les di,tab // color table + asm mov dx,0x3C7 // PEL address read mode register + asm xor al,al // start from address 0 + asm out dx,al // put address + asm mov cx,256*3 // # of colors + asm mov dl,0xC9 // PEL data register + + // asm rep insb // very fast! + + gc: // much slower: + asm in al,dx // take 1 color + asm jmp sto // little delay + sto: + asm stosb // store 1 color + asm loop gc // next one? + */ warning("STUB: VGA::GetColors"); } -void VGA::SetColors(DAC * tab, int lum) -{ -/* - DAC * des = NewColors; - asm push ds - - asm les di,des - asm lds si,tab - asm mov cx,256*3 - asm xor bx,bx - asm mov dx,lum - - copcol: - asm mov al,[si+bx] - asm mul dl - asm shr ax,6 - asm mov es:[di+bx],al - asm inc bx - asm cmp bx,cx - asm jb copcol - - asm pop ds - - if (Mono) - { - asm add cx,di - mono: - asm xor dx,dx - asm mov al,77 // 30% R - asm mul byte ptr es:[di].0 - asm add dx,ax - asm mov al,151 // 59% G - asm mul byte ptr es:[di].1 - asm add dx,ax - asm mov al,28 // 11% B - asm mul byte ptr es:[di].2 - asm add dx,ax - - asm mov es:[di].0,dh - asm mov es:[di].1,dh - asm mov es:[di].2,dh - - asm add di,3 - asm cmp di,cx - asm jb mono - } - */ - SetPal = true; - warning("STUB: VGA::SetColors"); +void VGA::SetColors(DAC *tab, int lum) { + /* + DAC * des = NewColors; + asm push ds + + asm les di,des + asm lds si,tab + asm mov cx,256*3 + asm xor bx,bx + asm mov dx,lum + + copcol: + asm mov al,[si+bx] + asm mul dl + asm shr ax,6 + asm mov es:[di+bx],al + asm inc bx + asm cmp bx,cx + asm jb copcol + + asm pop ds + + if (Mono) + { + asm add cx,di + mono: + asm xor dx,dx + asm mov al,77 // 30% R + asm mul byte ptr es:[di].0 + asm add dx,ax + asm mov al,151 // 59% G + asm mul byte ptr es:[di].1 + asm add dx,ax + asm mov al,28 // 11% B + asm mul byte ptr es:[di].2 + asm add dx,ax + + asm mov es:[di].0,dh + asm mov es:[di].1,dh + asm mov es:[di].2,dh + + asm add di,3 + asm cmp di,cx + asm jb mono + } + */ + SetPal = true; + warning("STUB: VGA::SetColors"); } -void VGA::SetColors (void) -{ - memset(NewColors, 0, PAL_SIZ); - UpdateColors(); +void VGA::SetColors(void) { + memset(NewColors, 0, PAL_SIZ); + UpdateColors(); } -void VGA::Sunrise (DAC * tab) -{ - int i; - for (i = 0; i <= 64; i += FADE_STEP) - { - SetColors(tab, i); - WaitVR(); - UpdateColors(); - } +void VGA::Sunrise(DAC *tab) { + for (int i = 0; i <= 64; i += FADE_STEP) { + SetColors(tab, i); + WaitVR(); + UpdateColors(); + } } -void VGA::Sunset (void) -{ - DAC tab[256]; - int i; - GetColors(tab); - for (i = 64; i >= 0; i -= FADE_STEP) - { - SetColors(tab, i); - WaitVR(); - UpdateColors(); - } +void VGA::Sunset(void) { + DAC tab[256]; + GetColors(tab); + for (int i = 64; i >= 0; i -= FADE_STEP) { + SetColors(tab, i); + WaitVR(); + UpdateColors(); + } } -void VGA::Show (void) -{ - SPRITE * spr = ShowQ.First(); +void VGA::Show(void) { + SPRITE *spr = ShowQ.First(); - for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Show(); - Update(); - for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Hide(); + for (spr = ShowQ.First(); spr; spr = spr->Next) + spr->Show(); + Update(); + for (spr = ShowQ.First(); spr; spr = spr->Next) + spr->Hide(); - ++ FrmCnt; + ++ FrmCnt; } -void VGA::UpdateColors(void) -{ -/* - DAC * tab = NewColors; +void VGA::UpdateColors(void) { + /* + DAC * tab = NewColors; - asm push ds - asm cld - asm lds si,tab // color table - asm mov dx,0x3C8 // PEL address write mode register - asm xor al,al // start from address 0 - asm out dx,al // put address - asm mov cx,256*3 // # of colors - asm mov dl,0xC9 // PEL data register + asm push ds + asm cld + asm lds si,tab // color table + asm mov dx,0x3C8 // PEL address write mode register + asm xor al,al // start from address 0 + asm out dx,al // put address + asm mov cx,256*3 // # of colors + asm mov dl,0xC9 // PEL data register -// asm rep outsb // very fast! + // asm rep outsb // very fast! - // the slower version of above: - sc: - asm lodsb // take 1/3 color - asm out dx,al // put 1/3 color - asm jmp loop // little delay - loop: - asm loop sc // next one? + // the slower version of above: + sc: + asm lodsb // take 1/3 color + asm out dx,al // put 1/3 color + asm jmp loop // little delay + loop: + asm loop sc // next one? - asm pop ds - */ - warning("STUB: VGA::UpdateColors"); + asm pop ds + */ + warning("STUB: VGA::UpdateColors"); } -void VGA::Update(void) -{ -/* - uint8 * p = Page[1]; - Page[1] = Page[0]; - Page[0] = p; - - asm mov dx,VGACRT_ - asm mov al,0x0D - asm mov ah,byte ptr p - asm out dx,ax - asm dec al - asm mov ah,byte ptr p+1 - asm out dx,ax -*/ - if (! SpeedTest) WaitVR(); +void VGA::Update(void) { + /* + uint8 * p = Page[1]; + Page[1] = Page[0]; + Page[0] = p; + + asm mov dx,VGACRT_ + asm mov al,0x0D + asm mov ah,byte ptr p + asm out dx,ax + asm dec al + asm mov ah,byte ptr p+1 + asm out dx,ax + */ + if (! SpeedTest) WaitVR(); - if (SetPal) - { - UpdateColors(); - SetPal = false; - } - warning("STUB: VGA::Update"); + if (SetPal) { + UpdateColors(); + SetPal = false; + } + warning("STUB: VGA::Update"); } -void VGA::Clear(uint8 color) -{ -/* - uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); +void VGA::Clear(uint8 color) { + /* + uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // map mask register - enable all planes - asm out dx,ax - asm les di,a - asm cld + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // map mask register - enable all planes + asm out dx,ax + asm les di,a + asm cld - asm mov cx,0xFFFF - asm mov al,color - asm rep stosb - asm stosb - */ - warning("STUB: VGA::Clear"); + asm mov cx,0xFFFF + asm mov al,color + asm rep stosb + asm stosb + */ + warning("STUB: VGA::Clear"); } -void VGA::CopyPage(uint16 d, uint16 s) -{ -/* - uint8 * S = Page[s & 3], * D = Page[d & 3]; +void VGA::CopyPage(uint16 d, uint16 s) { + /* + uint8 * S = Page[s & 3], * D = Page[d & 3]; - asm mov dx,VGAGRA_ - asm mov al,0x05 // R/W mode - asm out dx,al - asm inc dx - asm in al,dx - asm and al,0xF4 - asm push ax - asm push dx - asm or al,0x01 - asm out dx,al + asm mov dx,VGAGRA_ + asm mov al,0x05 // R/W mode + asm out dx,al + asm inc dx + asm in al,dx + asm and al,0xF4 + asm push ax + asm push dx + asm or al,0x01 + asm out dx,al - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // map mask register - enable all planes - asm out dx,ax + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // map mask register - enable all planes + asm out dx,ax - asm push ds + asm push ds - asm les di,D - asm lds si,S - asm cld - asm mov cx,0x4000 - asm rep movsb + asm les di,D + asm lds si,S + asm cld + asm mov cx,0x4000 + asm rep movsb - asm pop ds + asm pop ds - asm pop dx - asm pop ax - asm out dx,al // end of copy mode - */ - warning("STUB: VGA::CopyPage"); + asm pop dx + asm pop ax + asm out dx,al // end of copy mode + */ + warning("STUB: VGA::CopyPage"); } //-------------------------------------------------------------------------- -void BITMAP::XShow(int x, int y) -{ -/* - uint8 rmsk = x % 4, - mask = 1 << rmsk, - * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint8 * m = (char *) M; - uint8 * v = V; - - asm push bx - asm push si - asm push ds - - asm cld - asm les di,scr - asm lds si,v - asm mov bx,m - - asm mov al,0x02 // map mask register - asm mov ah,mask - - plane: - // enable output plane - asm mov dx,VGASEQ_ - asm out dx,ax - asm push ax - - // select input plane - asm mov dx,VGAGRA_ - asm mov al,0x04 // read map select register - asm mov ah,rmsk - asm out dx,ax - - asm push di - - block: - asm lodsw - asm mov cx,ax - asm and ch,0x3F - asm test ah,0xC0 - asm jz endpl - asm jns skip - asm jnp incsi // replicate? - asm add si,cx // skip over data block - asm dec si // fix it before following inc - - incsi: - asm inc si - tint: - asm mov al,es:[di] - //----------------------------------------------- - // asm xlat ss:0 // unsupported with BASM! - __emit__(0x36, 0xD7); // this stands for above! - //----------------------------------------------- - asm stosb - asm loop tint - asm jmp block - - skip: - asm add di,cx - asm jmp block - - endpl: - asm pop di - asm pop ax - asm inc rmsk - asm shl ah,1 - asm test ah,0x10 - asm jz x_chk - asm mov ah,0x01 - asm mov rmsk,0 - asm inc di - x_chk: - asm cmp ah,mask - asm jne plane - asm pop ds - asm pop si - asm pop bx - */ +void BITMAP::XShow(int x, int y) { + /* + uint8 rmsk = x % 4, + mask = 1 << rmsk, + * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint8 * m = (char *) M; + uint8 * v = V; + + asm push bx + asm push si + asm push ds + + asm cld + asm les di,scr + asm lds si,v + asm mov bx,m + + asm mov al,0x02 // map mask register + asm mov ah,mask + + plane: + // enable output plane + asm mov dx,VGASEQ_ + asm out dx,ax + asm push ax + + // select input plane + asm mov dx,VGAGRA_ + asm mov al,0x04 // read map select register + asm mov ah,rmsk + asm out dx,ax + + asm push di + + block: + asm lodsw + asm mov cx,ax + asm and ch,0x3F + asm test ah,0xC0 + asm jz endpl + asm jns skip + asm jnp incsi // replicate? + asm add si,cx // skip over data block + asm dec si // fix it before following inc + + incsi: + asm inc si + tint: + asm mov al,es:[di] + //----------------------------------------------- + // asm xlat ss:0 // unsupported with BASM! + __emit__(0x36, 0xD7); // this stands for above! + //----------------------------------------------- + asm stosb + asm loop tint + asm jmp block + + skip: + asm add di,cx + asm jmp block + + endpl: + asm pop di + asm pop ax + asm inc rmsk + asm shl ah,1 + asm test ah,0x10 + asm jz x_chk + asm mov ah,0x01 + asm mov rmsk,0 + asm inc di + x_chk: + asm cmp ah,mask + asm jne plane + asm pop ds + asm pop si + asm pop bx + */ warning("STUB: BITMAP::XShow"); } -void BITMAP::Show(int x, int y) -{ +void BITMAP::Show(int x, int y) { /* - uint8 mask = 1 << (x & 3), - * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - uint8 * v = V; - - asm push ds // preserve DS - - asm cld // normal direction - asm les di,scr // screen address - asm lds si,v // picture address - asm mov dx,VGASEQ_ // VGA reg - asm mov al,0x02 - asm mov ah,mask - - plane: - asm out dx,ax - asm push ax - asm push di - - block: - asm mov cx,[si] // with ADD faster then LODSW - asm add si,2 - asm test ch,0xC0 - asm jns skip // 1 (SKP) or 0 (EOI) - asm jpo repeat // 2 (REP) - - copy: // 3 (CPY) - asm and ch,0x3F - asm shr cx,1 - asm rep movsw - asm jnc block - asm movsb - asm jmp block - - repeat: - asm and ch,0x3F - asm mov al,[si] - asm inc si - asm mov ah,al - asm shr cx,1 - asm rep stosw - asm jnc block - asm mov es:[di],al - asm inc di - asm jmp block - - skip: - asm jz endpl - asm and ch,0x3F - asm add di,cx - asm jmp block - - endpl: - asm pop di - asm pop ax - asm shl ah,1 - asm test ah,0x10 - asm jz x_chk - asm mov ah,0x01 - asm inc di - x_chk: - asm cmp ah,mask - asm jne plane - asm pop ds + uint8 mask = 1 << (x & 3), + * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); + uint8 * v = V; + + asm push ds // preserve DS + + asm cld // normal direction + asm les di,scr // screen address + asm lds si,v // picture address + asm mov dx,VGASEQ_ // VGA reg + asm mov al,0x02 + asm mov ah,mask + + plane: + asm out dx,ax + asm push ax + asm push di + + block: + asm mov cx,[si] // with ADD faster then LODSW + asm add si,2 + asm test ch,0xC0 + asm jns skip // 1 (SKP) or 0 (EOI) + asm jpo repeat // 2 (REP) + + copy: // 3 (CPY) + asm and ch,0x3F + asm shr cx,1 + asm rep movsw + asm jnc block + asm movsb + asm jmp block + + repeat: + asm and ch,0x3F + asm mov al,[si] + asm inc si + asm mov ah,al + asm shr cx,1 + asm rep stosw + asm jnc block + asm mov es:[di],al + asm inc di + asm jmp block + + skip: + asm jz endpl + asm and ch,0x3F + asm add di,cx + asm jmp block + + endpl: + asm pop di + asm pop ax + asm shl ah,1 + asm test ah,0x10 + asm jz x_chk + asm mov ah,0x01 + asm inc di + x_chk: + asm cmp ah,mask + asm jne plane + asm pop ds */ warning("STUB: BITMAP::Show"); } -void BITMAP::Hide(int x, int y) -{ -/* - uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); - HideDesc * b = B; - uint16 extra = ((x & 3) != 0); - uint16 h = H; - -// asm push bx - asm push si - asm push ds - - asm cld - asm les di,scr - asm mov si,di - asm add si,d // take bytes from background page - asm lds bx,b - - asm mov dx,VGAGRA_ - asm mov al,0x05 // R/W mode - asm out dx,al - asm inc dx - asm in al,dx - asm and al,0xF4 - asm push ax - asm push dx - asm or al,0x01 - asm out dx,al - - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // enable all planes - asm out dx,ax - - asm mov dx,ds // save DS - - row: -// skip block - asm mov cx,[bx] - asm add si,cx - asm add di,cx - asm mov cx,[bx+2] - asm add bx,4 - asm add cx,extra - - asm push es - asm pop ds // set DS to video seg - asm rep movsb // move bytes fast - asm sub si,extra - asm sub di,extra - asm mov ds,dx // restore DS - - asm dec h - asm jnz row - - asm pop dx - asm pop ax - asm out dx,al // end of copy mode - - - asm pop ds - asm pop si -// asm pop bx -*/ +void BITMAP::Hide(int x, int y) { + /* + uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); + HideDesc * b = B; + uint16 extra = ((x & 3) != 0); + uint16 h = H; + + // asm push bx + asm push si + asm push ds + + asm cld + asm les di,scr + asm mov si,di + asm add si,d // take bytes from background page + asm lds bx,b + + asm mov dx,VGAGRA_ + asm mov al,0x05 // R/W mode + asm out dx,al + asm inc dx + asm in al,dx + asm and al,0xF4 + asm push ax + asm push dx + asm or al,0x01 + asm out dx,al + + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // enable all planes + asm out dx,ax + + asm mov dx,ds // save DS + + row: + // skip block + asm mov cx,[bx] + asm add si,cx + asm add di,cx + asm mov cx,[bx+2] + asm add bx,4 + asm add cx,extra + + asm push es + asm pop ds // set DS to video seg + asm rep movsb // move bytes fast + asm sub si,extra + asm sub di,extra + asm mov ds,dx // restore DS + + asm dec h + asm jnz row + + asm pop dx + asm pop ax + asm out dx,al // end of copy mode + + + asm pop ds + asm pop si + // asm pop bx + */ warning("STUB: BITMAP::Hide"); } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index f1a4b498c4..810e781808 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -25,295 +25,290 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __VGA13H__ -#define __VGA13H__ +#ifndef __VGA13H__ +#define __VGA13H__ -#include "cge/general.h" -#include -//#include -#include "cge/bitmap.h" -#include "cge/snail.h" +#include "cge/general.h" +#include +#include "cge/bitmap.h" +#include "cge/snail.h" namespace CGE { -#define TMR_RATE1 16 -#define TMR_RATE2 4 -#define TMR_RATE (TMR_RATE1*TMR_RATE2) +#define TMR_RATE1 16 +#define TMR_RATE2 4 +#define TMR_RATE (TMR_RATE1 * TMR_RATE2) -#define MAX_NAME 20 -#define VIDEO 0x10 +#define MAX_NAME 20 +#define VIDEO 0x10 -#define NO_CLEAR 0x80 -#define TEXT_MODE 0x03 -#define M13H 0x13 +#define NO_CLEAR 0x80 +#define TEXT_MODE 0x03 +#define M13H 0x13 -#ifndef SCR_WID - #define SCR_WID 320 +#ifndef SCR_WID +#define SCR_WID 320 #endif -#ifndef SCR_HIG - #define SCR_HIG 200 +#ifndef SCR_HIG +#define SCR_HIG 200 #endif #if 0 - #define LIGHT 0xFF - #define DARK 0x00 - #define DGRAY 0xF6 - #define GRAY 0xFC - #define LGRAY 0xFF +#define LIGHT 0xFF +#define DARK 0x00 +#define DGRAY 0xF6 +#define GRAY 0xFC +#define LGRAY 0xFF #else - #define LIGHT 0xFF - #define DARK 207 - #define DGRAY 225 /*219*/ - #define GRAY 231 - #define LGRAY 237 +#define LIGHT 0xFF +#define DARK 207 +#define DGRAY 225 /*219*/ +#define GRAY 231 +#define LGRAY 237 #endif -#define NO_SEQ (-1) -#define NO_PTR ((uint8)-1) - -#define SPR_EXT ".SPR" - -#define IsFile(s) (access(s,0)==0) -#define IsWrit(s) (access(s,2)==0) - - - -typedef struct { uint16 r : 2; uint16 R : 6; - uint16 g : 2; uint16 G : 6; - uint16 b : 2; uint16 B : 6; - } RGB; - -typedef union { - DAC dac; - RGB rgb; - } TRGB; - -typedef struct { uint8 idx, adr; uint8 clr, set; } VgaRegBlk; - -typedef struct { uint8 Now, Next; signed char Dx, Dy; int Dly; } SEQ; - -extern SEQ Seq1[]; -extern SEQ Seq2[]; -//extern SEQ * Compass[]; -//extern SEQ TurnToS[]; - - -#define PAL_CNT 256 -#define PAL_SIZ (PAL_CNT*sizeof(DAC)) - -#define VGAATR_ 0x3C0 -#define VGAMIw_ 0x3C0 -#define VGASEQ_ 0x3C4 -#define VGAMIr_ 0x3CC -#define VGAGRA_ 0x3CE -#define VGACRT_ 0x3D4 -#define VGAST1_ 0x3DA -#define VGAATR (VGAATR_ & 0xFF) -#define VGAMIw (VGAMIw_ & 0xFF) -#define VGASEQ (VGASEQ_ & 0xFF) -#define VGAMIr (VGAMIr_ & 0xFF) -#define VGAGRA (VGAGRA_ & 0xFF) -#define VGACRT (VGACRT_ & 0xFF) -#define VGAST1 (VGAST1_ & 0xFF) - - - - - - -class HEART : public ENGINE -{ - friend ENGINE; +#define NO_SEQ (-1) +#define NO_PTR ((uint8)-1) + +#define SPR_EXT ".SPR" + +#define IsFile(s) (access(s, 0) == 0) +#define IsWrit(s) (access(s, 2) == 0) + + + +typedef struct { + uint16 r : 2; + uint16 R : 6; + uint16 g : 2; + uint16 G : 6; + uint16 b : 2; + uint16 B : 6; +} RGB; + +typedef union { + DAC dac; + RGB rgb; +} TRGB; + +typedef struct { + uint8 idx, adr; + uint8 clr, set; +} VgaRegBlk; + +typedef struct { + uint8 Now, Next; + signed char Dx, Dy; + int Dly; +} SEQ; + +extern SEQ Seq1[]; +extern SEQ Seq2[]; +//extern SEQ * Compass[]; +//extern SEQ TurnToS[]; + + +#define PAL_CNT 256 +#define PAL_SIZ (PAL_CNT * sizeof(DAC)) +#define VGAATR_ 0x3C0 +#define VGAMIw_ 0x3C0 +#define VGASEQ_ 0x3C4 +#define VGAMIr_ 0x3CC +#define VGAGRA_ 0x3CE +#define VGACRT_ 0x3D4 +#define VGAST1_ 0x3DA +#define VGAATR (VGAATR_ & 0xFF) +#define VGAMIw (VGAMIw_ & 0xFF) +#define VGASEQ (VGASEQ_ & 0xFF) +#define VGAMIr (VGAMIr_ & 0xFF) +#define VGAGRA (VGAGRA_ & 0xFF) +#define VGACRT (VGACRT_ & 0xFF) +#define VGAST1 (VGAST1_ & 0xFF) + + +class HEART : public ENGINE { + friend ENGINE; public: - static bool Enable; - static uint16 * XTimer; - static void SetXTimer (uint16 * ptr); - static void SetXTimer (uint16 * ptr, uint16 time); - HEART (void); + static bool Enable; + static uint16 *XTimer; + static void SetXTimer(uint16 *ptr); + static void SetXTimer(uint16 *ptr, uint16 time); + HEART(void); }; - - - -class SPREXT -{ +class SPREXT { public: - int x0, y0; - int x1, y1; - BMP_PTR b0, b1; - BMP_PTR * ShpList; - SEQ * Seq; - char * Name; - SNAIL::COM * Near, * Take; - SPREXT (void) : - x0(0), y0(0), - x1(0), y1(0), - b0(NULL), b1(NULL), - ShpList(NULL), Seq(NULL), - Name(NULL), Near(NULL), Take(NULL) - {} + int x0, y0; + int x1, y1; + BMP_PTR b0, b1; + BMP_PTR *ShpList; + SEQ *Seq; + char *Name; + SNAIL::COM *Near, * Take; + SPREXT(void) : + x0(0), y0(0), + x1(0), y1(0), + b0(NULL), b1(NULL), + ShpList(NULL), Seq(NULL), + Name(NULL), Near(NULL), Take(NULL) + {} }; - - -class SPRITE -{ +class SPRITE { protected: - SPREXT * Ext; + SPREXT *Ext; public: - int Ref; - signed char Cave; - struct FLAGS { uint16 Hide : 1; // general visibility switch - uint16 Near : 1; // Near action lock - uint16 Drag : 1; // sprite is moveable - uint16 Hold : 1; // sprite is held with mouse - uint16 ____ : 1; // intrrupt driven animation - uint16 Slav : 1; // slave object - uint16 Syst : 1; // system object - uint16 Kill : 1; // dispose memory after remove - uint16 Xlat : 1; // 2nd way display: xlat table - uint16 Port : 1; // portable - uint16 Kept : 1; // kept in pocket - uint16 East : 1; // talk to east (in opposite to west) - uint16 Shad : 1; // shadow - uint16 Back : 1; // 'send to background' request - uint16 BDel : 1; // delete bitmaps in ~SPRITE - uint16 Tran : 1; // transparent (untouchable) - } Flags; - int X, Y; - signed char Z; - uint16 W, H; - uint16 Time; - uint8 NearPtr, TakePtr; - int SeqPtr; - int ShpCnt; - char File[MAXFILE]; - SPRITE * Prev, * Next; - bool Works (SPRITE * spr); - bool SeqTest (int n); - inline bool Active (void) { return Ext != NULL; } - SPRITE (BMP_PTR * shp); - virtual ~SPRITE (void); - BMP_PTR Shp (void); - BMP_PTR * SetShapeList (BMP_PTR * shp); - void MoveShapes (uint8 * buf); - SPRITE * Expand (void); - SPRITE * Contract (void); - SPRITE * BackShow (bool fast = false); - void SetName(char * n); - inline char * Name(void) { return (Ext) ? Ext->Name : NULL; } - void Goto (int x, int y); - void Center (void); - void Show (void); - void Hide (void); - BMP_PTR Ghost (void); - void Show (uint16 pg); - void MakeXlat (uint8 * x); - void KillXlat (void); - void Step (int nr = -1); - SEQ * SetSeq (SEQ * seq); - SNAIL::COM * SnList(SNLIST type); - virtual void Touch (uint16 mask, int x, int y); - virtual void Tick (void); + int Ref; + signed char Cave; + struct FLAGS { + uint16 Hide : 1; // general visibility switch + uint16 Near : 1; // Near action lock + uint16 Drag : 1; // sprite is moveable + uint16 Hold : 1; // sprite is held with mouse + uint16 ____ : 1; // intrrupt driven animation + uint16 Slav : 1; // slave object + uint16 Syst : 1; // system object + uint16 Kill : 1; // dispose memory after remove + uint16 Xlat : 1; // 2nd way display: xlat table + uint16 Port : 1; // portable + uint16 Kept : 1; // kept in pocket + uint16 East : 1; // talk to east (in opposite to west) + uint16 Shad : 1; // shadow + uint16 Back : 1; // 'send to background' request + uint16 BDel : 1; // delete bitmaps in ~SPRITE + uint16 Tran : 1; // transparent (untouchable) + } Flags; + int X, Y; + signed char Z; + uint16 W, H; + uint16 Time; + uint8 NearPtr, TakePtr; + int SeqPtr; + int ShpCnt; + char File[MAXFILE]; + SPRITE *Prev, * Next; + bool Works(SPRITE *spr); + bool SeqTest(int n); + inline bool Active(void) { + return Ext != NULL; + } + SPRITE(BMP_PTR *shp); + virtual ~SPRITE(void); + BMP_PTR Shp(void); + BMP_PTR *SetShapeList(BMP_PTR *shp); + void MoveShapes(uint8 *buf); + SPRITE *Expand(void); + SPRITE *Contract(void); + SPRITE *BackShow(bool fast = false); + void SetName(char *n); + inline char *Name(void) { + return (Ext) ? Ext->Name : NULL; + } + void Goto(int x, int y); + void Center(void); + void Show(void); + void Hide(void); + BMP_PTR Ghost(void); + void Show(uint16 pg); + void MakeXlat(uint8 *x); + void KillXlat(void); + void Step(int nr = -1); + SEQ *SetSeq(SEQ *seq); + SNAIL::COM *SnList(SNLIST type); + virtual void Touch(uint16 mask, int x, int y); + virtual void Tick(void); }; - - - - -class QUEUE -{ - SPRITE * Head, * Tail; +class QUEUE { + SPRITE *Head, * Tail; public: - bool Show; - QUEUE (bool show = false); - ~QUEUE (void); - void Append (SPRITE * spr); - void Insert (SPRITE * spr, SPRITE * nxt); - void Insert (SPRITE * spr); - SPRITE * Remove (SPRITE * spr); - void ForAll (void (*fun)(SPRITE *)); - SPRITE * First (void) { return Head; } - SPRITE * Last (void) { return Tail; } - SPRITE * Locate (int ref); - void Clear (void); + bool Show; + QUEUE(bool show = false); + ~QUEUE(void); + void Append(SPRITE *spr); + void Insert(SPRITE *spr, SPRITE *nxt); + void Insert(SPRITE *spr); + SPRITE *Remove(SPRITE *spr); + void ForAll(void (*fun)(SPRITE *)); + SPRITE *First(void) { + return Head; + } + SPRITE *Last(void) { + return Tail; + } + SPRITE *Locate(int ref); + void Clear(void); }; - - - - -class VGA -{ - static uint16 OldMode; - static uint16 * OldScreen; - static uint16 StatAdr; - static bool SetPal; - static DAC * OldColors, * NewColors; - static int SetMode (int mode); - static void UpdateColors (void); - static void SetColors (void); - static const char * Msg; - static const char * Nam; - static void SetStatAdr (void); - static void WaitVR (bool on = true); +class VGA { + static uint16 OldMode; + static uint16 *OldScreen; + static uint16 StatAdr; + static bool SetPal; + static DAC *OldColors, * NewColors; + static int SetMode(int mode); + static void UpdateColors(void); + static void SetColors(void); + static const char *Msg; + static const char *Nam; + static void SetStatAdr(void); + static void WaitVR(bool on = true); public: - uint32 FrmCnt; - static QUEUE ShowQ, SpareQ; - static int Mono; - static uint8 * Page[4]; - VGA (int mode = M13H); - ~VGA (void); - void Setup (VgaRegBlk * vrb); - static void GetColors (DAC * tab); - static void SetColors (DAC * tab, int lum); - static void Clear (uint8 color = 0); - static void CopyPage (uint16 d, uint16 s = 3); - static void Sunrise (DAC * tab); - static void Sunset (void); - void Show (void); - void Update (void); + uint32 FrmCnt; + static QUEUE ShowQ, SpareQ; + static int Mono; + static uint8 *Page[4]; + VGA(int mode = M13H); + ~VGA(void); + void Setup(VgaRegBlk *vrb); + static void GetColors(DAC *tab); + static void SetColors(DAC *tab, int lum); + static void Clear(uint8 color = 0); + static void CopyPage(uint16 d, uint16 s = 3); + static void Sunrise(DAC *tab); + static void Sunset(void); + void Show(void); + void Update(void); }; - -DAC MkDAC (uint8 r, uint8 g, uint8 b); -RGB MkRGB (uint8 r, uint8 g, uint8 b); - - +DAC MkDAC(uint8 r, uint8 g, uint8 b); +RGB MkRGB(uint8 r, uint8 g, uint8 b); template -uint8 Closest (CBLK * pal, CBLK x) -{ - #define f(col,lum) ((((uint16)(col))<<8)/lum) - uint16 i, dif = 0xFFFF, found = 0; - uint16 L = x.R + x.G + x.B; if (! L) ++ L; - uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); - for (i = 0; i < 256; i ++) - { - uint16 l = pal[i].R + pal[i].G + pal[i].B; if (! l) ++ l; - int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l); - uint16 D = ((r > R) ? (r - R) : (R - r)) + - ((g > G) ? (g - G) : (G - g)) + - ((b > B) ? (b - B) : (B - b)) + - ((l > L) ? (l - L) : (L - l)) * 10 ; - - if (D < dif) - { - found = i; - dif = D; - if (D == 0) break; // exact! +uint8 Closest(CBLK *pal, CBLK x) { +#define f(col, lum) ((((uint16)(col)) << 8) / lum) + uint16 i, dif = 0xFFFF, found = 0; + uint16 L = x.R + x.G + x.B; + if (!L) + ++L; + uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); + for (i = 0; i < 256; i ++) { + uint16 l = pal[i].R + pal[i].G + pal[i].B; + if (! l) + ++l; + int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l); + uint16 D = ((r > R) ? (r - R) : (R - r)) + + ((g > G) ? (g - G) : (G - g)) + + ((b > B) ? (b - B) : (B - b)) + + ((l > L) ? (l - L) : (L - l)) * 10 ; + + if (D < dif) { + found = i; + dif = D; + if (D == 0) + break; // exact! + } } - } - return found; - #undef f + return found; +#undef f }; @@ -322,14 +317,14 @@ uint8 Closest (CBLK * pal, CBLK x) - char * NumStr (char * str, int num); - //static void Video (void); - uint16 * SaveScreen (void); - void RestoreScreen (uint16 * &sav); - SPRITE * SpriteAt (int x, int y); - SPRITE * Locate (int ref); +char *NumStr(char *str, int num); +//static void Video (void); +uint16 *SaveScreen(void); +void RestoreScreen(uint16 * &sav); +SPRITE *SpriteAt(int x, int y); +SPRITE *Locate(int ref); -extern bool SpeedTest; +extern bool SpeedTest; } // End if namespace CGE diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 46bb45e9c9..a8da163b33 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -25,151 +25,131 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/vmenu.h" -#include "cge/mouse.h" -#include -//#include +#include "cge/vmenu.h" +#include "cge/mouse.h" +#include namespace CGE { -//-------------------------------------------------------------------------- -#define RELIEF 1 -#if RELIEF - #define MB_LT LGRAY - #define MB_RB DGRAY +#define RELIEF 1 +#if RELIEF +#define MB_LT LGRAY +#define MB_RB DGRAY #else - #define MB_LT DGRAY - #define MB_RB LGRAY +#define MB_LT DGRAY +#define MB_RB LGRAY #endif -MENU_BAR::MENU_BAR (uint16 w) -{ - int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; - uint8 * p = farnew(uint8, i), * p1, * p2; - - memset(p+w, TRANS, i-2*w); - memset(p, MB_LT, w); - memset(p+i-w, MB_RB, w); - p1 = p; - p2 = p+i-1; - for (i = 0; i < h; i ++) - { - * p1 = MB_LT; - * p2 = MB_RB; - p1 += w; - p2 -= w; - } - TS[0] = new BITMAP(w, h, p); - SetShapeList(TS); - Flags.Slav = true; - Flags.Tran = true; - Flags.Kill = true; - Flags.BDel = true; -} - - - -//-------------------------------------------------------------------------- - -static char * vmgt; +MENU_BAR::MENU_BAR(uint16 w) { + int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; + uint8 *p = farnew(uint8, i), * p1, * p2; - - -char * VMGather (CHOICE * list) -{ - CHOICE * cp; - int len = 0, h = 0; - - for (cp = list; cp->Text; cp ++) - { - len += strlen(cp->Text); - ++ h; - } - vmgt = new char[len+h]; - if (vmgt) - { - *vmgt = '\0'; - for (cp = list; cp->Text; cp ++) - { - if (*vmgt) strcat(vmgt, "|"); - strcat(vmgt, cp->Text); - ++ h; + memset(p + w, TRANS, i - 2 * w); + memset(p, MB_LT, w); + memset(p + i - w, MB_RB, w); + p1 = p; + p2 = p + i - 1; + for (i = 0; i < h; i ++) { + *p1 = MB_LT; + *p2 = MB_RB; + p1 += w; + p2 -= w; } - } - return vmgt; + TS[0] = new BITMAP(w, h, p); + SetShapeList(TS); + Flags.Slav = true; + Flags.Tran = true; + Flags.Kill = true; + Flags.BDel = true; } +static char *vmgt; -VMENU * VMENU::Addr = NULL; -int VMENU::Recent = -1; - +char *VMGather(CHOICE *list) { + CHOICE *cp; + int len = 0, h = 0; - - -VMENU::VMENU (CHOICE * list, int x, int y) -: TALK(VMGather(list), RECT), Menu(list), Bar(NULL) -{ - CHOICE * cp; - - Addr = this; - delete[] vmgt; - Items = 0; - for (cp = list; cp->Text; cp ++) ++ Items; - Flags.BDel = true; - Flags.Kill = true; - if (x < 0 || y < 0) Center(); - else Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); - VGA::ShowQ.Insert(this, VGA::ShowQ.Last()); - Bar = new MENU_BAR(W - 2 * TEXT_HM); - Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM); - VGA::ShowQ.Insert(Bar, VGA::ShowQ.Last()); + for (cp = list; cp->Text; cp ++) { + len += strlen(cp->Text); + ++h; + } + vmgt = new char[len + h]; + if (vmgt) { + *vmgt = '\0'; + for (cp = list; cp->Text; cp ++) { + if (*vmgt) + strcat(vmgt, "|"); + strcat(vmgt, cp->Text); + ++ h; + } + } + return vmgt; } - - -VMENU::~VMENU (void) -{ - Addr = NULL; +VMENU *VMENU::Addr = NULL; +int VMENU::Recent = -1; + + +VMENU::VMENU(CHOICE *list, int x, int y) + : TALK(VMGather(list), RECT), Menu(list), Bar(NULL) { + CHOICE *cp; + + Addr = this; + delete[] vmgt; + Items = 0; + for (cp = list; cp->Text; cp ++) + ++Items; + Flags.BDel = true; + Flags.Kill = true; + if (x < 0 || y < 0) + Center(); + else + Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); + VGA::ShowQ.Insert(this, VGA::ShowQ.Last()); + Bar = new MENU_BAR(W - 2 * TEXT_HM); + Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM); + VGA::ShowQ.Insert(Bar, VGA::ShowQ.Last()); } +VMENU::~VMENU(void) { + Addr = NULL; +} -void VMENU::Touch (uint16 mask, int x, int y) -{ -#define h (FONT_HIG+TEXT_LS) - int n = 0; - bool ok = false; +void VMENU::Touch(uint16 mask, int x, int y) { +#define h (FONT_HIG + TEXT_LS) + int n = 0; + bool ok = false; - if (Items) - { - SPRITE::Touch(mask, x, y); + if (Items) { + SPRITE::Touch(mask, x, y); - y -= TEXT_VM-1; - //if - if (y >= 0) - { - n = y / h; - if (n < Items) ok = (x >= TEXT_HM && x < W - TEXT_HM/* && y % h < FONT_HIG*/); - else n = Items-1; - } + y -= TEXT_VM - 1; + //if + if (y >= 0) { + n = y / h; + if (n < Items) + ok = (x >= TEXT_HM && x < W - TEXT_HM/* && y % h < FONT_HIG*/); + else + n = Items - 1; + } - Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM + n * h - MB_VM); + Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM + n * h - MB_VM); - if (ok && (mask & L_UP)) - { - Items = 0; - SNPOST_(SNKILL, -1, 0, this); - Menu[Recent = n].Proc(); + if (ok && (mask & L_UP)) { + Items = 0; + SNPOST_(SNKILL, -1, 0, this); + Menu[Recent = n].Proc(); + } } - } #undef h } diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index cdbabf9966..ecec9d51b5 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -25,38 +25,39 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __VMENU__ -#define __VMENU__ +#ifndef __VMENU__ +#define __VMENU__ -#include "cge/talk.h" +#include "cge/talk.h" namespace CGE { -#define MB_VM 1 -#define MB_HM 3 +#define MB_VM 1 +#define MB_HM 3 -typedef struct { char * Text; void (* Proc)(void); } CHOICE; +typedef struct { + char *Text; + void (* Proc)(void); +} CHOICE; -class MENU_BAR : public TALK -{ +class MENU_BAR : public TALK { public: - MENU_BAR (uint16 w); + MENU_BAR(uint16 w); }; -class VMENU : public TALK -{ - uint16 Items; - CHOICE * Menu; +class VMENU : public TALK { + uint16 Items; + CHOICE *Menu; public: - static VMENU * Addr; - static int Recent; - MENU_BAR * Bar; - VMENU (CHOICE * list, int x, int y); - ~VMENU (void); - void Touch (uint16 mask, int x, int y); + static VMENU *Addr; + static int Recent; + MENU_BAR *Bar; + VMENU(CHOICE *list, int x, int y); + ~VMENU(void); + void Touch(uint16 mask, int x, int y); }; } // End of namespace CGE diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 4f39cd6186..46282d2bbe 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -35,68 +35,55 @@ namespace CGE { #ifdef VOL_UPD -BTFILE VFILE::Cat(CAT_NAME, UPD, CRP); -VOLBASE DAT::File(DAT_NAME, UPD, CRP); +BTFILE VFILE::Cat(CAT_NAME, UPD, CRP); +VOLBASE DAT::File(DAT_NAME, UPD, CRP); #else -BTFILE VFILE::Cat(CAT_NAME, REA, CRP); -VOLBASE DAT::File(DAT_NAME, REA, CRP); +BTFILE VFILE::Cat(CAT_NAME, REA, CRP); +VOLBASE DAT::File(DAT_NAME, REA, CRP); +#endif +DAT VFILE::Dat; +VFILE *VFILE::Recent = NULL; + + +VFILE::VFILE(const char *name, IOMODE mode) + : IOBUF(mode) { + if (mode == REA) { + if (Dat.File.Error || Cat.Error) + error("Bad volume data"); + BT_KEYPACK *kp = Cat.Find(name); + if (scumm_stricmp(kp->Key, name) != 0) + Error = 1; + EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; + } +#ifdef VOL_UPD + else + Make(name); #endif -DAT VFILE::Dat; -VFILE * VFILE::Recent = NULL; - - - - - -VFILE::VFILE (const char * name, IOMODE mode) -: IOBUF(mode) -{ - if (mode == REA) - { - if (Dat.File.Error || Cat.Error) - error("Bad volume data"); - BT_KEYPACK * kp = Cat.Find(name); - if (scumm_stricmp(kp->Key, name) != 0) Error = 1; - EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; - } - #ifdef VOL_UPD - else Make(name); - #endif } - - - -VFILE::~VFILE (void) -{ - if (Recent == this) Recent = NULL; +VFILE::~VFILE(void) { + if (Recent == this) + Recent = NULL; } - - - -bool VFILE::Exist (const char * name) -{ - return scumm_stricmp(Cat.Find(name)->Key, name) == 0; +bool VFILE::Exist(const char *name) { + return scumm_stricmp(Cat.Find(name)->Key, name) == 0; } - - -void VFILE::ReadBuff (void) -{ - if (Recent != this) - { - Dat.File.Seek(BufMark + Lim); - Recent = this; - } - BufMark = Dat.File.Mark(); - long n = EndMark - BufMark; - if (n > IOBUF_SIZE) n = IOBUF_SIZE; - Lim = Dat.File.Read(Buff, (uint16) n); - Ptr = 0; +void VFILE::ReadBuff(void) { + if (Recent != this) { + Dat.File.Seek(BufMark + Lim); + Recent = this; + } + BufMark = Dat.File.Mark(); + long n = EndMark - BufMark; + if (n > IOBUF_SIZE) + n = IOBUF_SIZE; + Lim = Dat.File.Read(Buff, (uint16) n); + Ptr = 0; } } // End of namespace CGE diff --git a/engines/cge/vol.h b/engines/cge/vol.h index 421bd7593c..ea82e8bf6a 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -25,66 +25,64 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __VOL__ -#define __VOL__ +#ifndef __VOL__ +#define __VOL__ - -//#include -#include "cge/btfile.h" -#include "cge/cfile.h" +#include "cge/btfile.h" +#include "cge/cfile.h" namespace CGE { -#define CAT_NAME "VOL.CAT" -#define DAT_NAME "VOL.DAT" +#define CAT_NAME "VOL.CAT" +#define DAT_NAME "VOL.DAT" -#ifndef CRP - #define CRP XCrypt +#ifndef CRP +#define CRP XCrypt #endif -#define XMASK 0xA5 +#define XMASK 0xA5 -#ifdef VOL_UPD -#define VOLBASE IOHAND +#ifdef VOL_UPD +#define VOLBASE IOHAND #else -#define VOLBASE CFILE +#define VOLBASE CFILE #endif - -class DAT -{ - friend class VFILE; - static VOLBASE File; +class DAT { + friend class VFILE; + static VOLBASE File; public: - static bool Append (uint8 * buf, uint16 len); - static bool Write (CFILE& f); - static bool Read (long org, uint16 len, uint8 * buf); + static bool Append(uint8 *buf, uint16 len); + static bool Write(CFILE &f); + static bool Read(long org, uint16 len, uint8 *buf); }; - - - - - -class VFILE : public IOBUF -{ - static DAT Dat; - static BTFILE Cat; - static VFILE * Recent; - long BegMark, EndMark; - void ReadBuff (void); - void WriteBuff (void) { } - void Make(const char * fspec); +class VFILE : public IOBUF { + static DAT Dat; + static BTFILE Cat; + static VFILE *Recent; + long BegMark, EndMark; + void ReadBuff(void); + void WriteBuff(void) { } + void Make(const char *fspec); public: - VFILE (const char * name, IOMODE mode = REA); - ~VFILE (void); - static bool Exist (const char * name); - static const char * Next (void); - long Mark (void) { return (BufMark+Ptr) - BegMark; } - long Size (void) { return EndMark - BegMark; } - long Seek (long pos) { Recent = NULL; Lim = 0; return (BufMark = BegMark+pos); } + VFILE(const char *name, IOMODE mode = REA); + ~VFILE(void); + static bool Exist(const char *name); + static const char *Next(void); + long Mark(void) { + return (BufMark + Ptr) - BegMark; + } + long Size(void) { + return EndMark - BegMark; + } + long Seek(long pos) { + Recent = NULL; + Lim = 0; + return (BufMark = BegMark + pos); + } }; diff --git a/engines/cge/wav.h b/engines/cge/wav.h index a8da4f9e72..6d46769cf9 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -25,117 +25,128 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __WAV__ -#define __WAV__ +#ifndef __WAV__ +#define __WAV__ -#include "cge/general.h" -#include +#include "cge/general.h" +#include namespace CGE { -#define WAVE_FORMAT_PCM 0x0001 -#define IBM_FORMAT_MULAW 0x0101 -#define IBM_FORMAT_ALAW 0x0102 -#define IBM_FORMAT_ADPCM 0x0103 +#define WAVE_FORMAT_PCM 0x0001 +#define IBM_FORMAT_MULAW 0x0101 +#define IBM_FORMAT_ALAW 0x0102 +#define IBM_FORMAT_ADPCM 0x0103 +typedef char FOURCC[4]; // Four-character code +typedef uint32 CKSIZE; // 32-bit unsigned size -typedef char FOURCC[4]; // Four-character code -typedef uint32 CKSIZE; // 32-bit unsigned size - -class CKID // Chunk type identifier -{ - union { FOURCC Tx; uint32 Id; }; +class CKID { // Chunk type identifier + union { + FOURCC Tx; + uint32 Id; + }; protected: - static XFILE * ckFile; + static XFILE *ckFile; public: - CKID (FOURCC t) { memcpy(Tx, t, sizeof(Tx)); } - CKID (uint32 d) { Id = d; } - CKID (XFILE * xf) { (ckFile = xf)->Read(Tx, sizeof(Tx)); } - bool operator !=(CKID& X) { return Id != X.Id; } - bool operator ==(CKID& X) { return Id == X.Id; } - const char * Name (void); + CKID(FOURCC t) { + memcpy(Tx, t, sizeof(Tx)); + } + CKID(uint32 d) { + Id = d; + } + CKID(XFILE *xf) { + (ckFile = xf)->Read(Tx, sizeof(Tx)); + } + bool operator !=(CKID &X) { + return Id != X.Id; + } + bool operator ==(CKID &X) { + return Id == X.Id; + } + const char *Name(void); }; - - -class CKHEA : public CKID -{ +class CKHEA : public CKID { protected: - CKSIZE ckSize; // Chunk size field (size of ckData) + CKSIZE ckSize; // Chunk size field (size of ckData) public: - CKHEA (XFILE * xf) : CKID(xf) { XRead(xf, &ckSize); } - CKHEA (char id[]) : CKID(id), ckSize(0) { } - void Skip (void); - CKSIZE Size (void) { return ckSize; } + CKHEA(XFILE *xf) : CKID(xf) { + XRead(xf, &ckSize); + } + CKHEA(char id[]) : CKID(id), ckSize(0) { } + void Skip(void); + CKSIZE Size(void) { + return ckSize; + } }; - - - -class FMTCK : public CKHEA -{ - struct WAV - { - uint16 wFormatTag; // Format category - uint16 wChannels; // Number of channels - uint32 dwSamplesPerSec; // Sampling rate - uint32 dwAvgBytesPerSec; // For buffer estimation - uint16 wBlockAlign; // Data block size - } Wav; - - union - { - struct PCM - { - uint16 wBitsPerSample; // Sample size - } Pcm; - }; +class FMTCK : public CKHEA { + struct WAV { + uint16 wFormatTag; // Format category + uint16 wChannels; // Number of channels + uint32 dwSamplesPerSec; // Sampling rate + uint32 dwAvgBytesPerSec; // For buffer estimation + uint16 wBlockAlign; // Data block size + } Wav; + + union { + struct PCM { + uint16 wBitsPerSample; // Sample size + } Pcm; + }; public: - FMTCK (CKHEA& hea); - inline uint16 Channels (void) { return Wav.wChannels; } - inline uint32 SmplRate (void) { return Wav.dwSamplesPerSec; } - inline uint32 ByteRate (void) { return Wav.dwAvgBytesPerSec; } - inline uint16 BlckSize (void) { return Wav.wBlockAlign; } - inline uint16 SmplSize (void) { return Pcm.wBitsPerSample; } + FMTCK(CKHEA &hea); + inline uint16 Channels(void) { + return Wav.wChannels; + } + inline uint32 SmplRate(void) { + return Wav.dwSamplesPerSec; + } + inline uint32 ByteRate(void) { + return Wav.dwAvgBytesPerSec; + } + inline uint16 BlckSize(void) { + return Wav.wBlockAlign; + } + inline uint16 SmplSize(void) { + return Pcm.wBitsPerSample; + } }; - - - -class DATACK : public CKHEA -{ - bool e; - union - { - uint8 * Buf; - EMS * EBuf; - }; +class DATACK : public CKHEA { + bool e; + union { + uint8 *Buf; + EMS *EBuf; + }; public: - DATACK (CKHEA& hea); - DATACK (CKHEA& hea, EMM * emm); - DATACK (int first, int last); - ~DATACK (void); - inline uint8 * Addr (void) { return Buf; } - inline EMS * EAddr (void) { return EBuf; } + DATACK(CKHEA &hea); + DATACK(CKHEA &hea, EMM *emm); + DATACK(int first, int last); + ~DATACK(void); + inline uint8 *Addr(void) { + return Buf; + } + inline EMS *EAddr(void) { + return EBuf; + } }; +extern CKID RIFF; +extern CKID WAVE; +extern CKID FMT; +extern CKID DATA; -extern CKID RIFF; -extern CKID WAVE; -extern CKID FMT; -extern CKID DATA; - - -DATACK * LoadWave (XFILE * file, EMM * emm = NULL); +DATACK *LoadWave(XFILE *file, EMM *emm = NULL); } // End of namespace CGE - #endif -- cgit v1.2.3 From 64f2ccca9bf4ba7fef87def8bee5209118d78ce8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 13:07:45 +0200 Subject: CGE: Cleanup: remove trailing spaces --- engines/cge/bitmaps.cpp | 24 ++++---- engines/cge/cfile.cpp | 48 +++++++-------- engines/cge/cge_main.cpp | 72 +++++++++++----------- engines/cge/cge_main.h | 16 +---- engines/cge/config.cpp | 28 ++++----- engines/cge/ems.cpp | 2 +- engines/cge/game.cpp | 4 +- engines/cge/general.cpp | 2 +- engines/cge/gettext.cpp | 8 +-- engines/cge/keybd.cpp | 40 ++++++------- engines/cge/mixer.cpp | 10 ++-- engines/cge/mouse.cpp | 18 +++--- engines/cge/snail.cpp | 152 +++++++++++++++++++++++------------------------ engines/cge/snail.h | 14 ++--- engines/cge/sound.cpp | 10 ++-- engines/cge/startup.cpp | 14 ++--- engines/cge/talk.cpp | 24 ++++---- engines/cge/text.cpp | 32 +++++----- engines/cge/text.h | 7 +-- engines/cge/vga13h.cpp | 124 +++++++++++++++++++------------------- engines/cge/vga13h.h | 6 +- engines/cge/vmenu.cpp | 12 ++-- engines/cge/vol.cpp | 4 +- 23 files changed, 327 insertions(+), 344 deletions(-) diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp index 8e1b7ce5e9..77012c0488 100644 --- a/engines/cge/bitmaps.cpp +++ b/engines/cge/bitmaps.cpp @@ -225,35 +225,35 @@ static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 namespace CGE { #ifdef DEBUG -BMP_PTR MB[] = { - new BITMAP("BRICK"), - NULL +BMP_PTR MB[] = { + new BITMAP("BRICK"), + NULL }; -BMP_PTR HL[] = { - new BITMAP("HLINE"), - NULL +BMP_PTR HL[] = { + new BITMAP("HLINE"), + NULL }; #endif -BMP_PTR MC[] = { +BMP_PTR MC[] = { new BITMAP("MOUSE"), new BITMAP("DUMMY"), NULL }; -BMP_PTR PR[] = { - new BITMAP("PRESS"), - NULL +BMP_PTR PR[] = { + new BITMAP("PRESS"), + NULL }; -BMP_PTR SP[] = { +BMP_PTR SP[] = { new BITMAP("SPK_L"), new BITMAP("SPK_R"), NULL }; -BMP_PTR LI[] = { +BMP_PTR LI[] = { new BITMAP("LITE0"), new BITMAP("LITE1"), new BITMAP("LITE2"), diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 7c4f689e30..4fb0988d38 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -55,9 +55,9 @@ IOBUF::IOBUF(const char *name, IOMODE mode, CRYPT *crpt) } IOBUF::~IOBUF(void) { - if (Mode > REA) + if (Mode > REA) WriteBuff(); - if (Buff) + if (Buff) free(Buff); } @@ -81,18 +81,18 @@ void IOBUF::WriteBuff(void) { uint16 IOBUF::Read(void *buf, uint16 len) { uint16 total = 0; while (len) { - if (Ptr >= Lim) + if (Ptr >= Lim) ReadBuff(); uint16 n = Lim - Ptr; if (n) { - if (len < n) + if (len < n) n = len; memcpy(buf, Buff + Ptr, n); buf = (uint8 *)buf + n; len -= n; total += n; Ptr += n; - } else + } else break; } return total; @@ -103,40 +103,40 @@ uint16 IOBUF::Read(uint8 *buf) { uint16 total = 0; while (total < LINE_MAX - 2) { - if (Ptr >= Lim) + if (Ptr >= Lim) ReadBuff(); uint8 *p = Buff + Ptr; uint16 n = Lim - Ptr; if (n) { - if (total + n >= LINE_MAX - 2) + if (total + n >= LINE_MAX - 2) n = LINE_MAX - 2 - total; uint8 *eol = (uint8 *) memchr(p, '\r', n); - if (eol) + if (eol) n = (uint16)(eol - p); uint8 *eof = (uint8 *) memchr(p, '\32', n); if (eof) { // end-of-file n = (uint16)(eof - p); Ptr = (uint16)(eof - Buff); } - if (n) + if (n) memcpy(buf, p, n); buf += n; total += n; - if (eof) + if (eof) break; Ptr += n; if (eol) { ++ Ptr; * (buf ++) = '\n'; ++ total; - if (Ptr >= Lim) + if (Ptr >= Lim) ReadBuff(); - if (Ptr < Lim) - if (Buff[Ptr] == '\n') + if (Ptr < Lim) + if (Buff[Ptr] == '\n') ++Ptr; break; } - } else + } else break; } *buf = '\0'; @@ -148,7 +148,7 @@ uint16 IOBUF::Write(void *buf, uint16 len) { uint16 tot = 0; while (len) { uint16 n = IOBUF_SIZE - Lim; - if (n > len) + if (n > len) n = len; if (n) { memcpy(Buff + Lim, buf, n); @@ -156,7 +156,7 @@ uint16 IOBUF::Write(void *buf, uint16 len) { len -= n; buf = (uint8 *)buf + n; tot += n; - } else + } else WriteBuff(); } return tot; @@ -167,8 +167,8 @@ uint16 IOBUF::Write(uint8 *buf) { uint16 len = 0; if (buf) { len = strlen((const char *) buf); - if (len) - if (buf[len - 1] == '\n') + if (len) + if (buf[len - 1] == '\n') --len; len = Write(buf, len); if (len) { @@ -184,7 +184,7 @@ uint16 IOBUF::Write(uint8 *buf) { int IOBUF::Read(void) { if (Ptr >= Lim) { ReadBuff(); - if (Lim == 0) + if (Lim == 0) return -1; } return Buff[Ptr ++]; @@ -211,9 +211,9 @@ CFILE::~CFILE(void) { void CFILE::Flush(void) { - if (Mode > REA) + if (Mode > REA) WriteBuff(); - else + else Lim = 0; /* @@ -250,11 +250,11 @@ void CFILE::Append(CFILE &f) { Seek(Size()); if (f.Error == 0) { while (true) { - if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) + if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) WriteBuff(); - else + else break; - if ((Error = f.Error) != 0) + if ((Error = f.Error) != 0) break; } } diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 62936e8c9c..24964da0fc 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1322,19 +1322,19 @@ void SPRITE::Touch(uint16 mask, int x, int y) { if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) { if (Works(ps)) { FeedSnail(ps, TAKE); - } else + } else OffUse(); SelectPocket(-1); - } else + } else TooFar(); } else { - if (Flags.Kept) + if (Flags.Kept) mask |= L_UP; else { if (Hero->Distance(this) < MAX_DISTANCE) { /// if (Flags.Port) { - if (FindPocket(NULL) < 0) + if (FindPocket(NULL) < 0) PocFul(); else { SNPOST(SNREACH, -1, -1, this); @@ -1343,15 +1343,15 @@ void SPRITE::Touch(uint16 mask, int x, int y) { } } else { if (TakePtr != NO_PTR) { - if (SnList(TAKE)[TakePtr].Com == SNNEXT) + if (SnList(TAKE)[TakePtr].Com == SNNEXT) OffUse(); - else + else FeedSnail(this, TAKE); - } else + } else OffUse(); } }/// - else + else TooFar(); } } @@ -1365,7 +1365,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { break; } } - } else + } else SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this); } } @@ -1400,9 +1400,9 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row while ((len = sprf.Read((uint8 *)line)) != 0) { ++ lcnt; - if (len && line[len - 1] == '\n') + if (len && line[len - 1] == '\n') line[-- len] = '\0'; - if (len == 0 || *line == '.') + if (len == 0 || *line == '.') continue; if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) @@ -1531,42 +1531,42 @@ static void LoadScript(const char *fname) { int lcnt = 0; bool ok = true; - if (scrf.Error) + if (scrf.Error) return; while (scrf.Read((uint8 *)line) != 0) { char *p; ++lcnt; - if (*line == 0 || *line == '\n' || *line == '.') + if (*line == 0 || *line == '\n' || *line == '.') continue; ok = false; // not OK if break // sprite ident number - if ((p = strtok(line, " \t\n")) == NULL) + if ((p = strtok(line, " \t\n")) == NULL) break; SpI = atoi(p); // sprite file name - if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) + if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) break; // sprite cave - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; SpA = atoi(p); // sprite column - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; SpX = atoi(p); // sprite row - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; SpY = atoi(p); // sprite Z pos - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; SpZ = atoi(p); // sprite life - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; BkG = atoi(p) == 0; @@ -1574,7 +1574,7 @@ static void LoadScript(const char *fname) { Sprite = NULL; LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); - if (Sprite && BkG) + if (Sprite && BkG) Sprite->Flags.Back = true; } if (! ok) @@ -1688,10 +1688,10 @@ static void RunGame(void) { if ((Sprite = VGA::SpareQ.Locate(121)) != NULL) SNPOST_(SNSEQ, -1, VGA::Mono, Sprite); - if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) + if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) Sprite->Step(Music); SNPOST_(SNSEQ, -1, Music, Sprite); - if (! Music) + if (! Music) KillMIDI(); if (Mini && INI_FILE::Exist("MINI.SPR")) { @@ -1738,7 +1738,7 @@ static void RunGame(void) { #endif Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF); - if (Mouse.Busy) + if (Mouse.Busy) ExpandSprite(Mouse.Busy); Startup = 0; @@ -1820,14 +1820,14 @@ bool ShowTitle(const char *name) { VGA::ShowQ.Append(&Mouse); HEART::Enable = true; Mouse.On(); - for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) + for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) MainLoop(); Mouse.Off(); HEART::Enable = false; VGA::ShowQ.Clear(); VGA::CopyPage(0, 2); STARTUP::SoundOk = 2; - if (Music) + if (Music) LoadMIDI(0); } @@ -1857,12 +1857,12 @@ bool ShowTitle(const char *name) { VGA::ShowQ.Append(&Mouse); //Mouse.On(); HEART::Enable = true; - for (TakeName(); GET_TEXT::Ptr;) + for (TakeName(); GET_TEXT::Ptr;) MainLoop(); HEART::Enable = false; - if (KEYBOARD::Last() == Enter && *UsrFnam) + if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = true; - if (usr_ok) + if (usr_ok) strcat(UsrFnam, SVG_EXT); //Mouse.Off(); VGA::ShowQ.Clear(); @@ -1879,12 +1879,12 @@ bool ShowTitle(const char *name) { ++ STARTUP::Mode; FINIS = false; } - } else + } else ++STARTUP::Mode; } } - if (STARTUP::Mode < 2) + if (STARTUP::Mode < 2) Movie("X01"); // wink VGA::CopyPage(0, 2); @@ -1918,7 +1918,7 @@ void cge_main(void) { if (! Mouse.Exist) error("%s", Text[NO_MOUSE_TEXT]); - if (! SVG0FILE::Exist(SVG0NAME)) + if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; Debug(DebugLine.Flags.Hide = true;) @@ -1927,9 +1927,9 @@ void cge_main(void) { //srand((uint16) Timer()); Sys = new SYSTEM; - if (Music && STARTUP::SoundOk) + if (Music && STARTUP::SoundOk) LoadMIDI(0); - if (STARTUP::Mode < 2) + if (STARTUP::Mode < 2) Movie(LGO_EXT); if (ShowTitle("WELCOME")) { #ifndef DEMO @@ -1937,9 +1937,9 @@ void cge_main(void) { #endif RunGame(); Startup = 2; - if (FINIS) + if (FINIS) Movie("X03"); - } else + } else Vga.Sunset(); error("%s", Text[EXIT_OK_TEXT + FINIS]); } diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index a67cd29000..fa27274803 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -39,7 +39,6 @@ namespace CGE { #define NO_WAY (TSEQ+5) #define POC_FUL (TSEQ+5) #define OFF_USE (TSEQ+6) - #define EXIT_OK_TEXT 40 #define NOMUSIC_TEXT 98 #define BADSVG_TEXT 99 @@ -49,19 +48,15 @@ namespace CGE { #define TOO_FAR_TEXT 681 #define POC_FUL_TEXT 691 #define A_C_D_TEXT 777 - #define GETNAME_PROMPT 50 #define GETNAME_TITLE 51 - #define QUIT_TITLE 200 #define QUIT_TEXT 201 #define NOQUIT_TEXT 202 #define DEMO_TEXT 300 #define NOSOUND_TEXT 310 - #define PAN_HIG 40 #define WORLD_HIG (SCR_HIG-PAN_HIG) - #define INFO_X 177 #define INFO_Y 164 #define INFO_W 140 @@ -75,7 +70,7 @@ namespace CGE { #define CAVE_DY 29 #define CAVE_NX 3 #define CAVE_NY 1 -#else +#else #define CAVE_X 4 #define CAVE_Y 166 #define CAVE_SX 0 @@ -92,19 +87,14 @@ namespace CGE { #define BUTTON_DY 11 #define BUTTON_NX 1 #define BUTTON_NY 3 - #define MINI_X 86 #define MINI_Y 162 - -//#define MAP_XCNT 16 -//#define MAP_ZCNT 4 #define MAP_XCNT 40 #define MAP_ZCNT 20 #define MAP_TOP 80 #define MAP_HIG 80 #define MAP_XGRID (SCR_WID / MAP_XCNT) #define MAP_ZGRID (MAP_HIG / MAP_ZCNT) - #define LINE_MAX 512 #define USER_MAX 100 #define SHP_MAX 1024 @@ -113,16 +103,12 @@ namespace CGE { #define CAVE_MAX (CAVE_NX*CAVE_NY) #define MAX_FIND_LEVEL 3 #define MAX_DISTANCE 3 - #define INI_EXT ".INI" #define IN0_EXT ".IN0" #define LGO_EXT ".LGO" #define SVG_EXT ".SVG" - #define WALKSIDE 10 - #define BUSY_REF 500 - #define SYSTIMERATE 6 // 12 Hz #define HEROFUN0 (40*12) #define HEROFUN1 ( 2*12) diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index c1e9ae4762..1900093520 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -72,12 +72,12 @@ static void SetIRQ(void); static void SetDMA(void); -static int DevName[] = { +static int DevName[] = { NONE_TEXT, SB_TEXT, SBM_TEXT, GUS_TEXT, GUSM_TEXT, MIDI_TEXT, AUTO_TEXT }; -static CHOICE DevMenu[] = { +static CHOICE DevMenu[] = { { NULL, NONE }, { NULL, SB }, { NULL, SBM }, @@ -89,7 +89,7 @@ static CHOICE DevMenu[] = { }; -static CHOICE DigiPorts[] = { +static CHOICE DigiPorts[] = { { " 210h", SetPortD }, { " 220h", SetPortD }, { " 230h", SetPortD }, @@ -100,7 +100,7 @@ static CHOICE DigiPorts[] = { { NULL, NULL } }; -static CHOICE MIDIPorts[] = { +static CHOICE MIDIPorts[] = { { " 220h", SetPortM }, { " 230h", SetPortM }, { " 240h", SetPortM }, @@ -115,7 +115,7 @@ static CHOICE MIDIPorts[] = { { NULL, NULL } }; -static CHOICE BlsterIRQ[] = { +static CHOICE BlsterIRQ[] = { { "IRQ 2", SetIRQ }, { "IRQ 5", SetIRQ }, { "IRQ 7", SetIRQ }, @@ -124,7 +124,7 @@ static CHOICE BlsterIRQ[] = { { NULL, NULL } }; -static CHOICE GravisIRQ[] = { +static CHOICE GravisIRQ[] = { { "IRQ 2", SetIRQ }, { "IRQ 5", SetIRQ }, { "IRQ 7", SetIRQ }, @@ -135,7 +135,7 @@ static CHOICE GravisIRQ[] = { { NULL, NULL } }; -static CHOICE GravisDMA[] = { +static CHOICE GravisDMA[] = { { "DMA 1", SetDMA }, { "DMA 3", SetDMA }, { "DMA 5", SetDMA }, @@ -145,7 +145,7 @@ static CHOICE GravisDMA[] = { { NULL, NULL } }; -static CHOICE BlsterDMA[] = { +static CHOICE BlsterDMA[] = { { "DMA 0", SetDMA }, { "DMA 1", SetDMA }, { "DMA 3", SetDMA }, @@ -157,7 +157,7 @@ static CHOICE BlsterDMA[] = { void SelectSound(void) { int i; Sound.Close(); - if (VMENU::Addr) + if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); Inf(Text[STYPE_TEXT]); Talk->Goto(Talk->X, FONT_HIG / 2); @@ -173,11 +173,11 @@ static void Reset(void) { static uint16 deco(const char *str, uint16(*dco)(const char *)) { - while (*str && ! IsDigit(*str)) + while (*str && ! IsDigit(*str)) ++str; - if (*str) + if (*str) return dco(str); - else + else return DETECT; } @@ -286,9 +286,9 @@ static void SetIRQ(void) { static void SetDMA(void) { SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); - if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) + if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) Select(MIDIPorts, MPORT_TEXT); - else + else Sound.Open(); } diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index b654000553..7b0697cd8a 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -34,7 +34,7 @@ namespace CGE { #define SIZ(n) ((n) ? ((long)n) : (0x10000L)) -enum EMM_FUN { +enum EMM_FUN { GET_STATUS = 0x40, GET_FRAME, GET_SIZE, OPEN_HANDLE, MAP_PAGE, CLOSE_HANDLE, GET_VER, SAVE_CONTEXT, REST_CONTEXT, GET_PAGES = 0x4B, GET_HANDLES, GET_INFO, CONTROL diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 25af315d98..4102e080b6 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -83,9 +83,9 @@ void FLY::Tick(void) { Tx = new_random(3) - 1; Ty = new_random(3) - 1; } - if (X + Tx < L || X + Tx + W > R) + if (X + Tx < L || X + Tx + W > R) Tx = -Tx; - if (Y + Ty < T || Y + Ty + H > B) + if (Y + Ty < T || Y + Ty + H > B) Ty = -Ty; Goto(X + Tx, Y + Ty); } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 3a0114c672..e68533d0b2 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -187,7 +187,7 @@ char *wtom(uint16 val, char *str, int radix, int len) { char *dwtom(uint32 val, char *str, int radix, int len) { while (--len >= 0) { uint16 w = (uint16) (val % radix); - if (w > 9) + if (w > 9) w += ('A' - ('9' + 1)); str[len] = '0' + w; val /= radix; diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 78cc0356a1..4399a30916 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -75,7 +75,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { char *p; if (mask & KEYB) { - if (Click) + if (Click) Click(); switch (x) { case Enter : @@ -83,7 +83,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { strcpy(Text, Buff); for (p = Text; *p; p ++) { char *q = strchr(ogon, *p); - if (q) + if (q) *p = bezo[q - ogon]; } case Esc : @@ -103,7 +103,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { } else { if (KEYBOARD::Key[ALT]) { p = strchr(bezo, x); - if (p) + if (p) x = ogon[p - bezo]; } if (Len < Size && 2 * TEXT_HM + Font.Width(Buff) + Font.Wid[x] <= W) { @@ -114,7 +114,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { } break; } - } else + } else SPRITE::Touch(mask, x, y); } diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index a4590f4980..35e6c72c11 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -34,26 +34,26 @@ namespace CGE { SPRITE *KEYBOARD::Client = NULL; uint8 KEYBOARD::Key[0x60] = { 0 }; uint16 KEYBOARD::Current = 0; -uint16 KEYBOARD::Code[0x60] = { - 0, Esc, '1', '2', '3', - '4', '5', '6', '7', '8', - '9', '0', '-', '+', BSp, - Tab, 'Q', 'W', 'E', 'R', - 'T', 'Y', 'U', 'I', 'O', - 'P', '[', ']', Enter, 0/*Ctrl*/, - 'A', 'S', 'D', 'F', 'G', - 'H', 'J', 'K', 'L', ';', - '\'', '`', 0/*LShift*/, '\\', 'Z', - 'X', 'C', 'V', 'B', 'N', - 'M', ',', '.', '/', 0/*RShift*/, - '*', 0/*Alt*/, ' ', 0/*Caps*/, F1, - F2, F3, F4, F5, F6, - F7, F8, F9, F10, 0/*NumLock*/, - 0/*ScrollLock*/, Home, Up, PgUp, '-', - Left, Ctr, Right, '+', End, - Down, PgDn, Ins, Del, 0 * 0x54, - 0 * 0x55, 0 * 0x56, F11, F12, 0 * 0x59, - 0 * 0x5A, 0 * 0x5B, 0 * 0x5C, 0 * 0x5D, 0 * 0x5E, +uint16 KEYBOARD::Code[0x60] = { + 0, Esc, '1', '2', '3', + '4', '5', '6', '7', '8', + '9', '0', '-', '+', BSp, + Tab, 'Q', 'W', 'E', 'R', + 'T', 'Y', 'U', 'I', 'O', + 'P', '[', ']', Enter, 0/*Ctrl*/, + 'A', 'S', 'D', 'F', 'G', + 'H', 'J', 'K', 'L', ';', + '\'', '`', 0/*LShift*/, '\\', 'Z', + 'X', 'C', 'V', 'B', 'N', + 'M', ',', '.', '/', 0/*RShift*/, + '*', 0/*Alt*/, ' ', 0/*Caps*/, F1, + F2, F3, F4, F5, F6, + F7, F8, F9, F10, 0/*NumLock*/, + 0/*ScrollLock*/, Home, Up, PgUp, '-', + Left, Ctr, Right, '+', End, + Down, PgDn, Ins, Del, 0 * 0x54, + 0 * 0x55, 0 * 0x56, F11, F12, 0 * 0x59, + 0 * 0x5A, 0 * 0x5B, 0 * 0x5C, 0 * 0x5D, 0 * 0x5E, 0 * 0x5F }; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 47a6e17fc9..83d9cd1be5 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -76,7 +76,7 @@ MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { Led[ArrayCount(Led) - 1]->Flags.BDel = true; VGA::ShowQ.Insert(this); - for (i = 0; i < ArrayCount(Led); i ++) + for (i = 0; i < ArrayCount(Led); i ++) VGA::ShowQ.Insert(Led[i]); //--- reset balance @@ -101,10 +101,10 @@ void MIXER::Touch(uint16 mask, int x, int y) { if (mask & L_UP) { uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < W / 2); if (y < MIX_BHIG) { - if (*vol < 0xFF) + if (*vol < 0xFF) *vol += 0x11; } else if (y >= H - MIX_BHIG) { - if (*vol > 0x00) + if (*vol > 0x00) *vol -= 0x11; } Update(); @@ -116,10 +116,10 @@ void MIXER::Tick(void) { int x = Mouse.X, y = Mouse.Y; if (SpriteAt(x, y) == this) { Fall = MIX_FALL; - if (Flags.Hold) + if (Flags.Hold) Touch(L_UP, x - X, y - Y); } else { - if (Fall) + if (Fall) --Fall; else { for (int i = 0; i < ArrayCount(Led); i ++) diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index d97a7eca7f..9bb9626deb 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -40,9 +40,9 @@ uint16 MOUSE::OldMouseMask = 0; MOUSE::MOUSE(BITMAP **shpl) : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0) { - static SEQ ms[] = { - { 0, 0, 0, 0, 1 }, - { 1, 1, 0, 0, 1 } + static SEQ ms[] = { + { 0, 0, 0, 0, 1 }, + { 1, 1, 0, 0, 1 } }; SetSeq(ms); @@ -135,9 +135,9 @@ void MOUSE::ClrEvt(SPRITE *spr) { if (spr) { uint16 e; for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) - if (Evt[e].Ptr == spr) + if (Evt[e].Ptr == spr) Evt[e].Msk = 0; - } else + } else EvtTail = EvtHead; } @@ -156,11 +156,11 @@ void MOUSE::Tick(void) { // activate current touched SPRITE if (e.Ptr) { - if (e.Msk & KEYB) + if (e.Msk & KEYB) e.Ptr->Touch(e.Msk, e.X, e.Y); - else + else e.Ptr->Touch(e.Msk, e.X - e.Ptr->X, e.Y - e.Ptr->Y); - } else if (Sys) + } else if (Sys) Sys->Touch(e.Msk, e.X, e.Y); if (e.Msk & L_DN) { @@ -186,7 +186,7 @@ void MOUSE::Tick(void) { ///Touched = e.Ptr; // discard Text if button released - if (e.Msk & (L_UP | R_UP)) + if (e.Msk & (L_UP | R_UP)) KillText(); } EvtTail = (EvtTail + 1) % EVT_MAX; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 952e032222..cc52ec63dc 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -88,7 +88,7 @@ static void SNGame(SPRITE *spr, int num) { if (Game) { // continue game int i = new_random(3), hand = (dup[0]->ShpCnt == 6); ++ Stage; - if (hand && Stage > DRESSED) + if (hand && Stage > DRESSED) ++hand; if (Debug(i >= 0 ||) dup[i] == spr && new_random(3) == 0) { @@ -138,8 +138,8 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNSEQ, -1, 2, dup[1]); // no SNPOST(SNSEQ, -1, 2, dup[2]); // no SNPOST(SNPAUSE, -1, 72, NULL); // 1 sec - } - } + } + } SNPOST(SNWALK, 198, 134, NULL); // na miejsce SNPOST(SNWAIT, 1, -1, NULL); // stoi SNPOST(SNCOVER, 1, 16101, NULL); // ch’op do bicia @@ -152,7 +152,7 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask SNPOST(SNWAIT, 16101, -1, NULL); // stoi SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS - if (! Game) { + if (! Game) { SNPOST(SNSAY, buref, 16008, NULL); // zgadnij! Game = true; } @@ -200,13 +200,13 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNKEEP, 20007, 0, NULL); // do kieszeni SNPOST(SNSEND, 20006, 20, NULL); // bilon SNPOST(SNSOUND, 20006, 20002, NULL); // bilon! - SNPOST(SNSAY, 20002, 20004, NULL); + SNPOST(SNSAY, 20002, 20004, NULL); SNPOST(SNSEND, 20010, 20, NULL); // papier SNPOST(SNSOUND, 20010, 20003, NULL); // papier! SNPOST(SNSAY, 20001, 20005, NULL); Game = false; return; - } else + } else k3->Step(new_random(5)); } if (count < 100) { @@ -237,7 +237,7 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNWAIT, 20007, -1, NULL); // koniec SNPOST(SNGAME, 20001, 2, NULL); // again! break; - case 20001 : + case 20001: SNPOST(SNSAY, 20002, 20012, NULL); // zapro SNPOST(SNSEQ, 20002, 1, NULL); // rzu SNPOST(SNWAIT, 20002, 3, NULL); // czekaj @@ -249,8 +249,8 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNSOUND, 20007, 20001, NULL); // grzech SNPOST(SNWAIT, 20007, -1, NULL); // koniec SNPOST(SNGAME, 20002, 2, NULL); // again! - break; - case 20002 : + break; + case 20002: SNPOST(SNSAY, 20002, 20010, NULL); // zapro SNPOST(SNWALK, 20005, -1, NULL); // do stol SNPOST(SNWAIT, 1, -1, NULL); // stoi @@ -276,19 +276,19 @@ static void SNGame(SPRITE *spr, int num) { void ExpandSprite(SPRITE *spr) { - if (spr) + if (spr) VGA::ShowQ.Insert(VGA::SpareQ.Remove(spr)); } void ContractSprite(SPRITE *spr) { - if (spr) + if (spr) VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); } int FindPocket(SPRITE *spr) { - for (int i = 0; i < POCKET_NX; i ++) - if (Pocket[i] == spr) + for (int i = 0; i < POCKET_NX; i ++) + if (Pocket[i] == spr) return i; return -1; } @@ -298,7 +298,7 @@ void SelectPocket(int n) { if (n < 0 || (PocLight.SeqPtr && PocPtr == n)) { PocLight.Step(0); n = FindPocket(NULL); - if (n >= 0) + if (n >= 0) PocPtr = n; } else { if (Pocket[n] != NULL) { @@ -335,7 +335,7 @@ void SNGhost(BITMAP *bmp) { void FeedSnail(SPRITE *spr, SNLIST snq) { - if (spr) + if (spr) if (spr->Active()) { uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; @@ -350,13 +350,13 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { PocFul(); return; } - if (p->Ptr) + if (p->Ptr) break; } } while (true) { if (c->Com == SNTALK) { - if ((Snail.TalkEnable = (c->Val != 0)) == false) + if ((Snail.TalkEnable = (c->Val != 0)) == false) KillText(); } if (c->Com == SNNEXT) { @@ -379,27 +379,27 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { v = c->Val; break; } - if (v >= 0) + if (v >= 0) *idx = v; } } - if (s == spr) + if (s == spr) break; } if (c->Com == SNIF) { SPRITE *s = (c->Ref < 0) ? spr : Locate(c->Ref); if (s) { // sprite extsts - if (! s->SeqTest(-1)) + if (! s->SeqTest(-1)) c = comtab + c->Val; // not parked - else + else ++c; - } else + } else ++c; } else { SNPOST(c->Com, c->Ref, c->Val, spr); - if (c->Ptr) + if (c->Ptr) break; - else + else ++c; } } @@ -408,17 +408,17 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { } -const char *SNAIL::ComTxt[] = { - "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", - "SAY", "INF", "TIME", "CAVE", "KILL", - "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", - "GIVE", "IF", "GAME", "SETX0", "SETY0", +const char *SNAIL::ComTxt[] = { + "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", + "SAY", "INF", "TIME", "CAVE", "KILL", + "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", + "GIVE", "IF", "GAME", "SETX0", "SETY0", "SLAVE", "SETXY", "RELX", "RELY", "RELZ", "SETX", "SETY", "SETZ", "TRANS", "PORT", "NEXT", "NNEXT", "TNEXT", "RNNEXT", "RTNEXT", - "RMNEAR", "RMTAKE", "FLAG", "SETREF", "BACKPT", - "FLASH", "LIGHT", "SETHB", "SETVB", "WALK", - "REACH", "COVER", "UNCOVER", "CLEAR", "TALK", + "RMNEAR", "RMTAKE", "FLAG", "SETREF", "BACKPT", + "FLASH", "LIGHT", "SETHB", "SETVB", "WALK", + "REACH", "COVER", "UNCOVER", "CLEAR", "TALK", "MOUSE", "SOUND", "COUNT", NULL }; @@ -431,7 +431,7 @@ SNAIL::SNAIL(bool turbo) SNAIL::~SNAIL(void) { - if (SNList) + if (SNList) free(SNList); } @@ -459,7 +459,7 @@ void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { if (Busy) { SNList[(Tail - 1) & 0xFF] = SNList[Tail]; snc = &SNList[Tail]; - } else + } else snc = &SNList[(Tail - 1) & 0xFF]; --Tail; snc->Com = com; @@ -476,35 +476,35 @@ void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { static void SNNNext(SPRITE *sprel, int p) { - if (sprel) - if (sprel->NearPtr != NO_PTR) + if (sprel) + if (sprel->NearPtr != NO_PTR) sprel->NearPtr = p; } static void SNTNext(SPRITE *sprel, int p) { - if (sprel) - if (sprel->TakePtr != NO_PTR) + if (sprel) + if (sprel->TakePtr != NO_PTR) sprel->TakePtr = p; } static void SNRNNext(SPRITE *sprel, int p) { - if (sprel) - if (sprel->NearPtr != NO_PTR) + if (sprel) + if (sprel->NearPtr != NO_PTR) sprel->NearPtr += p; } static void SNRTNext(SPRITE *sprel, int p) { - if (sprel) - if (sprel->TakePtr != NO_PTR) + if (sprel) + if (sprel->TakePtr != NO_PTR) sprel->TakePtr += p; } static void SNZTrim(SPRITE *spr) { - if (spr) + if (spr) if (spr->Active()) { bool en = HEART::Enable; SPRITE *s; @@ -523,36 +523,36 @@ static void SNZTrim(SPRITE *spr) { static void SNHide(SPRITE *spr, int val) { if (spr) { spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide); - if (spr->Flags.Shad) + if (spr->Flags.Shad) spr->Prev->Flags.Hide = spr->Flags.Hide; } } static void SNRmNear(SPRITE *spr) { - if (spr) + if (spr) spr->NearPtr = NO_PTR; } static void SNRmTake(SPRITE *spr) { - if (spr) + if (spr) spr->TakePtr = NO_PTR; } void SNSeq(SPRITE *spr, int val) { if (spr) { - if (spr == Hero && val == 0) + if (spr == Hero && val == 0) Hero->Park(); - else + else spr->Step(val); } } void SNRSeq(SPRITE *spr, int val) { - if (spr) + if (spr) SNSeq(spr, spr->SeqPtr + val); } @@ -567,18 +567,18 @@ void SNSend(SPRITE *spr, int val) { if (was1) { if (spr->Flags.Kept) { int n = FindPocket(spr); - if (n >= 0) + if (n >= 0) Pocket[n] = NULL; } Hide1(spr); ContractSprite(spr); spr->Flags.Slav = false; } else { - if (spr->Ref % 1000 == 0) + if (spr->Ref % 1000 == 0) BITMAP::Pal = SysPal; - if (spr->Flags.Back) + if (spr->Flags.Back) spr->BackShow(true); - else + else ExpandSprite(spr); BITMAP::Pal = NULL; } @@ -601,7 +601,7 @@ void SNSwap(SPRITE *spr, int xref) { Swap(spr->Z, xspr->Z); if (spr->Flags.Kept) { int n = FindPocket(spr); - if (n >= 0) + if (n >= 0) Pocket[n] = xspr; xspr->Flags.Kept = true; xspr->Flags.Port = false; @@ -610,12 +610,12 @@ void SNSwap(SPRITE *spr, int xref) { if (was1) { Hide1(spr); ContractSprite(spr); - } else + } else ExpandSprite(spr); if (xwas1) { Hide1(xspr); ContractSprite(xspr); - } else + } else ExpandSprite(xspr); } } @@ -650,7 +650,7 @@ void SNUncover(SPRITE *spr, SPRITE *xspr) { } spr->Z = xspr->Z; SNSend(xspr, -1); - if (spr->Time == 0) + if (spr->Time == 0) ++spr->Time; } } @@ -742,21 +742,21 @@ void SNKill(SPRITE *spr) { if (spr) { if (spr->Flags.Kept) { int n = FindPocket(spr); - if (n >= 0) + if (n >= 0) Pocket[n] = NULL; } SPRITE *nx = spr->Next; Hide1(spr); VGA::ShowQ.Remove(spr); MOUSE::ClrEvt(spr); - if (spr->Flags.Kill) + if (spr->Flags.Kill) delete spr; else { spr->Cave = -1; VGA::SpareQ.Append(spr); } - if (nx) - if (nx->Flags.Slav) + if (nx) + if (nx->Flags.Slav) SNKill(nx); } } @@ -764,7 +764,7 @@ void SNKill(SPRITE *spr) { static void SNSound(SPRITE *spr, int wav, int cnt) { if (SNDDrvInfo.DDEV) { - if (wav == -1) + if (wav == -1) Sound.Stop(); else Sound.Play(Fx[wav], (spr) ? ((spr->X + spr->W / 2) / (SCR_WID / 16)) : 8, cnt); @@ -781,7 +781,7 @@ void SNKeep(SPRITE *spr, int stp) { spr->Flags.Kept = true; spr->Goto(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->W / 2, POCKET_Y + POCKET_DY / 2 - spr->H / 2); - if (stp >= 0) + if (stp >= 0) spr->Step(stp); } SelectPocket(-1); @@ -795,7 +795,7 @@ void SNGive(SPRITE *spr, int stp) { Pocket[p] = NULL; spr->Cave = Now; spr->Flags.Kept = false; - if (stp >= 0) + if (stp >= 0) spr->Step(stp); } } @@ -805,7 +805,7 @@ void SNGive(SPRITE *spr, int stp) { static void SNBackPt(SPRITE *spr, int stp) { if (spr) { - if (stp >= 0) + if (stp >= 0) spr->Step(stp); spr->BackShow(true); } @@ -828,7 +828,7 @@ static void SNLevel(SPRITE *spr, int lev) { } } MaxCave = maxcav[Lev]; - if (spr) + if (spr) spr->Flags.Hide = false; } @@ -860,14 +860,14 @@ void SNFlash(bool on) { } VGA::SetColors(pal, 64); } - } else + } else VGA::SetColors(SysPal, 64); Dark = false; } static void SNLight(bool in) { - if (in) + if (in) VGA::Sunrise(SysPal); else VGA::Sunset(); @@ -882,16 +882,16 @@ static void SNBarrier(int cav, int bar, bool horz) { static void SNWalk(SPRITE *spr, int x, int y) { if (Hero) { - if (spr && y < 0) + if (spr && y < 0) Hero->FindWay(spr); - else + else Hero->FindWay(XZ(x, y)); } } static void SNReach(SPRITE *spr, int mode) { - if (Hero) + if (Hero) Hero->Reach(spr, mode); } @@ -914,7 +914,7 @@ void SNAIL::RunCom(void) { COM *snc = &SNList[Tail]; if (! Turbo) { // only for the slower one - if (Pause) + if (Pause) break; else { if (TextDelay) { @@ -922,7 +922,7 @@ void SNAIL::RunCom(void) { TextDelay = false; } } - if (Talk && snc->Com != SNPAUSE) + if (Talk && snc->Com != SNPAUSE) break; } @@ -932,7 +932,7 @@ void SNAIL::RunCom(void) { break; case SNPAUSE : HEART::SetXTimer(&Pause, snc->Val); - if (Talk) + if (Talk) TextDelay = true; break; case SNWAIT : @@ -940,7 +940,7 @@ void SNAIL::RunCom(void) { if (sprel->SeqTest(snc->Val) && (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) { HEART::SetXTimer(&Pause, sprel->Time); - } else + } else goto xit; } break; @@ -1116,7 +1116,7 @@ void SNAIL::RunCom(void) { break; } ++Tail; - if (!Turbo) + if (!Turbo) break; } xit: diff --git a/engines/cge/snail.h b/engines/cge/snail.h index f9b969a554..4255ea4e61 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -61,16 +61,16 @@ struct SCB { enum SNCOM { SNLABEL, SNPAUSE, SNWAIT, SNLEVEL, SNHIDE, - SNSAY, SNINF, SNTIME, SNCAVE, SNKILL, - SNRSEQ, SNSEQ, SNSEND, SNSWAP, SNKEEP, - SNGIVE, SNIF, SNGAME, SNSETX0, SNSETY0, + SNSAY, SNINF, SNTIME, SNCAVE, SNKILL, + SNRSEQ, SNSEQ, SNSEND, SNSWAP, SNKEEP, + SNGIVE, SNIF, SNGAME, SNSETX0, SNSETY0, SNSLAVE, SNSETXY, SNRELX, SNRELY, SNRELZ, SNSETX, SNSETY, SNSETZ, SNTRANS, SNPORT, SNNEXT, SNNNEXT, SNTNEXT, SNRNNEXT, SNRTNEXT, - SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, SNBACKPT, - SNFLASH, SNLIGHT, SNSETHB, SNSETVB, SNWALK, - SNREACH, SNCOVER, SNUNCOVER, SNCLEAR, SNTALK, - SNMOUSE, SNSOUND, SNCOUNT, SNEXEC, SNSTEP, + SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, SNBACKPT, + SNFLASH, SNLIGHT, SNSETHB, SNSETVB, SNWALK, + SNREACH, SNCOVER, SNUNCOVER, SNCLEAR, SNTALK, + SNMOUSE, SNSOUND, SNCOUNT, SNEXEC, SNSTEP, SNZTRIM, SNGHOST }; diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 397684849a..04e5d9464a 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -41,7 +41,7 @@ SOUND Sound; SOUND::SOUND(void) { - if (STARTUP::SoundOk) + if (STARTUP::SoundOk) Open(); } @@ -115,7 +115,7 @@ int FX::Find(int ref) { for (p = Cache, q = p + Size; p < q; p ++) { if (p->Ref == ref) break; - else + else ++i; } return i; @@ -133,7 +133,7 @@ void FX::Preload(int ref0) { DATACK *wav = LoadWave(&file, &Emm); if (wav) { HAN *p = &Cache[Find(0)]; - if (p >= CacheLim) + if (p >= CacheLim) break; p->Wav = wav; p->Ref = ref; @@ -159,7 +159,7 @@ DATACK *FX::Load(int idx, int ref) { DATACK *FX::operator [](int ref) { int i; - if ((i = Find(ref)) < Size) + if ((i = Find(ref)) < Size) Current = Cache[i].Wav; else { if ((i = Find(0)) >= Size) { @@ -195,7 +195,7 @@ void LoadMIDI(int ref) { midi = new uint8[siz]; if (midi) { mid.Read(midi, siz); - if (mid.Error) + if (mid.Error) KillMIDI(); else SNDMIDIStart(midi); diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 2bed51af97..24aaf3e042 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -160,25 +160,25 @@ const char *UsrPath(const char *nam) { int i = strlen(key); while (ini.Read(buf) && !ok) { int j = strlen(buf); - if (j) - if (buf[--j] == '\n') + if (j) + if (buf[--j] == '\n') buf[j] = '\0'; - if (memicmp(buf, key, i) == 0) + if (memicmp(buf, key, i) == 0) ok = true; } if (ok) { strcpy(buf, buf + i); p = buf + strlen(buf); - if (*(p - 1) != '\\') + if (*(p - 1) != '\\') *(p++) = '\\'; strcpy(p, "NUL"); - if (_dos_open(buf, 0, &i) == 0) + if (_dos_open(buf, 0, &i) == 0) _dos_close(i); - else + else ok = false; } } - if (!ok) + if (!ok) quit_now(BADCD_TEXT); } #endif diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 1dbcbad98d..e707e4e705 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -79,8 +79,8 @@ void FONT::Load(void) { uint16 FONT::Width(const char *text) { uint16 w = 0; - if (text) - while (* text) + if (text) + while (* text) w += Wid[*(text ++)]; return w; } @@ -141,13 +141,13 @@ void TALK::Update(const char *tx) { for (p = tx; *p; p ++) { if (*p == '|' || *p == '\n') { mh += FONT_HIG + TEXT_LS; - if (k > mw) + if (k > mw) mw = k; k = 2 * hmarg; - } else + } else k += Font.Wid[*p]; } - if (k > mw) + if (k > mw) mw = k; TS[0] = Box(mw, mh); } @@ -165,7 +165,7 @@ void TALK::Update(const char *tx) { uint16 n; register uint16 b = *(f++); for (n = 0; n < FONT_HIG; n++) { - if (b & 1) + if (b & 1) *p = TEXT_FG; b >>= 1; p += mw; @@ -186,9 +186,9 @@ BITMAP *TALK::Box(uint16 w, uint16 h) { uint8 *b, * p, * q; uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0; - if (w < 8) + if (w < 8) w = 8; - if (h < 8) + if (h < 8) h = 8; b = farnew(uint8, n = w * h); if (! b) @@ -263,13 +263,13 @@ void TALK::PutLine(int line, const char *text) { register uint16 b = fp[i]; uint16 n; for (n = 0; n < FONT_HIG; n ++) { - if (b & 1) + if (b & 1) *p = TEXT_FG; b >>= 1; p += lsiz; } p = p - rsiz + psiz; - if (p >= q) + if (p >= q) p = p - size + 1; } ++text; @@ -310,12 +310,12 @@ void INFO_LINE::Update(const char *tx) { for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; for (uint16 n = 0; n < FONT_HIG; n ++) { - if (b & 1) + if (b & 1) *p = TEXT_FG; b >>= 1; p += lsiz; } - if (p >= q) + if (p >= q) p = p - size + 1; } ++tx; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 71f4f156d5..92951196c7 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -79,7 +79,7 @@ int TEXT::Find(int ref) { for (p = Cache, q = p + Size; p < q; p ++) { if (p->Ref == ref) break; - else + else ++i; } return i; @@ -111,14 +111,14 @@ void TEXT::Preload(int from, int upto) { if (p < CacheLim) { delete[] p->Txt; p->Txt = NULL; - } else + } else p = &Cache[Find(0)]; - if (p >= CacheLim) + if (p >= CacheLim) break; s += strlen(s); - if (s < line + n) + if (s < line + n) ++s; - if ((p->Txt = new char[strlen(s) + 1]) == NULL) + if ((p->Txt = new char[strlen(s) + 1]) == NULL) break; p->Ref = ref; strcpy(p->Txt, s); @@ -138,24 +138,24 @@ char *TEXT::Load(int idx, int ref) { while ((n = tf.Read((uint8 *)line)) != 0) { char *s; - if (line[n - 1] == '\n') + if (line[n - 1] == '\n') line[-- n] = '\0'; - if ((s = strtok(line, " =,;/\t\n")) == NULL) + if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; - if (! IsDigit(*s)) + if (! IsDigit(*s)) continue; int r = atoi(s); - if (r < ref) + if (r < ref) continue; - if (r > ref) + if (r > ref) break; // (r == ref) s += strlen(s); - if (s < line + n) + if (s < line + n) ++s; p->Ref = ref; - if ((p->Txt = new char[strlen(s) + 1]) == NULL) + if ((p->Txt = new char[strlen(s) + 1]) == NULL) return NULL; return strcpy(p->Txt, s); } @@ -166,7 +166,7 @@ char *TEXT::Load(int idx, int ref) { char *TEXT::operator [](int ref) { int i; - if ((i = Find(ref)) < Size) + if ((i = Find(ref)) < Size) return Cache[i].Txt; if ((i = Find(0)) >= Size) { @@ -191,14 +191,14 @@ void Say(const char *txt, SPRITE *spr) { uint16 sw = spike->W; if (east) { - if (x + sw + TEXT_RD + 5 >= SCR_WID) + if (x + sw + TEXT_RD + 5 >= SCR_WID) east = false; } else { - if (x <= 5 + TEXT_RD + sw) + if (x <= 5 + TEXT_RD + sw) east = true; } x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2 - sw); - if (spr->Ref == 1) + if (spr->Ref == 1) x += (east) ? -10 : 10; // Hero Talk->Flags.Kill = true; diff --git a/engines/cge/text.h b/engines/cge/text.h index fe740ffacd..7cf3922c5a 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -34,10 +34,10 @@ namespace CGE { #ifndef SYSTXT_MAX -#define SYSTXT_MAX 1000 +#define SYSTXT_MAX 1000 #endif -#define SAY_EXT ".SAY" +#define SAY_EXT ".SAY" #define NOT_VGA_TEXT 90 #define BAD_CHIP_TEXT 91 @@ -45,11 +45,8 @@ namespace CGE { #define NO_CORE_TEXT 93 #define BAD_MIPS_TEXT 94 #define NO_MOUSE_TEXT 95 - - #define INF_NAME 101 #define SAY_NAME 102 - #define INF_REF 301 #define SAY_REF 302 diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e7ed6d0402..3f303e7f29 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -88,7 +88,7 @@ extern "C" void SNDMIDIPlay(void); char *NumStr(char *str, int num) { char *p = strchr(str, '#'); - if (p) + if (p) wtom(num, p, 10, 5); return str; } @@ -345,7 +345,7 @@ void ENGINE::NewTimer(...) { void HEART::SetXTimer(uint16 *ptr) { - if (XTimer && ptr != XTimer) + if (XTimer && ptr != XTimer) *XTimer = 0; XTimer = ptr; } @@ -374,7 +374,7 @@ SPRITE::~SPRITE(void) { BMP_PTR SPRITE::Shp(void) { register SPREXT *e = Ext; - if (e) + if (e) if (e->Seq) { int i = e->Seq[SeqPtr].Now; #ifdef DEBUG @@ -403,15 +403,15 @@ BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { BMP_PTR *p; for (p = shp; *p; p++) { BMP_PTR b = (*p); // ->Code(); - if (b->W > W) + if (b->W > W) W = b->W; - if (b->H > H) + if (b->H > H) H = b->H; ++ShpCnt; } Expand(); Ext->ShpList = shp; - if (! Ext->Seq) + if (! Ext->Seq) SetSeq((ShpCnt < 2) ? Seq1 : Seq2); } return r; @@ -427,7 +427,7 @@ void SPRITE::MoveShapes(uint8 *buf) { bool SPRITE::Works(SPRITE *spr) { - if (spr) + if (spr) if (spr->Ext) { SNAIL::COM *c = spr->Ext->Take; if (c != NULL) { @@ -445,18 +445,18 @@ SEQ *SPRITE::SetSeq(SEQ *seq) { Expand(); register SEQ *s = Ext->Seq; Ext->Seq = seq; - if (SeqPtr == NO_SEQ) + if (SeqPtr == NO_SEQ) Step(0); - else if (Time == 0) + else if (Time == 0) Step(SeqPtr); return s; } bool SPRITE::SeqTest(int n) { - if (n >= 0) + if (n >= 0) return (SeqPtr == n); - if (Ext) + if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); return true; } @@ -464,7 +464,7 @@ bool SPRITE::SeqTest(int n) { SNAIL::COM *SPRITE::SnList(SNLIST type) { register SPREXT *e = Ext; - if (e) + if (e) return (type == NEAR) ? e->Near : e->Take; return NULL; } @@ -477,7 +477,7 @@ void SPRITE::SetName(char *n) { Ext->Name = NULL; } if (n) { - if ((Ext->Name = new char[strlen(n) + 1]) != NULL) + if ((Ext->Name = new char[strlen(n) + 1]) != NULL) strcpy(Ext->Name, n); else error("No core [%s]", n); @@ -516,9 +516,9 @@ SPRITE *SPRITE::Expand(void) { while ((len = sprf.Read((uint8 *)line)) != 0) { ++ lcnt; - if (len && line[len - 1] == '\n') + if (len && line[len - 1] == '\n') line[-- len] = '\0'; - if (len == 0 || *line == '.') + if (len == 0 || *line == '.') continue; switch (TakeEnum(Comd, strtok(line, " =\t"))) { @@ -536,7 +536,7 @@ SPRITE *SPRITE::Expand(void) { error("No core [%s]", fname); SEQ *s = &seq[seqcnt ++]; s->Now = atoi(strtok(NULL, " \t,;/")); - if (s->Now > maxnow) + if (s->Now > maxnow) maxnow = s->Now; s->Next = atoi(strtok(NULL, " \t,;/")); switch (s->Next) { @@ -547,7 +547,7 @@ SPRITE *SPRITE::Expand(void) { s->Next = seqcnt - 1; break; } - if (s->Next > maxnxt) + if (s->Next > maxnxt) maxnxt = s->Next; s->Dx = atoi(strtok(NULL, " \t,;/")); s->Dy = atoi(strtok(NULL, " \t,;/")); @@ -598,19 +598,19 @@ SPRITE *SPRITE::Expand(void) { if (maxnxt >= seqcnt) error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); - } else + } else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); //disable(); // disable interupt SetShapeList(shplist); //enable(); // enable interupt - if (nea) + if (nea) nea[neacnt - 1].Ptr = Ext->Near = nea; - else + else NearPtr = NO_PTR; - if (tak) + if (tak) tak[takcnt - 1].Ptr = Ext->Take = tak; - else + else TakePtr = NO_PTR; } HEART::Enable = enbl; @@ -622,20 +622,20 @@ SPRITE *SPRITE::Expand(void) { SPRITE *SPRITE::Contract(void) { register SPREXT *e = Ext; if (e) { - if (e->Name) + if (e->Name) delete[] e->Name; if (Flags.BDel && e->ShpList) { int i; - for (i = 0; e->ShpList[i]; i ++) + for (i = 0; e->ShpList[i]; i ++) delete e->ShpList[i]; - if (MemType(e->ShpList) == NEAR_MEM) + if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; } - if (MemType(e->Seq) == NEAR_MEM) + if (MemType(e->Seq) == NEAR_MEM) free(e->Seq); - if (e->Near) + if (e->Near) free(e->Near); - if (e->Take) + if (e->Take) free(e->Take); delete e; Ext = NULL; @@ -648,7 +648,7 @@ SPRITE *SPRITE::BackShow(bool fast) { Expand(); Show(2); Show(1); - if (fast) + if (fast) Show(0); Contract(); return this; @@ -656,11 +656,11 @@ SPRITE *SPRITE::BackShow(bool fast) { void SPRITE::Step(int nr) { - if (nr >= 0) + if (nr >= 0) SeqPtr = nr; if (Ext) { SEQ *seq; - if (nr < 0) + if (nr < 0) SeqPtr = Ext->Seq[SeqPtr].Next; seq = Ext->Seq + SeqPtr; if (seq->Dly >= 0) { @@ -680,7 +680,7 @@ void SPRITE::MakeXlat(uint8 *x) { if (Ext) { BMP_PTR *b; - if (Flags.Xlat) + if (Flags.Xlat) KillXlat(); for (b = Ext->ShpList; *b; b ++) (*b)->M = x; @@ -712,23 +712,23 @@ void SPRITE::KillXlat(void) { void SPRITE::Goto(int x, int y) { int xo = X, yo = Y; if (W < SCR_WID) { - if (x < 0) + if (x < 0) x = 0; - if (x + W > SCR_WID) + if (x + W > SCR_WID) x = (SCR_WID - W); X = x; } if (H < SCR_HIG) { - if (y < 0) + if (y < 0) y = 0; - if (y + H > SCR_HIG) + if (y + H > SCR_HIG) y = (SCR_HIG - H); Y = y; } - if (Next) - if (Next->Flags.Slav) + if (Next) + if (Next->Flags.Slav) Next->Goto(Next->X - xo + X, Next->Y - yo + Y); - if (Flags.Shad) + if (Flags.Shad) Prev->Goto(Prev->X - xo + X, Prev->Y - yo + Y); } @@ -766,7 +766,7 @@ void SPRITE::Show(uint16 pg) { void SPRITE::Hide(void) { register SPREXT *e = Ext; - if (e->b0) + if (e->b0) e->b0->Hide(e->x0, e->y0); } @@ -815,7 +815,7 @@ QUEUE::~QUEUE(void) { void QUEUE::Clear(void) { while (Head) { SPRITE *s = Remove(Head); - if (s->Flags.Kill) + if (s->Flags.Kill) delete s; } } @@ -835,12 +835,12 @@ void QUEUE::Append(SPRITE *spr) { if (Tail) { spr->Prev = Tail; Tail->Next = spr; - } else + } else Head = spr; Tail = spr; - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } @@ -849,19 +849,19 @@ void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { if (nxt == Head) { spr->Next = Head; Head = spr; - if (! Tail) + if (! Tail) Tail = spr; } else { spr->Next = nxt; spr->Prev = nxt->Prev; - if (spr->Prev) + if (spr->Prev) spr->Prev->Next = spr; } - if (spr->Next) + if (spr->Next) spr->Next->Prev = spr; - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } @@ -871,25 +871,25 @@ void QUEUE::Insert(SPRITE *spr) { for (s = Head; s; s = s->Next) if (s->Z > spr->Z) break; - if (s) + if (s) Insert(spr, s); - else + else Append(spr); - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } SPRITE *QUEUE::Remove(SPRITE *spr) { - if (spr == Head) + if (spr == Head) Head = spr->Next; - if (spr == Tail) + if (spr == Tail) Tail = spr->Prev; - if (spr->Next) + if (spr->Next) spr->Next->Prev = spr->Prev; - if (spr->Prev) + if (spr->Prev) spr->Prev->Next = spr->Next; spr->Prev = NULL; spr->Next = NULL; @@ -899,8 +899,8 @@ SPRITE *QUEUE::Remove(SPRITE *spr) { SPRITE *QUEUE::Locate(int ref) { SPRITE *spr; - for (spr = Head; spr; spr = spr->Next) - if (spr->Ref == ref) + for (spr = Head; spr; spr = spr->Next) + if (spr->Ref == ref) return spr; return NULL; } @@ -948,7 +948,7 @@ VGA::VGA(int mode) warning("TODO: Fix Copr"); SetStatAdr(); - if (StatAdr != VGAST1_) + if (StatAdr != VGAST1_) ++Mono; if (IsVga()) { OldColors = farnew(DAC, 256); @@ -1194,10 +1194,10 @@ void VGA::Sunset(void) { void VGA::Show(void) { SPRITE *spr = ShowQ.First(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Show(); Update(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Hide(); ++ FrmCnt; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 810e781808..b762268956 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -287,12 +287,12 @@ uint8 Closest(CBLK *pal, CBLK x) { #define f(col, lum) ((((uint16)(col)) << 8) / lum) uint16 i, dif = 0xFFFF, found = 0; uint16 L = x.R + x.G + x.B; - if (!L) + if (!L) ++L; uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); for (i = 0; i < 256; i ++) { uint16 l = pal[i].R + pal[i].G + pal[i].B; - if (! l) + if (! l) ++l; int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l); uint16 D = ((r > R) ? (r - R) : (R - r)) + @@ -303,7 +303,7 @@ uint8 Closest(CBLK *pal, CBLK x) { if (D < dif) { found = i; dif = D; - if (D == 0) + if (D == 0) break; // exact! } } diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index a8da163b33..4287c12d63 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -83,7 +83,7 @@ char *VMGather(CHOICE *list) { if (vmgt) { *vmgt = '\0'; for (cp = list; cp->Text; cp ++) { - if (*vmgt) + if (*vmgt) strcat(vmgt, "|"); strcat(vmgt, cp->Text); ++ h; @@ -104,13 +104,13 @@ VMENU::VMENU(CHOICE *list, int x, int y) Addr = this; delete[] vmgt; Items = 0; - for (cp = list; cp->Text; cp ++) + for (cp = list; cp->Text; cp ++) ++Items; Flags.BDel = true; Flags.Kill = true; - if (x < 0 || y < 0) + if (x < 0 || y < 0) Center(); - else + else Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); VGA::ShowQ.Insert(this, VGA::ShowQ.Last()); Bar = new MENU_BAR(W - 2 * TEXT_HM); @@ -136,9 +136,9 @@ void VMENU::Touch(uint16 mask, int x, int y) { //if if (y >= 0) { n = y / h; - if (n < Items) + if (n < Items) ok = (x >= TEXT_HM && x < W - TEXT_HM/* && y % h < FONT_HIG*/); - else + else n = Items - 1; } diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 46282d2bbe..9b6489afab 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -56,7 +56,7 @@ VFILE::VFILE(const char *name, IOMODE mode) EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; } #ifdef VOL_UPD - else + else Make(name); #endif } @@ -80,7 +80,7 @@ void VFILE::ReadBuff(void) { } BufMark = Dat.File.Mark(); long n = EndMark - BufMark; - if (n > IOBUF_SIZE) + if (n > IOBUF_SIZE) n = IOBUF_SIZE; Lim = Dat.File.Read(Buff, (uint16) n); Ptr = 0; -- cgit v1.2.3 From aa1d8986a698ebf9b740ed1720baff4e5b091613 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 13:13:39 +0200 Subject: CGE: Cleanup: also remove trailing tabs --- engines/cge/bitmap.cpp | 2 +- engines/cge/cfile.cpp | 2 +- engines/cge/general.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 1e5310a8e7..2763c00868 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -125,7 +125,7 @@ BITMAP::BITMAP(const BITMAP &bmp) : W(bmp.W), H(bmp.H), M(NULL), V(NULL) { BITMAP::~BITMAP(void) { if (MemType(M) == FAR_MEM) free(M); - + switch (MemType(V)) { case NEAR_MEM : delete[](uint8 *) V; diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 4fb0988d38..72ec73030f 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -239,7 +239,7 @@ long CFILE::Seek(long pos) { WriteBuff(); else Lim = 0; - + Ptr = 0; return BufMark = IOHAND::Seek(pos); } diff --git a/engines/cge/general.h b/engines/cge/general.h index 7c0bd7f762..1146832623 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -74,7 +74,7 @@ public: COUPLE operator + (COUPLE c) { return COUPLE(A + c.A, B + c.B); } - + void operator += (COUPLE c) { A += c.A; B += c.B; -- cgit v1.2.3 From 9918344cdc596d211c2c03b5c31f669f06c89f0f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 13:44:52 +0200 Subject: CGE: Fix several issues reported by CPPCHECK --- engines/cge/bitmap.cpp | 2 +- engines/cge/cge_main.cpp | 7 +++---- engines/cge/snail.cpp | 3 +-- engines/cge/text.cpp | 2 +- engines/cge/vga13h.cpp | 10 ++++------ engines/cge/vmenu.cpp | 3 +-- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 2763c00868..36723aba28 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -348,7 +348,7 @@ bool BITMAP::SolidAt(int x, int y) { return true; break; } - m += (t == REP) ? 1 : w; + m += ((t == REP) ? 1 : w); } } diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 24964da0fc..64a20293bd 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -668,7 +668,7 @@ static void MiniStep(int stp) { static void PostMiniStep(int stp) { - static int recent = -2; + //static int recent = -2; //TODO Change the SNPOST message send to a special way to send function pointer //if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep); warning("STUB: PostMiniStep()"); @@ -843,7 +843,6 @@ void SwitchCave(int cav) { void SYSTEM::Touch(uint16 mask, int x, int y) { static int pp = 0; void SwitchCave(int cav); - int cav = 0; FunTouch(); @@ -968,7 +967,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { } else { if (Startup) return; - + int cav = 0; InfoLine.Update(NULL); if (y >= WORLD_HIG) { if (x < BUTTON_X) { // select cave? @@ -998,7 +997,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { #ifdef DEBUG if (!HorzLine.Flags.Hide) { if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { - signed char x1, z1; + int8 x1, z1; XZ(x, y).Split(x1, z1); CLUSTER::Map[z1][x1] = 1; SetMapBrick(x1, z1); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index cc52ec63dc..3fedeab04d 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -164,7 +164,6 @@ static void SNGame(SPRITE *spr, int num) { case 2 : { static SPRITE *k = NULL, * k1, * k2, * k3; static int count = 0; - bool hit; if (k == NULL) { k = VGA::ShowQ.Locate(20700); @@ -188,7 +187,7 @@ static void SNGame(SPRITE *spr, int num) { } ///-------------------- SNPOST(SNSETZ, 20700, 0, NULL); - hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15); + bool hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15); if (hit) { if (spr->Ref == 1) { SNPOST(SNSAY, 1, 20003, NULL); // hura! diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 92951196c7..9b79147cff 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -199,7 +199,7 @@ void Say(const char *txt, SPRITE *spr) { } x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2 - sw); if (spr->Ref == 1) - x += (east) ? -10 : 10; // Hero + x += ((east) ? -10 : 10); // Hero Talk->Flags.Kill = true; Talk->Flags.BDel = true; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 3f303e7f29..72831e83cf 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -279,9 +279,9 @@ extern "C" void TimerProc (void) void ENGINE::NewTimer(...) { + /* static SPRITE *spr; static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - /* ___1152_Hz___: SNDMIDIPlay(); @@ -502,9 +502,7 @@ SPRITE *SPRITE::Expand(void) { neacnt = 0, takcnt = 0, maxnow = 0, - maxnxt = 0, - lcnt = 0, - len; + maxnxt = 0; SNAIL::COM *nea = NULL; SNAIL::COM *tak = NULL; @@ -513,9 +511,9 @@ SPRITE *SPRITE::Expand(void) { INI_FILE sprf(fname); if (! OK(sprf)) error("Bad SPR [%s]", fname); - + int len = 0, lcnt = 0; while ((len = sprf.Read((uint8 *)line)) != 0) { - ++ lcnt; + ++lcnt; if (len && line[len - 1] == '\n') line[-- len] = '\0'; if (len == 0 || *line == '.') diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 4287c12d63..4e1a3334bf 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -126,14 +126,13 @@ VMENU::~VMENU(void) { void VMENU::Touch(uint16 mask, int x, int y) { #define h (FONT_HIG + TEXT_LS) - int n = 0; bool ok = false; if (Items) { SPRITE::Touch(mask, x, y); y -= TEXT_VM - 1; - //if + int n = 0; if (y >= 0) { n = y / h; if (n < Items) -- cgit v1.2.3 From 44cf1872e22dc673dde422faa255a1fd7e6e78e8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 18:23:48 +0200 Subject: CGE: Fix one linker error --- engines/cge/general.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index e68533d0b2..03e5126436 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -93,6 +93,8 @@ DAC StdPal[] = {// R G B { 255, 255, 255}, // 255 }; +DRVINFO SNDDrvInfo; + EC void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) { warning("STUB: _fqsort"); } -- cgit v1.2.3 From 1ebe182ba1f707bbc10afb3626a30fed89ceb923 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 14 Jun 2011 23:54:59 +0200 Subject: CGE: Fix the remaining link errors. It now crashes instantly, most likely because of the VGA class --- engines/cge/general.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/general.h | 6 +----- engines/cge/snail.cpp | 5 +++-- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 03e5126436..73e5b4d21f 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -363,5 +363,51 @@ long Timer(void) { warning("STUB: Timer"); return 0; } + +int new_random(int range) { + warning("STUB: new_random(a)"); + return 0; +} + +#define TIMER_INT 0x08 +//void interrupt (* ENGINE::OldTimer) (...) = NULL; + +ENGINE::ENGINE (uint16 tdiv) +{ +/* + // steal timer interrupt + OldTimer = getvect(TIMER_INT); + setvect(TIMER_INT, NewTimer); + + // set turbo-timer mode + asm mov al,0x36 + asm out 0x43,al + asm mov ax,TMR_DIV + asm out 0x40,al + asm mov al,ah + asm out 0x40,al +*/ + warning("STUB: ENGINE::ENGINE"); +} + +ENGINE::~ENGINE (void) +{ +/* + // reset timer + asm mov al,0x36 + asm out 0x43,al + asm xor al,al + asm out 0x40,al + asm out 0x40,al + // bring back timer interrupt + setvect(TIMER_INT, OldTimer); +*/ + warning("STUB: ENGINE::~ENGINE"); +} + +DATACK::~DATACK (void) +{ + if (!e && Buf) free(Buf); +} } // End of namespace CGE diff --git a/engines/cge/general.h b/engines/cge/general.h index 1146832623..1fc8bd0b0b 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -60,10 +60,6 @@ typedef struct { typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); -extern Common::RandomSource randSrc; - -#define new_random(a) (randSrc.getRandomNumber(a)) - class COUPLE { protected: signed char A; @@ -237,7 +233,7 @@ char *dwtom(uint32 val, char * str, int radix, int len); int TakeEnum(const char **tab, const char *txt); Boot *ReadBoot(int drive); long Timer(void); - +int new_random(int range); } // End of namespace CGE #endif diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 3fedeab04d..b2f4648e10 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -905,7 +905,7 @@ static void SNMouse(bool on) { void SNAIL::RunCom(void) { static int count = 1; - extern void SwitchCave(int); +// extern void SwitchCave(int); if (! Busy) { Busy = true; uint8 tmphea = Head; @@ -971,7 +971,8 @@ void SNAIL::RunCom(void) { } break; case SNCAVE : - SwitchCave(snc->Val); + // SwitchCave(snc->Val); + warning("Problematic call of SwitchCave in SNAIL::RunCom"); break; case SNKILL : SNKill(sprel); -- cgit v1.2.3 From 77d5c25472f414c2b0c49a920329a6811d271281 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 18 Jun 2011 08:54:22 +0200 Subject: CGE: Suppress some defines, fix semi-columns in template definitions --- engines/cge/bitmaps.cpp | 2 - engines/cge/bitmaps.h | 3 -- engines/cge/btfile.cpp | 16 +++--- engines/cge/btfile.h | 2 +- engines/cge/cge_main.cpp | 137 +++++++++-------------------------------------- engines/cge/ems.cpp | 2 +- engines/cge/general.h | 8 +-- engines/cge/jbw.h | 22 +------- engines/cge/mouse.cpp | 14 ++--- engines/cge/snail.cpp | 7 ++- engines/cge/startup.cpp | 11 ---- engines/cge/vga13h.cpp | 21 ++------ engines/cge/vga13h.h | 2 +- 13 files changed, 52 insertions(+), 195 deletions(-) diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp index 77012c0488..cabe04b784 100644 --- a/engines/cge/bitmaps.cpp +++ b/engines/cge/bitmaps.cpp @@ -224,7 +224,6 @@ static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 namespace CGE { -#ifdef DEBUG BMP_PTR MB[] = { new BITMAP("BRICK"), NULL @@ -234,7 +233,6 @@ BMP_PTR HL[] = { new BITMAP("HLINE"), NULL }; -#endif BMP_PTR MC[] = { new BITMAP("MOUSE"), diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h index 5023c2e657..5ac878de3c 100644 --- a/engines/cge/bitmaps.h +++ b/engines/cge/bitmaps.h @@ -32,11 +32,8 @@ namespace CGE { -#ifdef DEBUG extern BITMAP *MB[]; extern BITMAP *HL[]; -#endif - extern BITMAP *MC[]; extern BITMAP *PR[]; extern BITMAP *SP[]; diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index b5e59e0988..7bb835f704 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -46,7 +46,7 @@ BTFILE::BTFILE(const char *name, IOMODE mode, CRYPT *crpt) Buff[i].Page = new BT_PAGE; Buff[i].PgNo = BT_NONE; Buff[i].Indx = -1; - Buff[i].Updt = FALSE; + Buff[i].Updt = false; if (Buff[i].Page == NULL) error("No core"); } @@ -65,7 +65,7 @@ void BTFILE::PutPage(int lev, bool hard) { if (hard || Buff[lev].Updt) { Seek(Buff[lev].PgNo * sizeof(BT_PAGE)); Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); - Buff[lev].Updt = FALSE; + Buff[lev].Updt = false; } } @@ -78,12 +78,12 @@ BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) { if (Size() > pos) { Seek((uint32) pgn * sizeof(BT_PAGE)); Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); - Buff[lev].Updt = FALSE; + Buff[lev].Updt = false; } else { Buff[lev].Page->Hea.Count = 0; Buff[lev].Page->Hea.Down = BT_NONE; memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data)); - Buff[lev].Updt = TRUE; + Buff[lev].Updt = true; } Buff[lev].Indx = -1; } @@ -132,17 +132,17 @@ void BTFILE::Make(BT_KEYPACK *keypack, uint16 count) { BT_PAGE *Root = GetPage(0, n++), *Leaf = GetPage(1, n); Root->Hea.Down = n; - PutPage(0, TRUE); + PutPage(0, true); while (count --) { if (Leaf->Hea.Count >= ArrayCount(Leaf->Lea)) { - PutPage(1, TRUE); // save filled page + PutPage(1, true); // save filled page Leaf = GetPage(1, ++n); // take empty page memcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); Root->Inn[Root->Hea.Count ++].Down = n; - Buff[0].Updt = TRUE; + Buff[0].Updt = true; } Leaf->Lea[Leaf->Hea.Count ++] = * (keypack ++); - Buff[1].Updt = TRUE; + Buff[1].Updt = true; } } diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index c55891cae4..3ab4880585 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -73,7 +73,7 @@ class BTFILE : public IOHAND { int Indx; bool Updt; } Buff[BT_LEVELS]; - void PutPage(int lev, bool hard = FALSE); + void PutPage(int lev, bool hard = false); BT_PAGE *GetPage(int lev, uint16 pgn); public: BTFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 64a20293bd..22168fe44c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -59,21 +59,8 @@ namespace CGE { #define STACK_SIZ (K(2)) #define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText) -#ifdef DEMO -#ifdef DEBUG #define SVG0NAME ("{{INIT}}" SVG_EXT) -#else -#define SVG0NAME (ProgName(SVG_EXT)) -#endif -#else -#define SVG0NAME ("{{INIT}}" SVG_EXT) -#endif - -#ifdef DEBUG #define SVG0FILE CFILE -#else -#define SVG0FILE INI_FILE -#endif extern uint16 _stklen = (STACK_SIZ * 2); @@ -152,9 +139,7 @@ extern int FindPocket(SPRITE *); extern DAC StdPal[58]; -#ifdef DEBUG static SPRITE HorzLine = HL; -#endif void FeedSnail(SPRITE *spr, SNLIST snq); // defined in SNAIL uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; @@ -204,7 +189,7 @@ bool CLUSTER::Protected(void) { */ warning("STUB: CLUSTER::Protected()"); - return TRUE; + return true; } @@ -548,8 +533,6 @@ void WALK::Reach(SPRITE *spr, int mode) { } -#ifdef DEBUG - class SQUARE : public SPRITE { public: SQUARE(void); @@ -586,14 +569,11 @@ static void SetMapBrick(int x, int z) { } } -#endif - - void dummy(void) {} static void SwitchMapping(void); static void SwitchColorMode(void); static void StartCountDown(void); -Debug(static void SwitchDebug(void);) +static void SwitchDebug(void); static void SwitchMusic(void); static void KillSprite(void); static void PushSprite(void); @@ -642,13 +622,6 @@ static void Quit(void) { static void AltCtrlDel(void) { -#if 0 - //def DEBUG - if (KEYBOARD::Key[LSHIFT] || KEYBOARD::Key[RSHIFT]) { - PostFlag = 0x1234; - POST(); - } else -#endif SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero); } @@ -774,18 +747,18 @@ static void CaveUp(void) { static void CaveDown(void) { SPRITE *spr; - Debug(if (! HorzLine.Flags.Hide) SwitchMapping();) + if (! HorzLine.Flags.Hide) + SwitchMapping(); - for (spr = VGA::ShowQ.First(); spr;) { - SPRITE *n = spr->Next; - if (spr->Ref >= 1000 /*&& spr->Cave*/) { - if (spr->Ref % 1000 == 999) - FeedSnail(spr, TAKE); - - VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); - } - spr = n; + for (spr = VGA::ShowQ.First(); spr;) { + SPRITE *n = spr->Next; + if (spr->Ref >= 1000 /*&& spr->Cave*/) { + if (spr->Ref % 1000 == 999) + FeedSnail(spr, TAKE); + VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); } + spr = n; + } Text.Clear(1000); } @@ -857,10 +830,11 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { pp0 = pp; switch (x) { case Del: - if (KEYBOARD::Key[ALT] && - KEYBOARD::Key[CTRL]) AltCtrlDel(); - Debug(else KillSprite();) - break; + if (KEYBOARD::Key[ALT] && KEYBOARD::Key[CTRL]) + AltCtrlDel(); + else + KillSprite(); + break; case 'F': if (KEYBOARD::Key[ALT]) { SPRITE *m = VGA::ShowQ.Locate(17001); @@ -870,8 +844,6 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { } } break; - -#ifdef DEBUG case PgUp: PushSprite(); break; @@ -932,19 +904,6 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (Sprite) Sprite->Step(x - '0'); break; -#else - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - SelectPocket(x - '1'); - break; -#endif - case F10 : if (Snail.Idle() && ! Hero->Flags.Hide) StartCountDown(); @@ -994,7 +953,6 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (cav && Snail.Idle() && Hero->TracePtr < 0) SwitchCave(cav); -#ifdef DEBUG if (!HorzLine.Flags.Hide) { if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { int8 x1, z1; @@ -1003,7 +961,6 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { SetMapBrick(x1, z1); } } else -#endif { if (! Talk && Snail.Idle() && Hero && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && ! Game) { @@ -1119,7 +1076,6 @@ static void TakeName(void) { #endif -#ifdef DEBUG static void SwitchMapping(void) { if (HorzLine.Flags.Hide) { int i; @@ -1200,10 +1156,6 @@ static void SaveMapping(void) { } } -#endif - - -#ifdef DEBUG // 1111111111222222222233333333 334444444444555555555566666666667777777777 // 01234567890123456789012345678901234567 890123456789012345678901234567890123456789 static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 000:000:000 000:000 00 "; @@ -1272,8 +1224,6 @@ static void SwitchDebug(void) { DebugLine.Flags.Hide = ! DebugLine.Flags.Hide; } -#endif - static void OptionTouch(int opt, uint16 mask) { switch (opt) { @@ -1304,7 +1254,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { if ((mask & ATTN) == 0) { InfoLine.Update(Name()); if (mask & (R_DN | L_DN)) - Sprite = this; // DEBUG mode only? + Sprite = this; if (Ref / 10 == 12) { OptionTouch(Ref % 10, mask); return; @@ -1582,50 +1532,20 @@ static void LoadScript(const char *fname) { static void MainLoop(void) { -#if 0 -//def DEBUG - static VgaRegBlk Mode[] = { - - { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode - - { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 - { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 - { 0x06, VGAGRA, 0x02, 0x00 }, // misc - - { 0x14, VGACRT, 0x40, 0x00 }, // underline - { 0x13, VGACRT, 0xFF, 0x28 }, // screen width - { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control - - { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end - { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line - - { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode - -// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end -// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb -// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr - - { 0x00 } - }; - - Vga.Setup(Mode); -#endif - - Debug(SayDebug();) + SayDebug(); #ifdef DEMO -#define TIM ((182L*6L) * 5L) static uint32 tc = 0; - if (TimerCount - tc >= TIM && Talk == NULL && Snail.Idle()) { + if (/* FIXME: TimerCount - tc >= ((182L*6L) * 5L) && */ Talk == NULL && Snail.Idle()) { if (Text[DemoText]) { SNPOST(SNSOUND, -1, 4, NULL); // drumla SNPOST(SNINF, -1, DemoText, NULL); SNPOST(SNLABEL, -1, -1, NULL); - if (Text[++ DemoText] == NULL) DemoText = DEMO_TEXT + 1; + if (Text[++ DemoText] == NULL) + DemoText = DEMO_TEXT + 1; } - tc = TimerCount; + //FIXME: tc = TimerCount; } -#undef TIM #endif Vga.Show(); @@ -1727,14 +1647,12 @@ static void RunGame(void) { InfoLine.Update(NULL); VGA::ShowQ.Insert(&InfoLine); -#ifdef DEBUG DebugLine.Z = 126; VGA::ShowQ.Insert(&DebugLine); HorzLine.Y = MAP_TOP - (MAP_TOP > 0); HorzLine.Z = 126; VGA::ShowQ.Insert(&HorzLine); -#endif Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF); if (Mouse.Busy) @@ -1897,13 +1815,10 @@ bool ShowTitle(const char *name) { /* -#ifdef DEBUG -void StkDump (void) -{ +void StkDump (void) { CFILE f("!STACK.DMP", BFW); f.Write((uint8 *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2); } -#endif */ @@ -1920,8 +1835,8 @@ void cge_main(void) { if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; - Debug(DebugLine.Flags.Hide = true;) - Debug(HorzLine.Flags.Hide = true;) + DebugLine.Flags.Hide = true; + HorzLine.Flags.Hide = true; //srand((uint16) Timer()); Sys = new SYSTEM; diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index 7b0697cd8a..c21bc356dc 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -127,7 +127,7 @@ bool EMM::Test(void) { return FALSE; */ warning("EMM::Test"); - return FALSE; + return false; } diff --git a/engines/cge/general.h b/engines/cge/general.h index 1fc8bd0b0b..c1c417c237 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -146,19 +146,19 @@ void Swap(T &A, T &B) { T a = A; A = B; B = a; -}; +} #ifdef __cplusplus template T max(T A, T B) { return (A > B) ? A : B; -}; +} template T min(T A, T B) { return (A < B) ? A : B; -}; +} #endif @@ -179,7 +179,7 @@ public: template inline uint16 XRead(XFILE *xf, T *t) { return xf->Read((uint8 *) t, sizeof(*t)); -}; +} class IOHAND : public XFILE { diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 73131d71e3..4a341fbbb7 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -33,8 +33,8 @@ namespace CGE { // Defines found in cge.mak -#define DEBUG #define VOL +//#define DEMO #define INI_FILE VFILE // Or is it CFILE? #define PIC_FILE VFILE #define BMP_MODE 0 @@ -46,15 +46,8 @@ namespace CGE { #define LF 10 #define FF 12 #define CR 13 - -#define TRUE 1 -#define FALSE 0 - #define MAXFILE 128 - -#define NULL 0 -#define OFF false -#define ON true +#define NULL 0 #define IsWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') #define IsUpper(c) ((c) >= 'A' && (c) <= 'Z') @@ -148,17 +141,6 @@ struct KeyStatStruct { #define BreakFlag (* ((volatile uint8 *) ((void _seg *) 0x40 + (void *) 0x71))) #define PostFlag (* ((volatile uint16 *) ((void _seg *) 0x40 + (void *) 0x72))) #define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0)) -#define SLIF if (KeyStat.ScrollLock) - -#define FOR(i,n) for(i = 0; i < (n); i++) - -#define TRAP(x) { warning("STUB: TRAP"); /*if (x) asm { int 3 } */ } - -#ifdef DEBUG -#define Debug(x) x -#else -#define Debug(x) -#endif #ifdef DEMO #define Demo(x) x diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 9bb9626deb..601d02999f 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -167,13 +167,8 @@ void MOUSE::Tick(void) { Hold = e.Ptr; if (Hold) { Hold->Flags.Hold = true; -#ifndef DEBUG - if (Hold->Flags.Drag) -#endif - { - hx = e.X - Hold->X; - hy = e.Y - Hold->Y; - } + hx = e.X - Hold->X; + hy = e.Y - Hold->Y; } } @@ -192,10 +187,7 @@ void MOUSE::Tick(void) { EvtTail = (EvtTail + 1) % EVT_MAX; } if (Hold) -#ifndef DEBUG - if (Hold->Flags.Drag) -#endif - Hold->Goto(X - hx, Y - hy); + Hold->Goto(X - hx, Y - hy); } } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index b2f4648e10..382b6dbc62 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -90,8 +90,7 @@ static void SNGame(SPRITE *spr, int num) { ++ Stage; if (hand && Stage > DRESSED) ++hand; - if (Debug(i >= 0 ||) - dup[i] == spr && new_random(3) == 0) { + if (i >= 0 || dup[i] == spr && new_random(3) == 0) { SNPOST(SNSEQ, -1, 3, dup[0]); // yes SNPOST(SNSEQ, -1, 3, dup[1]); // yes SNPOST(SNSEQ, -1, 3, dup[2]); // yes @@ -629,7 +628,7 @@ void SNCover(SPRITE *spr, int xref) { xspr->Cave = spr->Cave; xspr->Goto(spr->X, spr->Y); ExpandSprite(xspr); - if ((xspr->Flags.Shad = spr->Flags.Shad) == TRUE) { + if ((xspr->Flags.Shad = spr->Flags.Shad) == 1) { VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr); spr->Flags.Shad = false; } @@ -643,7 +642,7 @@ void SNUncover(SPRITE *spr, SPRITE *xspr) { spr->Flags.Hide = false; spr->Cave = xspr->Cave; spr->Goto(xspr->X, xspr->Y); - if ((spr->Flags.Shad = xspr->Flags.Shad) == TRUE) { + if ((spr->Flags.Shad = xspr->Flags.Shad) == 1) { VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr); xspr->Flags.Shad = false; } diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 24aaf3e042..10967afbc4 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -35,10 +35,7 @@ #include #include #include - -#ifdef DEBUG #include -#endif namespace CGE { @@ -124,14 +121,6 @@ STARTUP::STARTUP(void) { if (Cpu() < _80286) quit_now(BAD_CHIP_TEXT); if (100 * _osmajor + _osminor < 330) quit_now(BAD_DOS_TEXT); - #ifndef DEBUG - if (Core < CORE_LOW) quit_now(NO_CORE_TEXT); - if (Core < CORE_HIG) - { - SNDDrvInfo.MDEV = DEV_QUIET; - Music = false; - } - #endif if (! get_parms()) quit_now(BAD_ARG_TEXT); //--- load sound configuration const char * fn = UsrPath(ProgName(CFG_EXT)); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 72831e83cf..c1587fa45a 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -40,25 +40,14 @@ namespace CGE { -#ifdef DEBUG -#define REPORT -#endif - -#define OK(f) ((f).Error==0) #define FADE_STEP 2 - #define TMR_DIV ((0x8000/TMR_RATE)*2) - //-------------------------------------------------------------------------- -#ifdef REPORT static char Report[] = "NearHeap=..... FarHeap=......\n"; #define NREP 9 #define FREP 24 -#endif - - static VgaRegBlk VideoMode[] = { @@ -377,7 +366,6 @@ BMP_PTR SPRITE::Shp(void) { if (e) if (e->Seq) { int i = e->Seq[SeqPtr].Now; -#ifdef DEBUG if (i >= ShpCnt) { //char s[256]; //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", @@ -385,7 +373,6 @@ BMP_PTR SPRITE::Shp(void) { //VGA::Exit(s, File); error("Invalid PHASE in SPRITE::Shp() %s", File); } -#endif return e->ShpList[i]; } return NULL; @@ -509,7 +496,7 @@ SPRITE *SPRITE::Expand(void) { MergeExt(fname, File, SPR_EXT); if (INI_FILE::Exist(fname)) { // sprite description file exist INI_FILE sprf(fname); - if (! OK(sprf)) + if (! (sprf.Error==0)) error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; while ((len = sprf.Read((uint8 *)line)) != 0) { @@ -936,14 +923,12 @@ VGA::VGA(int mode) if (txt) { // puts(txt); warning(txt); -#ifndef DEBUG std = false; -#endif } } -// if (std) + if (std) // warning(Copr); - warning("TODO: Fix Copr"); + warning("TODO: Fix Copr"); SetStatAdr(); if (StatAdr != VGAST1_) diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index b762268956..2660274c23 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -309,7 +309,7 @@ uint8 Closest(CBLK *pal, CBLK x) { } return found; #undef f -}; +} -- cgit v1.2.3 From 3871c71f0e6f5202e935ac7119fefedde1f8e449 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sun, 19 Jun 2011 07:59:37 +0200 Subject: CGE: Fix compilation under GCC Unfortunately, I had to stub a few things but this all looks like code that will have to be rewritten later anyway. --- engines/cge/bitmap.cpp | 1 - engines/cge/btfile.cpp | 2 ++ engines/cge/btfile.h | 9 +++++---- engines/cge/cfile.cpp | 1 - engines/cge/cfile.h | 1 - engines/cge/cge_main.cpp | 3 --- engines/cge/cge_main.h | 4 ++-- engines/cge/game.cpp | 1 - engines/cge/general.cpp | 17 +++++++++++++++++ engines/cge/general.h | 9 ++++----- engines/cge/jbw.h | 1 - engines/cge/keybd.cpp | 1 - engines/cge/mouse.cpp | 1 - engines/cge/snail.cpp | 9 ++++++++- engines/cge/startup.cpp | 2 -- engines/cge/talk.cpp | 1 - engines/cge/text.cpp | 1 - engines/cge/vga13h.cpp | 3 --- engines/cge/vga13h.h | 2 +- engines/cge/wav.h | 2 +- 20 files changed, 40 insertions(+), 31 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 36723aba28..b528b5578d 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -29,7 +29,6 @@ #include "cge/cfile.h" #include "cge/jbw.h" #include "cge/vol.h" -#include #include "cge/cfile.h" #include "common/system.h" diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 7bb835f704..3cdb3c7199 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -90,6 +90,8 @@ BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) { return Buff[lev].Page; } +// Does this work, or does it have to compare the entire buffer? +#define memicmp(s1, s2, n) scumm_strnicmp((const char *)s1, (const char *)s2, n) BT_KEYPACK *BTFILE::Find(const char *key) { int lev = 0; diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 3ab4880585..6e6398f4de 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -46,6 +46,10 @@ struct BT_KEYPACK { uint16 Size; }; +typedef struct { + uint8 Key[BT_KEYLEN]; + uint16 Down; +} INNER; struct BT_PAGE { struct HEA { @@ -56,10 +60,7 @@ struct BT_PAGE { // dummy filler to make proper size of union uint8 Data[BT_SIZE - sizeof(HEA)]; // inner version of data: key + word-sized page link - struct INNER { - uint8 Key[BT_KEYLEN]; - uint16 Down; - } Inn[(BT_SIZE - sizeof(HEA)) / sizeof(INNER)]; + INNER Inn[(BT_SIZE - sizeof(HEA)) / sizeof(INNER)]; // leaf version of data: key + all user data BT_KEYPACK Lea[(BT_SIZE - sizeof(HEA)) / sizeof(BT_KEYPACK)]; }; diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 72ec73030f..da56587ebe 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -26,7 +26,6 @@ */ #include "cge/cfile.h" -#include #include #include #include "common/system.h" diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index d2d5320ae5..f045c48c0f 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -29,7 +29,6 @@ #define __CFILE__ #include "cge/general.h" -#include namespace CGE { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 22168fe44c..8cfa3a1cf6 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -44,13 +44,10 @@ #include "cge/gettext.h" #include "cge/mixer.h" #include "cge/cge_main.h" -#include #include #include #include -#include #include -#include #include "common/str.h" diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index fa27274803..3c9fede6fb 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -28,8 +28,8 @@ #ifndef __CGE__ #define __CGE__ -#include "cge\wav.h" -#include "cge\vga13h.h" +#include "cge/wav.h" +#include "cge/vga13h.h" namespace CGE { diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 4102e080b6..655cfbe4ec 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -28,7 +28,6 @@ #include "cge/game.h" #include "cge/mouse.h" #include -#include namespace CGE { diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 73e5b4d21f..e547921bb5 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -251,22 +251,39 @@ uint16 IOHAND::Write(void *buf, uint16 len) { } long IOHAND::Mark(void) { + /* return (Handle < 0) ? 0 : tell(Handle); + */ + warning("STUB: IOHAND::Mark"); + return 0; } long IOHAND::Seek(long pos) { + /* if (Handle < 0) return 0; lseek(Handle, pos, SEEK_SET); return tell(Handle); + */ + warning("STUB: IOHAND::Seek"); + return 0; } long IOHAND::Size(void) { + /* if (Handle < 0) return 0; + return filelength(Handle); + */ + warning("STUB: IOHAND::Size"); + return 0; } bool IOHAND::Exist(const char *name) { + /* return access(name, 0) == 0; + */ + warning("STUB: IOHAND::Exist"); + return 0; } //#define EMS_ADR(a) (FP_SEG(a) > 0xA000) diff --git a/engines/cge/general.h b/engines/cge/general.h index c1c417c237..16b0c1e2bf 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -33,7 +33,6 @@ #include "common/textconsole.h" #include "common/str.h" #include "cge/jbw.h" -#include #include "cge/boot.h" namespace CGE { @@ -114,22 +113,22 @@ class EMS; class EMM { - friend EMS; + friend class EMS; bool Test(void); long Top, Lim; EMS *List; int Han; static void *Frame; public: - EMM::EMM(long size = 0); - EMM::~EMM(void); + EMM(long size = 0); + ~EMM(void); EMS *Alloc(uint16 siz); void Release(void); }; class EMS { - friend EMM; + friend class EMM; EMM *Emm; long Ptr; uint16 Siz; diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 4a341fbbb7..82647ed49a 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -47,7 +47,6 @@ namespace CGE { #define FF 12 #define CR 13 #define MAXFILE 128 -#define NULL 0 #define IsWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') #define IsUpper(c) ((c) >= 'A' && (c) <= 'Z') diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index 35e6c72c11..c912555949 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -27,7 +27,6 @@ #include "cge/keybd.h" #include "cge/mouse.h" -#include namespace CGE { diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 601d02999f..78e686ff95 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -27,7 +27,6 @@ #include "cge/mouse.h" #include "cge/text.h" -#include namespace CGE { diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 382b6dbc62..ec1fae515c 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -33,13 +33,20 @@ #include "cge/text.h" #include "cge/mouse.h" #include "cge/cge_main.h" -#include #include #include #include "cge/keybd.h" namespace CGE { +static void _enable() { + warning("STUB: _enable"); +} + +static void _disable() { + warning("STUB: _disable"); +} + int MaxCave = 0; SCB Scb = { NULL, 0, NULL }; diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 10967afbc4..e534e04257 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -32,8 +32,6 @@ #include "cge/cfile.h" #include "cge/snddrv.h" #include -#include -#include #include #include diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index e707e4e705..f4c0c1ac27 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -30,7 +30,6 @@ #include "cge/vol.h" #include "cge/game.h" #include "cge/mouse.h" -#include namespace CGE { diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 9b79147cff..3695c955f5 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -35,7 +35,6 @@ #include #include #include -#include namespace CGE { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index c1587fa45a..a7dd76273d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -30,13 +30,10 @@ #include "cge/bitmap.h" #include "cge/vol.h" #include "cge/text.h" -#include #include #include #include -#include #include -#include namespace CGE { diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 2660274c23..19453a4523 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -129,7 +129,7 @@ extern SEQ Seq2[]; class HEART : public ENGINE { - friend ENGINE; + friend class ENGINE; public: static bool Enable; static uint16 *XTimer; diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 6d46769cf9..304c2827d8 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -95,7 +95,7 @@ class FMTCK : public CKHEA { } Wav; union { - struct PCM { + struct { uint16 wBitsPerSample; // Sample size } Pcm; }; -- cgit v1.2.3 From ac3d66d3dd56837d55e9ba42a1d2f9481e7846c8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 19 Jun 2011 10:09:25 +0200 Subject: CGE: (Eriktorbjorn) Fix compilation for GCC --- engines/cge/btfile.cpp | 2 +- engines/cge/game.cpp | 1 - engines/cge/general.cpp | 50 ++++++++++++++++++++++++++----------------------- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 3cdb3c7199..0552e78c1c 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -92,7 +92,7 @@ BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) { // Does this work, or does it have to compare the entire buffer? #define memicmp(s1, s2, n) scumm_strnicmp((const char *)s1, (const char *)s2, n) - + BT_KEYPACK *BTFILE::Find(const char *key) { int lev = 0; uint16 nxt = BT_ROOT; diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 655cfbe4ec..58334f2e53 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -29,7 +29,6 @@ #include "cge/mouse.h" #include - namespace CGE { uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b) { diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index e547921bb5..7e1653f61a 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -237,51 +237,55 @@ uint16 IOHAND::Read(void *buf, uint16 len) { } uint16 IOHAND::Write(void *buf, uint16 len) { - /* - if (len) { - if (Mode == REA || Handle < 0) return 0; - if (Crypt) Seed = Crypt(buf, len, Seed); - Error = _dos_write(Handle, buf, len, &len); - if (Crypt) Seed = Crypt(buf, len, Seed); //------$$$$$$$ - } - return len; - */ +/* + if (len) { + if (Mode == REA || Handle < 0) + return 0; + if (Crypt) + Seed = Crypt(buf, len, Seed); + Error = _dos_write(Handle, buf, len, &len); + if (Crypt) + Seed = Crypt(buf, len, Seed); //------$$$$$$$ + } + return len; +*/ warning("STUB: IOHAND::Write"); return 0; } long IOHAND::Mark(void) { - /* - return (Handle < 0) ? 0 : tell(Handle); - */ +/* + return (Handle < 0) ? 0 : tell(Handle); +*/ warning("STUB: IOHAND::Mark"); return 0; } long IOHAND::Seek(long pos) { - /* - if (Handle < 0) return 0; - lseek(Handle, pos, SEEK_SET); - return tell(Handle); - */ +/* + if (Handle < 0) + return 0; + lseek(Handle, pos, SEEK_SET); + return tell(Handle); +*/ warning("STUB: IOHAND::Seek"); return 0; } long IOHAND::Size(void) { - /* - if (Handle < 0) return 0; - +/* + if (Handle < 0) + return 0; return filelength(Handle); - */ +*/ warning("STUB: IOHAND::Size"); return 0; } bool IOHAND::Exist(const char *name) { - /* +/* return access(name, 0) == 0; - */ +*/ warning("STUB: IOHAND::Exist"); return 0; } -- cgit v1.2.3 From 78e3f2a57bc0442066e00c9b625bbdde3c80ddf9 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sun, 19 Jun 2011 11:17:54 +0200 Subject: CGE: Get rid of some static initializing ScummVM itself (not the engine; I haven't tried that) now starts without crashing. It exits immediately, but as far as I can tell it does not crash. It still produces lots of Valgrind warnings, though... --- engines/cge/cge.cpp | 5 +++++ engines/cge/cge_main.cpp | 56 ++++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 3 +++ engines/cge/config.cpp | 10 ++++----- engines/cge/gettext.cpp | 4 ++-- engines/cge/mixer.cpp | 2 +- engines/cge/snail.cpp | 4 ++-- engines/cge/startup.cpp | 2 +- engines/cge/talk.cpp | 18 +++++++--------- engines/cge/talk.h | 2 +- engines/cge/text.cpp | 10 ++++----- engines/cge/text.h | 4 ++-- engines/cge/vga13h.cpp | 2 +- 13 files changed, 64 insertions(+), 58 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 0d0df4ea9c..8b3bea3eb5 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -31,6 +31,7 @@ #include "engines/util.h" #include "cge/cge.h" #include "cge/cge_main.h" +#include "cge/text.h" namespace CGE { @@ -39,6 +40,10 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); _console = new CGEConsole(this); + Text = new TEXT(ProgName()); + Vga = new VGA(M13H); + + OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); debug("CGEEngine::CGEEngine"); } diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 8cfa3a1cf6..6472cdef0b 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -117,14 +117,14 @@ static SPRITE *Sprite = NULL; static SPRITE *MiniCave = NULL; static SPRITE *Shadow = NULL; -static VGA Vga = M13H; +VGA *Vga; static EMS *Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE); static BMP_PTR *MiniShpList = NULL; static BMP_PTR MiniShp[] = { NULL, NULL }; static KEYBOARD Keyboard; static bool Finis = false; static int Startup = 1; -static int OffUseCount = atoi(Text[OFF_USE_COUNT]); +int OffUseCount; uint16 *intStackPtr = false; @@ -248,7 +248,7 @@ static void LoadGame(XFILE &file, bool tiny = false) { file.Read((uint8 *) &i, sizeof(i)); if (i != SVGCHKSUM) - error(Text[BADSVG_TEXT]); + error(Text->getText(BADSVG_TEXT)); if (STARTUP::Core < CORE_HIG) Music = false; @@ -608,9 +608,9 @@ static void Quit(void) { SNPOST_(SNKILL, -1, 0, VMENU::Addr); ResetQSwitch(); } else { - QuitMenu[0].Text = Text[QUIT_TEXT]; - QuitMenu[1].Text = Text[NOQUIT_TEXT]; - (new VMENU(QuitMenu, -1, -1))->SetName(Text[QUIT_TITLE]); + QuitMenu[0].Text = Text->getText(QUIT_TEXT); + QuitMenu[1].Text = Text->getText(NOQUIT_TEXT); + (new VMENU(QuitMenu, -1, -1))->SetName(Text->getText(QUIT_TITLE)); SNPOST_(SNSEQ, 123, 1, NULL); KeyClick(); } @@ -687,7 +687,7 @@ static void CaveUp(void) { ShowBak(BakRef); LoadMapping(); - Text.Preload(BakRef, BakRef + 1000); + Text->Preload(BakRef, BakRef + 1000); SPRITE *spr = VGA::SpareQ.First(); while (spr) { SPRITE *n = spr->Next; @@ -716,7 +716,7 @@ static void CaveUp(void) { } if (! Dark) - Vga.Sunset(); + Vga->Sunset(); VGA::CopyPage(0, 1); SelectPocket(-1); @@ -730,10 +730,10 @@ static void CaveUp(void) { Shadow->Z = Hero->Z; } FeedSnail(VGA::ShowQ.Locate(BakRef + 999), TAKE); - Vga.Show(); - Vga.CopyPage(1, 0); - Vga.Show(); - Vga.Sunrise(SysPal); + Vga->Show(); + Vga->CopyPage(1, 0); + Vga->Show(); + Vga->Sunrise(SysPal); Dark = false; if (! Startup) Mouse.On(); @@ -756,7 +756,7 @@ static void CaveDown(void) { } spr = n; } - Text.Clear(1000); + Text->Clear(1000); } @@ -772,7 +772,7 @@ static void QGame(void) { SaveSound(); CFILE file = CFILE(UsrPath(UsrFnam), WRI, RCrypt); SaveGame(file); - Vga.Sunset(); + Vga->Sunset(); Finis = true; } @@ -1060,9 +1060,9 @@ static void TakeName(void) { if (GET_TEXT::Ptr) SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr); else { - GET_TEXT *tn = new GET_TEXT(Text[GETNAME_PROMPT], UsrFnam, 8, KeyClick); + GET_TEXT *tn = new GET_TEXT(Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick); if (tn) { - tn->SetName(Text[GETNAME_TITLE]); + tn->SetName(Text->getText(GETNAME_TITLE)); tn->Center(); tn->Goto(tn->X, tn->Y - 10); tn->Z = 126; @@ -1183,7 +1183,7 @@ static void SayDebug(void) { if (t1 - t >= 18) { static uint32 old = 0L; - uint32 now = Vga.FrmCnt; + uint32 now = Vga->FrmCnt; dwtom(now - old, FRPS, 10, 4); old = now; t = t1; @@ -1534,18 +1534,18 @@ static void MainLoop(void) { #ifdef DEMO static uint32 tc = 0; if (/* FIXME: TimerCount - tc >= ((182L*6L) * 5L) && */ Talk == NULL && Snail.Idle()) { - if (Text[DemoText]) { + if (Text->getText(DemoText)) { SNPOST(SNSOUND, -1, 4, NULL); // drumla SNPOST(SNINF, -1, DemoText, NULL); SNPOST(SNLABEL, -1, -1, NULL); - if (Text[++ DemoText] == NULL) + if (Text->getText(++ DemoText) == NULL) DemoText = DEMO_TEXT + 1; } //FIXME: tc = TimerCount; } #endif - Vga.Show(); + Vga->Show(); Snail_.RunCom(); Snail.RunCom(); } @@ -1573,8 +1573,8 @@ void LoadUser(void) { static void RunGame(void) { - Text.Clear(); - Text.Preload(100, 1000); + Text->Clear(); + Text->Preload(100, 1000); LoadHeroXY(); CavLight.Flags.Tran = true; @@ -1722,11 +1722,11 @@ bool ShowTitle(const char *name) { Talk->Show(2); } - Vga.Sunset(); + Vga->Sunset(); VGA::CopyPage(1, 2); VGA::CopyPage(0, 1); SelectPocket(-1); - Vga.Sunrise(SysPal); + Vga->Sunrise(SysPal); if (STARTUP::Mode < 2 && ! STARTUP::SoundOk) { VGA::CopyPage(1, 2); @@ -1788,7 +1788,7 @@ bool ShowTitle(const char *name) { CFILE file = CFILE(n, REA, RCrypt); LoadGame(file, true); // only system vars VGA::SetColors(SysPal, 64); - Vga.Update(); + Vga->Update(); if (FINIS) { ++ STARTUP::Mode; FINIS = false; @@ -1828,7 +1828,7 @@ void cge_main(void) { memset(Barriers, 0xFF, sizeof(Barriers)); if (! Mouse.Exist) - error("%s", Text[NO_MOUSE_TEXT]); + error("%s", Text->getText(NO_MOUSE_TEXT)); if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; @@ -1851,8 +1851,8 @@ void cge_main(void) { if (FINIS) Movie("X03"); } else - Vga.Sunset(); - error("%s", Text[EXIT_OK_TEXT + FINIS]); + Vga->Sunset(); + error("%s", Text->getText(EXIT_OK_TEXT + FINIS)); } } // End of namespace CGE diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 3c9fede6fb..fe50e7bab3 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -169,6 +169,9 @@ void ExpandSprite(SPRITE *spr); void ContractSprite(SPRITE *spr); void cge_main(void); +extern VGA *Vga; +extern int OffUseCount; + } // End of namespace CGE #endif diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 1900093520..9ffda8d635 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -159,11 +159,11 @@ void SelectSound(void) { Sound.Close(); if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); - Inf(Text[STYPE_TEXT]); + Inf(Text->getText(STYPE_TEXT)); Talk->Goto(Talk->X, FONT_HIG / 2); for (i = 0; i < ArrayCount(DevName); i ++) - DevMenu[i].Text = Text[DevName[i]]; - (new VMENU(DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text[MENU_TEXT]); + DevMenu[i].Text = Text->getText(DevName[i]); + (new VMENU(DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); } @@ -196,9 +196,9 @@ static CHOICE *Cho; static int Hlp; static void SNSelect(void) { - Inf(Text[Hlp]); + Inf(Text->getText(Hlp)); Talk->Goto(Talk->X, FONT_HIG / 2); - (new VMENU(Cho, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text[MENU_TEXT]); + (new VMENU(Cho, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); } diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 4399a30916..e11f4ff308 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -38,7 +38,7 @@ GET_TEXT *GET_TEXT::Ptr = NULL; GET_TEXT::GET_TEXT(const char *info, char *text, int size, void (*click)(void)) : Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)) { - int i = 2 * TEXT_HM + Font.Width(info); + int i = 2 * TEXT_HM + Font->Width(info); Ptr = this; Mode = RECT; TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); @@ -106,7 +106,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { if (p) x = ogon[p - bezo]; } - if (Len < Size && 2 * TEXT_HM + Font.Width(Buff) + Font.Wid[x] <= W) { + if (Len < Size && 2 * TEXT_HM + Font->Width(Buff) + Font->Wid[x] <= W) { Buff[Len + 2] = Buff[Len + 1]; Buff[Len + 1] = Buff[Len]; Buff[Len ++] = x; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 83d9cd1be5..5b65eee9ca 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -44,7 +44,7 @@ MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { mb[0] = new BITMAP("VOLUME"); mb[1] = NULL; SetShapeList(mb); - SetName(Text[MIX_NAME]); + SetName(Text->getText(MIX_NAME)); Flags.Syst = true; Flags.Kill = true; Flags.BDel = true; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index ec1fae515c..29ab11a36e 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -959,13 +959,13 @@ void SNAIL::RunCom(void) { if (sprel && TalkEnable) { if (sprel == Hero && sprel->SeqTest(-1)) sprel->Step(HTALK); - Say(Text[snc->Val], sprel); + Say(Text->getText(snc->Val), sprel); SYSTEM::FunDel = HEROFUN0; } break; case SNINF : if (TalkEnable) { - Inf(Text[snc->Val]); + Inf(Text->getText(snc->Val)); SYSTEM::FunDel = HEROFUN0; } break; diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index e534e04257..631a64d732 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -54,7 +54,7 @@ uint16 STARTUP::Summa; void quit_now(int ref) { - error("%d\n", Text[ref]); + error("%s", Text->getText(ref)); } diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index f4c0c1ac27..1739511a49 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -97,14 +97,12 @@ void FONT::Save(void) { */ -FONT TALK::Font(ProgName()); - - TALK::TALK(const char *tx, TBOX_STYLE mode) : SPRITE(NULL), Mode(mode) { TS[0] = TS[1] = NULL; Flags.Syst = true; Update(tx); + Font = new FONT(ProgName()); } @@ -144,7 +142,7 @@ void TALK::Update(const char *tx) { mw = k; k = 2 * hmarg; } else - k += Font.Wid[*p]; + k += Font->Wid[*p]; } if (k > mw) mw = k; @@ -157,8 +155,8 @@ void TALK::Update(const char *tx) { if (*tx == '|' || *tx == '\n') m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; else { - int cw = Font.Wid[*tx], i; - uint8 *f = Font.Map + Font.Pos[*tx]; + int cw = Font->Wid[*tx], i; + uint8 *f = Font->Map + Font->Pos[*tx]; for (i = 0; i < cw; i++) { uint8 *p = m; uint16 n; @@ -255,8 +253,8 @@ void TALK::PutLine(int line, const char *text) { q = v + size; while (* text) { - uint16 cw = Font.Wid[*text], i; - uint8 *fp = Font.Map + Font.Pos[*text]; + uint16 cw = Font->Wid[*text], i; + uint8 *fp = Font->Map + Font->Pos[*text]; for (i = 0; i < cw; i ++) { register uint16 b = fp[i]; @@ -303,8 +301,8 @@ void INFO_LINE::Update(const char *tx) { uint8 *p = v + 2, * q = p + size; while (*tx) { - uint16 cw = Font.Wid[*tx]; - uint8 *fp = Font.Map + Font.Pos[*tx]; + uint16 cw = Font->Wid[*tx]; + uint8 *fp = Font->Map + Font->Pos[*tx]; for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 568fd82964..67b4fc91d6 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -74,7 +74,7 @@ protected: BITMAP *TS[2]; BITMAP *Box(uint16 w, uint16 h); public: - static FONT Font; + FONT *Font; TALK(const char *tx, TBOX_STYLE mode = PURE); TALK(void); //~TALK (void); diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 3695c955f5..bbb69839dd 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -38,7 +38,7 @@ namespace CGE { -TEXT Text = ProgName(); +TEXT *Text; TALK *Talk = NULL; TEXT::TEXT(const char *fname, int size) { @@ -163,7 +163,7 @@ char *TEXT::Load(int idx, int ref) { } -char *TEXT::operator [](int ref) { +char *TEXT::getText(int ref) { int i; if ((i = Find(ref)) < Size) return Cache[i].Txt; @@ -202,7 +202,7 @@ void Say(const char *txt, SPRITE *spr) { Talk->Flags.Kill = true; Talk->Flags.BDel = true; - Talk->SetName(Text[SAY_NAME]); + Talk->SetName(Text->getText(SAY_NAME)); Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H + 1); Talk->Z = 125; Talk->Ref = SAY_REF; @@ -211,7 +211,7 @@ void Say(const char *txt, SPRITE *spr) { spike->Z = 126; spike->Flags.Slav = true; spike->Flags.Kill = true; - spike->SetName(Text[SAY_NAME]); + spike->SetName(Text->getText(SAY_NAME)); spike->Step(east); spike->Ref = SAY_REF; @@ -226,7 +226,7 @@ void Inf(const char *txt) { if (Talk) { Talk->Flags.Kill = true; Talk->Flags.BDel = true; - Talk->SetName(Text[INF_NAME]); + Talk->SetName(Text->getText(INF_NAME)); Talk->Center(); Talk->Goto(Talk->X, Talk->Y - 20); Talk->Z = 126; diff --git a/engines/cge/text.h b/engines/cge/text.h index 7cf3922c5a..c778210304 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -65,12 +65,12 @@ public: ~TEXT(void); void Clear(int from = 1, int upto = 0x7FFF); void Preload(int from = 1, int upto = 0x7FFF); - char *operator[](int ref); + char *getText(int ref); }; extern TALK *Talk; -extern TEXT Text; +extern TEXT *Text; void Say(const char *txt, SPRITE *spr); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index a7dd76273d..52015c27f1 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -916,7 +916,7 @@ VGA::VGA(int mode) bool std = true; int i; for (i = 10; i < 20; i ++) { - char *txt = Text[i]; + char *txt = Text->getText(i); if (txt) { // puts(txt); warning(txt); -- cgit v1.2.3 From 40f95669aeb60a50c2736d71008f0e3461654f4f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 20 Jun 2011 00:13:41 +0200 Subject: CGE: As there's only one instance of VGA, suppress all the static keywords from it --- engines/cge/cge_main.cpp | 122 ++++++++++++++++++++++++----------------------- engines/cge/mixer.cpp | 5 +- engines/cge/snail.cpp | 42 ++++++++-------- engines/cge/text.cpp | 7 +-- engines/cge/vga13h.cpp | 43 ++++++++--------- engines/cge/vga13h.h | 47 +++++++++--------- engines/cge/vmenu.cpp | 5 +- 7 files changed, 138 insertions(+), 133 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6472cdef0b..c6c6a3961b 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -224,7 +224,7 @@ struct SAVTAB { { &Game, sizeof(Game), 1 }, // spare 2 { &Game, sizeof(Game), 1 }, // spare 3 { &Game, sizeof(Game), 1 }, // spare 4 - { &VGA::Mono, sizeof(VGA::Mono), 0 }, +// { &VGA::Mono, sizeof(VGA::Mono), 0 }, { &Music, sizeof(Music), 1 }, { volume, sizeof(volume), 1 }, { Flag, sizeof(Flag), 1 }, @@ -273,12 +273,12 @@ static void LoadGame(XFILE &file, bool tiny = false) { if (spr == NULL) error("No core"); *spr = S; - VGA::SpareQ.Append(spr); + Vga->SpareQ->Append(spr); } for (i = 0; i < POCKET_NX; i ++) { register int r = pocref[i]; - Pocket[i] = (r < 0) ? NULL : VGA::SpareQ.Locate(r); + Pocket[i] = (r < 0) ? NULL : Vga->SpareQ->Locate(r); } } } @@ -311,7 +311,7 @@ static void SaveGame(XFILE &file) { file.Write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); - for (spr = VGA::SpareQ.First(); spr; spr = spr->Next) + for (spr = Vga->SpareQ->First(); spr; spr = spr->Next) if (spr->Ref >= 1000) if (!file.Error) file.Write((uint8 *)spr, sizeof(*spr)); @@ -386,7 +386,7 @@ void WALK::Tick(void) { if (Dir != NO_DIR) { SPRITE *spr; SYSTEM::FunTouch(); - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { + for (spr = Vga->ShowQ->First(); spr; spr = spr->Next) { if (Distance(spr) < 2) { if (! spr->Flags.Near) { FeedSnail(spr, NEAR); @@ -562,7 +562,7 @@ static void SetMapBrick(int x, int z) { wtom(z, n + 3, 10, 2); CLUSTER::Map[z][x] = 1; s->SetName(n); - VGA::ShowQ.Insert(s, VGA::ShowQ.First()); + Vga->ShowQ->Insert(s, Vga->ShowQ->First()); } } @@ -667,13 +667,13 @@ void SYSTEM::FunTouch(void) { static void ShowBak(int ref) { - SPRITE *spr = VGA::SpareQ.Locate(ref); + SPRITE *spr = Vga->SpareQ->Locate(ref); if (spr) { BITMAP::Pal = SysPal; spr->Expand(); BITMAP::Pal = NULL; spr->Show(2); - VGA::CopyPage(1, 2); + Vga->CopyPage(1, 2); SYSTEM::SetPal(); spr->Contract(); } @@ -688,7 +688,7 @@ static void CaveUp(void) { ShowBak(BakRef); LoadMapping(); Text->Preload(BakRef, BakRef + 1000); - SPRITE *spr = VGA::SpareQ.First(); + SPRITE *spr = Vga->SpareQ->First(); while (spr) { SPRITE *n = spr->Next; if (spr->Cave == Now || spr->Cave == 0) @@ -718,18 +718,18 @@ static void CaveUp(void) { if (! Dark) Vga->Sunset(); - VGA::CopyPage(0, 1); + Vga->CopyPage(0, 1); SelectPocket(-1); if (Hero) - VGA::ShowQ.Insert(VGA::ShowQ.Remove(Hero)); + Vga->ShowQ->Insert(Vga->ShowQ->Remove(Hero)); if (Shadow) { - VGA::ShowQ.Remove(Shadow); + Vga->ShowQ->Remove(Shadow); Shadow->MakeXlat(Glass(SysPal, 204, 204, 204)); - VGA::ShowQ.Insert(Shadow, Hero); + Vga->ShowQ->Insert(Shadow, Hero); Shadow->Z = Hero->Z; } - FeedSnail(VGA::ShowQ.Locate(BakRef + 999), TAKE); + FeedSnail(Vga->ShowQ->Locate(BakRef + 999), TAKE); Vga->Show(); Vga->CopyPage(1, 0); Vga->Show(); @@ -747,12 +747,12 @@ static void CaveDown(void) { if (! HorzLine.Flags.Hide) SwitchMapping(); - for (spr = VGA::ShowQ.First(); spr;) { + for (spr = Vga->ShowQ->First(); spr;) { SPRITE *n = spr->Next; if (spr->Ref >= 1000 /*&& spr->Cave*/) { if (spr->Ref % 1000 == 999) FeedSnail(spr, TAKE); - VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); + Vga->SpareQ->Append(Vga->ShowQ->Remove(spr)); } spr = n; } @@ -793,14 +793,15 @@ void SwitchCave(int cav) { Hero->Step(0); #ifndef DEMO ///// protection: auto-destruction on! ---------------------- - VGA::SpareQ.Show = STARTUP::Summa * (cav <= CAVE_MAX); + Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX); /////-------------------------------------------------------- #endif } CavLight.Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); KillText(); - if (! Startup) KeyClick(); + if (! Startup) + KeyClick(); SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave @@ -834,7 +835,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { break; case 'F': if (KEYBOARD::Key[ALT]) { - SPRITE *m = VGA::ShowQ.Locate(17001); + SPRITE *m = Vga->ShowQ->Locate(17001); if (m) { m->Step(1); m->Time = 216; // 3s @@ -1017,9 +1018,9 @@ static void SpkClose(void) { static void SwitchColorMode(void) { - SNPOST_(SNSEQ, 121, VGA::Mono = ! VGA::Mono, NULL); + SNPOST_(SNSEQ, 121, Vga->Mono = !Vga->Mono, NULL); KeyClick(); - VGA::SetColors(SysPal, 64); + Vga->SetColors(SysPal, 64); } @@ -1066,7 +1067,7 @@ static void TakeName(void) { tn->Center(); tn->Goto(tn->X, tn->Y - 10); tn->Z = 126; - VGA::ShowQ.Insert(tn); + Vga->ShowQ->Insert(tn); } } } @@ -1085,7 +1086,7 @@ static void SwitchMapping(void) { } } else { SPRITE *s; - for (s = VGA::ShowQ.First(); s; s = s->Next) + for (s = Vga->ShowQ->First(); s; s = s->Next) if (s->W == MAP_XGRID && s->H == MAP_ZGRID) SNPOST_(SNKILL, -1, 0, s); } @@ -1104,7 +1105,7 @@ static void KillSprite(void) { static void PushSprite(void) { SPRITE *spr = Sprite->Prev; if (spr) { - VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr); + Vga->ShowQ->Insert(Vga->ShowQ->Remove(Sprite), spr); while (Sprite->Z > Sprite->Next->Z) --Sprite->Z; } else @@ -1121,7 +1122,7 @@ static void PullSprite(void) { ok = (!spr->Flags.Slav); } if (ok) { - VGA::ShowQ.Insert(VGA::ShowQ.Remove(Sprite), spr); + Vga->ShowQ->Insert(Vga->ShowQ->Remove(Sprite), spr); if (Sprite->Prev) while (Sprite->Z < Sprite->Prev->Z) ++Sprite->Z; @@ -1197,7 +1198,7 @@ static void SayDebug(void) { // sprite queue size uint16 n = 0; SPRITE *spr; - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { + for (spr = Vga->ShowQ->First(); spr; spr = spr->Next) { ++ n; if (spr == Sprite) { *XSPR = ' '; @@ -1463,7 +1464,7 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row warning("LoadSprite: use of fnsplit"); Sprite->ShpCnt = shpcnt; - VGA::SpareQ.Append(Sprite); + Vga->SpareQ->Append(Sprite); } } @@ -1578,7 +1579,7 @@ static void RunGame(void) { LoadHeroXY(); CavLight.Flags.Tran = true; - VGA::ShowQ.Append(&CavLight); + Vga->ShowQ->Append(&CavLight); CavLight.Flags.Hide = true; static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 }, @@ -1593,18 +1594,18 @@ static void RunGame(void) { PocLight.Flags.Tran = true; PocLight.Time = 1; PocLight.Z = 120; - VGA::ShowQ.Append(&PocLight); + Vga->ShowQ->Append(&PocLight); SelectPocket(-1); - VGA::ShowQ.Append(&Mouse); + Vga->ShowQ->Append(&Mouse); // ___________ LoadUser(); // ~~~~~~~~~~~ - if ((Sprite = VGA::SpareQ.Locate(121)) != NULL) - SNPOST_(SNSEQ, -1, VGA::Mono, Sprite); - if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) + if ((Sprite = Vga->SpareQ->Locate(121)) != NULL) + SNPOST_(SNSEQ, -1, Vga->Mono, Sprite); + if ((Sprite = Vga->SpareQ->Locate(122)) != NULL) Sprite->Step(Music); SNPOST_(SNSEQ, -1, Music, Sprite); if (! Music) @@ -1634,7 +1635,7 @@ static void RunGame(void) { Shadow->Ref = 2; Shadow->Flags.Tran = true; Hero->Flags.Shad = true; - VGA::ShowQ.Insert(VGA::SpareQ.Remove(Shadow), Hero); + Vga->ShowQ->Insert(Vga->SpareQ->Remove(Shadow), Hero); } } } @@ -1642,16 +1643,16 @@ static void RunGame(void) { InfoLine.Goto(INFO_X, INFO_Y); InfoLine.Flags.Tran = true; InfoLine.Update(NULL); - VGA::ShowQ.Insert(&InfoLine); + Vga->ShowQ->Insert(&InfoLine); DebugLine.Z = 126; - VGA::ShowQ.Insert(&DebugLine); + Vga->ShowQ->Insert(&DebugLine); HorzLine.Y = MAP_TOP - (MAP_TOP > 0); HorzLine.Z = 126; - VGA::ShowQ.Insert(&HorzLine); + Vga->ShowQ->Insert(&HorzLine); - Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF); + Mouse.Busy = Vga->SpareQ->Locate(BUSY_REF); if (Mouse.Busy) ExpandSprite(Mouse.Busy); @@ -1676,8 +1677,8 @@ static void RunGame(void) { SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); Mouse.Off(); - VGA::ShowQ.Clear(); - VGA::SpareQ.Clear(); + Vga->ShowQ->Clear(); + Vga->SpareQ->Clear(); Hero = NULL; Shadow = NULL; } @@ -1687,9 +1688,9 @@ void Movie(const char *ext) { const char *fn = ProgName(ext); if (INI_FILE::Exist(fn)) { LoadScript(fn); - ExpandSprite(VGA::SpareQ.Locate(999)); - FeedSnail(VGA::ShowQ.Locate(999), TAKE); - VGA::ShowQ.Append(&Mouse); + ExpandSprite(Vga->SpareQ->Locate(999)); + FeedSnail(Vga->ShowQ->Locate(999), TAKE); + Vga->ShowQ->Append(&Mouse); HEART::Enable = true; KEYBOARD::SetClient(Sys); while (! Snail.Idle()) { @@ -1699,8 +1700,8 @@ void Movie(const char *ext) { HEART::Enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); - VGA::ShowQ.Clear(); - VGA::SpareQ.Clear(); + Vga->ShowQ->Clear(); + Vga->SpareQ->Clear(); } } @@ -1723,23 +1724,23 @@ bool ShowTitle(const char *name) { } Vga->Sunset(); - VGA::CopyPage(1, 2); - VGA::CopyPage(0, 1); + Vga->CopyPage(1, 2); + Vga->CopyPage(0, 1); SelectPocket(-1); Vga->Sunrise(SysPal); if (STARTUP::Mode < 2 && ! STARTUP::SoundOk) { - VGA::CopyPage(1, 2); - VGA::CopyPage(0, 1); - VGA::ShowQ.Append(&Mouse); + Vga->CopyPage(1, 2); + Vga->CopyPage(0, 1); + Vga->ShowQ->Append(&Mouse); HEART::Enable = true; Mouse.On(); for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) MainLoop(); Mouse.Off(); HEART::Enable = false; - VGA::ShowQ.Clear(); - VGA::CopyPage(0, 2); + Vga->ShowQ->Clear(); + Vga->CopyPage(0, 2); STARTUP::SoundOk = 2; if (Music) LoadMIDI(0); @@ -1766,9 +1767,9 @@ bool ShowTitle(const char *name) { #endif //----------------------------------------- Movie("X00"); // paylist - VGA::CopyPage(1, 2); - VGA::CopyPage(0, 1); - VGA::ShowQ.Append(&Mouse); + Vga->CopyPage(1, 2); + Vga->CopyPage(0, 1); + Vga->ShowQ->Append(&Mouse); //Mouse.On(); HEART::Enable = true; for (TakeName(); GET_TEXT::Ptr;) @@ -1779,15 +1780,15 @@ bool ShowTitle(const char *name) { if (usr_ok) strcat(UsrFnam, SVG_EXT); //Mouse.Off(); - VGA::ShowQ.Clear(); - VGA::CopyPage(0, 2); + Vga->ShowQ->Clear(); + Vga->CopyPage(0, 2); #endif if (usr_ok && STARTUP::Mode == 0) { const char *n = UsrPath(UsrFnam); if (CFILE::Exist(n)) { CFILE file = CFILE(n, REA, RCrypt); LoadGame(file, true); // only system vars - VGA::SetColors(SysPal, 64); + Vga->SetColors(SysPal, 64); Vga->Update(); if (FINIS) { ++ STARTUP::Mode; @@ -1801,7 +1802,7 @@ bool ShowTitle(const char *name) { if (STARTUP::Mode < 2) Movie("X01"); // wink - VGA::CopyPage(0, 2); + Vga->CopyPage(0, 2); #ifdef DEMO return true; @@ -1844,7 +1845,8 @@ void cge_main(void) { Movie(LGO_EXT); if (ShowTitle("WELCOME")) { #ifndef DEMO - if (STARTUP::Mode == 1) Movie("X02"); // intro + if (STARTUP::Mode == 1) + Movie("X02"); // intro #endif RunGame(); Startup = 2; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 5b65eee9ca..c1b69d40c2 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -30,6 +30,7 @@ #include "cge/snail.h" #include "cge/mouse.h" #include "cge/snddrv.h" +#include "cge/cge_main.h" #include namespace CGE { @@ -75,9 +76,9 @@ MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { } Led[ArrayCount(Led) - 1]->Flags.BDel = true; - VGA::ShowQ.Insert(this); + Vga->ShowQ->Insert(this); for (i = 0; i < ArrayCount(Led); i ++) - VGA::ShowQ.Insert(Led[i]); + Vga->ShowQ->Insert(Led[i]); //--- reset balance i = (SNDDrvInfo.VOL4.ML + SNDDrvInfo.VOL4.MR) / 2; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 29ab11a36e..f40d2bc2fa 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -80,7 +80,7 @@ static void SNGame(SPRITE *spr, int num) { int buref = 0; int Stage = 0; - for (dup[0] = VGA::ShowQ.First(); dup[0]; dup[0] = dup[0]->Next) { + for (dup[0] = Vga->ShowQ->First(); dup[0]; dup[0] = dup[0]->Next) { buref = dup[0]->Ref; if (buref / 1000 == 16 && buref % 100 == 6) { Stage = (buref / 100) % 10; @@ -88,8 +88,8 @@ static void SNGame(SPRITE *spr, int num) { } } if (dup[1] == NULL) { - dup[1] = VGA::ShowQ.Locate(16003); // pan - dup[2] = VGA::ShowQ.Locate(16004); // pani + dup[1] = Vga->ShowQ->Locate(16003); // pan + dup[2] = Vga->ShowQ->Locate(16004); // pani } if (Game) { // continue game @@ -172,10 +172,10 @@ static void SNGame(SPRITE *spr, int num) { static int count = 0; if (k == NULL) { - k = VGA::ShowQ.Locate(20700); - k1 = VGA::ShowQ.Locate(20701); - k2 = VGA::ShowQ.Locate(20702); - k3 = VGA::ShowQ.Locate(20703); + k = Vga->ShowQ->Locate(20700); + k1 = Vga->ShowQ->Locate(20701); + k2 = Vga->ShowQ->Locate(20702); + k3 = Vga->ShowQ->Locate(20703); } if (! Game) { // init @@ -282,13 +282,13 @@ static void SNGame(SPRITE *spr, int num) { void ExpandSprite(SPRITE *spr) { if (spr) - VGA::ShowQ.Insert(VGA::SpareQ.Remove(spr)); + Vga->ShowQ->Insert(Vga->SpareQ->Remove(spr)); } void ContractSprite(SPRITE *spr) { if (spr) - VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); + Vga->SpareQ->Append(Vga->ShowQ->Remove(spr)); } int FindPocket(SPRITE *spr) { @@ -515,10 +515,10 @@ static void SNZTrim(SPRITE *spr) { SPRITE *s; HEART::Enable = false; s = (spr->Flags.Shad) ? spr->Prev : NULL; - VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr)); + Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr)); if (s) { s->Z = spr->Z; - VGA::ShowQ.Insert(VGA::ShowQ.Remove(s), spr); + Vga->ShowQ->Insert(Vga->ShowQ->Remove(s), spr); } HEART::Enable = en; } @@ -636,7 +636,7 @@ void SNCover(SPRITE *spr, int xref) { xspr->Goto(spr->X, spr->Y); ExpandSprite(xspr); if ((xspr->Flags.Shad = spr->Flags.Shad) == 1) { - VGA::ShowQ.Insert(VGA::ShowQ.Remove(spr->Prev), xspr); + Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr->Prev), xspr); spr->Flags.Shad = false; } FeedSnail(xspr, NEAR); @@ -650,7 +650,7 @@ void SNUncover(SPRITE *spr, SPRITE *xspr) { spr->Cave = xspr->Cave; spr->Goto(xspr->X, xspr->Y); if ((spr->Flags.Shad = xspr->Flags.Shad) == 1) { - VGA::ShowQ.Insert(VGA::ShowQ.Remove(xspr->Prev), spr); + Vga->ShowQ->Insert(Vga->ShowQ->Remove(xspr->Prev), spr); xspr->Flags.Shad = false; } spr->Z = xspr->Z; @@ -725,7 +725,7 @@ void SNSlave(SPRITE *spr, int ref) { SNSend(slv, spr->Cave); slv->Flags.Slav = true; slv->Z = spr->Z; - VGA::ShowQ.Insert(VGA::ShowQ.Remove(slv), spr->Next); + Vga->ShowQ->Insert(Vga->ShowQ->Remove(slv), spr->Next); } } } @@ -752,13 +752,13 @@ void SNKill(SPRITE *spr) { } SPRITE *nx = spr->Next; Hide1(spr); - VGA::ShowQ.Remove(spr); + Vga->ShowQ->Remove(spr); MOUSE::ClrEvt(spr); if (spr->Flags.Kill) delete spr; else { spr->Cave = -1; - VGA::SpareQ.Append(spr); + Vga->SpareQ->Append(spr); } if (nx) if (nx->Flags.Slav) @@ -826,7 +826,7 @@ static void SNLevel(SPRITE *spr, int lev) { while (Lev < lev) { SPRITE *spr; ++Lev; - spr = VGA::SpareQ.Locate(100 + Lev); + spr = Vga->SpareQ->Locate(100 + Lev); if (spr) { spr->BackShow(true); spr->Cave = 0; @@ -863,19 +863,19 @@ void SNFlash(bool on) { c = pal[i].B << 1; pal[i].B = (c < 64) ? c : 63; } - VGA::SetColors(pal, 64); + Vga->SetColors(pal, 64); } } else - VGA::SetColors(SysPal, 64); + Vga->SetColors(SysPal, 64); Dark = false; } static void SNLight(bool in) { if (in) - VGA::Sunrise(SysPal); + Vga->Sunrise(SysPal); else - VGA::Sunset(); + Vga->Sunset(); Dark = ! in; } diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index bbb69839dd..4944d8529a 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -32,6 +32,7 @@ #include "cge/bitmaps.h" #include "cge/game.h" #include "cge/snail.h" +#include "cge/cge_main.h" #include #include #include @@ -215,8 +216,8 @@ void Say(const char *txt, SPRITE *spr) { spike->Step(east); spike->Ref = SAY_REF; - VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last()); - VGA::ShowQ.Insert(spike, VGA::ShowQ.Last()); + Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); + Vga->ShowQ->Insert(spike, Vga->ShowQ->Last()); } } @@ -231,7 +232,7 @@ void Inf(const char *txt) { Talk->Goto(Talk->X, Talk->Y - 20); Talk->Z = 126; Talk->Ref = INF_REF; - VGA::ShowQ.Insert(Talk, VGA::ShowQ.Last()); + Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); } } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 52015c27f1..54b34105d8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -30,6 +30,7 @@ #include "cge/bitmap.h" #include "cge/vol.h" #include "cge/text.h" +#include "cge/cge_main.h" #include #include #include @@ -213,8 +214,8 @@ RGB MkRGB(uint8 r, uint8 g, uint8 b) { SPRITE *Locate(int ref) { - SPRITE *spr = VGA::ShowQ.Locate(ref); - return (spr) ? spr : VGA::SpareQ.Locate(ref); + SPRITE *spr = Vga->ShowQ->Locate(ref); + return (spr) ? spr : Vga->SpareQ->Locate(ref); } @@ -774,7 +775,7 @@ BMP_PTR SPRITE::Ghost(void) { SPRITE *SpriteAt(int x, int y) { - SPRITE *spr = NULL, * tail = VGA::ShowQ.Last(); + SPRITE *spr = NULL, * tail = Vga->ShowQ->Last(); if (tail) { for (spr = tail->Prev; spr; spr = spr->Prev) if (! spr->Flags.Hide && ! spr->Flags.Tran) @@ -888,17 +889,6 @@ SPRITE *QUEUE::Locate(int ref) { } -uint16 VGA::StatAdr = VGAST1_; -uint16 VGA::OldMode = 0; -uint16 *VGA::OldScreen = NULL; -const char *VGA::Msg = NULL; -const char *VGA::Nam = NULL; -DAC *VGA::OldColors = NULL; -DAC *VGA::NewColors = NULL; -bool VGA::SetPal = false; -int VGA::Mono = 0; -QUEUE VGA::ShowQ = true, VGA::SpareQ = false; - // TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that uint8 *VGA::Page[4] = { 0, 0, 0, 0 }; @@ -912,7 +902,13 @@ uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), //extern const char Copr[]; VGA::VGA(int mode) - : FrmCnt(0) { + : FrmCnt(0), OldMode(0), OldScreen(NULL), StatAdr(VGAST1_), + Msg(NULL), Nam(NULL), SetPal(false), Mono(0) { + OldColors = NULL; + NewColors = NULL; + ShowQ = new QUEUE(true); + SpareQ = new QUEUE(false); + bool std = true; int i; for (i = 10; i < 20; i ++) { @@ -939,7 +935,7 @@ VGA::VGA(int mode) OldMode = SetMode(mode); SetColors(); Setup(VideoMode); - Clear(); + Clear(0); } } @@ -948,7 +944,7 @@ VGA::~VGA(void) { Mono = 0; if (IsVga()) { Common::String buffer = ""; - Clear(); + Clear(0); SetMode(OldMode); SetColors(); RestoreScreen(OldScreen); @@ -1154,7 +1150,7 @@ void VGA::SetColors(void) { void VGA::Sunrise(DAC *tab) { for (int i = 0; i <= 64; i += FADE_STEP) { SetColors(tab, i); - WaitVR(); + WaitVR(true); UpdateColors(); } } @@ -1165,19 +1161,19 @@ void VGA::Sunset(void) { GetColors(tab); for (int i = 64; i >= 0; i -= FADE_STEP) { SetColors(tab, i); - WaitVR(); + WaitVR(true); UpdateColors(); } } void VGA::Show(void) { - SPRITE *spr = ShowQ.First(); + SPRITE *spr = ShowQ->First(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ->First(); spr; spr = spr->Next) spr->Show(); Update(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ->First(); spr; spr = spr->Next) spr->Hide(); ++ FrmCnt; @@ -1228,7 +1224,8 @@ void VGA::Update(void) { asm mov ah,byte ptr p+1 asm out dx,ax */ - if (! SpeedTest) WaitVR(); + if (! SpeedTest) + WaitVR(true); if (SetPal) { UpdateColors(); diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 19453a4523..b467b0405f 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -228,7 +228,7 @@ class QUEUE { SPRITE *Head, * Tail; public: bool Show; - QUEUE(bool show = false); + QUEUE(bool show); ~QUEUE(void); void Append(SPRITE *spr); void Insert(SPRITE *spr, SPRITE *nxt); @@ -247,32 +247,35 @@ public: class VGA { - static uint16 OldMode; - static uint16 *OldScreen; - static uint16 StatAdr; - static bool SetPal; - static DAC *OldColors, * NewColors; - static int SetMode(int mode); - static void UpdateColors(void); - static void SetColors(void); - static const char *Msg; - static const char *Nam; - static void SetStatAdr(void); - static void WaitVR(bool on = true); + uint16 OldMode; + uint16 *OldScreen; + uint16 StatAdr; + bool SetPal; + DAC *OldColors, *NewColors; + const char *Msg; + const char *Nam; + + int SetMode(int mode); + void UpdateColors(void); + void SetColors(void); + void SetStatAdr(void); + void WaitVR(bool on); public: uint32 FrmCnt; - static QUEUE ShowQ, SpareQ; - static int Mono; + QUEUE *ShowQ, *SpareQ; + int Mono; static uint8 *Page[4]; - VGA(int mode = M13H); + + VGA(int mode); ~VGA(void); + void Setup(VgaRegBlk *vrb); - static void GetColors(DAC *tab); - static void SetColors(DAC *tab, int lum); - static void Clear(uint8 color = 0); - static void CopyPage(uint16 d, uint16 s = 3); - static void Sunrise(DAC *tab); - static void Sunset(void); + void GetColors(DAC *tab); + void SetColors(DAC *tab, int lum); + void Clear(uint8 color); + void CopyPage(uint16 d, uint16 s); + void Sunrise(DAC *tab); + void Sunset(void); void Show(void); void Update(void); }; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 4e1a3334bf..cb2c2013f4 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -27,6 +27,7 @@ #include "cge/vmenu.h" #include "cge/mouse.h" +#include "cge/cge_main.h" #include namespace CGE { @@ -112,10 +113,10 @@ VMENU::VMENU(CHOICE *list, int x, int y) Center(); else Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); - VGA::ShowQ.Insert(this, VGA::ShowQ.Last()); + Vga->ShowQ->Insert(this, Vga->ShowQ->Last()); Bar = new MENU_BAR(W - 2 * TEXT_HM); Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM); - VGA::ShowQ.Insert(Bar, VGA::ShowQ.Last()); + Vga->ShowQ->Insert(Bar, Vga->ShowQ->Last()); } -- cgit v1.2.3 From 77d4dcade26a69a6e2ebcc69a4224059c450f3e4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 20 Jun 2011 00:55:47 +0200 Subject: CGE: Remove static parts of HEART --- engines/cge/cge.cpp | 2 ++ engines/cge/cge_main.cpp | 23 ++++++++++++----------- engines/cge/cge_main.h | 1 + engines/cge/snail.cpp | 10 +++++----- engines/cge/vga13h.cpp | 28 +++++++++++++--------------- engines/cge/vga13h.h | 11 ++++++----- 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 8b3bea3eb5..f28be8b224 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -42,6 +42,8 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) _console = new CGEConsole(this); Text = new TEXT(ProgName()); Vga = new VGA(M13H); + Heart = new HEART; + OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index c6c6a3961b..3c1cb28b14 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -61,6 +61,9 @@ namespace CGE { extern uint16 _stklen = (STACK_SIZ * 2); +VGA *Vga; +HEART *Heart; + // 0.75 - 17II95 - full sound support // 0.76 - 18II95 - small MiniEMS in DEMO, // unhide CavLight in SNLEVEL @@ -117,7 +120,6 @@ static SPRITE *Sprite = NULL; static SPRITE *MiniCave = NULL; static SPRITE *Shadow = NULL; -VGA *Vga; static EMS *Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE); static BMP_PTR *MiniShpList = NULL; static BMP_PTR MiniShp[] = { NULL, NULL }; @@ -582,7 +584,6 @@ static void SaveMapping(void); WALK *Hero = NULL; static INFO_LINE InfoLine = INFO_W; -static HEART Heart; static SPRITE CavLight = PR; @@ -738,7 +739,7 @@ static void CaveUp(void) { if (! Startup) Mouse.On(); - HEART::Enable = true; + Heart->Enable = true; } @@ -779,7 +780,7 @@ static void QGame(void) { void SwitchCave(int cav) { if (cav != Now) { - HEART::Enable = false; + Heart->Enable = false; if (cav < 0) { SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer @@ -1673,7 +1674,7 @@ static void RunGame(void) { } KEYBOARD::SetClient(NULL); - HEART::Enable = false; + Heart->Enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); Mouse.Off(); @@ -1691,13 +1692,13 @@ void Movie(const char *ext) { ExpandSprite(Vga->SpareQ->Locate(999)); FeedSnail(Vga->ShowQ->Locate(999), TAKE); Vga->ShowQ->Append(&Mouse); - HEART::Enable = true; + Heart->Enable = true; KEYBOARD::SetClient(Sys); while (! Snail.Idle()) { MainLoop(); } KEYBOARD::SetClient(NULL); - HEART::Enable = false; + Heart->Enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); Vga->ShowQ->Clear(); @@ -1733,12 +1734,12 @@ bool ShowTitle(const char *name) { Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); Vga->ShowQ->Append(&Mouse); - HEART::Enable = true; + Heart->Enable = true; Mouse.On(); for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) MainLoop(); Mouse.Off(); - HEART::Enable = false; + Heart->Enable = false; Vga->ShowQ->Clear(); Vga->CopyPage(0, 2); STARTUP::SoundOk = 2; @@ -1771,10 +1772,10 @@ bool ShowTitle(const char *name) { Vga->CopyPage(0, 1); Vga->ShowQ->Append(&Mouse); //Mouse.On(); - HEART::Enable = true; + Heart->Enable = true; for (TakeName(); GET_TEXT::Ptr;) MainLoop(); - HEART::Enable = false; + Heart->Enable = false; if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = true; if (usr_ok) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index fe50e7bab3..0afdc0f820 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -170,6 +170,7 @@ void ContractSprite(SPRITE *spr); void cge_main(void); extern VGA *Vga; +extern HEART *Heart; extern int OffUseCount; } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index f40d2bc2fa..afe73b4d24 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -511,16 +511,16 @@ static void SNRTNext(SPRITE *sprel, int p) { static void SNZTrim(SPRITE *spr) { if (spr) if (spr->Active()) { - bool en = HEART::Enable; + bool en = Heart->Enable; SPRITE *s; - HEART::Enable = false; + Heart->Enable = false; s = (spr->Flags.Shad) ? spr->Prev : NULL; Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr)); if (s) { s->Z = spr->Z; Vga->ShowQ->Insert(Vga->ShowQ->Remove(s), spr); } - HEART::Enable = en; + Heart->Enable = en; } } @@ -936,7 +936,7 @@ void SNAIL::RunCom(void) { case SNLABEL : break; case SNPAUSE : - HEART::SetXTimer(&Pause, snc->Val); + Heart->SetXTimer(&Pause, snc->Val); if (Talk) TextDelay = true; break; @@ -944,7 +944,7 @@ void SNAIL::RunCom(void) { if (sprel) { if (sprel->SeqTest(snc->Val) && (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) { - HEART::SetXTimer(&Pause, sprel->Time); + Heart->SetXTimer(&Pause, sprel->Time); } else goto xit; } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 54b34105d8..a8a0c5faf0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -219,12 +219,10 @@ SPRITE *Locate(int ref) { } -bool HEART::Enable = false; -uint16 *HEART::XTimer = NULL; - - HEART::HEART(void) : ENGINE(TMR_DIV) { + Enable = false; + XTimer = NULL; } @@ -235,11 +233,11 @@ extern "C" void TimerProc (void) static uint8 run = 0; // decrement external timer uint16 - if (HEART::XTimer) - if (*HEART::XTimer) -- *HEART::XTimer; - else HEART::XTimer = NULL; + if (Heart->XTimer) + if (*Heart->XTimer) -- *Heart->XTimer; + else Heart->XTimer = NULL; - if (! run && HEART::Enable) // check overrun flag + if (! run && Heart->Enable) // check overrun flag { static uint16 oldSP, oldSS; @@ -299,11 +297,11 @@ void ENGINE::NewTimer(...) { my_int: //------72Hz-------// // decrement external timer uint16 - if (HEART::XTimer) - if (*HEART::XTimer) -- *HEART::XTimer; - else HEART::XTimer = NULL; + if (Heart->XTimer) + if (*Heart->XTimer) -- *Heart->XTimer; + else Heart->XTimer = NULL; - if (! run && HEART::Enable) // check overrun flag + if (! run && Heart->Enable) // check overrun flag { static uint16 oldSP, oldSS; @@ -473,8 +471,8 @@ void SPRITE::SetName(char *n) { SPRITE *SPRITE::Expand(void) { if (! Ext) { - bool enbl = HEART::Enable; - HEART::Enable = false; + bool enbl = Heart->Enable; + Heart->Enable = false; if ((Ext = new SPREXT) == NULL) error("No core"); if (*File) { @@ -596,7 +594,7 @@ SPRITE *SPRITE::Expand(void) { else TakePtr = NO_PTR; } - HEART::Enable = enbl; + Heart->Enable = enbl; } return this; } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index b467b0405f..63886d9a99 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -131,11 +131,12 @@ extern SEQ Seq2[]; class HEART : public ENGINE { friend class ENGINE; public: - static bool Enable; - static uint16 *XTimer; - static void SetXTimer(uint16 *ptr); - static void SetXTimer(uint16 *ptr, uint16 time); - HEART(void); + HEART(); + + bool Enable; + uint16 *XTimer; + void SetXTimer(uint16 *ptr); + void SetXTimer(uint16 *ptr, uint16 time); }; -- cgit v1.2.3 From 6dc29e4a0489a62498653a880f38369ce05d41f8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 20 Jun 2011 23:40:22 +0200 Subject: CGE: Remove some statics --- engines/cge/cge.cpp | 10 ++++++- engines/cge/cge_main.cpp | 76 ++++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 25 ++++++++-------- engines/cge/game.h | 4 --- engines/cge/mixer.cpp | 5 ++-- engines/cge/mouse.cpp | 1 + engines/cge/snail.cpp | 20 ++++++------- engines/cge/vga13h.cpp | 1 - 8 files changed, 73 insertions(+), 69 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index f28be8b224..04a950faf0 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -30,8 +30,11 @@ #include "common/fs.h" #include "engines/util.h" #include "cge/cge.h" +#include "cge/vga13h.h" #include "cge/cge_main.h" #include "cge/text.h" +#include "cge/bitmaps.h" + namespace CGE { @@ -43,7 +46,12 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) Text = new TEXT(ProgName()); Vga = new VGA(M13H); Heart = new HEART; - + Hero = new WALK(NULL); + Sys = new SYSTEM(); + PocLight = new SPRITE(LI); + Mouse = new MOUSE; + for (int i = 0; i < POCKET_NX; i++) + Pocket[i] = new SPRITE(NULL); OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 3c1cb28b14..5817c1436b 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -61,8 +61,13 @@ namespace CGE { extern uint16 _stklen = (STACK_SIZ * 2); -VGA *Vga; +VGA *Vga; HEART *Heart; +WALK *Hero; +SYSTEM *Sys; +SPRITE *PocLight; +MOUSE *Mouse; +SPRITE *Pocket[POCKET_NX]; // 0.75 - 17II95 - full sound support // 0.76 - 18II95 - small MiniEMS in DEMO, @@ -109,13 +114,8 @@ bool JBW = false; DAC *SysPal = farnew(DAC, PAL_CNT); //------------------------------------------------------------------------- -SPRITE PocLight = LI; -SPRITE *Pocket[POCKET_NX] = { NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - }; int PocPtr = 0; -MOUSE Mouse; static SPRITE *Sprite = NULL; static SPRITE *MiniCave = NULL; static SPRITE *Shadow = NULL; @@ -387,9 +387,9 @@ void WALK::Tick(void) { if (Dir != NO_DIR) { SPRITE *spr; - SYSTEM::FunTouch(); + Sys->FunTouch(); for (spr = Vga->ShowQ->First(); spr; spr = spr->Next) { - if (Distance(spr) < 2) { + if (Distance(spr) < 2) { if (! spr->Flags.Near) { FeedSnail(spr, NEAR); spr->Flags.Near = true; @@ -582,7 +582,6 @@ static void NextStep(void); static void SaveMapping(void); -WALK *Hero = NULL; static INFO_LINE InfoLine = INFO_W; static SPRITE CavLight = PR; @@ -645,10 +644,6 @@ static void PostMiniStep(int stp) { warning("STUB: PostMiniStep()"); } - -int SYSTEM::FunDel = HEROFUN0; - - void SYSTEM::SetPal(void) { int i; DAC *p = SysPal + 256 - ArrayCount(StdPal); @@ -675,7 +670,7 @@ static void ShowBak(int ref) { BITMAP::Pal = NULL; spr->Show(2); Vga->CopyPage(1, 2); - SYSTEM::SetPal(); + Sys->SetPal(); spr->Contract(); } } @@ -737,7 +732,7 @@ static void CaveUp(void) { Vga->Sunrise(SysPal); Dark = false; if (! Startup) - Mouse.On(); + Mouse->On(); Heart->Enable = true; } @@ -788,7 +783,7 @@ void SwitchCave(int cav) { warning("SwitchCave() - SNPOST"); } else { Now = cav; - Mouse.Off(); + Mouse->Off(); if (Hero) { Hero->Park(); Hero->Step(0); @@ -811,6 +806,11 @@ void SwitchCave(int cav) { } } +SYSTEM::SYSTEM() : SPRITE(NULL) { + FunDel = HEROFUN0; + SetPal(); + Tick(); +} void SYSTEM::Touch(uint16 mask, int x, int y) { static int pp = 0; @@ -880,7 +880,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { Hero->Step(TSEQ + 3); break; case F9: - SYSTEM::FunDel = 1; + Sys->FunDel = 1; break; case 'X': if (KEYBOARD::Key[ALT]) @@ -1191,8 +1191,8 @@ static void SayDebug(void) { t = t1; } - dwtom(Mouse.X, ABSX, 10, 3); - dwtom(Mouse.Y, ABSY, 10, 3); + dwtom(Mouse->X, ABSX, 10, 3); + dwtom(Mouse->Y, ABSY, 10, 3); // dwtom(coreleft(), NFRE, 10, 5); // dwtom(farcoreleft(), FFRE, 10, 6); @@ -1249,7 +1249,7 @@ static void OptionTouch(int opt, uint16 mask) { #pragma argsused void SPRITE::Touch(uint16 mask, int x, int y) { - SYSTEM::FunTouch(); + Sys->FunTouch(); if ((mask & ATTN) == 0) { InfoLine.Update(Name()); if (mask & (R_DN | L_DN)) @@ -1265,7 +1265,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { mask |= R_UP; } if ((mask & R_UP) && Snail.Idle()) { - SPRITE *ps = (PocLight.SeqPtr) ? Pocket[PocPtr] : NULL; + SPRITE *ps = (PocLight->SeqPtr) ? Pocket[PocPtr] : NULL; if (ps) { if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) { if (Works(ps)) { @@ -1591,14 +1591,14 @@ static void RunGame(void) { { 1, 6, 0, 0, 4 }, { 0, 1, 0, 0, 16 }, }; - PocLight.SetSeq(PocSeq); - PocLight.Flags.Tran = true; - PocLight.Time = 1; - PocLight.Z = 120; - Vga->ShowQ->Append(&PocLight); + PocLight->SetSeq(PocSeq); + PocLight->Flags.Tran = true; + PocLight->Time = 1; + PocLight->Z = 120; + Vga->ShowQ->Append(PocLight); SelectPocket(-1); - Vga->ShowQ->Append(&Mouse); + Vga->ShowQ->Append(Mouse); // ___________ LoadUser(); @@ -1653,9 +1653,9 @@ static void RunGame(void) { HorzLine.Z = 126; Vga->ShowQ->Insert(&HorzLine); - Mouse.Busy = Vga->SpareQ->Locate(BUSY_REF); - if (Mouse.Busy) - ExpandSprite(Mouse.Busy); + Mouse->Busy = Vga->SpareQ->Locate(BUSY_REF); + if (Mouse->Busy) + ExpandSprite(Mouse->Busy); Startup = 0; @@ -1677,7 +1677,7 @@ static void RunGame(void) { Heart->Enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); - Mouse.Off(); + Mouse->Off(); Vga->ShowQ->Clear(); Vga->SpareQ->Clear(); Hero = NULL; @@ -1691,7 +1691,7 @@ void Movie(const char *ext) { LoadScript(fn); ExpandSprite(Vga->SpareQ->Locate(999)); FeedSnail(Vga->ShowQ->Locate(999), TAKE); - Vga->ShowQ->Append(&Mouse); + Vga->ShowQ->Append(Mouse); Heart->Enable = true; KEYBOARD::SetClient(Sys); while (! Snail.Idle()) { @@ -1733,12 +1733,12 @@ bool ShowTitle(const char *name) { if (STARTUP::Mode < 2 && ! STARTUP::SoundOk) { Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); - Vga->ShowQ->Append(&Mouse); + Vga->ShowQ->Append(Mouse); Heart->Enable = true; - Mouse.On(); + Mouse->On(); for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) MainLoop(); - Mouse.Off(); + Mouse->Off(); Heart->Enable = false; Vga->ShowQ->Clear(); Vga->CopyPage(0, 2); @@ -1770,7 +1770,7 @@ bool ShowTitle(const char *name) { Movie("X00"); // paylist Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); - Vga->ShowQ->Append(&Mouse); + Vga->ShowQ->Append(Mouse); //Mouse.On(); Heart->Enable = true; for (TakeName(); GET_TEXT::Ptr;) @@ -1829,9 +1829,9 @@ void cge_main(void) { //Debug( memset((void *) (-K(4)), 0, K(1)); ) memset(Barriers, 0xFF, sizeof(Barriers)); - if (! Mouse.Exist) + if (!Mouse->Exist) error("%s", Text->getText(NO_MOUSE_TEXT)); - if (! SVG0FILE::Exist(SVG0NAME)) + if (!SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; DebugLine.Flags.Hide = true; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 0afdc0f820..3eb38cafce 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -30,6 +30,7 @@ #include "cge/wav.h" #include "cge/vga13h.h" +#include "cge/mouse.h" namespace CGE { @@ -119,15 +120,14 @@ namespace CGE { class SYSTEM : public SPRITE { int lum; public: - static int FunDel; - static void SetPal(void); - static void FunTouch(void); - SYSTEM(void) : SPRITE(NULL) { - SetPal(); - Tick(); - } + int FunDel; + + SYSTEM(); + + void SetPal(); + void FunTouch(); void Touch(uint16 mask, int x, int y); - void Tick(void); + void Tick(); }; @@ -161,17 +161,18 @@ public: CLUSTER XZ(int x, int y); CLUSTER XZ(COUPLE xy); - -extern WALK *Hero; - - void ExpandSprite(SPRITE *spr); void ContractSprite(SPRITE *spr); void cge_main(void); +extern WALK *Hero; extern VGA *Vga; extern HEART *Heart; +extern SYSTEM *Sys; extern int OffUseCount; +extern SPRITE *PocLight; +extern MOUSE *Mouse; +extern SPRITE *Pocket[]; } // End of namespace CGE diff --git a/engines/cge/game.h b/engines/cge/game.h index 1bc24e1fd9..1d65d0c767 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -40,14 +40,10 @@ namespace CGE { #define TBound(s) (s->Y <= 0) #define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG) - -extern SPRITE *Sys; - int Sinus(long x); uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b); uint8 *Mark(DAC *pal); - class FLY : public SPRITE { static int L, T, R, B; public: diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index c1b69d40c2..6a3a45553a 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -35,7 +35,7 @@ namespace CGE { -extern MOUSE Mouse; +extern MOUSE *Mouse; bool MIXER::Appear = false; @@ -114,7 +114,8 @@ void MIXER::Touch(uint16 mask, int x, int y) { void MIXER::Tick(void) { - int x = Mouse.X, y = Mouse.Y; + int x = Mouse->X; + int y = Mouse->Y; if (SpriteAt(x, y) == this) { Fall = MIX_FALL; if (Flags.Hold) diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 78e686ff95..8ad12742d3 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -27,6 +27,7 @@ #include "cge/mouse.h" #include "cge/text.h" +#include "cge/cge_main.h" namespace CGE { diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index afe73b4d24..4675c6b848 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -58,7 +58,7 @@ int Lev = -1; SNAIL Snail = false; SNAIL Snail_ = true; -extern SPRITE PocLight; +extern SPRITE *PocLight; //------------------------------------------------------------------------- // SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, @@ -68,8 +68,6 @@ extern SPRITE PocLight; extern SPRITE *Pocket[]; extern int PocPtr; extern DAC *SysPal; -extern MOUSE Mouse; - static void SNGame(SPRITE *spr, int num) { switch (num) { @@ -300,18 +298,18 @@ int FindPocket(SPRITE *spr) { void SelectPocket(int n) { - if (n < 0 || (PocLight.SeqPtr && PocPtr == n)) { - PocLight.Step(0); + if (n < 0 || (PocLight->SeqPtr && PocPtr == n)) { + PocLight->Step(0); n = FindPocket(NULL); if (n >= 0) PocPtr = n; } else { if (Pocket[n] != NULL) { PocPtr = n; - PocLight.Step(1); + PocLight->Step(1); } } - PocLight.Goto(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); + PocLight->Goto(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); } @@ -903,9 +901,9 @@ static void SNReach(SPRITE *spr, int mode) { static void SNMouse(bool on) { if (on) - Mouse.On(); + Mouse->On(); else - Mouse.Off(); + Mouse->Off(); } @@ -960,13 +958,13 @@ void SNAIL::RunCom(void) { if (sprel == Hero && sprel->SeqTest(-1)) sprel->Step(HTALK); Say(Text->getText(snc->Val), sprel); - SYSTEM::FunDel = HEROFUN0; + Sys->FunDel = HEROFUN0; } break; case SNINF : if (TalkEnable) { Inf(Text->getText(snc->Val)); - SYSTEM::FunDel = HEROFUN0; + Sys->FunDel = HEROFUN0; } break; case SNTIME : diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index a8a0c5faf0..349f412ca0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -69,7 +69,6 @@ static VgaRegBlk VideoMode[] = { bool SpeedTest = false; SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; -SPRITE *Sys = NULL; extern "C" void SNDMIDIPlay(void); -- cgit v1.2.3 From b5ad69d13cf531c2d4c841c043a89f732fc4d4e0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 21 Jun 2011 19:38:16 +0200 Subject: CGE: ScummVM no longer crashes instantly --- engines/cge/bitmaps.cpp | 35 +--------------------- engines/cge/cge.cpp | 24 +++++++++++++++ engines/cge/cge_main.cpp | 77 ++++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 14 +++++++++ 4 files changed, 78 insertions(+), 72 deletions(-) diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp index cabe04b784..5e8757ae73 100644 --- a/engines/cge/bitmaps.cpp +++ b/engines/cge/bitmaps.cpp @@ -224,39 +224,6 @@ static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 namespace CGE { -BMP_PTR MB[] = { - new BITMAP("BRICK"), - NULL -}; - -BMP_PTR HL[] = { - new BITMAP("HLINE"), - NULL -}; - -BMP_PTR MC[] = { - new BITMAP("MOUSE"), - new BITMAP("DUMMY"), - NULL -}; - -BMP_PTR PR[] = { - new BITMAP("PRESS"), - NULL -}; - -BMP_PTR SP[] = { - new BITMAP("SPK_L"), - new BITMAP("SPK_R"), - NULL -}; - -BMP_PTR LI[] = { - new BITMAP("LITE0"), - new BITMAP("LITE1"), - new BITMAP("LITE2"), - new BITMAP("LITE3"), - NULL -}; + } // End of namespace CGE diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 04a950faf0..a34288b7e9 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -52,6 +52,30 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) Mouse = new MOUSE; for (int i = 0; i < POCKET_NX; i++) Pocket[i] = new SPRITE(NULL); + Sprite = new SPRITE(NULL); + MiniCave = new SPRITE(NULL); + Shadow = new SPRITE(NULL); + HorzLine = new SPRITE(HL); + InfoLine = new INFO_LINE(INFO_W); + CavLight = new SPRITE(PR); + DebugLine = new INFO_LINE(SCR_WID); + MB[0] = new BITMAP("BRICK"); + MB[1] = NULL; + HL[0] = new BITMAP("HLINE"); + HL[1] = NULL; + MC[0] = new BITMAP("MOUSE"); + MC[1] = new BITMAP("DUMMY"); + MC[2] = NULL; + PR[0] = new BITMAP("PRESS"); + PR[1] = NULL; + SP[0] = new BITMAP("SPK_L"); + SP[1] = new BITMAP("SPK_R"); + SP[2] = NULL; + LI[0] = new BITMAP("LITE0"); + LI[1] = new BITMAP("LITE1"), + LI[2] = new BITMAP("LITE2"), + LI[3] = new BITMAP("LITE3"), + LI[4] = NULL; OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 5817c1436b..7c055548a3 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -68,6 +68,20 @@ SYSTEM *Sys; SPRITE *PocLight; MOUSE *Mouse; SPRITE *Pocket[POCKET_NX]; +SPRITE *Sprite; +SPRITE *MiniCave; +SPRITE *Shadow; +SPRITE *HorzLine; +INFO_LINE *InfoLine; +SPRITE *CavLight; +INFO_LINE *DebugLine; + +BMP_PTR MB[2]; +BMP_PTR HL[2]; +BMP_PTR MC[3]; +BMP_PTR PR[2]; +BMP_PTR SP[3]; +BMP_PTR LI[5]; // 0.75 - 17II95 - full sound support // 0.76 - 18II95 - small MiniEMS in DEMO, @@ -116,10 +130,6 @@ DAC *SysPal = farnew(DAC, PAL_CNT); //------------------------------------------------------------------------- int PocPtr = 0; -static SPRITE *Sprite = NULL; -static SPRITE *MiniCave = NULL; -static SPRITE *Shadow = NULL; - static EMS *Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE); static BMP_PTR *MiniShpList = NULL; static BMP_PTR MiniShp[] = { NULL, NULL }; @@ -138,8 +148,6 @@ extern int FindPocket(SPRITE *); extern DAC StdPal[58]; -static SPRITE HorzLine = HL; - void FeedSnail(SPRITE *spr, SNLIST snq); // defined in SNAIL uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; @@ -581,11 +589,6 @@ static void BackPaint(void); static void NextStep(void); static void SaveMapping(void); - -static INFO_LINE InfoLine = INFO_W; -static SPRITE CavLight = PR; - - static void KeyClick(void) { SNPOST_(SNSOUND, -1, 5, NULL); } @@ -740,7 +743,7 @@ static void CaveUp(void) { static void CaveDown(void) { SPRITE *spr; - if (! HorzLine.Flags.Hide) + if (! HorzLine->Flags.Hide) SwitchMapping(); for (spr = Vga->ShowQ->First(); spr;) { @@ -793,7 +796,7 @@ void SwitchCave(int cav) { /////-------------------------------------------------------- #endif } - CavLight.Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + CavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); KillText(); if (! Startup) @@ -926,7 +929,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (Startup) return; int cav = 0; - InfoLine.Update(NULL); + InfoLine->Update(NULL); if (y >= WORLD_HIG) { if (x < BUTTON_X) { // select cave? if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && @@ -952,7 +955,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (cav && Snail.Idle() && Hero->TracePtr < 0) SwitchCave(cav); - if (!HorzLine.Flags.Hide) { + if (!HorzLine->Flags.Hide) { if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { int8 x1, z1; XZ(x, y).Split(x1, z1); @@ -1076,7 +1079,7 @@ static void TakeName(void) { static void SwitchMapping(void) { - if (HorzLine.Flags.Hide) { + if (HorzLine->Flags.Hide) { int i; for (i = 0; i < MAP_ZCNT; i ++) { int j; @@ -1091,7 +1094,7 @@ static void SwitchMapping(void) { if (s->W == MAP_XGRID && s->H == MAP_ZGRID) SNPOST_(SNKILL, -1, 0, s); } - HorzLine.Flags.Hide = ! HorzLine.Flags.Hide; + HorzLine->Flags.Hide = ! HorzLine->Flags.Hide; } @@ -1176,10 +1179,8 @@ static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 0 #define SP_F (DebugText + 67) #define SP__ (DebugText + 70) -INFO_LINE DebugLine(SCR_WID); - static void SayDebug(void) { - if (!DebugLine.Flags.Hide) { + if (!DebugLine->Flags.Hide) { static long t = -1L; long t1 = Timer(); @@ -1214,13 +1215,13 @@ static void SayDebug(void) { } dwtom(n, SP_S, 10, 2); // *SP__ = (heapcheck() < 0) ? '!' : ' '; - DebugLine.Update(DebugText); + DebugLine->Update(DebugText); } } static void SwitchDebug(void) { - DebugLine.Flags.Hide = ! DebugLine.Flags.Hide; + DebugLine->Flags.Hide = ! DebugLine->Flags.Hide; } @@ -1251,7 +1252,7 @@ static void OptionTouch(int opt, uint16 mask) { void SPRITE::Touch(uint16 mask, int x, int y) { Sys->FunTouch(); if ((mask & ATTN) == 0) { - InfoLine.Update(Name()); + InfoLine->Update(Name()); if (mask & (R_DN | L_DN)) Sprite = this; if (Ref / 10 == 12) { @@ -1579,9 +1580,9 @@ static void RunGame(void) { Text->Preload(100, 1000); LoadHeroXY(); - CavLight.Flags.Tran = true; - Vga->ShowQ->Append(&CavLight); - CavLight.Flags.Hide = true; + CavLight->Flags.Tran = true; + Vga->ShowQ->Append(CavLight); + CavLight->Flags.Hide = true; static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 }, { 1, 2, 0, 0, 4 }, @@ -1641,17 +1642,17 @@ static void RunGame(void) { } } - InfoLine.Goto(INFO_X, INFO_Y); - InfoLine.Flags.Tran = true; - InfoLine.Update(NULL); - Vga->ShowQ->Insert(&InfoLine); + InfoLine->Goto(INFO_X, INFO_Y); + InfoLine->Flags.Tran = true; + InfoLine->Update(NULL); + Vga->ShowQ->Insert(InfoLine); - DebugLine.Z = 126; - Vga->ShowQ->Insert(&DebugLine); + DebugLine->Z = 126; + Vga->ShowQ->Insert(DebugLine); - HorzLine.Y = MAP_TOP - (MAP_TOP > 0); - HorzLine.Z = 126; - Vga->ShowQ->Insert(&HorzLine); + HorzLine->Y = MAP_TOP - (MAP_TOP > 0); + HorzLine->Z = 126; + Vga->ShowQ->Insert(HorzLine); Mouse->Busy = Vga->SpareQ->Locate(BUSY_REF); if (Mouse->Busy) @@ -1660,7 +1661,7 @@ static void RunGame(void) { Startup = 0; SNPOST(SNLEVEL, -1, OldLev, &CavLight); - CavLight.Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + CavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); CaveUp(); @@ -1834,8 +1835,8 @@ void cge_main(void) { if (!SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; - DebugLine.Flags.Hide = true; - HorzLine.Flags.Hide = true; + DebugLine->Flags.Hide = true; + HorzLine->Flags.Hide = true; //srand((uint16) Timer()); Sys = new SYSTEM; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 3eb38cafce..d2443a7e87 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -173,6 +173,20 @@ extern int OffUseCount; extern SPRITE *PocLight; extern MOUSE *Mouse; extern SPRITE *Pocket[]; +extern SPRITE *Sprite; +extern SPRITE *MiniCave; +extern SPRITE *Shadow; +extern SPRITE *HorzLine; +extern INFO_LINE *InfoLine; +extern SPRITE *CavLight; +extern INFO_LINE *DebugLine; +extern BMP_PTR MB[2]; +extern BMP_PTR MB[2]; +extern BMP_PTR HL[2]; +extern BMP_PTR MC[3]; +extern BMP_PTR PR[2]; +extern BMP_PTR SP[3]; +extern BMP_PTR LI[5]; } // End of namespace CGE -- cgit v1.2.3 From a307d405b6ddf4cb94d57e8365327667a6291bac Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2011 08:11:18 +0200 Subject: CGE: suppress a couple of static, add ProgName and MergeExt --- engines/cge/cge.cpp | 43 +++++++++++++++++++++++++++++++++++++++---- engines/cge/cge_main.cpp | 29 ++++++++++++++++------------- engines/cge/cge_main.h | 2 ++ engines/cge/general.cpp | 18 ++++++++++++++---- engines/cge/gettext.cpp | 1 + engines/cge/snail.cpp | 4 +--- engines/cge/snail.h | 28 ++++++++++++++-------------- engines/cge/text.cpp | 2 +- engines/cge/text.h | 2 +- 9 files changed, 89 insertions(+), 40 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index a34288b7e9..ef00d0e517 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -42,8 +42,9 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) : Engine(syst), _gameDescription(gameDescription) { DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); + _console = new CGEConsole(this); - Text = new TEXT(ProgName()); + Text = new TEXT(ProgName(), 128); Vga = new VGA(M13H); Heart = new HEART; Hero = new WALK(NULL); @@ -72,10 +73,12 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) SP[1] = new BITMAP("SPK_R"); SP[2] = NULL; LI[0] = new BITMAP("LITE0"); - LI[1] = new BITMAP("LITE1"), - LI[2] = new BITMAP("LITE2"), - LI[3] = new BITMAP("LITE3"), + LI[1] = new BITMAP("LITE1"); + LI[2] = new BITMAP("LITE2"); + LI[3] = new BITMAP("LITE3"); LI[4] = NULL; + Snail = new SNAIL(false); + Snail_ = new SNAIL(true); OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); @@ -87,6 +90,38 @@ CGEEngine::~CGEEngine() { // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); + + _console = new CGEConsole(this); + + delete Text; + delete Vga; + delete Heart; + delete Hero; + delete Sys; + delete PocLight; + delete Mouse; + for (int i = 0; i < POCKET_NX; i++) + delete Pocket[i]; + delete Sprite; + delete MiniCave; + delete Shadow; + delete HorzLine; + delete InfoLine; + delete CavLight; + delete DebugLine; + delete MB[0]; + delete HL[0]; + delete MC[0]; + delete MC[1]; + delete PR[0]; + delete SP[0]; + delete SP[1]; + delete LI[0]; + delete LI[1]; + delete LI[2]; + delete LI[3]; + delete Snail; + delete Snail_; } Common::Error CGEEngine::run() { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 7c055548a3..ec8f743fe4 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -83,6 +83,9 @@ BMP_PTR PR[2]; BMP_PTR SP[3]; BMP_PTR LI[5]; +SNAIL *Snail; +SNAIL *Snail_; + // 0.75 - 17II95 - full sound support // 0.76 - 18II95 - small MiniEMS in DEMO, // unhide CavLight in SNLEVEL @@ -606,7 +609,7 @@ static void Quit(void) { { NULL, dummy } }; - if (Snail.Idle() && ! Hero->Flags.Hide) { + if (Snail->Idle() && ! Hero->Flags.Hide) { if (VMENU::Addr) { SNPOST_(SNKILL, -1, 0, VMENU::Addr); ResetQSwitch(); @@ -907,7 +910,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { Sprite->Step(x - '0'); break; case F10 : - if (Snail.Idle() && ! Hero->Flags.Hide) + if (Snail->Idle() && ! Hero->Flags.Hide) StartCountDown(); break; case 'J': @@ -952,7 +955,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { PostMiniStep(cav - 1); if (mask & L_UP) { - if (cav && Snail.Idle() && Hero->TracePtr < 0) + if (cav && Snail->Idle() && Hero->TracePtr < 0) SwitchCave(cav); if (!HorzLine->Flags.Hide) { @@ -964,7 +967,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { } } else { - if (! Talk && Snail.Idle() && Hero + if (! Talk && Snail->Idle() && Hero && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && ! Game) { Hero->FindWay(XZ(x, y)); } @@ -977,7 +980,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { void SYSTEM::Tick(void) { if (! Startup) if (-- FunDel == 0) { KillText(); - if (Snail.Idle()) { + if (Snail->Idle()) { if (PAIN) HeroCover(9); else if (STARTUP::Core >= CORE_MID) { @@ -1265,7 +1268,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { mask &= ~L_UP; mask |= R_UP; } - if ((mask & R_UP) && Snail.Idle()) { + if ((mask & R_UP) && Snail->Idle()) { SPRITE *ps = (PocLight->SeqPtr) ? Pocket[PocPtr] : NULL; if (ps) { if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) { @@ -1305,7 +1308,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { } } } - if ((mask & L_UP) && Snail.Idle()) { + if ((mask & L_UP) && Snail->Idle()) { if (Flags.Kept) { int n; for (n = 0; n < POCKET_NX; n ++) { @@ -1549,8 +1552,8 @@ static void MainLoop(void) { #endif Vga->Show(); - Snail_.RunCom(); - Snail.RunCom(); + Snail_->RunCom(); + Snail->RunCom(); } @@ -1695,9 +1698,9 @@ void Movie(const char *ext) { Vga->ShowQ->Append(Mouse); Heart->Enable = true; KEYBOARD::SetClient(Sys); - while (! Snail.Idle()) { + while (!Snail->Idle()) MainLoop(); - } + KEYBOARD::SetClient(NULL); Heart->Enable = false; SNPOST(SNCLEAR, -1, 0, NULL); @@ -1731,13 +1734,13 @@ bool ShowTitle(const char *name) { SelectPocket(-1); Vga->Sunrise(SysPal); - if (STARTUP::Mode < 2 && ! STARTUP::SoundOk) { + if (STARTUP::Mode < 2 && !STARTUP::SoundOk) { Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); Vga->ShowQ->Append(Mouse); Heart->Enable = true; Mouse->On(); - for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) + for (SelectSound(); !Snail->Idle() || VMENU::Addr;) MainLoop(); Mouse->Off(); Heart->Enable = false; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index d2443a7e87..f3a95e786c 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -187,6 +187,8 @@ extern BMP_PTR MC[3]; extern BMP_PTR PR[2]; extern BMP_PTR SP[3]; extern BMP_PTR LI[5]; +extern SNAIL *Snail; +extern SNAIL *Snail_; } // End of namespace CGE diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 7e1653f61a..efca664b71 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -99,16 +99,26 @@ EC void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const vo warning("STUB: _fqsort"); } -const char *ProgName(const char *ext) { - warning("STUB: ProgName"); - return NULL; +const char *ProgName(const char *ext) { + warning("ProgName"); + + static Common::String buf = "CGE"; + if (ext) + buf += ext; + return buf.c_str(); } char *MergeExt(char *buf, const char *nam, const char *ext) { // char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; // fnmerge(buf, dr, di, na, (fnsplit(nam, dr, di, na, ex) & EXTENSION) ? ex : ext); // return buf; - warning("STUB: MergeExt"); + warning("MergeExt"); + + strcpy(buf, nam); + char *dot = strrchr(buf, '.'); + if (!dot) + strcat(buf, ext); + return buf; } diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index e11f4ff308..c1d54099f8 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -28,6 +28,7 @@ #include "cge/gettext.h" #include "cge/keybd.h" #include "cge/mouse.h" +#include "cge/cge_main.h" #include namespace CGE { diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 4675c6b848..2b36ca4325 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -55,8 +55,6 @@ bool Dark = false; bool Game = false; int Now = 1; int Lev = -1; -SNAIL Snail = false; -SNAIL Snail_ = true; extern SPRITE *PocLight; @@ -359,7 +357,7 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { } while (true) { if (c->Com == SNTALK) { - if ((Snail.TalkEnable = (c->Val != 0)) == false) + if ((Snail->TalkEnable = (c->Val != 0)) == false) KillText(); } if (c->Com == SNNEXT) { diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 4255ea4e61..54c7809fda 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -42,9 +42,9 @@ namespace CGE { #define POCKET_SX 8 #define POCKET_SY 3 -#define SNINSERT(c,r,v,p) Snail.InsCom(c,r,v,p) -#define SNPOST(c,r,v,p) Snail.AddCom(c,r,v,p) -#define SNPOST_(c,r,v,p) Snail_.AddCom(c,r,v,p) +#define SNINSERT(c,r,v,p) Snail->InsCom(c,r,v,p) +#define SNPOST(c,r,v,p) Snail->AddCom(c,r,v,p) +#define SNPOST_(c,r,v,p) Snail_->AddCom(c,r,v,p) typedef struct { @@ -102,17 +102,17 @@ void SelectPocket(int n); void PocFul(void); -extern SCB Scb; -extern bool Flag[4]; -extern bool Game; -extern bool Dark; -extern SNAIL Snail; -extern SNAIL Snail_; -extern int Now; -extern int Lev; -extern int MaxCave; -extern int PocPtr; -extern BAR Barriers[]; +extern SCB Scb; +extern bool Flag[4]; +extern bool Game; +extern bool Dark; +//extern SNAIL *Snail; +//extern SNAIL *Snail_; +extern int Now; +extern int Lev; +extern int MaxCave; +extern int PocPtr; +extern BAR Barriers[]; extern struct HXY { int X; int Y; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 4944d8529a..ee94983352 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -46,7 +46,7 @@ TEXT::TEXT(const char *fname, int size) { Cache = new HAN[size]; MergeExt(FileName, fname, SAY_EXT); if (!INI_FILE::Exist(FileName)) - error("No talk\n"); + error("No talk (%s)\n", FileName); for (Size = 0; Size < size; Size ++) { Cache[Size].Ref = 0; diff --git a/engines/cge/text.h b/engines/cge/text.h index c778210304..64e3b1d669 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -61,7 +61,7 @@ class TEXT { char *Load(int idx, int ref); int Find(int ref); public: - TEXT(const char *fname, int size = 128); + TEXT(const char *fname, int size); ~TEXT(void); void Clear(int from = 1, int upto = 0x7FFF); void Preload(int from = 1, int upto = 0x7FFF); -- cgit v1.2.3 From fe9dc10964ab4dc4528cc473ef841709732fceff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 26 Jun 2011 17:53:55 +1000 Subject: CGE: Implemented basic file access functionality --- engines/cge/cge.cpp | 22 ++++++++++--- engines/cge/cge.h | 2 ++ engines/cge/general.cpp | 82 +++++++++++++++---------------------------------- engines/cge/general.h | 3 +- engines/cge/vol.cpp | 54 ++++++++++++++++++++++---------- engines/cge/vol.h | 23 +++++++++----- 6 files changed, 100 insertions(+), 86 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index ef00d0e517..d056a6737d 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -34,6 +34,7 @@ #include "cge/cge_main.h" #include "cge/text.h" #include "cge/bitmaps.h" +#include "cge/vol.h" namespace CGE { @@ -41,9 +42,20 @@ namespace CGE { CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) : Engine(syst), _gameDescription(gameDescription) { + // Debug/console setup DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); + debug("CGEEngine::CGEEngine"); +} + +void CGEEngine::setup() { + // Create debugger console _console = new CGEConsole(this); + + // Initialise classes that have static members + VFILE::init(); + + // Initialise engine objects Text = new TEXT(ProgName(), 128); Vga = new VGA(M13H); Heart = new HEART; @@ -81,18 +93,20 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) Snail_ = new SNAIL(true); OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); - - debug("CGEEngine::CGEEngine"); } CGEEngine::~CGEEngine() { debug("CGEEngine::~CGEEngine"); + // Call classes with static members to clear them up + VFILE::deinit(); + // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); _console = new CGEConsole(this); + // Delete engine objects delete Text; delete Vga; delete Heart; @@ -128,8 +142,8 @@ Common::Error CGEEngine::run() { // Initialize graphics using following: initGraphics(320, 200, false); - // Create debugger console. It requires GFX to be initialized - _console = new CGEConsole(this); + // Setup necessary game objects + setup(); // Additional setup. debug("CGEEngine::init"); diff --git a/engines/cge/cge.h b/engines/cge/cge.h index c6d9a099bf..f8857f045f 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -55,6 +55,8 @@ public: private: CGEConsole *_console; + + void setup(); }; // Example console class diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index efca664b71..9caa864227 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -158,9 +158,11 @@ uint16 RCrypt(void *buf, uint16 siz, uint16 seed) { } uint16 XCrypt(void *buf, uint16 siz, uint16 seed) { -// for (uint16 i = 0; i < siz; i ++) -// *(BUF ++) ^= seed; - warning("STUB: XCrypt"); + byte *b = static_cast(buf); + + for (uint16 i = 0; i < siz; i ++) + *b++ ^= seed; + return seed; } @@ -208,45 +210,32 @@ char *dwtom(uint32 val, char *str, int radix, int len) { } IOHAND::IOHAND(IOMODE mode, CRYPT *crpt) - : XFILE(mode), Handle(-1), Crypt(crpt), Seed(SEED) { + : XFILE(mode), Crypt(crpt), Seed(SEED) { } IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt) - : XFILE(mode), Crypt(crpt), Seed(SEED) { - /* switch (mode) - { - case REA : Error = _dos_open(name, O_RDONLY | O_DENYNONE, &Handle); break; - case WRI : Error = _dos_creat(name, FA_ARCH, &Handle); break; - case UPD : Error = _dos_open(name, O_RDWR | O_DENYALL, &Handle); break; - } - if (Error) Handle = -1; - */ - warning("STUB: IOHAND::IOHAND"); + : XFILE(mode), Crypt(crpt), Seed(SEED) { + // TODO: Check if WRI and/or UPD modes are needed, and map to a save file + assert(mode == REA); + + _file.open(name); } IOHAND::~IOHAND(void) { - /* - if (Handle != -1) - { - Error = _dos_close(Handle); - Handle = -1; - } - */ - warning("STUB: IOHAND::~IOHAND"); + _file.close(); } uint16 IOHAND::Read(void *buf, uint16 len) { - /* - if (Mode == WRI || Handle < 0) return 0; - if (len) Error = _dos_read(Handle, buf, len, &len); - if (Crypt) Seed = Crypt(buf, len, Seed); - return len; - */ - warning("STUB: IOHAND::Read"); - return 0; + if (Mode == WRI || !_file.isOpen()) + return 0; + + uint16 bytesRead = _file.read(buf, len); + if (Crypt) Seed = Crypt(buf, len, Seed); + return bytesRead; } uint16 IOHAND::Write(void *buf, uint16 len) { + error("IOHAND::Write not supported"); /* if (len) { if (Mode == REA || Handle < 0) @@ -259,45 +248,24 @@ uint16 IOHAND::Write(void *buf, uint16 len) { } return len; */ - warning("STUB: IOHAND::Write"); - return 0; } long IOHAND::Mark(void) { -/* - return (Handle < 0) ? 0 : tell(Handle); -*/ - warning("STUB: IOHAND::Mark"); - return 0; + return _file.pos(); } long IOHAND::Seek(long pos) { -/* - if (Handle < 0) - return 0; - lseek(Handle, pos, SEEK_SET); - return tell(Handle); -*/ - warning("STUB: IOHAND::Seek"); - return 0; + _file.seek(pos, SEEK_SET); + return _file.pos(); } long IOHAND::Size(void) { -/* - if (Handle < 0) - return 0; - return filelength(Handle); -*/ - warning("STUB: IOHAND::Size"); - return 0; + return _file.size(); } bool IOHAND::Exist(const char *name) { -/* - return access(name, 0) == 0; -*/ - warning("STUB: IOHAND::Exist"); - return 0; + Common::File f; + return f.exists(name); } //#define EMS_ADR(a) (FP_SEG(a) > 0xA000) diff --git a/engines/cge/general.h b/engines/cge/general.h index 16b0c1e2bf..6fb8e24f9c 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -29,6 +29,7 @@ #define __GENERAL__ #include "common/system.h" +#include "common/file.h" #include "common/random.h" #include "common/textconsole.h" #include "common/str.h" @@ -183,7 +184,7 @@ inline uint16 XRead(XFILE *xf, T *t) { class IOHAND : public XFILE { protected: - int Handle; + Common::File _file; uint16 Seed; CRYPT *Crypt; public: diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 9b6489afab..c76914c003 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -34,23 +34,45 @@ namespace CGE { +DAT *VFILE::_Dat = NULL; +BTFILE *VFILE::_Cat = NULL; +VFILE *VFILE::_Recent = NULL; + +/*-----------------------------------------------------------------------*/ + +DAT::DAT(): #ifdef VOL_UPD -BTFILE VFILE::Cat(CAT_NAME, UPD, CRP); -VOLBASE DAT::File(DAT_NAME, UPD, CRP); + _File(DAT_NAME, UPD, CRP) #else -BTFILE VFILE::Cat(CAT_NAME, REA, CRP); -VOLBASE DAT::File(DAT_NAME, REA, CRP); + _File(DAT_NAME, REA, CRP) #endif -DAT VFILE::Dat; -VFILE *VFILE::Recent = NULL; +{ +} +/*-----------------------------------------------------------------------*/ + +void VFILE::init() { + _Dat = new DAT(); +#ifdef VOL_UPD + _Cat = new BTFILE(CAT_NAME, UPD, CRP); +#else + _Cat = new BTFILE(CAT_NAME, REA, CRP); +#endif + + _Recent = NULL; +} + +void VFILE::deinit() { + delete _Dat; + delete _Cat; +} VFILE::VFILE(const char *name, IOMODE mode) : IOBUF(mode) { if (mode == REA) { - if (Dat.File.Error || Cat.Error) + if (_Dat->_File.Error || _Cat->Error) error("Bad volume data"); - BT_KEYPACK *kp = Cat.Find(name); + BT_KEYPACK *kp = _Cat->Find(name); if (scumm_stricmp(kp->Key, name) != 0) Error = 1; EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; @@ -63,26 +85,26 @@ VFILE::VFILE(const char *name, IOMODE mode) VFILE::~VFILE(void) { - if (Recent == this) - Recent = NULL; + if (_Recent == this) + _Recent = NULL; } bool VFILE::Exist(const char *name) { - return scumm_stricmp(Cat.Find(name)->Key, name) == 0; + return scumm_stricmp(_Cat->Find(name)->Key, name) == 0; } void VFILE::ReadBuff(void) { - if (Recent != this) { - Dat.File.Seek(BufMark + Lim); - Recent = this; + if (_Recent != this) { + _Dat->_File.Seek(BufMark + Lim); + _Recent = this; } - BufMark = Dat.File.Mark(); + BufMark = _Dat->_File.Mark(); long n = EndMark - BufMark; if (n > IOBUF_SIZE) n = IOBUF_SIZE; - Lim = Dat.File.Read(Buff, (uint16) n); + Lim = _Dat->_File.Read(Buff, (uint16) n); Ptr = 0; } diff --git a/engines/cge/vol.h b/engines/cge/vol.h index ea82e8bf6a..a910aa7209 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -51,18 +51,22 @@ namespace CGE { class DAT { friend class VFILE; - static VOLBASE File; + VOLBASE _File; public: - static bool Append(uint8 *buf, uint16 len); - static bool Write(CFILE &f); - static bool Read(long org, uint16 len, uint8 *buf); + DAT(); + + bool Append(uint8 *buf, uint16 len); + bool Write(CFILE &f); + bool Read(long org, uint16 len, uint8 *buf); }; class VFILE : public IOBUF { - static DAT Dat; - static BTFILE Cat; - static VFILE *Recent; +private: + static DAT *_Dat; + static BTFILE *_Cat; + static VFILE *_Recent; + long BegMark, EndMark; void ReadBuff(void); void WriteBuff(void) { } @@ -70,6 +74,9 @@ class VFILE : public IOBUF { public: VFILE(const char *name, IOMODE mode = REA); ~VFILE(void); + static void init(); + static void deinit(); + static bool Exist(const char *name); static const char *Next(void); long Mark(void) { @@ -79,7 +86,7 @@ public: return EndMark - BegMark; } long Seek(long pos) { - Recent = NULL; + _Recent = NULL; Lim = 0; return (BufMark = BegMark + pos); } -- cgit v1.2.3 From d5fdd094294becb49ef2adf0af00c4814c6efefe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 26 Jun 2011 18:51:12 +1000 Subject: CGE: Bugfix for scanning archive index in BTFILE class --- engines/cge/btfile.cpp | 3 ++- engines/cge/btfile.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 0552e78c1c..a6ba3d85b0 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -101,9 +101,10 @@ BT_KEYPACK *BTFILE::Find(const char *key) { // search if (pg->Hea.Down != BT_NONE) { int i; - for (i = 0; i < pg->Hea.Count; i ++) + for (i = 0; i < pg->Hea.Count; i ++) { if (memicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) break; + } nxt = (i) ? pg->Inn[i - 1].Down : pg->Hea.Down; Buff[lev].Indx = i - 1; ++ lev; diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 6e6398f4de..449f200140 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -39,6 +39,7 @@ namespace CGE { #define BT_NONE 0xFFFF #define BT_ROOT 0 +#include "common/pack-start.h" // START STRUCT PACKING struct BT_KEYPACK { char Key[BT_KEYLEN]; @@ -66,6 +67,8 @@ struct BT_PAGE { }; }; +#include "common/pack-end.h" // END STRUCT PACKING + class BTFILE : public IOHAND { struct { -- cgit v1.2.3 From a06a75b9a41fb3ef9da2c7420ee9dee257c89cca Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 26 Jun 2011 12:07:42 +0200 Subject: CGE: Implement ForceExt and RCrypt. Little style cleanup. --- engines/cge/bitmap.cpp | 10 ++++----- engines/cge/btfile.cpp | 14 ++++++------ engines/cge/cfile.cpp | 6 +++--- engines/cge/cge_main.cpp | 22 +++++++++---------- engines/cge/config.cpp | 2 +- engines/cge/detection.cpp | 2 +- engines/cge/ems.cpp | 4 ++-- engines/cge/game.cpp | 4 ++-- engines/cge/general.cpp | 39 +++++++++++++++++++--------------- engines/cge/gettext.cpp | 4 ++-- engines/cge/jbw.h | 14 ++++++------ engines/cge/mixer.cpp | 8 +++---- engines/cge/snail.cpp | 8 +++---- engines/cge/sound.cpp | 8 +++---- engines/cge/talk.cpp | 22 +++++++++---------- engines/cge/text.cpp | 6 +++--- engines/cge/vga13h.cpp | 54 +++++++++++++++++++++++++---------------------- engines/cge/vga13h.h | 2 +- engines/cge/vmenu.cpp | 8 +++---- 19 files changed, 123 insertions(+), 114 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index b528b5578d..90c6a02059 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -194,18 +194,18 @@ BMP_PTR BITMAP::Code(void) { int bpl; if (V) { // 2nd pass - fill the hide table - for (i = 0; i < H; i ++) { + for (i = 0; i < H; i++) { B[i].skip = 0xFFFF; B[i].hide = 0x0000; } } - for (bpl = 0; bpl < 4; bpl ++) { // once per each bitplane + for (bpl = 0; bpl < 4; bpl++) { // once per each bitplane uint8 *bm = M; bool skip = (bm[bpl] == TRANS); uint16 j; cnt = 0; - for (i = 0; i < H; i ++) { // once per each line + for (i = 0; i < H; i++) { // once per each line uint8 pix; for (j = bpl; j < W; j += 4) { pix = bm[j]; @@ -274,7 +274,7 @@ BMP_PTR BITMAP::Code(void) { B = (HideDesc *)(V + sizV); } cnt = 0; - for (i = 0; i < H; i ++) { + for (i = 0; i < H; i++) { if (B[i].skip == 0xFFFF) { // whole line is skipped B[i].skip = (cnt + SCR_WID) >> 2; cnt = 0; @@ -326,7 +326,7 @@ bool BITMAP::SolidAt(int x, int y) { while (true) { uint16 w, t; - w = * (uint16 *) m; + w = *(uint16 *) m; m += 2; t = w & 0xC000; w &= 0x3FFF; diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index a6ba3d85b0..12c3519466 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -42,7 +42,7 @@ namespace CGE { BTFILE::BTFILE(const char *name, IOMODE mode, CRYPT *crpt) : IOHAND(name, mode, crpt) { - for (int i = 0; i < BT_LEVELS; i ++) { + for (int i = 0; i < BT_LEVELS; i++) { Buff[i].Page = new BT_PAGE; Buff[i].PgNo = BT_NONE; Buff[i].Indx = -1; @@ -54,7 +54,7 @@ BTFILE::BTFILE(const char *name, IOMODE mode, CRYPT *crpt) BTFILE::~BTFILE(void) { - for (int i = 0; i < BT_LEVELS; i ++) { + for (int i = 0; i < BT_LEVELS; i++) { PutPage(i); delete Buff[i].Page; } @@ -101,7 +101,7 @@ BT_KEYPACK *BTFILE::Find(const char *key) { // search if (pg->Hea.Down != BT_NONE) { int i; - for (i = 0; i < pg->Hea.Count; i ++) { + for (i = 0; i < pg->Hea.Count; i++) { if (memicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) break; } @@ -110,7 +110,7 @@ BT_KEYPACK *BTFILE::Find(const char *key) { ++ lev; } else { int i; - for (i = 0; i < pg->Hea.Count - 1; i ++) + for (i = 0; i < pg->Hea.Count - 1; i++) if (scumm_stricmp((const char *)key, (const char *)pg->Lea[i].Key) <= 0) break; Buff[lev].Indx = i; @@ -136,15 +136,15 @@ void BTFILE::Make(BT_KEYPACK *keypack, uint16 count) { *Leaf = GetPage(1, n); Root->Hea.Down = n; PutPage(0, true); - while (count --) { + while (count--) { if (Leaf->Hea.Count >= ArrayCount(Leaf->Lea)) { PutPage(1, true); // save filled page Leaf = GetPage(1, ++n); // take empty page memcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); - Root->Inn[Root->Hea.Count ++].Down = n; + Root->Inn[Root->Hea.Count++].Down = n; Buff[0].Updt = true; } - Leaf->Lea[Leaf->Hea.Count ++] = * (keypack ++); + Leaf->Lea[Leaf->Hea.Count++] = *(keypack++); Buff[1].Updt = true; } } diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index da56587ebe..85e51a94c1 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -126,7 +126,7 @@ uint16 IOBUF::Read(uint8 *buf) { Ptr += n; if (eol) { ++ Ptr; - * (buf ++) = '\n'; + *(buf++) = '\n'; ++ total; if (Ptr >= Lim) ReadBuff(); @@ -186,14 +186,14 @@ int IOBUF::Read(void) { if (Lim == 0) return -1; } - return Buff[Ptr ++]; + return Buff[Ptr++]; } void IOBUF::Write(uint8 b) { if (Lim >= IOBUF_SIZE) WriteBuff(); - Buff[Lim ++] = b; + Buff[Lim++] = b; } diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index ec8f743fe4..4121efdb78 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -253,7 +253,7 @@ static void LoadGame(XFILE &file, bool tiny = false) { SPRITE *spr; int i; - for (st = SavTab; st->Ptr; st ++) { + for (st = SavTab; st->Ptr; st++) { if (file.Error) error("Bad SVG"); file.Read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len); @@ -289,7 +289,7 @@ static void LoadGame(XFILE &file, bool tiny = false) { Vga->SpareQ->Append(spr); } - for (i = 0; i < POCKET_NX; i ++) { + for (i = 0; i < POCKET_NX; i++) { register int r = pocref[i]; Pocket[i] = (r < 0) ? NULL : Vga->SpareQ->Locate(r); } @@ -308,7 +308,7 @@ static void SaveGame(XFILE &file) { SPRITE *spr; int i; - for (i = 0; i < POCKET_NX; i ++) { + for (i = 0; i < POCKET_NX; i++) { register SPRITE *s = Pocket[i]; pocref[i] = (s) ? s->Ref : -1; } @@ -316,7 +316,7 @@ static void SaveGame(XFILE &file) { volume[0] = SNDDrvInfo.VOL2.D; volume[1] = SNDDrvInfo.VOL2.M; - for (st = SavTab; st->Ptr; st ++) { + for (st = SavTab; st->Ptr; st++) { if (file.Error) error("Bad SVG"); file.Write((uint8 *) st->Ptr, st->Len); @@ -450,7 +450,7 @@ int WALK::Distance(SPRITE *spr) { dz = - dz; dx = dx * dx + dz * dz; - for (dz = 1; dz * dz < dx; dz ++) + for (dz = 1; dz * dz < dx; dz++) ; return dz - 1; @@ -485,7 +485,7 @@ void WALK::FindWay(CLUSTER c) { extern uint16 Target; if (c != Here) { - for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel ++) { + for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel++) { signed char x, z; Here.Split(x, z); Target = (z << 8) | x; @@ -653,7 +653,7 @@ static void PostMiniStep(int stp) { void SYSTEM::SetPal(void) { int i; DAC *p = SysPal + 256 - ArrayCount(StdPal); - for (i = 0; i < ArrayCount(StdPal); i ++) { + for (i = 0; i < ArrayCount(StdPal); i++) { p[i].R = StdPal[i].R >> 2; p[i].G = StdPal[i].G >> 2; p[i].B = StdPal[i].B >> 2; @@ -1084,9 +1084,9 @@ static void TakeName(void) { static void SwitchMapping(void) { if (HorzLine->Flags.Hide) { int i; - for (i = 0; i < MAP_ZCNT; i ++) { + for (i = 0; i < MAP_ZCNT; i++) { int j; - for (j = 0; j < MAP_XCNT; j ++) { + for (j = 0; j < MAP_XCNT; j++) { if (CLUSTER::Map[i][j]) SetMapBrick(j, i); } @@ -1311,7 +1311,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { if ((mask & L_UP) && Snail->Idle()) { if (Flags.Kept) { int n; - for (n = 0; n < POCKET_NX; n ++) { + for (n = 0; n < POCKET_NX; n++) { if (Pocket[n] == this) { SelectPocket(n); break; @@ -1436,7 +1436,7 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row l->By = 13; l->Cx = 300; l->Cy = 500; - * (long *) &l->Dx = 0; // movex * cnt + *(long *) &l->Dx = 0; // movex * cnt l->Goto(col, row); } Sprite = l; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 9ffda8d635..fe2d1bc16e 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -161,7 +161,7 @@ void SelectSound(void) { SNPOST_(SNKILL, -1, 0, VMENU::Addr); Inf(Text->getText(STYPE_TEXT)); Talk->Goto(Talk->X, FONT_HIG / 2); - for (i = 0; i < ArrayCount(DevName); i ++) + for (i = 0; i < ArrayCount(DevName); i++) DevMenu[i].Text = Text->getText(DevName[i]); (new VMENU(DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); } diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index f522f872c9..bebb342c03 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -160,7 +160,7 @@ SaveStateList CGEMetaEngine::listSaves(const char *target) const { SaveStateList saveList; int slotNum = 0; - for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { + for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); filename++) { // Obtain the last 3 digits of the filename, since they correspond to the save slot slotNum = atoi(filename->c_str() + filename->size() - 3); diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index c21bc356dc..f1f7ece708 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -142,8 +142,8 @@ EMS *EMM::Alloc(uint16 siz) { if (cnt > 4) { top = (top + PAGE_MASK) & 0xFFFFC000L; - ++ pgn; - -- cnt; + pgn++; + cnt--; } if (size <= Lim - top) diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 58334f2e53..afa6fbeed0 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -35,7 +35,7 @@ uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b) { uint8 *x = new uint8[256]; if (x) { uint16 i; - for (i = 0; i < 256; i ++) { + for (i = 0; i < 256; i++) { x[i] = Closest(pal, MkDAC(((uint16)(pal[i].R) * r) / 255, ((uint16)(pal[i].G) * g) / 255, ((uint16)(pal[i].B) * b) / 255)); @@ -50,7 +50,7 @@ uint8 *Mark(DAC *pal) { uint8 *x = new uint8[256]; if (x) { uint16 i; - for (i = 0; i < 256; i ++) { + for (i = 0; i < 256; i++) { x[i] = Closest(pal, MkDAC(f(pal[i].R), f(pal[i].G), f(pal[i].B))); diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 9caa864227..fd5cee3ec9 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -127,7 +127,13 @@ char *ForceExt(char *buf, const char *nam, const char *ext) { // fnsplit(nam, dr, di, na, ex); // fnmerge(buf, dr, di, na, ext); // return buf; - warning("STUB: ForceExt"); + warning("ForceExt"); + strcpy(buf, nam); + char *dot = strrchr(buf, '.'); + if (dot) + *dot = '\0'; + strcat(buf, ext); + return buf; } @@ -143,24 +149,23 @@ unsigned FastRand(unsigned s) { } uint16 RCrypt(void *buf, uint16 siz, uint16 seed) { - /* - if (buf && siz) { - uint8 * q = BUF + (siz-1); - seed = FastRand(seed); - * (BUF ++) ^= seed; - while (buf < q) * (BUF ++) ^= FastRand(); - if (buf == q) * BUF ^= (seed = FastRand()); - } - return seed; - */ - warning("STUB: RCrypt"); - return 0; + if (buf && siz) { + byte *b = static_cast(buf); + byte *q = b + (siz - 1); + seed = FastRand(seed); + *b++ ^= seed; + while (buf < q) + *b++ ^= FastRand(); + if (buf == q) + *b ^= (seed = FastRand()); + } + return seed; } uint16 XCrypt(void *buf, uint16 siz, uint16 seed) { byte *b = static_cast(buf); - for (uint16 i = 0; i < siz; i ++) + for (uint16 i = 0; i < siz; i++) *b++ ^= seed; return seed; @@ -170,7 +175,7 @@ uint16 atow(const char *a) { uint16 w = 0; if (a) while (IsDigit(*a)) - w = (10 * w) + (*(a ++) & 0xF); + w = (10 * w) + (*(a++) & 0xF); return w; } @@ -178,7 +183,7 @@ uint16 xtow(const char *x) { uint16 w = 0; if (x) { while (IsHxDig(*x)) { - register uint16 d = * (x ++); + register uint16 d = *(x++); if (d > '9') d -= 'A' - ('9' + 1); w = (w << 4) | (d & 0xF); @@ -327,7 +332,7 @@ DATACK *LoadWave(XFILE *file, EMM *emm) { int TakeEnum(const char **tab, const char *txt) { const char **e; if (txt) { - for (e = tab; *e; e ++) { + for (e = tab; *e; e++) { if (scumm_stricmp(txt, *e) == 0) { return e - tab; } diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index c1d54099f8..b6b47a05f9 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -82,7 +82,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { case Enter : Buff[Len] = '\0'; strcpy(Text, Buff); - for (p = Text; *p; p ++) { + for (p = Text; *p; p++) { char *q = strchr(ogon, *p); if (q) *p = bezo[q - ogon]; @@ -110,7 +110,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { if (Len < Size && 2 * TEXT_HM + Font->Width(Buff) + Font->Wid[x] <= W) { Buff[Len + 2] = Buff[Len + 1]; Buff[Len + 1] = Buff[Len]; - Buff[Len ++] = x; + Buff[Len++] = x; } } break; diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 82647ed49a..4c96507ab7 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -57,7 +57,7 @@ namespace CGE { #define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) #define farnew(t,n) ((t *) malloc(sizeof(t) * (n))) -#define ArrayCount(a) (sizeof(a)/sizeof((a)[0])) +#define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) #define MAX_TIMER 0x1800B0L typedef void (MouseFunType)(void); @@ -66,8 +66,8 @@ typedef void (MouseFunType)(void); #define Hi(d) (((int *) &d)[1]) #define LoWord(d) ((uint16) Lo(d)) #define HiWord(d) ((uint16) Hi(d)) -#define K(n) (1024*(n)) -#define MASK(n) ((1<SetSeq(ls); spr->Goto(x + 2 + 12 * i, y + 8); @@ -77,7 +77,7 @@ MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { Led[ArrayCount(Led) - 1]->Flags.BDel = true; Vga->ShowQ->Insert(this); - for (i = 0; i < ArrayCount(Led); i ++) + for (i = 0; i < ArrayCount(Led); i++) Vga->ShowQ->Insert(Led[i]); //--- reset balance @@ -124,7 +124,7 @@ void MIXER::Tick(void) { if (Fall) --Fall; else { - for (int i = 0; i < ArrayCount(Led); i ++) + for (int i = 0; i < ArrayCount(Led); i++) SNPOST_(SNKILL, -1, 0, Led[i]); SNPOST_(SNKILL, -1, 0, this); } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 2b36ca4325..cc79dfcc62 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -288,7 +288,7 @@ void ContractSprite(SPRITE *spr) { } int FindPocket(SPRITE *spr) { - for (int i = 0; i < POCKET_NX; i ++) + for (int i = 0; i < POCKET_NX; i++) if (Pocket[i] == spr) return i; return -1; @@ -346,7 +346,7 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { if (FindPocket(NULL) < 0) { // no empty pockets? SNAIL::COM *p; - for (p = c; p->Com != SNNEXT; p ++) { // find KEEP command + for (p = c; p->Com != SNNEXT; p++) { // find KEEP command if (p->Com == SNKEEP) { PocFul(); return; @@ -439,7 +439,7 @@ SNAIL::~SNAIL(void) { void SNAIL::AddCom(SNCOM com, int ref, int val, void *ptr) { _disable(); - COM *snc = &SNList[Head ++]; + COM *snc = &SNList[Head++]; snc->Com = com; snc->Ref = ref; snc->Val = val; @@ -850,7 +850,7 @@ void SNFlash(bool on) { DAC *pal = farnew(DAC, PAL_CNT); if (pal) { memcpy(pal, SysPal, PAL_SIZ); - for (int i = 0; i < PAL_CNT; i ++) { + for (int i = 0; i < PAL_CNT; i++) { register int c; c = pal[i].R << 1; pal[i].R = (c < 64) ? c : 63; diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 04e5d9464a..4a7b63fb08 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -82,7 +82,7 @@ void SOUND::Stop(void) { FX::FX(int size) : Emm(0L), Current(NULL) { Cache = new HAN[size]; - for (Size = 0; Size < size; Size ++) { + for (Size = 0; Size < size; Size++) { Cache[Size].Ref = 0; Cache[Size].Wav = NULL; } @@ -97,7 +97,7 @@ FX::~FX(void) { void FX::Clear(void) { HAN *p, * q; - for (p = Cache, q = p + Size; p < q; p ++) { + for (p = Cache, q = p + Size; p < q; p++) { if (p->Ref) { p->Ref = 0; delete p->Wav; @@ -112,7 +112,7 @@ void FX::Clear(void) { int FX::Find(int ref) { HAN *p, * q; int i = 0; - for (p = Cache, q = p + Size; p < q; p ++) { + for (p = Cache, q = p + Size; p < q; p++) { if (p->Ref == ref) break; else @@ -126,7 +126,7 @@ void FX::Preload(int ref0) { HAN *CacheLim = Cache + Size; int ref; - for (ref = ref0; ref < ref0 + 10; ref ++) { + for (ref = ref0; ref < ref0 + 10; ref++) { static char fname[] = "FX00000.WAV"; wtom(ref, fname + 2, 10, 5); INI_FILE file = INI_FILE(fname); diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 1739511a49..9f162d0e6c 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -66,7 +66,7 @@ void FONT::Load(void) { f.Read(Wid, WID_SIZ); if (! f.Error) { uint16 i, p = 0; - for (i = 0; i < POS_SIZ; i ++) { + for (i = 0; i < POS_SIZ; i++) { Pos[i] = p; p += Wid[i]; } @@ -80,7 +80,7 @@ uint16 FONT::Width(const char *text) { uint16 w = 0; if (text) while (* text) - w += Wid[*(text ++)]; + w += Wid[*(text++)]; return w; } @@ -91,7 +91,7 @@ void FONT::Save(void) { if (! f.Error) { f.Write(Wid, WID_SIZ); if (! f.Error) - f.Write(Map, Pos[POS_SIZ-1] + Wid[WID_SIZ-1]); + f.Write(Map, Pos[POS_SIZ - 1] + Wid[WID_SIZ - 1]); } } */ @@ -115,7 +115,7 @@ TALK::TALK(void) /* TALK::~TALK (void) { - for (uint16 i = 0; i < ShpCnt; i ++) { + for (uint16 i = 0; i < ShpCnt; i++) { if (FP_SEG(ShpList[i]) != _DS) { // small model: always false delete ShpList[i]; ShpList[i] = NULL; @@ -135,7 +135,7 @@ void TALK::Update(const char *tx) { if (!TS[0]) { uint16 k = 2 * hmarg; mh = 2 * vmarg + FONT_HIG; - for (p = tx; *p; p ++) { + for (p = tx; *p; p++) { if (*p == '|' || *p == '\n') { mh += FONT_HIG + TEXT_LS; if (k > mw) @@ -203,9 +203,9 @@ BITMAP *TALK::Box(uint16 w, uint16 h) { *p = LGRAY; } p = b; - for (int i = 0; i < r; i ++) { + for (int i = 0; i < r; i++) { int j; - for (j = 0; j < r - i; j ++) { + for (j = 0; j < r - i; j++) { p[j] = TRANS; p[w - j - 1] = TRANS; q[j] = TRANS; @@ -256,10 +256,10 @@ void TALK::PutLine(int line, const char *text) { uint16 cw = Font->Wid[*text], i; uint8 *fp = Font->Map + Font->Pos[*text]; - for (i = 0; i < cw; i ++) { + for (i = 0; i < cw; i++) { register uint16 b = fp[i]; uint16 n; - for (n = 0; n < FONT_HIG; n ++) { + for (n = 0; n < FONT_HIG; n++) { if (b & 1) *p = TEXT_FG; b >>= 1; @@ -293,7 +293,7 @@ void INFO_LINE::Update(const char *tx) { // claer whole rectangle memset(v + 2, TEXT_BG, dsiz); // data bytes memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines - * (uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 + *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes // paint text line @@ -306,7 +306,7 @@ void INFO_LINE::Update(const char *tx) { for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; - for (uint16 n = 0; n < FONT_HIG; n ++) { + for (uint16 n = 0; n < FONT_HIG; n++) { if (b & 1) *p = TEXT_FG; b >>= 1; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index ee94983352..a8bf0d0cf8 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -48,7 +48,7 @@ TEXT::TEXT(const char *fname, int size) { if (!INI_FILE::Exist(FileName)) error("No talk (%s)\n", FileName); - for (Size = 0; Size < size; Size ++) { + for (Size = 0; Size < size; Size++) { Cache[Size].Ref = 0; Cache[Size].Txt = NULL; } @@ -63,7 +63,7 @@ TEXT::~TEXT(void) { void TEXT::Clear(int from, int upto) { HAN *p, * q; - for (p = Cache, q = p + Size; p < q; p ++) { + for (p = Cache, q = p + Size; p < q; p++) { if (p->Ref && p->Ref >= from && p->Ref < upto) { p->Ref = 0; delete p->Txt; @@ -76,7 +76,7 @@ void TEXT::Clear(int from, int upto) { int TEXT::Find(int ref) { HAN *p, * q; int i = 0; - for (p = Cache, q = p + Size; p < q; p ++) { + for (p = Cache, q = p + Size; p < q; p++) { if (p->Ref == ref) break; else diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 349f412ca0..d7c6946e87 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -233,14 +233,16 @@ extern "C" void TimerProc (void) // decrement external timer uint16 if (Heart->XTimer) - if (*Heart->XTimer) -- *Heart->XTimer; - else Heart->XTimer = NULL; + if (*Heart->XTimer) + *Heart->XTimer--; + else + Heart->XTimer = NULL; if (! run && Heart->Enable) // check overrun flag { static uint16 oldSP, oldSS; - ++ run; // disable 2nd call until current lasts + run++; // disable 2nd call until current lasts asm mov ax,ds asm mov oldSS,ss asm mov oldSP,sp @@ -256,7 +258,7 @@ extern "C" void TimerProc (void) } asm mov ss,oldSS asm mov sp,oldSP - -- run; + run--; } } */ @@ -297,14 +299,16 @@ void ENGINE::NewTimer(...) { // decrement external timer uint16 if (Heart->XTimer) - if (*Heart->XTimer) -- *Heart->XTimer; - else Heart->XTimer = NULL; + if (*Heart->XTimer) + *Heart->XTimer--; + else + Heart->XTimer = NULL; if (! run && Heart->Enable) // check overrun flag { static uint16 oldSP, oldSS; - ++ run; // disable 2nd call until current lasts + run++; // disable 2nd call until current lasts asm mov ax,ds asm mov oldSS,ss asm mov oldSP,sp @@ -320,7 +324,7 @@ void ENGINE::NewTimer(...) { } asm mov ss,oldSS asm mov sp,oldSP - -- run; + run--; } */ @@ -402,7 +406,7 @@ BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { void SPRITE::MoveShapes(uint8 *buf) { BMP_PTR *p; - for (p = Ext->ShpList; *p; p ++) { + for (p = Ext->ShpList; *p; p++) { buf += (*p)->MoveVmap(buf); } } @@ -507,14 +511,14 @@ SPRITE *SPRITE::Expand(void) { break; } case 1 : { // Phase - shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); + shplist[shpcnt++] = new BITMAP(strtok(NULL, " \t,;/")); break; } case 2 : { // Seq seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); if (seq == NULL) error("No core [%s]", fname); - SEQ *s = &seq[seqcnt ++]; + SEQ *s = &seq[seqcnt++]; s->Now = atoi(strtok(NULL, " \t,;/")); if (s->Now > maxnow) maxnow = s->Now; @@ -540,7 +544,7 @@ SPRITE *SPRITE::Expand(void) { if (nea == NULL) error("No core [%s]", fname); else { - SNAIL::COM *c = &nea[neacnt ++]; + SNAIL::COM *c = &nea[neacnt++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); c->Ref = atoi(strtok(NULL, " \t,;/")); @@ -556,7 +560,7 @@ SPRITE *SPRITE::Expand(void) { if (tak == NULL) error("No core [%s]", fname); else { - SNAIL::COM *c = &tak[takcnt ++]; + SNAIL::COM *c = &tak[takcnt++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); c->Ref = atoi(strtok(NULL, " \t,;/")); @@ -569,7 +573,7 @@ SPRITE *SPRITE::Expand(void) { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt ++] = new BITMAP(File); + shplist[shpcnt++] = new BITMAP(File); } shplist[shpcnt] = NULL; if (seq) { @@ -606,7 +610,7 @@ SPRITE *SPRITE::Contract(void) { delete[] e->Name; if (Flags.BDel && e->ShpList) { int i; - for (i = 0; e->ShpList[i]; i ++) + for (i = 0; e->ShpList[i]; i++) delete e->ShpList[i]; if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; @@ -662,7 +666,7 @@ void SPRITE::MakeXlat(uint8 *x) { if (Flags.Xlat) KillXlat(); - for (b = Ext->ShpList; *b; b ++) + for (b = Ext->ShpList; *b; b++) (*b)->M = x; Flags.Xlat = true; } @@ -682,7 +686,7 @@ void SPRITE::KillXlat(void) { free(m); break; } - for (b = Ext->ShpList; *b; b ++) + for (b = Ext->ShpList; *b; b++) (*b)->M = NULL; Flags.Xlat = false; } @@ -908,7 +912,7 @@ VGA::VGA(int mode) bool std = true; int i; - for (i = 10; i < 20; i ++) { + for (i = 10; i < 20; i++) { char *txt = Text->getText(i); if (txt) { // puts(txt); @@ -1293,9 +1297,9 @@ void BITMAP::XShow(int x, int y) { /* uint8 rmsk = x % 4, mask = 1 << rmsk, - * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint8 * m = (char *) M; - uint8 * v = V; + *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint8 *m = (char *) M; + uint8 *v = V; asm push bx asm push si @@ -1374,8 +1378,8 @@ void BITMAP::XShow(int x, int y) { void BITMAP::Show(int x, int y) { /* uint8 mask = 1 << (x & 3), - * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - uint8 * v = V; + *scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); + uint8 *v = V; asm push ds // preserve DS @@ -1443,9 +1447,9 @@ void BITMAP::Show(int x, int y) { void BITMAP::Hide(int x, int y) { /* - uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); - HideDesc * b = B; + HideDesc *b = B; uint16 extra = ((x & 3) != 0); uint16 h = H; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 63886d9a99..d5bbf3972e 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -294,7 +294,7 @@ uint8 Closest(CBLK *pal, CBLK x) { if (!L) ++L; uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); - for (i = 0; i < 256; i ++) { + for (i = 0; i < 256; i++) { uint16 l = pal[i].R + pal[i].G + pal[i].B; if (! l) ++l; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index cb2c2013f4..e2b2a29515 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -54,7 +54,7 @@ MENU_BAR::MENU_BAR(uint16 w) { memset(p + i - w, MB_RB, w); p1 = p; p2 = p + i - 1; - for (i = 0; i < h; i ++) { + for (i = 0; i < h; i++) { *p1 = MB_LT; *p2 = MB_RB; p1 += w; @@ -76,14 +76,14 @@ char *VMGather(CHOICE *list) { CHOICE *cp; int len = 0, h = 0; - for (cp = list; cp->Text; cp ++) { + for (cp = list; cp->Text; cp++) { len += strlen(cp->Text); ++h; } vmgt = new char[len + h]; if (vmgt) { *vmgt = '\0'; - for (cp = list; cp->Text; cp ++) { + for (cp = list; cp->Text; cp++) { if (*vmgt) strcat(vmgt, "|"); strcat(vmgt, cp->Text); @@ -105,7 +105,7 @@ VMENU::VMENU(CHOICE *list, int x, int y) Addr = this; delete[] vmgt; Items = 0; - for (cp = list; cp->Text; cp ++) + for (cp = list; cp->Text; cp++) ++Items; Flags.BDel = true; Flags.Kill = true; -- cgit v1.2.3 From e0673c113563ab9fc28d08c07a3bcb5c3b98fa1c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 26 Jun 2011 12:52:07 +0200 Subject: CGE: get rid of memicmp --- engines/cge/btfile.cpp | 13 ++++++------- engines/cge/startup.cpp | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 12c3519466..db0ebc2d5f 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -72,7 +72,7 @@ void BTFILE::PutPage(int lev, bool hard) { BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) { if (Buff[lev].PgNo != pgn) { - uint32 pos = pgn * sizeof(BT_PAGE); + int32 pos = pgn * sizeof(BT_PAGE); PutPage(lev); Buff[lev].PgNo = pgn; if (Size() > pos) { @@ -90,9 +90,6 @@ BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) { return Buff[lev].Page; } -// Does this work, or does it have to compare the entire buffer? -#define memicmp(s1, s2, n) scumm_strnicmp((const char *)s1, (const char *)s2, n) - BT_KEYPACK *BTFILE::Find(const char *key) { int lev = 0; uint16 nxt = BT_ROOT; @@ -102,7 +99,8 @@ BT_KEYPACK *BTFILE::Find(const char *key) { if (pg->Hea.Down != BT_NONE) { int i; for (i = 0; i < pg->Hea.Count; i++) { - if (memicmp(key, pg->Inn[i].Key, BT_KEYLEN) < 0) + // Does this work, or does it have to compare the entire buffer? + if (scumm_strnicmp((const char *) key, (const char*)pg->Inn[i].Key, BT_KEYLEN) < 0) break; } nxt = (i) ? pg->Inn[i - 1].Down : pg->Hea.Down; @@ -110,9 +108,10 @@ BT_KEYPACK *BTFILE::Find(const char *key) { ++ lev; } else { int i; - for (i = 0; i < pg->Hea.Count - 1; i++) + for (i = 0; i < pg->Hea.Count - 1; i++) { if (scumm_stricmp((const char *)key, (const char *)pg->Lea[i].Key) <= 0) break; + } Buff[lev].Indx = i; return &pg->Lea[i]; } @@ -122,7 +121,7 @@ BT_KEYPACK *BTFILE::Find(const char *key) { int keycomp(const void *k1, const void *k2) { - return memicmp(k1, k2, BT_KEYLEN); + return scumm_strnicmp((const char *) k1, (const char*) k2, BT_KEYLEN); } diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 631a64d732..4895ce9861 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -150,7 +150,7 @@ const char *UsrPath(const char *nam) { if (j) if (buf[--j] == '\n') buf[j] = '\0'; - if (memicmp(buf, key, i) == 0) + if (scumm_strnicmp((const char *) buf, (const char*) key, i) == 0) ok = true; } if (ok) { -- cgit v1.2.3 From 083d6ff6122cb2faf0a4330eb480bb9f77afa255 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Jun 2011 01:03:47 +0200 Subject: CGE: remove some if(n)def DEMO by using a new flag. Added CGEEngine in several classes in order to do so. --- engines/cge/cge.cpp | 33 +++---- engines/cge/cge.h | 39 ++++++++- engines/cge/cge_main.cpp | 213 ++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 39 ++++----- engines/cge/config.cpp | 126 +++++++++++++-------------- engines/cge/detection.cpp | 4 +- engines/cge/game.cpp | 4 +- engines/cge/game.h | 4 +- engines/cge/gettext.cpp | 6 +- engines/cge/gettext.h | 11 ++- engines/cge/jbw.h | 9 +- engines/cge/mixer.cpp | 4 +- engines/cge/mixer.h | 8 +- engines/cge/mouse.cpp | 2 +- engines/cge/mouse.h | 12 +-- engines/cge/snail.cpp | 9 +- engines/cge/snail.h | 7 +- engines/cge/talk.cpp | 10 +-- engines/cge/talk.h | 10 ++- engines/cge/text.cpp | 14 +-- engines/cge/text.h | 5 +- engines/cge/vga13h.cpp | 5 +- engines/cge/vga13h.h | 5 +- engines/cge/vmenu.cpp | 14 +-- engines/cge/vmenu.h | 12 ++- 25 files changed, 329 insertions(+), 276 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index d056a6737d..d09085857f 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -45,7 +45,8 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) // Debug/console setup DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); - debug("CGEEngine::CGEEngine"); + _isDemo = _gameDescription->flags & ADGF_DEMO; + } void CGEEngine::setup() { @@ -56,22 +57,22 @@ void CGEEngine::setup() { VFILE::init(); // Initialise engine objects - Text = new TEXT(ProgName(), 128); + Text = new TEXT(this, ProgName(), 128); Vga = new VGA(M13H); Heart = new HEART; - Hero = new WALK(NULL); - Sys = new SYSTEM(); - PocLight = new SPRITE(LI); - Mouse = new MOUSE; + Hero = new WALK(this, NULL); + Sys = new SYSTEM(this); + PocLight = new SPRITE(this, LI); + Mouse = new MOUSE(this); for (int i = 0; i < POCKET_NX; i++) - Pocket[i] = new SPRITE(NULL); - Sprite = new SPRITE(NULL); - MiniCave = new SPRITE(NULL); - Shadow = new SPRITE(NULL); - HorzLine = new SPRITE(HL); - InfoLine = new INFO_LINE(INFO_W); - CavLight = new SPRITE(PR); - DebugLine = new INFO_LINE(SCR_WID); + Pocket[i] = new SPRITE(this, NULL); + Sprite = new SPRITE(this, NULL); + MiniCave = new SPRITE(this, NULL); + Shadow = new SPRITE(this, NULL); + HorzLine = new SPRITE(this, HL); + InfoLine = new INFO_LINE(this, INFO_W); + CavLight = new SPRITE(this, PR); + DebugLine = new INFO_LINE(this, SCR_WID); MB[0] = new BITMAP("BRICK"); MB[1] = NULL; HL[0] = new BITMAP("HLINE"); @@ -89,8 +90,8 @@ void CGEEngine::setup() { LI[2] = new BITMAP("LITE2"); LI[3] = new BITMAP("LITE3"); LI[4] = NULL; - Snail = new SNAIL(false); - Snail_ = new SNAIL(true); + Snail = new SNAIL(this, false); + Snail_ = new SNAIL(this, true); OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index f8857f045f..c3f241b2fe 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -23,6 +23,7 @@ #ifndef CGE_H #define CGE_H +#include "cge/general.h" #include "common/random.h" #include "engines/engine.h" #include "gui/debugger.h" @@ -47,15 +48,51 @@ public: ~CGEEngine(); const ADGameDescription *_gameDescription; + bool _isDemo; virtual Common::Error run(); GUI::Debugger *getDebugger() { return _console; } + void cge_main(); + void SwitchCave(int cav); + void StartCountDown(); + void Quit(); + void ResetQSwitch(); + void OptionTouch(int opt, uint16 mask); + void LoadGame(XFILE &file, bool tiny); + void SetMapBrick(int x, int z); + void SwitchMapping(); + void LoadSprite(const char *fname, int ref, int cav, int col, int row, int pos); + void LoadScript(const char *fname); + void LoadUser(); + void RunGame(); + bool ShowTitle(const char *name); + void Movie(const char *ext); + void TakeName(); + void Inf(const char *txt); + void SelectSound(); + void SNSelect(); + void dummy() {} + void NONE(); + void SB(); + void CaveDown(); + void XCave(); + void QGame(); + void SBM(); + void GUS(); + void GUSM(); + void MIDI(); + void AUTO(); + void SetPortD(); + void SetPortM(); + void SetIRQ(); + void SetDMA(); + void MainLoop(); + private: CGEConsole *_console; - void setup(); }; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4121efdb78..dda6041f0a 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -44,6 +44,7 @@ #include "cge/gettext.h" #include "cge/mixer.h" #include "cge/cge_main.h" +#include "cge/cge.h" #include #include #include @@ -54,7 +55,7 @@ namespace CGE { #define STACK_SIZ (K(2)) -#define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText) +#define SVGCHKSUM (1956 + Now + OldLev + Game + Music + DemoText) #define SVG0NAME ("{{INIT}}" SVG_EXT) #define SVG0FILE CFILE @@ -142,7 +143,6 @@ static int Startup = 1; int OffUseCount; uint16 *intStackPtr = false; - HXY HeroXY[CAVE_MAX] = {{0, 0}}; BAR Barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; @@ -248,7 +248,7 @@ struct SAVTAB { }; -static void LoadGame(XFILE &file, bool tiny = false) { +void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { SAVTAB *st; SPRITE *spr; int i; @@ -274,15 +274,15 @@ static void LoadGame(XFILE &file, bool tiny = false) { if (! tiny) { // load sprites & pocket while (! file.Error) { - SPRITE S(NULL); + SPRITE S(this, NULL); uint16 n = file.Read((uint8 *) &S, sizeof(S)); if (n != sizeof(S)) break; S.Prev = S.Next = NULL; - spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(NULL) - : new SPRITE(NULL); + spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(this, NULL) + : new SPRITE(this, NULL); if (spr == NULL) error("No core"); *spr = S; @@ -385,8 +385,8 @@ CLUSTER Trace[MAX_FIND_LEVEL]; int FindLevel; -WALK::WALK(BMP_PTR *shpl) - : SPRITE(shpl), Dir(NO_DIR), TracePtr(-1) { +WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) + : SPRITE(vm, shpl), Dir(NO_DIR), TracePtr(-1), _vm(vm) { } @@ -545,13 +545,15 @@ void WALK::Reach(SPRITE *spr, int mode) { class SQUARE : public SPRITE { public: - SQUARE(void); + SQUARE(CGEEngine *vm); void Touch(uint16 mask, int x, int y); +private: + CGEEngine *_vm; }; -SQUARE::SQUARE(void) - : SPRITE(MB) { +SQUARE::SQUARE(CGEEngine *vm) + : SPRITE(vm, MB), _vm(vm) { Flags.Kill = true; Flags.BDel = false; } @@ -566,8 +568,8 @@ void SQUARE::Touch(uint16 mask, int x, int y) { } -static void SetMapBrick(int x, int z) { - SQUARE *s = new SQUARE; +void CGEEngine::SetMapBrick(int x, int z) { + SQUARE *s = new SQUARE(this); if (s) { static char n[] = "00:00"; s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); @@ -579,10 +581,9 @@ static void SetMapBrick(int x, int z) { } } -void dummy(void) {} -static void SwitchMapping(void); +//static void SwitchMapping(void); static void SwitchColorMode(void); -static void StartCountDown(void); +//static void StartCountDown(void); static void SwitchDebug(void); static void SwitchMusic(void); static void KillSprite(void); @@ -597,16 +598,17 @@ static void KeyClick(void) { } -static void ResetQSwitch(void) { +void CGEEngine::ResetQSwitch() { SNPOST_(SNSEQ, 123, 0, NULL); KeyClick(); } -static void Quit(void) { - static CHOICE QuitMenu[] = { { NULL, StartCountDown }, - { NULL, ResetQSwitch }, - { NULL, dummy } +void CGEEngine::Quit() { + static CHOICE QuitMenu[] = { + { NULL, &CGEEngine::StartCountDown }, + { NULL, &CGEEngine::ResetQSwitch }, + { NULL, &CGEEngine::dummy } }; if (Snail->Idle() && ! Hero->Flags.Hide) { @@ -616,7 +618,7 @@ static void Quit(void) { } else { QuitMenu[0].Text = Text->getText(QUIT_TEXT); QuitMenu[1].Text = Text->getText(NOQUIT_TEXT); - (new VMENU(QuitMenu, -1, -1))->SetName(Text->getText(QUIT_TITLE)); + (new VMENU(this, QuitMenu, -1, -1))->SetName(Text->getText(QUIT_TITLE)); SNPOST_(SNSEQ, 123, 1, NULL); KeyClick(); } @@ -744,7 +746,7 @@ static void CaveUp(void) { } -static void CaveDown(void) { +void CGEEngine::CaveDown() { SPRITE *spr; if (! HorzLine->Flags.Hide) SwitchMapping(); @@ -762,13 +764,13 @@ static void CaveDown(void) { } -static void XCave(void) { +void CGEEngine::XCave() { CaveDown(); CaveUp(); } -static void QGame(void) { +void CGEEngine::QGame() { CaveDown(); OldLev = Lev; SaveSound(); @@ -779,7 +781,7 @@ static void QGame(void) { } -void SwitchCave(int cav) { +void CGEEngine::SwitchCave(int cav) { if (cav != Now) { Heart->Enable = false; if (cav < 0) { @@ -793,11 +795,10 @@ void SwitchCave(int cav) { if (Hero) { Hero->Park(); Hero->Step(0); -#ifndef DEMO + if (!_isDemo) ///// protection: auto-destruction on! ---------------------- - Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX); + Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX); /////-------------------------------------------------------- -#endif } CavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); @@ -812,7 +813,7 @@ void SwitchCave(int cav) { } } -SYSTEM::SYSTEM() : SPRITE(NULL) { +SYSTEM::SYSTEM(CGEEngine *vm) : SPRITE(vm, NULL), _vm(vm) { FunDel = HEROFUN0; SetPal(); Tick(); @@ -820,7 +821,6 @@ SYSTEM::SYSTEM() : SPRITE(NULL) { void SYSTEM::Touch(uint16 mask, int x, int y) { static int pp = 0; - void SwitchCave(int cav); FunTouch(); @@ -862,7 +862,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (KEYBOARD::Key[ALT]) SaveMapping(); else - SwitchMapping(); + _vm->SwitchMapping(); break; case F1: SwitchDebug(); @@ -911,7 +911,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { break; case F10 : if (Snail->Idle() && ! Hero->Flags.Hide) - StartCountDown(); + _vm->StartCountDown(); break; case 'J': if (pp == 0) @@ -956,14 +956,14 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (mask & L_UP) { if (cav && Snail->Idle() && Hero->TracePtr < 0) - SwitchCave(cav); + _vm->SwitchCave(cav); if (!HorzLine->Flags.Hide) { if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { int8 x1, z1; XZ(x, y).Split(x1, z1); CLUSTER::Map[z1][x1] = 1; - SetMapBrick(x1, z1); + _vm->SetMapBrick(x1, z1); } } else { @@ -1057,18 +1057,17 @@ static void SwitchMusic(void) { } -static void StartCountDown(void) { +void CGEEngine::StartCountDown() { //SNPOST(SNSEQ, 123, 0, NULL); SwitchCave(-1); } -#ifndef DEMO -static void TakeName(void) { +void CGEEngine::TakeName() { if (GET_TEXT::Ptr) SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr); else { - GET_TEXT *tn = new GET_TEXT(Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick); + GET_TEXT *tn = new GET_TEXT(this, Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick); if (tn) { tn->SetName(Text->getText(GETNAME_TITLE)); tn->Center(); @@ -1078,10 +1077,9 @@ static void TakeName(void) { } } } -#endif -static void SwitchMapping(void) { +void CGEEngine::SwitchMapping() { if (HorzLine->Flags.Hide) { int i; for (i = 0; i < MAP_ZCNT; i++) { @@ -1228,7 +1226,7 @@ static void SwitchDebug(void) { } -static void OptionTouch(int opt, uint16 mask) { +void CGEEngine::OptionTouch(int opt, uint16 mask) { switch (opt) { case 1 : if (mask & L_UP) @@ -1240,7 +1238,7 @@ static void OptionTouch(int opt, uint16 mask) { else if (mask & R_UP) if (! MIXER::Appear) { MIXER::Appear = true; - new MIXER(BUTTON_X, BUTTON_Y); + new MIXER(this, BUTTON_X, BUTTON_Y); } break; case 3 : @@ -1259,7 +1257,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { if (mask & (R_DN | L_DN)) Sprite = this; if (Ref / 10 == 12) { - OptionTouch(Ref % 10, mask); + _vm->OptionTouch(Ref % 10, mask); return; } if (Flags.Syst) @@ -1324,7 +1322,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { } -static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) { +void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) { static const char *Comd[] = { "Name", "Type", "Phase", "East", "Left", "Right", "Top", "Bottom", "Seq", "Near", "Take", @@ -1391,7 +1389,7 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row // make sprite of choosen type switch (type) { case 1 : { // AUTO - Sprite = new SPRITE(NULL); + Sprite = new SPRITE(this, NULL); if (Sprite) { Sprite->Goto(col, row); //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$ @@ -1399,7 +1397,7 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row break; } case 2 : { // WALK - WALK *w = new WALK(NULL); + WALK *w = new WALK(this, NULL); if (w && ref == 1) { w->Goto(col, row); if (Hero) @@ -1444,13 +1442,13 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row break; } case 5 : { // FLY - FLY *f = new FLY(NULL); + FLY *f = new FLY(this, NULL); Sprite = f; //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$ break; } default: { // DEAD - Sprite = new SPRITE(NULL); + Sprite = new SPRITE(this, NULL); if (Sprite) Sprite->Goto(col, row); break; @@ -1474,7 +1472,7 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row } -static void LoadScript(const char *fname) { +void CGEEngine::LoadScript(const char *fname) { char line[LINE_MAX]; char *SpN; int SpI, SpA, SpX, SpY, SpZ; @@ -1534,30 +1532,29 @@ static void LoadScript(const char *fname) { } -static void MainLoop(void) { +void CGEEngine::MainLoop() { SayDebug(); -#ifdef DEMO - static uint32 tc = 0; - if (/* FIXME: TimerCount - tc >= ((182L*6L) * 5L) && */ Talk == NULL && Snail.Idle()) { - if (Text->getText(DemoText)) { - SNPOST(SNSOUND, -1, 4, NULL); // drumla - SNPOST(SNINF, -1, DemoText, NULL); - SNPOST(SNLABEL, -1, -1, NULL); - if (Text->getText(++ DemoText) == NULL) - DemoText = DEMO_TEXT + 1; + if (_isDemo) { + static uint32 tc = 0; + if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ Talk == NULL && Snail->Idle()) { + if (Text->getText(DemoText)) { + SNPOST(SNSOUND, -1, 4, NULL); // drumla + SNPOST(SNINF, -1, DemoText, NULL); + SNPOST(SNLABEL, -1, -1, NULL); + if (Text->getText(++ DemoText) == NULL) + DemoText = DEMO_TEXT + 1; + } + //FIXME: tc = TimerCount; } - //FIXME: tc = TimerCount; } -#endif - Vga->Show(); Snail_->RunCom(); Snail->RunCom(); } -void LoadUser(void) { +void CGEEngine::LoadUser() { // set scene if (STARTUP::Mode == 0) { // user .SVG file found CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt); @@ -1578,7 +1575,7 @@ void LoadUser(void) { } -static void RunGame(void) { +void CGEEngine::RunGame() { Text->Clear(); Text->Preload(100, 1000); LoadHeroXY(); @@ -1689,7 +1686,7 @@ static void RunGame(void) { } -void Movie(const char *ext) { +void CGEEngine::Movie(const char *ext) { const char *fn = ProgName(ext); if (INI_FILE::Exist(fn)) { LoadScript(fn); @@ -1711,13 +1708,13 @@ void Movie(const char *ext) { } -bool ShowTitle(const char *name) { +bool CGEEngine::ShowTitle(const char *name) { BITMAP::Pal = SysPal; BMP_PTR LB[] = { new BITMAP(name), NULL }; BITMAP::Pal = NULL; bool usr_ok = false; - SPRITE D(LB); + SPRITE D(this, LB); D.Flags.Kill = true; D.Flags.BDel = true; D.Center(); @@ -1752,42 +1749,43 @@ bool ShowTitle(const char *name) { } if (STARTUP::Mode < 2) { -#ifdef DEMO - strcpy(UsrFnam, ProgName(SVG_EXT)); - usr_ok = true; -#else - //----------------------------------------- + if (_isDemo) { + strcpy(UsrFnam, ProgName(SVG_EXT)); + usr_ok = true; + } else { + //----------------------------------------- #ifndef EVA #ifdef CD - STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; + STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; #else -// Boot * b = ReadBoot(getdisk()); - warning("ShowTitle: FIXME ReadBoot"); - Boot *b = ReadBoot(0); - uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; - free(b); - sn -= ((IDENT *)Copr)->disk; - STARTUP::Summa |= Lo(sn) | Hi(sn); +// Boot * b = ReadBoot(getdisk()); + warning("ShowTitle: FIXME ReadBoot"); + Boot *b = ReadBoot(0); + uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; + free(b); + sn -= ((IDENT *)Copr)->disk; + STARTUP::Summa |= Lo(sn) | Hi(sn); #endif + //----------------------------------------- + Movie("X00"); // paylist + Vga->CopyPage(1, 2); + Vga->CopyPage(0, 1); + Vga->ShowQ->Append(Mouse); + //Mouse.On(); + Heart->Enable = true; + for (TakeName(); GET_TEXT::Ptr;) + MainLoop(); + Heart->Enable = false; + if (KEYBOARD::Last() == Enter && *UsrFnam) + usr_ok = true; + if (usr_ok) + strcat(UsrFnam, SVG_EXT); + //Mouse.Off(); + Vga->ShowQ->Clear(); + Vga->CopyPage(0, 2); #endif - //----------------------------------------- - Movie("X00"); // paylist - Vga->CopyPage(1, 2); - Vga->CopyPage(0, 1); - Vga->ShowQ->Append(Mouse); - //Mouse.On(); - Heart->Enable = true; - for (TakeName(); GET_TEXT::Ptr;) - MainLoop(); - Heart->Enable = false; - if (KEYBOARD::Last() == Enter && *UsrFnam) - usr_ok = true; - if (usr_ok) - strcat(UsrFnam, SVG_EXT); - //Mouse.Off(); - Vga->ShowQ->Clear(); - Vga->CopyPage(0, 2); -#endif + } + if (usr_ok && STARTUP::Mode == 0) { const char *n = UsrPath(UsrFnam); if (CFILE::Exist(n)) { @@ -1809,11 +1807,10 @@ bool ShowTitle(const char *name) { Vga->CopyPage(0, 2); -#ifdef DEMO - return true; -#else - return (STARTUP::Mode == 2 || usr_ok); -#endif + if (_isDemo) + return true; + else + return (STARTUP::Mode == 2 || usr_ok); } @@ -1825,7 +1822,7 @@ void StkDump (void) { */ -void cge_main(void) { +void CGEEngine::cge_main(void) { uint16 intStack[STACK_SIZ / 2]; intStackPtr = intStack; @@ -1842,17 +1839,15 @@ void cge_main(void) { HorzLine->Flags.Hide = true; //srand((uint16) Timer()); - Sys = new SYSTEM; + Sys = new SYSTEM(this); if (Music && STARTUP::SoundOk) LoadMIDI(0); if (STARTUP::Mode < 2) Movie(LGO_EXT); if (ShowTitle("WELCOME")) { -#ifndef DEMO - if (STARTUP::Mode == 1) + if ((!_isDemo) && (STARTUP::Mode == 1)) Movie("X02"); // intro -#endif RunGame(); Startup = 2; if (FINIS) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index f3a95e786c..146c3cb6c9 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -35,11 +35,11 @@ namespace CGE { #define TSEQ 96 -#define HTALK (TSEQ+4) -#define TOO_FAR (TSEQ+5) -#define NO_WAY (TSEQ+5) -#define POC_FUL (TSEQ+5) -#define OFF_USE (TSEQ+6) +#define HTALK (TSEQ + 4) +#define TOO_FAR (TSEQ + 5) +#define NO_WAY (TSEQ + 5) +#define POC_FUL (TSEQ + 5) +#define OFF_USE (TSEQ + 6) #define EXIT_OK_TEXT 40 #define NOMUSIC_TEXT 98 #define BADSVG_TEXT 99 @@ -57,25 +57,21 @@ namespace CGE { #define DEMO_TEXT 300 #define NOSOUND_TEXT 310 #define PAN_HIG 40 -#define WORLD_HIG (SCR_HIG-PAN_HIG) +#define WORLD_HIG (SCR_HIG - PAN_HIG) #define INFO_X 177 #define INFO_Y 164 #define INFO_W 140 - -#if defined(DEMO) #define CAVE_X 4 #define CAVE_Y 166 #define CAVE_SX 0 #define CAVE_SY 0 + +#ifdef DEMO #define CAVE_DX 23 #define CAVE_DY 29 #define CAVE_NX 3 #define CAVE_NY 1 #else -#define CAVE_X 4 -#define CAVE_Y 166 -#define CAVE_SX 0 -#define CAVE_SY 0 #define CAVE_DX 9 #define CAVE_DY 10 #define CAVE_NX 8 @@ -101,7 +97,7 @@ namespace CGE { #define SHP_MAX 1024 #define STD_DELAY 3 #define LEV_MAX 5 -#define CAVE_MAX (CAVE_NX*CAVE_NY) +#define CAVE_MAX (CAVE_NX * CAVE_NY) #define MAX_FIND_LEVEL 3 #define MAX_DISTANCE 3 #define INI_EXT ".INI" @@ -111,8 +107,8 @@ namespace CGE { #define WALKSIDE 10 #define BUSY_REF 500 #define SYSTIMERATE 6 // 12 Hz -#define HEROFUN0 (40*12) -#define HEROFUN1 ( 2*12) +#define HEROFUN0 (40 * 12) +#define HEROFUN1 ( 2 * 12) #define PAIN (Flag[0]) #define FINIS (Flag[3]) @@ -122,12 +118,14 @@ class SYSTEM : public SPRITE { public: int FunDel; - SYSTEM(); + SYSTEM(CGEEngine *vm); void SetPal(); void FunTouch(); void Touch(uint16 mask, int x, int y); void Tick(); +private: + CGEEngine *_vm; }; @@ -144,9 +142,10 @@ public: class WALK : public SPRITE { public: CLUSTER Here; - enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; int TracePtr; - WALK(BMP_PTR *shpl); + + enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; + WALK(CGEEngine *vm, BMP_PTR *shpl); void Tick(void); void FindWay(CLUSTER c); void FindWay(SPRITE *spr); @@ -155,6 +154,9 @@ public: void Park(void); bool Lower(SPRITE *spr); void Reach(SPRITE *spr, int mode = -1); +private: + CGEEngine *_vm; + }; @@ -163,7 +165,6 @@ CLUSTER XZ(COUPLE xy); void ExpandSprite(SPRITE *spr); void ContractSprite(SPRITE *spr); -void cge_main(void); extern WALK *Hero; extern VGA *Vga; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index fe2d1bc16e..4aa4f40c8a 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -78,83 +78,83 @@ static int DevName[] = { }; static CHOICE DevMenu[] = { - { NULL, NONE }, - { NULL, SB }, - { NULL, SBM }, - { NULL, GUS }, - { NULL, GUSM }, - { NULL, MIDI }, - { NULL, AUTO }, - { NULL, NULL } + { NULL, &CGEEngine::NONE }, + { NULL, &CGEEngine::SB }, + { NULL, &CGEEngine::SBM }, + { NULL, &CGEEngine::GUS }, + { NULL, &CGEEngine::GUSM }, + { NULL, &CGEEngine::MIDI }, + { NULL, &CGEEngine::AUTO }, + { NULL, NULL } }; static CHOICE DigiPorts[] = { - { " 210h", SetPortD }, - { " 220h", SetPortD }, - { " 230h", SetPortD }, - { " 240h", SetPortD }, - { " 250h", SetPortD }, - { " 260h", SetPortD }, - { "AUTO ", SetPortD }, + { " 210h", &CGEEngine::SetPortD }, + { " 220h", &CGEEngine::SetPortD }, + { " 230h", &CGEEngine::SetPortD }, + { " 240h", &CGEEngine::SetPortD }, + { " 250h", &CGEEngine::SetPortD }, + { " 260h", &CGEEngine::SetPortD }, + { "AUTO ", &CGEEngine::SetPortD }, { NULL, NULL } }; static CHOICE MIDIPorts[] = { - { " 220h", SetPortM }, - { " 230h", SetPortM }, - { " 240h", SetPortM }, - { " 250h", SetPortM }, - { " 300h", SetPortM }, - { " 320h", SetPortM }, - { " 330h", SetPortM }, - { " 340h", SetPortM }, - { " 350h", SetPortM }, - { " 360h", SetPortM }, - { "AUTO ", SetPortM }, + { " 220h", &CGEEngine::SetPortM }, + { " 230h", &CGEEngine::SetPortM }, + { " 240h", &CGEEngine::SetPortM }, + { " 250h", &CGEEngine::SetPortM }, + { " 300h", &CGEEngine::SetPortM }, + { " 320h", &CGEEngine::SetPortM }, + { " 330h", &CGEEngine::SetPortM }, + { " 340h", &CGEEngine::SetPortM }, + { " 350h", &CGEEngine::SetPortM }, + { " 360h", &CGEEngine::SetPortM }, + { "AUTO ", &CGEEngine::SetPortM }, { NULL, NULL } }; static CHOICE BlsterIRQ[] = { - { "IRQ 2", SetIRQ }, - { "IRQ 5", SetIRQ }, - { "IRQ 7", SetIRQ }, - { "IRQ 10", SetIRQ }, - { "AUTO ", SetIRQ }, + { "IRQ 2", &CGEEngine::SetIRQ }, + { "IRQ 5", &CGEEngine::SetIRQ }, + { "IRQ 7", &CGEEngine::SetIRQ }, + { "IRQ 10", &CGEEngine::SetIRQ }, + { "AUTO ", &CGEEngine::SetIRQ }, { NULL, NULL } }; static CHOICE GravisIRQ[] = { - { "IRQ 2", SetIRQ }, - { "IRQ 5", SetIRQ }, - { "IRQ 7", SetIRQ }, - { "IRQ 11", SetIRQ }, - { "IRQ 12", SetIRQ }, - { "IRQ 15", SetIRQ }, - { "AUTO ", SetIRQ }, + { "IRQ 2", &CGEEngine::SetIRQ }, + { "IRQ 5", &CGEEngine::SetIRQ }, + { "IRQ 7", &CGEEngine::SetIRQ }, + { "IRQ 11", &CGEEngine::SetIRQ }, + { "IRQ 12", &CGEEngine::SetIRQ }, + { "IRQ 15", &CGEEngine::SetIRQ }, + { "AUTO ", &CGEEngine::SetIRQ }, { NULL, NULL } }; static CHOICE GravisDMA[] = { - { "DMA 1", SetDMA }, - { "DMA 3", SetDMA }, - { "DMA 5", SetDMA }, - { "DMA 6", SetDMA }, - { "DMA 7", SetDMA }, - { "AUTO ", SetDMA }, + { "DMA 1", &CGEEngine::SetDMA }, + { "DMA 3", &CGEEngine::SetDMA }, + { "DMA 5", &CGEEngine::SetDMA }, + { "DMA 6", &CGEEngine::SetDMA }, + { "DMA 7", &CGEEngine::SetDMA }, + { "AUTO ", &CGEEngine::SetDMA }, { NULL, NULL } }; static CHOICE BlsterDMA[] = { - { "DMA 0", SetDMA }, - { "DMA 1", SetDMA }, - { "DMA 3", SetDMA }, - { "AUTO ", SetDMA }, + { "DMA 0", &CGEEngine::SetDMA }, + { "DMA 1", &CGEEngine::SetDMA }, + { "DMA 3", &CGEEngine::SetDMA }, + { "AUTO ", &CGEEngine::SetDMA }, { NULL, NULL } }; -void SelectSound(void) { +void CGEEngine::SelectSound() { int i; Sound.Close(); if (VMENU::Addr) @@ -163,7 +163,7 @@ void SelectSound(void) { Talk->Goto(Talk->X, FONT_HIG / 2); for (i = 0; i < ArrayCount(DevName); i++) DevMenu[i].Text = Text->getText(DevName[i]); - (new VMENU(DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); + (new VMENU(this, DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); } @@ -195,10 +195,10 @@ static uint16 xdeco(const char *str) { static CHOICE *Cho; static int Hlp; -static void SNSelect(void) { +void CGEEngine::SNSelect() { Inf(Text->getText(Hlp)); Talk->Goto(Talk->X, FONT_HIG / 2); - (new VMENU(Cho, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); + (new VMENU(this, Cho, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); } @@ -211,14 +211,14 @@ static void Select(CHOICE *cho, int hlp) { } -static void NONE(void) { +void CGEEngine::NONE() { SNDDrvInfo.DDEV = DEV_QUIET; SNDDrvInfo.MDEV = DEV_QUIET; Sound.Open(); } -static void SB(void) { +void CGEEngine::SB() { SNDDrvInfo.DDEV = DEV_SB; SNDDrvInfo.MDEV = DEV_SB; Reset(); @@ -226,7 +226,7 @@ static void SB(void) { } -static void SBM(void) { +void CGEEngine::SBM() { SNDDrvInfo.DDEV = DEV_SB; SNDDrvInfo.MDEV = DEV_GM; Reset(); @@ -234,7 +234,7 @@ static void SBM(void) { } -static void GUS(void) { +void CGEEngine::GUS() { SNDDrvInfo.DDEV = DEV_GUS; SNDDrvInfo.MDEV = DEV_GUS; Reset(); @@ -242,7 +242,7 @@ static void GUS(void) { } -static void GUSM(void) { +void CGEEngine::GUSM() { SNDDrvInfo.DDEV = DEV_GUS; SNDDrvInfo.MDEV = DEV_GM; Reset(); @@ -250,7 +250,7 @@ static void GUSM(void) { } -static void MIDI(void) { +void CGEEngine::MIDI() { SNDDrvInfo.DDEV = DEV_QUIET; SNDDrvInfo.MDEV = DEV_GM; SNDDrvInfo.MBASE = DETECT; @@ -258,7 +258,7 @@ static void MIDI(void) { } -static void AUTO(void) { +void CGEEngine::AUTO() { SNDDrvInfo.DDEV = DEV_AUTO; SNDDrvInfo.MDEV = DEV_AUTO; Reset(); @@ -266,25 +266,25 @@ static void AUTO(void) { } -static void SetPortD(void) { +void CGEEngine::SetPortD() { SNDDrvInfo.DBASE = xdeco(DigiPorts[VMENU::Recent].Text); Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); } -static void SetPortM(void) { +void CGEEngine::SetPortM() { SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text); Sound.Open(); } -static void SetIRQ(void) { +void CGEEngine::SetIRQ() { SNDDrvInfo.DIRQ = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); } -static void SetDMA(void) { +void CGEEngine::SetDMA() { SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) Select(MIDIPorts, MPORT_TEXT); diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index bebb342c03..f03a42fb35 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -64,7 +64,7 @@ static const ADGameDescription gameDescriptions[] = { {"vol.dat", 0, "75d385a6074c58b69f7730481f256051", 1796710}, AD_LISTEND }, - Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + Common::PL_POL, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE }, { "soltys", "Soltys Demo", @@ -73,7 +73,7 @@ static const ADGameDescription gameDescriptions[] = { {"vol.dat", 0, "c5d9b15863cab61dc125551576dece04", 1075272}, AD_LISTEND }, - Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + Common::PL_POL, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE }, AD_TABLE_END_MARKER }; diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index afa6fbeed0..21e8ceddeb 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -67,8 +67,8 @@ int FLY::L = 20, FLY::B = 100; -FLY::FLY(BITMAP **shpl) - : SPRITE(shpl), Tx(0), Ty(0) { +FLY::FLY(CGEEngine *vm, BITMAP **shpl) + : SPRITE(vm, shpl), Tx(0), Ty(0), _vm(vm) { Step(new_random(2)); Goto(L + new_random(R - L - W), T + new_random(B - T - H)); } diff --git a/engines/cge/game.h b/engines/cge/game.h index 1d65d0c767..7892b1c93f 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -48,8 +48,10 @@ class FLY : public SPRITE { static int L, T, R, B; public: int Tx, Ty; - FLY(BITMAP **shpl); + FLY(CGEEngine *vm, BITMAP **shpl); void Tick(void); +private: + CGEEngine *_vm; }; } // End of namespace CGE diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index b6b47a05f9..69e19b175c 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -36,9 +36,9 @@ namespace CGE { GET_TEXT *GET_TEXT::Ptr = NULL; -GET_TEXT::GET_TEXT(const char *info, char *text, int size, void (*click)(void)) - : Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), - Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)) { +GET_TEXT::GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void)) + : TALK(vm), Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), + Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)), _vm(vm) { int i = 2 * TEXT_HM + Font->Width(info); Ptr = this; Mode = RECT; diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index 3fc7e4ff34..c868232677 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -42,13 +42,16 @@ class GET_TEXT : public TALK { uint16 Size, Len; uint16 Cntr; SPRITE *OldKeybClient; - void (*Click)(void); + void (*Click)(); public: static GET_TEXT *Ptr; - GET_TEXT(const char *info, char *text, int size, void (*click)(void) = NULL); - ~GET_TEXT(void); + GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void) = NULL); + ~GET_TEXT(); void Touch(uint16 mask, int x, int y); - void Tick(void); + void Tick(); + +private: + CGEEngine *_vm; }; } // End of namespace CGE diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 4c96507ab7..12c6609f4e 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -34,7 +34,6 @@ namespace CGE { // Defines found in cge.mak #define VOL -//#define DEMO #define INI_FILE VFILE // Or is it CFILE? #define PIC_FILE VFILE #define BMP_MODE 0 @@ -56,7 +55,7 @@ namespace CGE { #define IsAlNum(c) (IsAlpha(c) || IsDigit(c)) #define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) -#define farnew(t,n) ((t *) malloc(sizeof(t) * (n))) +#define farnew(t, n) ((t *) malloc(sizeof(t) * (n))) #define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) #define MAX_TIMER 0x1800B0L @@ -141,12 +140,6 @@ struct KeyStatStruct { #define PostFlag (*((volatile uint16 *) ((void _seg *) 0x40 + (void *) 0x72))) #define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0)) -#ifdef DEMO -#define Demo(x) x -#else -#define Demo(x) -#endif - #ifdef __cplusplus #define EC extern "C" diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index e0a4409a86..864fb6cdba 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -40,7 +40,7 @@ extern MOUSE *Mouse; bool MIXER::Appear = false; -MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { +MIXER::MIXER(CGEEngine *vm, int x, int y) : SPRITE(vm, NULL), Fall(MIX_FALL), _vm(vm) { Appear = true; mb[0] = new BITMAP("VOLUME"); mb[1] = NULL; @@ -65,7 +65,7 @@ MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { lb[i] = NULL; for (i = 0; i < ArrayCount(Led); i++) { - register SPRITE *spr = new SPRITE(lb); + register SPRITE *spr = new SPRITE(_vm, lb); spr->SetSeq(ls); spr->Goto(x + 2 + 12 * i, y + 8); spr->Flags.Tran = true; diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index 81bc7c7cdf..d589aceaea 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -48,10 +48,12 @@ class MIXER : public SPRITE { void Update(void); public: static bool Appear; - MIXER(int x, int y); - ~MIXER(void); + MIXER(CGEEngine *vm, int x, int y); + ~MIXER(); void Touch(uint16 mask, int x, int y); - void Tick(void); + void Tick(); +private: + CGEEngine *_vm; }; } // End of namespace CGE diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 8ad12742d3..10953291f2 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -39,7 +39,7 @@ MOUSE_FUN *MOUSE::OldMouseFun = NULL; uint16 MOUSE::OldMouseMask = 0; -MOUSE::MOUSE(BITMAP **shpl) : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0) { +MOUSE::MOUSE(CGEEngine *vm, BITMAP **shpl) : SPRITE(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { static SEQ ms[] = { { 0, 0, 0, 0, 1 }, { 1, 1, 0, 0, 1 } diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index 78f43665cd..61503fadd1 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -69,12 +69,14 @@ public: int Buttons; SPRITE *Busy; //SPRITE * Touched; - MOUSE(BITMAP **shpl = MC); - ~MOUSE(void); - void On(void); - void Off(void); + MOUSE(CGEEngine *vm, BITMAP **shpl = MC); + ~MOUSE(); + void On(); + void Off(); static void ClrEvt(SPRITE *spr = NULL); - void Tick(void); + void Tick(); +private: + CGEEngine *_vm; }; } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index cc79dfcc62..7325d767b4 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -424,10 +424,10 @@ const char *SNAIL::ComTxt[] = { }; -SNAIL::SNAIL(bool turbo) +SNAIL::SNAIL(CGEEngine *vm, bool turbo) : Turbo(turbo), Busy(false), TextDelay(false), Pause(0), TalkEnable(true), - Head(0), Tail(0), SNList(farnew(COM, 256)) { + Head(0), Tail(0), SNList(farnew(COM, 256)), _vm(vm) { } @@ -907,7 +907,6 @@ static void SNMouse(bool on) { void SNAIL::RunCom(void) { static int count = 1; -// extern void SwitchCave(int); if (! Busy) { Busy = true; uint8 tmphea = Head; @@ -955,13 +954,13 @@ void SNAIL::RunCom(void) { if (sprel && TalkEnable) { if (sprel == Hero && sprel->SeqTest(-1)) sprel->Step(HTALK); - Say(Text->getText(snc->Val), sprel); + Text->Say(Text->getText(snc->Val), sprel); Sys->FunDel = HEROFUN0; } break; case SNINF : if (TalkEnable) { - Inf(Text->getText(snc->Val)); + _vm->Inf(Text->getText(snc->Val)); Sys->FunDel = HEROFUN0; } break; diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 54c7809fda..9449a8081e 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -29,6 +29,7 @@ #define __SNAIL__ #include "cge/jbw.h" +#include "cge/cge.h" namespace CGE { @@ -89,12 +90,14 @@ public: uint16 Pause; static const char *ComTxt[]; bool TalkEnable; - SNAIL(bool turbo = false); - ~SNAIL(void); + SNAIL(CGEEngine *vm, bool turbo = false); + ~SNAIL(); void RunCom(void); void AddCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL); void InsCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL); bool Idle(void); +private: + CGEEngine *_vm; }; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 9f162d0e6c..b67d9082ac 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -97,8 +97,8 @@ void FONT::Save(void) { */ -TALK::TALK(const char *tx, TBOX_STYLE mode) - : SPRITE(NULL), Mode(mode) { +TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode) + : SPRITE(vm, NULL), Mode(mode), _vm(vm) { TS[0] = TS[1] = NULL; Flags.Syst = true; Update(tx); @@ -106,8 +106,8 @@ TALK::TALK(const char *tx, TBOX_STYLE mode) } -TALK::TALK(void) - : SPRITE(NULL), Mode(PURE) { +TALK::TALK(CGEEngine *vm) + : SPRITE(vm, NULL), Mode(PURE), _vm(vm) { TS[0] = TS[1] = NULL; Flags.Syst = true; } @@ -275,7 +275,7 @@ void TALK::PutLine(int line, const char *text) { } -INFO_LINE::INFO_LINE(uint16 w) : OldTxt(NULL) { +INFO_LINE::INFO_LINE(CGEEngine *vm, uint16 w) : TALK(vm), OldTxt(NULL), _vm(vm) { TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG); SetShapeList(TS); } diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 67b4fc91d6..ba4952c3e6 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -75,20 +75,24 @@ protected: BITMAP *Box(uint16 w, uint16 h); public: FONT *Font; - TALK(const char *tx, TBOX_STYLE mode = PURE); - TALK(void); + TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode = PURE); + TALK(CGEEngine *vm); //~TALK (void); virtual void Update(const char *tx); virtual void Update(void) {} void PutLine(int line, const char *text); +private: + CGEEngine *_vm; }; class INFO_LINE : public TALK { const char *OldTxt; public: - INFO_LINE(uint16 wid); + INFO_LINE(CGEEngine *vm, uint16 wid); void Update(const char *tx); +private: + CGEEngine *_vm; }; } // End of namespace CGE diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index a8bf0d0cf8..6d7341af0a 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -42,7 +42,7 @@ namespace CGE { TEXT *Text; TALK *Talk = NULL; -TEXT::TEXT(const char *fname, int size) { +TEXT::TEXT(CGEEngine *vm, const char *fname, int size) : _vm(vm) { Cache = new HAN[size]; MergeExt(FileName, fname, SAY_EXT); if (!INI_FILE::Exist(FileName)) @@ -55,7 +55,7 @@ TEXT::TEXT(const char *fname, int size) { } -TEXT::~TEXT(void) { +TEXT::~TEXT() { Clear(); delete[] Cache; } @@ -180,14 +180,14 @@ char *TEXT::getText(int ref) { } -void Say(const char *txt, SPRITE *spr) { +void TEXT::Say(const char *txt, SPRITE *spr) { KillText(); - Talk = new TALK(txt, ROUND); + Talk = new TALK(_vm, txt, ROUND); if (Talk) { bool east = spr->Flags.East; int x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2); int y = spr->Y + 2; - SPRITE *spike = new SPRITE(SP); + SPRITE *spike = new SPRITE(_vm, SP); uint16 sw = spike->W; if (east) { @@ -221,9 +221,9 @@ void Say(const char *txt, SPRITE *spr) { } } -void Inf(const char *txt) { +void CGEEngine::Inf(const char *txt) { KillText(); - Talk = new TALK(txt, RECT); + Talk = new TALK(this, txt, RECT); if (Talk) { Talk->Flags.Kill = true; Talk->Flags.BDel = true; diff --git a/engines/cge/text.h b/engines/cge/text.h index 64e3b1d669..161b2e813a 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -61,11 +61,14 @@ class TEXT { char *Load(int idx, int ref); int Find(int ref); public: - TEXT(const char *fname, int size); + TEXT(CGEEngine *vm, const char *fname, int size); ~TEXT(void); void Clear(int from = 1, int upto = 0x7FFF); void Preload(int from = 1, int upto = 0x7FFF); char *getText(int ref); + void Say(const char *txt, SPRITE *spr); +private: + CGEEngine *_vm; }; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d7c6946e87..1038cd2631 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -35,6 +35,7 @@ #include #include #include +#include "cge/cge.h" namespace CGE { @@ -345,10 +346,10 @@ void HEART::SetXTimer(uint16 *ptr, uint16 time) { } -SPRITE::SPRITE(BMP_PTR *shp) +SPRITE::SPRITE(CGEEngine *vm, BMP_PTR *shp) : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), - Ext(NULL), Ref(-1), Cave(0) { + Ext(NULL), Ref(-1), Cave(0), _vm(vm) { memset(File, 0, sizeof(File)); *((uint16 *)&Flags) = 0; SetShapeList(shp); diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index d5bbf3972e..7d23954059 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -32,6 +32,7 @@ #include #include "cge/bitmap.h" #include "cge/snail.h" +#include "cge/cge.h" namespace CGE { @@ -197,7 +198,7 @@ public: inline bool Active(void) { return Ext != NULL; } - SPRITE(BMP_PTR *shp); + SPRITE(CGEEngine *vm, BMP_PTR *shp); virtual ~SPRITE(void); BMP_PTR Shp(void); BMP_PTR *SetShapeList(BMP_PTR *shp); @@ -222,6 +223,8 @@ public: SNAIL::COM *SnList(SNLIST type); virtual void Touch(uint16 mask, int x, int y); virtual void Tick(void); +private: + CGEEngine *_vm; }; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index e2b2a29515..7db5a79f85 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -45,7 +45,7 @@ namespace CGE { -MENU_BAR::MENU_BAR(uint16 w) { +MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : TALK(vm), _vm(vm) { int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; uint8 *p = farnew(uint8, i), * p1, * p2; @@ -98,8 +98,8 @@ VMENU *VMENU::Addr = NULL; int VMENU::Recent = -1; -VMENU::VMENU(CHOICE *list, int x, int y) - : TALK(VMGather(list), RECT), Menu(list), Bar(NULL) { +VMENU::VMENU(CGEEngine *vm, CHOICE *list, int x, int y) + : TALK(vm, VMGather(list), RECT), Menu(list), Bar(NULL), _vm(vm) { CHOICE *cp; Addr = this; @@ -114,7 +114,7 @@ VMENU::VMENU(CHOICE *list, int x, int y) else Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); Vga->ShowQ->Insert(this, Vga->ShowQ->Last()); - Bar = new MENU_BAR(W - 2 * TEXT_HM); + Bar = new MENU_BAR(_vm, W - 2 * TEXT_HM); Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM); Vga->ShowQ->Insert(Bar, Vga->ShowQ->Last()); } @@ -126,7 +126,7 @@ VMENU::~VMENU(void) { void VMENU::Touch(uint16 mask, int x, int y) { -#define h (FONT_HIG + TEXT_LS) + uint16 h = FONT_HIG + TEXT_LS; bool ok = false; if (Items) { @@ -147,10 +147,10 @@ void VMENU::Touch(uint16 mask, int x, int y) { if (ok && (mask & L_UP)) { Items = 0; SNPOST_(SNKILL, -1, 0, this); - Menu[Recent = n].Proc(); + //Menu[Recent = n].Proc(); + warning("Missing call to proc()"); } } -#undef h } } // End of namespace CGE diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index ecec9d51b5..61645d2c55 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -38,13 +38,15 @@ namespace CGE { typedef struct { char *Text; - void (* Proc)(void); + void (CGEEngine::*Proc)(); } CHOICE; class MENU_BAR : public TALK { public: - MENU_BAR(uint16 w); + MENU_BAR(CGEEngine *vm, uint16 w); +private: + CGEEngine *_vm; }; @@ -55,9 +57,11 @@ public: static VMENU *Addr; static int Recent; MENU_BAR *Bar; - VMENU(CHOICE *list, int x, int y); - ~VMENU(void); + VMENU(CGEEngine *vm, CHOICE *list, int x, int y); + ~VMENU(); void Touch(uint16 mask, int x, int y); +private: + CGEEngine *_vm; }; } // End of namespace CGE -- cgit v1.2.3 From e13317baeab99f4868d49a89e110deda1d5ca5f4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 27 Jun 2011 18:57:58 +1000 Subject: CGE: Beginnings of work on graphics support --- engines/cge/bitmap.cpp | 20 ++- engines/cge/bitmap.h | 5 + engines/cge/cge.cpp | 4 + engines/cge/cge_main.cpp | 17 +- engines/cge/general.cpp | 7 +- engines/cge/snail.cpp | 9 +- engines/cge/vga13h.cpp | 395 +++++++++++++++-------------------------------- engines/cge/vga13h.h | 11 +- 8 files changed, 179 insertions(+), 289 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index b528b5578d..4112ccb380 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -30,6 +30,7 @@ #include "cge/jbw.h" #include "cge/vol.h" #include "cge/cfile.h" +#include "cge/vga13h.h" #include "common/system.h" namespace CGE { @@ -37,6 +38,13 @@ namespace CGE { DAC *BITMAP::Pal = NULL; #define MAXPATH 128 +void BITMAP::init() { + Pal = NULL; +} + +void BITMAP::deinit() { +} + #pragma argsused BITMAP::BITMAP(const char *fname, bool rem) : M(NULL), V(NULL) { char pat[MAXPATH]; @@ -369,7 +377,7 @@ bool BITMAP::VBMSave(XFILE *f) { if (f->Error == 0) if (p) - f->Write((uint8 *)Pal, 256 * sizeof(DAC)); + f->Write((uint8 *)Pal, 256 * 3); if (f->Error == 0) f->Write(V, n); @@ -394,10 +402,12 @@ bool BITMAP::VBMLoad(XFILE *f) { if (f->Error == 0) { if (p) { - if (Pal) - f->Read((uint8 *)Pal, 256 * sizeof(DAC)); - else - f->Seek(f->Mark() + 256 * sizeof(DAC)); + if (Pal) { + byte palData[PAL_SIZ]; + f->Read(palData, PAL_SIZ); + VGA::pal2DAC(palData, Pal); + } else + f->Seek(f->Mark() + PAL_SIZ); } } if ((V = farnew(uint8, n)) == NULL) diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index eca3be70e8..13e28f4369 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -39,6 +39,7 @@ namespace CGE { #define TRANS 0xFE +#include "common/pack-start.h" typedef struct { uint16 b : 2; @@ -56,6 +57,7 @@ typedef struct { uint16 hide; } HideDesc; +#include "common/pack-end.h" class BITMAP { bool BMPLoad(XFILE *f); @@ -70,6 +72,9 @@ public: BITMAP(uint16 w, uint16 h, uint8 fill); BITMAP(const BITMAP &bmp); ~BITMAP(void); + static void init(); + static void deinit(); + BITMAP *FlipH(void); BITMAP *Code(); BITMAP &operator = (const BITMAP &bmp); diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index d056a6737d..287586e092 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -53,7 +53,9 @@ void CGEEngine::setup() { _console = new CGEConsole(this); // Initialise classes that have static members + BITMAP::init(); VFILE::init(); + VGA::init(); // Initialise engine objects Text = new TEXT(ProgName(), 128); @@ -99,7 +101,9 @@ CGEEngine::~CGEEngine() { debug("CGEEngine::~CGEEngine"); // Call classes with static members to clear them up + BITMAP::deinit(); VFILE::deinit(); + VGA::deinit(); // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index ec8f743fe4..d49f71cd99 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -128,7 +128,6 @@ static int DemoText = DEMO_TEXT; //-------------------------------------------------------------------------- bool JBW = false; -DAC *SysPal = farnew(DAC, PAL_CNT); //------------------------------------------------------------------------- int PocPtr = 0; @@ -652,7 +651,7 @@ static void PostMiniStep(int stp) { void SYSTEM::SetPal(void) { int i; - DAC *p = SysPal + 256 - ArrayCount(StdPal); + DAC *p = VGA::SysPal + 256 - ArrayCount(StdPal); for (i = 0; i < ArrayCount(StdPal); i ++) { p[i].R = StdPal[i].R >> 2; p[i].G = StdPal[i].G >> 2; @@ -671,7 +670,7 @@ void SYSTEM::FunTouch(void) { static void ShowBak(int ref) { SPRITE *spr = Vga->SpareQ->Locate(ref); if (spr) { - BITMAP::Pal = SysPal; + BITMAP::Pal = VGA::SysPal; spr->Expand(); BITMAP::Pal = NULL; spr->Show(2); @@ -727,7 +726,7 @@ static void CaveUp(void) { if (Shadow) { Vga->ShowQ->Remove(Shadow); - Shadow->MakeXlat(Glass(SysPal, 204, 204, 204)); + Shadow->MakeXlat(Glass(VGA::SysPal, 204, 204, 204)); Vga->ShowQ->Insert(Shadow, Hero); Shadow->Z = Hero->Z; } @@ -735,7 +734,7 @@ static void CaveUp(void) { Vga->Show(); Vga->CopyPage(1, 0); Vga->Show(); - Vga->Sunrise(SysPal); + Vga->Sunrise(VGA::SysPal); Dark = false; if (! Startup) Mouse->On(); @@ -1027,7 +1026,7 @@ static void SpkClose(void) { static void SwitchColorMode(void) { SNPOST_(SNSEQ, 121, Vga->Mono = !Vga->Mono, NULL); KeyClick(); - Vga->SetColors(SysPal, 64); + Vga->SetColors(VGA::SysPal, 64); } @@ -1712,7 +1711,7 @@ void Movie(const char *ext) { bool ShowTitle(const char *name) { - BITMAP::Pal = SysPal; + BITMAP::Pal = VGA::SysPal; BMP_PTR LB[] = { new BITMAP(name), NULL }; BITMAP::Pal = NULL; bool usr_ok = false; @@ -1732,7 +1731,7 @@ bool ShowTitle(const char *name) { Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); SelectPocket(-1); - Vga->Sunrise(SysPal); + Vga->Sunrise(VGA::SysPal); if (STARTUP::Mode < 2 && !STARTUP::SoundOk) { Vga->CopyPage(1, 2); @@ -1793,7 +1792,7 @@ bool ShowTitle(const char *name) { if (CFILE::Exist(n)) { CFILE file = CFILE(n, REA, RCrypt); LoadGame(file, true); // only system vars - Vga->SetColors(SysPal, 64); + Vga->SetColors(VGA::SysPal, 64); Vga->Update(); if (FINIS) { ++ STARTUP::Mode; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 9caa864227..a851957b21 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -127,7 +127,12 @@ char *ForceExt(char *buf, const char *nam, const char *ext) { // fnsplit(nam, dr, di, na, ex); // fnmerge(buf, dr, di, na, ext); // return buf; - warning("STUB: ForceExt"); + strcpy(buf, nam); + char *dot = strrchr(buf, '.'); + if (dot) + *dot = '\0'; + strcat(buf, ext); + return buf; } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 2b36ca4325..a07cf9d09b 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -65,7 +65,6 @@ extern SPRITE *PocLight; //------------------------------------------------------------------------- extern SPRITE *Pocket[]; extern int PocPtr; -extern DAC *SysPal; static void SNGame(SPRITE *spr, int num) { switch (num) { @@ -576,7 +575,7 @@ void SNSend(SPRITE *spr, int val) { spr->Flags.Slav = false; } else { if (spr->Ref % 1000 == 0) - BITMAP::Pal = SysPal; + BITMAP::Pal = VGA::SysPal; if (spr->Flags.Back) spr->BackShow(true); else @@ -849,7 +848,7 @@ void SNFlash(bool on) { if (on) { DAC *pal = farnew(DAC, PAL_CNT); if (pal) { - memcpy(pal, SysPal, PAL_SIZ); + memcpy(pal, VGA::SysPal, PAL_SIZ); for (int i = 0; i < PAL_CNT; i ++) { register int c; c = pal[i].R << 1; @@ -862,14 +861,14 @@ void SNFlash(bool on) { Vga->SetColors(pal, 64); } } else - Vga->SetColors(SysPal, 64); + Vga->SetColors(VGA::SysPal, 64); Dark = false; } static void SNLight(bool in) { if (in) - Vga->Sunrise(SysPal); + Vga->Sunrise(VGA::SysPal); else Vga->Sunset(); Dark = ! in; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 349f412ca0..f5fde14122 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -25,6 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ +#include "common/rect.h" +#include "graphics/palette.h" #include "cge/general.h" #include "cge/vga13h.h" #include "cge/bitmap.h" @@ -737,7 +739,7 @@ void SPRITE::Show(void) { void SPRITE::Show(uint16 pg) { - uint8 *a = VGA::Page[1]; + Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; Shp()->Show(X, Y); VGA::Page[1] = a; @@ -886,17 +888,25 @@ SPRITE *QUEUE::Locate(int ref) { } -// TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that -uint8 *VGA::Page[4] = { 0, 0, 0, 0 }; +//extern const char Copr[]; +Graphics::Surface *VGA::Page[4]; +DAC *VGA::SysPal; -/* -uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), - (uint8 *) MK_FP(SCR_SEG, 0x4000), - (uint8 *) MK_FP(SCR_SEG, 0x8000), - (uint8 *) MK_FP(SCR_SEG, 0xC000) }; -*/ +void VGA::init() { + for (int idx = 0; idx < 4; ++idx) { + Page[idx] = new Graphics::Surface(); + Page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); + } -//extern const char Copr[]; + SysPal = new DAC[PAL_CNT]; +} + +void VGA::deinit() { + for (int idx = 0; idx < 4; ++idx) { + delete Page[idx]; + } + delete[] SysPal; +} VGA::VGA(int mode) : FrmCnt(0), OldMode(0), OldScreen(NULL), StatAdr(VGAST1_), @@ -977,21 +987,9 @@ void VGA::SetStatAdr(void) { #pragma argsused void VGA::WaitVR(bool on) { - /* - _DX = StatAdr; - _AH = (on) ? 0x00 : 0x08; - - asm mov cx,2 - // wait for vertical retrace on (off) - wait: - asm in al,dx - asm xor al,ah - asm test al,0x08 - asm jnz wait - asm xor ah,0x08 - asm loop wait - */ - warning("STUB: VGA::WaitVR"); + // Since some of the game parts rely on using vertical sync as a delay mechanism, + // we're introducing a short delay to simulate it + g_system->delayMillis(10); } @@ -1039,102 +1037,54 @@ void VGA::Setup(VgaRegBlk *vrb) { int VGA::SetMode(int mode) { - /* - Clear(); - // get current mode - asm mov ah,0x0F - Video(); // BIOS video service - asm xor ah,ah - asm push ax - - // wait for v-retrace - WaitVR(); - - // set mode - asm xor ah,ah - asm mov al,byte ptr mode - Video(); // BIOS video service - SetStatAdr(); - // return previous mode - asm pop ax - return _AX; - */ - warning("STUB: VGA::SetMode"); + // ScummVM provides it's own vieo services return 0; } void VGA::GetColors(DAC *tab) { - /* - asm cld - asm les di,tab // color table - asm mov dx,0x3C7 // PEL address read mode register - asm xor al,al // start from address 0 - asm out dx,al // put address - asm mov cx,256*3 // # of colors - asm mov dl,0xC9 // PEL data register - - // asm rep insb // very fast! - - gc: // much slower: - asm in al,dx // take 1 color - asm jmp sto // little delay - sto: - asm stosb // store 1 color - asm loop gc // next one? - */ - warning("STUB: VGA::GetColors"); + byte palData[PAL_SIZ]; + g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT); + pal2DAC(palData, tab); } +void VGA::pal2DAC(const byte *palData, DAC *tab) { + const byte *colP = palData; + for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { + tab[idx].R = *colP; + tab[idx].G = *(colP + 1); + tab[idx].B = *(colP + 2); + } +} + +void VGA::DAC2pal(const DAC *tab, byte *palData) { + for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { + *palData = tab[idx].R; + *(palData + 1) = tab[idx].G; + *(palData + 2) = tab[idx].B; + } +} void VGA::SetColors(DAC *tab, int lum) { - /* - DAC * des = NewColors; - asm push ds - - asm les di,des - asm lds si,tab - asm mov cx,256*3 - asm xor bx,bx - asm mov dx,lum - - copcol: - asm mov al,[si+bx] - asm mul dl - asm shr ax,6 - asm mov es:[di+bx],al - asm inc bx - asm cmp bx,cx - asm jb copcol - - asm pop ds - - if (Mono) - { - asm add cx,di - mono: - asm xor dx,dx - asm mov al,77 // 30% R - asm mul byte ptr es:[di].0 - asm add dx,ax - asm mov al,151 // 59% G - asm mul byte ptr es:[di].1 - asm add dx,ax - asm mov al,28 // 11% B - asm mul byte ptr es:[di].2 - asm add dx,ax - - asm mov es:[di].0,dh - asm mov es:[di].1,dh - asm mov es:[di].2,dh - - asm add di,3 - asm cmp di,cx - asm jb mono - } - */ + DAC *palP = tab; + for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { + palP->R = (palP->R * lum) >> 6; + palP->G = (palP->G * lum) >> 6; + palP->B = (palP->B * lum) >> 6; + } + + if (Mono) { + palP = tab; + for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { + // Form a greyscalce colour from 30% R, 59% G, 11% B + uint8 intensity = (palP->R * 77) + (palP->G * 151) + (palP->B * 28); + palP->R = intensity; + palP->G = intensity; + palP->B = intensity; + } + } + SetPal = true; - warning("STUB: VGA::SetColors"); } @@ -1178,113 +1128,33 @@ void VGA::Show(void) { void VGA::UpdateColors(void) { - /* - DAC * tab = NewColors; - - asm push ds - asm cld - asm lds si,tab // color table - asm mov dx,0x3C8 // PEL address write mode register - asm xor al,al // start from address 0 - asm out dx,al // put address - asm mov cx,256*3 // # of colors - asm mov dl,0xC9 // PEL data register - - // asm rep outsb // very fast! - - // the slower version of above: - sc: - asm lodsb // take 1/3 color - asm out dx,al // put 1/3 color - asm jmp loop // little delay - loop: - asm loop sc // next one? - - - asm pop ds - */ - warning("STUB: VGA::UpdateColors"); + byte palData[PAL_SIZ]; + DAC2pal(NewColors, palData); + g_system->getPaletteManager()->setPalette(palData, 0, 256); } void VGA::Update(void) { - /* - uint8 * p = Page[1]; - Page[1] = Page[0]; - Page[0] = p; - - asm mov dx,VGACRT_ - asm mov al,0x0D - asm mov ah,byte ptr p - asm out dx,ax - asm dec al - asm mov ah,byte ptr p+1 - asm out dx,ax - */ - if (! SpeedTest) - WaitVR(true); + SWAP(VGA::Page[0], VGA::Page[1]); if (SetPal) { UpdateColors(); SetPal = false; } - warning("STUB: VGA::Update"); + + g_system->copyRectToScreen((const byte *)VGA::Page[0]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); + g_system->updateScreen(); } void VGA::Clear(uint8 color) { - /* - uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); - - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // map mask register - enable all planes - asm out dx,ax - asm les di,a - asm cld - - asm mov cx,0xFFFF - asm mov al,color - asm rep stosb - asm stosb - */ - warning("STUB: VGA::Clear"); + for (int paneNum = 0; paneNum < 4; ++paneNum) + Page[paneNum]->fillRect(Common::Rect(0, 0, SCR_WID, SCR_HIG), color); } void VGA::CopyPage(uint16 d, uint16 s) { - /* - uint8 * S = Page[s & 3], * D = Page[d & 3]; - - asm mov dx,VGAGRA_ - asm mov al,0x05 // R/W mode - asm out dx,al - asm inc dx - asm in al,dx - asm and al,0xF4 - asm push ax - asm push dx - asm or al,0x01 - asm out dx,al - - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // map mask register - enable all planes - asm out dx,ax - - asm push ds - - asm les di,D - asm lds si,S - asm cld - asm mov cx,0x4000 - asm rep movsb - - asm pop ds - - asm pop dx - asm pop ax - asm out dx,al // end of copy mode - */ - warning("STUB: VGA::CopyPage"); + Page[d]->copyFrom(*Page[s]); } //-------------------------------------------------------------------------- @@ -1372,72 +1242,63 @@ void BITMAP::XShow(int x, int y) { void BITMAP::Show(int x, int y) { - /* - uint8 mask = 1 << (x & 3), - * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - uint8 * v = V; - - asm push ds // preserve DS - - asm cld // normal direction - asm les di,scr // screen address - asm lds si,v // picture address - asm mov dx,VGASEQ_ // VGA reg - asm mov al,0x02 - asm mov ah,mask - - plane: - asm out dx,ax - asm push ax - asm push di - - block: - asm mov cx,[si] // with ADD faster then LODSW - asm add si,2 - asm test ch,0xC0 - asm jns skip // 1 (SKP) or 0 (EOI) - asm jpo repeat // 2 (REP) - - copy: // 3 (CPY) - asm and ch,0x3F - asm shr cx,1 - asm rep movsw - asm jnc block - asm movsb - asm jmp block - - repeat: - asm and ch,0x3F - asm mov al,[si] - asm inc si - asm mov ah,al - asm shr cx,1 - asm rep stosw - asm jnc block - asm mov es:[di],al - asm inc di - asm jmp block - - skip: - asm jz endpl - asm and ch,0x3F - asm add di,cx - asm jmp block - - endpl: - asm pop di - asm pop ax - asm shl ah,1 - asm test ah,0x10 - asm jz x_chk - asm mov ah,0x01 - asm inc di - x_chk: - asm cmp ah,mask - asm jne plane - asm pop ds - */ - warning("STUB: BITMAP::Show"); + const byte *srcP = (const byte *)V; + byte *destP = (byte *)VGA::Page[1]->getBasePtr(x, y); + + int yc = 0, xc = 0; + + for (;;) { + uint16 v = READ_LE_UINT16(srcP); + srcP += 2; + int cmd = v >> 14; + int count = v & 0x3FFF; + + if (cmd == 0) + // End of image + break; + + // Handle a set of pixels + while (count-- > 0) { + // Transfer operation + switch (cmd) { + case 1: + // SKIP + break; + case 2: + // REPEAT + *destP = *srcP; + break; + case 3: + // COPY + *destP = *srcP++; + break; + } + + // Move to next dest position + ++destP; + ++xc; + if (xc == W) { + xc = 0; + ++yc; + if (yc == H) + return; + + destP = (byte *)VGA::Page[1]->getBasePtr(x, y + yc); + } + } + + if (cmd == 2) + ++srcP; + } + + // Temporary + g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); + byte palData[PAL_SIZ]; + VGA::DAC2pal(VGA::SysPal, palData); + g_system->getPaletteManager()->setPalette(palData, 0, PAL_CNT); + + g_system->updateScreen(); + g_system->delayMillis(5000); } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 63886d9a99..edbeebf727 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -28,6 +28,7 @@ #ifndef __VGA13H__ #define __VGA13H__ +#include "graphics/surface.h" #include "cge/general.h" #include #include "cge/bitmap.h" @@ -111,7 +112,7 @@ extern SEQ Seq2[]; #define PAL_CNT 256 -#define PAL_SIZ (PAL_CNT * sizeof(DAC)) +#define PAL_SIZ (PAL_CNT * 3) #define VGAATR_ 0x3C0 #define VGAMIw_ 0x3C0 #define VGASEQ_ 0x3C4 @@ -265,10 +266,13 @@ public: uint32 FrmCnt; QUEUE *ShowQ, *SpareQ; int Mono; - static uint8 *Page[4]; + static Graphics::Surface *Page[4]; + static DAC *VGA::SysPal; VGA(int mode); ~VGA(void); + static void init(); + static void deinit(); void Setup(VgaRegBlk *vrb); void GetColors(DAC *tab); @@ -279,6 +283,9 @@ public: void Sunset(void); void Show(void); void Update(void); + + static void pal2DAC(const byte *palData, DAC *tab); + static void DAC2pal(const DAC *tab, byte *palData); }; -- cgit v1.2.3 From 571c3fc666ce95ce880e7a428585ea99c7c66fd2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 27 Jun 2011 21:29:18 +1000 Subject: CGE: Getting closer to properly showing bitmap images --- engines/cge/vga13h.cpp | 94 ++++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 42 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 1804d25aa9..32e0fd6090 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1064,9 +1064,9 @@ void VGA::pal2DAC(const byte *palData, DAC *tab) { void VGA::DAC2pal(const DAC *tab, byte *palData) { for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { - *palData = tab[idx].R; - *(palData + 1) = tab[idx].G; - *(palData + 2) = tab[idx].B; + *palData = tab[idx].R << 2; + *(palData + 1) = tab[idx].G << 2; + *(palData + 2) = tab[idx].B << 2; } } @@ -1247,53 +1247,63 @@ void BITMAP::XShow(int x, int y) { void BITMAP::Show(int x, int y) { - const byte *srcP = (const byte *)V; - byte *destP = (byte *)VGA::Page[1]->getBasePtr(x, y); - - int yc = 0, xc = 0; - - for (;;) { - uint16 v = READ_LE_UINT16(srcP); - srcP += 2; - int cmd = v >> 14; - int count = v & 0x3FFF; - - if (cmd == 0) - // End of image - break; + // Create a temporary surface to hold the unpacked bitmap data + Graphics::Surface rawSurface; + rawSurface.create(W, H, Graphics::PixelFormat::createFormatCLUT8()); - // Handle a set of pixels - while (count-- > 0) { - // Transfer operation - switch (cmd) { - case 1: - // SKIP - break; - case 2: - // REPEAT - *destP = *srcP; - break; - case 3: - // COPY - *destP = *srcP++; + const byte *srcP = (const byte *)V; + byte *destP = (byte *)rawSurface.pixels; + byte *destEndP = destP + (W * H); + Common::set_to(destP, destEndP, 0); + + // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a + // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data + // must be decompressed and inserted into the surface + for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { + destP = (byte *)rawSurface.getBasePtr(planeCtr, 0); + + while (destP < destEndP) { + uint16 v = READ_LE_UINT16(srcP); + srcP += 2; + int cmd = v >> 14; + int count = v & 0x3FFF; + + if (cmd == 0) { + // End of image break; } - // Move to next dest position - ++destP; - ++xc; - if (xc == W) { - xc = 0; - ++yc; - if (yc == H) - return; + // Handle a set of pixels + while (count-- > 0) { + // Transfer operation + switch (cmd) { + case 1: + // SKIP + break; + case 2: + // REPEAT + *destP = *srcP; + break; + case 3: + // COPY + *destP = *srcP++; + break; + } - destP = (byte *)VGA::Page[1]->getBasePtr(x, y + yc); + // Move to next dest position + destP += 4; } + + if (cmd == 2) + ++srcP; } + } - if (cmd == 2) - ++srcP; + // Copy the decompressed buffer to the specified x/y position on Page #1 + for (int yc = 0; yc < rawSurface.h; ++yc) { + srcP = (const byte *)rawSurface.getBasePtr(0, yc); + destP = (byte *)VGA::Page[1]->getBasePtr(x, y + yc); + Common::copy(srcP, srcP + rawSurface.w, destP); } // Temporary -- cgit v1.2.3 From 315bbd348d490d3edf6f5dcfb58ffcc9ecde83b3 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Mon, 27 Jun 2011 19:25:24 +0200 Subject: CGE: Fix some GCC compile errors and warnings. --- engines/cge/cge_main.cpp | 2 +- engines/cge/general.cpp | 19 +++++++++++-------- engines/cge/general.h | 3 ++- engines/cge/mixer.cpp | 4 ++-- engines/cge/snail.cpp | 2 +- engines/cge/vga13h.h | 2 +- engines/cge/vmenu.h | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index cd8a8ff9df..90b14d2c70 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -652,7 +652,7 @@ static void PostMiniStep(int stp) { } void SYSTEM::SetPal(void) { - int i; + uint i; DAC *p = VGA::SysPal + 256 - ArrayCount(StdPal); for (i = 0; i < ArrayCount(StdPal); i++) { p[i].R = StdPal[i].R >> 2; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index b07ddbc362..1bf4bcd982 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -215,6 +215,7 @@ char *dwtom(uint32 val, char *str, int radix, int len) { IOHAND::IOHAND(IOMODE mode, CRYPT *crpt) : XFILE(mode), Crypt(crpt), Seed(SEED) { + _file = new Common::File(); } IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt) @@ -222,18 +223,20 @@ IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt) // TODO: Check if WRI and/or UPD modes are needed, and map to a save file assert(mode == REA); - _file.open(name); + _file = new Common::File(); + _file->open(name); } IOHAND::~IOHAND(void) { - _file.close(); + _file->close(); + delete _file; } uint16 IOHAND::Read(void *buf, uint16 len) { - if (Mode == WRI || !_file.isOpen()) + if (Mode == WRI || !_file->isOpen()) return 0; - uint16 bytesRead = _file.read(buf, len); + uint16 bytesRead = _file->read(buf, len); if (Crypt) Seed = Crypt(buf, len, Seed); return bytesRead; } @@ -255,16 +258,16 @@ uint16 IOHAND::Write(void *buf, uint16 len) { } long IOHAND::Mark(void) { - return _file.pos(); + return _file->pos(); } long IOHAND::Seek(long pos) { - _file.seek(pos, SEEK_SET); - return _file.pos(); + _file->seek(pos, SEEK_SET); + return _file->pos(); } long IOHAND::Size(void) { - return _file.size(); + return _file->size(); } bool IOHAND::Exist(const char *name) { diff --git a/engines/cge/general.h b/engines/cge/general.h index 6fb8e24f9c..4946e40c7b 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -173,6 +173,7 @@ public: virtual long Mark(void) = 0; virtual long Size(void) = 0; virtual long Seek(long pos) = 0; + virtual ~XFILE() { } }; @@ -184,7 +185,7 @@ inline uint16 XRead(XFILE *xf, T *t) { class IOHAND : public XFILE { protected: - Common::File _file; + Common::File *_file; uint16 Seed; CRYPT *Crypt; public: diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 864fb6cdba..ecdd2b7533 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -54,7 +54,7 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : SPRITE(vm, NULL), Fall(MIX_FALL), _v // slaves - int i; + uint i; for (i = 0; i < MIX_MAX; i++) { static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); @@ -124,7 +124,7 @@ void MIXER::Tick(void) { if (Fall) --Fall; else { - for (int i = 0; i < ArrayCount(Led); i++) + for (uint i = 0; i < ArrayCount(Led); i++) SNPOST_(SNKILL, -1, 0, Led[i]); SNPOST_(SNKILL, -1, 0, this); } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 24ed08c140..0137ab4cfa 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -92,7 +92,7 @@ static void SNGame(SPRITE *spr, int num) { ++ Stage; if (hand && Stage > DRESSED) ++hand; - if (i >= 0 || dup[i] == spr && new_random(3) == 0) { + if (i >= 0 || (dup[i] == spr && new_random(3) == 0)) { SNPOST(SNSEQ, -1, 3, dup[0]); // yes SNPOST(SNSEQ, -1, 3, dup[1]); // yes SNPOST(SNSEQ, -1, 3, dup[2]); // yes diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index cf4252e5c2..c984e121e8 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -270,7 +270,7 @@ public: QUEUE *ShowQ, *SpareQ; int Mono; static Graphics::Surface *Page[4]; - static DAC *VGA::SysPal; + static DAC *SysPal; VGA(int mode); ~VGA(void); diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 61645d2c55..3c38576a40 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -37,7 +37,7 @@ namespace CGE { typedef struct { - char *Text; + const char *Text; void (CGEEngine::*Proc)(); } CHOICE; -- cgit v1.2.3 From 2fe6061d919a84e1f2849415902b3e91403bf69d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 28 Jun 2011 21:58:03 +1000 Subject: CGE: Bitmap now shows correctly --- engines/cge/vga13h.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 32e0fd6090..21aec31e5d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1261,8 +1261,8 @@ void BITMAP::Show(int x, int y) { // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { destP = (byte *)rawSurface.getBasePtr(planeCtr, 0); - - while (destP < destEndP) { + + for (;;) { uint16 v = READ_LE_UINT16(srcP); srcP += 2; int cmd = v >> 14; @@ -1273,6 +1273,8 @@ void BITMAP::Show(int x, int y) { break; } + assert(destP < destEndP); + // Handle a set of pixels while (count-- > 0) { // Transfer operation -- cgit v1.2.3 From a89ce394bcaa9f967f2db7e9281bf25f381ceb69 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 28 Jun 2011 22:18:21 +1000 Subject: CGE: Fix initialisation of the TALK class --- engines/cge/cge.cpp | 7 +++++-- engines/cge/gettext.cpp | 4 ++-- engines/cge/talk.cpp | 25 +++++++++++++++++-------- engines/cge/talk.h | 6 +++++- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 2fd196f509..f2bebef258 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -32,6 +32,7 @@ #include "cge/cge.h" #include "cge/vga13h.h" #include "cge/cge_main.h" +#include "cge/talk.h" #include "cge/text.h" #include "cge/bitmaps.h" #include "cge/vol.h" @@ -54,9 +55,10 @@ void CGEEngine::setup() { _console = new CGEConsole(this); // Initialise classes that have static members - BITMAP::init(); - VFILE::init(); VGA::init(); + VFILE::init(); + BITMAP::init(); + TALK::init(); // Initialise engine objects Text = new TEXT(this, ProgName(), 128); @@ -102,6 +104,7 @@ CGEEngine::~CGEEngine() { debug("CGEEngine::~CGEEngine"); // Call classes with static members to clear them up + TALK::deinit(); BITMAP::deinit(); VFILE::deinit(); VGA::deinit(); diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 69e19b175c..d444b75ab4 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -39,7 +39,7 @@ GET_TEXT *GET_TEXT::Ptr = NULL; GET_TEXT::GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void)) : TALK(vm), Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)), _vm(vm) { - int i = 2 * TEXT_HM + Font->Width(info); + int i = 2 * TEXT_HM + _Font->Width(info); Ptr = this; Mode = RECT; TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); @@ -107,7 +107,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { if (p) x = ogon[p - bezo]; } - if (Len < Size && 2 * TEXT_HM + Font->Width(Buff) + Font->Wid[x] <= W) { + if (Len < Size && 2 * TEXT_HM + _Font->Width(Buff) + _Font->Wid[x] <= W) { Buff[Len + 2] = Buff[Len + 1]; Buff[Len + 1] = Buff[Len]; Buff[Len++] = x; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index b67d9082ac..ae94233464 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -102,7 +102,6 @@ TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode) TS[0] = TS[1] = NULL; Flags.Syst = true; Update(tx); - Font = new FONT(ProgName()); } @@ -124,6 +123,16 @@ TALK::~TALK (void) { } */ +FONT *TALK::_Font; + +void TALK::init() { + _Font = new FONT(ProgName()); +} + +void TALK::deinit() { + delete _Font; +} + void TALK::Update(const char *tx) { uint16 vmarg = (Mode) ? TEXT_VM : 0; @@ -142,7 +151,7 @@ void TALK::Update(const char *tx) { mw = k; k = 2 * hmarg; } else - k += Font->Wid[*p]; + k += _Font->Wid[*p]; } if (k > mw) mw = k; @@ -155,8 +164,8 @@ void TALK::Update(const char *tx) { if (*tx == '|' || *tx == '\n') m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; else { - int cw = Font->Wid[*tx], i; - uint8 *f = Font->Map + Font->Pos[*tx]; + int cw = _Font->Wid[*tx], i; + uint8 *f = _Font->Map + _Font->Pos[*tx]; for (i = 0; i < cw; i++) { uint8 *p = m; uint16 n; @@ -253,8 +262,8 @@ void TALK::PutLine(int line, const char *text) { q = v + size; while (* text) { - uint16 cw = Font->Wid[*text], i; - uint8 *fp = Font->Map + Font->Pos[*text]; + uint16 cw = _Font->Wid[*text], i; + uint8 *fp = _Font->Map + _Font->Pos[*text]; for (i = 0; i < cw; i++) { register uint16 b = fp[i]; @@ -301,8 +310,8 @@ void INFO_LINE::Update(const char *tx) { uint8 *p = v + 2, * q = p + size; while (*tx) { - uint16 cw = Font->Wid[*tx]; - uint8 *fp = Font->Map + Font->Pos[*tx]; + uint16 cw = _Font->Wid[*tx]; + uint8 *fp = _Font->Map + _Font->Pos[*tx]; for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; diff --git a/engines/cge/talk.h b/engines/cge/talk.h index ba4952c3e6..184b84e553 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -74,10 +74,14 @@ protected: BITMAP *TS[2]; BITMAP *Box(uint16 w, uint16 h); public: - FONT *Font; TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode = PURE); TALK(CGEEngine *vm); //~TALK (void); + + static FONT *_Font; + static void init(); + static void deinit(); + virtual void Update(const char *tx); virtual void Update(void) {} void PutLine(int line, const char *text); -- cgit v1.2.3 From 04a123a4efc0ae4a76fa4ca20d8ffd692d7359ab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 28 Jun 2011 22:36:43 +1000 Subject: CGE: Fix for displaying non full-screen bitmaps --- engines/cge/vga13h.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 21aec31e5d..b59f8e8de5 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1247,20 +1247,14 @@ void BITMAP::XShow(int x, int y) { void BITMAP::Show(int x, int y) { - // Create a temporary surface to hold the unpacked bitmap data - Graphics::Surface rawSurface; - rawSurface.create(W, H, Graphics::PixelFormat::createFormatCLUT8()); - const byte *srcP = (const byte *)V; - byte *destP = (byte *)rawSurface.pixels; - byte *destEndP = destP + (W * H); - Common::set_to(destP, destEndP, 0); + byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { - destP = (byte *)rawSurface.getBasePtr(planeCtr, 0); + byte *destP = (byte *)VGA::Page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -1301,13 +1295,6 @@ void BITMAP::Show(int x, int y) { } } - // Copy the decompressed buffer to the specified x/y position on Page #1 - for (int yc = 0; yc < rawSurface.h; ++yc) { - srcP = (const byte *)rawSurface.getBasePtr(0, yc); - destP = (byte *)VGA::Page[1]->getBasePtr(x, y + yc); - Common::copy(srcP, srcP + rawSurface.w, destP); - } - // Temporary g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); byte palData[PAL_SIZ]; -- cgit v1.2.3 From e25f9c71f525a0feba28648a93846d7c9435f6e2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 28 Jun 2011 22:58:51 +1000 Subject: CGE: Fix SVG0FILE define to point to INI_FILE class --- engines/cge/cge_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 90b14d2c70..c415258ad8 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -58,7 +58,7 @@ namespace CGE { #define SVGCHKSUM (1956 + Now + OldLev + Game + Music + DemoText) #define SVG0NAME ("{{INIT}}" SVG_EXT) -#define SVG0FILE CFILE +#define SVG0FILE INI_FILE extern uint16 _stklen = (STACK_SIZ * 2); -- cgit v1.2.3 From 290305ad4320a489d6dc98279433e0d3b3a7de40 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Jun 2011 00:35:21 +0200 Subject: CGE: Cleanup : Start renaming. Add BMPLoad() function --- engines/cge/bitmap.cpp | 56 +++++++ engines/cge/bitmap.h | 8 +- engines/cge/cge.cpp | 32 ++-- engines/cge/cge_main.cpp | 366 +++++++++++++++++++++++---------------------- engines/cge/cge_main.h | 32 ++-- engines/cge/game.cpp | 2 +- engines/cge/game.h | 2 +- engines/cge/general.cpp | 7 +- engines/cge/gettext.cpp | 2 +- engines/cge/gettext.h | 2 +- engines/cge/keybd.cpp | 6 +- engines/cge/keybd.h | 4 +- engines/cge/mixer.cpp | 6 +- engines/cge/mixer.h | 6 +- engines/cge/mouse.cpp | 7 +- engines/cge/mouse.h | 12 +- engines/cge/snail.cpp | 176 +++++++++++----------- engines/cge/talk.cpp | 4 +- engines/cge/talk.h | 2 +- engines/cge/text.cpp | 14 +- engines/cge/text.h | 6 +- engines/cge/vga13h.cpp | 382 ++++++++++++++++++++++++----------------------- engines/cge/vga13h.h | 132 ++++++++-------- engines/cge/vmenu.cpp | 2 +- 24 files changed, 674 insertions(+), 594 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 943f1cf154..10fc9a4df6 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -139,6 +139,7 @@ BITMAP::~BITMAP(void) { break; case FAR_MEM : free(V); + default: break; } } @@ -419,4 +420,59 @@ bool BITMAP::VBMLoad(XFILE *f) { B = (HideDesc *)(V + n - H * sizeof(HideDesc)); return (f->Error == 0); } + +bool BITMAP::BMPLoad (XFILE * f) { + struct { + char BM[2]; + union { int16 len; int32 len_; }; + union { int16 _06; int32 _06_; }; + union { int16 hdr; int32 hdr_; }; + union { int16 _0E; int32 _0E_; }; + union { int16 wid; int32 wid_; }; + union { int16 hig; int32 hig_; }; + union { int16 _1A; int32 _1A_; }; + union { int16 _1E; int32 _1E_; }; + union { int16 _22; int32 _22_; }; + union { int16 _26; int32 _26_; }; + union { int16 _2A; int32 _2A_; }; + union { int16 _2E; int32 _2E_; }; + union { int16 _32; int32 _32_; }; + } hea; + BGR4 bpal[256]; + + f->Read((byte *)&hea, sizeof(hea)); + if (f->Error == 0) { + if (hea.hdr == 0x436L) { + int16 i = (hea.hdr - sizeof(hea)) / sizeof(BGR4); + f->Read((byte *)&bpal, sizeof(bpal)); + if (f->Error == 0) { + if (Pal) { + for (i = 0; i < 256; i ++) { + Pal[i].R = bpal[i].R; + Pal[i].G = bpal[i].G; + Pal[i].B = bpal[i].B; + } + Pal = NULL; + } + H = hea.hig; + W = hea.wid; + if ((M = farnew(byte, H * W)) != NULL) { + int16 r = (4 - (hea.wid & 3)) % 4; + byte buf[3]; int i; + for (i = H-1; i >= 0; i --) { + f->Read(M + (W * i), W); + if (r && f->Error == 0) + f->Read(buf, r); + if (f->Error) + break; + } + if (i < 0) + return true; + } + } + } + } + return false; +} + } // End of namespace CGE diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 13e28f4369..e114760e2a 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -41,7 +41,7 @@ namespace CGE { #include "common/pack-start.h" -typedef struct { +struct BGR4 { uint16 b : 2; uint16 B : 6; uint16 g : 2; @@ -49,13 +49,13 @@ typedef struct { uint16 r : 2; uint16 R : 6; uint16 Z : 8; -} BGR4; +}; -typedef struct { +struct HideDesc { uint16 skip; uint16 hide; -} HideDesc; +}; #include "common/pack-end.h" diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index f2bebef258..07638ebdd8 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -63,19 +63,19 @@ void CGEEngine::setup() { // Initialise engine objects Text = new TEXT(this, ProgName(), 128); Vga = new VGA(M13H); - Heart = new HEART; + _heart = new Heart; Hero = new WALK(this, NULL); Sys = new SYSTEM(this); - PocLight = new SPRITE(this, LI); + _pocLight = new Sprite(this, LI); Mouse = new MOUSE(this); for (int i = 0; i < POCKET_NX; i++) - Pocket[i] = new SPRITE(this, NULL); - Sprite = new SPRITE(this, NULL); - MiniCave = new SPRITE(this, NULL); - Shadow = new SPRITE(this, NULL); - HorzLine = new SPRITE(this, HL); + _pocket[i] = new Sprite(this, NULL); + _sprite = new Sprite(this, NULL); + _miniCave = new Sprite(this, NULL); + _shadow = new Sprite(this, NULL); + _horzLine = new Sprite(this, HL); InfoLine = new INFO_LINE(this, INFO_W); - CavLight = new SPRITE(this, PR); + _cavLight = new Sprite(this, PR); DebugLine = new INFO_LINE(this, SCR_WID); MB[0] = new BITMAP("BRICK"); MB[1] = NULL; @@ -117,19 +117,19 @@ CGEEngine::~CGEEngine() { // Delete engine objects delete Text; delete Vga; - delete Heart; + delete _heart; delete Hero; delete Sys; - delete PocLight; + delete _pocLight; delete Mouse; for (int i = 0; i < POCKET_NX; i++) - delete Pocket[i]; - delete Sprite; - delete MiniCave; - delete Shadow; - delete HorzLine; + delete _pocket[i]; + delete _sprite; + delete _miniCave; + delete _shadow; + delete _horzLine; delete InfoLine; - delete CavLight; + delete _cavLight; delete DebugLine; delete MB[0]; delete HL[0]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index c415258ad8..ece6ec5adb 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -25,56 +25,55 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/general.h" -#include "cge/boot.h" -#include "cge/ident.h" -#include "cge/sound.h" -#include "cge/startup.h" -#include "cge/config.h" -#include "cge/vga13h.h" -#include "cge/snail.h" -#include "cge/text.h" -#include "cge/game.h" -#include "cge/mouse.h" -#include "cge/keybd.h" -#include "cge/cfile.h" -#include "cge/vol.h" -#include "cge/talk.h" -#include "cge/vmenu.h" -#include "cge/gettext.h" -#include "cge/mixer.h" -#include "cge/cge_main.h" -#include "cge/cge.h" -#include -#include -#include -#include - +#include "cge/general.h" +#include "cge/boot.h" +#include "cge/ident.h" +#include "cge/sound.h" +#include "cge/startup.h" +#include "cge/config.h" +#include "cge/vga13h.h" +#include "cge/snail.h" +#include "cge/text.h" +#include "cge/game.h" +#include "cge/mouse.h" +#include "cge/keybd.h" +#include "cge/cfile.h" +#include "cge/vol.h" +#include "cge/talk.h" +#include "cge/vmenu.h" +#include "cge/gettext.h" +#include "cge/mixer.h" +#include "cge/cge_main.h" +#include "cge/cge.h" +#include +#include +#include +#include #include "common/str.h" namespace CGE { -#define STACK_SIZ (K(2)) -#define SVGCHKSUM (1956 + Now + OldLev + Game + Music + DemoText) +#define STACK_SIZ (K(2)) +#define SVGCHKSUM (1956 + Now + OldLev + Game + Music + DemoText) -#define SVG0NAME ("{{INIT}}" SVG_EXT) -#define SVG0FILE INI_FILE +#define SVG0NAME ("{{INIT}}" SVG_EXT) +#define SVG0FILE INI_FILE extern uint16 _stklen = (STACK_SIZ * 2); VGA *Vga; -HEART *Heart; +Heart *_heart; WALK *Hero; SYSTEM *Sys; -SPRITE *PocLight; +Sprite *_pocLight; MOUSE *Mouse; -SPRITE *Pocket[POCKET_NX]; -SPRITE *Sprite; -SPRITE *MiniCave; -SPRITE *Shadow; -SPRITE *HorzLine; +Sprite *_pocket[POCKET_NX]; +Sprite *_sprite; +Sprite *_miniCave; +Sprite *_shadow; +Sprite *_horzLine; INFO_LINE *InfoLine; -SPRITE *CavLight; +Sprite *_cavLight; INFO_LINE *DebugLine; BMP_PTR MB[2]; @@ -146,11 +145,11 @@ HXY HeroXY[CAVE_MAX] = {{0, 0}}; BAR Barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; -extern int FindPocket(SPRITE *); +extern int FindPocket(Sprite *); extern DAC StdPal[58]; -void FeedSnail(SPRITE *spr, SNLIST snq); // defined in SNAIL +void FeedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; @@ -223,11 +222,13 @@ CLUSTER XZ(COUPLE xy) { int pocref[POCKET_NX]; uint8 volume[2]; -struct SAVTAB { +struct SavTab { void *Ptr; int Len; uint8 Flg; -} SavTab[] = { +}; + +SavTab _savTab[] = { { &Now, sizeof(Now), 1 }, { &OldLev, sizeof(OldLev), 1 }, { &DemoText, sizeof(DemoText), 1 }, @@ -248,11 +249,11 @@ struct SAVTAB { void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { - SAVTAB *st; - SPRITE *spr; + SavTab *st; + Sprite *spr; int i; - for (st = SavTab; st->Ptr; st++) { + for (st = _savTab; st->Ptr; st++) { if (file.Error) error("Bad SVG"); file.Read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len); @@ -273,7 +274,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { if (! tiny) { // load sprites & pocket while (! file.Error) { - SPRITE S(this, NULL); + Sprite S(this, NULL); uint16 n = file.Read((uint8 *) &S, sizeof(S)); if (n != sizeof(S)) @@ -281,7 +282,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { S.Prev = S.Next = NULL; spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(this, NULL) - : new SPRITE(this, NULL); + : new Sprite(this, NULL); if (spr == NULL) error("No core"); *spr = S; @@ -290,7 +291,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { for (i = 0; i < POCKET_NX; i++) { register int r = pocref[i]; - Pocket[i] = (r < 0) ? NULL : Vga->SpareQ->Locate(r); + _pocket[i] = (r < 0) ? NULL : Vga->SpareQ->Locate(r); } } } @@ -303,19 +304,19 @@ static void SaveSound(void) { static void SaveGame(XFILE &file) { - SAVTAB *st; - SPRITE *spr; + SavTab *st; + Sprite *spr; int i; for (i = 0; i < POCKET_NX; i++) { - register SPRITE *s = Pocket[i]; - pocref[i] = (s) ? s->Ref : -1; + register Sprite *s = _pocket[i]; + pocref[i] = (s) ? s->_ref : -1; } volume[0] = SNDDrvInfo.VOL2.D; volume[1] = SNDDrvInfo.VOL2.M; - for (st = SavTab; st->Ptr; st++) { + for (st = _savTab; st->Ptr; st++) { if (file.Error) error("Bad SVG"); file.Write((uint8 *) st->Ptr, st->Len); @@ -324,7 +325,7 @@ static void SaveGame(XFILE &file) { file.Write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); for (spr = Vga->SpareQ->First(); spr; spr = spr->Next) - if (spr->Ref >= 1000) + if (spr->_ref >= 1000) if (!file.Error) file.Write((uint8 *)spr, sizeof(*spr)); } @@ -385,7 +386,7 @@ int FindLevel; WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) - : SPRITE(vm, shpl), Dir(NO_DIR), TracePtr(-1), _vm(vm) { + : Sprite(vm, shpl), Dir(NO_DIR), TracePtr(-1), _vm(vm) { } @@ -396,7 +397,7 @@ void WALK::Tick(void) { Here = XZ(X + W / 2, Y + H); if (Dir != NO_DIR) { - SPRITE *spr; + Sprite *spr; Sys->FunTouch(); for (spr = Vga->ShowQ->First(); spr; spr = spr->Next) { if (Distance(spr) < 2) { @@ -434,7 +435,7 @@ void WALK::Tick(void) { } -int WALK::Distance(SPRITE *spr) { +int WALK::Distance(Sprite *spr) { int dx, dz; dx = spr->X - (X + W - WALKSIDE); if (dx < 0) @@ -502,7 +503,7 @@ void WALK::FindWay(CLUSTER c) { } -void WALK::FindWay(SPRITE *spr) { +void WALK::FindWay(Sprite *spr) { if (spr && spr != this) { int x = spr->X, z = spr->Z; if (spr->Flags.East) @@ -516,12 +517,12 @@ void WALK::FindWay(SPRITE *spr) { } -bool WALK::Lower(SPRITE *spr) { +bool WALK::Lower(Sprite *spr) { return (spr->Y > Y + (H * 3) / 5); } -void WALK::Reach(SPRITE *spr, int mode) { +void WALK::Reach(Sprite *spr, int mode) { if (spr) { Hero->FindWay(spr); if (mode < 0) { @@ -542,7 +543,7 @@ void WALK::Reach(SPRITE *spr, int mode) { } -class SQUARE : public SPRITE { +class SQUARE : public Sprite { public: SQUARE(CGEEngine *vm); void Touch(uint16 mask, int x, int y); @@ -552,14 +553,14 @@ private: SQUARE::SQUARE(CGEEngine *vm) - : SPRITE(vm, MB), _vm(vm) { + : Sprite(vm, MB), _vm(vm) { Flags.Kill = true; Flags.BDel = false; } void SQUARE::Touch(uint16 mask, int x, int y) { - SPRITE::Touch(mask, x, y); + Sprite::Touch(mask, x, y); if (mask & L_UP) { XZ(X + x, Y + y).Cell() = 0; SNPOST_(SNKILL, -1, 0, this); @@ -632,14 +633,14 @@ static void AltCtrlDel(void) { static void MiniStep(int stp) { if (stp < 0) - MiniCave->Flags.Hide = true; + _miniCave->Flags.Hide = true; else { &*Mini; *MiniShp[0] = *MiniShpList[stp]; if (Fx.Current) &*(Fx.Current->EAddr()); - MiniCave->Flags.Hide = false; + _miniCave->Flags.Hide = false; } } @@ -670,7 +671,7 @@ void SYSTEM::FunTouch(void) { static void ShowBak(int ref) { - SPRITE *spr = Vga->SpareQ->Locate(ref); + Sprite *spr = Vga->SpareQ->Locate(ref); if (spr) { BITMAP::Pal = VGA::SysPal; spr->Expand(); @@ -691,11 +692,11 @@ static void CaveUp(void) { ShowBak(BakRef); LoadMapping(); Text->Preload(BakRef, BakRef + 1000); - SPRITE *spr = Vga->SpareQ->First(); + Sprite *spr = Vga->SpareQ->First(); while (spr) { - SPRITE *n = spr->Next; - if (spr->Cave == Now || spr->Cave == 0) - if (spr->Ref != BakRef) { + Sprite *n = spr->Next; + if (spr->_cave == Now || spr->_cave == 0) + if (spr->_ref != BakRef) { if (spr->Flags.Back) spr->BackShow(); else @@ -726,11 +727,11 @@ static void CaveUp(void) { if (Hero) Vga->ShowQ->Insert(Vga->ShowQ->Remove(Hero)); - if (Shadow) { - Vga->ShowQ->Remove(Shadow); - Shadow->MakeXlat(Glass(VGA::SysPal, 204, 204, 204)); - Vga->ShowQ->Insert(Shadow, Hero); - Shadow->Z = Hero->Z; + if (_shadow) { + Vga->ShowQ->Remove(_shadow); + _shadow->MakeXlat(Glass(VGA::SysPal, 204, 204, 204)); + Vga->ShowQ->Insert(_shadow, Hero); + _shadow->Z = Hero->Z; } FeedSnail(Vga->ShowQ->Locate(BakRef + 999), TAKE); Vga->Show(); @@ -741,19 +742,19 @@ static void CaveUp(void) { if (! Startup) Mouse->On(); - Heart->Enable = true; + _heart->_enable = true; } void CGEEngine::CaveDown() { - SPRITE *spr; - if (! HorzLine->Flags.Hide) + Sprite *spr; + if (!_horzLine->Flags.Hide) SwitchMapping(); for (spr = Vga->ShowQ->First(); spr;) { - SPRITE *n = spr->Next; - if (spr->Ref >= 1000 /*&& spr->Cave*/) { - if (spr->Ref % 1000 == 999) + Sprite *n = spr->Next; + if (spr->_ref >= 1000 /*&& spr->_cave*/) { + if (spr->_ref % 1000 == 999) FeedSnail(spr, TAKE); Vga->SpareQ->Append(Vga->ShowQ->Remove(spr)); } @@ -782,7 +783,7 @@ void CGEEngine::QGame() { void CGEEngine::SwitchCave(int cav) { if (cav != Now) { - Heart->Enable = false; + _heart->_enable = false; if (cav < 0) { SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer @@ -799,7 +800,7 @@ void CGEEngine::SwitchCave(int cav) { Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX); /////-------------------------------------------------------- } - CavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + _cavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); KillText(); if (! Startup) @@ -812,7 +813,7 @@ void CGEEngine::SwitchCave(int cav) { } } -SYSTEM::SYSTEM(CGEEngine *vm) : SPRITE(vm, NULL), _vm(vm) { +SYSTEM::SYSTEM(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { FunDel = HEROFUN0; SetPal(); Tick(); @@ -841,7 +842,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { break; case 'F': if (KEYBOARD::Key[ALT]) { - SPRITE *m = Vga->ShowQ->Locate(17001); + Sprite *m = Vga->ShowQ->Locate(17001); if (m) { m->Step(1); m->Time = 216; // 3s @@ -905,8 +906,8 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { case '7': case '8': case '9': - if (Sprite) - Sprite->Step(x - '0'); + if (_sprite) + _sprite->Step(x - '0'); break; case F10 : if (Snail->Idle() && ! Hero->Flags.Hide) @@ -957,7 +958,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (cav && Snail->Idle() && Hero->TracePtr < 0) _vm->SwitchCave(cav); - if (!HorzLine->Flags.Hide) { + if (!_horzLine->Flags.Hide) { if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { int8 x1, z1; XZ(x, y).Split(x1, z1); @@ -1079,7 +1080,7 @@ void CGEEngine::TakeName() { void CGEEngine::SwitchMapping() { - if (HorzLine->Flags.Hide) { + if (_horzLine->Flags.Hide) { int i; for (i = 0; i < MAP_ZCNT; i++) { int j; @@ -1089,29 +1090,29 @@ void CGEEngine::SwitchMapping() { } } } else { - SPRITE *s; + Sprite *s; for (s = Vga->ShowQ->First(); s; s = s->Next) if (s->W == MAP_XGRID && s->H == MAP_ZGRID) SNPOST_(SNKILL, -1, 0, s); } - HorzLine->Flags.Hide = ! HorzLine->Flags.Hide; + _horzLine->Flags.Hide = !_horzLine->Flags.Hide; } static void KillSprite(void) { - Sprite->Flags.Kill = true; - Sprite->Flags.BDel = true; - SNPOST_(SNKILL, -1, 0, Sprite); - Sprite = NULL; + _sprite->Flags.Kill = true; + _sprite->Flags.BDel = true; + SNPOST_(SNKILL, -1, 0, _sprite); + _sprite = NULL; } static void PushSprite(void) { - SPRITE *spr = Sprite->Prev; + Sprite *spr = _sprite->Prev; if (spr) { - Vga->ShowQ->Insert(Vga->ShowQ->Remove(Sprite), spr); - while (Sprite->Z > Sprite->Next->Z) - --Sprite->Z; + Vga->ShowQ->Insert(Vga->ShowQ->Remove(_sprite), spr); + while (_sprite->Z > _sprite->Next->Z) + --_sprite->Z; } else SNPOST_(SNSOUND, -1, 2, NULL); } @@ -1119,24 +1120,24 @@ static void PushSprite(void) { static void PullSprite(void) { bool ok = false; - SPRITE *spr = Sprite->Next; + Sprite *spr = _sprite->Next; if (spr) { spr = spr->Next; if (spr) ok = (!spr->Flags.Slav); } if (ok) { - Vga->ShowQ->Insert(Vga->ShowQ->Remove(Sprite), spr); - if (Sprite->Prev) - while (Sprite->Z < Sprite->Prev->Z) - ++Sprite->Z; + Vga->ShowQ->Insert(Vga->ShowQ->Remove(_sprite), spr); + if (_sprite->Prev) + while (_sprite->Z < _sprite->Prev->Z) + ++_sprite->Z; } else SNPOST_(SNSOUND, -1, 2, NULL); } static void NextStep(void) { - SNPOST_(SNSTEP, 0, 0, Sprite); + SNPOST_(SNSTEP, 0, 0, _sprite); } @@ -1199,18 +1200,18 @@ static void SayDebug(void) { // sprite queue size uint16 n = 0; - SPRITE *spr; + Sprite *spr; for (spr = Vga->ShowQ->First(); spr; spr = spr->Next) { ++ n; - if (spr == Sprite) { + if (spr == _sprite) { *XSPR = ' '; dwtom(n, SP_N, 10, 2); - dwtom(Sprite->X, SP_X, 10, 3); - dwtom(Sprite->Y, SP_Y, 10, 3); - dwtom(Sprite->Z, SP_Z, 10, 3); - dwtom(Sprite->W, SP_W, 10, 3); - dwtom(Sprite->H, SP_H, 10, 3); - dwtom(*(uint16 *)(&Sprite->Flags), SP_F, 16, 2); + dwtom(_sprite->X, SP_X, 10, 3); + dwtom(_sprite->Y, SP_Y, 10, 3); + dwtom(_sprite->Z, SP_Z, 10, 3); + dwtom(_sprite->W, SP_W, 10, 3); + dwtom(_sprite->H, SP_H, 10, 3); + dwtom(*(uint16 *)(&_sprite->Flags), SP_F, 16, 2); } } dwtom(n, SP_S, 10, 2); @@ -1249,14 +1250,14 @@ void CGEEngine::OptionTouch(int opt, uint16 mask) { #pragma argsused -void SPRITE::Touch(uint16 mask, int x, int y) { +void Sprite::Touch(uint16 mask, int x, int y) { Sys->FunTouch(); if ((mask & ATTN) == 0) { InfoLine->Update(Name()); if (mask & (R_DN | L_DN)) - Sprite = this; - if (Ref / 10 == 12) { - _vm->OptionTouch(Ref % 10, mask); + _sprite = this; + if (_ref / 10 == 12) { + _vm->OptionTouch(_ref % 10, mask); return; } if (Flags.Syst) @@ -1266,7 +1267,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { mask |= R_UP; } if ((mask & R_UP) && Snail->Idle()) { - SPRITE *ps = (PocLight->SeqPtr) ? Pocket[PocPtr] : NULL; + Sprite *ps = (_pocLight->SeqPtr) ? _pocket[PocPtr] : NULL; if (ps) { if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) { if (Works(ps)) { @@ -1309,7 +1310,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { if (Flags.Kept) { int n; for (n = 0; n < POCKET_NX; n++) { - if (Pocket[n] == this) { + if (_pocket[n] == this) { SelectPocket(n); break; } @@ -1388,9 +1389,9 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int // make sprite of choosen type switch (type) { case 1 : { // AUTO - Sprite = new SPRITE(this, NULL); - if (Sprite) { - Sprite->Goto(col, row); + _sprite = new Sprite(this, NULL); + if (_sprite) { + _sprite->Goto(col, row); //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$ } break; @@ -1403,7 +1404,7 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int error("2nd HERO [%s]", fname); Hero = w; } - Sprite = w; + _sprite = w; break; } /* @@ -1418,7 +1419,7 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int n->Cx = 3; n->Goto(col, row); } - Sprite = n; + _sprite = n; break; */ case 4 : { // LISSAJOUS @@ -1436,37 +1437,37 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int *(long *) &l->Dx = 0; // movex * cnt l->Goto(col, row); } - Sprite = l; + _sprite = l; */ break; } case 5 : { // FLY FLY *f = new FLY(this, NULL); - Sprite = f; + _sprite = f; //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$ break; } default: { // DEAD - Sprite = new SPRITE(this, NULL); - if (Sprite) - Sprite->Goto(col, row); + _sprite = new Sprite(this, NULL); + if (_sprite) + _sprite->Goto(col, row); break; } } - if (Sprite) { - Sprite->Ref = ref; - Sprite->Cave = cav; - Sprite->Z = pos; - Sprite->Flags.East = east; - Sprite->Flags.Port = port; - Sprite->Flags.Tran = tran; - Sprite->Flags.Kill = true; - Sprite->Flags.BDel = true; - //fnsplit(fname, NULL, NULL, Sprite->File, NULL); + if (_sprite) { + _sprite->_ref = ref; + _sprite->_cave = cav; + _sprite->Z = pos; + _sprite->Flags.East = east; + _sprite->Flags.Port = port; + _sprite->Flags.Tran = tran; + _sprite->Flags.Kill = true; + _sprite->Flags.BDel = true; + //fnsplit(fname, NULL, NULL, _sprite->File, NULL); warning("LoadSprite: use of fnsplit"); - Sprite->ShpCnt = shpcnt; - Vga->SpareQ->Append(Sprite); + _sprite->ShpCnt = shpcnt; + Vga->SpareQ->Append(_sprite); } } @@ -1521,10 +1522,10 @@ void CGEEngine::LoadScript(const char *fname) { ok = true; // no break: OK - Sprite = NULL; + _sprite = NULL; LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); - if (Sprite && BkG) - Sprite->Flags.Back = true; + if (_sprite && BkG) + _sprite->Flags.Back = true; } if (! ok) error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname); @@ -1579,11 +1580,11 @@ void CGEEngine::RunGame() { Text->Preload(100, 1000); LoadHeroXY(); - CavLight->Flags.Tran = true; - Vga->ShowQ->Append(CavLight); - CavLight->Flags.Hide = true; + _cavLight->Flags.Tran = true; + Vga->ShowQ->Append(_cavLight); + _cavLight->Flags.Hide = true; - static SEQ PocSeq[] = { { 0, 0, 0, 0, 20 }, + static Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, { 1, 2, 0, 0, 4 }, { 2, 3, 0, 0, 4 }, { 3, 4, 0, 0, 16 }, @@ -1591,11 +1592,11 @@ void CGEEngine::RunGame() { { 1, 6, 0, 0, 4 }, { 0, 1, 0, 0, 16 }, }; - PocLight->SetSeq(PocSeq); - PocLight->Flags.Tran = true; - PocLight->Time = 1; - PocLight->Z = 120; - Vga->ShowQ->Append(PocLight); + _pocLight->SetSeq(pocSeq); + _pocLight->Flags.Tran = true; + _pocLight->Time = 1; + _pocLight->Z = 120; + Vga->ShowQ->Append(_pocLight); SelectPocket(-1); Vga->ShowQ->Append(Mouse); @@ -1604,11 +1605,11 @@ void CGEEngine::RunGame() { LoadUser(); // ~~~~~~~~~~~ - if ((Sprite = Vga->SpareQ->Locate(121)) != NULL) - SNPOST_(SNSEQ, -1, Vga->Mono, Sprite); - if ((Sprite = Vga->SpareQ->Locate(122)) != NULL) - Sprite->Step(Music); - SNPOST_(SNSEQ, -1, Music, Sprite); + if ((_sprite = Vga->SpareQ->Locate(121)) != NULL) + SNPOST_(SNSEQ, -1, Vga->Mono, _sprite); + if ((_sprite = Vga->SpareQ->Locate(122)) != NULL) + _sprite->Step(Music); + SNPOST_(SNSEQ, -1, Music, _sprite); if (! Music) KillMIDI(); @@ -1616,12 +1617,12 @@ void CGEEngine::RunGame() { uint8 *ptr = (uint8 *) &*Mini; if (ptr != NULL) { LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); - ExpandSprite(MiniCave = Sprite); // NULL is ok - if (MiniCave) { - MiniCave->Flags.Hide = true; - MiniCave->MoveShapes(ptr); - MiniShp[0] = new BITMAP(*MiniCave->Shp()); - MiniShpList = MiniCave->SetShapeList(MiniShp); + ExpandSprite(_miniCave = _sprite); // NULL is ok + if (_miniCave) { + _miniCave->Flags.Hide = true; + _miniCave->MoveShapes(ptr); + MiniShp[0] = new BITMAP(*_miniCave->Shp()); + MiniShpList = _miniCave->SetShapeList(MiniShp); PostMiniStep(-1); } } @@ -1632,11 +1633,11 @@ void CGEEngine::RunGame() { Hero->Goto(HeroXY[Now - 1].X, HeroXY[Now - 1].Y); if (INI_FILE::Exist("00SHADOW.SPR")) { LoadSprite("00SHADOW", -1, 0, Hero->X + 14, Hero->Y + 51); - if ((Shadow = Sprite) != NULL) { - Shadow->Ref = 2; - Shadow->Flags.Tran = true; + if ((_shadow = _sprite) != NULL) { + _shadow->_ref = 2; + _shadow->Flags.Tran = true; Hero->Flags.Shad = true; - Vga->ShowQ->Insert(Vga->SpareQ->Remove(Shadow), Hero); + Vga->ShowQ->Insert(Vga->SpareQ->Remove(_shadow), Hero); } } } @@ -1649,9 +1650,9 @@ void CGEEngine::RunGame() { DebugLine->Z = 126; Vga->ShowQ->Insert(DebugLine); - HorzLine->Y = MAP_TOP - (MAP_TOP > 0); - HorzLine->Z = 126; - Vga->ShowQ->Insert(HorzLine); + _horzLine->Y = MAP_TOP - (MAP_TOP > 0); + _horzLine->Z = 126; + Vga->ShowQ->Insert(_horzLine); Mouse->Busy = Vga->SpareQ->Locate(BUSY_REF); if (Mouse->Busy) @@ -1659,8 +1660,8 @@ void CGEEngine::RunGame() { Startup = 0; - SNPOST(SNLEVEL, -1, OldLev, &CavLight); - CavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + SNPOST(SNLEVEL, -1, OldLev, &_cavLight); + _cavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); CaveUp(); @@ -1674,14 +1675,14 @@ void CGEEngine::RunGame() { } KEYBOARD::SetClient(NULL); - Heart->Enable = false; + _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); Mouse->Off(); Vga->ShowQ->Clear(); Vga->SpareQ->Clear(); Hero = NULL; - Shadow = NULL; + _shadow = NULL; } @@ -1692,13 +1693,13 @@ void CGEEngine::Movie(const char *ext) { ExpandSprite(Vga->SpareQ->Locate(999)); FeedSnail(Vga->ShowQ->Locate(999), TAKE); Vga->ShowQ->Append(Mouse); - Heart->Enable = true; + _heart->_enable = true; KEYBOARD::SetClient(Sys); while (!Snail->Idle()) MainLoop(); KEYBOARD::SetClient(NULL); - Heart->Enable = false; + _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); Vga->ShowQ->Clear(); @@ -1713,7 +1714,7 @@ bool CGEEngine::ShowTitle(const char *name) { BITMAP::Pal = NULL; bool usr_ok = false; - SPRITE D(this, LB); + Sprite D(this, LB); D.Flags.Kill = true; D.Flags.BDel = true; D.Center(); @@ -1734,12 +1735,12 @@ bool CGEEngine::ShowTitle(const char *name) { Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); Vga->ShowQ->Append(Mouse); - Heart->Enable = true; + _heart->_enable = true; Mouse->On(); for (SelectSound(); !Snail->Idle() || VMENU::Addr;) MainLoop(); Mouse->Off(); - Heart->Enable = false; + _heart->_enable = false; Vga->ShowQ->Clear(); Vga->CopyPage(0, 2); STARTUP::SoundOk = 2; @@ -1771,10 +1772,10 @@ bool CGEEngine::ShowTitle(const char *name) { Vga->CopyPage(0, 1); Vga->ShowQ->Append(Mouse); //Mouse.On(); - Heart->Enable = true; + _heart->_enable = true; for (TakeName(); GET_TEXT::Ptr;) MainLoop(); - Heart->Enable = false; + _heart->_enable = false; if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = true; if (usr_ok) @@ -1831,11 +1832,12 @@ void CGEEngine::cge_main(void) { if (!Mouse->Exist) error("%s", Text->getText(NO_MOUSE_TEXT)); + if (!SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; DebugLine->Flags.Hide = true; - HorzLine->Flags.Hide = true; + _horzLine->Flags.Hide = true; //srand((uint16) Timer()); Sys = new SYSTEM(this); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 146c3cb6c9..8b2f87aad9 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -113,7 +113,7 @@ namespace CGE { #define FINIS (Flag[3]) -class SYSTEM : public SPRITE { +class SYSTEM : public Sprite { int lum; public: int FunDel; @@ -139,7 +139,7 @@ public: }; -class WALK : public SPRITE { +class WALK : public Sprite { public: CLUSTER Here; int TracePtr; @@ -148,12 +148,12 @@ public: WALK(CGEEngine *vm, BMP_PTR *shpl); void Tick(void); void FindWay(CLUSTER c); - void FindWay(SPRITE *spr); - int Distance(SPRITE *spr); + void FindWay(Sprite *spr); + int Distance(Sprite *spr); void Turn(DIR d); void Park(void); - bool Lower(SPRITE *spr); - void Reach(SPRITE *spr, int mode = -1); + bool Lower(Sprite *spr); + void Reach(Sprite *spr, int mode = -1); private: CGEEngine *_vm; @@ -163,23 +163,23 @@ private: CLUSTER XZ(int x, int y); CLUSTER XZ(COUPLE xy); -void ExpandSprite(SPRITE *spr); -void ContractSprite(SPRITE *spr); +void ExpandSprite(Sprite *spr); +void ContractSprite(Sprite *spr); extern WALK *Hero; extern VGA *Vga; -extern HEART *Heart; +extern Heart *_heart; extern SYSTEM *Sys; extern int OffUseCount; -extern SPRITE *PocLight; +extern Sprite *_pocLight; extern MOUSE *Mouse; -extern SPRITE *Pocket[]; -extern SPRITE *Sprite; -extern SPRITE *MiniCave; -extern SPRITE *Shadow; -extern SPRITE *HorzLine; +extern Sprite *_pocket[]; +extern Sprite *_sprite; +extern Sprite *_miniCave; +extern Sprite *_shadow; +extern Sprite *_horzLine; extern INFO_LINE *InfoLine; -extern SPRITE *CavLight; +extern Sprite *_cavLight; extern INFO_LINE *DebugLine; extern BMP_PTR MB[2]; extern BMP_PTR MB[2]; diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 21e8ceddeb..a5b82f1e8d 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -68,7 +68,7 @@ int FLY::L = 20, FLY::FLY(CGEEngine *vm, BITMAP **shpl) - : SPRITE(vm, shpl), Tx(0), Ty(0), _vm(vm) { + : Sprite(vm, shpl), Tx(0), Ty(0), _vm(vm) { Step(new_random(2)); Goto(L + new_random(R - L - W), T + new_random(B - T - H)); } diff --git a/engines/cge/game.h b/engines/cge/game.h index 7892b1c93f..fb4dad6fae 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -44,7 +44,7 @@ int Sinus(long x); uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b); uint8 *Mark(DAC *pal); -class FLY : public SPRITE { +class FLY : public Sprite { static int L, T, R, B; public: int Tx, Ty; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 1bf4bcd982..428498923e 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -136,8 +136,6 @@ char *ForceExt(char *buf, const char *nam, const char *ext) { return buf; } - -#define BUF ((uint8 *) buf) static unsigned Seed = 1; unsigned FastRand(void) { @@ -237,7 +235,10 @@ uint16 IOHAND::Read(void *buf, uint16 len) { return 0; uint16 bytesRead = _file->read(buf, len); - if (Crypt) Seed = Crypt(buf, len, Seed); + if (!bytesRead) + error("Read %s - %d bytes", _file->getName(), len); + if (Crypt) + Seed = Crypt(buf, len, Seed); return bytesRead; } diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index d444b75ab4..f891b9c092 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -116,7 +116,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { break; } } else - SPRITE::Touch(mask, x, y); + Sprite::Touch(mask, x, y); } } // End of namespace CGE diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index c868232677..33210758af 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -41,7 +41,7 @@ class GET_TEXT : public TALK { char Buff[GTMAX + 2], * Text; uint16 Size, Len; uint16 Cntr; - SPRITE *OldKeybClient; + Sprite *OldKeybClient; void (*Click)(); public: static GET_TEXT *Ptr; diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index c912555949..4aee394e07 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -30,8 +30,8 @@ namespace CGE { -SPRITE *KEYBOARD::Client = NULL; -uint8 KEYBOARD::Key[0x60] = { 0 }; +Sprite *KEYBOARD::Client = NULL; +uint8 KEYBOARD::Key[0x60] = { 0 }; uint16 KEYBOARD::Current = 0; uint16 KEYBOARD::Code[0x60] = { 0, Esc, '1', '2', '3', @@ -78,7 +78,7 @@ KEYBOARD::~KEYBOARD(void) { } -SPRITE *KEYBOARD::SetClient(SPRITE *spr) { +Sprite *KEYBOARD::SetClient(Sprite *spr) { Swap(Client, spr); return spr; } diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h index f2fa595be2..2cdbd558d8 100644 --- a/engines/cge/keybd.h +++ b/engines/cge/keybd.h @@ -46,14 +46,14 @@ public: static void NewKeyboard(...); static uint16 Code[0x60]; static uint16 Current; - static SPRITE *Client; + static Sprite *Client; static uint8 Key[0x60]; static uint16 Last(void) { uint16 cur = Current; Current = 0; return cur; } - static SPRITE *SetClient(SPRITE *spr); + static Sprite *SetClient(Sprite *spr); KEYBOARD(void); ~KEYBOARD(void); }; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index ecdd2b7533..c1f688babd 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -40,7 +40,7 @@ extern MOUSE *Mouse; bool MIXER::Appear = false; -MIXER::MIXER(CGEEngine *vm, int x, int y) : SPRITE(vm, NULL), Fall(MIX_FALL), _vm(vm) { +MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _vm(vm) { Appear = true; mb[0] = new BITMAP("VOLUME"); mb[1] = NULL; @@ -65,7 +65,7 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : SPRITE(vm, NULL), Fall(MIX_FALL), _v lb[i] = NULL; for (i = 0; i < ArrayCount(Led); i++) { - register SPRITE *spr = new SPRITE(_vm, lb); + register Sprite *spr = new Sprite(_vm, lb); spr->SetSeq(ls); spr->Goto(x + 2 + 12 * i, y + 8); spr->Flags.Tran = true; @@ -98,7 +98,7 @@ MIXER::~MIXER(void) { #pragma argsused void MIXER::Touch(uint16 mask, int x, int y) { - SPRITE::Touch(mask, x, y); + Sprite::Touch(mask, x, y); if (mask & L_UP) { uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < W / 2); if (y < MIX_BHIG) { diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index d589aceaea..d42d25ca24 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -39,11 +39,11 @@ namespace CGE { #define MIX_BHIG 6 // mixer button high #define MIX_NAME 105 // sprite name -class MIXER : public SPRITE { +class MIXER : public Sprite { BMP_PTR mb[2]; BMP_PTR lb[MIX_MAX + 1]; - SEQ ls[MIX_MAX]; - SPRITE *Led[2]; + Seq ls[MIX_MAX]; + Sprite *Led[2]; int Fall; void Update(void); public: diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 10953291f2..cb94e926c5 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -39,8 +39,8 @@ MOUSE_FUN *MOUSE::OldMouseFun = NULL; uint16 MOUSE::OldMouseMask = 0; -MOUSE::MOUSE(CGEEngine *vm, BITMAP **shpl) : SPRITE(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { - static SEQ ms[] = { +MOUSE::MOUSE(CGEEngine *vm, BITMAP **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { + static Seq ms[] = { { 0, 0, 0, 0, 1 }, { 1, 1, 0, 0, 1 } }; @@ -58,6 +58,7 @@ MOUSE::MOUSE(CGEEngine *vm, BITMAP **shpl) : SPRITE(vm, shpl), Busy(NULL), Hold( Z = 127; Step(1); */ + Exist = true; warning("STUB: MOUSE::MOUSE"); } @@ -131,7 +132,7 @@ void MOUSE::Off(void) { } -void MOUSE::ClrEvt(SPRITE *spr) { +void MOUSE::ClrEvt(Sprite *spr) { if (spr) { uint16 e; for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index 61503fadd1..28152b7f29 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -48,7 +48,7 @@ extern TALK *Talk; struct EVENT { uint16 Msk; uint16 X, Y; - SPRITE *Ptr; + Sprite *Ptr; }; extern EVENT Evt[EVT_MAX]; @@ -56,24 +56,24 @@ extern uint16 EvtHead, EvtTail; typedef void (MOUSE_FUN)(void); -class MOUSE : public SPRITE { +class MOUSE : public Sprite { static MOUSE_FUN *OldMouseFun; static MOUSE_FUN NewMouseFun; static uint16 OldMouseMask; - SPRITE *Hold; + Sprite *Hold; int hx, hy; //void SetFun (void); //void ResetFun (void); public: bool Exist; int Buttons; - SPRITE *Busy; - //SPRITE * Touched; + Sprite *Busy; + //Sprite *Touched; MOUSE(CGEEngine *vm, BITMAP **shpl = MC); ~MOUSE(); void On(); void Off(); - static void ClrEvt(SPRITE *spr = NULL); + static void ClrEvt(Sprite *spr = NULL); void Tick(); private: CGEEngine *_vm; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 0137ab4cfa..1cb53d2024 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -56,27 +56,27 @@ bool Game = false; int Now = 1; int Lev = -1; -extern SPRITE *PocLight; +extern Sprite *_pocLight; //------------------------------------------------------------------------- // SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, // NULL, NULL, NULL, NULL, }; // int PocPtr = 0; //------------------------------------------------------------------------- -extern SPRITE *Pocket[]; +extern Sprite *_pocket[]; extern int PocPtr; -static void SNGame(SPRITE *spr, int num) { +static void SNGame(Sprite *spr, int num) { switch (num) { case 1 : { #define STAGES 8 #define DRESSED 3 - static SPRITE *dup[3] = { NULL, NULL, NULL }; + static Sprite *dup[3] = { NULL, NULL, NULL }; int buref = 0; int Stage = 0; for (dup[0] = Vga->ShowQ->First(); dup[0]; dup[0] = dup[0]->Next) { - buref = dup[0]->Ref; + buref = dup[0]->_ref; if (buref / 1000 == 16 && buref % 100 == 6) { Stage = (buref / 100) % 10; break; @@ -163,7 +163,7 @@ static void SNGame(SPRITE *spr, int num) { break; //-------------------------------------------------------------------- case 2 : { - static SPRITE *k = NULL, * k1, * k2, * k3; + static Sprite *k = NULL, * k1, * k2, * k3; static int count = 0; if (k == NULL) { @@ -181,7 +181,7 @@ static void SNGame(SPRITE *spr, int num) { k2->Step(new_random(6)); k3->Step(new_random(6)); ///-------------------- - if (spr->Ref == 1 && KEYBOARD::Key[ALT]) { + if (spr->_ref == 1 && KEYBOARD::Key[ALT]) { k1->Step(5); k2->Step(5); k3->Step(5); @@ -190,7 +190,7 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNSETZ, 20700, 0, NULL); bool hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15); if (hit) { - if (spr->Ref == 1) { + if (spr->_ref == 1) { SNPOST(SNSAY, 1, 20003, NULL); // hura! SNPOST(SNSEQ, 20011, 2, NULL); // kamera won SNPOST(SNSEND, 20701, -1, NULL); // k1 won @@ -223,7 +223,7 @@ static void SNGame(SPRITE *spr, int num) { } ++ count; } - switch (spr->Ref) { + switch (spr->_ref) { case 1 : SNPOST(SNSAY, 20001, 20011, NULL); // zapro SNPOST(SNSEQ, 20001, 1, NULL); // rzu @@ -275,38 +275,38 @@ static void SNGame(SPRITE *spr, int num) { } -void ExpandSprite(SPRITE *spr) { +void ExpandSprite(Sprite *spr) { if (spr) Vga->ShowQ->Insert(Vga->SpareQ->Remove(spr)); } -void ContractSprite(SPRITE *spr) { +void ContractSprite(Sprite *spr) { if (spr) Vga->SpareQ->Append(Vga->ShowQ->Remove(spr)); } -int FindPocket(SPRITE *spr) { +int FindPocket(Sprite *spr) { for (int i = 0; i < POCKET_NX; i++) - if (Pocket[i] == spr) + if (_pocket[i] == spr) return i; return -1; } void SelectPocket(int n) { - if (n < 0 || (PocLight->SeqPtr && PocPtr == n)) { - PocLight->Step(0); + if (n < 0 || (_pocLight->SeqPtr && PocPtr == n)) { + _pocLight->Step(0); n = FindPocket(NULL); if (n >= 0) PocPtr = n; } else { - if (Pocket[n] != NULL) { + if (_pocket[n] != NULL) { PocPtr = n; - PocLight->Step(1); + _pocLight->Step(1); } } - PocLight->Goto(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); + _pocLight->Goto(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); } @@ -320,7 +320,7 @@ void PocFul(void) { } -void Hide1(SPRITE *spr) { +void Hide1(Sprite *spr) { SNPOST_(SNGHOST, -1, 0, spr->Ghost()); } @@ -334,7 +334,7 @@ void SNGhost(BITMAP *bmp) { } -void FeedSnail(SPRITE *spr, SNLIST snq) { +void FeedSnail(Sprite *spr, SNLIST snq) { if (spr) if (spr->Active()) { uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; @@ -360,7 +360,7 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { KillText(); } if (c->Com == SNNEXT) { - SPRITE *s = (c->Ref < 0) ? spr : Locate(c->Ref); + Sprite *s = (c->Ref < 0) ? spr : Locate(c->Ref); if (s) { uint8 *idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr; if (*idx != NO_PTR) { @@ -387,7 +387,7 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { break; } if (c->Com == SNIF) { - SPRITE *s = (c->Ref < 0) ? spr : Locate(c->Ref); + Sprite *s = (c->Ref < 0) ? spr : Locate(c->Ref); if (s) { // sprite extsts if (! s->SeqTest(-1)) c = comtab + c->Val; // not parked @@ -475,52 +475,52 @@ void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { } -static void SNNNext(SPRITE *sprel, int p) { +static void SNNNext(Sprite *sprel, int p) { if (sprel) if (sprel->NearPtr != NO_PTR) sprel->NearPtr = p; } -static void SNTNext(SPRITE *sprel, int p) { +static void SNTNext(Sprite *sprel, int p) { if (sprel) if (sprel->TakePtr != NO_PTR) sprel->TakePtr = p; } -static void SNRNNext(SPRITE *sprel, int p) { +static void SNRNNext(Sprite *sprel, int p) { if (sprel) if (sprel->NearPtr != NO_PTR) sprel->NearPtr += p; } -static void SNRTNext(SPRITE *sprel, int p) { +static void SNRTNext(Sprite *sprel, int p) { if (sprel) if (sprel->TakePtr != NO_PTR) sprel->TakePtr += p; } -static void SNZTrim(SPRITE *spr) { +static void SNZTrim(Sprite *spr) { if (spr) if (spr->Active()) { - bool en = Heart->Enable; - SPRITE *s; - Heart->Enable = false; + bool en = _heart->_enable; + Sprite *s; + _heart->_enable = false; s = (spr->Flags.Shad) ? spr->Prev : NULL; Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr)); if (s) { s->Z = spr->Z; Vga->ShowQ->Insert(Vga->ShowQ->Remove(s), spr); } - Heart->Enable = en; + _heart->_enable = en; } } -static void SNHide(SPRITE *spr, int val) { +static void SNHide(Sprite *spr, int val) { if (spr) { spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide); if (spr->Flags.Shad) @@ -529,19 +529,19 @@ static void SNHide(SPRITE *spr, int val) { } -static void SNRmNear(SPRITE *spr) { +static void SNRmNear(Sprite *spr) { if (spr) spr->NearPtr = NO_PTR; } -static void SNRmTake(SPRITE *spr) { +static void SNRmTake(Sprite *spr) { if (spr) spr->TakePtr = NO_PTR; } -void SNSeq(SPRITE *spr, int val) { +void SNSeq(Sprite *spr, int val) { if (spr) { if (spr == Hero && val == 0) Hero->Park(); @@ -551,30 +551,30 @@ void SNSeq(SPRITE *spr, int val) { } -void SNRSeq(SPRITE *spr, int val) { +void SNRSeq(Sprite *spr, int val) { if (spr) SNSeq(spr, spr->SeqPtr + val); } -void SNSend(SPRITE *spr, int val) { +void SNSend(Sprite *spr, int val) { if (spr) { - int was = spr->Cave; + int was = spr->_cave; bool was1 = (was == 0 || was == Now); bool val1 = (val == 0 || val == Now); - spr->Cave = val; + spr->_cave = val; if (val1 != was1) { if (was1) { if (spr->Flags.Kept) { int n = FindPocket(spr); if (n >= 0) - Pocket[n] = NULL; + _pocket[n] = NULL; } Hide1(spr); ContractSprite(spr); spr->Flags.Slav = false; } else { - if (spr->Ref % 1000 == 0) + if (spr->_ref % 1000 == 0) BITMAP::Pal = VGA::SysPal; if (spr->Flags.Back) spr->BackShow(true); @@ -587,22 +587,22 @@ void SNSend(SPRITE *spr, int val) { } -void SNSwap(SPRITE *spr, int xref) { - SPRITE *xspr = Locate(xref); +void SNSwap(Sprite *spr, int xref) { + Sprite *xspr = Locate(xref); if (spr && xspr) { - int was = spr->Cave; - int xwas = xspr->Cave; + int was = spr->_cave; + int xwas = xspr->_cave; bool was1 = (was == 0 || was == Now); bool xwas1 = (xwas == 0 || xwas == Now); - Swap(spr->Cave, xspr->Cave); + Swap(spr->_cave, xspr->_cave); Swap(spr->X, xspr->X); Swap(spr->Y, xspr->Y); Swap(spr->Z, xspr->Z); if (spr->Flags.Kept) { int n = FindPocket(spr); if (n >= 0) - Pocket[n] = xspr; + _pocket[n] = xspr; xspr->Flags.Kept = true; xspr->Flags.Port = false; } @@ -622,12 +622,12 @@ void SNSwap(SPRITE *spr, int xref) { } -void SNCover(SPRITE *spr, int xref) { - SPRITE *xspr = Locate(xref); +void SNCover(Sprite *spr, int xref) { + Sprite *xspr = Locate(xref); if (spr && xspr) { spr->Flags.Hide = true; xspr->Z = spr->Z; - xspr->Cave = spr->Cave; + xspr->_cave = spr->_cave; xspr->Goto(spr->X, spr->Y); ExpandSprite(xspr); if ((xspr->Flags.Shad = spr->Flags.Shad) == 1) { @@ -639,10 +639,10 @@ void SNCover(SPRITE *spr, int xref) { } -void SNUncover(SPRITE *spr, SPRITE *xspr) { +void SNUncover(Sprite *spr, Sprite *xspr) { if (spr && xspr) { spr->Flags.Hide = false; - spr->Cave = xspr->Cave; + spr->_cave = xspr->_cave; spr->Goto(xspr->X, xspr->Y); if ((spr->Flags.Shad = xspr->Flags.Shad) == 1) { Vga->ShowQ->Insert(Vga->ShowQ->Remove(xspr->Prev), spr); @@ -666,25 +666,25 @@ void SNSetY0(int cav, int y0) { } -void SNSetXY(SPRITE *spr, uint16 xy) { +void SNSetXY(Sprite *spr, uint16 xy) { if (spr) spr->Goto(xy % SCR_WID, xy / SCR_WID); } -void SNRelX(SPRITE *spr, int x) { +void SNRelX(Sprite *spr, int x) { if (spr && Hero) spr->Goto(Hero->X + x, spr->Y); } -void SNRelY(SPRITE *spr, int y) { +void SNRelY(Sprite *spr, int y) { if (spr && Hero) spr->Goto(spr->X, Hero->Y + y); } -void SNRelZ(SPRITE *spr, int z) { +void SNRelZ(Sprite *spr, int z) { if (spr && Hero) { spr->Z = Hero->Z + z; SNZTrim(spr); @@ -692,19 +692,19 @@ void SNRelZ(SPRITE *spr, int z) { } -void SNSetX(SPRITE *spr, int x) { +void SNSetX(Sprite *spr, int x) { if (spr) spr->Goto(x, spr->Y); } -void SNSetY(SPRITE *spr, int y) { +void SNSetY(Sprite *spr, int y) { if (spr) spr->Goto(spr->X, y); } -void SNSetZ(SPRITE *spr, int z) { +void SNSetZ(Sprite *spr, int z) { if (spr) { spr->Z = z; //SNPOST_(SNZTRIM, -1, 0, spr); @@ -713,11 +713,11 @@ void SNSetZ(SPRITE *spr, int z) { } -void SNSlave(SPRITE *spr, int ref) { - SPRITE *slv = Locate(ref); +void SNSlave(Sprite *spr, int ref) { + Sprite *slv = Locate(ref); if (spr && slv) { if (spr->Active()) { - SNSend(slv, spr->Cave); + SNSend(slv, spr->_cave); slv->Flags.Slav = true; slv->Z = spr->Z; Vga->ShowQ->Insert(Vga->ShowQ->Remove(slv), spr->Next); @@ -726,33 +726,33 @@ void SNSlave(SPRITE *spr, int ref) { } -void SNTrans(SPRITE *spr, int trans) { +void SNTrans(Sprite *spr, int trans) { if (spr) spr->Flags.Tran = (trans < 0) ? !spr->Flags.Tran : (trans != 0); } -void SNPort(SPRITE *spr, int port) { +void SNPort(Sprite *spr, int port) { if (spr) spr->Flags.Port = (port < 0) ? !spr->Flags.Port : (port != 0); } -void SNKill(SPRITE *spr) { +void SNKill(Sprite *spr) { if (spr) { if (spr->Flags.Kept) { int n = FindPocket(spr); if (n >= 0) - Pocket[n] = NULL; + _pocket[n] = NULL; } - SPRITE *nx = spr->Next; + Sprite *nx = spr->Next; Hide1(spr); Vga->ShowQ->Remove(spr); MOUSE::ClrEvt(spr); if (spr->Flags.Kill) delete spr; else { - spr->Cave = -1; + spr->_cave = -1; Vga->SpareQ->Append(spr); } if (nx) @@ -762,7 +762,7 @@ void SNKill(SPRITE *spr) { } -static void SNSound(SPRITE *spr, int wav, int cnt) { +static void SNSound(Sprite *spr, int wav, int cnt) { if (SNDDrvInfo.DDEV) { if (wav == -1) Sound.Stop(); @@ -772,12 +772,12 @@ static void SNSound(SPRITE *spr, int wav, int cnt) { } -void SNKeep(SPRITE *spr, int stp) { +void SNKeep(Sprite *spr, int stp) { SelectPocket(-1); - if (spr && ! spr->Flags.Kept && Pocket[PocPtr] == NULL) { + if (spr && ! spr->Flags.Kept && _pocket[PocPtr] == NULL) { SNSound(spr, 3, 1); - Pocket[PocPtr] = spr; - spr->Cave = 0; + _pocket[PocPtr] = spr; + spr->_cave = 0; spr->Flags.Kept = true; spr->Goto(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->W / 2, POCKET_Y + POCKET_DY / 2 - spr->H / 2); @@ -788,12 +788,12 @@ void SNKeep(SPRITE *spr, int stp) { } -void SNGive(SPRITE *spr, int stp) { +void SNGive(Sprite *spr, int stp) { if (spr) { int p = FindPocket(spr); if (p >= 0) { - Pocket[p] = NULL; - spr->Cave = Now; + _pocket[p] = NULL; + spr->_cave = Now; spr->Flags.Kept = false; if (stp >= 0) spr->Step(stp); @@ -803,7 +803,7 @@ void SNGive(SPRITE *spr, int stp) { } -static void SNBackPt(SPRITE *spr, int stp) { +static void SNBackPt(Sprite *spr, int stp) { if (spr) { if (stp >= 0) spr->Step(stp); @@ -812,19 +812,19 @@ static void SNBackPt(SPRITE *spr, int stp) { } -static void SNLevel(SPRITE *spr, int lev) { +static void SNLevel(Sprite *spr, int lev) { #ifdef DEMO static int maxcav[] = { CAVE_MAX }; #else static int maxcav[] = { 1, 8, 16, 23, 24 }; #endif while (Lev < lev) { - SPRITE *spr; + Sprite *spr; ++Lev; spr = Vga->SpareQ->Locate(100 + Lev); if (spr) { spr->BackShow(true); - spr->Cave = 0; + spr->_cave = 0; } } MaxCave = maxcav[Lev]; @@ -838,9 +838,9 @@ static void SNFlag(int fn, bool v) { } -static void SNSetRef(SPRITE *spr, int nr) { +static void SNSetRef(Sprite *spr, int nr) { if (spr) - spr->Ref = nr; + spr->_ref = nr; } @@ -880,7 +880,7 @@ static void SNBarrier(int cav, int bar, bool horz) { } -static void SNWalk(SPRITE *spr, int x, int y) { +static void SNWalk(Sprite *spr, int x, int y) { if (Hero) { if (spr && y < 0) Hero->FindWay(spr); @@ -890,7 +890,7 @@ static void SNWalk(SPRITE *spr, int x, int y) { } -static void SNReach(SPRITE *spr, int mode) { +static void SNReach(Sprite *spr, int mode) { if (Hero) Hero->Reach(spr, mode); } @@ -925,12 +925,12 @@ void SNAIL::RunCom(void) { break; } - SPRITE *sprel = ((snc->Ref >= 0) ? Locate(snc->Ref) : ((SPRITE *) snc->Ptr)); + Sprite *sprel = ((snc->Ref >= 0) ? Locate(snc->Ref) : ((Sprite *) snc->Ptr)); switch (snc->Com) { case SNLABEL : break; case SNPAUSE : - Heart->SetXTimer(&Pause, snc->Val); + _heart->setXTimer(&Pause, snc->Val); if (Talk) TextDelay = true; break; @@ -938,7 +938,7 @@ void SNAIL::RunCom(void) { if (sprel) { if (sprel->SeqTest(snc->Val) && (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) { - Heart->SetXTimer(&Pause, sprel->Time); + _heart->setXTimer(&Pause, sprel->Time); } else goto xit; } @@ -993,7 +993,7 @@ void SNAIL::RunCom(void) { SNCover(sprel, snc->Val); break; case SNUNCOVER : - SNUncover(sprel, (snc->Val >= 0) ? Locate(snc->Val) : ((SPRITE *) snc->Ptr)); + SNUncover(sprel, (snc->Val >= 0) ? Locate(snc->Val) : ((Sprite *) snc->Ptr)); break; case SNKEEP : SNKeep(sprel, snc->Val); diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index ae94233464..544359897f 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -98,7 +98,7 @@ void FONT::Save(void) { TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode) - : SPRITE(vm, NULL), Mode(mode), _vm(vm) { + : Sprite(vm, NULL), Mode(mode), _vm(vm) { TS[0] = TS[1] = NULL; Flags.Syst = true; Update(tx); @@ -106,7 +106,7 @@ TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode) TALK::TALK(CGEEngine *vm) - : SPRITE(vm, NULL), Mode(PURE), _vm(vm) { + : Sprite(vm, NULL), Mode(PURE), _vm(vm) { TS[0] = TS[1] = NULL; Flags.Syst = true; } diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 184b84e553..2a38af91d1 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -68,7 +68,7 @@ public: enum TBOX_STYLE { PURE, RECT, ROUND }; -class TALK : public SPRITE { +class TALK : public Sprite { protected: TBOX_STYLE Mode; BITMAP *TS[2]; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 6d7341af0a..74ff6fac2d 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -180,14 +180,14 @@ char *TEXT::getText(int ref) { } -void TEXT::Say(const char *txt, SPRITE *spr) { +void TEXT::Say(const char *txt, Sprite *spr) { KillText(); Talk = new TALK(_vm, txt, ROUND); if (Talk) { bool east = spr->Flags.East; int x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2); int y = spr->Y + 2; - SPRITE *spike = new SPRITE(_vm, SP); + Sprite *spike = new Sprite(_vm, SP); uint16 sw = spike->W; if (east) { @@ -198,7 +198,7 @@ void TEXT::Say(const char *txt, SPRITE *spr) { east = true; } x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2 - sw); - if (spr->Ref == 1) + if (spr->_ref == 1) x += ((east) ? -10 : 10); // Hero Talk->Flags.Kill = true; @@ -206,7 +206,7 @@ void TEXT::Say(const char *txt, SPRITE *spr) { Talk->SetName(Text->getText(SAY_NAME)); Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H + 1); Talk->Z = 125; - Talk->Ref = SAY_REF; + Talk->_ref = SAY_REF; spike->Goto(x, Talk->Y + Talk->H - 1); spike->Z = 126; @@ -214,7 +214,7 @@ void TEXT::Say(const char *txt, SPRITE *spr) { spike->Flags.Kill = true; spike->SetName(Text->getText(SAY_NAME)); spike->Step(east); - spike->Ref = SAY_REF; + spike->_ref = SAY_REF; Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); Vga->ShowQ->Insert(spike, Vga->ShowQ->Last()); @@ -231,13 +231,13 @@ void CGEEngine::Inf(const char *txt) { Talk->Center(); Talk->Goto(Talk->X, Talk->Y - 20); Talk->Z = 126; - Talk->Ref = INF_REF; + Talk->_ref = INF_REF; Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); } } -void SayTime(SPRITE *spr) { +void SayTime(Sprite *spr) { /* static char t[] = "00:00"; struct time ti; diff --git a/engines/cge/text.h b/engines/cge/text.h index 161b2e813a..874a640ad0 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -66,7 +66,7 @@ public: void Clear(int from = 1, int upto = 0x7FFF); void Preload(int from = 1, int upto = 0x7FFF); char *getText(int ref); - void Say(const char *txt, SPRITE *spr); + void Say(const char *txt, Sprite *spr); private: CGEEngine *_vm; }; @@ -76,8 +76,8 @@ extern TALK *Talk; extern TEXT *Text; -void Say(const char *txt, SPRITE *spr); -void SayTime(SPRITE *spr); +void Say(const char *txt, Sprite *spr); +void SayTime(Sprite *spr); void Inf(const char *txt); void KillText(void); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index b59f8e8de5..1d55af7e31 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -51,7 +51,6 @@ static char Report[] = "NearHeap=..... FarHeap=......\n"; #define FREP 24 static VgaRegBlk VideoMode[] = { - { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 @@ -69,9 +68,9 @@ static VgaRegBlk VideoMode[] = { }; -bool SpeedTest = false; -SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; -SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; +bool SpeedTest = false; +Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; +Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; extern "C" void SNDMIDIPlay(void); @@ -83,8 +82,7 @@ char *NumStr(char *str, int num) { } -static void Video(void) -{ +static void Video() { /* static uint16 SP_S; @@ -206,7 +204,7 @@ DAC MkDAC(uint8 r, uint8 g, uint8 b) { } -RGB MkRGB(uint8 r, uint8 g, uint8 b) { +Rgb MkRGB(uint8 r, uint8 g, uint8 b) { static TRGB x; x.dac.R = r; x.dac.G = g; @@ -215,54 +213,60 @@ RGB MkRGB(uint8 r, uint8 g, uint8 b) { } -SPRITE *Locate(int ref) { - SPRITE *spr = Vga->ShowQ->Locate(ref); +Sprite *Locate(int ref) { + Sprite *spr = Vga->ShowQ->Locate(ref); return (spr) ? spr : Vga->SpareQ->Locate(ref); } -HEART::HEART(void) +Heart::Heart(void) : ENGINE(TMR_DIV) { - Enable = false; - XTimer = NULL; + _enable = false; + _xTimer = NULL; } /* -extern "C" void TimerProc (void) -{ - static SPRITE * spr; - static uint8 run = 0; - - // decrement external timer uint16 - if (Heart->XTimer) - if (*Heart->XTimer) - *Heart->XTimer--; - else - Heart->XTimer = NULL; - - if (! run && Heart->Enable) // check overrun flag - { - static uint16 oldSP, oldSS; - - run++; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 - - // system pseudo-sprite - if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); - - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) - { - if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); - } - asm mov ss,oldSS - asm mov sp,oldSP - run--; - } +extern "C" void TimerProc() { + static SPRITE * spr; + static uint8 run = 0; + + // decrement external timer uint16 + if (_heart->_xTimer) { + if (*_heart->_xTimer) + *_heart->_xTimer--; + else + _heart->_xTimer = NULL; + } + + if (!run && _heart->_enable) { // check overrun flag + static uint16 oldSP, oldSS; + run++; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 + + // system pseudo-sprite + if (Sys) { + if (Sys->Time) { + if (--Sys->Time == 0) + Sys->Tick(); + } + } + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { + if (spr->Time) { + if (!spr->Flags.Hide) { + if (-- spr->Time == 0) + spr->Tick(); + } + } + } + asm mov ss,oldSS + asm mov sp,oldSP + run--; + } } */ @@ -301,17 +305,17 @@ void ENGINE::NewTimer(...) { my_int: //------72Hz-------// // decrement external timer uint16 - if (Heart->XTimer) - if (*Heart->XTimer) - *Heart->XTimer--; + if (_heart->XTimer) { + if (*_heart->XTimer) + *_heart->XTimer--; else - Heart->XTimer = NULL; + _heart->XTimer = NULL; + } - if (! run && Heart->Enable) // check overrun flag - { + if (! run && _heart->Enable) { // check overrun flag static uint16 oldSP, oldSS; - run++; // disable 2nd call until current lasts + run++; // disable 2nd call until current lasts asm mov ax,ds asm mov oldSS,ss asm mov oldSP,sp @@ -319,12 +323,21 @@ void ENGINE::NewTimer(...) { asm mov sp,0xFF80 // system pseudo-sprite - if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); + if (Sys) { + if (Sys->Time) { + if (--Sys->Time == 0) + Sys->Tick(); + } + } - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) - { - if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); - } + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { + if (spr->Time) { + if (!spr->Flags.Hide) { + if (--spr->Time == 0) + spr->Tick(); + } + } + } asm mov ss,oldSS asm mov sp,oldSP run--; @@ -335,39 +348,39 @@ void ENGINE::NewTimer(...) { } -void HEART::SetXTimer(uint16 *ptr) { - if (XTimer && ptr != XTimer) - *XTimer = 0; - XTimer = ptr; +void Heart::setXTimer(uint16 *ptr) { + if (_xTimer && ptr != _xTimer) + *_xTimer = 0; + _xTimer = ptr; } -void HEART::SetXTimer(uint16 *ptr, uint16 time) { - SetXTimer(ptr); +void Heart::setXTimer(uint16 *ptr, uint16 time) { + setXTimer(ptr); *ptr = time; } -SPRITE::SPRITE(CGEEngine *vm, BMP_PTR *shp) +Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), - Ext(NULL), Ref(-1), Cave(0), _vm(vm) { + _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(File, 0, sizeof(File)); *((uint16 *)&Flags) = 0; SetShapeList(shp); } -SPRITE::~SPRITE(void) { +Sprite::~Sprite() { Contract(); } -BMP_PTR SPRITE::Shp(void) { - register SPREXT *e = Ext; +BMP_PTR Sprite::Shp() { + register SprExt *e = _ext; if (e) - if (e->Seq) { - int i = e->Seq[SeqPtr].Now; + if (e->_seq) { + int i = e->_seq[SeqPtr].Now; if (i >= ShpCnt) { //char s[256]; //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", @@ -375,14 +388,14 @@ BMP_PTR SPRITE::Shp(void) { //VGA::Exit(s, File); error("Invalid PHASE in SPRITE::Shp() %s", File); } - return e->ShpList[i]; + return e->_shpList[i]; } return NULL; } -BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { - BMP_PTR *r = (Ext) ? Ext->ShpList : NULL; +BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { + BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; ShpCnt = 0; W = 0; @@ -399,29 +412,29 @@ BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { ++ShpCnt; } Expand(); - Ext->ShpList = shp; - if (! Ext->Seq) - SetSeq((ShpCnt < 2) ? Seq1 : Seq2); + _ext->_shpList = shp; + if (!_ext->_seq) + SetSeq((ShpCnt < 2) ? _seq1 : _seq2); } return r; } -void SPRITE::MoveShapes(uint8 *buf) { +void Sprite::MoveShapes(uint8 *buf) { BMP_PTR *p; - for (p = Ext->ShpList; *p; p++) { + for (p = _ext->_shpList; *p; p++) { buf += (*p)->MoveVmap(buf); } } -bool SPRITE::Works(SPRITE *spr) { +bool Sprite::Works(Sprite *spr) { if (spr) - if (spr->Ext) { - SNAIL::COM *c = spr->Ext->Take; + if (spr->_ext) { + SNAIL::COM *c = spr->_ext->_take; if (c != NULL) { c += spr->TakePtr; - if (c->Ref == Ref) + if (c->Ref == _ref) if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) return true; } @@ -430,10 +443,10 @@ bool SPRITE::Works(SPRITE *spr) { } -SEQ *SPRITE::SetSeq(SEQ *seq) { +Seq *Sprite::SetSeq(Seq *seq) { Expand(); - register SEQ *s = Ext->Seq; - Ext->Seq = seq; + register Seq *s = _ext->_seq; + _ext->_seq = seq; if (SeqPtr == NO_SEQ) Step(0); else if (Time == 0) @@ -442,32 +455,32 @@ SEQ *SPRITE::SetSeq(SEQ *seq) { } -bool SPRITE::SeqTest(int n) { +bool Sprite::SeqTest(int n) { if (n >= 0) return (SeqPtr == n); - if (Ext) - return (Ext->Seq[SeqPtr].Next == SeqPtr); + if (_ext) + return (_ext->_seq[SeqPtr].Next == SeqPtr); return true; } -SNAIL::COM *SPRITE::SnList(SNLIST type) { - register SPREXT *e = Ext; +SNAIL::COM *Sprite::SnList(SNLIST type) { + register SprExt *e = _ext; if (e) - return (type == NEAR) ? e->Near : e->Take; + return (type == NEAR) ? e->_near : e->_take; return NULL; } -void SPRITE::SetName(char *n) { - if (Ext) { - if (Ext->Name) { - delete[] Ext->Name; - Ext->Name = NULL; +void Sprite::SetName(char *n) { + if (_ext) { + if (_ext->_name) { + delete[] _ext->_name; + _ext->_name = NULL; } if (n) { - if ((Ext->Name = new char[strlen(n) + 1]) != NULL) - strcpy(Ext->Name, n); + if ((_ext->_name = new char[strlen(n) + 1]) != NULL) + strcpy(_ext->_name, n); else error("No core [%s]", n); } @@ -475,17 +488,17 @@ void SPRITE::SetName(char *n) { } -SPRITE *SPRITE::Expand(void) { - if (! Ext) { - bool enbl = Heart->Enable; - Heart->Enable = false; - if ((Ext = new SPREXT) == NULL) +Sprite *Sprite::Expand(void) { + if (!_ext) { + bool enbl = _heart->_enable; + _heart->_enable = false; + if ((_ext = new SprExt) == NULL) error("No core"); if (*File) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; BMP_PTR *shplist = new BMP_PTR [ShpCnt + 1]; - SEQ *seq = NULL; + Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, neacnt = 0, @@ -518,10 +531,10 @@ SPRITE *SPRITE::Expand(void) { break; } case 2 : { // Seq - seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); if (seq == NULL) error("No core [%s]", fname); - SEQ *s = &seq[seqcnt++]; + Seq *s = &seq[seqcnt++]; s->Now = atoi(strtok(NULL, " \t,;/")); if (s->Now > maxnow) maxnow = s->Now; @@ -586,52 +599,52 @@ SPRITE *SPRITE::Expand(void) { error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); } else - SetSeq((ShpCnt == 1) ? Seq1 : Seq2); + SetSeq((ShpCnt == 1) ? _seq1 : _seq2); //disable(); // disable interupt SetShapeList(shplist); //enable(); // enable interupt if (nea) - nea[neacnt - 1].Ptr = Ext->Near = nea; + nea[neacnt - 1].Ptr = _ext->_near = nea; else NearPtr = NO_PTR; if (tak) - tak[takcnt - 1].Ptr = Ext->Take = tak; + tak[takcnt - 1].Ptr = _ext->_take = tak; else TakePtr = NO_PTR; } - Heart->Enable = enbl; + _heart->_enable = enbl; } return this; } -SPRITE *SPRITE::Contract(void) { - register SPREXT *e = Ext; +Sprite *Sprite::Contract(void) { + register SprExt *e = _ext; if (e) { - if (e->Name) - delete[] e->Name; - if (Flags.BDel && e->ShpList) { + if (e->_name) + delete[] e->_name; + if (Flags.BDel && e->_shpList) { int i; - for (i = 0; e->ShpList[i]; i++) - delete e->ShpList[i]; - if (MemType(e->ShpList) == NEAR_MEM) - delete[] e->ShpList; + for (i = 0; e->_shpList[i]; i++) + delete e->_shpList[i]; + if (MemType(e->_shpList) == NEAR_MEM) + delete[] e->_shpList; } - if (MemType(e->Seq) == NEAR_MEM) - free(e->Seq); - if (e->Near) - free(e->Near); - if (e->Take) - free(e->Take); + if (MemType(e->_seq) == NEAR_MEM) + free(e->_seq); + if (e->_near) + free(e->_near); + if (e->_take) + free(e->_take); delete e; - Ext = NULL; + _ext = NULL; } return this; } -SPRITE *SPRITE::BackShow(bool fast) { +Sprite *Sprite::BackShow(bool fast) { Expand(); Show(2); Show(1); @@ -642,14 +655,14 @@ SPRITE *SPRITE::BackShow(bool fast) { } -void SPRITE::Step(int nr) { +void Sprite::Step(int nr) { if (nr >= 0) SeqPtr = nr; - if (Ext) { - SEQ *seq; + if (_ext) { + Seq *seq; if (nr < 0) - SeqPtr = Ext->Seq[SeqPtr].Next; - seq = Ext->Seq + SeqPtr; + SeqPtr = _ext->_seq[SeqPtr].Next; + seq = _ext->_seq + SeqPtr; if (seq->Dly >= 0) { Goto(X + (seq->Dx), Y + (seq->Dy)); Time = seq->Dly; @@ -658,28 +671,28 @@ void SPRITE::Step(int nr) { } -void SPRITE::Tick(void) { +void Sprite::Tick(void) { Step(); } -void SPRITE::MakeXlat(uint8 *x) { - if (Ext) { +void Sprite::MakeXlat(uint8 *x) { + if (_ext) { BMP_PTR *b; if (Flags.Xlat) KillXlat(); - for (b = Ext->ShpList; *b; b++) + for (b = _ext->_shpList; *b; b++) (*b)->M = x; Flags.Xlat = true; } } -void SPRITE::KillXlat(void) { - if (Flags.Xlat && Ext) { +void Sprite::KillXlat(void) { + if (Flags.Xlat && _ext) { BMP_PTR *b; - uint8 *m = (*Ext->ShpList)->M; + uint8 *m = (*_ext->_shpList)->M; switch (MemType(m)) { case NEAR_MEM : @@ -689,14 +702,14 @@ void SPRITE::KillXlat(void) { free(m); break; } - for (b = Ext->ShpList; *b; b++) + for (b = _ext->_shpList; *b; b++) (*b)->M = NULL; Flags.Xlat = false; } } -void SPRITE::Goto(int x, int y) { +void Sprite::Goto(int x, int y) { int xo = X, yo = Y; if (W < SCR_WID) { if (x < 0) @@ -720,30 +733,32 @@ void SPRITE::Goto(int x, int y) { } -void SPRITE::Center(void) { +void Sprite::Center(void) { Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); } -void SPRITE::Show(void) { - register SPREXT *e; +void Sprite::Show(void) { + register SprExt *e; // asm cli // critic section... - e = Ext; - e->x0 = e->x1; - e->y0 = e->y1; - e->b0 = e->b1; - e->x1 = X; - e->y1 = Y; - e->b1 = Shp(); + e = _ext; + e->_x0 = e->_x1; + e->_y0 = e->_y1; + e->_b0 = e->_b1; + e->_x1 = X; + e->_y1 = Y; + e->_b1 = Shp(); // asm sti // ...done! if (! Flags.Hide) { - if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); - else e->b1->Show(e->x1, e->y1); + if (Flags.Xlat) + e->_b1->XShow(e->_x1, e->_y1); + else + e->_b1->Show(e->_x1, e->_y1); } } -void SPRITE::Show(uint16 pg) { +void Sprite::Show(uint16 pg) { Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; Shp()->Show(X, Y); @@ -751,24 +766,24 @@ void SPRITE::Show(uint16 pg) { } -void SPRITE::Hide(void) { - register SPREXT *e = Ext; - if (e->b0) - e->b0->Hide(e->x0, e->y0); +void Sprite::Hide(void) { + register SprExt *e = _ext; + if (e->_b0) + e->_b0->Hide(e->_x0, e->_y0); } -BMP_PTR SPRITE::Ghost(void) { - register SPREXT *e = Ext; - if (e->b1) { +BMP_PTR Sprite::Ghost(void) { + register SprExt *e = _ext; + if (e->_b1) { BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); if (bmp == NULL) error("No core"); - bmp->W = e->b1->W; - bmp->H = e->b1->H; + bmp->W = e->_b1->W; + bmp->H = e->_b1->H; if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) error("No Core"); - bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + bmp->V = (uint8 *) memcpy(bmp->B, e->_b1->B, sizeof(HideDesc) * bmp->H); // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); warning("FIXME: SPRITE::Ghost"); @@ -778,8 +793,8 @@ BMP_PTR SPRITE::Ghost(void) { } -SPRITE *SpriteAt(int x, int y) { - SPRITE *spr = NULL, * tail = Vga->ShowQ->Last(); +Sprite *SpriteAt(int x, int y) { + Sprite *spr = NULL, * tail = Vga->ShowQ->Last(); if (tail) { for (spr = tail->Prev; spr; spr = spr->Prev) if (! spr->Flags.Hide && ! spr->Flags.Tran) @@ -801,24 +816,24 @@ QUEUE::~QUEUE(void) { void QUEUE::Clear(void) { while (Head) { - SPRITE *s = Remove(Head); + Sprite *s = Remove(Head); if (s->Flags.Kill) delete s; } } -void QUEUE::ForAll(void (*fun)(SPRITE *)) { - SPRITE *s = Head; +void QUEUE::ForAll(void (*fun)(Sprite *)) { + Sprite *s = Head; while (s) { - SPRITE *n = s->Next; + Sprite *n = s->Next; fun(s); s = n; } } -void QUEUE::Append(SPRITE *spr) { +void QUEUE::Append(Sprite *spr) { if (Tail) { spr->Prev = Tail; Tail->Next = spr; @@ -832,7 +847,7 @@ void QUEUE::Append(SPRITE *spr) { } -void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { +void QUEUE::Insert(Sprite *spr, Sprite *nxt) { if (nxt == Head) { spr->Next = Head; Head = spr; @@ -853,8 +868,8 @@ void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { } -void QUEUE::Insert(SPRITE *spr) { - SPRITE *s; +void QUEUE::Insert(Sprite *spr) { + Sprite *s; for (s = Head; s; s = s->Next) if (s->Z > spr->Z) break; @@ -869,7 +884,7 @@ void QUEUE::Insert(SPRITE *spr) { } -SPRITE *QUEUE::Remove(SPRITE *spr) { +Sprite *QUEUE::Remove(Sprite *spr) { if (spr == Head) Head = spr->Next; if (spr == Tail) @@ -884,11 +899,12 @@ SPRITE *QUEUE::Remove(SPRITE *spr) { } -SPRITE *QUEUE::Locate(int ref) { - SPRITE *spr; - for (spr = Head; spr; spr = spr->Next) - if (spr->Ref == ref) +Sprite *QUEUE::Locate(int ref) { + Sprite *spr; + for (spr = Head; spr; spr = spr->Next) { + if (spr->_ref == ref) return spr; + } return NULL; } @@ -907,9 +923,9 @@ void VGA::init() { } void VGA::deinit() { - for (int idx = 0; idx < 4; ++idx) { + for (int idx = 0; idx < 4; ++idx) delete Page[idx]; - } + delete[] SysPal; } @@ -1120,7 +1136,7 @@ void VGA::Sunset(void) { void VGA::Show(void) { - SPRITE *spr = ShowQ->First(); + Sprite *spr = ShowQ->First(); for (spr = ShowQ->First(); spr; spr = spr->Next) spr->Show(); diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index c984e121e8..af1c981aa8 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -81,37 +81,40 @@ namespace CGE { -typedef struct { +struct Rgb { uint16 r : 2; uint16 R : 6; uint16 g : 2; uint16 G : 6; uint16 b : 2; uint16 B : 6; -} RGB; +}; typedef union { DAC dac; - RGB rgb; + Rgb rgb; } TRGB; -typedef struct { - uint8 idx, adr; - uint8 clr, set; -} VgaRegBlk; +struct VgaRegBlk { + uint8 idx; + uint8 adr; + uint8 clr; + uint8 set; +}; -typedef struct { - uint8 Now, Next; - signed char Dx, Dy; +struct Seq { + uint8 Now; + uint8 Next; + int8 Dx; + int8 Dy; int Dly; -} SEQ; +}; -extern SEQ Seq1[]; -extern SEQ Seq2[]; +extern Seq _seq1[]; +extern Seq _seq2[]; //extern SEQ * Compass[]; //extern SEQ TurnToS[]; - #define PAL_CNT 256 #define PAL_SIZ (PAL_CNT * 3) #define VGAATR_ 0x3C0 @@ -130,43 +133,44 @@ extern SEQ Seq2[]; #define VGAST1 (VGAST1_ & 0xFF) -class HEART : public ENGINE { +class Heart : public ENGINE { friend class ENGINE; public: - HEART(); + Heart(); + + bool _enable; + uint16 *_xTimer; - bool Enable; - uint16 *XTimer; - void SetXTimer(uint16 *ptr); - void SetXTimer(uint16 *ptr, uint16 time); + void setXTimer(uint16 *ptr); + void setXTimer(uint16 *ptr, uint16 time); }; -class SPREXT { +class SprExt { public: - int x0, y0; - int x1, y1; - BMP_PTR b0, b1; - BMP_PTR *ShpList; - SEQ *Seq; - char *Name; - SNAIL::COM *Near, * Take; - SPREXT(void) : - x0(0), y0(0), - x1(0), y1(0), - b0(NULL), b1(NULL), - ShpList(NULL), Seq(NULL), - Name(NULL), Near(NULL), Take(NULL) + int _x0, _y0; + int _x1, _y1; + BMP_PTR _b0, _b1; + BMP_PTR *_shpList; + Seq *_seq; + char *_name; + SNAIL::COM *_near, *_take; + SprExt() : + _x0(0), _y0(0), + _x1(0), _y1(0), + _b0(NULL), _b1(NULL), + _shpList(NULL), _seq(NULL), + _name(NULL), _near(NULL), _take(NULL) {} }; -class SPRITE { +class Sprite { protected: - SPREXT *Ext; + SprExt *_ext; public: - int Ref; - signed char Cave; + int _ref; + signed char _cave; struct FLAGS { uint16 Hide : 1; // general visibility switch uint16 Near : 1; // Near action lock @@ -193,23 +197,23 @@ public: int SeqPtr; int ShpCnt; char File[MAXFILE]; - SPRITE *Prev, * Next; - bool Works(SPRITE *spr); + Sprite *Prev, * Next; + bool Works(Sprite *spr); bool SeqTest(int n); inline bool Active(void) { - return Ext != NULL; + return _ext != NULL; } - SPRITE(CGEEngine *vm, BMP_PTR *shp); - virtual ~SPRITE(void); + Sprite(CGEEngine *vm, BMP_PTR *shp); + virtual ~Sprite(void); BMP_PTR Shp(void); BMP_PTR *SetShapeList(BMP_PTR *shp); void MoveShapes(uint8 *buf); - SPRITE *Expand(void); - SPRITE *Contract(void); - SPRITE *BackShow(bool fast = false); + Sprite *Expand(void); + Sprite *Contract(void); + Sprite *BackShow(bool fast = false); void SetName(char *n); inline char *Name(void) { - return (Ext) ? Ext->Name : NULL; + return (_ext) ? _ext->_name : NULL; } void Goto(int x, int y); void Center(void); @@ -220,7 +224,7 @@ public: void MakeXlat(uint8 *x); void KillXlat(void); void Step(int nr = -1); - SEQ *SetSeq(SEQ *seq); + Seq *SetSeq(Seq *seq); SNAIL::COM *SnList(SNLIST type); virtual void Touch(uint16 mask, int x, int y); virtual void Tick(void); @@ -230,23 +234,23 @@ private: class QUEUE { - SPRITE *Head, * Tail; + Sprite *Head, * Tail; public: bool Show; QUEUE(bool show); ~QUEUE(void); - void Append(SPRITE *spr); - void Insert(SPRITE *spr, SPRITE *nxt); - void Insert(SPRITE *spr); - SPRITE *Remove(SPRITE *spr); - void ForAll(void (*fun)(SPRITE *)); - SPRITE *First(void) { + void Append(Sprite *spr); + void Insert(Sprite *spr, Sprite *nxt); + void Insert(Sprite *spr); + Sprite *Remove(Sprite *spr); + void ForAll(void (*fun)(Sprite *)); + Sprite *First(void) { return Head; } - SPRITE *Last(void) { + Sprite *Last(void) { return Tail; } - SPRITE *Locate(int ref); + Sprite *Locate(int ref); void Clear(void); }; @@ -292,8 +296,8 @@ public: }; -DAC MkDAC(uint8 r, uint8 g, uint8 b); -RGB MkRGB(uint8 r, uint8 g, uint8 b); +DAC MkDAC(uint8 r, uint8 g, uint8 b); +Rgb MkRGB(uint8 r, uint8 g, uint8 b); template @@ -331,12 +335,12 @@ uint8 Closest(CBLK *pal, CBLK x) { -char *NumStr(char *str, int num); +char *NumStr(char *str, int num); //static void Video (void); -uint16 *SaveScreen(void); -void RestoreScreen(uint16 * &sav); -SPRITE *SpriteAt(int x, int y); -SPRITE *Locate(int ref); +uint16 *SaveScreen(void); +void RestoreScreen(uint16 * &sav); +Sprite *SpriteAt(int x, int y); +Sprite *Locate(int ref); extern bool SpeedTest; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 7db5a79f85..ed335191aa 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -130,7 +130,7 @@ void VMENU::Touch(uint16 mask, int x, int y) { bool ok = false; if (Items) { - SPRITE::Touch(mask, x, y); + Sprite::Touch(mask, x, y); y -= TEXT_VM - 1; int n = 0; -- cgit v1.2.3 From e1b6bc042752f2a07a6cb0911d11bf52ed26d9a8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 29 Jun 2011 21:17:07 +1000 Subject: CGE: Removed Mouse from VGA::ShowQ to prevent crashes in the movie player --- engines/cge/cge_main.cpp | 20 ++++++++++++++++---- engines/cge/vga13h.cpp | 4 +++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index ece6ec5adb..2066376885 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -25,6 +25,7 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ +#include "common/scummsys.h" #include "cge/general.h" #include "cge/boot.h" #include "cge/ident.h" @@ -1463,8 +1464,12 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int _sprite->Flags.Tran = tran; _sprite->Flags.Kill = true; _sprite->Flags.BDel = true; - //fnsplit(fname, NULL, NULL, _sprite->File, NULL); - warning("LoadSprite: use of fnsplit"); + + // Extract the filename, without the extension + strcpy(_sprite->File, fname); + char *p = strchr(_sprite->File, '.'); + if (p) + *p = '\0'; _sprite->ShpCnt = shpcnt; Vga->SpareQ->Append(_sprite); @@ -1551,6 +1556,9 @@ void CGEEngine::MainLoop() { Vga->Show(); Snail_->RunCom(); Snail->RunCom(); + + // Delay to slow things down + g_system->delayMillis(10); } @@ -1599,7 +1607,8 @@ void CGEEngine::RunGame() { Vga->ShowQ->Append(_pocLight); SelectPocket(-1); - Vga->ShowQ->Append(Mouse); + // FIXME: Allow ScummVM to handle mouse display +// Vga->ShowQ->Append(Mouse); // ___________ LoadUser(); @@ -1692,7 +1701,10 @@ void CGEEngine::Movie(const char *ext) { LoadScript(fn); ExpandSprite(Vga->SpareQ->Locate(999)); FeedSnail(Vga->ShowQ->Locate(999), TAKE); - Vga->ShowQ->Append(Mouse); + + // FIXME: Allow ScummVM to handle mouse display + //Vga->ShowQ->Append(Mouse); + _heart->_enable = true; KEYBOARD::SetClient(Sys); while (!Snail->Idle()) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 1d55af7e31..e642db8e7f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1310,7 +1310,8 @@ void BITMAP::Show(int x, int y) { ++srcP; } } - +/* + DEBUG code to display image immediately // Temporary g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); byte palData[PAL_SIZ]; @@ -1319,6 +1320,7 @@ void BITMAP::Show(int x, int y) { g_system->updateScreen(); g_system->delayMillis(5000); +*/ } -- cgit v1.2.3 From 91dc5f424aa474001ac85d600cd22aff54e317c4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Jun 2011 09:57:16 +0200 Subject: CGE: Misc cleanup (provided by Digitall) --- engines/cge/bitmap.cpp | 5 +++++ engines/cge/cge_main.cpp | 14 ++++++-------- engines/cge/config.cpp | 13 ------------- engines/cge/detection.cpp | 33 +++++++-------------------------- engines/cge/ems.cpp | 3 +-- engines/cge/general.cpp | 4 ++-- engines/cge/keybd.cpp | 2 +- engines/cge/snail.cpp | 4 +++- engines/cge/talk.cpp | 6 +++--- engines/cge/vga13h.cpp | 28 ++++++++++++---------------- engines/cge/vga13h.h | 2 +- 11 files changed, 41 insertions(+), 73 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 10fc9a4df6..9f19e91b1f 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -140,6 +140,8 @@ BITMAP::~BITMAP(void) { case FAR_MEM : free(V); default: + warning("Unhandled MemType in Bitmap destructor"); + break; break; } } @@ -193,6 +195,9 @@ BMP_PTR BITMAP::Code(void) { case FAR_MEM : free(V); break; + default: + warning("Unhandled MemType in Bitmap::Code()"); + break; } V = NULL; } diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 2066376885..e5294c0c14 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -262,7 +262,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { file.Read((uint8 *) &i, sizeof(i)); if (i != SVGCHKSUM) - error(Text->getText(BADSVG_TEXT)); + error("%s", Text->getText(BADSVG_TEXT)); if (STARTUP::Core < CORE_HIG) Music = false; @@ -357,6 +357,7 @@ static void TooFar(void) { } +// Used in stubbed function, do not remove! static void NoWay(void) { Trouble(NO_WAY, NO_WAY_TEXT); } @@ -582,15 +583,12 @@ void CGEEngine::SetMapBrick(int x, int z) { } } -//static void SwitchMapping(void); static void SwitchColorMode(void); -//static void StartCountDown(void); static void SwitchDebug(void); static void SwitchMusic(void); static void KillSprite(void); static void PushSprite(void); static void PullSprite(void); -static void BackPaint(void); static void NextStep(void); static void SaveMapping(void); @@ -631,7 +629,7 @@ static void AltCtrlDel(void) { SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero); } - +// Used in stubbed function, do not remove! static void MiniStep(int stp) { if (stp < 0) _miniCave->Flags.Hide = true; @@ -1357,7 +1355,7 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int continue; if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) - error("%s [%s]", NumStr("Bad line ######", lcnt), fname); + error("%s [%s]", NumStr("Bad line ######", lcnt), (const char *)fname); switch (i) { @@ -1365,7 +1363,7 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int break; case 1 : // Type if ((type = TakeEnum(Type, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad line ######", lcnt), fname); + error("%s [%s]", NumStr("Bad line ######", lcnt), (const char *)fname); break; case 2 : // Phase ++ shpcnt; @@ -1541,7 +1539,7 @@ void CGEEngine::MainLoop() { SayDebug(); if (_isDemo) { - static uint32 tc = 0; +// static uint32 tc = 0; if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ Talk == NULL && Snail->Idle()) { if (Text->getText(DemoText)) { SNPOST(SNSOUND, -1, 4, NULL); // drumla diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 4aa4f40c8a..a9d55957af 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -59,19 +59,6 @@ namespace CGE { #define DETECT 0xFFFF -static void NONE(void); -static void SB(void); -static void SBM(void); -static void GUS(void); -static void GUSM(void); -static void MIDI(void); -static void AUTO(void); -static void SetPortD(void); -static void SetPortM(void); -static void SetIRQ(void); -static void SetDMA(void); - - static int DevName[] = { NONE_TEXT, SB_TEXT, SBM_TEXT, GUS_TEXT, GUSM_TEXT, MIDI_TEXT, AUTO_TEXT diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index f03a42fb35..31bf629fcf 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -85,34 +85,15 @@ static const ADFileBasedFallback fileBasedFallback[] = { } // End of namespace CGE -static const ADParams detectionParams = { - // Pointer to ADGameDescription or its superset structure - (const byte *)CGE::gameDescriptions, - // Size of that superset structure - sizeof(ADGameDescription), - // Number of bytes to compute MD5 sum for - 5000, - // List of all engine targets - CGEGames, - // Structure for autoupgrading obsolete targets - 0, - // Name of single gameid (optional) - "Soltys", - // List of files for file-based fallback detection (optional) - CGE::fileBasedFallback, - // Flags - 0, - // Additional GUI options (for every game} - Common::GUIO_NONE, - // Maximum directory depth - 0, - // List of directory globs - NULL -}; - class CGEMetaEngine : public AdvancedMetaEngine { public: - CGEMetaEngine() : AdvancedMetaEngine(detectionParams) {} + CGEMetaEngine() : AdvancedMetaEngine(CGE::gameDescriptions, sizeof(ADGameDescription), CGEGames) { + _singleid = "Soltys"; + } + + virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { + return detectGameFilebased(allFiles, CGE::fileBasedFallback); + } virtual const char *getName() const { return "CGE"; diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index f1f7ece708..56d853f4e8 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -83,7 +83,7 @@ EMM::EMM(long size): Han(-1), Top(0), Lim(0), List(NULL) { EMM::~EMM(void) { - /* + /* FIXME Release(); if (Han >= 0) { @@ -94,7 +94,6 @@ EMM::~EMM(void) { asm int EMS_INT } */ - warning("STUB: EMM::~EMM"); } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 428498923e..7bf753ff9f 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -304,7 +304,7 @@ EC void SNDInit() { } EC void SNDDone() { - warning("STUB: SNDDone"); + // FIXME: STUB: SNDDone } EC void SNDSetVolume() { @@ -324,7 +324,7 @@ EC void SNDMIDIStart(uint8 *MIDFile) { } EC void SNDMIDIStop() { - warning("STUB: SNDMIDIStop"); + // FIXME: STUB: SNDMIDIStop } DATACK *LoadWave(XFILE *file, EMM *emm) { diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index 4aee394e07..8530815b16 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -74,7 +74,7 @@ KEYBOARD::~KEYBOARD(void) { /* TODO replace totally by scummvm handling setvect(KEYBD_INT, OldKeyboard); */ - warning("STUB: KEYBOARD::~KEYBOARD"); + // FIXME: STUB: KEYBOARD::~KEYBOARD } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 1cb53d2024..50eed3f562 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -819,7 +819,6 @@ static void SNLevel(Sprite *spr, int lev) { static int maxcav[] = { 1, 8, 16, 23, 24 }; #endif while (Lev < lev) { - Sprite *spr; ++Lev; spr = Vga->SpareQ->Locate(100 + Lev); if (spr) { @@ -1114,6 +1113,9 @@ void SNAIL::RunCom(void) { case SNGHOST : SNGhost((BITMAP *) snc->Ptr); break; + default : + warning("Unhandled snc->Com in SNMouse(bool)"); + break; } ++Tail; if (!Turbo) diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 544359897f..43917732be 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -167,14 +167,14 @@ void TALK::Update(const char *tx) { int cw = _Font->Wid[*tx], i; uint8 *f = _Font->Map + _Font->Pos[*tx]; for (i = 0; i < cw; i++) { - uint8 *p = m; + uint8 *pp = m; uint16 n; register uint16 b = *(f++); for (n = 0; n < FONT_HIG; n++) { if (b & 1) - *p = TEXT_FG; + *pp = TEXT_FG; b >>= 1; - p += mw; + pp += mw; } ++m; } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e642db8e7f..56960389c8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -41,12 +41,8 @@ namespace CGE { -#define FADE_STEP 2 -#define TMR_DIV ((0x8000/TMR_RATE)*2) - -//-------------------------------------------------------------------------- - -static char Report[] = "NearHeap=..... FarHeap=......\n"; +#define FADE_STEP 2 +#define TMR_DIV ((0x8000/TMR_RATE)*2) #define NREP 9 #define FREP 24 @@ -64,10 +60,9 @@ static VgaRegBlk VideoMode[] = { // { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end // { 0x15, VGACRT, 0xFF, 0x7F }, // start vb // { 0x10, VGACRT, 0xFF, 0x94 }, // start vr - { 0x00 } + { 0x00, 0x00, 0x00, 0x00 } }; - bool SpeedTest = false; Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; @@ -82,8 +77,8 @@ char *NumStr(char *str, int num) { } -static void Video() { /* +static void Video() { static uint16 SP_S; asm push bx @@ -100,9 +95,8 @@ static void Video() { asm pop si asm pop bp asm pop bx -*/ - warning("STUB: Video"); } +*/ uint16 *SaveScreen(void) { @@ -562,7 +556,7 @@ Sprite *Sprite::Expand(void) { else { SNAIL::COM *c = &nea[neacnt++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); + error("%s [%s]", (const char*)NumStr("Bad NEAR in ######", lcnt), (const char*)fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); c->Ptr = NULL; @@ -578,7 +572,7 @@ Sprite *Sprite::Expand(void) { else { SNAIL::COM *c = &tak[takcnt++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), (const char *)fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); c->Ptr = NULL; @@ -701,6 +695,9 @@ void Sprite::KillXlat(void) { case FAR_MEM : free(m); break; + default: + warning("Unhandled MemType in Sprite::KillXlat()"); + break; } for (b = _ext->_shpList; *b; b++) (*b)->M = NULL; @@ -942,8 +939,7 @@ VGA::VGA(int mode) for (i = 10; i < 20; i++) { char *txt = Text->getText(i); if (txt) { -// puts(txt); - warning(txt); + warning("%s", txt); std = false; } } @@ -986,7 +982,7 @@ VGA::~VGA(void) { if (Nam) buffer = buffer + " [" + Nam + "]"; - warning(buffer.c_str()); + warning("%s", buffer.c_str()); } } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index af1c981aa8..77594217ab 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -344,6 +344,6 @@ Sprite *Locate(int ref); extern bool SpeedTest; -} // End if namespace CGE +} // End of namespace CGE #endif -- cgit v1.2.3 From f2f3124246a77036f843dee2d83ad28084234ebc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Jun 2011 16:13:17 +0200 Subject: CGE: Some more renaming (wip) --- engines/cge/bitmap.cpp | 220 ++++++++++++++++++++++---------------------- engines/cge/bitmap.h | 29 +++--- engines/cge/bitmaps.h | 12 +-- engines/cge/cge.cpp | 26 +++--- engines/cge/cge_main.cpp | 231 ++++++++++++++++++++++++----------------------- engines/cge/config.cpp | 8 +- engines/cge/game.cpp | 12 +-- engines/cge/game.h | 2 +- engines/cge/gettext.cpp | 8 +- engines/cge/mixer.cpp | 38 ++++---- engines/cge/mouse.cpp | 48 +++++----- engines/cge/mouse.h | 13 +-- engines/cge/snail.cpp | 135 +++++++++++++-------------- engines/cge/snail.h | 4 +- engines/cge/talk.cpp | 30 +++--- engines/cge/talk.h | 4 +- engines/cge/text.cpp | 34 +++---- engines/cge/vga13h.cpp | 190 +++++++++++++++++++------------------- engines/cge/vga13h.h | 57 ++++++------ engines/cge/vmenu.cpp | 30 +++--- 20 files changed, 569 insertions(+), 562 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 9f19e91b1f..ab5c1ff3c7 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -35,18 +35,18 @@ namespace CGE { -DAC *BITMAP::Pal = NULL; +DAC *Bitmap::Pal = NULL; #define MAXPATH 128 -void BITMAP::init() { +void Bitmap::init() { Pal = NULL; } -void BITMAP::deinit() { +void Bitmap::deinit() { } #pragma argsused -BITMAP::BITMAP(const char *fname, bool rem) : M(NULL), V(NULL) { +Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { char pat[MAXPATH]; ForceExt(pat, fname, ".VBM"); @@ -65,8 +65,8 @@ BITMAP::BITMAP(const char *fname, bool rem) : M(NULL), V(NULL) { if (BMPLoad(&file)) { Code(); if (rem) { - free(M); - M = NULL; + free(_m); + _m = NULL; } } else error("Bad BMP [%s]", fname); @@ -78,7 +78,7 @@ BITMAP::BITMAP(const char *fname, bool rem) : M(NULL), V(NULL) { } -BITMAP::BITMAP(uint16 w, uint16 h, uint8 *map) : W(w), H(h), M(map), V(NULL) { +Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL) { if (map) Code(); } @@ -87,14 +87,14 @@ BITMAP::BITMAP(uint16 w, uint16 h, uint8 *map) : W(w), H(h), M(map), V(NULL) { // following routine creates filled rectangle // immediately as VGA video chunks, in near memory as fast as possible, // especially for text line real time display -BITMAP::BITMAP(uint16 w, uint16 h, uint8 fill) - : W((w + 3) & ~3), // only full uint32 allowed! - H(h), - M(NULL) { - uint16 dsiz = W >> 2; // data size (1 plane line size) +Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) + : _w((w + 3) & ~3), // only full uint32 allowed! + _h(h), + _m(NULL) { + uint16 dsiz = _w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap - uint16 psiz = H * lsiz; // - last gape, but + plane trailer - uint8 *v = new uint8[4 * psiz + H * sizeof(*B)];// the same for 4 planes + uint16 psiz = _h * lsiz; // - last gape, but + plane trailer + uint8 *v = new uint8[4 * psiz + _h * sizeof(*_b)];// the same for 4 planes // + room for wash table if (v == NULL) error("No core"); @@ -106,39 +106,39 @@ BITMAP::BITMAP(uint16 w, uint16 h, uint8 fill) *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes HideDesc *b = (HideDesc *)(v + 4 * psiz); - b->skip = (SCR_WID - W) >> 2; - b->hide = W >> 2; - memcpy(b + 1, b, (H - 1) * sizeof(*b)); // tricky fill entire table + b->skip = (SCR_WID - _w) >> 2; + b->hide = _w >> 2; + memcpy(b + 1, b, (_h - 1) * sizeof(*b)); // tricky fill entire table b->skip = 0; // fix the first entry - V = v; - B = b; + _v = v; + _b = b; } -BITMAP::BITMAP(const BITMAP &bmp) : W(bmp.W), H(bmp.H), M(NULL), V(NULL) { - uint8 *v0 = bmp.V; +Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL) { + uint8 *v0 = bmp._v; if (v0) { - uint16 vsiz = (uint8 *)(bmp.B) - (uint8 *)(v0); - uint16 siz = vsiz + H * sizeof(HideDesc); + uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); + uint16 siz = vsiz + _h * sizeof(HideDesc); uint8 *v1 = farnew(uint8, siz); if (v1 == NULL) error("No core"); memcpy(v1, v0, siz); - B = (HideDesc *)((V = v1) + vsiz); + _b = (HideDesc *)((_v = v1) + vsiz); } } -BITMAP::~BITMAP(void) { - if (MemType(M) == FAR_MEM) - free(M); +Bitmap::~Bitmap(void) { + if (MemType(_m) == FAR_MEM) + free(_m); - switch (MemType(V)) { + switch (MemType(_v)) { case NEAR_MEM : - delete[](uint8 *) V; + delete[](uint8 *) _v; break; case FAR_MEM : - free(V); + free(_v); default: warning("Unhandled MemType in Bitmap destructor"); break; @@ -147,92 +147,92 @@ BITMAP::~BITMAP(void) { } -BITMAP &BITMAP::operator = (const BITMAP &bmp) { - uint8 *v0 = bmp.V; - W = bmp.W; - H = bmp.H; - M = NULL; - if (MemType(V) == FAR_MEM) - free(V); +Bitmap &Bitmap::operator = (const Bitmap &bmp) { + uint8 *v0 = bmp._v; + _w = bmp._w; + _h = bmp._h; + _m = NULL; + if (MemType(_v) == FAR_MEM) + free(_v); if (v0 == NULL) - V = NULL; + _v = NULL; else { - uint16 vsiz = (uint8 *)bmp.B - (uint8 *)v0; - uint16 siz = vsiz + H * sizeof(HideDesc); + uint16 vsiz = (uint8 *)bmp._b - (uint8 *)v0; + uint16 siz = vsiz + _h * sizeof(HideDesc); uint8 *v1 = farnew(uint8, siz); if (v1 == NULL) error("No core"); memcpy(v1, v0, siz); - B = (HideDesc *)((V = v1) + vsiz); + _b = (HideDesc *)((_v = v1) + vsiz); } return *this; } -uint16 BITMAP::MoveVmap(uint8 *buf) { - if (V) { - uint16 vsiz = (uint8 *)B - (uint8 *)V; - uint16 siz = vsiz + H * sizeof(HideDesc); - memcpy(buf, V, siz); - if (MemType(V) == FAR_MEM) - free(V); - B = (HideDesc *)((V = buf) + vsiz); +uint16 Bitmap::MoveVmap(uint8 *buf) { + if (_v) { + uint16 vsiz = (uint8 *)_b - (uint8 *)_v; + uint16 siz = vsiz + _h * sizeof(HideDesc); + memcpy(buf, _v, siz); + if (MemType(_v) == FAR_MEM) + free(_v); + _b = (HideDesc *)((_v = buf) + vsiz); return siz; } return 0; } -BMP_PTR BITMAP::Code(void) { - if (M) { +BMP_PTR Bitmap::Code(void) { + if (_m) { uint16 i, cnt; - if (V) { // old X-map exists, so remove it - switch (MemType(V)) { + if (_v) { // old X-map exists, so remove it + switch (MemType(_v)) { case NEAR_MEM : - delete[](uint8 *) V; + delete[](uint8 *) _v; break; case FAR_MEM : - free(V); + free(_v); break; default: warning("Unhandled MemType in Bitmap::Code()"); break; } - V = NULL; + _v = NULL; } while (true) { // at most 2 times: for (V == NULL) & for allocated block; - uint8 *im = V + 2; - uint16 *cp = (uint16 *) V; + uint8 *im = _v + 2; + uint16 *cp = (uint16 *) _v; int bpl; - if (V) { // 2nd pass - fill the hide table - for (i = 0; i < H; i++) { - B[i].skip = 0xFFFF; - B[i].hide = 0x0000; + if (_v) { // 2nd pass - fill the hide table + for (i = 0; i < _h; i++) { + _b[i].skip = 0xFFFF; + _b[i].hide = 0x0000; } } for (bpl = 0; bpl < 4; bpl++) { // once per each bitplane - uint8 *bm = M; + uint8 *bm = _m; bool skip = (bm[bpl] == TRANS); uint16 j; cnt = 0; - for (i = 0; i < H; i++) { // once per each line + for (i = 0; i < _h; i++) { // once per each line uint8 pix; - for (j = bpl; j < W; j += 4) { + for (j = bpl; j < _w; j += 4) { pix = bm[j]; - if (V && pix != TRANS) { - if (j < B[i].skip) - B[i].skip = j; + if (_v && pix != TRANS) { + if (j < _b[i].skip) + _b[i].skip = j; - if (j >= B[i].hide) - B[i].hide = j + 1; + if (j >= _b[i].hide) + _b[i].hide = j + 1; } if ((pix == TRANS) != skip || cnt >= 0x3FF0) { // end of block cnt |= (skip) ? SKP : CPY; - if (V) + if (_v) *cp = cnt; // store block description uint16 cp = (uint16 *) im; @@ -241,20 +241,20 @@ BMP_PTR BITMAP::Code(void) { cnt = 0; } if (! skip) { - if (V) + if (_v) *im = pix; ++ im; } ++ cnt; } - bm += W; - if (W < SCR_WID) { + bm += _w; + if (_w < SCR_WID) { if (skip) { cnt += (SCR_WID - j + 3) / 4; } else { cnt |= CPY; - if (V) + if (_v) *cp = cnt; cp = (uint16 *) im; @@ -266,37 +266,37 @@ BMP_PTR BITMAP::Code(void) { } if (cnt && ! skip) { cnt |= CPY; - if (V) + if (_v) *cp = cnt; cp = (uint16 *) im; im += 2; } - if (V) + if (_v) *cp = EOI; cp = (uint16 *) im; im += 2; } - if (V) + if (_v) break; - uint16 sizV = (uint16)(im - 2 - V); - V = farnew(uint8, sizV + H * sizeof(*B)); - if (! V) + uint16 sizV = (uint16)(im - 2 - _v); + _v = farnew(uint8, sizV + _h * sizeof(*_b)); + if (!_v) error("No core"); - B = (HideDesc *)(V + sizV); + _b = (HideDesc *)(_v + sizV); } cnt = 0; - for (i = 0; i < H; i++) { - if (B[i].skip == 0xFFFF) { // whole line is skipped - B[i].skip = (cnt + SCR_WID) >> 2; + for (i = 0; i < _h; i++) { + if (_b[i].skip == 0xFFFF) { // whole line is skipped + _b[i].skip = (cnt + SCR_WID) >> 2; cnt = 0; } else { - uint16 s = B[i].skip & ~3; - uint16 h = (B[i].hide + 3) & ~3; - B[i].skip = (cnt + s) >> 2; - B[i].hide = (h - s) >> 2; + uint16 s = _b[i].skip & ~3; + uint16 h = (_b[i].hide + 3) & ~3; + _b[i].skip = (cnt + s) >> 2; + _b[i].hide = (h - s) >> 2; cnt = SCR_WID - h; } } @@ -305,14 +305,14 @@ BMP_PTR BITMAP::Code(void) { } -bool BITMAP::SolidAt(int x, int y) { +bool Bitmap::SolidAt(int x, int y) { uint8 *m; uint16 r, n, n0; - if ((x >= W) || (y >= H)) + if ((x >= _w) || (y >= _h)) return false; - m = V; + m = _v; r = x % 4; n0 = (SCR_WID * y + x) / 4, n = 0; @@ -326,7 +326,7 @@ bool BITMAP::SolidAt(int x, int y) { switch (t) { case EOI : - -- r; + r--; case SKP : w = 0; break; @@ -366,9 +366,9 @@ bool BITMAP::SolidAt(int x, int y) { } -bool BITMAP::VBMSave(XFILE *f) { +bool Bitmap::VBMSave(XFILE *f) { uint16 p = (Pal != NULL), - n = ((uint16)(((uint8 *)B) - V)) + H * sizeof(HideDesc); + n = ((uint16)(((uint8 *)_b) - _v)) + _h * sizeof(HideDesc); if (f->Error == 0) f->Write((uint8 *)&p, sizeof(p)); @@ -376,23 +376,23 @@ bool BITMAP::VBMSave(XFILE *f) { f->Write((uint8 *)&n, sizeof(n)); if (f->Error == 0) - f->Write((uint8 *)&W, sizeof(W)); + f->Write((uint8 *)&_w, sizeof(_w)); if (f->Error == 0) - f->Write((uint8 *)&H, sizeof(H)); + f->Write((uint8 *)&_h, sizeof(_h)); if (f->Error == 0) if (p) f->Write((uint8 *)Pal, 256 * 3); if (f->Error == 0) - f->Write(V, n); + f->Write(_v, n); return (f->Error == 0); } -bool BITMAP::VBMLoad(XFILE *f) { +bool Bitmap::VBMLoad(XFILE *f) { uint16 p = 0, n = 0; if (f->Error == 0) f->Read((uint8 *)&p, sizeof(p)); @@ -401,10 +401,10 @@ bool BITMAP::VBMLoad(XFILE *f) { f->Read((uint8 *)&n, sizeof(n)); if (f->Error == 0) - f->Read((uint8 *)&W, sizeof(W)); + f->Read((uint8 *)&_w, sizeof(_w)); if (f->Error == 0) - f->Read((uint8 *)&H, sizeof(H)); + f->Read((uint8 *)&_h, sizeof(_h)); if (f->Error == 0) { if (p) { @@ -416,17 +416,17 @@ bool BITMAP::VBMLoad(XFILE *f) { f->Seek(f->Mark() + PAL_SIZ); } } - if ((V = farnew(uint8, n)) == NULL) + if ((_v = farnew(uint8, n)) == NULL) return false; if (f->Error == 0) - f->Read(V, n); + f->Read(_v, n); - B = (HideDesc *)(V + n - H * sizeof(HideDesc)); + _b = (HideDesc *)(_v + n - _h * sizeof(HideDesc)); return (f->Error == 0); } -bool BITMAP::BMPLoad (XFILE * f) { +bool Bitmap::BMPLoad (XFILE * f) { struct { char BM[2]; union { int16 len; int32 len_; }; @@ -459,13 +459,13 @@ bool BITMAP::BMPLoad (XFILE * f) { } Pal = NULL; } - H = hea.hig; - W = hea.wid; - if ((M = farnew(byte, H * W)) != NULL) { + _h = hea.hig; + _w = hea.wid; + if ((_m = farnew(byte, _h * _w)) != NULL) { int16 r = (4 - (hea.wid & 3)) % 4; byte buf[3]; int i; - for (i = H-1; i >= 0; i --) { - f->Read(M + (W * i), W); + for (i = _h - 1; i >= 0; i--) { + f->Read(_m + (_w * i), _w); if (r && f->Error == 0) f->Read(buf, r); if (f->Error) diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index e114760e2a..cfa7830f39 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -59,25 +59,28 @@ struct HideDesc { #include "common/pack-end.h" -class BITMAP { +class Bitmap { bool BMPLoad(XFILE *f); bool VBMLoad(XFILE *f); public: static DAC *Pal; - uint16 W, H; - uint8 *M, * V; - HideDesc *B; - BITMAP(const char *fname, bool rem = true); - BITMAP(uint16 w, uint16 h, uint8 *map); - BITMAP(uint16 w, uint16 h, uint8 fill); - BITMAP(const BITMAP &bmp); - ~BITMAP(void); + uint16 _w; + uint16 _h; + uint8 *_m; + uint8 *_v; + HideDesc *_b; + + Bitmap(const char *fname, bool rem = true); + Bitmap(uint16 w, uint16 h, uint8 *map); + Bitmap(uint16 w, uint16 h, uint8 fill); + Bitmap(const Bitmap &bmp); + ~Bitmap(void); static void init(); static void deinit(); - BITMAP *FlipH(void); - BITMAP *Code(); - BITMAP &operator = (const BITMAP &bmp); + Bitmap *FlipH(void); + Bitmap *Code(); + Bitmap &operator = (const Bitmap &bmp); void Hide(int x, int y); void Show(int x, int y); void XShow(int x, int y); @@ -87,7 +90,7 @@ public: }; -typedef BITMAP *BMP_PTR; +typedef Bitmap *BMP_PTR; } // End of namespace CGE diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h index 5ac878de3c..40b1158b21 100644 --- a/engines/cge/bitmaps.h +++ b/engines/cge/bitmaps.h @@ -32,12 +32,12 @@ namespace CGE { -extern BITMAP *MB[]; -extern BITMAP *HL[]; -extern BITMAP *MC[]; -extern BITMAP *PR[]; -extern BITMAP *SP[]; -extern BITMAP *LI[]; +extern Bitmap *MB[]; +extern Bitmap *HL[]; +extern Bitmap *MC[]; +extern Bitmap *PR[]; +extern Bitmap *SP[]; +extern Bitmap *LI[]; } // End of namespace CGE diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 07638ebdd8..885aa4d492 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -57,7 +57,7 @@ void CGEEngine::setup() { // Initialise classes that have static members VGA::init(); VFILE::init(); - BITMAP::init(); + Bitmap::init(); TALK::init(); // Initialise engine objects @@ -77,22 +77,22 @@ void CGEEngine::setup() { InfoLine = new INFO_LINE(this, INFO_W); _cavLight = new Sprite(this, PR); DebugLine = new INFO_LINE(this, SCR_WID); - MB[0] = new BITMAP("BRICK"); + MB[0] = new Bitmap("BRICK"); MB[1] = NULL; - HL[0] = new BITMAP("HLINE"); + HL[0] = new Bitmap("HLINE"); HL[1] = NULL; - MC[0] = new BITMAP("MOUSE"); - MC[1] = new BITMAP("DUMMY"); + MC[0] = new Bitmap("MOUSE"); + MC[1] = new Bitmap("DUMMY"); MC[2] = NULL; - PR[0] = new BITMAP("PRESS"); + PR[0] = new Bitmap("PRESS"); PR[1] = NULL; - SP[0] = new BITMAP("SPK_L"); - SP[1] = new BITMAP("SPK_R"); + SP[0] = new Bitmap("SPK_L"); + SP[1] = new Bitmap("SPK_R"); SP[2] = NULL; - LI[0] = new BITMAP("LITE0"); - LI[1] = new BITMAP("LITE1"); - LI[2] = new BITMAP("LITE2"); - LI[3] = new BITMAP("LITE3"); + LI[0] = new Bitmap("LITE0"); + LI[1] = new Bitmap("LITE1"); + LI[2] = new Bitmap("LITE2"); + LI[3] = new Bitmap("LITE3"); LI[4] = NULL; Snail = new SNAIL(this, false); Snail_ = new SNAIL(this, true); @@ -105,7 +105,7 @@ CGEEngine::~CGEEngine() { // Call classes with static members to clear them up TALK::deinit(); - BITMAP::deinit(); + Bitmap::deinit(); VFILE::deinit(); VGA::deinit(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index e5294c0c14..1e1b952f77 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -281,7 +281,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { if (n != sizeof(S)) break; - S.Prev = S.Next = NULL; + S._prev = S._next = NULL; spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(this, NULL) : new Sprite(this, NULL); if (spr == NULL) @@ -325,7 +325,7 @@ static void SaveGame(XFILE &file) { file.Write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); - for (spr = Vga->SpareQ->First(); spr; spr = spr->Next) + for (spr = Vga->SpareQ->First(); spr; spr = spr->_next) if (spr->_ref >= 1000) if (!file.Error) file.Write((uint8 *)spr, sizeof(*spr)); @@ -393,29 +393,31 @@ WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) void WALK::Tick(void) { - if (Flags.Hide) + if (_flags._hide) return; - Here = XZ(X + W / 2, Y + H); + Here = XZ(_x + _w / 2, _y + _h); if (Dir != NO_DIR) { Sprite *spr; Sys->FunTouch(); - for (spr = Vga->ShowQ->First(); spr; spr = spr->Next) { - if (Distance(spr) < 2) { - if (! spr->Flags.Near) { + for (spr = Vga->ShowQ->First(); spr; spr = spr->_next) { + if (Distance(spr) < 2) { + if (!spr->_flags._near) { FeedSnail(spr, NEAR); - spr->Flags.Near = true; + spr->_flags._near = true; } - } else spr->Flags.Near = false; + } else { + spr->_flags._near = false; + } } } - if (Flags.Hold || TracePtr < 0) + if (_flags._hold || TracePtr < 0) Park(); else { if (Here == Trace[TracePtr]) { - if (-- TracePtr < 0) + if (--TracePtr < 0) Park(); } else { signed char dx, dz; @@ -425,13 +427,13 @@ void WALK::Tick(void) { } } Step(); - if ((Dir == WW && X <= 0) || - (Dir == EE && X + W >= SCR_WID) || - (Dir == SS && Y + W >= WORLD_HIG - 2)) + if ((Dir == WW && _x <= 0) || + (Dir == EE && _x + _w >= SCR_WID) || + (Dir == SS && _y + _w >= WORLD_HIG - 2)) Park(); else { signed char x; // dummy var - Here.Split(x, Z); // take current Z position + Here.Split(x, _z); // take current Z position SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue } } @@ -439,15 +441,15 @@ void WALK::Tick(void) { int WALK::Distance(Sprite *spr) { int dx, dz; - dx = spr->X - (X + W - WALKSIDE); + dx = spr->_x - (_x + _w - WALKSIDE); if (dx < 0) - dx = (X + WALKSIDE) - (spr->X + spr->W); + dx = (_x + WALKSIDE) - (spr->_x + spr->_w); if (dx < 0) dx = 0; dx /= MAP_XGRID; - dz = spr->Z - Z; + dz = spr->_z - _z; if (dz < 0) dz = - dz; @@ -469,8 +471,8 @@ void WALK::Turn(DIR d) { void WALK::Park(void) { - if (Time == 0) - ++Time; + if (_time == 0) + ++_time; if (Dir != NO_DIR) { Step(9 + 4 * Dir + Dir); @@ -507,11 +509,12 @@ void WALK::FindWay(CLUSTER c) { void WALK::FindWay(Sprite *spr) { if (spr && spr != this) { - int x = spr->X, z = spr->Z; - if (spr->Flags.East) - x += spr->W + W / 2 - WALKSIDE; + int x = spr->_x; + int z = spr->_z; + if (spr->_flags._east) + x += spr->_w + _w / 2 - WALKSIDE; else - x -= W / 2 - WALKSIDE; + x -= _w / 2 - WALKSIDE; FindWay(CLUSTER((x / MAP_XGRID), ((z < MAP_ZCNT - MAX_DISTANCE) ? (z + 1) : (z - 1)))); @@ -520,7 +523,7 @@ void WALK::FindWay(Sprite *spr) { bool WALK::Lower(Sprite *spr) { - return (spr->Y > Y + (H * 3) / 5); + return (spr->_y > _y + (_h * 3) / 5); } @@ -528,7 +531,7 @@ void WALK::Reach(Sprite *spr, int mode) { if (spr) { Hero->FindWay(spr); if (mode < 0) { - mode = spr->Flags.East; + mode = spr->_flags._east; if (Lower(spr)) mode += 2; } @@ -556,15 +559,15 @@ private: SQUARE::SQUARE(CGEEngine *vm) : Sprite(vm, MB), _vm(vm) { - Flags.Kill = true; - Flags.BDel = false; + _flags._kill = true; + _flags._bDel = false; } void SQUARE::Touch(uint16 mask, int x, int y) { Sprite::Touch(mask, x, y); if (mask & L_UP) { - XZ(X + x, Y + y).Cell() = 0; + XZ(_x + x, _y + y).Cell() = 0; SNPOST_(SNKILL, -1, 0, this); } } @@ -610,7 +613,7 @@ void CGEEngine::Quit() { { NULL, &CGEEngine::dummy } }; - if (Snail->Idle() && ! Hero->Flags.Hide) { + if (Snail->Idle() && ! Hero->_flags._hide) { if (VMENU::Addr) { SNPOST_(SNKILL, -1, 0, VMENU::Addr); ResetQSwitch(); @@ -632,14 +635,14 @@ static void AltCtrlDel(void) { // Used in stubbed function, do not remove! static void MiniStep(int stp) { if (stp < 0) - _miniCave->Flags.Hide = true; + _miniCave->_flags._hide = true; else { &*Mini; *MiniShp[0] = *MiniShpList[stp]; if (Fx.Current) &*(Fx.Current->EAddr()); - _miniCave->Flags.Hide = false; + _miniCave->_flags._hide = false; } } @@ -672,9 +675,9 @@ void SYSTEM::FunTouch(void) { static void ShowBak(int ref) { Sprite *spr = Vga->SpareQ->Locate(ref); if (spr) { - BITMAP::Pal = VGA::SysPal; + Bitmap::Pal = VGA::SysPal; spr->Expand(); - BITMAP::Pal = NULL; + Bitmap::Pal = NULL; spr->Show(2); Vga->CopyPage(1, 2); Sys->SetPal(); @@ -693,10 +696,10 @@ static void CaveUp(void) { Text->Preload(BakRef, BakRef + 1000); Sprite *spr = Vga->SpareQ->First(); while (spr) { - Sprite *n = spr->Next; + Sprite *n = spr->_next; if (spr->_cave == Now || spr->_cave == 0) if (spr->_ref != BakRef) { - if (spr->Flags.Back) + if (spr->_flags._back) spr->BackShow(); else ExpandSprite(spr); @@ -711,11 +714,11 @@ static void CaveUp(void) { } if (Hero) { - Hero->Goto(HeroXY[Now - 1].X, HeroXY[Now - 1].Y); + Hero->Goto(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); // following 2 lines trims Hero's Z position! Hero->Tick(); - Hero->Time = 1; - Hero->Flags.Hide = false; + Hero->_time = 1; + Hero->_flags._hide = false; } if (! Dark) @@ -730,7 +733,7 @@ static void CaveUp(void) { Vga->ShowQ->Remove(_shadow); _shadow->MakeXlat(Glass(VGA::SysPal, 204, 204, 204)); Vga->ShowQ->Insert(_shadow, Hero); - _shadow->Z = Hero->Z; + _shadow->_z = Hero->_z; } FeedSnail(Vga->ShowQ->Locate(BakRef + 999), TAKE); Vga->Show(); @@ -747,11 +750,11 @@ static void CaveUp(void) { void CGEEngine::CaveDown() { Sprite *spr; - if (!_horzLine->Flags.Hide) + if (!_horzLine->_flags._hide) SwitchMapping(); for (spr = Vga->ShowQ->First(); spr;) { - Sprite *n = spr->Next; + Sprite *n = spr->_next; if (spr->_ref >= 1000 /*&& spr->_cave*/) { if (spr->_ref % 1000 == 999) FeedSnail(spr, TAKE); @@ -844,7 +847,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { Sprite *m = Vga->ShowQ->Locate(17001); if (m) { m->Step(1); - m->Time = 216; // 3s + m->_time = 216; // 3s } } break; @@ -909,7 +912,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { _sprite->Step(x - '0'); break; case F10 : - if (Snail->Idle() && ! Hero->Flags.Hide) + if (Snail->Idle() && ! Hero->_flags._hide) _vm->StartCountDown(); break; case 'J': @@ -957,7 +960,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (cav && Snail->Idle() && Hero->TracePtr < 0) _vm->SwitchCave(cav); - if (!_horzLine->Flags.Hide) { + if (!_horzLine->_flags._hide) { if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { int8 x1, z1; XZ(x, y).Split(x1, z1); @@ -985,7 +988,7 @@ void SYSTEM::Tick(void) { else if (STARTUP::Core >= CORE_MID) { int n = new_random(100); if (n > 96) - HeroCover(6 + (Hero->X + Hero->W / 2 < SCR_WID / 2)); + HeroCover(6 + (Hero->_x + Hero->_w / 2 < SCR_WID / 2)); else { if (n > 90) HeroCover(5); @@ -1000,7 +1003,7 @@ void SYSTEM::Tick(void) { } FunTouch(); } - Time = SYSTIMERATE; + _time = SYSTIMERATE; } @@ -1070,8 +1073,8 @@ void CGEEngine::TakeName() { if (tn) { tn->SetName(Text->getText(GETNAME_TITLE)); tn->Center(); - tn->Goto(tn->X, tn->Y - 10); - tn->Z = 126; + tn->Goto(tn->_x, tn->_y - 10); + tn->_z = 126; Vga->ShowQ->Insert(tn); } } @@ -1079,7 +1082,7 @@ void CGEEngine::TakeName() { void CGEEngine::SwitchMapping() { - if (_horzLine->Flags.Hide) { + if (_horzLine->_flags._hide) { int i; for (i = 0; i < MAP_ZCNT; i++) { int j; @@ -1090,28 +1093,28 @@ void CGEEngine::SwitchMapping() { } } else { Sprite *s; - for (s = Vga->ShowQ->First(); s; s = s->Next) - if (s->W == MAP_XGRID && s->H == MAP_ZGRID) + for (s = Vga->ShowQ->First(); s; s = s->_next) + if (s->_w == MAP_XGRID && s->_h == MAP_ZGRID) SNPOST_(SNKILL, -1, 0, s); } - _horzLine->Flags.Hide = !_horzLine->Flags.Hide; + _horzLine->_flags._hide = !_horzLine->_flags._hide; } static void KillSprite(void) { - _sprite->Flags.Kill = true; - _sprite->Flags.BDel = true; + _sprite->_flags._kill = true; + _sprite->_flags._bDel = true; SNPOST_(SNKILL, -1, 0, _sprite); _sprite = NULL; } static void PushSprite(void) { - Sprite *spr = _sprite->Prev; + Sprite *spr = _sprite->_prev; if (spr) { Vga->ShowQ->Insert(Vga->ShowQ->Remove(_sprite), spr); - while (_sprite->Z > _sprite->Next->Z) - --_sprite->Z; + while (_sprite->_z > _sprite->_next->_z) + _sprite->_z--; } else SNPOST_(SNSOUND, -1, 2, NULL); } @@ -1119,17 +1122,17 @@ static void PushSprite(void) { static void PullSprite(void) { bool ok = false; - Sprite *spr = _sprite->Next; + Sprite *spr = _sprite->_next; if (spr) { - spr = spr->Next; + spr = spr->_next; if (spr) - ok = (!spr->Flags.Slav); + ok = (!spr->_flags._slav); } if (ok) { Vga->ShowQ->Insert(Vga->ShowQ->Remove(_sprite), spr); - if (_sprite->Prev) - while (_sprite->Z < _sprite->Prev->Z) - ++_sprite->Z; + if (_sprite->_prev) + while (_sprite->_z < _sprite->_prev->_z) + _sprite->_z++; } else SNPOST_(SNSOUND, -1, 2, NULL); } @@ -1151,8 +1154,8 @@ static void SaveMapping(void) { { IOHAND cf(ProgName(".HXY"), WRI); if (!cf.Error) { - HeroXY[Now - 1].X = Hero->X; - HeroXY[Now - 1].Y = Hero->Y; + HeroXY[Now - 1]._x = Hero->_x; + HeroXY[Now - 1]._y = Hero->_y; cf.Write((uint8 *) HeroXY, sizeof(HeroXY)); } } @@ -1180,7 +1183,7 @@ static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 0 #define SP__ (DebugText + 70) static void SayDebug(void) { - if (!DebugLine->Flags.Hide) { + if (!DebugLine->_flags._hide) { static long t = -1L; long t1 = Timer(); @@ -1192,25 +1195,25 @@ static void SayDebug(void) { t = t1; } - dwtom(Mouse->X, ABSX, 10, 3); - dwtom(Mouse->Y, ABSY, 10, 3); + dwtom(Mouse->_x, ABSX, 10, 3); + dwtom(Mouse->_y, ABSY, 10, 3); // dwtom(coreleft(), NFRE, 10, 5); // dwtom(farcoreleft(), FFRE, 10, 6); // sprite queue size uint16 n = 0; Sprite *spr; - for (spr = Vga->ShowQ->First(); spr; spr = spr->Next) { + for (spr = Vga->ShowQ->First(); spr; spr = spr->_next) { ++ n; if (spr == _sprite) { *XSPR = ' '; dwtom(n, SP_N, 10, 2); - dwtom(_sprite->X, SP_X, 10, 3); - dwtom(_sprite->Y, SP_Y, 10, 3); - dwtom(_sprite->Z, SP_Z, 10, 3); - dwtom(_sprite->W, SP_W, 10, 3); - dwtom(_sprite->H, SP_H, 10, 3); - dwtom(*(uint16 *)(&_sprite->Flags), SP_F, 16, 2); + dwtom(_sprite->_x, SP_X, 10, 3); + dwtom(_sprite->_y, SP_Y, 10, 3); + dwtom(_sprite->_z, SP_Z, 10, 3); + dwtom(_sprite->_w, SP_W, 10, 3); + dwtom(_sprite->_h, SP_H, 10, 3); + dwtom(*(uint16 *)(&_sprite->_flags), SP_F, 16, 2); } } dwtom(n, SP_S, 10, 2); @@ -1221,7 +1224,7 @@ static void SayDebug(void) { static void SwitchDebug(void) { - DebugLine->Flags.Hide = ! DebugLine->Flags.Hide; + DebugLine->_flags._hide = ! DebugLine->_flags._hide; } @@ -1259,16 +1262,16 @@ void Sprite::Touch(uint16 mask, int x, int y) { _vm->OptionTouch(_ref % 10, mask); return; } - if (Flags.Syst) + if (_flags._syst) return; // cannot access system sprites if (Game) if (mask & L_UP) { mask &= ~L_UP; mask |= R_UP; } if ((mask & R_UP) && Snail->Idle()) { - Sprite *ps = (_pocLight->SeqPtr) ? _pocket[PocPtr] : NULL; + Sprite *ps = (_pocLight->_seqPtr) ? _pocket[PocPtr] : NULL; if (ps) { - if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) { + if (_flags._kept || Hero->Distance(this) < MAX_DISTANCE) { if (Works(ps)) { FeedSnail(ps, TAKE); } else @@ -1277,18 +1280,18 @@ void Sprite::Touch(uint16 mask, int x, int y) { } else TooFar(); } else { - if (Flags.Kept) + if (_flags._kept) mask |= L_UP; else { if (Hero->Distance(this) < MAX_DISTANCE) { /// - if (Flags.Port) { + if (_flags._port) { if (FindPocket(NULL) < 0) PocFul(); else { SNPOST(SNREACH, -1, -1, this); SNPOST(SNKEEP, -1, -1, this); - Flags.Port = false; + _flags._port = false; } } else { if (TakePtr != NO_PTR) { @@ -1306,7 +1309,7 @@ void Sprite::Touch(uint16 mask, int x, int y) { } } if ((mask & L_UP) && Snail->Idle()) { - if (Flags.Kept) { + if (_flags._kept) { int n; for (n = 0; n < POCKET_NX; n++) { if (_pocket[n] == this) { @@ -1456,12 +1459,12 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int if (_sprite) { _sprite->_ref = ref; _sprite->_cave = cav; - _sprite->Z = pos; - _sprite->Flags.East = east; - _sprite->Flags.Port = port; - _sprite->Flags.Tran = tran; - _sprite->Flags.Kill = true; - _sprite->Flags.BDel = true; + _sprite->_z = pos; + _sprite->_flags._east = east; + _sprite->_flags._port = port; + _sprite->_flags._tran = tran; + _sprite->_flags._kill = true; + _sprite->_flags._bDel = true; // Extract the filename, without the extension strcpy(_sprite->File, fname); @@ -1469,7 +1472,7 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int if (p) *p = '\0'; - _sprite->ShpCnt = shpcnt; + _sprite->_shpCnt = shpcnt; Vga->SpareQ->Append(_sprite); } } @@ -1528,7 +1531,7 @@ void CGEEngine::LoadScript(const char *fname) { _sprite = NULL; LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); if (_sprite && BkG) - _sprite->Flags.Back = true; + _sprite->_flags._back = true; } if (! ok) error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname); @@ -1586,9 +1589,9 @@ void CGEEngine::RunGame() { Text->Preload(100, 1000); LoadHeroXY(); - _cavLight->Flags.Tran = true; + _cavLight->_flags._tran = true; Vga->ShowQ->Append(_cavLight); - _cavLight->Flags.Hide = true; + _cavLight->_flags._hide = true; static Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, { 1, 2, 0, 0, 4 }, @@ -1599,9 +1602,9 @@ void CGEEngine::RunGame() { { 0, 1, 0, 0, 16 }, }; _pocLight->SetSeq(pocSeq); - _pocLight->Flags.Tran = true; - _pocLight->Time = 1; - _pocLight->Z = 120; + _pocLight->_flags._tran = true; + _pocLight->_time = 1; + _pocLight->_z = 120; Vga->ShowQ->Append(_pocLight); SelectPocket(-1); @@ -1626,9 +1629,9 @@ void CGEEngine::RunGame() { LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); ExpandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { - _miniCave->Flags.Hide = true; + _miniCave->_flags._hide = true; _miniCave->MoveShapes(ptr); - MiniShp[0] = new BITMAP(*_miniCave->Shp()); + MiniShp[0] = new Bitmap(*_miniCave->Shp()); MiniShpList = _miniCave->SetShapeList(MiniShp); PostMiniStep(-1); } @@ -1637,28 +1640,28 @@ void CGEEngine::RunGame() { if (Hero) { ExpandSprite(Hero); - Hero->Goto(HeroXY[Now - 1].X, HeroXY[Now - 1].Y); + Hero->Goto(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); if (INI_FILE::Exist("00SHADOW.SPR")) { - LoadSprite("00SHADOW", -1, 0, Hero->X + 14, Hero->Y + 51); + LoadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51); if ((_shadow = _sprite) != NULL) { _shadow->_ref = 2; - _shadow->Flags.Tran = true; - Hero->Flags.Shad = true; + _shadow->_flags._tran = true; + Hero->_flags._shad = true; Vga->ShowQ->Insert(Vga->SpareQ->Remove(_shadow), Hero); } } } InfoLine->Goto(INFO_X, INFO_Y); - InfoLine->Flags.Tran = true; + InfoLine->_flags._tran = true; InfoLine->Update(NULL); Vga->ShowQ->Insert(InfoLine); - DebugLine->Z = 126; + DebugLine->_z = 126; Vga->ShowQ->Insert(DebugLine); - _horzLine->Y = MAP_TOP - (MAP_TOP > 0); - _horzLine->Z = 126; + _horzLine->_y = MAP_TOP - (MAP_TOP > 0); + _horzLine->_z = 126; Vga->ShowQ->Insert(_horzLine); Mouse->Busy = Vga->SpareQ->Locate(BUSY_REF); @@ -1719,14 +1722,14 @@ void CGEEngine::Movie(const char *ext) { bool CGEEngine::ShowTitle(const char *name) { - BITMAP::Pal = VGA::SysPal; - BMP_PTR LB[] = { new BITMAP(name), NULL }; - BITMAP::Pal = NULL; + Bitmap::Pal = VGA::SysPal; + BMP_PTR LB[] = { new Bitmap(name), NULL }; + Bitmap::Pal = NULL; bool usr_ok = false; Sprite D(this, LB); - D.Flags.Kill = true; - D.Flags.BDel = true; + D._flags._kill = true; + D._flags._bDel = true; D.Center(); D.Show(2); @@ -1846,8 +1849,8 @@ void CGEEngine::cge_main(void) { if (!SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; - DebugLine->Flags.Hide = true; - _horzLine->Flags.Hide = true; + DebugLine->_flags._hide = true; + _horzLine->_flags._hide = true; //srand((uint16) Timer()); Sys = new SYSTEM(this); diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index a9d55957af..2673143285 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -147,10 +147,10 @@ void CGEEngine::SelectSound() { if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); Inf(Text->getText(STYPE_TEXT)); - Talk->Goto(Talk->X, FONT_HIG / 2); + Talk->Goto(Talk->_x, FONT_HIG / 2); for (i = 0; i < ArrayCount(DevName); i++) DevMenu[i].Text = Text->getText(DevName[i]); - (new VMENU(this, DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); + (new VMENU(this, DevMenu, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); } @@ -184,8 +184,8 @@ static int Hlp; void CGEEngine::SNSelect() { Inf(Text->getText(Hlp)); - Talk->Goto(Talk->X, FONT_HIG / 2); - (new VMENU(this, Cho, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); + Talk->Goto(Talk->_x, FONT_HIG / 2); + (new VMENU(this, Cho, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); } diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index a5b82f1e8d..87daced31e 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -67,25 +67,25 @@ int FLY::L = 20, FLY::B = 100; -FLY::FLY(CGEEngine *vm, BITMAP **shpl) +FLY::FLY(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Tx(0), Ty(0), _vm(vm) { Step(new_random(2)); - Goto(L + new_random(R - L - W), T + new_random(B - T - H)); + Goto(L + new_random(R - L - _w), T + new_random(B - T - _h)); } void FLY::Tick(void) { Step(); - if (! Flags.Kept) { + if (!_flags._kept) { if (new_random(10) < 1) { Tx = new_random(3) - 1; Ty = new_random(3) - 1; } - if (X + Tx < L || X + Tx + W > R) + if (_x + Tx < L || _x + Tx + _w > R) Tx = -Tx; - if (Y + Ty < T || Y + Ty + H > B) + if (_y + Ty < T || _y + Ty + _h > B) Ty = -Ty; - Goto(X + Tx, Y + Ty); + Goto(_x + Tx, _y + Ty); } } diff --git a/engines/cge/game.h b/engines/cge/game.h index fb4dad6fae..a64018aa58 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -48,7 +48,7 @@ class FLY : public Sprite { static int L, T, R, B; public: int Tx, Ty; - FLY(CGEEngine *vm, BITMAP **shpl); + FLY(CGEEngine *vm, Bitmap **shpl); void Tick(void); private: CGEEngine *_vm; diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index f891b9c092..e3c60b6e21 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -44,8 +44,8 @@ GET_TEXT::GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void ( Mode = RECT; TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); SetShapeList(TS); - Flags.BDel = true; - Flags.Kill = true; + _flags._bDel = true; + _flags._kill = true; memcpy(Buff, text, Len); Buff[Len] = ' '; Buff[Len + 1] = '\0'; @@ -66,7 +66,7 @@ void GET_TEXT::Tick(void) { Cntr = 0; } PutLine(1, Buff); - Time = GTTIME; + _time = GTTIME; } @@ -107,7 +107,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { if (p) x = ogon[p - bezo]; } - if (Len < Size && 2 * TEXT_HM + _Font->Width(Buff) + _Font->Wid[x] <= W) { + if (Len < Size && 2 * TEXT_HM + _Font->Width(Buff) + _Font->Wid[x] <= _w) { Buff[Len + 2] = Buff[Len + 1]; Buff[Len + 1] = Buff[Len]; Buff[Len++] = x; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index c1f688babd..7b9ce59f5e 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -42,15 +42,15 @@ bool MIXER::Appear = false; MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _vm(vm) { Appear = true; - mb[0] = new BITMAP("VOLUME"); + mb[0] = new Bitmap("VOLUME"); mb[1] = NULL; SetShapeList(mb); SetName(Text->getText(MIX_NAME)); - Flags.Syst = true; - Flags.Kill = true; - Flags.BDel = true; + _flags._syst = true; + _flags._kill = true; + _flags._bDel = true; Goto(x, y); - Z = MIX_Z; + _z = MIX_Z; // slaves @@ -58,7 +58,7 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _v for (i = 0; i < MIX_MAX; i++) { static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); - lb[i] = new BITMAP(fn); + lb[i] = new Bitmap(fn); ls[i].Now = ls[i].Next = i; ls[i].Dx = ls[i].Dy = ls[i].Dly = 0; } @@ -68,13 +68,13 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _v register Sprite *spr = new Sprite(_vm, lb); spr->SetSeq(ls); spr->Goto(x + 2 + 12 * i, y + 8); - spr->Flags.Tran = true; - spr->Flags.Kill = true; - spr->Flags.BDel = false; - spr->Z = MIX_Z; + spr->_flags._tran = true; + spr->_flags._kill = true; + spr->_flags._bDel = false; + spr->_z = MIX_Z; Led[i] = spr; } - Led[ArrayCount(Led) - 1]->Flags.BDel = true; + Led[ArrayCount(Led) - 1]->_flags._bDel = true; Vga->ShowQ->Insert(this); for (i = 0; i < ArrayCount(Led); i++) @@ -88,7 +88,7 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _v SNDDrvInfo.VOL4.DL = i; SNDDrvInfo.VOL4.DR = i; Update(); - Time = MIX_DELAY; + _time = MIX_DELAY; } MIXER::~MIXER(void) { @@ -100,11 +100,11 @@ MIXER::~MIXER(void) { void MIXER::Touch(uint16 mask, int x, int y) { Sprite::Touch(mask, x, y); if (mask & L_UP) { - uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < W / 2); + uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < _w / 2); if (y < MIX_BHIG) { if (*vol < 0xFF) *vol += 0x11; - } else if (y >= H - MIX_BHIG) { + } else if (y >= _h - MIX_BHIG) { if (*vol > 0x00) *vol -= 0x11; } @@ -114,12 +114,12 @@ void MIXER::Touch(uint16 mask, int x, int y) { void MIXER::Tick(void) { - int x = Mouse->X; - int y = Mouse->Y; + int x = Mouse->_x; + int y = Mouse->_y; if (SpriteAt(x, y) == this) { Fall = MIX_FALL; - if (Flags.Hold) - Touch(L_UP, x - X, y - Y); + if (_flags._hold) + Touch(L_UP, x - _x, y - _y); } else { if (Fall) --Fall; @@ -129,7 +129,7 @@ void MIXER::Tick(void) { SNPOST_(SNKILL, -1, 0, this); } } - Time = MIX_DELAY; + _time = MIX_DELAY; } diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index cb94e926c5..5bdf7449fc 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -31,7 +31,7 @@ namespace CGE { -EVENT Evt[EVT_MAX]; +Event Evt[EVT_MAX]; uint16 EvtHead = 0, EvtTail = 0; @@ -39,7 +39,7 @@ MOUSE_FUN *MOUSE::OldMouseFun = NULL; uint16 MOUSE::OldMouseMask = 0; -MOUSE::MOUSE(CGEEngine *vm, BITMAP **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { +MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { static Seq ms[] = { { 0, 0, 0, 0, 1 }, { 1, 1, 0, 0, 1 } @@ -136,8 +136,8 @@ void MOUSE::ClrEvt(Sprite *spr) { if (spr) { uint16 e; for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) - if (Evt[e].Ptr == spr) - Evt[e].Msk = 0; + if (Evt[e]._ptr == spr) + Evt[e]._msk = 0; } else EvtTail = EvtHead; } @@ -146,49 +146,49 @@ void MOUSE::ClrEvt(Sprite *spr) { void MOUSE::Tick(void) { Step(); while (EvtTail != EvtHead) { - EVENT e = Evt[EvtTail]; - if (e.Msk) { - if (Hold && e.Ptr != Hold) - Hold->Touch(e.Msk | ATTN, e.X - Hold->X, e.Y - Hold->Y); + Event e = Evt[EvtTail]; + if (e._msk) { + if (Hold && e._ptr != Hold) + Hold->Touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y); // update mouse cursor position - if (e.Msk & ROLL) - Goto(e.X, e.Y); + if (e._msk & ROLL) + Goto(e._x, e._y); // activate current touched SPRITE - if (e.Ptr) { - if (e.Msk & KEYB) - e.Ptr->Touch(e.Msk, e.X, e.Y); + if (e._ptr) { + if (e._msk & KEYB) + e._ptr->Touch(e._msk, e._x, e._y); else - e.Ptr->Touch(e.Msk, e.X - e.Ptr->X, e.Y - e.Ptr->Y); + e._ptr->Touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y); } else if (Sys) - Sys->Touch(e.Msk, e.X, e.Y); + Sys->Touch(e._msk, e._x, e._y); - if (e.Msk & L_DN) { - Hold = e.Ptr; + if (e._msk & L_DN) { + Hold = e._ptr; if (Hold) { - Hold->Flags.Hold = true; - hx = e.X - Hold->X; - hy = e.Y - Hold->Y; + Hold->_flags._hold = true; + hx = e._x - Hold->_x; + hy = e._y - Hold->_y; } } - if (e.Msk & L_UP) { + if (e._msk & L_UP) { if (Hold) { - Hold->Flags.Hold = false; + Hold->_flags._hold = false; Hold = NULL; } } ///Touched = e.Ptr; // discard Text if button released - if (e.Msk & (L_UP | R_UP)) + if (e._msk & (L_UP | R_UP)) KillText(); } EvtTail = (EvtTail + 1) % EVT_MAX; } if (Hold) - Hold->Goto(X - hx, Y - hy); + Hold->Goto(_x - hx, _y - hy); } } // End of namespace CGE diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h index 28152b7f29..4d95f10423 100644 --- a/engines/cge/mouse.h +++ b/engines/cge/mouse.h @@ -45,13 +45,14 @@ namespace CGE { extern TALK *Talk; -struct EVENT { - uint16 Msk; - uint16 X, Y; - Sprite *Ptr; +struct Event { + uint16 _msk; + uint16 _x; + uint16 _y; + Sprite *_ptr; }; -extern EVENT Evt[EVT_MAX]; +extern Event Evt[EVT_MAX]; extern uint16 EvtHead, EvtTail; typedef void (MOUSE_FUN)(void); @@ -69,7 +70,7 @@ public: int Buttons; Sprite *Busy; //Sprite *Touched; - MOUSE(CGEEngine *vm, BITMAP **shpl = MC); + MOUSE(CGEEngine *vm, Bitmap **shpl = MC); ~MOUSE(); void On(); void Off(); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 50eed3f562..565c7d33f0 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -75,7 +75,7 @@ static void SNGame(Sprite *spr, int num) { int buref = 0; int Stage = 0; - for (dup[0] = Vga->ShowQ->First(); dup[0]; dup[0] = dup[0]->Next) { + for (dup[0] = Vga->ShowQ->First(); dup[0]; dup[0] = dup[0]->_next) { buref = dup[0]->_ref; if (buref / 1000 == 16 && buref % 100 == 6) { Stage = (buref / 100) % 10; @@ -88,8 +88,8 @@ static void SNGame(Sprite *spr, int num) { } if (Game) { // continue game - int i = new_random(3), hand = (dup[0]->ShpCnt == 6); - ++ Stage; + int i = new_random(3), hand = (dup[0]->_shpCnt == 6); + Stage++; if (hand && Stage > DRESSED) ++hand; if (i >= 0 || (dup[i] == spr && new_random(3) == 0)) { @@ -188,7 +188,7 @@ static void SNGame(Sprite *spr, int num) { } ///-------------------- SNPOST(SNSETZ, 20700, 0, NULL); - bool hit = (k1->SeqPtr + k2->SeqPtr + k3->SeqPtr == 15); + bool hit = (k1->_seqPtr + k2->_seqPtr + k3->_seqPtr == 15); if (hit) { if (spr->_ref == 1) { SNPOST(SNSAY, 1, 20003, NULL); // hura! @@ -295,7 +295,7 @@ int FindPocket(Sprite *spr) { void SelectPocket(int n) { - if (n < 0 || (_pocLight->SeqPtr && PocPtr == n)) { + if (n < 0 || (_pocLight->_seqPtr && PocPtr == n)) { _pocLight->Step(0); n = FindPocket(NULL); if (n >= 0) @@ -325,10 +325,10 @@ void Hide1(Sprite *spr) { } -void SNGhost(BITMAP *bmp) { +void SNGhost(Bitmap *bmp) { // TODO : Get x and y from M but not using segment / offset - //bmp->Hide(FP_OFF(bmp->M), FP_SEG(bmp->M)); - bmp->M = NULL; + //bmp->Hide(FP_OFF(bmp->_m), FP_SEG(bmp->_m)); + bmp->_m = NULL; delete bmp; warning("STUB: SNGhost"); } @@ -509,10 +509,10 @@ static void SNZTrim(Sprite *spr) { bool en = _heart->_enable; Sprite *s; _heart->_enable = false; - s = (spr->Flags.Shad) ? spr->Prev : NULL; + s = (spr->_flags._shad) ? spr->_prev : NULL; Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr)); if (s) { - s->Z = spr->Z; + s->_z = spr->_z; Vga->ShowQ->Insert(Vga->ShowQ->Remove(s), spr); } _heart->_enable = en; @@ -522,9 +522,9 @@ static void SNZTrim(Sprite *spr) { static void SNHide(Sprite *spr, int val) { if (spr) { - spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide); - if (spr->Flags.Shad) - spr->Prev->Flags.Hide = spr->Flags.Hide; + spr->_flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags._hide); + if (spr->_flags._shad) + spr->_prev->_flags._hide = spr->_flags._hide; } } @@ -553,7 +553,7 @@ void SNSeq(Sprite *spr, int val) { void SNRSeq(Sprite *spr, int val) { if (spr) - SNSeq(spr, spr->SeqPtr + val); + SNSeq(spr, spr->_seqPtr + val); } @@ -565,22 +565,22 @@ void SNSend(Sprite *spr, int val) { spr->_cave = val; if (val1 != was1) { if (was1) { - if (spr->Flags.Kept) { + if (spr->_flags._kept) { int n = FindPocket(spr); if (n >= 0) _pocket[n] = NULL; } Hide1(spr); ContractSprite(spr); - spr->Flags.Slav = false; + spr->_flags._slav = false; } else { if (spr->_ref % 1000 == 0) - BITMAP::Pal = VGA::SysPal; - if (spr->Flags.Back) + Bitmap::Pal = VGA::SysPal; + if (spr->_flags._back) spr->BackShow(true); else ExpandSprite(spr); - BITMAP::Pal = NULL; + Bitmap::Pal = NULL; } } } @@ -596,15 +596,15 @@ void SNSwap(Sprite *spr, int xref) { bool xwas1 = (xwas == 0 || xwas == Now); Swap(spr->_cave, xspr->_cave); - Swap(spr->X, xspr->X); - Swap(spr->Y, xspr->Y); - Swap(spr->Z, xspr->Z); - if (spr->Flags.Kept) { + Swap(spr->_x, xspr->_x); + Swap(spr->_y, xspr->_y); + Swap(spr->_z, xspr->_z); + if (spr->_flags._kept) { int n = FindPocket(spr); if (n >= 0) _pocket[n] = xspr; - xspr->Flags.Kept = true; - xspr->Flags.Port = false; + xspr->_flags._kept = true; + xspr->_flags._port = false; } if (xwas1 != was1) { if (was1) { @@ -625,14 +625,14 @@ void SNSwap(Sprite *spr, int xref) { void SNCover(Sprite *spr, int xref) { Sprite *xspr = Locate(xref); if (spr && xspr) { - spr->Flags.Hide = true; - xspr->Z = spr->Z; + spr->_flags._hide = true; + xspr->_z = spr->_z; xspr->_cave = spr->_cave; - xspr->Goto(spr->X, spr->Y); + xspr->Goto(spr->_x, spr->_y); ExpandSprite(xspr); - if ((xspr->Flags.Shad = spr->Flags.Shad) == 1) { - Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr->Prev), xspr); - spr->Flags.Shad = false; + if ((xspr->_flags._shad = spr->_flags._shad) == 1) { + Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr->_prev), xspr); + spr->_flags._shad = false; } FeedSnail(xspr, NEAR); } @@ -641,28 +641,28 @@ void SNCover(Sprite *spr, int xref) { void SNUncover(Sprite *spr, Sprite *xspr) { if (spr && xspr) { - spr->Flags.Hide = false; + spr->_flags._hide = false; spr->_cave = xspr->_cave; - spr->Goto(xspr->X, xspr->Y); - if ((spr->Flags.Shad = xspr->Flags.Shad) == 1) { - Vga->ShowQ->Insert(Vga->ShowQ->Remove(xspr->Prev), spr); - xspr->Flags.Shad = false; + spr->Goto(xspr->_x, xspr->_y); + if ((spr->_flags._shad = xspr->_flags._shad) == 1) { + Vga->ShowQ->Insert(Vga->ShowQ->Remove(xspr->_prev), spr); + xspr->_flags._shad = false; } - spr->Z = xspr->Z; + spr->_z = xspr->_z; SNSend(xspr, -1); - if (spr->Time == 0) - ++spr->Time; + if (spr->_time == 0) + ++spr->_time; } } void SNSetX0(int cav, int x0) { - HeroXY[cav - 1].X = x0; + HeroXY[cav - 1]._x = x0; } void SNSetY0(int cav, int y0) { - HeroXY[cav - 1].Y = y0; + HeroXY[cav - 1]._y = y0; } @@ -674,19 +674,19 @@ void SNSetXY(Sprite *spr, uint16 xy) { void SNRelX(Sprite *spr, int x) { if (spr && Hero) - spr->Goto(Hero->X + x, spr->Y); + spr->Goto(Hero->_x + x, spr->_y); } void SNRelY(Sprite *spr, int y) { if (spr && Hero) - spr->Goto(spr->X, Hero->Y + y); + spr->Goto(spr->_x, Hero->_y + y); } void SNRelZ(Sprite *spr, int z) { if (spr && Hero) { - spr->Z = Hero->Z + z; + spr->_z = Hero->_z + z; SNZTrim(spr); } } @@ -694,19 +694,19 @@ void SNRelZ(Sprite *spr, int z) { void SNSetX(Sprite *spr, int x) { if (spr) - spr->Goto(x, spr->Y); + spr->Goto(x, spr->_y); } void SNSetY(Sprite *spr, int y) { if (spr) - spr->Goto(spr->X, y); + spr->Goto(spr->_x, y); } void SNSetZ(Sprite *spr, int z) { if (spr) { - spr->Z = z; + spr->_z = z; //SNPOST_(SNZTRIM, -1, 0, spr); SNZTrim(spr); } @@ -718,9 +718,9 @@ void SNSlave(Sprite *spr, int ref) { if (spr && slv) { if (spr->Active()) { SNSend(slv, spr->_cave); - slv->Flags.Slav = true; - slv->Z = spr->Z; - Vga->ShowQ->Insert(Vga->ShowQ->Remove(slv), spr->Next); + slv->_flags._slav = true; + slv->_z = spr->_z; + Vga->ShowQ->Insert(Vga->ShowQ->Remove(slv), spr->_next); } } } @@ -728,36 +728,37 @@ void SNSlave(Sprite *spr, int ref) { void SNTrans(Sprite *spr, int trans) { if (spr) - spr->Flags.Tran = (trans < 0) ? !spr->Flags.Tran : (trans != 0); + spr->_flags._tran = (trans < 0) ? !spr->_flags._tran : (trans != 0); } void SNPort(Sprite *spr, int port) { if (spr) - spr->Flags.Port = (port < 0) ? !spr->Flags.Port : (port != 0); + spr->_flags._port = (port < 0) ? !spr->_flags._port : (port != 0); } void SNKill(Sprite *spr) { if (spr) { - if (spr->Flags.Kept) { + if (spr->_flags._kept) { int n = FindPocket(spr); if (n >= 0) _pocket[n] = NULL; } - Sprite *nx = spr->Next; + Sprite *nx = spr->_next; Hide1(spr); Vga->ShowQ->Remove(spr); MOUSE::ClrEvt(spr); - if (spr->Flags.Kill) + if (spr->_flags._kill) delete spr; else { spr->_cave = -1; Vga->SpareQ->Append(spr); } - if (nx) - if (nx->Flags.Slav) + if (nx) { + if (nx->_flags._slav) SNKill(nx); + } } } @@ -767,20 +768,20 @@ static void SNSound(Sprite *spr, int wav, int cnt) { if (wav == -1) Sound.Stop(); else - Sound.Play(Fx[wav], (spr) ? ((spr->X + spr->W / 2) / (SCR_WID / 16)) : 8, cnt); + Sound.Play(Fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (SCR_WID / 16)) : 8, cnt); } } void SNKeep(Sprite *spr, int stp) { SelectPocket(-1); - if (spr && ! spr->Flags.Kept && _pocket[PocPtr] == NULL) { + if (spr && ! spr->_flags._kept && _pocket[PocPtr] == NULL) { SNSound(spr, 3, 1); _pocket[PocPtr] = spr; spr->_cave = 0; - spr->Flags.Kept = true; - spr->Goto(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->W / 2, - POCKET_Y + POCKET_DY / 2 - spr->H / 2); + spr->_flags._kept = true; + spr->Goto(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->_w / 2, + POCKET_Y + POCKET_DY / 2 - spr->_h / 2); if (stp >= 0) spr->Step(stp); } @@ -794,7 +795,7 @@ void SNGive(Sprite *spr, int stp) { if (p >= 0) { _pocket[p] = NULL; spr->_cave = Now; - spr->Flags.Kept = false; + spr->_flags._kept = false; if (stp >= 0) spr->Step(stp); } @@ -828,7 +829,7 @@ static void SNLevel(Sprite *spr, int lev) { } MaxCave = maxcav[Lev]; if (spr) - spr->Flags.Hide = false; + spr->_flags._hide = false; } @@ -937,7 +938,7 @@ void SNAIL::RunCom(void) { if (sprel) { if (sprel->SeqTest(snc->Val) && (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) { - _heart->setXTimer(&Pause, sprel->Time); + _heart->setXTimer(&Pause, sprel->_time); } else goto xit; } @@ -1111,13 +1112,13 @@ void SNAIL::RunCom(void) { SNZTrim(sprel); break; case SNGHOST : - SNGhost((BITMAP *) snc->Ptr); + SNGhost((Bitmap *) snc->Ptr); break; default : warning("Unhandled snc->Com in SNMouse(bool)"); break; } - ++Tail; + Tail++; if (!Turbo) break; } diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 9449a8081e..e1df628d3b 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -117,8 +117,8 @@ extern int MaxCave; extern int PocPtr; extern BAR Barriers[]; extern struct HXY { - int X; - int Y; + int _x; + int _y; } HeroXY[]; } // End of namespace CGE diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 43917732be..5aa5e44b8d 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -100,7 +100,7 @@ void FONT::Save(void) { TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode) : Sprite(vm, NULL), Mode(mode), _vm(vm) { TS[0] = TS[1] = NULL; - Flags.Syst = true; + _flags._syst = true; Update(tx); } @@ -108,7 +108,7 @@ TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode) TALK::TALK(CGEEngine *vm) : Sprite(vm, NULL), Mode(PURE), _vm(vm) { TS[0] = TS[1] = NULL; - Flags.Syst = true; + _flags._syst = true; } @@ -158,11 +158,11 @@ void TALK::Update(const char *tx) { TS[0] = Box(mw, mh); } - m = TS[0]->M + ln * mw + hmarg; + m = TS[0]->_m + ln * mw + hmarg; while (* tx) { if (*tx == '|' || *tx == '\n') - m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; + m = TS[0]->_m + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; else { int cw = _Font->Wid[*tx], i; uint8 *f = _Font->Map + _Font->Pos[*tx]; @@ -176,10 +176,10 @@ void TALK::Update(const char *tx) { b >>= 1; pp += mw; } - ++m; + m++; } } - ++tx; + tx++; } TS[0]->Code(); SetShapeList(TS); @@ -188,7 +188,7 @@ void TALK::Update(const char *tx) { -BITMAP *TALK::Box(uint16 w, uint16 h) { +Bitmap *TALK::Box(uint16 w, uint16 h) { uint8 *b, * p, * q; uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0; @@ -228,14 +228,14 @@ BITMAP *TALK::Box(uint16 w, uint16 h) { q -= w; } } - return new BITMAP(w, h, b); + return new Bitmap(w, h, b); } void TALK::PutLine(int line, const char *text) { // Note: (TS[0].W % 4) have to be 0 - uint16 w = TS[0]->W, h = TS[0]->H; - uint8 *v = TS[0]->V, * p; + uint16 w = TS[0]->_w, h = TS[0]->_h; + uint8 *v = TS[0]->_v, * p; uint16 dsiz = w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap uint16 psiz = h * lsiz; // - last gap, but + plane trailer @@ -278,22 +278,22 @@ void TALK::PutLine(int line, const char *text) { if (p >= q) p = p - size + 1; } - ++text; + text++; } } } INFO_LINE::INFO_LINE(CGEEngine *vm, uint16 w) : TALK(vm), OldTxt(NULL), _vm(vm) { - TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG); + TS[0] = new Bitmap(w, FONT_HIG, TEXT_BG); SetShapeList(TS); } void INFO_LINE::Update(const char *tx) { if (tx != OldTxt) { - uint16 w = TS[0]->W, h = TS[0]->H; - uint8 *v = (uint8 *) TS[0]->V; + uint16 w = TS[0]->_w, h = TS[0]->_h; + uint8 *v = (uint8 *) TS[0]->_v; uint16 dsiz = w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap uint16 psiz = h * lsiz; // - last gape, but + plane trailer @@ -324,7 +324,7 @@ void INFO_LINE::Update(const char *tx) { if (p >= q) p = p - size + 1; } - ++tx; + tx++; } } OldTxt = tx; diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 2a38af91d1..60f7f213d4 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -71,8 +71,8 @@ enum TBOX_STYLE { PURE, RECT, ROUND }; class TALK : public Sprite { protected: TBOX_STYLE Mode; - BITMAP *TS[2]; - BITMAP *Box(uint16 w, uint16 h); + Bitmap *TS[2]; + Bitmap *Box(uint16 w, uint16 h); public: TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode = PURE); TALK(CGEEngine *vm); diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 74ff6fac2d..7b191b492b 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -184,11 +184,11 @@ void TEXT::Say(const char *txt, Sprite *spr) { KillText(); Talk = new TALK(_vm, txt, ROUND); if (Talk) { - bool east = spr->Flags.East; - int x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2); - int y = spr->Y + 2; + bool east = spr->_flags._east; + int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); + int y = spr->_y + 2; Sprite *spike = new Sprite(_vm, SP); - uint16 sw = spike->W; + uint16 sw = spike->_w; if (east) { if (x + sw + TEXT_RD + 5 >= SCR_WID) @@ -197,21 +197,21 @@ void TEXT::Say(const char *txt, Sprite *spr) { if (x <= 5 + TEXT_RD + sw) east = true; } - x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2 - sw); + x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2 - sw); if (spr->_ref == 1) x += ((east) ? -10 : 10); // Hero - Talk->Flags.Kill = true; - Talk->Flags.BDel = true; + Talk->_flags._kill = true; + Talk->_flags._bDel = true; Talk->SetName(Text->getText(SAY_NAME)); - Talk->Goto(x - (Talk->W - sw) / 2 - 3 + 6 * east, y - spike->H - Talk->H + 1); - Talk->Z = 125; + Talk->Goto(x - (Talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - Talk->_h + 1); + Talk->_z = 125; Talk->_ref = SAY_REF; - spike->Goto(x, Talk->Y + Talk->H - 1); - spike->Z = 126; - spike->Flags.Slav = true; - spike->Flags.Kill = true; + spike->Goto(x, Talk->_y + Talk->_h - 1); + spike->_z = 126; + spike->_flags._slav = true; + spike->_flags._kill = true; spike->SetName(Text->getText(SAY_NAME)); spike->Step(east); spike->_ref = SAY_REF; @@ -225,12 +225,12 @@ void CGEEngine::Inf(const char *txt) { KillText(); Talk = new TALK(this, txt, RECT); if (Talk) { - Talk->Flags.Kill = true; - Talk->Flags.BDel = true; + Talk->_flags._kill = true; + Talk->_flags._bDel = true; Talk->SetName(Text->getText(INF_NAME)); Talk->Center(); - Talk->Goto(Talk->X, Talk->Y - 20); - Talk->Z = 126; + Talk->Goto(Talk->_x, Talk->_y - 20); + Talk->_z = 126; Talk->_ref = INF_REF; Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 56960389c8..673d6036d8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -356,11 +356,11 @@ void Heart::setXTimer(uint16 *ptr, uint16 time) { Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) - : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), - Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), + : _x(0), _y(0), _z(0), NearPtr(0), TakePtr(0), + _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(File, 0, sizeof(File)); - *((uint16 *)&Flags) = 0; + *((uint16 *)&_flags) = 0; SetShapeList(shp); } @@ -374,8 +374,8 @@ BMP_PTR Sprite::Shp() { register SprExt *e = _ext; if (e) if (e->_seq) { - int i = e->_seq[SeqPtr].Now; - if (i >= ShpCnt) { + int i = e->_seq[_seqPtr].Now; + if (i >= _shpCnt) { //char s[256]; //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); @@ -391,24 +391,24 @@ BMP_PTR Sprite::Shp() { BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; - ShpCnt = 0; - W = 0; - H = 0; + _shpCnt = 0; + _w = 0; + _h = 0; if (shp) { BMP_PTR *p; for (p = shp; *p; p++) { BMP_PTR b = (*p); // ->Code(); - if (b->W > W) - W = b->W; - if (b->H > H) - H = b->H; - ++ShpCnt; + if (b->_w > _w) + _w = b->_w; + if (b->_h > _h) + _h = b->_h; + _shpCnt++; } Expand(); _ext->_shpList = shp; if (!_ext->_seq) - SetSeq((ShpCnt < 2) ? _seq1 : _seq2); + SetSeq((_shpCnt < 2) ? _seq1 : _seq2); } return r; } @@ -441,19 +441,19 @@ Seq *Sprite::SetSeq(Seq *seq) { Expand(); register Seq *s = _ext->_seq; _ext->_seq = seq; - if (SeqPtr == NO_SEQ) + if (_seqPtr == NO_SEQ) Step(0); - else if (Time == 0) - Step(SeqPtr); + else if (_time == 0) + Step(_seqPtr); return s; } bool Sprite::SeqTest(int n) { if (n >= 0) - return (SeqPtr == n); + return (_seqPtr == n); if (_ext) - return (_ext->_seq[SeqPtr].Next == SeqPtr); + return (_ext->_seq[_seqPtr].Next == _seqPtr); return true; } @@ -491,7 +491,7 @@ Sprite *Sprite::Expand(void) { if (*File) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; - BMP_PTR *shplist = new BMP_PTR [ShpCnt + 1]; + BMP_PTR *shplist = new BMP_PTR [_shpCnt + 1]; Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -521,7 +521,7 @@ Sprite *Sprite::Expand(void) { break; } case 1 : { // Phase - shplist[shpcnt++] = new BITMAP(strtok(NULL, " \t,;/")); + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); break; } case 2 : { // Seq @@ -583,7 +583,7 @@ Sprite *Sprite::Expand(void) { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new BITMAP(File); + shplist[shpcnt++] = new Bitmap(File); } shplist[shpcnt] = NULL; if (seq) { @@ -593,7 +593,7 @@ Sprite *Sprite::Expand(void) { error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); } else - SetSeq((ShpCnt == 1) ? _seq1 : _seq2); + SetSeq((_shpCnt == 1) ? _seq1 : _seq2); //disable(); // disable interupt SetShapeList(shplist); @@ -618,7 +618,7 @@ Sprite *Sprite::Contract(void) { if (e) { if (e->_name) delete[] e->_name; - if (Flags.BDel && e->_shpList) { + if (_flags._bDel && e->_shpList) { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; @@ -651,15 +651,15 @@ Sprite *Sprite::BackShow(bool fast) { void Sprite::Step(int nr) { if (nr >= 0) - SeqPtr = nr; + _seqPtr = nr; if (_ext) { Seq *seq; if (nr < 0) - SeqPtr = _ext->_seq[SeqPtr].Next; - seq = _ext->_seq + SeqPtr; + _seqPtr = _ext->_seq[_seqPtr].Next; + seq = _ext->_seq + _seqPtr; if (seq->Dly >= 0) { - Goto(X + (seq->Dx), Y + (seq->Dy)); - Time = seq->Dly; + Goto(_x + (seq->Dx), _y + (seq->Dy)); + _time = seq->Dly; } } } @@ -674,19 +674,19 @@ void Sprite::MakeXlat(uint8 *x) { if (_ext) { BMP_PTR *b; - if (Flags.Xlat) + if (_flags._xlat) KillXlat(); for (b = _ext->_shpList; *b; b++) - (*b)->M = x; - Flags.Xlat = true; + (*b)->_m = x; + _flags._xlat = true; } } void Sprite::KillXlat(void) { - if (Flags.Xlat && _ext) { + if (_flags._xlat && _ext) { BMP_PTR *b; - uint8 *m = (*_ext->_shpList)->M; + uint8 *m = (*_ext->_shpList)->_m; switch (MemType(m)) { case NEAR_MEM : @@ -700,38 +700,38 @@ void Sprite::KillXlat(void) { break; } for (b = _ext->_shpList; *b; b++) - (*b)->M = NULL; - Flags.Xlat = false; + (*b)->_m = NULL; + _flags._xlat = false; } } void Sprite::Goto(int x, int y) { - int xo = X, yo = Y; - if (W < SCR_WID) { + int xo = _x, yo = _y; + if (_x < SCR_WID) { if (x < 0) x = 0; - if (x + W > SCR_WID) - x = (SCR_WID - W); - X = x; + if (x + _w > SCR_WID) + x = (SCR_WID - _w); + _x = x; } - if (H < SCR_HIG) { + if (_h < SCR_HIG) { if (y < 0) y = 0; - if (y + H > SCR_HIG) - y = (SCR_HIG - H); - Y = y; + if (y + _h > SCR_HIG) + y = (SCR_HIG - _h); + _y = y; } - if (Next) - if (Next->Flags.Slav) - Next->Goto(Next->X - xo + X, Next->Y - yo + Y); - if (Flags.Shad) - Prev->Goto(Prev->X - xo + X, Prev->Y - yo + Y); + if (_next) + if (_next->_flags._slav) + _next->Goto(_next->_x - xo + _x, _next->_y - yo + _y); + if (_flags._shad) + _prev->Goto(_prev->_x - xo + _x, _prev->_y - yo + _y); } void Sprite::Center(void) { - Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); + Goto((SCR_WID - _w) / 2, (SCR_HIG - _h) / 2); } @@ -742,12 +742,12 @@ void Sprite::Show(void) { e->_x0 = e->_x1; e->_y0 = e->_y1; e->_b0 = e->_b1; - e->_x1 = X; - e->_y1 = Y; + e->_x1 = _x; + e->_y1 = _y; e->_b1 = Shp(); // asm sti // ...done! - if (! Flags.Hide) { - if (Flags.Xlat) + if (!_flags._hide) { + if (_flags._xlat) e->_b1->XShow(e->_x1, e->_y1); else e->_b1->Show(e->_x1, e->_y1); @@ -758,7 +758,7 @@ void Sprite::Show(void) { void Sprite::Show(uint16 pg) { Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; - Shp()->Show(X, Y); + Shp()->Show(_x, _y); VGA::Page[1] = a; } @@ -773,16 +773,16 @@ void Sprite::Hide(void) { BMP_PTR Sprite::Ghost(void) { register SprExt *e = _ext; if (e->_b1) { - BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); + BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL); if (bmp == NULL) error("No core"); - bmp->W = e->_b1->W; - bmp->H = e->_b1->H; - if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) + bmp->_w = e->_b1->_w; + bmp->_h = e->_b1->_h; + if ((bmp->_b = farnew(HideDesc, bmp->_h)) == NULL) error("No Core"); - bmp->V = (uint8 *) memcpy(bmp->B, e->_b1->B, sizeof(HideDesc) * bmp->H); + bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment - //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); + //bmp->_m = (uint8 *) MK_FP(e->y1, e->x1); warning("FIXME: SPRITE::Ghost"); return bmp; } @@ -793,10 +793,12 @@ BMP_PTR Sprite::Ghost(void) { Sprite *SpriteAt(int x, int y) { Sprite *spr = NULL, * tail = Vga->ShowQ->Last(); if (tail) { - for (spr = tail->Prev; spr; spr = spr->Prev) - if (! spr->Flags.Hide && ! spr->Flags.Tran) - if (spr->Shp()->SolidAt(x - spr->X, y - spr->Y)) + for (spr = tail->_prev; spr; spr = spr->_prev) { + if (! spr->_flags._hide && ! spr->_flags._tran) { + if (spr->Shp()->SolidAt(x - spr->_x, y - spr->_y)) break; + } + } } return spr; } @@ -814,7 +816,7 @@ QUEUE::~QUEUE(void) { void QUEUE::Clear(void) { while (Head) { Sprite *s = Remove(Head); - if (s->Flags.Kill) + if (s->_flags._kill) delete s; } } @@ -823,7 +825,7 @@ void QUEUE::Clear(void) { void QUEUE::ForAll(void (*fun)(Sprite *)) { Sprite *s = Head; while (s) { - Sprite *n = s->Next; + Sprite *n = s->_next; fun(s); s = n; } @@ -832,8 +834,8 @@ void QUEUE::ForAll(void (*fun)(Sprite *)) { void QUEUE::Append(Sprite *spr) { if (Tail) { - spr->Prev = Tail; - Tail->Next = spr; + spr->_prev = Tail; + Tail->_next = spr; } else Head = spr; Tail = spr; @@ -846,18 +848,18 @@ void QUEUE::Append(Sprite *spr) { void QUEUE::Insert(Sprite *spr, Sprite *nxt) { if (nxt == Head) { - spr->Next = Head; + spr->_next = Head; Head = spr; if (! Tail) Tail = spr; } else { - spr->Next = nxt; - spr->Prev = nxt->Prev; - if (spr->Prev) - spr->Prev->Next = spr; + spr->_next = nxt; + spr->_prev = nxt->_prev; + if (spr->_prev) + spr->_prev->_next = spr; } - if (spr->Next) - spr->Next->Prev = spr; + if (spr->_next) + spr->_next->_prev = spr; if (Show) spr->Expand(); else @@ -867,8 +869,8 @@ void QUEUE::Insert(Sprite *spr, Sprite *nxt) { void QUEUE::Insert(Sprite *spr) { Sprite *s; - for (s = Head; s; s = s->Next) - if (s->Z > spr->Z) + for (s = Head; s; s = s->_next) + if (s->_z > spr->_z) break; if (s) Insert(spr, s); @@ -883,22 +885,22 @@ void QUEUE::Insert(Sprite *spr) { Sprite *QUEUE::Remove(Sprite *spr) { if (spr == Head) - Head = spr->Next; + Head = spr->_next; if (spr == Tail) - Tail = spr->Prev; - if (spr->Next) - spr->Next->Prev = spr->Prev; - if (spr->Prev) - spr->Prev->Next = spr->Next; - spr->Prev = NULL; - spr->Next = NULL; + Tail = spr->_prev; + if (spr->_next) + spr->_next->_prev = spr->_prev; + if (spr->_prev) + spr->_prev->_next = spr->_next; + spr->_prev = NULL; + spr->_next = NULL; return spr; } Sprite *QUEUE::Locate(int ref) { Sprite *spr; - for (spr = Head; spr; spr = spr->Next) { + for (spr = Head; spr; spr = spr->_next) { if (spr->_ref == ref) return spr; } @@ -1134,10 +1136,10 @@ void VGA::Sunset(void) { void VGA::Show(void) { Sprite *spr = ShowQ->First(); - for (spr = ShowQ->First(); spr; spr = spr->Next) + for (spr = ShowQ->First(); spr; spr = spr->_next) spr->Show(); Update(); - for (spr = ShowQ->First(); spr; spr = spr->Next) + for (spr = ShowQ->First(); spr; spr = spr->_next) spr->Hide(); ++ FrmCnt; @@ -1176,7 +1178,7 @@ void VGA::CopyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- -void BITMAP::XShow(int x, int y) { +void Bitmap::XShow(int x, int y) { /* uint8 rmsk = x % 4, mask = 1 << rmsk, @@ -1258,8 +1260,8 @@ void BITMAP::XShow(int x, int y) { } -void BITMAP::Show(int x, int y) { - const byte *srcP = (const byte *)V; +void Bitmap::Show(int x, int y) { + const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a @@ -1320,7 +1322,7 @@ void BITMAP::Show(int x, int y) { } -void BITMAP::Hide(int x, int y) { +void Bitmap::Hide(int x, int y) { /* uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); @@ -1383,7 +1385,7 @@ void BITMAP::Hide(int x, int y) { asm pop si // asm pop bx */ - warning("STUB: BITMAP::Hide"); + warning("STUB: Bitmap::Hide"); } } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 77594217ab..0c75dd6ba9 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -172,32 +172,35 @@ public: int _ref; signed char _cave; struct FLAGS { - uint16 Hide : 1; // general visibility switch - uint16 Near : 1; // Near action lock - uint16 Drag : 1; // sprite is moveable - uint16 Hold : 1; // sprite is held with mouse - uint16 ____ : 1; // intrrupt driven animation - uint16 Slav : 1; // slave object - uint16 Syst : 1; // system object - uint16 Kill : 1; // dispose memory after remove - uint16 Xlat : 1; // 2nd way display: xlat table - uint16 Port : 1; // portable - uint16 Kept : 1; // kept in pocket - uint16 East : 1; // talk to east (in opposite to west) - uint16 Shad : 1; // shadow - uint16 Back : 1; // 'send to background' request - uint16 BDel : 1; // delete bitmaps in ~SPRITE - uint16 Tran : 1; // transparent (untouchable) - } Flags; - int X, Y; - signed char Z; - uint16 W, H; - uint16 Time; + uint16 _hide : 1; // general visibility switch + uint16 _near : 1; // Near action lock + uint16 _drag : 1; // sprite is moveable + uint16 _hold : 1; // sprite is held with mouse + uint16 _____ : 1; // intrrupt driven animation + uint16 _slav : 1; // slave object + uint16 _syst : 1; // system object + uint16 _kill : 1; // dispose memory after remove + uint16 _xlat : 1; // 2nd way display: xlat table + uint16 _port : 1; // portable + uint16 _kept : 1; // kept in pocket + uint16 _east : 1; // talk to east (in opposite to west) + uint16 _shad : 1; // shadow + uint16 _back : 1; // 'send to background' request + uint16 _bDel : 1; // delete bitmaps in ~SPRITE + uint16 _tran : 1; // transparent (untouchable) + } _flags; + int _x; + int _y; + signed char _z; + uint16 _w; + uint16 _h; + uint16 _time; uint8 NearPtr, TakePtr; - int SeqPtr; - int ShpCnt; + int _seqPtr; + int _shpCnt; char File[MAXFILE]; - Sprite *Prev, * Next; + Sprite *_prev; + Sprite *_next; bool Works(Sprite *spr); bool SeqTest(int n); inline bool Active(void) { @@ -329,12 +332,6 @@ uint8 Closest(CBLK *pal, CBLK x) { #undef f } - - - - - - char *NumStr(char *str, int num); //static void Video (void); uint16 *SaveScreen(void); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index ed335191aa..ed07a1269f 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -60,12 +60,12 @@ MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : TALK(vm), _vm(vm) { p1 += w; p2 -= w; } - TS[0] = new BITMAP(w, h, p); + TS[0] = new Bitmap(w, h, p); SetShapeList(TS); - Flags.Slav = true; - Flags.Tran = true; - Flags.Kill = true; - Flags.BDel = true; + _flags._slav = true; + _flags._tran = true; + _flags._kill = true; + _flags._bDel = true; } @@ -78,7 +78,7 @@ char *VMGather(CHOICE *list) { for (cp = list; cp->Text; cp++) { len += strlen(cp->Text); - ++h; + h++; } vmgt = new char[len + h]; if (vmgt) { @@ -87,7 +87,7 @@ char *VMGather(CHOICE *list) { if (*vmgt) strcat(vmgt, "|"); strcat(vmgt, cp->Text); - ++ h; + h++; } } return vmgt; @@ -106,16 +106,16 @@ VMENU::VMENU(CGEEngine *vm, CHOICE *list, int x, int y) delete[] vmgt; Items = 0; for (cp = list; cp->Text; cp++) - ++Items; - Flags.BDel = true; - Flags.Kill = true; + Items++; + _flags._bDel = true; + _flags._kill = true; if (x < 0 || y < 0) Center(); else - Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); + Goto(x - _w / 2, y - (TEXT_VM + FONT_HIG / 2)); Vga->ShowQ->Insert(this, Vga->ShowQ->Last()); - Bar = new MENU_BAR(_vm, W - 2 * TEXT_HM); - Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM); + Bar = new MENU_BAR(_vm, _w - 2 * TEXT_HM); + Bar->Goto(_x + TEXT_HM - MB_HM, _y + TEXT_VM - MB_VM); Vga->ShowQ->Insert(Bar, Vga->ShowQ->Last()); } @@ -137,12 +137,12 @@ void VMENU::Touch(uint16 mask, int x, int y) { if (y >= 0) { n = y / h; if (n < Items) - ok = (x >= TEXT_HM && x < W - TEXT_HM/* && y % h < FONT_HIG*/); + ok = (x >= TEXT_HM && x < _w - TEXT_HM/* && y % h < FONT_HIG*/); else n = Items - 1; } - Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM + n * h - MB_VM); + Bar->Goto(_x + TEXT_HM - MB_HM, _y + TEXT_VM + n * h - MB_VM); if (ok && (mask & L_UP)) { Items = 0; -- cgit v1.2.3 From f59c910b8f41cfa9eeda88ce5f4d5c2a18b97662 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 30 Jun 2011 08:30:23 +0200 Subject: CGE: Some more renaming (wip) --- engines/cge/bitmap.cpp | 78 +++++++++++----------- engines/cge/bitmap.h | 28 ++++---- engines/cge/boot.h | 64 +++++++++--------- engines/cge/btfile.cpp | 110 +++++++++++++++---------------- engines/cge/btfile.h | 61 +++++++++-------- engines/cge/cfile.cpp | 168 +++++++++++++++++++++++------------------------ engines/cge/cfile.h | 53 +++++++-------- engines/cge/cge.cpp | 22 +++---- engines/cge/cge_main.cpp | 67 +++++++++---------- engines/cge/general.cpp | 26 ++++---- engines/cge/general.h | 36 +++++----- engines/cge/mixer.cpp | 4 +- engines/cge/snail.cpp | 4 +- engines/cge/sound.cpp | 10 +-- engines/cge/talk.cpp | 10 +-- engines/cge/text.cpp | 6 +- engines/cge/vga13h.cpp | 30 ++++----- engines/cge/vol.cpp | 52 +++++++-------- engines/cge/vol.h | 48 +++++++------- engines/cge/wav.h | 2 +- 20 files changed, 441 insertions(+), 438 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index ab5c1ff3c7..3068499975 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -35,11 +35,11 @@ namespace CGE { -DAC *Bitmap::Pal = NULL; +DAC *Bitmap::_pal = NULL; #define MAXPATH 128 void Bitmap::init() { - Pal = NULL; + _pal = NULL; } void Bitmap::deinit() { @@ -51,9 +51,9 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { ForceExt(pat, fname, ".VBM"); #if (BMP_MODE < 2) - if (rem && PIC_FILE::Exist(pat)) { + if (rem && PIC_FILE::exist(pat)) { PIC_FILE file(pat); - if ((file.Error == 0) && (!VBMLoad(&file))) + if ((file.Error == 0) && (!loadVBM(&file))) error("Bad VBM [%s]", fname); } else #endif @@ -62,7 +62,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { ForceExt(pat, fname, ".BMP"); PIC_FILE file(pat); if (file.Error == 0) { - if (BMPLoad(&file)) { + if (loadBMP(&file)) { Code(); if (rem) { free(_m); @@ -80,7 +80,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL) { if (map) - Code(); + code(); } @@ -169,7 +169,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { } -uint16 Bitmap::MoveVmap(uint8 *buf) { +uint16 Bitmap::moveVmap(uint8 *buf) { if (_v) { uint16 vsiz = (uint8 *)_b - (uint8 *)_v; uint16 siz = vsiz + _h * sizeof(HideDesc); @@ -183,7 +183,7 @@ uint16 Bitmap::MoveVmap(uint8 *buf) { } -BMP_PTR Bitmap::Code(void) { +BMP_PTR Bitmap::code(void) { if (_m) { uint16 i, cnt; @@ -305,7 +305,7 @@ BMP_PTR Bitmap::Code(void) { } -bool Bitmap::SolidAt(int x, int y) { +bool Bitmap::solidAt(int x, int y) { uint8 *m; uint16 r, n, n0; @@ -366,67 +366,67 @@ bool Bitmap::SolidAt(int x, int y) { } -bool Bitmap::VBMSave(XFILE *f) { - uint16 p = (Pal != NULL), +bool Bitmap::saveVBM(XFILE *f) { + uint16 p = (_pal != NULL), n = ((uint16)(((uint8 *)_b) - _v)) + _h * sizeof(HideDesc); if (f->Error == 0) - f->Write((uint8 *)&p, sizeof(p)); + f->write((uint8 *)&p, sizeof(p)); if (f->Error == 0) - f->Write((uint8 *)&n, sizeof(n)); + f->write((uint8 *)&n, sizeof(n)); if (f->Error == 0) - f->Write((uint8 *)&_w, sizeof(_w)); + f->write((uint8 *)&_w, sizeof(_w)); if (f->Error == 0) - f->Write((uint8 *)&_h, sizeof(_h)); + f->write((uint8 *)&_h, sizeof(_h)); if (f->Error == 0) if (p) - f->Write((uint8 *)Pal, 256 * 3); + f->write((uint8 *)_pal, 256 * 3); if (f->Error == 0) - f->Write(_v, n); + f->write(_v, n); return (f->Error == 0); } -bool Bitmap::VBMLoad(XFILE *f) { +bool Bitmap::loadVBM(XFILE *f) { uint16 p = 0, n = 0; if (f->Error == 0) - f->Read((uint8 *)&p, sizeof(p)); + f->read((uint8 *)&p, sizeof(p)); if (f->Error == 0) - f->Read((uint8 *)&n, sizeof(n)); + f->read((uint8 *)&n, sizeof(n)); if (f->Error == 0) - f->Read((uint8 *)&_w, sizeof(_w)); + f->read((uint8 *)&_w, sizeof(_w)); if (f->Error == 0) - f->Read((uint8 *)&_h, sizeof(_h)); + f->read((uint8 *)&_h, sizeof(_h)); if (f->Error == 0) { if (p) { - if (Pal) { + if (_pal) { byte palData[PAL_SIZ]; - f->Read(palData, PAL_SIZ); - VGA::pal2DAC(palData, Pal); + f->read(palData, PAL_SIZ); + VGA::pal2DAC(palData, _pal); } else - f->Seek(f->Mark() + PAL_SIZ); + f->seek(f->mark() + PAL_SIZ); } } if ((_v = farnew(uint8, n)) == NULL) return false; if (f->Error == 0) - f->Read(_v, n); + f->read(_v, n); _b = (HideDesc *)(_v + n - _h * sizeof(HideDesc)); return (f->Error == 0); } -bool Bitmap::BMPLoad (XFILE * f) { +bool Bitmap::loadBMP(XFILE * f) { struct { char BM[2]; union { int16 len; int32 len_; }; @@ -445,19 +445,19 @@ bool Bitmap::BMPLoad (XFILE * f) { } hea; BGR4 bpal[256]; - f->Read((byte *)&hea, sizeof(hea)); + f->read((byte *)&hea, sizeof(hea)); if (f->Error == 0) { if (hea.hdr == 0x436L) { int16 i = (hea.hdr - sizeof(hea)) / sizeof(BGR4); - f->Read((byte *)&bpal, sizeof(bpal)); + f->read((byte *)&bpal, sizeof(bpal)); if (f->Error == 0) { - if (Pal) { - for (i = 0; i < 256; i ++) { - Pal[i].R = bpal[i].R; - Pal[i].G = bpal[i].G; - Pal[i].B = bpal[i].B; - } - Pal = NULL; + if (_pal) { + for (i = 0; i < 256; i ++) { + _pal[i].R = bpal[i].R; + _pal[i].G = bpal[i].G; + _pal[i].B = bpal[i].B; + } + _pal = NULL; } _h = hea.hig; _w = hea.wid; @@ -465,9 +465,9 @@ bool Bitmap::BMPLoad (XFILE * f) { int16 r = (4 - (hea.wid & 3)) % 4; byte buf[3]; int i; for (i = _h - 1; i >= 0; i--) { - f->Read(_m + (_w * i), _w); + f->read(_m + (_w * i), _w); if (r && f->Error == 0) - f->Read(buf, r); + f->read(buf, r); if (f->Error) break; } diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index cfa7830f39..b13912a3c6 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -60,33 +60,33 @@ struct HideDesc { #include "common/pack-end.h" class Bitmap { - bool BMPLoad(XFILE *f); - bool VBMLoad(XFILE *f); + bool loadBMP(XFILE *f); + bool loadVBM(XFILE *f); public: - static DAC *Pal; + static DAC *_pal; uint16 _w; uint16 _h; uint8 *_m; uint8 *_v; HideDesc *_b; - Bitmap(const char *fname, bool rem = true); + Bitmap(const char *fname, bool rem); Bitmap(uint16 w, uint16 h, uint8 *map); Bitmap(uint16 w, uint16 h, uint8 fill); Bitmap(const Bitmap &bmp); - ~Bitmap(void); + ~Bitmap(); + static void init(); static void deinit(); - - Bitmap *FlipH(void); - Bitmap *Code(); + Bitmap *flipH(); + Bitmap *code(); Bitmap &operator = (const Bitmap &bmp); - void Hide(int x, int y); - void Show(int x, int y); - void XShow(int x, int y); - bool SolidAt(int x, int y); - bool VBMSave(XFILE *f); - uint16 MoveVmap(uint8 *buf); + void hide(int x, int y); + void show(int x, int y); + void xShow(int x, int y); + bool solidAt(int x, int y); + bool saveVBM(XFILE *f); + uint16 moveVmap(uint8 *buf); }; diff --git a/engines/cge/boot.h b/engines/cge/boot.h index ab4dcde0e2..2dce0d6d16 100644 --- a/engines/cge/boot.h +++ b/engines/cge/boot.h @@ -37,42 +37,38 @@ namespace CGE { #define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ #define FreeBoot(b) free(b) -#ifndef EC -#define EC -#endif - -typedef struct { - uint8 Jmp[3]; // NEAR jump machine code - char OEM_ID[8]; // OEM name and version - uint16 SectSize; // bytes per sector - uint8 ClustSize; // sectors per cluster - uint16 ResSecs; // sectors before 1st FAT - uint8 FatCnt; // number of FATs - uint16 RootSize; // root directory entries - uint16 TotSecs; // total sectors on disk - uint8 Media; // media descriptor byte - uint16 FatSize; // sectors per FAT - uint16 TrkSecs; // sectors per track - uint16 HeadCnt; // number of sufraces - uint16 HidnSecs; // special hidden sectors - uint16 _; // (unknown: reserved?) - uint32 lTotSecs; // total number of sectors - uint16 DriveNum; // physical drive number - uint8 XSign; // extended boot signature - uint32 Serial; // volume serial number - char Label[11]; // volume label - char FileSysID[8]; // file system ID - char Code[BOOTCODE_SIZ - 8]; // 8 = length of following - uint32 Secret; // long secret number - uint8 BootCheck; // boot sector checksum - uint8 BootFlags; // secret flags - uint16 BootSig; // boot signature 0xAA55 -} Boot; +struct Boot { + uint8 _jmp[3]; // NEAR jump machine code + char _idOEM[8]; // OEM name and version + uint16 _sectSize; // bytes per sector + uint8 _clustSize; // sectors per cluster + uint16 _resSecs; // sectors before 1st FAT + uint8 _fatCnt; // number of FATs + uint16 _rootSize; // root directory entries + uint16 _totSecs; // total sectors on disk + uint8 _media; // media descriptor byte + uint16 _fatSize; // sectors per FAT + uint16 _trkSecs; // sectors per track + uint16 _headCnt; // number of sufraces + uint16 _hidnSecs; // special hidden sectors + uint16 __; // (unknown: reserved?) + uint32 _lTotSecs; // total number of sectors + uint16 _driveNum; // physical drive number + uint8 _xSign; // extended boot signature + uint32 _serial; // volume serial number + char _label[11]; // volume label + char _fileSysID[8]; // file system ID + char _code[BOOTCODE_SIZ - 8]; // 8 = length of following + uint32 _secret; // long secret number + uint8 _bootCheck; // boot sector checksum + uint8 _bootFlags; // secret flags + uint16 _bootSig; // boot signature 0xAA55 +}; -EC Boot *ReadBoot(int drive); -EC uint8 CheckBoot(Boot *boot); -EC bool WriteBoot(int drive, Boot *boot); +Boot *readBoot(int drive); +uint8 checkBoot(Boot *boot); +bool writeBoot(int drive, Boot *boot); } // End of namespace CGE diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index db0ebc2d5f..8255775fd1 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -40,80 +40,80 @@ namespace CGE { #define BT_KEYLEN 13 #endif -BTFILE::BTFILE(const char *name, IOMODE mode, CRYPT *crpt) - : IOHAND(name, mode, crpt) { +BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) + : IoHand(name, mode, crpt) { for (int i = 0; i < BT_LEVELS; i++) { - Buff[i].Page = new BT_PAGE; - Buff[i].PgNo = BT_NONE; - Buff[i].Indx = -1; - Buff[i].Updt = false; - if (Buff[i].Page == NULL) + _buff[i]._page = new BtPage; + _buff[i]._pgNo = BT_NONE; + _buff[i]._indx = -1; + _buff[i]._updt = false; + if (_buff[i]._page == NULL) error("No core"); } } -BTFILE::~BTFILE(void) { +BtFile::~BtFile(void) { for (int i = 0; i < BT_LEVELS; i++) { - PutPage(i); - delete Buff[i].Page; + putPage(i); + delete _buff[i]._page; } } -void BTFILE::PutPage(int lev, bool hard) { - if (hard || Buff[lev].Updt) { - Seek(Buff[lev].PgNo * sizeof(BT_PAGE)); - Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); - Buff[lev].Updt = false; +void BtFile::putPage(int lev, bool hard) { + if (hard || _buff[lev]._updt) { + seek(_buff[lev]._pgNo * sizeof(BtPage)); + write((uint8 *) _buff[lev]._page, sizeof(BtPage)); + _buff[lev]._updt = false; } } -BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) { - if (Buff[lev].PgNo != pgn) { - int32 pos = pgn * sizeof(BT_PAGE); - PutPage(lev); - Buff[lev].PgNo = pgn; - if (Size() > pos) { - Seek((uint32) pgn * sizeof(BT_PAGE)); - Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE)); - Buff[lev].Updt = false; +BtPage *BtFile::getPage(int lev, uint16 pgn) { + if (_buff[lev]._pgNo != pgn) { + int32 pos = pgn * sizeof(BtPage); + putPage(lev); + _buff[lev]._pgNo = pgn; + if (size() > pos) { + seek((uint32) pgn * sizeof(BtPage)); + read((uint8 *) _buff[lev]._page, sizeof(BtPage)); + _buff[lev]._updt = false; } else { - Buff[lev].Page->Hea.Count = 0; - Buff[lev].Page->Hea.Down = BT_NONE; - memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data)); - Buff[lev].Updt = true; + _buff[lev]._page->_hea._count = 0; + _buff[lev]._page->_hea._down = BT_NONE; + memset(_buff[lev]._page->_data, '\0', sizeof(_buff[lev]._page->_data)); + _buff[lev]._updt = true; } - Buff[lev].Indx = -1; + _buff[lev]._indx = -1; } - return Buff[lev].Page; + return _buff[lev]._page; } -BT_KEYPACK *BTFILE::Find(const char *key) { +BtKeypack *BtFile::find(const char *key) { int lev = 0; uint16 nxt = BT_ROOT; while (! Error) { - BT_PAGE *pg = GetPage(lev, nxt); + BtPage *pg = getPage(lev, nxt); // search - if (pg->Hea.Down != BT_NONE) { + if (pg->_hea._down != BT_NONE) { int i; - for (i = 0; i < pg->Hea.Count; i++) { + for (i = 0; i < pg->_hea._count; i++) { // Does this work, or does it have to compare the entire buffer? - if (scumm_strnicmp((const char *) key, (const char*)pg->Inn[i].Key, BT_KEYLEN) < 0) + if (scumm_strnicmp((const char *)key, (const char*)pg->_inn[i]._key, BT_KEYLEN) < 0) break; } - nxt = (i) ? pg->Inn[i - 1].Down : pg->Hea.Down; - Buff[lev].Indx = i - 1; - ++ lev; + nxt = (i) ? pg->_inn[i - 1]._down : pg->_hea._down; + _buff[lev]._indx = i - 1; + lev++; } else { int i; - for (i = 0; i < pg->Hea.Count - 1; i++) { - if (scumm_stricmp((const char *)key, (const char *)pg->Lea[i].Key) <= 0) + for (i = 0; i < pg->_hea._count - 1; i++) { + if (scumm_stricmp((const char *)key, (const char *)pg->_lea[i]._key) <= 0) break; } - Buff[lev].Indx = i; - return &pg->Lea[i]; + _buff[lev]._indx = i; + return &pg->_lea[i]; } } return NULL; @@ -125,26 +125,26 @@ int keycomp(const void *k1, const void *k2) { } -void BTFILE::Make(BT_KEYPACK *keypack, uint16 count) { +void BtFile::make(BtKeypack *keypack, uint16 count) { #if BT_LEVELS != 2 #error This tiny BTREE implementation works with exactly 2 levels! #endif _fqsort(keypack, count, sizeof(*keypack), keycomp); uint16 n = 0; - BT_PAGE *Root = GetPage(0, n++), - *Leaf = GetPage(1, n); - Root->Hea.Down = n; - PutPage(0, true); + BtPage *Root = getPage(0, n++); + BtPage *Leaf = getPage(1, n); + Root->_hea._down = n; + putPage(0, true); while (count--) { - if (Leaf->Hea.Count >= ArrayCount(Leaf->Lea)) { - PutPage(1, true); // save filled page - Leaf = GetPage(1, ++n); // take empty page - memcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN); - Root->Inn[Root->Hea.Count++].Down = n; - Buff[0].Updt = true; + if (Leaf->_hea._count >= ArrayCount(Leaf->_lea)) { + putPage(1, true); // save filled page + Leaf = getPage(1, ++n); // take empty page + memcpy(Root->_inn[Root->_hea._count]._key, keypack->_key, BT_KEYLEN); + Root->_inn[Root->_hea._count++]._down = n; + _buff[0]._updt = true; } - Leaf->Lea[Leaf->Hea.Count++] = *(keypack++); - Buff[1].Updt = true; + Leaf->_lea[Leaf->_hea._count++] = *(keypack++); + _buff[1]._updt = true; } } diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 449f200140..3fd3175798 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -41,50 +41,53 @@ namespace CGE { #include "common/pack-start.h" // START STRUCT PACKING -struct BT_KEYPACK { - char Key[BT_KEYLEN]; - uint32 Mark; - uint16 Size; +struct BtKeypack { + char _key[BT_KEYLEN]; + uint32 _mark; + uint16 _size; }; -typedef struct { - uint8 Key[BT_KEYLEN]; - uint16 Down; -} INNER; +struct Inner { + uint8 _key[BT_KEYLEN]; + uint16 _down; +}; + +struct Hea { + uint16 _count; + uint16 _down; +}; -struct BT_PAGE { - struct HEA { - uint16 Count; - uint16 Down; - } Hea; +struct BtPage { + Hea _hea; union { // dummy filler to make proper size of union - uint8 Data[BT_SIZE - sizeof(HEA)]; + uint8 _data[BT_SIZE - sizeof(Hea)]; // inner version of data: key + word-sized page link - INNER Inn[(BT_SIZE - sizeof(HEA)) / sizeof(INNER)]; + Inner _inn[(BT_SIZE - sizeof(Hea)) / sizeof(Inner)]; // leaf version of data: key + all user data - BT_KEYPACK Lea[(BT_SIZE - sizeof(HEA)) / sizeof(BT_KEYPACK)]; + BtKeypack _lea[(BT_SIZE - sizeof(Hea)) / sizeof(BtKeypack)]; }; }; #include "common/pack-end.h" // END STRUCT PACKING -class BTFILE : public IOHAND { +class BtFile : public IoHand { struct { - BT_PAGE *Page; - uint16 PgNo; - int Indx; - bool Updt; - } Buff[BT_LEVELS]; - void PutPage(int lev, bool hard = false); - BT_PAGE *GetPage(int lev, uint16 pgn); + BtPage *_page; + uint16 _pgNo; + int _indx; + bool _updt; + } _buff[BT_LEVELS]; + + void putPage(int lev, bool hard = false); + BtPage *getPage(int lev, uint16 pgn); public: - BTFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); - virtual ~BTFILE(void); - BT_KEYPACK *Find(const char *key); - BT_KEYPACK *Next(void); - void Make(BT_KEYPACK *keypack, uint16 count); + BtFile(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); + virtual ~BtFile(); + BtKeypack *find(const char *key); + BtKeypack *next(); + void make(BtKeypack *keypack, uint16 count); }; } // End of namespace CGE diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 85e51a94c1..9a2b697bd7 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -32,65 +32,65 @@ namespace CGE { -IOBUF::IOBUF(IOMODE mode, CRYPT *crpt) - : IOHAND(mode, crpt), - BufMark(0), - Ptr(0), - Lim(0) { - Buff = farnew(uint8, IOBUF_SIZE); - if (Buff == NULL) +IoBuf::IoBuf(IOMODE mode, CRYPT *crpt) + : IoHand(mode, crpt), + _bufMark(0), + _ptr(0), + _lim(0) { + _buff = farnew(uint8, IOBUF_SIZE); + if (_buff == NULL) error("No core for I/O"); } -IOBUF::IOBUF(const char *name, IOMODE mode, CRYPT *crpt) - : IOHAND(name, mode, crpt), - BufMark(0), - Ptr(0), - Lim(0) { - Buff = farnew(uint8, IOBUF_SIZE); - if (Buff == NULL) +IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) + : IoHand(name, mode, crpt), + _bufMark(0), + _ptr(0), + _lim(0) { + _buff = farnew(uint8, IOBUF_SIZE); + if (_buff == NULL) error("No core for I/O [%s]", name); } -IOBUF::~IOBUF(void) { +IoBuf::~IoBuf(void) { if (Mode > REA) - WriteBuff(); - if (Buff) - free(Buff); + writeBuff(); + if (_buff) + free(_buff); } -void IOBUF::ReadBuff(void) { - BufMark = IOHAND::Mark(); - Lim = IOHAND::Read(Buff, IOBUF_SIZE); - Ptr = 0; +void IoBuf::readBuff(void) { + _bufMark = IoHand::mark(); + _lim = IoHand::read(_buff, IOBUF_SIZE); + _ptr = 0; } -void IOBUF::WriteBuff(void) { - if (Lim) { - IOHAND::Write(Buff, Lim); - BufMark = IOHAND::Mark(); - Lim = 0; +void IoBuf::writeBuff(void) { + if (_lim) { + IoHand::write(_buff, _lim); + _bufMark = IoHand::mark(); + _lim = 0; } } -uint16 IOBUF::Read(void *buf, uint16 len) { +uint16 IoBuf::read(void *buf, uint16 len) { uint16 total = 0; while (len) { - if (Ptr >= Lim) - ReadBuff(); - uint16 n = Lim - Ptr; + if (_ptr >= _lim) + readBuff(); + uint16 n = _lim - _ptr; if (n) { if (len < n) n = len; - memcpy(buf, Buff + Ptr, n); + memcpy(buf, _buff + _ptr, n); buf = (uint8 *)buf + n; len -= n; total += n; - Ptr += n; + _ptr += n; } else break; } @@ -98,14 +98,14 @@ uint16 IOBUF::Read(void *buf, uint16 len) { } -uint16 IOBUF::Read(uint8 *buf) { +uint16 IoBuf::read(uint8 *buf) { uint16 total = 0; while (total < LINE_MAX - 2) { - if (Ptr >= Lim) - ReadBuff(); - uint8 *p = Buff + Ptr; - uint16 n = Lim - Ptr; + if (_ptr >= _lim) + readBuff(); + uint8 *p = _buff + _ptr; + uint16 n = _lim - _ptr; if (n) { if (total + n >= LINE_MAX - 2) n = LINE_MAX - 2 - total; @@ -115,7 +115,7 @@ uint16 IOBUF::Read(uint8 *buf) { uint8 *eof = (uint8 *) memchr(p, '\32', n); if (eof) { // end-of-file n = (uint16)(eof - p); - Ptr = (uint16)(eof - Buff); + _ptr = (uint16)(eof - _buff); } if (n) memcpy(buf, p, n); @@ -123,16 +123,16 @@ uint16 IOBUF::Read(uint8 *buf) { total += n; if (eof) break; - Ptr += n; + _ptr += n; if (eol) { - ++ Ptr; + _ptr++; *(buf++) = '\n'; - ++ total; - if (Ptr >= Lim) - ReadBuff(); - if (Ptr < Lim) - if (Buff[Ptr] == '\n') - ++Ptr; + total++; + if (_ptr >= _lim) + readBuff(); + if (_ptr < _lim) + if (_buff[_ptr] == '\n') + ++_ptr; break; } } else @@ -143,36 +143,36 @@ uint16 IOBUF::Read(uint8 *buf) { } -uint16 IOBUF::Write(void *buf, uint16 len) { +uint16 IoBuf::write(void *buf, uint16 len) { uint16 tot = 0; while (len) { - uint16 n = IOBUF_SIZE - Lim; + uint16 n = IOBUF_SIZE - _lim; if (n > len) n = len; if (n) { - memcpy(Buff + Lim, buf, n); - Lim += n; + memcpy(_buff + _lim, buf, n); + _lim += n; len -= n; buf = (uint8 *)buf + n; tot += n; } else - WriteBuff(); + writeBuff(); } return tot; } -uint16 IOBUF::Write(uint8 *buf) { +uint16 IoBuf::write(uint8 *buf) { uint16 len = 0; if (buf) { len = strlen((const char *) buf); if (len) if (buf[len - 1] == '\n') --len; - len = Write(buf, len); + len = write(buf, len); if (len) { static char EOL[] = "\r\n"; - uint16 n = Write(EOL, sizeof(EOL) - 1); + uint16 n = write(EOL, sizeof(EOL) - 1); len += n; } } @@ -180,40 +180,40 @@ uint16 IOBUF::Write(uint8 *buf) { } -int IOBUF::Read(void) { - if (Ptr >= Lim) { - ReadBuff(); - if (Lim == 0) +int IoBuf::read() { + if (_ptr >= _lim) { + readBuff(); + if (_lim == 0) return -1; } - return Buff[Ptr++]; + return _buff[_ptr++]; } -void IOBUF::Write(uint8 b) { - if (Lim >= IOBUF_SIZE) - WriteBuff(); - Buff[Lim++] = b; +void IoBuf::write(uint8 b) { + if (_lim >= IOBUF_SIZE) + writeBuff(); + _buff[_lim++] = b; } -uint16 CFILE::MaxLineLen = LINE_MAX; +uint16 CFile::_maxLineLen = LINE_MAX; -CFILE::CFILE(const char *name, IOMODE mode, CRYPT *crpt) - : IOBUF(name, mode, crpt) { +CFile::CFile(const char *name, IOMODE mode, CRYPT *crpt) + : IoBuf(name, mode, crpt) { } -CFILE::~CFILE(void) { +CFile::~CFile(void) { } -void CFILE::Flush(void) { +void CFile::flush(void) { if (Mode > REA) - WriteBuff(); + writeBuff(); else - Lim = 0; + _lim = 0; /* _BX = Handle; @@ -224,33 +224,33 @@ void CFILE::Flush(void) { } -long CFILE::Mark(void) { - return BufMark + ((Mode > REA) ? Lim : Ptr); +long CFile::mark(void) { + return _bufMark + ((Mode > REA) ? _lim : _ptr); } -long CFILE::Seek(long pos) { - if (pos >= BufMark && pos < BufMark + Lim) { - ((Mode == REA) ? Ptr : Lim) = (uint16)(pos - BufMark); +long CFile::seek(long pos) { + if (pos >= _bufMark && pos < _bufMark + _lim) { + ((Mode == REA) ? _ptr : _lim) = (uint16)(pos - _bufMark); return pos; } else { if (Mode > REA) - WriteBuff(); + writeBuff(); else - Lim = 0; + _lim = 0; - Ptr = 0; - return BufMark = IOHAND::Seek(pos); + _ptr = 0; + return _bufMark = IoHand::seek(pos); } } -void CFILE::Append(CFILE &f) { - Seek(Size()); +void CFile::append(CFile &f) { + seek(size()); if (f.Error == 0) { while (true) { - if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) - WriteBuff(); + if ((_lim = f.IoHand::read(_buff, IOBUF_SIZE)) == IOBUF_SIZE) + writeBuff(); else break; if ((Error = f.Error) != 0) diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index f045c48c0f..376e50ae44 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -38,40 +38,41 @@ namespace CGE { #define IOBUF_SIZE K(2) #endif -#define CFREAD(x) Read((uint8 *)(x),sizeof(*(x))) +#define CFREAD(x) read((uint8 *)(x),sizeof(*(x))) -class IOBUF : public IOHAND { +class IoBuf : public IoHand { protected: - uint8 *Buff; - uint16 Ptr, Lim; - long BufMark; - uint16 Seed; - CRYPT *Crypt; - virtual void ReadBuff(void); - virtual void WriteBuff(void); + uint8 *_buff; + uint16 _ptr; + uint16 _lim; + long _bufMark; + uint16 _seed; + CRYPT *_crypt; + virtual void readBuff(); + virtual void writeBuff(); public: - IOBUF(IOMODE mode, CRYPT *crpt = NULL); - IOBUF(const char *name, IOMODE mode, CRYPT *crpt = NULL); - virtual ~IOBUF(void); - uint16 Read(void *buf, uint16 len); - uint16 Read(uint8 *buf); - int Read(void); - uint16 Write(void *buf, uint16 len); - uint16 Write(uint8 *buf); - void Write(uint8 b); + IoBuf(IOMODE mode, CRYPT *crpt = NULL); + IoBuf(const char *name, IOMODE mode, CRYPT *crpt = NULL); + virtual ~IoBuf(); + uint16 read(void *buf, uint16 len); + uint16 read(uint8 *buf); + int read(); + uint16 write(void *buf, uint16 len); + uint16 write(uint8 *buf); + void write(uint8 b); }; -class CFILE : public IOBUF { +class CFile : public IoBuf { public: - static uint16 MaxLineLen; - CFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); - virtual ~CFILE(void); - void Flush(void); - long Mark(void); - long Seek(long pos); - void Append(CFILE &f); + static uint16 _maxLineLen; + CFile(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); + virtual ~CFile(); + void flush(); + long mark(); + long seek(long pos); + void append(CFile &f); }; } // End of namespace CGE diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 885aa4d492..c921d7c6ba 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -77,22 +77,22 @@ void CGEEngine::setup() { InfoLine = new INFO_LINE(this, INFO_W); _cavLight = new Sprite(this, PR); DebugLine = new INFO_LINE(this, SCR_WID); - MB[0] = new Bitmap("BRICK"); + MB[0] = new Bitmap("BRICK", true); MB[1] = NULL; - HL[0] = new Bitmap("HLINE"); + HL[0] = new Bitmap("HLINE", true); HL[1] = NULL; - MC[0] = new Bitmap("MOUSE"); - MC[1] = new Bitmap("DUMMY"); + MC[0] = new Bitmap("MOUSE", true); + MC[1] = new Bitmap("DUMMY", true); MC[2] = NULL; - PR[0] = new Bitmap("PRESS"); + PR[0] = new Bitmap("PRESS", true); PR[1] = NULL; - SP[0] = new Bitmap("SPK_L"); - SP[1] = new Bitmap("SPK_R"); + SP[0] = new Bitmap("SPK_L", true); + SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; - LI[0] = new Bitmap("LITE0"); - LI[1] = new Bitmap("LITE1"); - LI[2] = new Bitmap("LITE2"); - LI[3] = new Bitmap("LITE3"); + LI[0] = new Bitmap("LITE0", true); + LI[1] = new Bitmap("LITE1", true); + LI[2] = new Bitmap("LITE2", true); + LI[3] = new Bitmap("LITE3", true); LI[4] = NULL; Snail = new SNAIL(this, false); Snail_ = new SNAIL(this, true); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 1e1b952f77..035c4dc317 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -257,10 +257,10 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { for (st = _savTab; st->Ptr; st++) { if (file.Error) error("Bad SVG"); - file.Read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len); + file.read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len); } - file.Read((uint8 *) &i, sizeof(i)); + file.read((uint8 *) &i, sizeof(i)); if (i != SVGCHKSUM) error("%s", Text->getText(BADSVG_TEXT)); @@ -276,7 +276,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { if (! tiny) { // load sprites & pocket while (! file.Error) { Sprite S(this, NULL); - uint16 n = file.Read((uint8 *) &S, sizeof(S)); + uint16 n = file.read((uint8 *) &S, sizeof(S)); if (n != sizeof(S)) break; @@ -299,8 +299,9 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { static void SaveSound(void) { - CFILE cfg(UsrPath(ProgName(CFG_EXT)), WRI); - if (! cfg.Error) cfg.Write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2)); + CFile cfg(UsrPath(ProgName(CFG_EXT)), WRI); + if (! cfg.Error) + cfg.write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2)); } @@ -320,15 +321,15 @@ static void SaveGame(XFILE &file) { for (st = _savTab; st->Ptr; st++) { if (file.Error) error("Bad SVG"); - file.Write((uint8 *) st->Ptr, st->Len); + file.write((uint8 *) st->Ptr, st->Len); } - file.Write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); + file.write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); for (spr = Vga->SpareQ->First(); spr; spr = spr->_next) if (spr->_ref >= 1000) if (!file.Error) - file.Write((uint8 *)spr, sizeof(*spr)); + file.write((uint8 *)spr, sizeof(*spr)); } @@ -376,8 +377,8 @@ static void LoadMapping(void) { INI_FILE cf(ProgName(".TAB")); if (! cf.Error) { memset(CLUSTER::Map, 0, sizeof(CLUSTER::Map)); - cf.Seek((Now - 1) * sizeof(CLUSTER::Map)); - cf.Read((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); + cf.seek((Now - 1) * sizeof(CLUSTER::Map)); + cf.read((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); } } } @@ -675,9 +676,9 @@ void SYSTEM::FunTouch(void) { static void ShowBak(int ref) { Sprite *spr = Vga->SpareQ->Locate(ref); if (spr) { - Bitmap::Pal = VGA::SysPal; + Bitmap::_pal = VGA::SysPal; spr->Expand(); - Bitmap::Pal = NULL; + Bitmap::_pal = NULL; spr->Show(2); Vga->CopyPage(1, 2); Sys->SetPal(); @@ -776,7 +777,7 @@ void CGEEngine::QGame() { CaveDown(); OldLev = Lev; SaveSound(); - CFILE file = CFILE(UsrPath(UsrFnam), WRI, RCrypt); + CFile file = CFile(UsrPath(UsrFnam), WRI, RCrypt); SaveGame(file); Vga->Sunset(); Finis = true; @@ -1145,18 +1146,18 @@ static void NextStep(void) { static void SaveMapping(void) { { - IOHAND cf(ProgName(".TAB"), UPD); + IoHand cf(ProgName(".TAB"), UPD); if (!cf.Error) { - cf.Seek((Now - 1) * sizeof(CLUSTER::Map)); - cf.Write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); + cf.seek((Now - 1) * sizeof(CLUSTER::Map)); + cf.write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); } } { - IOHAND cf(ProgName(".HXY"), WRI); + IoHand cf(ProgName(".HXY"), WRI); if (!cf.Error) { HeroXY[Now - 1]._x = Hero->_x; HeroXY[Now - 1]._y = Hero->_y; - cf.Write((uint8 *) HeroXY, sizeof(HeroXY)); + cf.write((uint8 *) HeroXY, sizeof(HeroXY)); } } } @@ -1345,12 +1346,12 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int uint16 len; MergeExt(line, fname, SPR_EXT); - if (INI_FILE::Exist(line)) { // sprite description file exist + if (INI_FILE::exist(line)) { // sprite description file exist INI_FILE sprf(line); if (sprf.Error) error("Bad SPR [%s]", line); - while ((len = sprf.Read((uint8 *)line)) != 0) { + while ((len = sprf.read((uint8 *)line)) != 0) { ++ lcnt; if (len && line[len - 1] == '\n') line[-- len] = '\0'; @@ -1490,7 +1491,7 @@ void CGEEngine::LoadScript(const char *fname) { if (scrf.Error) return; - while (scrf.Read((uint8 *)line) != 0) { + while (scrf.read((uint8 *)line) != 0) { char *p; ++lcnt; @@ -1566,7 +1567,7 @@ void CGEEngine::MainLoop() { void CGEEngine::LoadUser() { // set scene if (STARTUP::Mode == 0) { // user .SVG file found - CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt); + CFile cfile = CFile(UsrPath(UsrFnam), REA, RCrypt); LoadGame(cfile); } else { if (STARTUP::Mode == 1) { @@ -1575,7 +1576,7 @@ void CGEEngine::LoadUser() { } else { LoadScript(ProgName(INI_EXT)); Music = true; - CFILE file = CFILE(SVG0NAME, WRI); + CFile file = CFile(SVG0NAME, WRI); SaveGame(file); error("Ok [%s]", SVG0NAME); } @@ -1623,7 +1624,7 @@ void CGEEngine::RunGame() { if (! Music) KillMIDI(); - if (Mini && INI_FILE::Exist("MINI.SPR")) { + if (Mini && INI_FILE::exist("MINI.SPR")) { uint8 *ptr = (uint8 *) &*Mini; if (ptr != NULL) { LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); @@ -1641,7 +1642,7 @@ void CGEEngine::RunGame() { if (Hero) { ExpandSprite(Hero); Hero->Goto(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); - if (INI_FILE::Exist("00SHADOW.SPR")) { + if (INI_FILE::exist("00SHADOW.SPR")) { LoadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51); if ((_shadow = _sprite) != NULL) { _shadow->_ref = 2; @@ -1698,7 +1699,7 @@ void CGEEngine::RunGame() { void CGEEngine::Movie(const char *ext) { const char *fn = ProgName(ext); - if (INI_FILE::Exist(fn)) { + if (INI_FILE::exist(fn)) { LoadScript(fn); ExpandSprite(Vga->SpareQ->Locate(999)); FeedSnail(Vga->ShowQ->Locate(999), TAKE); @@ -1722,9 +1723,9 @@ void CGEEngine::Movie(const char *ext) { bool CGEEngine::ShowTitle(const char *name) { - Bitmap::Pal = VGA::SysPal; - BMP_PTR LB[] = { new Bitmap(name), NULL }; - Bitmap::Pal = NULL; + Bitmap::_pal = VGA::SysPal; + BMP_PTR LB[] = { new Bitmap(name, true), NULL }; + Bitmap::_pal = NULL; bool usr_ok = false; Sprite D(this, LB); @@ -1774,7 +1775,7 @@ bool CGEEngine::ShowTitle(const char *name) { // Boot * b = ReadBoot(getdisk()); warning("ShowTitle: FIXME ReadBoot"); Boot *b = ReadBoot(0); - uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs; + uint32 sn = (b->_xSign == 0x29) ? b->_serial : b->_lTotSecs; free(b); sn -= ((IDENT *)Copr)->disk; STARTUP::Summa |= Lo(sn) | Hi(sn); @@ -1801,8 +1802,8 @@ bool CGEEngine::ShowTitle(const char *name) { if (usr_ok && STARTUP::Mode == 0) { const char *n = UsrPath(UsrFnam); - if (CFILE::Exist(n)) { - CFILE file = CFILE(n, REA, RCrypt); + if (CFile::exist(n)) { + CFile file = CFile(n, REA, RCrypt); LoadGame(file, true); // only system vars Vga->SetColors(VGA::SysPal, 64); Vga->Update(); @@ -1846,7 +1847,7 @@ void CGEEngine::cge_main(void) { if (!Mouse->Exist) error("%s", Text->getText(NO_MOUSE_TEXT)); - if (!SVG0FILE::Exist(SVG0NAME)) + if (!SVG0FILE::exist(SVG0NAME)) STARTUP::Mode = 2; DebugLine->_flags._hide = true; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 7bf753ff9f..510456087f 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -211,13 +211,13 @@ char *dwtom(uint32 val, char *str, int radix, int len) { return str; } -IOHAND::IOHAND(IOMODE mode, CRYPT *crpt) - : XFILE(mode), Crypt(crpt), Seed(SEED) { +IoHand::IoHand(IOMODE mode, CRYPT *crpt) + : XFILE(mode), _crypt(crpt), _seed(SEED) { _file = new Common::File(); } -IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt) - : XFILE(mode), Crypt(crpt), Seed(SEED) { +IoHand::IoHand(const char *name, IOMODE mode, CRYPT *crpt) + : XFILE(mode), _crypt(crpt), _seed(SEED) { // TODO: Check if WRI and/or UPD modes are needed, and map to a save file assert(mode == REA); @@ -225,24 +225,24 @@ IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt) _file->open(name); } -IOHAND::~IOHAND(void) { +IoHand::~IoHand(void) { _file->close(); delete _file; } -uint16 IOHAND::Read(void *buf, uint16 len) { +uint16 IoHand::read(void *buf, uint16 len) { if (Mode == WRI || !_file->isOpen()) return 0; uint16 bytesRead = _file->read(buf, len); if (!bytesRead) error("Read %s - %d bytes", _file->getName(), len); - if (Crypt) - Seed = Crypt(buf, len, Seed); + if (_crypt) + _seed = _crypt(buf, len, Seed); return bytesRead; } -uint16 IOHAND::Write(void *buf, uint16 len) { +uint16 IoHand::write(void *buf, uint16 len) { error("IOHAND::Write not supported"); /* if (len) { @@ -258,20 +258,20 @@ uint16 IOHAND::Write(void *buf, uint16 len) { */ } -long IOHAND::Mark(void) { +long IoHand::mark(void) { return _file->pos(); } -long IOHAND::Seek(long pos) { +long IoHand::seek(long pos) { _file->seek(pos, SEEK_SET); return _file->pos(); } -long IOHAND::Size(void) { +long IoHand::size(void) { return _file->size(); } -bool IOHAND::Exist(const char *name) { +bool IoHand::exist(const char *name) { Common::File f; return f.exists(name); } diff --git a/engines/cge/general.h b/engines/cge/general.h index 4946e40c7b..1ecec9fbe9 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -168,36 +168,36 @@ public: uint16 Error; XFILE(void) : Mode(REA), Error(0) { } XFILE(IOMODE mode) : Mode(mode), Error(0) { } - virtual uint16 Read(void *buf, uint16 len) = 0; - virtual uint16 Write(void *buf, uint16 len) = 0; - virtual long Mark(void) = 0; - virtual long Size(void) = 0; - virtual long Seek(long pos) = 0; + virtual uint16 read(void *buf, uint16 len) = 0; + virtual uint16 write(void *buf, uint16 len) = 0; + virtual long mark(void) = 0; + virtual long size(void) = 0; + virtual long seek(long pos) = 0; virtual ~XFILE() { } }; template inline uint16 XRead(XFILE *xf, T *t) { - return xf->Read((uint8 *) t, sizeof(*t)); + return xf->read((uint8 *) t, sizeof(*t)); } -class IOHAND : public XFILE { +class IoHand : public XFILE { protected: Common::File *_file; - uint16 Seed; - CRYPT *Crypt; + uint16 _seed; + CRYPT *_crypt; public: - IOHAND(const char *name, IOMODE mode = REA, CRYPT crypt = NULL); - IOHAND(IOMODE mode = REA, CRYPT *crpt = NULL); - virtual ~IOHAND(void); - static bool Exist(const char *name); - uint16 Read(void *buf, uint16 len); - uint16 Write(void *buf, uint16 len); - long Mark(void); - long Size(void); - long Seek(long pos); + IoHand(const char *name, IOMODE mode = REA, CRYPT crypt = NULL); + IoHand(IOMODE mode = REA, CRYPT *crpt = NULL); + virtual ~IoHand(); + static bool exist(const char *name); + uint16 read(void *buf, uint16 len); + uint16 write(void *buf, uint16 len); + long mark(); + long size(); + long seek(long pos); //timeb Time (void); // void SetTime (timeb t); }; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 7b9ce59f5e..a5ef5b8b62 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -42,7 +42,7 @@ bool MIXER::Appear = false; MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _vm(vm) { Appear = true; - mb[0] = new Bitmap("VOLUME"); + mb[0] = new Bitmap("VOLUME", true); mb[1] = NULL; SetShapeList(mb); SetName(Text->getText(MIX_NAME)); @@ -58,7 +58,7 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _v for (i = 0; i < MIX_MAX; i++) { static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); - lb[i] = new Bitmap(fn); + lb[i] = new Bitmap(fn, true); ls[i].Now = ls[i].Next = i; ls[i].Dx = ls[i].Dy = ls[i].Dly = 0; } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 565c7d33f0..e9d9b4643f 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -575,12 +575,12 @@ void SNSend(Sprite *spr, int val) { spr->_flags._slav = false; } else { if (spr->_ref % 1000 == 0) - Bitmap::Pal = VGA::SysPal; + Bitmap::_pal = VGA::SysPal; if (spr->_flags._back) spr->BackShow(true); else ExpandSprite(spr); - Bitmap::Pal = NULL; + Bitmap::_pal = NULL; } } } diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 4a7b63fb08..eecd3bacb2 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -187,14 +187,14 @@ void KillMIDI(void) { void LoadMIDI(int ref) { static char fn[] = "00.MID"; wtom(ref, fn, 10, 2); - if (INI_FILE::Exist(fn)) { + if (INI_FILE::exist(fn)) { KillMIDI(); INI_FILE mid = fn; if (mid.Error == 0) { - uint16 siz = (uint16) mid.Size(); + uint16 siz = (uint16) mid.size(); midi = new uint8[siz]; if (midi) { - mid.Read(midi, siz); + mid.read(midi, siz); if (mid.Error) KillMIDI(); else @@ -212,10 +212,10 @@ EC void *Patch(int pat) { wtom(pat, fn + 5, 10, 3); INI_FILE snd = fn; if (! snd.Error) { - uint16 siz = (uint16) snd.Size(); + uint16 siz = (uint16) snd.size(); p = (uint8 *) malloc(siz); if (p) { - snd.Read(p, siz); + snd.read(p, siz); if (snd.Error) { free(p); p = NULL; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 5aa5e44b8d..c8aa8292e8 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -53,24 +53,24 @@ FONT::FONT(const char *name) { } -FONT::~FONT(void) { +FONT::~FONT() { free(Map); free(Pos); free(Wid); } -void FONT::Load(void) { +void FONT::Load() { INI_FILE f(Path); if (! f.Error) { - f.Read(Wid, WID_SIZ); + f.read(Wid, WID_SIZ); if (! f.Error) { uint16 i, p = 0; for (i = 0; i < POS_SIZ; i++) { Pos[i] = p; p += Wid[i]; } - f.Read(Map, p); + f.read(Map, p); } } } @@ -181,7 +181,7 @@ void TALK::Update(const char *tx) { } tx++; } - TS[0]->Code(); + TS[0]->code(); SetShapeList(TS); } diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 7b191b492b..7df51f1126 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -45,7 +45,7 @@ TALK *Talk = NULL; TEXT::TEXT(CGEEngine *vm, const char *fname, int size) : _vm(vm) { Cache = new HAN[size]; MergeExt(FileName, fname, SAY_EXT); - if (!INI_FILE::Exist(FileName)) + if (!INI_FILE::exist(FileName)) error("No talk (%s)\n", FileName); for (Size = 0; Size < size; Size++) { @@ -93,7 +93,7 @@ void TEXT::Preload(int from, int upto) { char line[LINE_MAX + 1]; int n; - while ((n = tf.Read((uint8 *)line)) != 0) { + while ((n = tf.read((uint8 *)line)) != 0) { char *s; int ref; @@ -135,7 +135,7 @@ char *TEXT::Load(int idx, int ref) { char line[LINE_MAX + 1]; int n; - while ((n = tf.Read((uint8 *)line)) != 0) { + while ((n = tf.read((uint8 *)line)) != 0) { char *s; if (line[n - 1] == '\n') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 673d6036d8..f26d202dca 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -417,7 +417,7 @@ BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { void Sprite::MoveShapes(uint8 *buf) { BMP_PTR *p; for (p = _ext->_shpList; *p; p++) { - buf += (*p)->MoveVmap(buf); + buf += (*p)->moveVmap(buf); } } @@ -503,12 +503,12 @@ Sprite *Sprite::Expand(void) { SNAIL::COM *nea = NULL; SNAIL::COM *tak = NULL; MergeExt(fname, File, SPR_EXT); - if (INI_FILE::Exist(fname)) { // sprite description file exist + if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); if (! (sprf.Error==0)) error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; - while ((len = sprf.Read((uint8 *)line)) != 0) { + while ((len = sprf.read((uint8 *)line)) != 0) { ++lcnt; if (len && line[len - 1] == '\n') line[-- len] = '\0'; @@ -521,7 +521,7 @@ Sprite *Sprite::Expand(void) { break; } case 1 : { // Phase - shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"), true); break; } case 2 : { // Seq @@ -583,7 +583,7 @@ Sprite *Sprite::Expand(void) { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(File); + shplist[shpcnt++] = new Bitmap(File, true); } shplist[shpcnt] = NULL; if (seq) { @@ -748,9 +748,9 @@ void Sprite::Show(void) { // asm sti // ...done! if (!_flags._hide) { if (_flags._xlat) - e->_b1->XShow(e->_x1, e->_y1); + e->_b1->xShow(e->_x1, e->_y1); else - e->_b1->Show(e->_x1, e->_y1); + e->_b1->show(e->_x1, e->_y1); } } @@ -758,7 +758,7 @@ void Sprite::Show(void) { void Sprite::Show(uint16 pg) { Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; - Shp()->Show(_x, _y); + Shp()->show(_x, _y); VGA::Page[1] = a; } @@ -766,7 +766,7 @@ void Sprite::Show(uint16 pg) { void Sprite::Hide(void) { register SprExt *e = _ext; if (e->_b0) - e->_b0->Hide(e->_x0, e->_y0); + e->_b0->hide(e->_x0, e->_y0); } @@ -795,7 +795,7 @@ Sprite *SpriteAt(int x, int y) { if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { if (! spr->_flags._hide && ! spr->_flags._tran) { - if (spr->Shp()->SolidAt(x - spr->_x, y - spr->_y)) + if (spr->Shp()->solidAt(x - spr->_x, y - spr->_y)) break; } } @@ -1178,7 +1178,7 @@ void VGA::CopyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- -void Bitmap::XShow(int x, int y) { +void Bitmap::xShow(int x, int y) { /* uint8 rmsk = x % 4, mask = 1 << rmsk, @@ -1256,11 +1256,11 @@ void Bitmap::XShow(int x, int y) { asm pop si asm pop bx */ - warning("STUB: BITMAP::XShow"); + warning("STUB: BITMAP::xShow"); } -void Bitmap::Show(int x, int y) { +void Bitmap::show(int x, int y) { const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1322,7 +1322,7 @@ void Bitmap::Show(int x, int y) { } -void Bitmap::Hide(int x, int y) { +void Bitmap::hide(int x, int y) { /* uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); @@ -1385,7 +1385,7 @@ void Bitmap::Hide(int x, int y) { asm pop si // asm pop bx */ - warning("STUB: Bitmap::Hide"); + warning("STUB: Bitmap::hide"); } } // End of namespace CGE diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index c76914c003..8170bd5980 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -34,9 +34,9 @@ namespace CGE { -DAT *VFILE::_Dat = NULL; -BTFILE *VFILE::_Cat = NULL; -VFILE *VFILE::_Recent = NULL; +DAT *VFILE::_dat = NULL; +BtFile *VFILE::_cat = NULL; +VFILE *VFILE::_recent = NULL; /*-----------------------------------------------------------------------*/ @@ -52,30 +52,30 @@ DAT::DAT(): /*-----------------------------------------------------------------------*/ void VFILE::init() { - _Dat = new DAT(); + _dat = new DAT(); #ifdef VOL_UPD - _Cat = new BTFILE(CAT_NAME, UPD, CRP); + _cat = new BtFile(CAT_NAME, UPD, CRP); #else - _Cat = new BTFILE(CAT_NAME, REA, CRP); + _cat = new BtFile(CAT_NAME, REA, CRP); #endif - _Recent = NULL; + _recent = NULL; } void VFILE::deinit() { - delete _Dat; - delete _Cat; + delete _dat; + delete _cat; } VFILE::VFILE(const char *name, IOMODE mode) - : IOBUF(mode) { + : IoBuf(mode) { if (mode == REA) { - if (_Dat->_File.Error || _Cat->Error) + if (_dat->_File.Error || _cat->Error) error("Bad volume data"); - BT_KEYPACK *kp = _Cat->Find(name); - if (scumm_stricmp(kp->Key, name) != 0) + BtKeypack *kp = _cat->find(name); + if (scumm_stricmp(kp->_key, name) != 0) Error = 1; - EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; + _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size; } #ifdef VOL_UPD else @@ -85,27 +85,27 @@ VFILE::VFILE(const char *name, IOMODE mode) VFILE::~VFILE(void) { - if (_Recent == this) - _Recent = NULL; + if (_recent == this) + _recent = NULL; } -bool VFILE::Exist(const char *name) { - return scumm_stricmp(_Cat->Find(name)->Key, name) == 0; +bool VFILE::exist(const char *name) { + return scumm_stricmp(_cat->find(name)->_key, name) == 0; } -void VFILE::ReadBuff(void) { - if (_Recent != this) { - _Dat->_File.Seek(BufMark + Lim); - _Recent = this; +void VFILE::readBuff(void) { + if (_recent != this) { + _dat->_File.seek(_bufMark + _lim); + _recent = this; } - BufMark = _Dat->_File.Mark(); - long n = EndMark - BufMark; + _bufMark = _dat->_File.mark(); + long n = _endMark - _bufMark; if (n > IOBUF_SIZE) n = IOBUF_SIZE; - Lim = _Dat->_File.Read(Buff, (uint16) n); - Ptr = 0; + _lim = _dat->_File.read(_buff, (uint16) n); + _ptr = 0; } } // End of namespace CGE diff --git a/engines/cge/vol.h b/engines/cge/vol.h index a910aa7209..c2e676130e 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -45,7 +45,7 @@ namespace CGE { #ifdef VOL_UPD #define VOLBASE IOHAND #else -#define VOLBASE CFILE +#define VOLBASE CFile #endif @@ -55,40 +55,42 @@ class DAT { public: DAT(); - bool Append(uint8 *buf, uint16 len); - bool Write(CFILE &f); - bool Read(long org, uint16 len, uint8 *buf); + bool append(uint8 *buf, uint16 len); + bool write(CFile &f); + bool read(long org, uint16 len, uint8 *buf); }; -class VFILE : public IOBUF { +class VFILE : public IoBuf { private: - static DAT *_Dat; - static BTFILE *_Cat; - static VFILE *_Recent; - - long BegMark, EndMark; - void ReadBuff(void); - void WriteBuff(void) { } - void Make(const char *fspec); + static DAT *_dat; + static BtFile *_cat; + static VFILE *_recent; + + long _begMark; + long _endMark; + + void readBuff(void); + void writeBuff(void) { } + void make(const char *fspec); public: VFILE(const char *name, IOMODE mode = REA); ~VFILE(void); static void init(); static void deinit(); - static bool Exist(const char *name); - static const char *Next(void); - long Mark(void) { - return (BufMark + Ptr) - BegMark; + static bool exist(const char *name); + static const char *next(void); + long mark(void) { + return (_bufMark + _ptr) - _begMark; } - long Size(void) { - return EndMark - BegMark; + long size(void) { + return _endMark - _begMark; } - long Seek(long pos) { - _Recent = NULL; - Lim = 0; - return (BufMark = BegMark + pos); + long seek(long pos) { + _recent = NULL; + _lim = 0; + return (_bufMark = _begMark + pos); } }; diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 304c2827d8..3423c43033 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -58,7 +58,7 @@ public: Id = d; } CKID(XFILE *xf) { - (ckFile = xf)->Read(Tx, sizeof(Tx)); + (ckFile = xf)->read(Tx, sizeof(Tx)); } bool operator !=(CKID &X) { return Id != X.Id; -- cgit v1.2.3 From 0000a3139a7c1d3ddf993741d4e0aa0c7ac3d760 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 1 Jul 2011 08:37:40 +0200 Subject: CGE: Some more renaming (wip) --- engines/cge/bitmap.cpp | 54 +++++----- engines/cge/bitmap.h | 8 +- engines/cge/btfile.cpp | 6 +- engines/cge/btfile.h | 4 +- engines/cge/cfile.cpp | 14 +-- engines/cge/cge.h | 50 ++++----- engines/cge/cge_main.cpp | 274 +++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 34 +++--- engines/cge/config.cpp | 94 ++++++++-------- engines/cge/config.h | 2 +- engines/cge/ems.cpp | 28 ++--- engines/cge/game.cpp | 42 ++++---- engines/cge/game.h | 33 +++--- engines/cge/general.cpp | 28 +++-- engines/cge/general.h | 109 ++++++++++--------- engines/cge/snail.cpp | 28 ++--- engines/cge/sound.cpp | 10 +- engines/cge/talk.cpp | 4 +- engines/cge/text.cpp | 6 +- engines/cge/vga13h.cpp | 72 ++++++------- engines/cge/vga13h.h | 31 +++--- engines/cge/vol.cpp | 4 +- engines/cge/wav.h | 8 +- 23 files changed, 474 insertions(+), 469 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 3068499975..64a89e9381 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -35,7 +35,7 @@ namespace CGE { -DAC *Bitmap::_pal = NULL; +Dac *Bitmap::_pal = NULL; #define MAXPATH 128 void Bitmap::init() { @@ -53,7 +53,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { #if (BMP_MODE < 2) if (rem && PIC_FILE::exist(pat)) { PIC_FILE file(pat); - if ((file.Error == 0) && (!loadVBM(&file))) + if ((file._error == 0) && (!loadVBM(&file))) error("Bad VBM [%s]", fname); } else #endif @@ -61,7 +61,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { #if (BMP_MODE) ForceExt(pat, fname, ".BMP"); PIC_FILE file(pat); - if (file.Error == 0) { + if (file._error == 0) { if (loadBMP(&file)) { Code(); if (rem) { @@ -366,47 +366,47 @@ bool Bitmap::solidAt(int x, int y) { } -bool Bitmap::saveVBM(XFILE *f) { +bool Bitmap::saveVBM(XFile *f) { uint16 p = (_pal != NULL), n = ((uint16)(((uint8 *)_b) - _v)) + _h * sizeof(HideDesc); - if (f->Error == 0) + if (f->_error == 0) f->write((uint8 *)&p, sizeof(p)); - if (f->Error == 0) + if (f->_error == 0) f->write((uint8 *)&n, sizeof(n)); - if (f->Error == 0) + if (f->_error == 0) f->write((uint8 *)&_w, sizeof(_w)); - if (f->Error == 0) + if (f->_error == 0) f->write((uint8 *)&_h, sizeof(_h)); - if (f->Error == 0) + if (f->_error == 0) if (p) f->write((uint8 *)_pal, 256 * 3); - if (f->Error == 0) + if (f->_error == 0) f->write(_v, n); - return (f->Error == 0); + return (f->_error == 0); } -bool Bitmap::loadVBM(XFILE *f) { +bool Bitmap::loadVBM(XFile *f) { uint16 p = 0, n = 0; - if (f->Error == 0) + if (f->_error == 0) f->read((uint8 *)&p, sizeof(p)); - if (f->Error == 0) + if (f->_error == 0) f->read((uint8 *)&n, sizeof(n)); - if (f->Error == 0) + if (f->_error == 0) f->read((uint8 *)&_w, sizeof(_w)); - if (f->Error == 0) + if (f->_error == 0) f->read((uint8 *)&_h, sizeof(_h)); - if (f->Error == 0) { + if (f->_error == 0) { if (p) { if (_pal) { byte palData[PAL_SIZ]; @@ -419,14 +419,14 @@ bool Bitmap::loadVBM(XFILE *f) { if ((_v = farnew(uint8, n)) == NULL) return false; - if (f->Error == 0) + if (f->_error == 0) f->read(_v, n); _b = (HideDesc *)(_v + n - _h * sizeof(HideDesc)); - return (f->Error == 0); + return (f->_error == 0); } -bool Bitmap::loadBMP(XFILE * f) { +bool Bitmap::loadBMP(XFile *f) { struct { char BM[2]; union { int16 len; int32 len_; }; @@ -446,16 +446,16 @@ bool Bitmap::loadBMP(XFILE * f) { BGR4 bpal[256]; f->read((byte *)&hea, sizeof(hea)); - if (f->Error == 0) { + if (f->_error == 0) { if (hea.hdr == 0x436L) { int16 i = (hea.hdr - sizeof(hea)) / sizeof(BGR4); f->read((byte *)&bpal, sizeof(bpal)); - if (f->Error == 0) { + if (f->_error == 0) { if (_pal) { for (i = 0; i < 256; i ++) { - _pal[i].R = bpal[i].R; - _pal[i].G = bpal[i].G; - _pal[i].B = bpal[i].B; + _pal[i]._r = bpal[i].R; + _pal[i]._g = bpal[i].G; + _pal[i]._b = bpal[i].B; } _pal = NULL; } @@ -466,9 +466,9 @@ bool Bitmap::loadBMP(XFILE * f) { byte buf[3]; int i; for (i = _h - 1; i >= 0; i--) { f->read(_m + (_w * i), _w); - if (r && f->Error == 0) + if (r && f->_error == 0) f->read(buf, r); - if (f->Error) + if (f->_error) break; } if (i < 0) diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index b13912a3c6..99464bffeb 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -60,10 +60,10 @@ struct HideDesc { #include "common/pack-end.h" class Bitmap { - bool loadBMP(XFILE *f); - bool loadVBM(XFILE *f); + bool loadBMP(XFile *f); + bool loadVBM(XFile *f); public: - static DAC *_pal; + static Dac *_pal; uint16 _w; uint16 _h; uint8 *_m; @@ -85,7 +85,7 @@ public: void show(int x, int y); void xShow(int x, int y); bool solidAt(int x, int y); - bool saveVBM(XFILE *f); + bool saveVBM(XFile *f); uint16 moveVmap(uint8 *buf); }; diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 8255775fd1..18bd2d72e7 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -55,7 +55,7 @@ BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) BtFile::~BtFile(void) { for (int i = 0; i < BT_LEVELS; i++) { - putPage(i); + putPage(i, false); delete _buff[i]._page; } } @@ -73,7 +73,7 @@ void BtFile::putPage(int lev, bool hard) { BtPage *BtFile::getPage(int lev, uint16 pgn) { if (_buff[lev]._pgNo != pgn) { int32 pos = pgn * sizeof(BtPage); - putPage(lev); + putPage(lev, false); _buff[lev]._pgNo = pgn; if (size() > pos) { seek((uint32) pgn * sizeof(BtPage)); @@ -93,7 +93,7 @@ BtPage *BtFile::getPage(int lev, uint16 pgn) { BtKeypack *BtFile::find(const char *key) { int lev = 0; uint16 nxt = BT_ROOT; - while (! Error) { + while (!_error) { BtPage *pg = getPage(lev, nxt); // search if (pg->_hea._down != BT_NONE) { diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 3fd3175798..ac05c3a7e7 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -80,10 +80,10 @@ class BtFile : public IoHand { bool _updt; } _buff[BT_LEVELS]; - void putPage(int lev, bool hard = false); + void putPage(int lev, bool hard); BtPage *getPage(int lev, uint16 pgn); public: - BtFile(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); + BtFile(const char *name, IOMODE mode, CRYPT *crpt); virtual ~BtFile(); BtKeypack *find(const char *key); BtKeypack *next(); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 9a2b697bd7..ee2aecbc42 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -54,7 +54,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) } IoBuf::~IoBuf(void) { - if (Mode > REA) + if (_mode > REA) writeBuff(); if (_buff) free(_buff); @@ -210,7 +210,7 @@ CFile::~CFile(void) { void CFile::flush(void) { - if (Mode > REA) + if (_mode > REA) writeBuff(); else _lim = 0; @@ -225,16 +225,16 @@ void CFile::flush(void) { long CFile::mark(void) { - return _bufMark + ((Mode > REA) ? _lim : _ptr); + return _bufMark + ((_mode > REA) ? _lim : _ptr); } long CFile::seek(long pos) { if (pos >= _bufMark && pos < _bufMark + _lim) { - ((Mode == REA) ? _ptr : _lim) = (uint16)(pos - _bufMark); + ((_mode == REA) ? _ptr : _lim) = (uint16)(pos - _bufMark); return pos; } else { - if (Mode > REA) + if (_mode > REA) writeBuff(); else _lim = 0; @@ -247,13 +247,13 @@ long CFile::seek(long pos) { void CFile::append(CFile &f) { seek(size()); - if (f.Error == 0) { + if (f._error == 0) { while (true) { if ((_lim = f.IoHand::read(_buff, IOBUF_SIZE)) == IOBUF_SIZE) writeBuff(); else break; - if ((Error = f.Error) != 0) + if ((_error = f._error) != 0) break; } } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index c3f241b2fe..06c7fb2326 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -56,40 +56,40 @@ public: } void cge_main(); - void SwitchCave(int cav); - void StartCountDown(); - void Quit(); - void ResetQSwitch(); - void OptionTouch(int opt, uint16 mask); - void LoadGame(XFILE &file, bool tiny); - void SetMapBrick(int x, int z); - void SwitchMapping(); - void LoadSprite(const char *fname, int ref, int cav, int col, int row, int pos); - void LoadScript(const char *fname); - void LoadUser(); - void RunGame(); - bool ShowTitle(const char *name); - void Movie(const char *ext); - void TakeName(); - void Inf(const char *txt); - void SelectSound(); + void switchCave(int cav); + void startCountDown(); + void quit(); + void resetQSwitch(); + void optionTouch(int opt, uint16 mask); + void loadGame(XFile &file, bool tiny); + void setMapBrick(int x, int z); + void switchMapping(); + void loadSprite(const char *fname, int ref, int cav, int col, int row, int pos); + void loadScript(const char *fname); + void loadUser(); + void runGame(); + bool showTitle(const char *name); + void movie(const char *ext); + void takeName(); + void inf(const char *txt); + void selectSound(); void SNSelect(); void dummy() {} void NONE(); void SB(); - void CaveDown(); - void XCave(); - void QGame(); + void caveDown(); + void xCave(); + void qGame(); void SBM(); void GUS(); void GUSM(); void MIDI(); void AUTO(); - void SetPortD(); - void SetPortM(); - void SetIRQ(); - void SetDMA(); - void MainLoop(); + void setPortD(); + void setPortM(); + void setIRQ(); + void setDMA(); + void mainLoop(); private: CGEConsole *_console; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 035c4dc317..2d4f004632 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -133,7 +133,7 @@ bool JBW = false; //------------------------------------------------------------------------- int PocPtr = 0; -static EMS *Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE); +static EMS *Mini = MiniEmm.alloc((uint16)MINI_EMM_SIZE); static BMP_PTR *MiniShpList = NULL; static BMP_PTR MiniShp[] = { NULL, NULL }; static KEYBOARD Keyboard; @@ -148,18 +148,18 @@ BAR Barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; extern int FindPocket(Sprite *); -extern DAC StdPal[58]; +extern Dac _stdPal[58]; void FeedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL -uint8 CLUSTER::Map[MAP_ZCNT][MAP_XCNT]; +uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; -uint8 &CLUSTER::Cell(void) { - return Map[B][A]; +uint8 &Cluster::cell(void) { + return _map[_b][_a]; } -bool CLUSTER::Protected(void) { +bool Cluster::Protected(void) { /* if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) return true; @@ -202,20 +202,20 @@ bool CLUSTER::Protected(void) { } -CLUSTER XZ(int x, int y) { +Cluster XZ(int x, int y) { if (y < MAP_TOP) y = MAP_TOP; if (y > MAP_TOP + MAP_HIG - MAP_ZGRID) y = MAP_TOP + MAP_HIG - MAP_ZGRID; - return CLUSTER(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID); + return Cluster(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID); } -CLUSTER XZ(COUPLE xy) { +Cluster XZ(Couple xy) { signed char x, y; - xy.Split(x, y); + xy.split(x, y); return XZ(x, y); } @@ -249,13 +249,13 @@ SavTab _savTab[] = { }; -void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { +void CGEEngine::loadGame(XFile &file, bool tiny = false) { SavTab *st; Sprite *spr; int i; for (st = _savTab; st->Ptr; st++) { - if (file.Error) + if (file._error) error("Bad SVG"); file.read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len); } @@ -274,7 +274,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { } if (! tiny) { // load sprites & pocket - while (! file.Error) { + while (!file._error) { Sprite S(this, NULL); uint16 n = file.read((uint8 *) &S, sizeof(S)); @@ -282,7 +282,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { break; S._prev = S._next = NULL; - spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(this, NULL) + spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new Fly(this, NULL) : new Sprite(this, NULL); if (spr == NULL) error("No core"); @@ -300,12 +300,12 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) { static void SaveSound(void) { CFile cfg(UsrPath(ProgName(CFG_EXT)), WRI); - if (! cfg.Error) + if (!cfg._error) cfg.write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2)); } -static void SaveGame(XFILE &file) { +static void SaveGame(XFile &file) { SavTab *st; Sprite *spr; int i; @@ -319,7 +319,7 @@ static void SaveGame(XFILE &file) { volume[1] = SNDDrvInfo.VOL2.M; for (st = _savTab; st->Ptr; st++) { - if (file.Error) + if (file._error) error("Bad SVG"); file.write((uint8 *) st->Ptr, st->Len); } @@ -328,7 +328,7 @@ static void SaveGame(XFILE &file) { for (spr = Vga->SpareQ->First(); spr; spr = spr->_next) if (spr->_ref >= 1000) - if (!file.Error) + if (!file._error) file.write((uint8 *)spr, sizeof(*spr)); } @@ -339,7 +339,7 @@ static void HeroCover(int cvr) { static void Trouble(int seq, int txt) { - Hero->Park(); + Hero->park(); SNPOST(SNWAIT, -1, -1, Hero); SNPOST(SNSEQ, -1, seq, Hero); SNPOST(SNSOUND, -1, 2, Hero); @@ -359,7 +359,7 @@ static void TooFar(void) { // Used in stubbed function, do not remove! -static void NoWay(void) { +static void noWay() { Trouble(NO_WAY, NO_WAY_TEXT); } @@ -367,7 +367,7 @@ static void NoWay(void) { static void LoadHeroXY(void) { INI_FILE cf(ProgName(".HXY")); memset(HeroXY, 0, sizeof(HeroXY)); - if (! cf.Error) + if (!cf._error) cf.CFREAD(&HeroXY); } @@ -375,35 +375,35 @@ static void LoadHeroXY(void) { static void LoadMapping(void) { if (Now <= CAVE_MAX) { INI_FILE cf(ProgName(".TAB")); - if (! cf.Error) { - memset(CLUSTER::Map, 0, sizeof(CLUSTER::Map)); - cf.seek((Now - 1) * sizeof(CLUSTER::Map)); - cf.read((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); + if (!cf._error) { + memset(Cluster::_map, 0, sizeof(Cluster::_map)); + cf.seek((Now - 1) * sizeof(Cluster::_map)); + cf.read((uint8 *) Cluster::_map, sizeof(Cluster::_map)); } } } -CLUSTER Trace[MAX_FIND_LEVEL]; +Cluster Trace[MAX_FIND_LEVEL]; int FindLevel; WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) - : Sprite(vm, shpl), Dir(NO_DIR), TracePtr(-1), _vm(vm) { + : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _vm(vm) { } -void WALK::Tick(void) { +void WALK::tick() { if (_flags._hide) return; - Here = XZ(_x + _w / 2, _y + _h); + _here = XZ(_x + _w / 2, _y + _h); if (Dir != NO_DIR) { Sprite *spr; Sys->FunTouch(); for (spr = Vga->ShowQ->First(); spr; spr = spr->_next) { - if (Distance(spr) < 2) { + if (distance(spr) < 2) { if (!spr->_flags._near) { FeedSnail(spr, NEAR); spr->_flags._near = true; @@ -414,33 +414,33 @@ void WALK::Tick(void) { } } - if (_flags._hold || TracePtr < 0) - Park(); + if (_flags._hold || _tracePtr < 0) + park(); else { - if (Here == Trace[TracePtr]) { - if (--TracePtr < 0) - Park(); + if (_here == Trace[_tracePtr]) { + if (--_tracePtr < 0) + park(); } else { signed char dx, dz; - (Trace[TracePtr] - Here).Split(dx, dz); + (Trace[_tracePtr] - _here).split(dx, dz); DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN); - Turn(d); + turn(d); } } Step(); if ((Dir == WW && _x <= 0) || (Dir == EE && _x + _w >= SCR_WID) || (Dir == SS && _y + _w >= WORLD_HIG - 2)) - Park(); + park(); else { signed char x; // dummy var - Here.Split(x, _z); // take current Z position + _here.split(x, _z); // take current Z position SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue } } -int WALK::Distance(Sprite *spr) { +int WALK::distance(Sprite *spr) { int dx, dz; dx = spr->_x - (_x + _w - WALKSIDE); if (dx < 0) @@ -462,7 +462,7 @@ int WALK::Distance(Sprite *spr) { } -void WALK::Turn(DIR d) { +void WALK::turn(DIR d) { DIR dir = (Dir == NO_DIR) ? SS : Dir; if (d != Dir) { Step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); @@ -471,20 +471,20 @@ void WALK::Turn(DIR d) { } -void WALK::Park(void) { +void WALK::park(void) { if (_time == 0) ++_time; if (Dir != NO_DIR) { Step(9 + 4 * Dir + Dir); Dir = NO_DIR; - TracePtr = -1; + _tracePtr = -1; } } -void WALK::FindWay(CLUSTER c) { - warning("STUB: Find1Way"); +void WALK::findWay(Cluster c) { + warning("STUB: WALK::findWay"); /* bool Find1Way(void); extern uint16 Target; @@ -508,7 +508,7 @@ void WALK::FindWay(CLUSTER c) { } -void WALK::FindWay(Sprite *spr) { +void WALK::findWay(Sprite *spr) { if (spr && spr != this) { int x = spr->_x; int z = spr->_z; @@ -516,24 +516,24 @@ void WALK::FindWay(Sprite *spr) { x += spr->_w + _w / 2 - WALKSIDE; else x -= _w / 2 - WALKSIDE; - FindWay(CLUSTER((x / MAP_XGRID), + findWay(Cluster((x / MAP_XGRID), ((z < MAP_ZCNT - MAX_DISTANCE) ? (z + 1) : (z - 1)))); } } -bool WALK::Lower(Sprite *spr) { +bool WALK::lower(Sprite *spr) { return (spr->_y > _y + (_h * 3) / 5); } -void WALK::Reach(Sprite *spr, int mode) { +void WALK::reach(Sprite *spr, int mode) { if (spr) { - Hero->FindWay(spr); + Hero->findWay(spr); if (mode < 0) { mode = spr->_flags._east; - if (Lower(spr)) + if (lower(spr)) mode += 2; } } @@ -568,20 +568,20 @@ SQUARE::SQUARE(CGEEngine *vm) void SQUARE::Touch(uint16 mask, int x, int y) { Sprite::Touch(mask, x, y); if (mask & L_UP) { - XZ(_x + x, _y + y).Cell() = 0; + XZ(_x + x, _y + y).cell() = 0; SNPOST_(SNKILL, -1, 0, this); } } -void CGEEngine::SetMapBrick(int x, int z) { +void CGEEngine::setMapBrick(int x, int z) { SQUARE *s = new SQUARE(this); if (s) { static char n[] = "00:00"; s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); wtom(x, n + 0, 10, 2); wtom(z, n + 3, 10, 2); - CLUSTER::Map[z][x] = 1; + Cluster::_map[z][x] = 1; s->SetName(n); Vga->ShowQ->Insert(s, Vga->ShowQ->First()); } @@ -601,23 +601,23 @@ static void KeyClick(void) { } -void CGEEngine::ResetQSwitch() { +void CGEEngine::resetQSwitch() { SNPOST_(SNSEQ, 123, 0, NULL); KeyClick(); } -void CGEEngine::Quit() { +void CGEEngine::quit() { static CHOICE QuitMenu[] = { - { NULL, &CGEEngine::StartCountDown }, - { NULL, &CGEEngine::ResetQSwitch }, + { NULL, &CGEEngine::startCountDown }, + { NULL, &CGEEngine::resetQSwitch }, { NULL, &CGEEngine::dummy } }; if (Snail->Idle() && ! Hero->_flags._hide) { if (VMENU::Addr) { SNPOST_(SNKILL, -1, 0, VMENU::Addr); - ResetQSwitch(); + resetQSwitch(); } else { QuitMenu[0].Text = Text->getText(QUIT_TEXT); QuitMenu[1].Text = Text->getText(NOQUIT_TEXT); @@ -634,7 +634,7 @@ static void AltCtrlDel(void) { } // Used in stubbed function, do not remove! -static void MiniStep(int stp) { +static void miniStep(int stp) { if (stp < 0) _miniCave->_flags._hide = true; else { @@ -657,11 +657,11 @@ static void PostMiniStep(int stp) { void SYSTEM::SetPal(void) { uint i; - DAC *p = VGA::SysPal + 256 - ArrayCount(StdPal); - for (i = 0; i < ArrayCount(StdPal); i++) { - p[i].R = StdPal[i].R >> 2; - p[i].G = StdPal[i].G >> 2; - p[i].B = StdPal[i].B >> 2; + Dac *p = VGA::SysPal + 256 - ArrayCount(_stdPal); + for (i = 0; i < ArrayCount(_stdPal); i++) { + p[i]._r = _stdPal[i]._r >> 2; + p[i]._g = _stdPal[i]._g >> 2; + p[i]._b = _stdPal[i]._b >> 2; } } @@ -687,7 +687,7 @@ static void ShowBak(int ref) { } -static void CaveUp(void) { +static void caveUp() { int BakRef = 1000 * Now; if (Music) LoadMIDI(Now); @@ -732,7 +732,7 @@ static void CaveUp(void) { if (_shadow) { Vga->ShowQ->Remove(_shadow); - _shadow->MakeXlat(Glass(VGA::SysPal, 204, 204, 204)); + _shadow->MakeXlat(glass(VGA::SysPal, 204, 204, 204)); Vga->ShowQ->Insert(_shadow, Hero); _shadow->_z = Hero->_z; } @@ -749,10 +749,10 @@ static void CaveUp(void) { } -void CGEEngine::CaveDown() { +void CGEEngine::caveDown() { Sprite *spr; if (!_horzLine->_flags._hide) - SwitchMapping(); + switchMapping(); for (spr = Vga->ShowQ->First(); spr;) { Sprite *n = spr->_next; @@ -767,14 +767,14 @@ void CGEEngine::CaveDown() { } -void CGEEngine::XCave() { - CaveDown(); - CaveUp(); +void CGEEngine::xCave() { + caveDown(); + caveUp(); } -void CGEEngine::QGame() { - CaveDown(); +void CGEEngine::qGame() { + caveDown(); OldLev = Lev; SaveSound(); CFile file = CFile(UsrPath(UsrFnam), WRI, RCrypt); @@ -784,7 +784,7 @@ void CGEEngine::QGame() { } -void CGEEngine::SwitchCave(int cav) { +void CGEEngine::switchCave(int cav) { if (cav != Now) { _heart->_enable = false; if (cav < 0) { @@ -796,7 +796,7 @@ void CGEEngine::SwitchCave(int cav) { Now = cav; Mouse->Off(); if (Hero) { - Hero->Park(); + Hero->park(); Hero->Step(0); if (!_isDemo) ///// protection: auto-destruction on! ---------------------- @@ -865,7 +865,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { if (KEYBOARD::Key[ALT]) SaveMapping(); else - _vm->SwitchMapping(); + _vm->switchMapping(); break; case F1: SwitchDebug(); @@ -914,7 +914,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { break; case F10 : if (Snail->Idle() && ! Hero->_flags._hide) - _vm->StartCountDown(); + _vm->startCountDown(); break; case 'J': if (pp == 0) @@ -958,21 +958,21 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { PostMiniStep(cav - 1); if (mask & L_UP) { - if (cav && Snail->Idle() && Hero->TracePtr < 0) - _vm->SwitchCave(cav); + if (cav && Snail->Idle() && Hero->_tracePtr < 0) + _vm->switchCave(cav); if (!_horzLine->_flags._hide) { if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { int8 x1, z1; - XZ(x, y).Split(x1, z1); - CLUSTER::Map[z1][x1] = 1; - _vm->SetMapBrick(x1, z1); + XZ(x, y).split(x1, z1); + Cluster::_map[z1][x1] = 1; + _vm->setMapBrick(x1, z1); } } else { if (! Talk && Snail->Idle() && Hero && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && ! Game) { - Hero->FindWay(XZ(x, y)); + Hero->findWay(XZ(x, y)); } } } @@ -1042,7 +1042,7 @@ static void SwitchMusic(void) { else { SNPOST_(SNSEQ, 122, (Music = false), NULL); //TODO Change the SNPOST message send to a special way to send function pointer - // SNPOST(SNEXEC, -1, 0, (void *)&SelectSound); + // SNPOST(SNEXEC, -1, 0, (void *)&selectSound); warning("SwitchMusic() - SNPOST"); } } else { @@ -1060,13 +1060,13 @@ static void SwitchMusic(void) { } -void CGEEngine::StartCountDown() { +void CGEEngine::startCountDown() { //SNPOST(SNSEQ, 123, 0, NULL); - SwitchCave(-1); + switchCave(-1); } -void CGEEngine::TakeName() { +void CGEEngine::takeName() { if (GET_TEXT::Ptr) SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr); else { @@ -1082,14 +1082,14 @@ void CGEEngine::TakeName() { } -void CGEEngine::SwitchMapping() { +void CGEEngine::switchMapping() { if (_horzLine->_flags._hide) { int i; for (i = 0; i < MAP_ZCNT; i++) { int j; for (j = 0; j < MAP_XCNT; j++) { - if (CLUSTER::Map[i][j]) - SetMapBrick(j, i); + if (Cluster::_map[i][j]) + setMapBrick(j, i); } } } else { @@ -1144,17 +1144,17 @@ static void NextStep(void) { } -static void SaveMapping(void) { +static void SaveMapping() { { IoHand cf(ProgName(".TAB"), UPD); - if (!cf.Error) { - cf.seek((Now - 1) * sizeof(CLUSTER::Map)); - cf.write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map)); + if (!cf._error) { + cf.seek((Now - 1) * sizeof(Cluster::_map)); + cf.write((uint8 *) Cluster::_map, sizeof(Cluster::_map)); } } { IoHand cf(ProgName(".HXY"), WRI); - if (!cf.Error) { + if (!cf._error) { HeroXY[Now - 1]._x = Hero->_x; HeroXY[Now - 1]._y = Hero->_y; cf.write((uint8 *) HeroXY, sizeof(HeroXY)); @@ -1229,7 +1229,7 @@ static void SwitchDebug(void) { } -void CGEEngine::OptionTouch(int opt, uint16 mask) { +void CGEEngine::optionTouch(int opt, uint16 mask) { switch (opt) { case 1 : if (mask & L_UP) @@ -1246,7 +1246,7 @@ void CGEEngine::OptionTouch(int opt, uint16 mask) { break; case 3 : if (mask & L_UP) - Quit(); + quit(); break; } } @@ -1260,7 +1260,7 @@ void Sprite::Touch(uint16 mask, int x, int y) { if (mask & (R_DN | L_DN)) _sprite = this; if (_ref / 10 == 12) { - _vm->OptionTouch(_ref % 10, mask); + _vm->optionTouch(_ref % 10, mask); return; } if (_flags._syst) @@ -1272,7 +1272,7 @@ void Sprite::Touch(uint16 mask, int x, int y) { if ((mask & R_UP) && Snail->Idle()) { Sprite *ps = (_pocLight->_seqPtr) ? _pocket[PocPtr] : NULL; if (ps) { - if (_flags._kept || Hero->Distance(this) < MAX_DISTANCE) { + if (_flags._kept || Hero->distance(this) < MAX_DISTANCE) { if (Works(ps)) { FeedSnail(ps, TAKE); } else @@ -1284,7 +1284,7 @@ void Sprite::Touch(uint16 mask, int x, int y) { if (_flags._kept) mask |= L_UP; else { - if (Hero->Distance(this) < MAX_DISTANCE) { + if (Hero->distance(this) < MAX_DISTANCE) { /// if (_flags._port) { if (FindPocket(NULL) < 0) @@ -1325,7 +1325,7 @@ void Sprite::Touch(uint16 mask, int x, int y) { } -void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) { +void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) { static const char *Comd[] = { "Name", "Type", "Phase", "East", "Left", "Right", "Top", "Bottom", "Seq", "Near", "Take", @@ -1348,7 +1348,7 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int MergeExt(line, fname, SPR_EXT); if (INI_FILE::exist(line)) { // sprite description file exist INI_FILE sprf(line); - if (sprf.Error) + if (sprf._error) error("Bad SPR [%s]", line); while ((len = sprf.read((uint8 *)line)) != 0) { @@ -1445,7 +1445,7 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int break; } case 5 : { // FLY - FLY *f = new FLY(this, NULL); + Fly *f = new Fly(this, NULL); _sprite = f; //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$ break; @@ -1479,7 +1479,7 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int } -void CGEEngine::LoadScript(const char *fname) { +void CGEEngine::loadScript(const char *fname) { char line[LINE_MAX]; char *SpN; int SpI, SpA, SpX, SpY, SpZ; @@ -1488,13 +1488,13 @@ void CGEEngine::LoadScript(const char *fname) { int lcnt = 0; bool ok = true; - if (scrf.Error) + if (scrf._error) return; while (scrf.read((uint8 *)line) != 0) { char *p; - ++lcnt; + lcnt++; if (*line == 0 || *line == '\n' || *line == '.') continue; @@ -1530,7 +1530,7 @@ void CGEEngine::LoadScript(const char *fname) { ok = true; // no break: OK _sprite = NULL; - LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); + loadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); if (_sprite && BkG) _sprite->_flags._back = true; } @@ -1539,7 +1539,7 @@ void CGEEngine::LoadScript(const char *fname) { } -void CGEEngine::MainLoop() { +void CGEEngine::mainLoop() { SayDebug(); if (_isDemo) { @@ -1564,28 +1564,28 @@ void CGEEngine::MainLoop() { } -void CGEEngine::LoadUser() { +void CGEEngine::loadUser() { // set scene if (STARTUP::Mode == 0) { // user .SVG file found CFile cfile = CFile(UsrPath(UsrFnam), REA, RCrypt); - LoadGame(cfile); + loadGame(cfile); } else { if (STARTUP::Mode == 1) { SVG0FILE file = SVG0FILE(SVG0NAME); - LoadGame(file); + loadGame(file); } else { - LoadScript(ProgName(INI_EXT)); + loadScript(ProgName(INI_EXT)); Music = true; CFile file = CFile(SVG0NAME, WRI); SaveGame(file); error("Ok [%s]", SVG0NAME); } } - LoadScript(ProgName(IN0_EXT)); + loadScript(ProgName(IN0_EXT)); } -void CGEEngine::RunGame() { +void CGEEngine::runGame() { Text->Clear(); Text->Preload(100, 1000); LoadHeroXY(); @@ -1613,7 +1613,7 @@ void CGEEngine::RunGame() { // Vga->ShowQ->Append(Mouse); // ___________ - LoadUser(); + loadUser(); // ~~~~~~~~~~~ if ((_sprite = Vga->SpareQ->Locate(121)) != NULL) @@ -1627,7 +1627,7 @@ void CGEEngine::RunGame() { if (Mini && INI_FILE::exist("MINI.SPR")) { uint8 *ptr = (uint8 *) &*Mini; if (ptr != NULL) { - LoadSprite("MINI", -1, 0, MINI_X, MINI_Y); + loadSprite("MINI", -1, 0, MINI_X, MINI_Y); ExpandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { _miniCave->_flags._hide = true; @@ -1643,7 +1643,7 @@ void CGEEngine::RunGame() { ExpandSprite(Hero); Hero->Goto(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); if (INI_FILE::exist("00SHADOW.SPR")) { - LoadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51); + loadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51); if ((_shadow = _sprite) != NULL) { _shadow->_ref = 2; _shadow->_flags._tran = true; @@ -1674,7 +1674,7 @@ void CGEEngine::RunGame() { SNPOST(SNLEVEL, -1, OldLev, &_cavLight); _cavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); - CaveUp(); + caveUp(); KEYBOARD::SetClient(Sys); // main loop @@ -1682,7 +1682,7 @@ void CGEEngine::RunGame() { //TODO Change the SNPOST message send to a special way to send function pointer // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame); warning("RunGame: problematic use of SNPOST"); - MainLoop(); + mainLoop(); } KEYBOARD::SetClient(NULL); @@ -1697,10 +1697,10 @@ void CGEEngine::RunGame() { } -void CGEEngine::Movie(const char *ext) { +void CGEEngine::movie(const char *ext) { const char *fn = ProgName(ext); if (INI_FILE::exist(fn)) { - LoadScript(fn); + loadScript(fn); ExpandSprite(Vga->SpareQ->Locate(999)); FeedSnail(Vga->ShowQ->Locate(999), TAKE); @@ -1710,7 +1710,7 @@ void CGEEngine::Movie(const char *ext) { _heart->_enable = true; KEYBOARD::SetClient(Sys); while (!Snail->Idle()) - MainLoop(); + mainLoop(); KEYBOARD::SetClient(NULL); _heart->_enable = false; @@ -1722,7 +1722,7 @@ void CGEEngine::Movie(const char *ext) { } -bool CGEEngine::ShowTitle(const char *name) { +bool CGEEngine::showTitle(const char *name) { Bitmap::_pal = VGA::SysPal; BMP_PTR LB[] = { new Bitmap(name, true), NULL }; Bitmap::_pal = NULL; @@ -1735,7 +1735,7 @@ bool CGEEngine::ShowTitle(const char *name) { D.Show(2); if (STARTUP::Mode == 2) { - Inf(SVG0NAME); + inf(SVG0NAME); Talk->Show(2); } @@ -1751,8 +1751,8 @@ bool CGEEngine::ShowTitle(const char *name) { Vga->ShowQ->Append(Mouse); _heart->_enable = true; Mouse->On(); - for (SelectSound(); !Snail->Idle() || VMENU::Addr;) - MainLoop(); + for (selectSound(); !Snail->Idle() || VMENU::Addr;) + mainLoop(); Mouse->Off(); _heart->_enable = false; Vga->ShowQ->Clear(); @@ -1781,14 +1781,14 @@ bool CGEEngine::ShowTitle(const char *name) { STARTUP::Summa |= Lo(sn) | Hi(sn); #endif //----------------------------------------- - Movie("X00"); // paylist + movie("X00"); // paylist Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); Vga->ShowQ->Append(Mouse); //Mouse.On(); _heart->_enable = true; - for (TakeName(); GET_TEXT::Ptr;) - MainLoop(); + for (takeName(); GET_TEXT::Ptr;) + mainLoop(); _heart->_enable = false; if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = true; @@ -1804,7 +1804,7 @@ bool CGEEngine::ShowTitle(const char *name) { const char *n = UsrPath(UsrFnam); if (CFile::exist(n)) { CFile file = CFile(n, REA, RCrypt); - LoadGame(file, true); // only system vars + loadGame(file, true); // only system vars Vga->SetColors(VGA::SysPal, 64); Vga->Update(); if (FINIS) { @@ -1817,7 +1817,7 @@ bool CGEEngine::ShowTitle(const char *name) { } if (STARTUP::Mode < 2) - Movie("X01"); // wink + movie("X01"); // wink Vga->CopyPage(0, 2); @@ -1859,14 +1859,14 @@ void CGEEngine::cge_main(void) { if (Music && STARTUP::SoundOk) LoadMIDI(0); if (STARTUP::Mode < 2) - Movie(LGO_EXT); - if (ShowTitle("WELCOME")) { + movie(LGO_EXT); + if (showTitle("WELCOME")) { if ((!_isDemo) && (STARTUP::Mode == 1)) - Movie("X02"); // intro - RunGame(); + movie("X02"); // intro + runGame(); Startup = 2; if (FINIS) - Movie("X03"); + movie("X03"); } else Vga->Sunset(); error("%s", Text->getText(EXIT_OK_TEXT + FINIS)); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 8b2f87aad9..9b905ea360 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -129,39 +129,39 @@ private: }; -class CLUSTER : public COUPLE { +class Cluster : public Couple { public: - static uint8 Map[MAP_ZCNT][MAP_XCNT]; - uint8 &Cell(void); - CLUSTER(void) : COUPLE() { } - CLUSTER(int a, int b) : COUPLE(a, b) { } + static uint8 _map[MAP_ZCNT][MAP_XCNT]; + uint8 &cell(void); + Cluster(void) : Couple() { } + Cluster(int a, int b) : Couple(a, b) { } bool Protected(void); }; class WALK : public Sprite { public: - CLUSTER Here; - int TracePtr; + Cluster _here; + int _tracePtr; enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; WALK(CGEEngine *vm, BMP_PTR *shpl); - void Tick(void); - void FindWay(CLUSTER c); - void FindWay(Sprite *spr); - int Distance(Sprite *spr); - void Turn(DIR d); - void Park(void); - bool Lower(Sprite *spr); - void Reach(Sprite *spr, int mode = -1); + void tick(); + void findWay(Cluster c); + void findWay(Sprite *spr); + int distance(Sprite *spr); + void turn(DIR d); + void park(); + bool lower(Sprite *spr); + void reach(Sprite *spr, int mode = -1); private: CGEEngine *_vm; }; -CLUSTER XZ(int x, int y); -CLUSTER XZ(COUPLE xy); +Cluster XZ(int x, int y); +Cluster XZ(Couple xy); void ExpandSprite(Sprite *spr); void ContractSprite(Sprite *spr); diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 2673143285..702c10ed15 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -77,76 +77,76 @@ static CHOICE DevMenu[] = { static CHOICE DigiPorts[] = { - { " 210h", &CGEEngine::SetPortD }, - { " 220h", &CGEEngine::SetPortD }, - { " 230h", &CGEEngine::SetPortD }, - { " 240h", &CGEEngine::SetPortD }, - { " 250h", &CGEEngine::SetPortD }, - { " 260h", &CGEEngine::SetPortD }, - { "AUTO ", &CGEEngine::SetPortD }, + { " 210h", &CGEEngine::setPortD }, + { " 220h", &CGEEngine::setPortD }, + { " 230h", &CGEEngine::setPortD }, + { " 240h", &CGEEngine::setPortD }, + { " 250h", &CGEEngine::setPortD }, + { " 260h", &CGEEngine::setPortD }, + { "AUTO ", &CGEEngine::setPortD }, { NULL, NULL } }; static CHOICE MIDIPorts[] = { - { " 220h", &CGEEngine::SetPortM }, - { " 230h", &CGEEngine::SetPortM }, - { " 240h", &CGEEngine::SetPortM }, - { " 250h", &CGEEngine::SetPortM }, - { " 300h", &CGEEngine::SetPortM }, - { " 320h", &CGEEngine::SetPortM }, - { " 330h", &CGEEngine::SetPortM }, - { " 340h", &CGEEngine::SetPortM }, - { " 350h", &CGEEngine::SetPortM }, - { " 360h", &CGEEngine::SetPortM }, - { "AUTO ", &CGEEngine::SetPortM }, + { " 220h", &CGEEngine::setPortM }, + { " 230h", &CGEEngine::setPortM }, + { " 240h", &CGEEngine::setPortM }, + { " 250h", &CGEEngine::setPortM }, + { " 300h", &CGEEngine::setPortM }, + { " 320h", &CGEEngine::setPortM }, + { " 330h", &CGEEngine::setPortM }, + { " 340h", &CGEEngine::setPortM }, + { " 350h", &CGEEngine::setPortM }, + { " 360h", &CGEEngine::setPortM }, + { "AUTO ", &CGEEngine::setPortM }, { NULL, NULL } }; static CHOICE BlsterIRQ[] = { - { "IRQ 2", &CGEEngine::SetIRQ }, - { "IRQ 5", &CGEEngine::SetIRQ }, - { "IRQ 7", &CGEEngine::SetIRQ }, - { "IRQ 10", &CGEEngine::SetIRQ }, - { "AUTO ", &CGEEngine::SetIRQ }, + { "IRQ 2", &CGEEngine::setIRQ }, + { "IRQ 5", &CGEEngine::setIRQ }, + { "IRQ 7", &CGEEngine::setIRQ }, + { "IRQ 10", &CGEEngine::setIRQ }, + { "AUTO ", &CGEEngine::setIRQ }, { NULL, NULL } }; static CHOICE GravisIRQ[] = { - { "IRQ 2", &CGEEngine::SetIRQ }, - { "IRQ 5", &CGEEngine::SetIRQ }, - { "IRQ 7", &CGEEngine::SetIRQ }, - { "IRQ 11", &CGEEngine::SetIRQ }, - { "IRQ 12", &CGEEngine::SetIRQ }, - { "IRQ 15", &CGEEngine::SetIRQ }, - { "AUTO ", &CGEEngine::SetIRQ }, + { "IRQ 2", &CGEEngine::setIRQ }, + { "IRQ 5", &CGEEngine::setIRQ }, + { "IRQ 7", &CGEEngine::setIRQ }, + { "IRQ 11", &CGEEngine::setIRQ }, + { "IRQ 12", &CGEEngine::setIRQ }, + { "IRQ 15", &CGEEngine::setIRQ }, + { "AUTO ", &CGEEngine::setIRQ }, { NULL, NULL } }; static CHOICE GravisDMA[] = { - { "DMA 1", &CGEEngine::SetDMA }, - { "DMA 3", &CGEEngine::SetDMA }, - { "DMA 5", &CGEEngine::SetDMA }, - { "DMA 6", &CGEEngine::SetDMA }, - { "DMA 7", &CGEEngine::SetDMA }, - { "AUTO ", &CGEEngine::SetDMA }, + { "DMA 1", &CGEEngine::setDMA }, + { "DMA 3", &CGEEngine::setDMA }, + { "DMA 5", &CGEEngine::setDMA }, + { "DMA 6", &CGEEngine::setDMA }, + { "DMA 7", &CGEEngine::setDMA }, + { "AUTO ", &CGEEngine::setDMA }, { NULL, NULL } }; static CHOICE BlsterDMA[] = { - { "DMA 0", &CGEEngine::SetDMA }, - { "DMA 1", &CGEEngine::SetDMA }, - { "DMA 3", &CGEEngine::SetDMA }, - { "AUTO ", &CGEEngine::SetDMA }, + { "DMA 0", &CGEEngine::setDMA }, + { "DMA 1", &CGEEngine::setDMA }, + { "DMA 3", &CGEEngine::setDMA }, + { "AUTO ", &CGEEngine::setDMA }, { NULL, NULL } }; -void CGEEngine::SelectSound() { +void CGEEngine::selectSound() { int i; Sound.Close(); if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); - Inf(Text->getText(STYPE_TEXT)); + inf(Text->getText(STYPE_TEXT)); Talk->Goto(Talk->_x, FONT_HIG / 2); for (i = 0; i < ArrayCount(DevName); i++) DevMenu[i].Text = Text->getText(DevName[i]); @@ -183,7 +183,7 @@ static CHOICE *Cho; static int Hlp; void CGEEngine::SNSelect() { - Inf(Text->getText(Hlp)); + inf(Text->getText(Hlp)); Talk->Goto(Talk->_x, FONT_HIG / 2); (new VMENU(this, Cho, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); } @@ -253,25 +253,25 @@ void CGEEngine::AUTO() { } -void CGEEngine::SetPortD() { +void CGEEngine::setPortD() { SNDDrvInfo.DBASE = xdeco(DigiPorts[VMENU::Recent].Text); Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); } -void CGEEngine::SetPortM() { +void CGEEngine::setPortM() { SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text); Sound.Open(); } -void CGEEngine::SetIRQ() { +void CGEEngine::setIRQ() { SNDDrvInfo.DIRQ = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); } -void CGEEngine::SetDMA() { +void CGEEngine::setDMA() { SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) Select(MIDIPorts, MPORT_TEXT); diff --git a/engines/cge/config.h b/engines/cge/config.h index e3fe094681..0f279ab047 100644 --- a/engines/cge/config.h +++ b/engines/cge/config.h @@ -30,7 +30,7 @@ namespace CGE { -void SelectSound(void); +void selectSound(); } // End of namespace CGE diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index 56d853f4e8..158857c002 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -41,10 +41,10 @@ enum EMM_FUN { }; -void *EMM::Frame = NULL; +void *EMM::_frame = NULL; -EMM::EMM(long size): Han(-1), Top(0), Lim(0), List(NULL) { +EMM::EMM(long size): _han(-1), _top(0), _lim(0), _list(NULL) { /* if (Test()) { @@ -97,7 +97,7 @@ EMM::~EMM(void) { } -bool EMM::Test(void) { +bool EMM::test() { /* static char e[] = "EMMXXXX0"; @@ -130,7 +130,7 @@ bool EMM::Test(void) { } -EMS *EMM::Alloc(uint16 siz) { +EMS *EMM::alloc(uint16 siz) { /* long size = SIZ(siz), top = Top; @@ -167,22 +167,22 @@ EMS *EMM::Alloc(uint16 siz) { } fail: return NULL; */ - warning("STUB: EMM::Alloc"); + warning("STUB: EMM::alloc"); return NULL; } -void EMM::Release(void) { - while (List) { - EMS *e = List; - List = e->Nxt; +void EMM::release() { + while (_list) { + EMS *e = _list; + _list = e->_next; delete e; } - Top = 0; + _top = 0; } -EMS::EMS(void) : Ptr(0), Siz(0), Nxt(NULL) { +EMS::EMS(void) : _ptr(0), _size(0), _next(NULL) { } @@ -193,7 +193,7 @@ void *EMS::operator & () const { cnt = (uint16) ((Ptr + SIZ(Siz) + PAGE_MASK) >> 14) - pgn, cmd = MAP_PAGE << 8; - _DX = Emm->Han; // take EMM handle + _DX = Emm->_han; // take EMM handle asm dec cnt // prapare for deferred checking asm or dx,dx // see if valid asm jns more // negative handle = unavailable @@ -218,8 +218,8 @@ void *EMS::operator & () const { } -uint16 EMS::Size(void) { - return Siz; +uint16 EMS::size() { + return _size; } } // End of namespace CGE diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 87daced31e..2a6bc85015 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -31,20 +31,20 @@ namespace CGE { -uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b) { +uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b) { uint8 *x = new uint8[256]; if (x) { uint16 i; for (i = 0; i < 256; i++) { - x[i] = Closest(pal, MkDAC(((uint16)(pal[i].R) * r) / 255, - ((uint16)(pal[i].G) * g) / 255, - ((uint16)(pal[i].B) * b) / 255)); + x[i] = Closest(pal, MkDAC(((uint16)(pal[i]._r) * r) / 255, + ((uint16)(pal[i]._g) * g) / 255, + ((uint16)(pal[i]._b) * b) / 255)); } } return x; } - +/* Useless? uint8 *Mark(DAC *pal) { #define f(c) (c ^ 63) uint8 *x = new uint8[256]; @@ -59,33 +59,33 @@ uint8 *Mark(DAC *pal) { return x; #undef f } +*/ - -int FLY::L = 20, - FLY::T = 40, - FLY::R = 110, - FLY::B = 100; +int Fly::_l = 20, + Fly::_t = 40, + Fly::_r = 110, + Fly::_b = 100; -FLY::FLY(CGEEngine *vm, Bitmap **shpl) - : Sprite(vm, shpl), Tx(0), Ty(0), _vm(vm) { +Fly::Fly(CGEEngine *vm, Bitmap **shpl) + : Sprite(vm, shpl), _tx(0), _ty(0), _vm(vm) { Step(new_random(2)); - Goto(L + new_random(R - L - _w), T + new_random(B - T - _h)); + Goto(_l + new_random(_r - _l - _w), _t + new_random(_b - _t - _h)); } -void FLY::Tick(void) { +void Fly::tick() { Step(); if (!_flags._kept) { if (new_random(10) < 1) { - Tx = new_random(3) - 1; - Ty = new_random(3) - 1; + _tx = new_random(3) - 1; + _ty = new_random(3) - 1; } - if (_x + Tx < L || _x + Tx + _w > R) - Tx = -Tx; - if (_y + Ty < T || _y + Ty + _h > B) - Ty = -Ty; - Goto(_x + Tx, _y + Ty); + if (_x + _tx < _l || _x + _tx + _w > _r) + _tx = -_tx; + if (_y + _ty < _t || _y + _ty + _h > _b) + _ty = -_ty; + Goto(_x + _tx, _y + _ty); } } diff --git a/engines/cge/game.h b/engines/cge/game.h index a64018aa58..3f86c97081 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -34,22 +34,25 @@ namespace CGE { -#define PAN_HIG 40 -#define LBound(s) (s->X <= 0) -#define RBound(s) (s->X+s->W >= SCR_WID) -#define TBound(s) (s->Y <= 0) -#define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG) - -int Sinus(long x); -uint8 *Glass(DAC *pal, uint8 r, uint8 g, uint8 b); -uint8 *Mark(DAC *pal); - -class FLY : public Sprite { - static int L, T, R, B; +//#define PAN_HIG 40 +//#define LBound(s) (s->X <= 0) +//#define RBound(s) (s->X+s->W >= SCR_WID) +//#define TBound(s) (s->Y <= 0) +//#define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG) + +//int sinus(long x); +uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b); +//uint8 *mark(DAC *pal); + +class Fly : public Sprite { + static int _l; + static int _t; + static int _r; + static int _b; public: - int Tx, Ty; - FLY(CGEEngine *vm, Bitmap **shpl); - void Tick(void); + int _tx, _ty; + Fly(CGEEngine *vm, Bitmap **shpl); + void tick(); private: CGEEngine *_vm; }; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 510456087f..0b761f2299 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -32,7 +32,7 @@ namespace CGE { -DAC StdPal[] = {// R G B +Dac _stdPal[] = {// R G B { 0, 60, 0}, // 198 { 0, 104, 0}, // 199 { 20, 172, 0}, // 200 @@ -212,12 +212,12 @@ char *dwtom(uint32 val, char *str, int radix, int len) { } IoHand::IoHand(IOMODE mode, CRYPT *crpt) - : XFILE(mode), _crypt(crpt), _seed(SEED) { + : XFile(mode), _crypt(crpt), _seed(SEED) { _file = new Common::File(); } IoHand::IoHand(const char *name, IOMODE mode, CRYPT *crpt) - : XFILE(mode), _crypt(crpt), _seed(SEED) { + : XFile(mode), _crypt(crpt), _seed(SEED) { // TODO: Check if WRI and/or UPD modes are needed, and map to a save file assert(mode == REA); @@ -231,7 +231,7 @@ IoHand::~IoHand(void) { } uint16 IoHand::read(void *buf, uint16 len) { - if (Mode == WRI || !_file->isOpen()) + if (_mode == WRI || !_file->isOpen()) return 0; uint16 bytesRead = _file->read(buf, len); @@ -327,7 +327,7 @@ EC void SNDMIDIStop() { // FIXME: STUB: SNDMIDIStop } -DATACK *LoadWave(XFILE *file, EMM *emm) { +DATACK *LoadWave(XFile *file, EMM *emm) { warning("STUB: LoadWave"); return NULL; } @@ -377,10 +377,9 @@ int new_random(int range) { } #define TIMER_INT 0x08 -//void interrupt (* ENGINE::OldTimer) (...) = NULL; +//void interrupt (* Engine_::oldTimer) (...) = NULL; -ENGINE::ENGINE (uint16 tdiv) -{ +Engine_::Engine_(uint16 tdiv) { /* // steal timer interrupt OldTimer = getvect(TIMER_INT); @@ -394,11 +393,10 @@ ENGINE::ENGINE (uint16 tdiv) asm mov al,ah asm out 0x40,al */ - warning("STUB: ENGINE::ENGINE"); + warning("STUB: Engine_::Engine_"); } -ENGINE::~ENGINE (void) -{ +Engine_::~Engine_() { /* // reset timer asm mov al,0x36 @@ -409,12 +407,12 @@ ENGINE::~ENGINE (void) // bring back timer interrupt setvect(TIMER_INT, OldTimer); */ - warning("STUB: ENGINE::~ENGINE"); + warning("STUB: Engine_::~Engine_"); } -DATACK::~DATACK (void) -{ - if (!e && Buf) free(Buf); +DATACK::~DATACK () { + if (!e && Buf) + free(Buf); } } // End of namespace CGE diff --git a/engines/cge/general.h b/engines/cge/general.h index 1ecec9fbe9..3c94e22ae4 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -54,59 +54,59 @@ enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM }; enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT }; enum IOMODE { REA, WRI, UPD }; -typedef struct { - uint8 R, G, B; -} DAC; +struct Dac { + uint8 _r, _g, _b; +}; typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); -class COUPLE { +class Couple { protected: - signed char A; - signed char B; + signed char _a; + signed char _b; public: - COUPLE(void) { } - COUPLE(const signed char a, const signed char b) : A(a), B(b) { } - COUPLE operator + (COUPLE c) { - return COUPLE(A + c.A, B + c.B); + Couple() { } + Couple(const signed char a, const signed char b) : _a(a), _b(b) { } + Couple operator + (Couple c) { + return Couple(_a + c._a, _b + c._b); } - void operator += (COUPLE c) { - A += c.A; - B += c.B; + void operator += (Couple c) { + _a += c._a; + _b += c._b; } - COUPLE operator - (COUPLE c) { - return COUPLE(A - c.A, B - c.B); + Couple operator - (Couple c) { + return Couple(_a - c._a, _b - c._b); } - void operator -= (COUPLE c) { - A -= c.A; - B -= c.B; + void operator -= (Couple c) { + _a -= c._a; + _b -= c._b; } - bool operator == (COUPLE c) { - return ((A - c.A) | (B - c.B)) == 0; + bool operator == (Couple c) { + return ((_a - c._a) | (_b - c._b)) == 0; } - bool operator != (COUPLE c) { + bool operator != (Couple c) { return !(operator == (c)); } - void Split(signed char &a, signed char &b) { - a = A; - b = B; + void split(signed char &a, signed char &b) { + a = _a; + b = _b; } }; -class ENGINE { +class Engine_ { protected: - static void (* OldTimer)(...); - static void NewTimer(...); + static void (* oldTimer)(...); + static void newTimer(...); public: - ENGINE(uint16 tdiv); - ~ENGINE(void); + Engine_(uint16 tdiv); + ~Engine_(void); }; @@ -115,29 +115,31 @@ class EMS; class EMM { friend class EMS; - bool Test(void); - long Top, Lim; - EMS *List; - int Han; - static void *Frame; + bool test(); + + long _top; + long _lim; + EMS *_list; + int _han; + static void *_frame; public: EMM(long size = 0); - ~EMM(void); - EMS *Alloc(uint16 siz); - void Release(void); + ~EMM(); + EMS *alloc(uint16 siz); + void release(); }; class EMS { friend class EMM; - EMM *Emm; - long Ptr; - uint16 Siz; - EMS *Nxt; + EMM *_emm; + long _ptr; + uint16 _size; + EMS *_next; public: - EMS(void); + EMS(); void *operator & () const; - uint16 Size(void); + uint16 size(void); }; @@ -162,28 +164,29 @@ T min(T A, T B) { #endif -class XFILE { +class XFile { public: - IOMODE Mode; - uint16 Error; - XFILE(void) : Mode(REA), Error(0) { } - XFILE(IOMODE mode) : Mode(mode), Error(0) { } + IOMODE _mode; + uint16 _error; + + XFile() : _mode(REA), _error(0) { } + XFile(IOMODE mode) : _mode(mode), _error(0) { } + virtual ~XFile() { } virtual uint16 read(void *buf, uint16 len) = 0; virtual uint16 write(void *buf, uint16 len) = 0; - virtual long mark(void) = 0; - virtual long size(void) = 0; + virtual long mark() = 0; + virtual long size() = 0; virtual long seek(long pos) = 0; - virtual ~XFILE() { } }; template -inline uint16 XRead(XFILE *xf, T *t) { +inline uint16 XRead(XFile *xf, T *t) { return xf->read((uint8 *) t, sizeof(*t)); } -class IoHand : public XFILE { +class IoHand : public XFile { protected: Common::File *_file; uint16 _seed; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index e9d9b4643f..a10ab21658 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -311,7 +311,7 @@ void SelectPocket(int n) { void PocFul(void) { - Hero->Park(); + Hero->park(); SNPOST(SNWAIT, -1, -1, Hero); SNPOST(SNSEQ, -1, POC_FUL, Hero); SNPOST(SNSOUND, -1, 2, Hero); @@ -544,7 +544,7 @@ static void SNRmTake(Sprite *spr) { void SNSeq(Sprite *spr, int val) { if (spr) { if (spr == Hero && val == 0) - Hero->Park(); + Hero->park(); else spr->Step(val); } @@ -846,17 +846,17 @@ static void SNSetRef(Sprite *spr, int nr) { void SNFlash(bool on) { if (on) { - DAC *pal = farnew(DAC, PAL_CNT); + Dac *pal = farnew(Dac, PAL_CNT); if (pal) { memcpy(pal, VGA::SysPal, PAL_SIZ); for (int i = 0; i < PAL_CNT; i++) { register int c; - c = pal[i].R << 1; - pal[i].R = (c < 64) ? c : 63; - c = pal[i].G << 1; - pal[i].G = (c < 64) ? c : 63; - c = pal[i].B << 1; - pal[i].B = (c < 64) ? c : 63; + c = pal[i]._r << 1; + pal[i]._r = (c < 64) ? c : 63; + c = pal[i]._g << 1; + pal[i]._g = (c < 64) ? c : 63; + c = pal[i]._b << 1; + pal[i]._b = (c < 64) ? c : 63; } Vga->SetColors(pal, 64); } @@ -883,16 +883,16 @@ static void SNBarrier(int cav, int bar, bool horz) { static void SNWalk(Sprite *spr, int x, int y) { if (Hero) { if (spr && y < 0) - Hero->FindWay(spr); + Hero->findWay(spr); else - Hero->FindWay(XZ(x, y)); + Hero->findWay(XZ(x, y)); } } static void SNReach(Sprite *spr, int mode) { if (Hero) - Hero->Reach(spr, mode); + Hero->reach(spr, mode); } @@ -937,7 +937,7 @@ void SNAIL::RunCom(void) { case SNWAIT : if (sprel) { if (sprel->SeqTest(snc->Val) && - (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) { + (snc->Val >= 0 || sprel != Hero || Hero->_tracePtr < 0)) { _heart->setXTimer(&Pause, sprel->_time); } else goto xit; @@ -959,7 +959,7 @@ void SNAIL::RunCom(void) { break; case SNINF : if (TalkEnable) { - _vm->Inf(Text->getText(snc->Val)); + _vm->inf(Text->getText(snc->Val)); Sys->FunDel = HEROFUN0; } break; diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index eecd3bacb2..a59179710b 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -104,7 +104,7 @@ void FX::Clear(void) { p->Wav = NULL; } } - Emm.Release(); + Emm.release(); Current = NULL; } @@ -190,12 +190,12 @@ void LoadMIDI(int ref) { if (INI_FILE::exist(fn)) { KillMIDI(); INI_FILE mid = fn; - if (mid.Error == 0) { + if (mid._error == 0) { uint16 siz = (uint16) mid.size(); midi = new uint8[siz]; if (midi) { mid.read(midi, siz); - if (mid.Error) + if (mid._error) KillMIDI(); else SNDMIDIStart(midi); @@ -211,12 +211,12 @@ EC void *Patch(int pat) { wtom(pat, fn + 5, 10, 3); INI_FILE snd = fn; - if (! snd.Error) { + if (!snd._error) { uint16 siz = (uint16) snd.size(); p = (uint8 *) malloc(siz); if (p) { snd.read(p, siz); - if (snd.Error) { + if (snd._error) { free(p); p = NULL; } diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index c8aa8292e8..fab1abc0d8 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -62,9 +62,9 @@ FONT::~FONT() { void FONT::Load() { INI_FILE f(Path); - if (! f.Error) { + if (!f._error) { f.read(Wid, WID_SIZ); - if (! f.Error) { + if (!f._error) { uint16 i, p = 0; for (i = 0; i < POS_SIZ; i++) { Pos[i] = p; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 7df51f1126..515c1091f8 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -88,7 +88,7 @@ int TEXT::Find(int ref) { void TEXT::Preload(int from, int upto) { INI_FILE tf = FileName; - if (! tf.Error) { + if (!tf._error) { HAN *CacheLim = Cache + Size; char line[LINE_MAX + 1]; int n; @@ -130,7 +130,7 @@ void TEXT::Preload(int from, int upto) { char *TEXT::Load(int idx, int ref) { INI_FILE tf = FileName; - if (! tf.Error) { + if (!tf._error) { HAN *p = &Cache[idx]; char line[LINE_MAX + 1]; int n; @@ -221,7 +221,7 @@ void TEXT::Say(const char *txt, Sprite *spr) { } } -void CGEEngine::Inf(const char *txt) { +void CGEEngine::inf(const char *txt) { KillText(); Talk = new TALK(this, txt, RECT); if (Talk) { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f26d202dca..d12bb9596c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -189,20 +189,20 @@ void RestoreScreen(uint16 * &sav) { } -DAC MkDAC(uint8 r, uint8 g, uint8 b) { - static DAC x; - x.R = r; - x.G = g; - x.B = b; +Dac MkDAC(uint8 r, uint8 g, uint8 b) { + static Dac x; + x._r = r; + x._g = g; + x._b = b; return x; } Rgb MkRGB(uint8 r, uint8 g, uint8 b) { static TRGB x; - x.dac.R = r; - x.dac.G = g; - x.dac.B = b; + x.dac._r = r; + x.dac._g = g; + x.dac._b = b; return x.rgb; } @@ -214,7 +214,7 @@ Sprite *Locate(int ref) { Heart::Heart(void) - : ENGINE(TMR_DIV) { + : Engine_(TMR_DIV) { _enable = false; _xTimer = NULL; } @@ -265,7 +265,7 @@ extern "C" void TimerProc() { */ -void ENGINE::NewTimer(...) { +void Engine_::newTimer(...) { /* static SPRITE *spr; static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; @@ -338,7 +338,7 @@ void ENGINE::NewTimer(...) { } */ - warning("STUB: ENGINE::NewTimer"); + warning("STUB: Engine_::NewTimer"); } @@ -505,7 +505,7 @@ Sprite *Sprite::Expand(void) { MergeExt(fname, File, SPR_EXT); if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); - if (! (sprf.Error==0)) + if (!(sprf._error==0)) error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; while ((len = sprf.read((uint8 *)line)) != 0) { @@ -910,7 +910,7 @@ Sprite *QUEUE::Locate(int ref) { //extern const char Copr[]; Graphics::Surface *VGA::Page[4]; -DAC *VGA::SysPal; +Dac *VGA::SysPal; void VGA::init() { for (int idx = 0; idx < 4; ++idx) { @@ -918,7 +918,7 @@ void VGA::init() { Page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - SysPal = new DAC[PAL_CNT]; + SysPal = new Dac[PAL_CNT]; } void VGA::deinit() { @@ -953,8 +953,8 @@ VGA::VGA(int mode) if (StatAdr != VGAST1_) ++Mono; if (IsVga()) { - OldColors = farnew(DAC, 256); - NewColors = farnew(DAC, 256); + OldColors = farnew(Dac, 256); + NewColors = farnew(Dac, 256); OldScreen = SaveScreen(); GetColors(OldColors); Sunset(); @@ -1061,45 +1061,45 @@ int VGA::SetMode(int mode) { } -void VGA::GetColors(DAC *tab) { +void VGA::GetColors(Dac *tab) { byte palData[PAL_SIZ]; g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT); pal2DAC(palData, tab); } -void VGA::pal2DAC(const byte *palData, DAC *tab) { +void VGA::pal2DAC(const byte *palData, Dac *tab) { const byte *colP = palData; for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { - tab[idx].R = *colP; - tab[idx].G = *(colP + 1); - tab[idx].B = *(colP + 2); + tab[idx]._r = *colP; + tab[idx]._g = *(colP + 1); + tab[idx]._b = *(colP + 2); } } -void VGA::DAC2pal(const DAC *tab, byte *palData) { +void VGA::DAC2pal(const Dac *tab, byte *palData) { for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { - *palData = tab[idx].R << 2; - *(palData + 1) = tab[idx].G << 2; - *(palData + 2) = tab[idx].B << 2; + *palData = tab[idx]._r << 2; + *(palData + 1) = tab[idx]._g << 2; + *(palData + 2) = tab[idx]._b << 2; } } -void VGA::SetColors(DAC *tab, int lum) { - DAC *palP = tab; +void VGA::SetColors(Dac *tab, int lum) { + Dac *palP = tab; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { - palP->R = (palP->R * lum) >> 6; - palP->G = (palP->G * lum) >> 6; - palP->B = (palP->B * lum) >> 6; + palP->_r = (palP->_r * lum) >> 6; + palP->_g = (palP->_g * lum) >> 6; + palP->_b = (palP->_b * lum) >> 6; } if (Mono) { palP = tab; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { // Form a greyscalce colour from 30% R, 59% G, 11% B - uint8 intensity = (palP->R * 77) + (palP->G * 151) + (palP->B * 28); - palP->R = intensity; - palP->G = intensity; - palP->B = intensity; + uint8 intensity = (palP->_r * 77) + (palP->_g * 151) + (palP->_b * 28); + palP->_r = intensity; + palP->_g = intensity; + palP->_b = intensity; } } @@ -1113,7 +1113,7 @@ void VGA::SetColors(void) { } -void VGA::Sunrise(DAC *tab) { +void VGA::Sunrise(Dac *tab) { for (int i = 0; i <= 64; i += FADE_STEP) { SetColors(tab, i); WaitVR(true); @@ -1123,7 +1123,7 @@ void VGA::Sunrise(DAC *tab) { void VGA::Sunset(void) { - DAC tab[256]; + Dac tab[256]; GetColors(tab); for (int i = 64; i >= 0; i -= FADE_STEP) { SetColors(tab, i); diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 0c75dd6ba9..a3d5ad949b 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -91,7 +91,7 @@ struct Rgb { }; typedef union { - DAC dac; + Dac dac; Rgb rgb; } TRGB; @@ -133,8 +133,8 @@ extern Seq _seq2[]; #define VGAST1 (VGAST1_ & 0xFF) -class Heart : public ENGINE { - friend class ENGINE; +class Heart : public Engine_ { + friend class Engine_; public: Heart(); @@ -263,7 +263,8 @@ class VGA { uint16 *OldScreen; uint16 StatAdr; bool SetPal; - DAC *OldColors, *NewColors; + Dac *OldColors; + Dac *NewColors; const char *Msg; const char *Nam; @@ -277,7 +278,7 @@ public: QUEUE *ShowQ, *SpareQ; int Mono; static Graphics::Surface *Page[4]; - static DAC *SysPal; + static Dac *SysPal; VGA(int mode); ~VGA(void); @@ -285,21 +286,21 @@ public: static void deinit(); void Setup(VgaRegBlk *vrb); - void GetColors(DAC *tab); - void SetColors(DAC *tab, int lum); + void GetColors(Dac *tab); + void SetColors(Dac *tab, int lum); void Clear(uint8 color); void CopyPage(uint16 d, uint16 s); - void Sunrise(DAC *tab); + void Sunrise(Dac *tab); void Sunset(void); void Show(void); void Update(void); - static void pal2DAC(const byte *palData, DAC *tab); - static void DAC2pal(const DAC *tab, byte *palData); + static void pal2DAC(const byte *palData, Dac *tab); + static void DAC2pal(const Dac *tab, byte *palData); }; -DAC MkDAC(uint8 r, uint8 g, uint8 b); +Dac MkDAC(uint8 r, uint8 g, uint8 b); Rgb MkRGB(uint8 r, uint8 g, uint8 b); @@ -307,15 +308,15 @@ template uint8 Closest(CBLK *pal, CBLK x) { #define f(col, lum) ((((uint16)(col)) << 8) / lum) uint16 i, dif = 0xFFFF, found = 0; - uint16 L = x.R + x.G + x.B; + uint16 L = x._r + x._g + x._b; if (!L) ++L; - uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); + uint16 R = f(x._r, L), G = f(x._g, L), B = f(x._b, L); for (i = 0; i < 256; i++) { - uint16 l = pal[i].R + pal[i].G + pal[i].B; + uint16 l = pal[i]._r + pal[i]._g + pal[i]._b; if (! l) ++l; - int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l); + int r = f(pal[i]._r, l), g = f(pal[i]._g, l), b = f(pal[i]._b, l); uint16 D = ((r > R) ? (r - R) : (R - r)) + ((g > G) ? (g - G) : (G - g)) + ((b > B) ? (b - B) : (B - b)) + diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 8170bd5980..5f8573706b 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -70,11 +70,11 @@ void VFILE::deinit() { VFILE::VFILE(const char *name, IOMODE mode) : IoBuf(mode) { if (mode == REA) { - if (_dat->_File.Error || _cat->Error) + if (_dat->_File._error || _cat->_error) error("Bad volume data"); BtKeypack *kp = _cat->find(name); if (scumm_stricmp(kp->_key, name) != 0) - Error = 1; + _error = 1; _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size; } #ifdef VOL_UPD diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 3423c43033..980c7672c3 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -49,7 +49,7 @@ class CKID { // Chunk type identifier uint32 Id; }; protected: - static XFILE *ckFile; + static XFile *ckFile; public: CKID(FOURCC t) { memcpy(Tx, t, sizeof(Tx)); @@ -57,7 +57,7 @@ public: CKID(uint32 d) { Id = d; } - CKID(XFILE *xf) { + CKID(XFile *xf) { (ckFile = xf)->read(Tx, sizeof(Tx)); } bool operator !=(CKID &X) { @@ -74,7 +74,7 @@ class CKHEA : public CKID { protected: CKSIZE ckSize; // Chunk size field (size of ckData) public: - CKHEA(XFILE *xf) : CKID(xf) { + CKHEA(XFile *xf) : CKID(xf) { XRead(xf, &ckSize); } CKHEA(char id[]) : CKID(id), ckSize(0) { } @@ -145,7 +145,7 @@ extern CKID FMT; extern CKID DATA; -DATACK *LoadWave(XFILE *file, EMM *emm = NULL); +DATACK *LoadWave(XFile *file, EMM *emm = NULL); } // End of namespace CGE -- cgit v1.2.3 From ac86efcd61aafe1ede9933f1d08b86b307de467a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 Jul 2011 18:04:21 +1000 Subject: CGE: Palette fixes so that first screen shows correctly --- engines/cge/bitmap.cpp | 9 ++++++++- engines/cge/general.cpp | 2 +- engines/cge/mouse.cpp | 6 +++--- engines/cge/vga13h.cpp | 26 +++++++++++++------------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 64a89e9381..959301bf50 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -409,9 +409,16 @@ bool Bitmap::loadVBM(XFile *f) { if (f->_error == 0) { if (p) { if (_pal) { + // Read in the palette byte palData[PAL_SIZ]; f->read(palData, PAL_SIZ); - VGA::pal2DAC(palData, _pal); + + const byte *srcP = palData; + for (int idx = 0; idx < PAL_CNT; ++idx, srcP += 3) { + _pal[idx]._r = *srcP; + _pal[idx]._g = *(srcP + 1); + _pal[idx]._b = *(srcP + 2); + } } else f->seek(f->mark() + PAL_SIZ); } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 0b761f2299..803100d0d4 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -136,7 +136,7 @@ char *ForceExt(char *buf, const char *nam, const char *ext) { return buf; } -static unsigned Seed = 1; +static unsigned Seed = 0xA5; unsigned FastRand(void) { return Seed = 257 * Seed + 817; diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index 5bdf7449fc..b16f4f52b2 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -53,11 +53,11 @@ MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold( __int__(0x33); Exist = (_AX != 0); Buttons = _BX; - +*/ Goto(SCR_WID/2, SCR_HIG/2); - Z = 127; + _z = 127; Step(1); - */ + Exist = true; warning("STUB: MOUSE::MOUSE"); } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d12bb9596c..e1bea9a15c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1070,9 +1070,9 @@ void VGA::GetColors(Dac *tab) { void VGA::pal2DAC(const byte *palData, Dac *tab) { const byte *colP = palData; for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { - tab[idx]._r = *colP; - tab[idx]._g = *(colP + 1); - tab[idx]._b = *(colP + 2); + tab[idx]._r = *colP >> 2; + tab[idx]._g = *(colP + 1) >> 2; + tab[idx]._b = *(colP + 2) >> 2; } } @@ -1085,21 +1085,21 @@ void VGA::DAC2pal(const Dac *tab, byte *palData) { } void VGA::SetColors(Dac *tab, int lum) { - Dac *palP = tab; - for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { - palP->_r = (palP->_r * lum) >> 6; - palP->_g = (palP->_g * lum) >> 6; - palP->_b = (palP->_b * lum) >> 6; + Dac *palP = tab, *destP = NewColors; + for (int idx = 0; idx < PAL_CNT; ++idx, ++palP, ++destP) { + destP->_r = (palP->_r * lum) >> 6; + destP->_g = (palP->_g * lum) >> 6; + destP->_b = (palP->_b * lum) >> 6; } if (Mono) { - palP = tab; + destP = NewColors; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { // Form a greyscalce colour from 30% R, 59% G, 11% B - uint8 intensity = (palP->_r * 77) + (palP->_g * 151) + (palP->_b * 28); - palP->_r = intensity; - palP->_g = intensity; - palP->_b = intensity; + uint8 intensity = (destP->_r * 77) + (destP->_g * 151) + (destP->_b * 28); + destP->_r = intensity; + destP->_g = intensity; + destP->_b = intensity; } } -- cgit v1.2.3 From c982298cbdf8220aa9a8151233e972f2c886c5fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 Jul 2011 18:17:58 +1000 Subject: CGE: Fix initialisation of the MOUSE class --- engines/cge/cge.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index c921d7c6ba..e844322e0e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -67,7 +67,6 @@ void CGEEngine::setup() { Hero = new WALK(this, NULL); Sys = new SYSTEM(this); _pocLight = new Sprite(this, LI); - Mouse = new MOUSE(this); for (int i = 0; i < POCKET_NX; i++) _pocket[i] = new Sprite(this, NULL); _sprite = new Sprite(this, NULL); @@ -97,6 +96,7 @@ void CGEEngine::setup() { Snail = new SNAIL(this, false); Snail_ = new SNAIL(this, true); + Mouse = new MOUSE(this); OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); } -- cgit v1.2.3 From 601bfbd6095a88b2f6b77d2dec16731fe4fbf687 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 Jul 2011 18:18:44 +1000 Subject: CGE: Reimplemented game timer from using thread to using getMillis() --- engines/cge/snail.cpp | 12 ++++++------ engines/cge/snail.h | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index a10ab21658..6600b75245 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -425,7 +425,7 @@ const char *SNAIL::ComTxt[] = { SNAIL::SNAIL(CGEEngine *vm, bool turbo) : Turbo(turbo), Busy(false), TextDelay(false), - Pause(0), TalkEnable(true), + _timerExpiry(0), TalkEnable(true), Head(0), Tail(0), SNList(farnew(COM, 256)), _vm(vm) { } @@ -446,7 +446,7 @@ void SNAIL::AddCom(SNCOM com, int ref, int val, void *ptr) { if (com == SNCLEAR) { Tail = Head; KillText(); - Pause = 0; + _timerExpiry = 0; } _enable(); } @@ -469,7 +469,7 @@ void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { if (com == SNCLEAR) { Tail = Head; KillText(); - Pause = 0; + _timerExpiry = 0; } _enable(); } @@ -913,7 +913,7 @@ void SNAIL::RunCom(void) { COM *snc = &SNList[Tail]; if (! Turbo) { // only for the slower one - if (Pause) + if (_timerExpiry && (_timerExpiry > g_system->getMillis())) break; else { if (TextDelay) { @@ -930,7 +930,7 @@ void SNAIL::RunCom(void) { case SNLABEL : break; case SNPAUSE : - _heart->setXTimer(&Pause, snc->Val); + _timerExpiry = g_system->getMillis() + snc->Val * SNAIL_FRAME_DELAY; if (Talk) TextDelay = true; break; @@ -938,7 +938,7 @@ void SNAIL::RunCom(void) { if (sprel) { if (sprel->SeqTest(snc->Val) && (snc->Val >= 0 || sprel != Hero || Hero->_tracePtr < 0)) { - _heart->setXTimer(&Pause, sprel->_time); + _timerExpiry = g_system->getMillis() + sprel->_time * SNAIL_FRAME_DELAY; } else goto xit; } diff --git a/engines/cge/snail.h b/engines/cge/snail.h index e1df628d3b..3221f5c02e 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -47,6 +47,8 @@ namespace CGE { #define SNPOST(c,r,v,p) Snail->AddCom(c,r,v,p) #define SNPOST_(c,r,v,p) Snail_->AddCom(c,r,v,p) +#define SNAIL_FRAME_RATE 62 +#define SNAIL_FRAME_DELAY (1000 / SNAIL_FRAME_RATE) typedef struct { uint8 Horz, Vert; @@ -87,7 +89,7 @@ public: } *SNList; uint8 Head, Tail; bool Turbo, Busy, TextDelay; - uint16 Pause; + uint32 _timerExpiry; static const char *ComTxt[]; bool TalkEnable; SNAIL(CGEEngine *vm, bool turbo = false); -- cgit v1.2.3 From 8e531d0da391b895a573c36c4b1bd8074571df83 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 2 Jul 2011 01:02:14 +0200 Subject: CGE: Some more renaming (WIP) --- engines/cge/bitmap.cpp | 23 +++---- engines/cge/bitmap.h | 16 ++--- engines/cge/cge.cpp | 2 +- engines/cge/cge_main.cpp | 165 +++++++++++++++++++++++------------------------ engines/cge/config.cpp | 8 +-- engines/cge/game.cpp | 8 +-- engines/cge/general.cpp | 61 +++++++++--------- engines/cge/general.h | 36 +++++------ engines/cge/gettext.cpp | 72 ++++++++++----------- engines/cge/gettext.h | 25 +++---- engines/cge/ident.h | 10 +-- engines/cge/jbw.h | 36 ++--------- engines/cge/keybd.cpp | 24 +++---- engines/cge/keybd.h | 22 +++---- engines/cge/mixer.cpp | 74 ++++++++++----------- engines/cge/mixer.h | 24 +++---- engines/cge/mouse.cpp | 20 +++--- engines/cge/snail.cpp | 100 ++++++++++++++-------------- engines/cge/snddrv.h | 16 ++--- engines/cge/sound.cpp | 2 +- engines/cge/startup.cpp | 51 ++++++++------- engines/cge/talk.cpp | 8 +-- engines/cge/text.cpp | 18 +++--- engines/cge/vga13h.cpp | 146 ++++++++++++++++++++--------------------- engines/cge/vga13h.h | 59 ++++++++--------- engines/cge/vmenu.cpp | 12 ++-- 26 files changed, 513 insertions(+), 525 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 959301bf50..dc06d9944e 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -48,7 +48,7 @@ void Bitmap::deinit() { #pragma argsused Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { char pat[MAXPATH]; - ForceExt(pat, fname, ".VBM"); + forceExt(pat, fname, ".VBM"); #if (BMP_MODE < 2) if (rem && PIC_FILE::exist(pat)) { @@ -130,10 +130,10 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL) { Bitmap::~Bitmap(void) { - if (MemType(_m) == FAR_MEM) + if (memType(_m) == FAR_MEM) free(_m); - switch (MemType(_v)) { + switch (memType(_v)) { case NEAR_MEM : delete[](uint8 *) _v; break; @@ -152,7 +152,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { _w = bmp._w; _h = bmp._h; _m = NULL; - if (MemType(_v) == FAR_MEM) + if (memType(_v) == FAR_MEM) free(_v); if (v0 == NULL) _v = NULL; @@ -174,7 +174,7 @@ uint16 Bitmap::moveVmap(uint8 *buf) { uint16 vsiz = (uint8 *)_b - (uint8 *)_v; uint16 siz = vsiz + _h * sizeof(HideDesc); memcpy(buf, _v, siz); - if (MemType(_v) == FAR_MEM) + if (memType(_v) == FAR_MEM) free(_v); _b = (HideDesc *)((_v = buf) + vsiz); return siz; @@ -188,7 +188,7 @@ BMP_PTR Bitmap::code(void) { uint16 i, cnt; if (_v) { // old X-map exists, so remove it - switch (MemType(_v)) { + switch (memType(_v)) { case NEAR_MEM : delete[](uint8 *) _v; break; @@ -450,19 +450,20 @@ bool Bitmap::loadBMP(XFile *f) { union { int16 _2E; int32 _2E_; }; union { int16 _32; int32 _32_; }; } hea; - BGR4 bpal[256]; + + Bgr4 bpal[256]; f->read((byte *)&hea, sizeof(hea)); if (f->_error == 0) { if (hea.hdr == 0x436L) { - int16 i = (hea.hdr - sizeof(hea)) / sizeof(BGR4); + int16 i = (hea.hdr - sizeof(hea)) / sizeof(Bgr4); f->read((byte *)&bpal, sizeof(bpal)); if (f->_error == 0) { if (_pal) { for (i = 0; i < 256; i ++) { - _pal[i]._r = bpal[i].R; - _pal[i]._g = bpal[i].G; - _pal[i]._b = bpal[i].B; + _pal[i]._r = bpal[i]._R; + _pal[i]._g = bpal[i]._G; + _pal[i]._b = bpal[i]._B; } _pal = NULL; } diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 99464bffeb..846f0149be 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -41,14 +41,14 @@ namespace CGE { #include "common/pack-start.h" -struct BGR4 { - uint16 b : 2; - uint16 B : 6; - uint16 g : 2; - uint16 G : 6; - uint16 r : 2; - uint16 R : 6; - uint16 Z : 8; +struct Bgr4 { + uint16 _b : 2; + uint16 _B : 6; + uint16 _g : 2; + uint16 _G : 6; + uint16 _r : 2; + uint16 _R : 6; + uint16 _Z : 8; }; diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index e844322e0e..43d74ab3a5 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -61,7 +61,7 @@ void CGEEngine::setup() { TALK::init(); // Initialise engine objects - Text = new TEXT(this, ProgName(), 128); + Text = new TEXT(this, progName(), 128); Vga = new VGA(M13H); _heart = new Heart; Hero = new WALK(this, NULL); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 2d4f004632..0d8bef4b85 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -136,7 +136,6 @@ int PocPtr = 0; static EMS *Mini = MiniEmm.alloc((uint16)MINI_EMM_SIZE); static BMP_PTR *MiniShpList = NULL; static BMP_PTR MiniShp[] = { NULL, NULL }; -static KEYBOARD Keyboard; static bool Finis = false; static int Startup = 1; int OffUseCount; @@ -282,7 +281,7 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { break; S._prev = S._next = NULL; - spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new Fly(this, NULL) + spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL) : new Sprite(this, NULL); if (spr == NULL) error("No core"); @@ -299,7 +298,7 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { static void SaveSound(void) { - CFile cfg(UsrPath(ProgName(CFG_EXT)), WRI); + CFile cfg(UsrPath(progName(CFG_EXT)), WRI); if (!cfg._error) cfg.write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2)); } @@ -365,7 +364,7 @@ static void noWay() { static void LoadHeroXY(void) { - INI_FILE cf(ProgName(".HXY")); + INI_FILE cf(progName(".HXY")); memset(HeroXY, 0, sizeof(HeroXY)); if (!cf._error) cf.CFREAD(&HeroXY); @@ -374,7 +373,7 @@ static void LoadHeroXY(void) { static void LoadMapping(void) { if (Now <= CAVE_MAX) { - INI_FILE cf(ProgName(".TAB")); + INI_FILE cf(progName(".TAB")); if (!cf._error) { memset(Cluster::_map, 0, sizeof(Cluster::_map)); cf.seek((Now - 1) * sizeof(Cluster::_map)); @@ -427,7 +426,7 @@ void WALK::tick() { turn(d); } } - Step(); + step(); if ((Dir == WW && _x <= 0) || (Dir == EE && _x + _w >= SCR_WID) || (Dir == SS && _y + _w >= WORLD_HIG - 2)) @@ -465,7 +464,7 @@ int WALK::distance(Sprite *spr) { void WALK::turn(DIR d) { DIR dir = (Dir == NO_DIR) ? SS : Dir; if (d != Dir) { - Step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); + step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); Dir = d; } } @@ -476,7 +475,7 @@ void WALK::park(void) { ++_time; if (Dir != NO_DIR) { - Step(9 + 4 * Dir + Dir); + step(9 + 4 * Dir + Dir); Dir = NO_DIR; _tracePtr = -1; } @@ -566,7 +565,7 @@ SQUARE::SQUARE(CGEEngine *vm) void SQUARE::Touch(uint16 mask, int x, int y) { - Sprite::Touch(mask, x, y); + Sprite::touch(mask, x, y); if (mask & L_UP) { XZ(_x + x, _y + y).cell() = 0; SNPOST_(SNKILL, -1, 0, this); @@ -578,11 +577,11 @@ void CGEEngine::setMapBrick(int x, int z) { SQUARE *s = new SQUARE(this); if (s) { static char n[] = "00:00"; - s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); + s->gotoxy(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); wtom(x, n + 0, 10, 2); wtom(z, n + 3, 10, 2); Cluster::_map[z][x] = 1; - s->SetName(n); + s->setName(n); Vga->ShowQ->Insert(s, Vga->ShowQ->First()); } } @@ -621,7 +620,7 @@ void CGEEngine::quit() { } else { QuitMenu[0].Text = Text->getText(QUIT_TEXT); QuitMenu[1].Text = Text->getText(NOQUIT_TEXT); - (new VMENU(this, QuitMenu, -1, -1))->SetName(Text->getText(QUIT_TITLE)); + (new VMENU(this, QuitMenu, -1, -1))->setName(Text->getText(QUIT_TITLE)); SNPOST_(SNSEQ, 123, 1, NULL); KeyClick(); } @@ -677,12 +676,12 @@ static void ShowBak(int ref) { Sprite *spr = Vga->SpareQ->Locate(ref); if (spr) { Bitmap::_pal = VGA::SysPal; - spr->Expand(); + spr->expand(); Bitmap::_pal = NULL; - spr->Show(2); + spr->show(2); Vga->CopyPage(1, 2); Sys->SetPal(); - spr->Contract(); + spr->contract(); } } @@ -701,7 +700,7 @@ static void caveUp() { if (spr->_cave == Now || spr->_cave == 0) if (spr->_ref != BakRef) { if (spr->_flags._back) - spr->BackShow(); + spr->backShow(); else ExpandSprite(spr); } @@ -715,9 +714,9 @@ static void caveUp() { } if (Hero) { - Hero->Goto(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); + Hero->gotoxy(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); // following 2 lines trims Hero's Z position! - Hero->Tick(); + Hero->tick(); Hero->_time = 1; Hero->_flags._hide = false; } @@ -732,7 +731,7 @@ static void caveUp() { if (_shadow) { Vga->ShowQ->Remove(_shadow); - _shadow->MakeXlat(glass(VGA::SysPal, 204, 204, 204)); + _shadow->makeXlat(glass(VGA::SysPal, 204, 204, 204)); Vga->ShowQ->Insert(_shadow, Hero); _shadow->_z = Hero->_z; } @@ -797,13 +796,13 @@ void CGEEngine::switchCave(int cav) { Mouse->Off(); if (Hero) { Hero->park(); - Hero->Step(0); + Hero->step(0); if (!_isDemo) ///// protection: auto-destruction on! ---------------------- Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX); /////-------------------------------------------------------- } - _cavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + _cavLight->gotoxy(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); KillText(); if (! Startup) @@ -838,16 +837,16 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { pp0 = pp; switch (x) { case Del: - if (KEYBOARD::Key[ALT] && KEYBOARD::Key[CTRL]) + if (Keyboard::_key[ALT] && Keyboard::_key[CTRL]) AltCtrlDel(); else KillSprite(); break; case 'F': - if (KEYBOARD::Key[ALT]) { + if (Keyboard::_key[ALT]) { Sprite *m = Vga->ShowQ->Locate(17001); if (m) { - m->Step(1); + m->step(1); m->_time = 216; // 3s } } @@ -862,7 +861,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { NextStep(); break; case '`': - if (KEYBOARD::Key[ALT]) + if (Keyboard::_key[ALT]) SaveMapping(); else _vm->switchMapping(); @@ -871,28 +870,28 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { SwitchDebug(); break; case F3: - Hero->Step(TSEQ + 4); + Hero->step(TSEQ + 4); break; case F4: - Hero->Step(TSEQ + 5); + Hero->step(TSEQ + 5); break; case F5: - Hero->Step(TSEQ + 0); + Hero->step(TSEQ + 0); break; case F6: - Hero->Step(TSEQ + 1); + Hero->step(TSEQ + 1); break; case F7: - Hero->Step(TSEQ + 2); + Hero->step(TSEQ + 2); break; case F8: - Hero->Step(TSEQ + 3); + Hero->step(TSEQ + 3); break; case F9: Sys->FunDel = 1; break; case 'X': - if (KEYBOARD::Key[ALT]) + if (Keyboard::_key[ALT]) Finis = true; break; case '0': @@ -900,7 +899,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { case '2': case '3': case '4': - if (KEYBOARD::Key[ALT]) { + if (Keyboard::_key[ALT]) { SNPOST(SNLEVEL, -1, x - '0', NULL); break; } @@ -910,7 +909,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { case '8': case '9': if (_sprite) - _sprite->Step(x - '0'); + _sprite->step(x - '0'); break; case F10 : if (Snail->Idle() && ! Hero->_flags._hide) @@ -1036,7 +1035,7 @@ static void SwitchColorMode(void) { static void SwitchMusic(void) { - if (KEYBOARD::Key[ALT]) { + if (Keyboard::_key[ALT]) { if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); else { @@ -1067,14 +1066,14 @@ void CGEEngine::startCountDown() { void CGEEngine::takeName() { - if (GET_TEXT::Ptr) - SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr); + if (GetText::_ptr) + SNPOST_(SNKILL, -1, 0, GetText::_ptr); else { - GET_TEXT *tn = new GET_TEXT(this, Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick); + GetText *tn = new GetText(this, Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick); if (tn) { - tn->SetName(Text->getText(GETNAME_TITLE)); - tn->Center(); - tn->Goto(tn->_x, tn->_y - 10); + tn->setName(Text->getText(GETNAME_TITLE)); + tn->center(); + tn->gotoxy(tn->_x, tn->_y - 10); tn->_z = 126; Vga->ShowQ->Insert(tn); } @@ -1146,14 +1145,14 @@ static void NextStep(void) { static void SaveMapping() { { - IoHand cf(ProgName(".TAB"), UPD); + IoHand cf(progName(".TAB"), UPD); if (!cf._error) { cf.seek((Now - 1) * sizeof(Cluster::_map)); cf.write((uint8 *) Cluster::_map, sizeof(Cluster::_map)); } } { - IoHand cf(ProgName(".HXY"), WRI); + IoHand cf(progName(".HXY"), WRI); if (!cf._error) { HeroXY[Now - 1]._x = Hero->_x; HeroXY[Now - 1]._y = Hero->_y; @@ -1186,7 +1185,7 @@ static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 0 static void SayDebug(void) { if (!DebugLine->_flags._hide) { static long t = -1L; - long t1 = Timer(); + long t1 = timer(); if (t1 - t >= 18) { static uint32 old = 0L; @@ -1239,9 +1238,9 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { if (mask & L_UP) SwitchMusic(); else if (mask & R_UP) - if (! MIXER::Appear) { - MIXER::Appear = true; - new MIXER(this, BUTTON_X, BUTTON_Y); + if (!Mixer::_appear) { + Mixer::_appear = true; + new Mixer(this, BUTTON_X, BUTTON_Y); } break; case 3 : @@ -1253,10 +1252,10 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { #pragma argsused -void Sprite::Touch(uint16 mask, int x, int y) { +void Sprite::touch(uint16 mask, int x, int y) { Sys->FunTouch(); if ((mask & ATTN) == 0) { - InfoLine->Update(Name()); + InfoLine->Update(name()); if (mask & (R_DN | L_DN)) _sprite = this; if (_ref / 10 == 12) { @@ -1273,7 +1272,7 @@ void Sprite::Touch(uint16 mask, int x, int y) { Sprite *ps = (_pocLight->_seqPtr) ? _pocket[PocPtr] : NULL; if (ps) { if (_flags._kept || Hero->distance(this) < MAX_DISTANCE) { - if (Works(ps)) { + if (works(ps)) { FeedSnail(ps, TAKE); } else OffUse(); @@ -1295,8 +1294,8 @@ void Sprite::Touch(uint16 mask, int x, int y) { _flags._port = false; } } else { - if (TakePtr != NO_PTR) { - if (SnList(TAKE)[TakePtr].Com == SNNEXT) + if (_takePtr != NO_PTR) { + if (snList(TAKE)[_takePtr].Com == SNNEXT) OffUse(); else FeedSnail(this, TAKE); @@ -1345,7 +1344,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int int i, lcnt = 0; uint16 len; - MergeExt(line, fname, SPR_EXT); + mergeExt(line, fname, SPR_EXT); if (INI_FILE::exist(line)) { // sprite description file exist INI_FILE sprf(line); if (sprf._error) @@ -1358,7 +1357,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int if (len == 0 || *line == '.') continue; - if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) + if ((i = takeEnum(Comd, strtok(line, " =\t"))) < 0) error("%s [%s]", NumStr("Bad line ######", lcnt), (const char *)fname); @@ -1366,7 +1365,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int case 0 : // Name - will be taken in Expand routine break; case 1 : // Type - if ((type = TakeEnum(Type, strtok(NULL, " \t,;/"))) < 0) + if ((type = takeEnum(Type, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad line ######", lcnt), (const char *)fname); break; case 2 : // Phase @@ -1394,7 +1393,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int case 1 : { // AUTO _sprite = new Sprite(this, NULL); if (_sprite) { - _sprite->Goto(col, row); + _sprite->gotoxy(col, row); //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$ } break; @@ -1402,7 +1401,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int case 2 : { // WALK WALK *w = new WALK(this, NULL); if (w && ref == 1) { - w->Goto(col, row); + w->gotoxy(col, row); if (Hero) error("2nd HERO [%s]", fname); Hero = w; @@ -1453,7 +1452,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int default: { // DEAD _sprite = new Sprite(this, NULL); if (_sprite) - _sprite->Goto(col, row); + _sprite->gotoxy(col, row); break; } } @@ -1468,8 +1467,8 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int _sprite->_flags._bDel = true; // Extract the filename, without the extension - strcpy(_sprite->File, fname); - char *p = strchr(_sprite->File, '.'); + strcpy(_sprite->_file, fname); + char *p = strchr(_sprite->_file, '.'); if (p) *p = '\0'; @@ -1574,14 +1573,14 @@ void CGEEngine::loadUser() { SVG0FILE file = SVG0FILE(SVG0NAME); loadGame(file); } else { - loadScript(ProgName(INI_EXT)); + loadScript(progName(INI_EXT)); Music = true; CFile file = CFile(SVG0NAME, WRI); SaveGame(file); error("Ok [%s]", SVG0NAME); } } - loadScript(ProgName(IN0_EXT)); + loadScript(progName(IN0_EXT)); } @@ -1602,7 +1601,7 @@ void CGEEngine::runGame() { { 1, 6, 0, 0, 4 }, { 0, 1, 0, 0, 16 }, }; - _pocLight->SetSeq(pocSeq); + _pocLight->setSeq(pocSeq); _pocLight->_flags._tran = true; _pocLight->_time = 1; _pocLight->_z = 120; @@ -1619,7 +1618,7 @@ void CGEEngine::runGame() { if ((_sprite = Vga->SpareQ->Locate(121)) != NULL) SNPOST_(SNSEQ, -1, Vga->Mono, _sprite); if ((_sprite = Vga->SpareQ->Locate(122)) != NULL) - _sprite->Step(Music); + _sprite->step(Music); SNPOST_(SNSEQ, -1, Music, _sprite); if (! Music) KillMIDI(); @@ -1631,9 +1630,9 @@ void CGEEngine::runGame() { ExpandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { _miniCave->_flags._hide = true; - _miniCave->MoveShapes(ptr); - MiniShp[0] = new Bitmap(*_miniCave->Shp()); - MiniShpList = _miniCave->SetShapeList(MiniShp); + _miniCave->moveShapes(ptr); + MiniShp[0] = new Bitmap(*_miniCave->shp()); + MiniShpList = _miniCave->setShapeList(MiniShp); PostMiniStep(-1); } } @@ -1641,7 +1640,7 @@ void CGEEngine::runGame() { if (Hero) { ExpandSprite(Hero); - Hero->Goto(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); + Hero->gotoxy(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); if (INI_FILE::exist("00SHADOW.SPR")) { loadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51); if ((_shadow = _sprite) != NULL) { @@ -1653,7 +1652,7 @@ void CGEEngine::runGame() { } } - InfoLine->Goto(INFO_X, INFO_Y); + InfoLine->gotoxy(INFO_X, INFO_Y); InfoLine->_flags._tran = true; InfoLine->Update(NULL); Vga->ShowQ->Insert(InfoLine); @@ -1672,11 +1671,11 @@ void CGEEngine::runGame() { Startup = 0; SNPOST(SNLEVEL, -1, OldLev, &_cavLight); - _cavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + _cavLight->gotoxy(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); caveUp(); - KEYBOARD::SetClient(Sys); + Keyboard::setClient(Sys); // main loop while (! Finis) { //TODO Change the SNPOST message send to a special way to send function pointer @@ -1685,7 +1684,7 @@ void CGEEngine::runGame() { mainLoop(); } - KEYBOARD::SetClient(NULL); + Keyboard::setClient(NULL); _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); @@ -1698,7 +1697,7 @@ void CGEEngine::runGame() { void CGEEngine::movie(const char *ext) { - const char *fn = ProgName(ext); + const char *fn = progName(ext); if (INI_FILE::exist(fn)) { loadScript(fn); ExpandSprite(Vga->SpareQ->Locate(999)); @@ -1708,11 +1707,11 @@ void CGEEngine::movie(const char *ext) { //Vga->ShowQ->Append(Mouse); _heart->_enable = true; - KEYBOARD::SetClient(Sys); + Keyboard::setClient(Sys); while (!Snail->Idle()) mainLoop(); - KEYBOARD::SetClient(NULL); + Keyboard::setClient(NULL); _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); @@ -1731,12 +1730,12 @@ bool CGEEngine::showTitle(const char *name) { Sprite D(this, LB); D._flags._kill = true; D._flags._bDel = true; - D.Center(); - D.Show(2); + D.center(); + D.show(2); if (STARTUP::Mode == 2) { inf(SVG0NAME); - Talk->Show(2); + Talk->show(2); } Vga->Sunset(); @@ -1764,7 +1763,7 @@ bool CGEEngine::showTitle(const char *name) { if (STARTUP::Mode < 2) { if (_isDemo) { - strcpy(UsrFnam, ProgName(SVG_EXT)); + strcpy(UsrFnam, progName(SVG_EXT)); usr_ok = true; } else { //----------------------------------------- @@ -1774,10 +1773,10 @@ bool CGEEngine::showTitle(const char *name) { #else // Boot * b = ReadBoot(getdisk()); warning("ShowTitle: FIXME ReadBoot"); - Boot *b = ReadBoot(0); + Boot *b = readBoot(0); uint32 sn = (b->_xSign == 0x29) ? b->_serial : b->_lTotSecs; free(b); - sn -= ((IDENT *)Copr)->disk; + sn -= ((Ident *)Copr)->_disk; STARTUP::Summa |= Lo(sn) | Hi(sn); #endif //----------------------------------------- @@ -1787,10 +1786,10 @@ bool CGEEngine::showTitle(const char *name) { Vga->ShowQ->Append(Mouse); //Mouse.On(); _heart->_enable = true; - for (takeName(); GET_TEXT::Ptr;) + for (takeName(); GetText::_ptr;) mainLoop(); _heart->_enable = false; - if (KEYBOARD::Last() == Enter && *UsrFnam) + if (Keyboard::last() == Enter && *UsrFnam) usr_ok = true; if (usr_ok) strcat(UsrFnam, SVG_EXT); diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 702c10ed15..8110e1702f 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -147,10 +147,10 @@ void CGEEngine::selectSound() { if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); inf(Text->getText(STYPE_TEXT)); - Talk->Goto(Talk->_x, FONT_HIG / 2); + Talk->gotoxy(Talk->_x, FONT_HIG / 2); for (i = 0; i < ArrayCount(DevName); i++) DevMenu[i].Text = Text->getText(DevName[i]); - (new VMENU(this, DevMenu, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); + (new VMENU(this, DevMenu, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->setName(Text->getText(MENU_TEXT)); } @@ -184,8 +184,8 @@ static int Hlp; void CGEEngine::SNSelect() { inf(Text->getText(Hlp)); - Talk->Goto(Talk->_x, FONT_HIG / 2); - (new VMENU(this, Cho, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT)); + Talk->gotoxy(Talk->_x, FONT_HIG / 2); + (new VMENU(this, Cho, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->setName(Text->getText(MENU_TEXT)); } diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 2a6bc85015..be93709f17 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -69,13 +69,13 @@ int Fly::_l = 20, Fly::Fly(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), _tx(0), _ty(0), _vm(vm) { - Step(new_random(2)); - Goto(_l + new_random(_r - _l - _w), _t + new_random(_b - _t - _h)); + step(new_random(2)); + gotoxy(_l + new_random(_r - _l - _w), _t + new_random(_b - _t - _h)); } void Fly::tick() { - Step(); + step(); if (!_flags._kept) { if (new_random(10) < 1) { _tx = new_random(3) - 1; @@ -85,7 +85,7 @@ void Fly::tick() { _tx = -_tx; if (_y + _ty < _t || _y + _ty + _h > _b) _ty = -_ty; - Goto(_x + _tx, _y + _ty); + gotoxy(_x + _tx, _y + _ty); } } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 803100d0d4..b285278842 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -95,12 +95,12 @@ Dac _stdPal[] = {// R G B DRVINFO SNDDrvInfo; -EC void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) { +void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) { warning("STUB: _fqsort"); } -const char *ProgName(const char *ext) { - warning("ProgName"); +const char *progName(const char *ext) { + warning("progName"); static Common::String buf = "CGE"; if (ext) @@ -108,11 +108,11 @@ const char *ProgName(const char *ext) { return buf.c_str(); } -char *MergeExt(char *buf, const char *nam, const char *ext) { +char *mergeExt(char *buf, const char *nam, const char *ext) { // char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; // fnmerge(buf, dr, di, na, (fnsplit(nam, dr, di, na, ex) & EXTENSION) ? ex : ext); // return buf; - warning("MergeExt"); + warning("mergeExt"); strcpy(buf, nam); char *dot = strrchr(buf, '.'); @@ -122,7 +122,7 @@ char *MergeExt(char *buf, const char *nam, const char *ext) { return buf; } -char *ForceExt(char *buf, const char *nam, const char *ext) { +char *forceExt(char *buf, const char *nam, const char *ext) { // char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; // fnsplit(nam, dr, di, na, ex); // fnmerge(buf, dr, di, na, ext); @@ -279,7 +279,7 @@ bool IoHand::exist(const char *name) { //#define EMS_ADR(a) (FP_SEG(a) > 0xA000) //#define HNODE_OK(p) (heapchecknode(p)==4) -MEM_TYPE MemType(void *mem) { +MEM_TYPE memType(void *mem) { /* if (FP_SEG(mem) == _DS) { if (heapchecknode((void *)mem)==4) return NEAR_MEM; @@ -291,39 +291,39 @@ MEM_TYPE MemType(void *mem) { } return BAD_MEM; */ - warning("STUB: MemType"); + warning("STUB: memType"); return FAR_MEM; } -bool IsVga() { +bool isVga() { return true; } -EC void SNDInit() { +void SNDInit() { warning("STUB: SNDInit"); } -EC void SNDDone() { +void SNDDone() { // FIXME: STUB: SNDDone } -EC void SNDSetVolume() { +void SNDSetVolume() { warning("STUB: SNDSetVolume"); } -EC void SNDDigiStart(SMPINFO *PSmpInfo) { +void SNDDigiStart(SMPINFO *PSmpInfo) { warning("STUB: SNDDigitStart"); } -EC void SNDDigiStop(SMPINFO *PSmpInfo) { +void SNDDigiStop(SMPINFO *PSmpInfo) { warning("STUB: SNDDigiStop"); } -EC void SNDMIDIStart(uint8 *MIDFile) { +void SNDMIDIStart(uint8 *MIDFile) { warning("STUB: SNDMIDIStart"); } -EC void SNDMIDIStop() { +void SNDMIDIStop() { // FIXME: STUB: SNDMIDIStop } @@ -332,7 +332,7 @@ DATACK *LoadWave(XFile *file, EMM *emm) { return NULL; } -int TakeEnum(const char **tab, const char *txt) { +int takeEnum(const char **tab, const char *txt) { const char **e; if (txt) { for (e = tab; *e; e++) { @@ -344,22 +344,25 @@ int TakeEnum(const char **tab, const char *txt) { return -1; } -Boot *ReadBoot(int drive) { +Boot *readBoot(int drive) { /* - struct fatinfo fi; Boot *b; - getfat(drive+1, &fi); - if (fi.fi_sclus & 0x80) return NULL; - if ((b = malloc(fi.fi_bysec)) == NULL) return NULL; - // read boot sector - if (absread(drive, 1, 0L, b) == 0) return b; - free(b); - return NULL; + struct fatinfo fi; Boot *b; + getfat(drive+1, &fi); + if (fi.fi_sclus & 0x80) + return NULL; + if ((b = malloc(fi.fi_bysec)) == NULL) + return NULL; + // read boot sector + if (absread(drive, 1, 0L, b) == 0) + return b; + free(b); + return NULL; */ - warning("STUB: ReadBoot"); + warning("STUB: readBoot"); return NULL; } -long Timer(void) { +long timer(void) { /* asm mov ax,0x40 asm mov es,ax @@ -367,7 +370,7 @@ long Timer(void) { asm mov dx,es:[0x6E] return ((long) _DX << 16) | _CX; */ - warning("STUB: Timer"); + warning("STUB: timer"); return 0; } diff --git a/engines/cge/general.h b/engines/cge/general.h index 3c94e22ae4..cff00fb7f3 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -208,35 +208,35 @@ public: CRYPT XCrypt; CRYPT RCrypt; -MEM_TYPE MemType(void *mem); +MEM_TYPE memType(void *mem); uint16 atow(const char *a); uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); char *dwtom(uint32 val, char *str, int radix, int len); -int TakeEnum(const char **tab, const char *txt); -uint16 ChkSum(void *m, uint16 n); -long Timer(void); -char *MergeExt(char *buf, const char *nam, const char *ext); -char *ForceExt(char *buf, const char *nam, const char *ext); -int DriveCD(unsigned drv); -bool IsVga(void); +int takeEnum(const char **tab, const char *txt); +uint16 chkSum(void *m, uint16 n); +long timer(); +char *mergeExt(char *buf, const char *nam, const char *ext); +char *forceExt(char *buf, const char *nam, const char *ext); +int driveCD(unsigned drv); +bool isVga(); // MISSING FUNCTIONS -EC void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)); -const char *ProgName(const char *ext = NULL); -char *MergeExt(char *buf, const char *nam, const char *ext); -char *ForceExt(char *buf, const char *nam, const char *ext); -unsigned FastRand(void); -unsigned FastRand(unsigned s); -uint16 RCrypt(void *buf, uint16 siz, uint16 seed); +void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)); +const char *progName(const char *ext = NULL); +char *mergeExt(char *buf, const char *nam, const char *ext); +char *forceExt(char *buf, const char *nam, const char *ext); +unsigned fastRand(void); +unsigned fastRand(unsigned s); +uint16 rCrypt(void *buf, uint16 siz, uint16 seed); uint16 atow(const char *a); uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); char *dwtom(uint32 val, char * str, int radix, int len); -int TakeEnum(const char **tab, const char *txt); -Boot *ReadBoot(int drive); -long Timer(void); +int takeEnum(const char **tab, const char *txt); +Boot *readBoot(int drive); +long timer(void); int new_random(int range); } // End of namespace CGE diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index e3c60b6e21..1b609e2d8b 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -33,56 +33,56 @@ namespace CGE { -GET_TEXT *GET_TEXT::Ptr = NULL; +GetText *GetText::_ptr = NULL; -GET_TEXT::GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void)) - : TALK(vm), Text(text), Size(min(size, GTMAX)), Len(min(Size, strlen(text))), - Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)), _vm(vm) { +GetText::GetText(CGEEngine *vm, const char *info, char *text, int size, void (*click)()) + : TALK(vm), _text(text), _size(min(size, GTMAX)), _len(min(_size, strlen(text))), + _cntr(GTBLINK), _click(click), _oldKeybClient(Keyboard::setClient(this)), _vm(vm) { int i = 2 * TEXT_HM + _Font->Width(info); - Ptr = this; + _ptr = this; Mode = RECT; TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); - SetShapeList(TS); + setShapeList(TS); _flags._bDel = true; _flags._kill = true; - memcpy(Buff, text, Len); - Buff[Len] = ' '; - Buff[Len + 1] = '\0'; + memcpy(_buff, text, _len); + _buff[_len] = ' '; + _buff[_len + 1] = '\0'; PutLine(0, info); - Tick(); + tick(); } -GET_TEXT::~GET_TEXT(void) { - KEYBOARD::SetClient(OldKeybClient); - Ptr = NULL; +GetText::~GetText() { + Keyboard::setClient(_oldKeybClient); + _ptr = NULL; } -void GET_TEXT::Tick(void) { - if (++ Cntr >= GTBLINK) { - Buff[Len] ^= (' ' ^ '_'); - Cntr = 0; +void GetText::tick() { + if (++_cntr >= GTBLINK) { + _buff[_len] ^= (' ' ^ '_'); + _cntr = 0; } - PutLine(1, Buff); + PutLine(1, _buff); _time = GTTIME; } -void GET_TEXT::Touch(uint16 mask, int x, int y) { +void GetText::touch(uint16 mask, int x, int y) { static char ogon[] = "•œ¥£˜ ¡"; static char bezo[] = "ACELNOSXZ"; char *p; if (mask & KEYB) { - if (Click) - Click(); + if (_click) + _click(); switch (x) { case Enter : - Buff[Len] = '\0'; - strcpy(Text, Buff); - for (p = Text; *p; p++) { + _buff[_len] = '\0'; + strcpy(_text, _buff); + for (p = _text; *p; p++) { char *q = strchr(ogon, *p); if (q) *p = bezo[q - ogon]; @@ -91,32 +91,32 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { SNPOST_(SNKILL, -1, 0, this); break; case BSp : - if (Len) { - --Len; - Buff[Len] = Buff[Len + 1]; - Buff[Len + 1] = Buff[Len + 2]; + if (_len) { + _len--; + _buff[_len] = _buff[_len + 1]; + _buff[_len + 1] = _buff[_len + 2]; } break; default : if (x < 'A' || x > 'Z') { - if (OldKeybClient) - OldKeybClient->Touch(mask, x, y); + if (_oldKeybClient) + _oldKeybClient->touch(mask, x, y); } else { - if (KEYBOARD::Key[ALT]) { + if (Keyboard::_key[ALT]) { p = strchr(bezo, x); if (p) x = ogon[p - bezo]; } - if (Len < Size && 2 * TEXT_HM + _Font->Width(Buff) + _Font->Wid[x] <= _w) { - Buff[Len + 2] = Buff[Len + 1]; - Buff[Len + 1] = Buff[Len]; - Buff[Len++] = x; + if (_len < _size && 2 * TEXT_HM + _Font->Width(_buff) + _Font->Wid[x] <= _w) { + _buff[_len + 2] = _buff[_len + 1]; + _buff[_len + 1] = _buff[_len]; + _buff[_len++] = x; } } break; } } else - Sprite::Touch(mask, x, y); + Sprite::touch(mask, x, y); } } // End of namespace CGE diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index 33210758af..059d84be41 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -37,18 +37,21 @@ namespace CGE { #define GTBLINK 6 #define GTTIME 6 -class GET_TEXT : public TALK { - char Buff[GTMAX + 2], * Text; - uint16 Size, Len; - uint16 Cntr; - Sprite *OldKeybClient; - void (*Click)(); +class GetText : public TALK { + char _buff[GTMAX + 2]; + char *_text; + uint16 _size; + uint16 _len; + uint16 _cntr; + Sprite *_oldKeybClient; + void (*_click)(); + public: - static GET_TEXT *Ptr; - GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void) = NULL); - ~GET_TEXT(); - void Touch(uint16 mask, int x, int y); - void Tick(); + static GetText *_ptr; + GetText(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void) = NULL); + ~GetText(); + void touch(uint16 mask, int x, int y); + void tick(); private: CGEEngine *_vm; diff --git a/engines/cge/ident.h b/engines/cge/ident.h index da36bfa682..afdb86d785 100644 --- a/engines/cge/ident.h +++ b/engines/cge/ident.h @@ -30,11 +30,11 @@ namespace CGE { -struct IDENT { - char copr[83]; - char fill[8]; - unsigned long disk; - unsigned char cork; +struct Ident { + char _copr[83]; + char _fill[8]; + unsigned long _disk; + unsigned char _cork; }; } // End of namespace CGE diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 12c6609f4e..359df8a216 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -59,7 +59,7 @@ namespace CGE { #define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) #define MAX_TIMER 0x1800B0L -typedef void (MouseFunType)(void); +typedef void (MouseFunType)(); #define Lo(d) (((int *) &d)[0]) #define Hi(d) (((int *) &d)[1]) @@ -68,7 +68,7 @@ typedef void (MouseFunType)(void); #define K(n) (1024 * (n)) #define MASK(n) ((1 << n) - 1) -typedef enum { +enum Keys { NoKey = 0, CtrlA, CtrlB, CtrlC, CtrlD, CtrlE, CtrlF, CtrlG, CtrlH, CtrlI, CtrlJ, CtrlK, CtrlL, CtrlM, CtrlN, CtrlO, CtrlP, CtrlQ, CtrlR, CtrlS, CtrlT, CtrlU, CtrlV, CtrlW, CtrlX, @@ -112,40 +112,16 @@ typedef enum { MouseRight, TwiceLeft = 512 + 256 + 1, TwiceRight -} Keys; - -struct KeyStatStruct { - int RShift : 1; - int LShift : 1; - int Ctrl : 1; - int Alt : 1; - - int ScrollLock : 1; - int NumLock : 1; - int CapsLock : 1; - int Ins : 1; - - int LeftCtrl : 1; - int LeftAlt : 1; - int Unused : 6; }; #define HGC_Cursor 0x0B0C #define CGA_Cursor 0x0607 #define OFF_Cursor 0x2000 -#define TimerCount (*((volatile long *) ((void _seg *) 0x40 + (void *) 0x6C))) -#define KeyStat (*((volatile struct KeyStatStruct *) ((void _seg *) 0x40 + (void *) 0x17))) -#define BreakFlag (*((volatile uint8 *) ((void _seg *) 0x40 + (void *) 0x71))) -#define PostFlag (*((volatile uint16 *) ((void _seg *) 0x40 + (void *) 0x72))) -#define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0)) - - -#ifdef __cplusplus -#define EC extern "C" -#else -#define EC -#endif +//#define TimerCount (*((volatile long *) ((void _seg *) 0x40 + (void *) 0x6C))) +//#define BreakFlag (*((volatile uint8 *) ((void _seg *) 0x40 + (void *) 0x71))) +//#define PostFlag (*((volatile uint16 *) ((void _seg *) 0x40 + (void *) 0x72))) +//#define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0)) extern uint16 _stklen; diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index 8530815b16..45237d15d1 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -30,10 +30,10 @@ namespace CGE { -Sprite *KEYBOARD::Client = NULL; -uint8 KEYBOARD::Key[0x60] = { 0 }; -uint16 KEYBOARD::Current = 0; -uint16 KEYBOARD::Code[0x60] = { +Sprite *Keyboard::_client = NULL; +uint8 Keyboard::_key[0x60] = { 0 }; +uint16 Keyboard::_current = 0; +uint16 Keyboard::_code[0x60] = { 0, Esc, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '+', BSp, @@ -56,20 +56,20 @@ uint16 KEYBOARD::Code[0x60] = { 0 * 0x5F }; -void (* KEYBOARD::OldKeyboard)(...); +void (* Keyboard::OldKeyboard)(...); -KEYBOARD::KEYBOARD(void) { +Keyboard::Keyboard() { // steal keyboard interrupt /* TODO replace totally by scummvm handling OldKeyboard = getvect(KEYBD_INT); setvect(KEYBD_INT, NewKeyboard); */ - warning("STUB: KEYBOARD::KEYBOARD"); + warning("STUB: Keyboard::Keyboard"); } -KEYBOARD::~KEYBOARD(void) { +Keyboard::~Keyboard() { // bring back keyboard interrupt /* TODO replace totally by scummvm handling setvect(KEYBD_INT, OldKeyboard); @@ -78,13 +78,13 @@ KEYBOARD::~KEYBOARD(void) { } -Sprite *KEYBOARD::SetClient(Sprite *spr) { - Swap(Client, spr); +Sprite *Keyboard::setClient(Sprite *spr) { + Swap(_client, spr); return spr; } -void KEYBOARD::NewKeyboard(...) { +void Keyboard::NewKeyboard(...) { // table address /* _SI = (uint16) Key; @@ -145,7 +145,7 @@ void KEYBOARD::NewKeyboard(...) { asm mov al,20h // send End-Of-Interrupt asm out 20h,al // to the 8259 IC */ - warning("STUB: KEYBOARD::NewKeyboard"); + warning("STUB: Keyboard::NewKeyboard"); } } // End of namespace CGE diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h index 2cdbd558d8..bb87ffb0ed 100644 --- a/engines/cge/keybd.h +++ b/engines/cge/keybd.h @@ -40,22 +40,22 @@ namespace CGE { #define ALT 56 -class KEYBOARD { +class Keyboard { public: static void (* OldKeyboard)(...); static void NewKeyboard(...); - static uint16 Code[0x60]; - static uint16 Current; - static Sprite *Client; - static uint8 Key[0x60]; - static uint16 Last(void) { - uint16 cur = Current; - Current = 0; + static uint16 _code[0x60]; + static uint16 _current; + static Sprite *_client; + static uint8 _key[0x60]; + static uint16 last() { + uint16 cur = _current; + _current = 0; return cur; } - static Sprite *SetClient(Sprite *spr); - KEYBOARD(void); - ~KEYBOARD(void); + static Sprite *setClient(Sprite *spr); + Keyboard(); + ~Keyboard(); }; } // End of namespace CGE diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index a5ef5b8b62..b6442f3cd3 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -37,19 +37,19 @@ namespace CGE { extern MOUSE *Mouse; -bool MIXER::Appear = false; +bool Mixer::_appear = false; -MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _vm(vm) { - Appear = true; - mb[0] = new Bitmap("VOLUME", true); - mb[1] = NULL; - SetShapeList(mb); - SetName(Text->getText(MIX_NAME)); +Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _vm(vm) { + _appear = true; + _mb[0] = new Bitmap("VOLUME", true); + _mb[1] = NULL; + setShapeList(_mb); + setName(Text->getText(MIX_NAME)); _flags._syst = true; _flags._kill = true; _flags._bDel = true; - Goto(x, y); + gotoxy(x, y); _z = MIX_Z; // slaves @@ -58,27 +58,27 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _v for (i = 0; i < MIX_MAX; i++) { static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); - lb[i] = new Bitmap(fn, true); - ls[i].Now = ls[i].Next = i; - ls[i].Dx = ls[i].Dy = ls[i].Dly = 0; + _lb[i] = new Bitmap(fn, true); + _ls[i].Now = _ls[i].Next = i; + _ls[i].Dx = _ls[i].Dy = _ls[i].Dly = 0; } - lb[i] = NULL; + _lb[i] = NULL; - for (i = 0; i < ArrayCount(Led); i++) { - register Sprite *spr = new Sprite(_vm, lb); - spr->SetSeq(ls); - spr->Goto(x + 2 + 12 * i, y + 8); + for (i = 0; i < ArrayCount(_led); i++) { + register Sprite *spr = new Sprite(_vm, _lb); + spr->setSeq(_ls); + spr->gotoxy(x + 2 + 12 * i, y + 8); spr->_flags._tran = true; spr->_flags._kill = true; spr->_flags._bDel = false; spr->_z = MIX_Z; - Led[i] = spr; + _led[i] = spr; } - Led[ArrayCount(Led) - 1]->_flags._bDel = true; + _led[ArrayCount(_led) - 1]->_flags._bDel = true; Vga->ShowQ->Insert(this); - for (i = 0; i < ArrayCount(Led); i++) - Vga->ShowQ->Insert(Led[i]); + for (i = 0; i < ArrayCount(_led); i++) + Vga->ShowQ->Insert(_led[i]); //--- reset balance i = (SNDDrvInfo.VOL4.ML + SNDDrvInfo.VOL4.MR) / 2; @@ -87,18 +87,18 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _v i = (SNDDrvInfo.VOL4.DL + SNDDrvInfo.VOL4.DR) / 2; SNDDrvInfo.VOL4.DL = i; SNDDrvInfo.VOL4.DR = i; - Update(); + update(); _time = MIX_DELAY; } -MIXER::~MIXER(void) { - Appear = false; +Mixer::~Mixer() { + _appear = false; } #pragma argsused -void MIXER::Touch(uint16 mask, int x, int y) { - Sprite::Touch(mask, x, y); +void Mixer::touch(uint16 mask, int x, int y) { + Sprite::touch(mask, x, y); if (mask & L_UP) { uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < _w / 2); if (y < MIX_BHIG) { @@ -108,24 +108,24 @@ void MIXER::Touch(uint16 mask, int x, int y) { if (*vol > 0x00) *vol -= 0x11; } - Update(); + update(); } } -void MIXER::Tick(void) { +void Mixer::tick() { int x = Mouse->_x; int y = Mouse->_y; if (SpriteAt(x, y) == this) { - Fall = MIX_FALL; + _fall = MIX_FALL; if (_flags._hold) - Touch(L_UP, x - _x, y - _y); + touch(L_UP, x - _x, y - _y); } else { - if (Fall) - --Fall; + if (_fall) + _fall--; else { - for (uint i = 0; i < ArrayCount(Led); i++) - SNPOST_(SNKILL, -1, 0, Led[i]); + for (uint i = 0; i < ArrayCount(_led); i++) + SNPOST_(SNKILL, -1, 0, _led[i]); SNPOST_(SNKILL, -1, 0, this); } } @@ -133,13 +133,13 @@ void MIXER::Tick(void) { } -void MIXER::Update(void) { - Led[0]->Step(SNDDrvInfo.VOL4.ML); - Led[1]->Step(SNDDrvInfo.VOL4.DL); +void Mixer::update(void) { + _led[0]->step(SNDDrvInfo.VOL4.ML); + _led[1]->step(SNDDrvInfo.VOL4.DL); //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST_(SNEXEC, -1, 0, (void*)&SNDSetVolume); - warning("STUB: MIXER::Update"); + warning("STUB: Mixer::Update"); } } // End of namespace CGE diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index d42d25ca24..a86e65d3d1 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -39,19 +39,19 @@ namespace CGE { #define MIX_BHIG 6 // mixer button high #define MIX_NAME 105 // sprite name -class MIXER : public Sprite { - BMP_PTR mb[2]; - BMP_PTR lb[MIX_MAX + 1]; - Seq ls[MIX_MAX]; - Sprite *Led[2]; - int Fall; - void Update(void); +class Mixer : public Sprite { + BMP_PTR _mb[2]; + BMP_PTR _lb[MIX_MAX + 1]; + Seq _ls[MIX_MAX]; + Sprite *_led[2]; + int _fall; + void update(); public: - static bool Appear; - MIXER(CGEEngine *vm, int x, int y); - ~MIXER(); - void Touch(uint16 mask, int x, int y); - void Tick(); + static bool _appear; + Mixer(CGEEngine *vm, int x, int y); + ~Mixer(); + void touch(uint16 mask, int x, int y); + void tick(); private: CGEEngine *_vm; }; diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index b16f4f52b2..a1b6b253ce 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -45,7 +45,7 @@ MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold( { 1, 1, 0, 0, 1 } }; - SetSeq(ms); + setSeq(ms); /* TODO Mouse handling // Mouse reset @@ -54,9 +54,9 @@ MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold( Exist = (_AX != 0); Buttons = _BX; */ - Goto(SCR_WID/2, SCR_HIG/2); + gotoxy(SCR_WID/2, SCR_HIG/2); _z = 127; - Step(1); + step(1); Exist = true; warning("STUB: MOUSE::MOUSE"); @@ -144,25 +144,25 @@ void MOUSE::ClrEvt(Sprite *spr) { void MOUSE::Tick(void) { - Step(); + step(); while (EvtTail != EvtHead) { Event e = Evt[EvtTail]; if (e._msk) { if (Hold && e._ptr != Hold) - Hold->Touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y); + Hold->touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y); // update mouse cursor position if (e._msk & ROLL) - Goto(e._x, e._y); + gotoxy(e._x, e._y); // activate current touched SPRITE if (e._ptr) { if (e._msk & KEYB) - e._ptr->Touch(e._msk, e._x, e._y); + e._ptr->touch(e._msk, e._x, e._y); else - e._ptr->Touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y); + e._ptr->touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y); } else if (Sys) - Sys->Touch(e._msk, e._x, e._y); + Sys->touch(e._msk, e._x, e._y); if (e._msk & L_DN) { Hold = e._ptr; @@ -188,7 +188,7 @@ void MOUSE::Tick(void) { EvtTail = (EvtTail + 1) % EVT_MAX; } if (Hold) - Hold->Goto(_x - hx, _y - hy); + Hold->gotoxy(_x - hx, _y - hy); } } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 6600b75245..baaac250dd 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -177,14 +177,14 @@ static void SNGame(Sprite *spr, int num) { SNPOST(SNGAME, 20002, 2, NULL); Game = true; } else { // cont - k1->Step(new_random(6)); - k2->Step(new_random(6)); - k3->Step(new_random(6)); + k1->step(new_random(6)); + k2->step(new_random(6)); + k3->step(new_random(6)); ///-------------------- - if (spr->_ref == 1 && KEYBOARD::Key[ALT]) { - k1->Step(5); - k2->Step(5); - k3->Step(5); + if (spr->_ref == 1 && Keyboard::_key[ALT]) { + k1->step(5); + k2->step(5); + k3->step(5); } ///-------------------- SNPOST(SNSETZ, 20700, 0, NULL); @@ -207,7 +207,7 @@ static void SNGame(Sprite *spr, int num) { Game = false; return; } else - k3->Step(new_random(5)); + k3->step(new_random(5)); } if (count < 100) { switch (count) { @@ -296,17 +296,17 @@ int FindPocket(Sprite *spr) { void SelectPocket(int n) { if (n < 0 || (_pocLight->_seqPtr && PocPtr == n)) { - _pocLight->Step(0); + _pocLight->step(0); n = FindPocket(NULL); if (n >= 0) PocPtr = n; } else { if (_pocket[n] != NULL) { PocPtr = n; - _pocLight->Step(1); + _pocLight->step(1); } } - _pocLight->Goto(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); + _pocLight->gotoxy(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); } @@ -321,7 +321,7 @@ void PocFul(void) { void Hide1(Sprite *spr) { - SNPOST_(SNGHOST, -1, 0, spr->Ghost()); + SNPOST_(SNGHOST, -1, 0, spr->ghost()); } @@ -336,11 +336,11 @@ void SNGhost(Bitmap *bmp) { void FeedSnail(Sprite *spr, SNLIST snq) { if (spr) - if (spr->Active()) { - uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; + if (spr->active()) { + uint8 ptr = (snq == TAKE) ? spr->_takePtr : spr->_nearPtr; if (ptr != NO_PTR) { - SNAIL::COM *comtab = spr->SnList(snq); + SNAIL::COM *comtab = spr->snList(snq); SNAIL::COM *c = comtab + ptr; if (FindPocket(NULL) < 0) { // no empty pockets? @@ -362,7 +362,7 @@ void FeedSnail(Sprite *spr, SNLIST snq) { if (c->Com == SNNEXT) { Sprite *s = (c->Ref < 0) ? spr : Locate(c->Ref); if (s) { - uint8 *idx = (snq == TAKE) ? &s->TakePtr : &s->NearPtr; + uint8 *idx = (snq == TAKE) ? &s->_takePtr : &s->_nearPtr; if (*idx != NO_PTR) { int v; switch (c->Val) { @@ -389,7 +389,7 @@ void FeedSnail(Sprite *spr, SNLIST snq) { if (c->Com == SNIF) { Sprite *s = (c->Ref < 0) ? spr : Locate(c->Ref); if (s) { // sprite extsts - if (! s->SeqTest(-1)) + if (! s->seqTest(-1)) c = comtab + c->Val; // not parked else ++c; @@ -477,35 +477,35 @@ void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { static void SNNNext(Sprite *sprel, int p) { if (sprel) - if (sprel->NearPtr != NO_PTR) - sprel->NearPtr = p; + if (sprel->_nearPtr != NO_PTR) + sprel->_nearPtr = p; } static void SNTNext(Sprite *sprel, int p) { if (sprel) - if (sprel->TakePtr != NO_PTR) - sprel->TakePtr = p; + if (sprel->_takePtr != NO_PTR) + sprel->_takePtr = p; } static void SNRNNext(Sprite *sprel, int p) { if (sprel) - if (sprel->NearPtr != NO_PTR) - sprel->NearPtr += p; + if (sprel->_nearPtr != NO_PTR) + sprel->_nearPtr += p; } static void SNRTNext(Sprite *sprel, int p) { if (sprel) - if (sprel->TakePtr != NO_PTR) - sprel->TakePtr += p; + if (sprel->_takePtr != NO_PTR) + sprel->_takePtr += p; } static void SNZTrim(Sprite *spr) { if (spr) - if (spr->Active()) { + if (spr->active()) { bool en = _heart->_enable; Sprite *s; _heart->_enable = false; @@ -531,13 +531,13 @@ static void SNHide(Sprite *spr, int val) { static void SNRmNear(Sprite *spr) { if (spr) - spr->NearPtr = NO_PTR; + spr->_nearPtr = NO_PTR; } static void SNRmTake(Sprite *spr) { if (spr) - spr->TakePtr = NO_PTR; + spr->_takePtr = NO_PTR; } @@ -546,7 +546,7 @@ void SNSeq(Sprite *spr, int val) { if (spr == Hero && val == 0) Hero->park(); else - spr->Step(val); + spr->step(val); } } @@ -577,7 +577,7 @@ void SNSend(Sprite *spr, int val) { if (spr->_ref % 1000 == 0) Bitmap::_pal = VGA::SysPal; if (spr->_flags._back) - spr->BackShow(true); + spr->backShow(true); else ExpandSprite(spr); Bitmap::_pal = NULL; @@ -628,7 +628,7 @@ void SNCover(Sprite *spr, int xref) { spr->_flags._hide = true; xspr->_z = spr->_z; xspr->_cave = spr->_cave; - xspr->Goto(spr->_x, spr->_y); + xspr->gotoxy(spr->_x, spr->_y); ExpandSprite(xspr); if ((xspr->_flags._shad = spr->_flags._shad) == 1) { Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr->_prev), xspr); @@ -643,7 +643,7 @@ void SNUncover(Sprite *spr, Sprite *xspr) { if (spr && xspr) { spr->_flags._hide = false; spr->_cave = xspr->_cave; - spr->Goto(xspr->_x, xspr->_y); + spr->gotoxy(xspr->_x, xspr->_y); if ((spr->_flags._shad = xspr->_flags._shad) == 1) { Vga->ShowQ->Insert(Vga->ShowQ->Remove(xspr->_prev), spr); xspr->_flags._shad = false; @@ -668,19 +668,19 @@ void SNSetY0(int cav, int y0) { void SNSetXY(Sprite *spr, uint16 xy) { if (spr) - spr->Goto(xy % SCR_WID, xy / SCR_WID); + spr->gotoxy(xy % SCR_WID, xy / SCR_WID); } void SNRelX(Sprite *spr, int x) { if (spr && Hero) - spr->Goto(Hero->_x + x, spr->_y); + spr->gotoxy(Hero->_x + x, spr->_y); } void SNRelY(Sprite *spr, int y) { if (spr && Hero) - spr->Goto(spr->_x, Hero->_y + y); + spr->gotoxy(spr->_x, Hero->_y + y); } @@ -694,13 +694,13 @@ void SNRelZ(Sprite *spr, int z) { void SNSetX(Sprite *spr, int x) { if (spr) - spr->Goto(x, spr->_y); + spr->gotoxy(x, spr->_y); } void SNSetY(Sprite *spr, int y) { if (spr) - spr->Goto(spr->_x, y); + spr->gotoxy(spr->_x, y); } @@ -716,7 +716,7 @@ void SNSetZ(Sprite *spr, int z) { void SNSlave(Sprite *spr, int ref) { Sprite *slv = Locate(ref); if (spr && slv) { - if (spr->Active()) { + if (spr->active()) { SNSend(slv, spr->_cave); slv->_flags._slav = true; slv->_z = spr->_z; @@ -780,10 +780,10 @@ void SNKeep(Sprite *spr, int stp) { _pocket[PocPtr] = spr; spr->_cave = 0; spr->_flags._kept = true; - spr->Goto(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->_w / 2, + spr->gotoxy(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->_w / 2, POCKET_Y + POCKET_DY / 2 - spr->_h / 2); if (stp >= 0) - spr->Step(stp); + spr->step(stp); } SelectPocket(-1); } @@ -797,7 +797,7 @@ void SNGive(Sprite *spr, int stp) { spr->_cave = Now; spr->_flags._kept = false; if (stp >= 0) - spr->Step(stp); + spr->step(stp); } } SelectPocket(-1); @@ -807,8 +807,8 @@ void SNGive(Sprite *spr, int stp) { static void SNBackPt(Sprite *spr, int stp) { if (spr) { if (stp >= 0) - spr->Step(stp); - spr->BackShow(true); + spr->step(stp); + spr->backShow(true); } } @@ -823,7 +823,7 @@ static void SNLevel(Sprite *spr, int lev) { ++Lev; spr = Vga->SpareQ->Locate(100 + Lev); if (spr) { - spr->BackShow(true); + spr->backShow(true); spr->_cave = 0; } } @@ -936,7 +936,7 @@ void SNAIL::RunCom(void) { break; case SNWAIT : if (sprel) { - if (sprel->SeqTest(snc->Val) && + if (sprel->seqTest(snc->Val) && (snc->Val >= 0 || sprel != Hero || Hero->_tracePtr < 0)) { _timerExpiry = g_system->getMillis() + sprel->_time * SNAIL_FRAME_DELAY; } else @@ -951,8 +951,8 @@ void SNAIL::RunCom(void) { break; case SNSAY : if (sprel && TalkEnable) { - if (sprel == Hero && sprel->SeqTest(-1)) - sprel->Step(HTALK); + if (sprel == Hero && sprel->seqTest(-1)) + sprel->step(HTALK); Text->Say(Text->getText(snc->Val), sprel); Sys->FunDel = HEROFUN0; } @@ -965,8 +965,8 @@ void SNAIL::RunCom(void) { break; case SNTIME : if (sprel && TalkEnable) { - if (sprel == Hero && sprel->SeqTest(-1)) - sprel->Step(HTALK); + if (sprel == Hero && sprel->seqTest(-1)) + sprel->step(HTALK); SayTime(sprel); } break; @@ -1106,7 +1106,7 @@ void SNAIL::RunCom(void) { // ((void(*)(int)) (snc->Ptr))(snc->Val); break; warning("STUB: SNEXEC code"); case SNSTEP : - sprel->Step(); + sprel->step(); break; case SNZTRIM : SNZTrim(sprel); diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 3d1658e1e0..2de9014034 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -101,29 +101,29 @@ extern uint16 MIDIEndFlag; // * Driver Code * // ****************************************************** // Init Digi Device -EC void SNDInit(void); +void SNDInit(); // Close Digi Device -EC void SNDDone(void); +void SNDDone(); // Set Volume -EC void SNDSetVolume(void); +void SNDSetVolume(); // Start Digi -EC void SNDDigiStart(SMPINFO *PSmpInfo); +void SNDDigiStart(SMPINFO *PSmpInfo); // Stop Digi -EC void SNDDigiStop(SMPINFO *PSmpInfo); +void SNDDigiStop(SMPINFO *PSmpInfo); // Start MIDI File -EC void SNDMIDIStart(uint8 *MIDFile); +void SNDMIDIStart(uint8 *MIDFile); // Stop MIDI File -EC void SNDMIDIStop(void); +void SNDMIDIStop(); // Play MIDI File (to be called while interrupting) // WARNING: Uses ALL registers! -EC void SNDMIDIPlay(void); +void SNDMIDIPlay(); } // End of namespace CGE diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index a59179710b..75adf3868a 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -205,7 +205,7 @@ void LoadMIDI(int ref) { } -EC void *Patch(int pat) { +void *Patch(int pat) { void *p = NULL; static char fn[] = "PATCH000.SND"; diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 4895ce9861..028e4c61b1 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -39,7 +39,7 @@ namespace CGE { extern char Copr[]; -#define id (*(IDENT*)Copr) +#define id (*(Ident*)Copr) EMM MiniEmm = MINI_EMM_SIZE; @@ -65,7 +65,7 @@ bool STARTUP::get_parms(void) { { static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", "P", "D", "I", "M" }; - int n = TakeEnum(PrmTab, strtok(_argv[--i], " =:(")); + int n = takeEnum(PrmTab, strtok(_argv[--i], " =:(")); uint16 p = xtow(strtok(NULL, " h,)")); switch (n) { @@ -99,7 +99,7 @@ bool STARTUP::get_parms(void) { Summa = 0; #else // disk signature checksum - Summa = ChkSum(Copr, sizeof(IDENT)); + Summa = ChkSum(Copr, sizeof(Ident)); #endif #endif if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; @@ -112,26 +112,31 @@ bool STARTUP::get_parms(void) { STARTUP::STARTUP(void) { /* - uint32 m = farcoreleft() >> 10; - if (m < 0x7FFF) Core = (int) m; else Core = 0x7FFF; - - if (! IsVga()) quit_now(NOT_VGA_TEXT); - if (Cpu() < _80286) quit_now(BAD_CHIP_TEXT); - if (100 * _osmajor + _osminor < 330) quit_now(BAD_DOS_TEXT); - - if (! get_parms()) quit_now(BAD_ARG_TEXT); - //--- load sound configuration - const char * fn = UsrPath(ProgName(CFG_EXT)); - if (! STARTUP::SoundOk && CFILE::Exist(fn)) - { - CFILE cfg(fn, REA); - if (! cfg.Error) - { - cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); - if (! cfg.Error) STARTUP::SoundOk = 1; - } - } - */ + uint32 m = farcoreleft() >> 10; + if (m < 0x7FFF) + Core = (int) m; + else + Core = 0x7FFF; + + if (! IsVga()) + quit_now(NOT_VGA_TEXT); + if (Cpu() < _80286) + quit_now(BAD_CHIP_TEXT); + if (100 * _osmajor + _osminor < 330) + quit_now(BAD_DOS_TEXT); + if (! get_parms()) + quit_now(BAD_ARG_TEXT); + //--- load sound configuration + const char * fn = UsrPath(ProgName(CFG_EXT)); + if (! STARTUP::SoundOk && CFILE::Exist(fn)) { + CFILE cfg(fn, REA); + if (! cfg.Error) { + cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); + if (! cfg.Error) + STARTUP::SoundOk = 1; + } + } + */ warning("STUB: STARTUP::STARTUP"); } diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index fab1abc0d8..38625e2971 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -48,7 +48,7 @@ FONT::FONT(const char *name) { Wid = farnew(uint8, WID_SIZ); if ((Map == NULL) || (Pos == NULL) || (Wid == NULL)) error("No core"); - MergeExt(Path, name, FONT_EXT); + mergeExt(Path, name, FONT_EXT); Load(); } @@ -126,7 +126,7 @@ TALK::~TALK (void) { FONT *TALK::_Font; void TALK::init() { - _Font = new FONT(ProgName()); + _Font = new FONT(progName()); } void TALK::deinit() { @@ -182,7 +182,7 @@ void TALK::Update(const char *tx) { tx++; } TS[0]->code(); - SetShapeList(TS); + setShapeList(TS); } @@ -286,7 +286,7 @@ void TALK::PutLine(int line, const char *text) { INFO_LINE::INFO_LINE(CGEEngine *vm, uint16 w) : TALK(vm), OldTxt(NULL), _vm(vm) { TS[0] = new Bitmap(w, FONT_HIG, TEXT_BG); - SetShapeList(TS); + setShapeList(TS); } diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 515c1091f8..f98b7f5d1c 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -44,7 +44,7 @@ TALK *Talk = NULL; TEXT::TEXT(CGEEngine *vm, const char *fname, int size) : _vm(vm) { Cache = new HAN[size]; - MergeExt(FileName, fname, SAY_EXT); + mergeExt(FileName, fname, SAY_EXT); if (!INI_FILE::exist(FileName)) error("No talk (%s)\n", FileName); @@ -203,17 +203,17 @@ void TEXT::Say(const char *txt, Sprite *spr) { Talk->_flags._kill = true; Talk->_flags._bDel = true; - Talk->SetName(Text->getText(SAY_NAME)); - Talk->Goto(x - (Talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - Talk->_h + 1); + Talk->setName(Text->getText(SAY_NAME)); + Talk->gotoxy(x - (Talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - Talk->_h + 1); Talk->_z = 125; Talk->_ref = SAY_REF; - spike->Goto(x, Talk->_y + Talk->_h - 1); + spike->gotoxy(x, Talk->_y + Talk->_h - 1); spike->_z = 126; spike->_flags._slav = true; spike->_flags._kill = true; - spike->SetName(Text->getText(SAY_NAME)); - spike->Step(east); + spike->setName(Text->getText(SAY_NAME)); + spike->step(east); spike->_ref = SAY_REF; Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); @@ -227,9 +227,9 @@ void CGEEngine::inf(const char *txt) { if (Talk) { Talk->_flags._kill = true; Talk->_flags._bDel = true; - Talk->SetName(Text->getText(INF_NAME)); - Talk->Center(); - Talk->Goto(Talk->_x, Talk->_y - 20); + Talk->setName(Text->getText(INF_NAME)); + Talk->center(); + Talk->gotoxy(Talk->_x, Talk->_y - 20); Talk->_z = 126; Talk->_ref = INF_REF; Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e1bea9a15c..0e865ffd90 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -356,21 +356,21 @@ void Heart::setXTimer(uint16 *ptr, uint16 time) { Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) - : _x(0), _y(0), _z(0), NearPtr(0), TakePtr(0), + : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { - memset(File, 0, sizeof(File)); + memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; - SetShapeList(shp); + setShapeList(shp); } Sprite::~Sprite() { - Contract(); + contract(); } -BMP_PTR Sprite::Shp() { +BMP_PTR Sprite::shp() { register SprExt *e = _ext; if (e) if (e->_seq) { @@ -380,7 +380,7 @@ BMP_PTR Sprite::Shp() { //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); //VGA::Exit(s, File); - error("Invalid PHASE in SPRITE::Shp() %s", File); + error("Invalid PHASE in SPRITE::Shp() %s", _file); } return e->_shpList[i]; } @@ -388,7 +388,7 @@ BMP_PTR Sprite::Shp() { } -BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { +BMP_PTR *Sprite::setShapeList(BMP_PTR *shp) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; _shpCnt = 0; @@ -405,16 +405,16 @@ BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { _h = b->_h; _shpCnt++; } - Expand(); + expand(); _ext->_shpList = shp; if (!_ext->_seq) - SetSeq((_shpCnt < 2) ? _seq1 : _seq2); + setSeq((_shpCnt < 2) ? _seq1 : _seq2); } return r; } -void Sprite::MoveShapes(uint8 *buf) { +void Sprite::moveShapes(uint8 *buf) { BMP_PTR *p; for (p = _ext->_shpList; *p; p++) { buf += (*p)->moveVmap(buf); @@ -422,12 +422,12 @@ void Sprite::MoveShapes(uint8 *buf) { } -bool Sprite::Works(Sprite *spr) { +bool Sprite::works(Sprite *spr) { if (spr) if (spr->_ext) { SNAIL::COM *c = spr->_ext->_take; if (c != NULL) { - c += spr->TakePtr; + c += spr->_takePtr; if (c->Ref == _ref) if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) return true; @@ -437,19 +437,19 @@ bool Sprite::Works(Sprite *spr) { } -Seq *Sprite::SetSeq(Seq *seq) { - Expand(); +Seq *Sprite::setSeq(Seq *seq) { + expand(); register Seq *s = _ext->_seq; _ext->_seq = seq; if (_seqPtr == NO_SEQ) - Step(0); + step(0); else if (_time == 0) - Step(_seqPtr); + step(_seqPtr); return s; } -bool Sprite::SeqTest(int n) { +bool Sprite::seqTest(int n) { if (n >= 0) return (_seqPtr == n); if (_ext) @@ -458,7 +458,7 @@ bool Sprite::SeqTest(int n) { } -SNAIL::COM *Sprite::SnList(SNLIST type) { +SNAIL::COM *Sprite::snList(SNLIST type) { register SprExt *e = _ext; if (e) return (type == NEAR) ? e->_near : e->_take; @@ -466,7 +466,7 @@ SNAIL::COM *Sprite::SnList(SNLIST type) { } -void Sprite::SetName(char *n) { +void Sprite::setName(char *n) { if (_ext) { if (_ext->_name) { delete[] _ext->_name; @@ -482,13 +482,13 @@ void Sprite::SetName(char *n) { } -Sprite *Sprite::Expand(void) { +Sprite *Sprite::expand() { if (!_ext) { bool enbl = _heart->_enable; _heart->_enable = false; if ((_ext = new SprExt) == NULL) error("No core"); - if (*File) { + if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; BMP_PTR *shplist = new BMP_PTR [_shpCnt + 1]; @@ -502,7 +502,7 @@ Sprite *Sprite::Expand(void) { SNAIL::COM *nea = NULL; SNAIL::COM *tak = NULL; - MergeExt(fname, File, SPR_EXT); + mergeExt(fname, _file, SPR_EXT); if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); if (!(sprf._error==0)) @@ -515,9 +515,9 @@ Sprite *Sprite::Expand(void) { if (len == 0 || *line == '.') continue; - switch (TakeEnum(Comd, strtok(line, " =\t"))) { + switch (takeEnum(Comd, strtok(line, " =\t"))) { case 0 : { // Name - SetName(strtok(NULL, "")); + setName(strtok(NULL, "")); break; } case 1 : { // Phase @@ -549,13 +549,13 @@ Sprite *Sprite::Expand(void) { break; } case 3 : { // Near - if (NearPtr != NO_PTR) { + if (_nearPtr != NO_PTR) { nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); if (nea == NULL) error("No core [%s]", fname); else { SNAIL::COM *c = &nea[neacnt++]; - if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->Com = (SNCOM) takeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", (const char*)NumStr("Bad NEAR in ######", lcnt), (const char*)fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); @@ -565,13 +565,13 @@ Sprite *Sprite::Expand(void) { } break; case 4 : { // Take - if (TakePtr != NO_PTR) { + if (_takePtr != NO_PTR) { tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); if (tak == NULL) error("No core [%s]", fname); else { SNAIL::COM *c = &tak[takcnt++]; - if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->Com = (SNCOM) takeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), (const char *)fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); @@ -583,7 +583,7 @@ Sprite *Sprite::Expand(void) { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(File, true); + shplist[shpcnt++] = new Bitmap(_file, true); } shplist[shpcnt] = NULL; if (seq) { @@ -591,21 +591,21 @@ Sprite *Sprite::Expand(void) { error("Bad PHASE in SEQ [%s]", fname); if (maxnxt >= seqcnt) error("Bad JUMP in SEQ [%s]", fname); - SetSeq(seq); + setSeq(seq); } else - SetSeq((_shpCnt == 1) ? _seq1 : _seq2); + setSeq((_shpCnt == 1) ? _seq1 : _seq2); //disable(); // disable interupt - SetShapeList(shplist); + setShapeList(shplist); //enable(); // enable interupt if (nea) nea[neacnt - 1].Ptr = _ext->_near = nea; else - NearPtr = NO_PTR; + _nearPtr = NO_PTR; if (tak) tak[takcnt - 1].Ptr = _ext->_take = tak; else - TakePtr = NO_PTR; + _takePtr = NO_PTR; } _heart->_enable = enbl; } @@ -613,7 +613,7 @@ Sprite *Sprite::Expand(void) { } -Sprite *Sprite::Contract(void) { +Sprite *Sprite::contract() { register SprExt *e = _ext; if (e) { if (e->_name) @@ -622,10 +622,10 @@ Sprite *Sprite::Contract(void) { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; - if (MemType(e->_shpList) == NEAR_MEM) + if (memType(e->_shpList) == NEAR_MEM) delete[] e->_shpList; } - if (MemType(e->_seq) == NEAR_MEM) + if (memType(e->_seq) == NEAR_MEM) free(e->_seq); if (e->_near) free(e->_near); @@ -638,18 +638,18 @@ Sprite *Sprite::Contract(void) { } -Sprite *Sprite::BackShow(bool fast) { - Expand(); - Show(2); - Show(1); +Sprite *Sprite::backShow(bool fast) { + expand(); + show(2); + show(1); if (fast) - Show(0); - Contract(); + show(0); + contract(); return this; } -void Sprite::Step(int nr) { +void Sprite::step(int nr) { if (nr >= 0) _seqPtr = nr; if (_ext) { @@ -658,24 +658,24 @@ void Sprite::Step(int nr) { _seqPtr = _ext->_seq[_seqPtr].Next; seq = _ext->_seq + _seqPtr; if (seq->Dly >= 0) { - Goto(_x + (seq->Dx), _y + (seq->Dy)); + gotoxy(_x + (seq->Dx), _y + (seq->Dy)); _time = seq->Dly; } } } -void Sprite::Tick(void) { - Step(); +void Sprite::tick() { + step(); } -void Sprite::MakeXlat(uint8 *x) { +void Sprite::makeXlat(uint8 *x) { if (_ext) { BMP_PTR *b; if (_flags._xlat) - KillXlat(); + killXlat(); for (b = _ext->_shpList; *b; b++) (*b)->_m = x; _flags._xlat = true; @@ -683,12 +683,12 @@ void Sprite::MakeXlat(uint8 *x) { } -void Sprite::KillXlat(void) { +void Sprite::killXlat() { if (_flags._xlat && _ext) { BMP_PTR *b; uint8 *m = (*_ext->_shpList)->_m; - switch (MemType(m)) { + switch (memType(m)) { case NEAR_MEM : delete[](uint8 *) m; break; @@ -706,7 +706,7 @@ void Sprite::KillXlat(void) { } -void Sprite::Goto(int x, int y) { +void Sprite::gotoxy(int x, int y) { int xo = _x, yo = _y; if (_x < SCR_WID) { if (x < 0) @@ -724,18 +724,18 @@ void Sprite::Goto(int x, int y) { } if (_next) if (_next->_flags._slav) - _next->Goto(_next->_x - xo + _x, _next->_y - yo + _y); + _next->gotoxy(_next->_x - xo + _x, _next->_y - yo + _y); if (_flags._shad) - _prev->Goto(_prev->_x - xo + _x, _prev->_y - yo + _y); + _prev->gotoxy(_prev->_x - xo + _x, _prev->_y - yo + _y); } -void Sprite::Center(void) { - Goto((SCR_WID - _w) / 2, (SCR_HIG - _h) / 2); +void Sprite::center() { + gotoxy((SCR_WID - _w) / 2, (SCR_HIG - _h) / 2); } -void Sprite::Show(void) { +void Sprite::show() { register SprExt *e; // asm cli // critic section... e = _ext; @@ -744,7 +744,7 @@ void Sprite::Show(void) { e->_b0 = e->_b1; e->_x1 = _x; e->_y1 = _y; - e->_b1 = Shp(); + e->_b1 = shp(); // asm sti // ...done! if (!_flags._hide) { if (_flags._xlat) @@ -755,22 +755,22 @@ void Sprite::Show(void) { } -void Sprite::Show(uint16 pg) { +void Sprite::show(uint16 pg) { Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; - Shp()->show(_x, _y); + shp()->show(_x, _y); VGA::Page[1] = a; } -void Sprite::Hide(void) { +void Sprite::hide() { register SprExt *e = _ext; if (e->_b0) e->_b0->hide(e->_x0, e->_y0); } -BMP_PTR Sprite::Ghost(void) { +BMP_PTR Sprite::ghost() { register SprExt *e = _ext; if (e->_b1) { BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL); @@ -795,7 +795,7 @@ Sprite *SpriteAt(int x, int y) { if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { if (! spr->_flags._hide && ! spr->_flags._tran) { - if (spr->Shp()->solidAt(x - spr->_x, y - spr->_y)) + if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) break; } } @@ -840,9 +840,9 @@ void QUEUE::Append(Sprite *spr) { Head = spr; Tail = spr; if (Show) - spr->Expand(); + spr->expand(); else - spr->Contract(); + spr->contract(); } @@ -861,9 +861,9 @@ void QUEUE::Insert(Sprite *spr, Sprite *nxt) { if (spr->_next) spr->_next->_prev = spr; if (Show) - spr->Expand(); + spr->expand(); else - spr->Contract(); + spr->contract(); } @@ -877,9 +877,9 @@ void QUEUE::Insert(Sprite *spr) { else Append(spr); if (Show) - spr->Expand(); + spr->expand(); else - spr->Contract(); + spr->contract(); } @@ -952,7 +952,7 @@ VGA::VGA(int mode) SetStatAdr(); if (StatAdr != VGAST1_) ++Mono; - if (IsVga()) { + if (isVga()) { OldColors = farnew(Dac, 256); NewColors = farnew(Dac, 256); OldScreen = SaveScreen(); @@ -968,7 +968,7 @@ VGA::VGA(int mode) VGA::~VGA(void) { Mono = 0; - if (IsVga()) { + if (isVga()) { Common::String buffer = ""; Clear(0); SetMode(OldMode); @@ -1137,10 +1137,10 @@ void VGA::Show(void) { Sprite *spr = ShowQ->First(); for (spr = ShowQ->First(); spr; spr = spr->_next) - spr->Show(); + spr->show(); Update(); for (spr = ShowQ->First(); spr; spr = spr->_next) - spr->Hide(); + spr->hide(); ++ FrmCnt; } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index a3d5ad949b..a22dd9d57a 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -195,42 +195,43 @@ public: uint16 _w; uint16 _h; uint16 _time; - uint8 NearPtr, TakePtr; + uint8 _nearPtr; + uint8 _takePtr; int _seqPtr; int _shpCnt; - char File[MAXFILE]; + char _file[MAXFILE]; Sprite *_prev; Sprite *_next; - bool Works(Sprite *spr); - bool SeqTest(int n); - inline bool Active(void) { + bool works(Sprite *spr); + bool seqTest(int n); + inline bool active() { return _ext != NULL; } Sprite(CGEEngine *vm, BMP_PTR *shp); virtual ~Sprite(void); - BMP_PTR Shp(void); - BMP_PTR *SetShapeList(BMP_PTR *shp); - void MoveShapes(uint8 *buf); - Sprite *Expand(void); - Sprite *Contract(void); - Sprite *BackShow(bool fast = false); - void SetName(char *n); - inline char *Name(void) { + BMP_PTR shp(); + BMP_PTR *setShapeList(BMP_PTR *shp); + void moveShapes(uint8 *buf); + Sprite *expand(); + Sprite *contract(); + Sprite *backShow(bool fast = false); + void setName(char *n); + inline char *name() { return (_ext) ? _ext->_name : NULL; } - void Goto(int x, int y); - void Center(void); - void Show(void); - void Hide(void); - BMP_PTR Ghost(void); - void Show(uint16 pg); - void MakeXlat(uint8 *x); - void KillXlat(void); - void Step(int nr = -1); - Seq *SetSeq(Seq *seq); - SNAIL::COM *SnList(SNLIST type); - virtual void Touch(uint16 mask, int x, int y); - virtual void Tick(void); + void gotoxy(int x, int y); + void center(); + void show(); + void hide(); + BMP_PTR ghost(); + void show(uint16 pg); + void makeXlat(uint8 *x); + void killXlat(); + void step(int nr = -1); + Seq *setSeq(Seq *seq); + SNAIL::COM *snList(SNLIST type); + virtual void touch(uint16 mask, int x, int y); + virtual void tick(); private: CGEEngine *_vm; }; @@ -291,9 +292,9 @@ public: void Clear(uint8 color); void CopyPage(uint16 d, uint16 s); void Sunrise(Dac *tab); - void Sunset(void); - void Show(void); - void Update(void); + void Sunset(); + void Show(); + void Update(); static void pal2DAC(const byte *palData, Dac *tab); static void DAC2pal(const Dac *tab, byte *palData); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index ed07a1269f..7e1d327b69 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -61,7 +61,7 @@ MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : TALK(vm), _vm(vm) { p2 -= w; } TS[0] = new Bitmap(w, h, p); - SetShapeList(TS); + setShapeList(TS); _flags._slav = true; _flags._tran = true; _flags._kill = true; @@ -110,12 +110,12 @@ VMENU::VMENU(CGEEngine *vm, CHOICE *list, int x, int y) _flags._bDel = true; _flags._kill = true; if (x < 0 || y < 0) - Center(); + center(); else - Goto(x - _w / 2, y - (TEXT_VM + FONT_HIG / 2)); + gotoxy(x - _w / 2, y - (TEXT_VM + FONT_HIG / 2)); Vga->ShowQ->Insert(this, Vga->ShowQ->Last()); Bar = new MENU_BAR(_vm, _w - 2 * TEXT_HM); - Bar->Goto(_x + TEXT_HM - MB_HM, _y + TEXT_VM - MB_VM); + Bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM - MB_VM); Vga->ShowQ->Insert(Bar, Vga->ShowQ->Last()); } @@ -130,7 +130,7 @@ void VMENU::Touch(uint16 mask, int x, int y) { bool ok = false; if (Items) { - Sprite::Touch(mask, x, y); + Sprite::touch(mask, x, y); y -= TEXT_VM - 1; int n = 0; @@ -142,7 +142,7 @@ void VMENU::Touch(uint16 mask, int x, int y) { n = Items - 1; } - Bar->Goto(_x + TEXT_HM - MB_HM, _y + TEXT_VM + n * h - MB_VM); + Bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM + n * h - MB_VM); if (ok && (mask & L_UP)) { Items = 0; -- cgit v1.2.3 From 3469d1fb04d84840bb720c472b79f738b72a08e8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 Jul 2011 20:09:36 +1000 Subject: CGE: Bugfix to correctly reset wait timeouts when done --- engines/cge/snail.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index baaac250dd..54b786722f 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -913,9 +913,15 @@ void SNAIL::RunCom(void) { COM *snc = &SNList[Tail]; if (! Turbo) { // only for the slower one - if (_timerExpiry && (_timerExpiry > g_system->getMillis())) - break; - else { + if (_timerExpiry) { + // Delay in progress + if (_timerExpiry > g_system->getMillis()) + // Delay not yet ended + break; + + // Delay is finished + _timerExpiry = 0; + } else { if (TextDelay) { KillText(); TextDelay = false; -- cgit v1.2.3 From 1ab67c2124d178cf38aae82af49f6babcd4dd2cd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 16:04:47 +1000 Subject: CGE: Fix problem with calculating box sizes for text strings --- engines/cge/talk.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 38625e2971..ce6490cccf 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -80,7 +80,7 @@ uint16 FONT::Width(const char *text) { uint16 w = 0; if (text) while (* text) - w += Wid[*(text++)]; + w += Wid[(unsigned char)*(text++)]; return w; } @@ -151,7 +151,7 @@ void TALK::Update(const char *tx) { mw = k; k = 2 * hmarg; } else - k += _Font->Wid[*p]; + k += _Font->Wid[(unsigned char)*p]; } if (k > mw) mw = k; @@ -164,8 +164,8 @@ void TALK::Update(const char *tx) { if (*tx == '|' || *tx == '\n') m = TS[0]->_m + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; else { - int cw = _Font->Wid[*tx], i; - uint8 *f = _Font->Map + _Font->Pos[*tx]; + int cw = _Font->Wid[(unsigned char)*tx], i; + uint8 *f = _Font->Map + _Font->Pos[(unsigned char)*tx]; for (i = 0; i < cw; i++) { uint8 *pp = m; uint16 n; @@ -262,8 +262,8 @@ void TALK::PutLine(int line, const char *text) { q = v + size; while (* text) { - uint16 cw = _Font->Wid[*text], i; - uint8 *fp = _Font->Map + _Font->Pos[*text]; + uint16 cw = _Font->Wid[(unsigned char)*text], i; + uint8 *fp = _Font->Map + _Font->Pos[(unsigned char)*text]; for (i = 0; i < cw; i++) { register uint16 b = fp[i]; @@ -310,8 +310,8 @@ void INFO_LINE::Update(const char *tx) { uint8 *p = v + 2, * q = p + size; while (*tx) { - uint16 cw = _Font->Wid[*tx]; - uint8 *fp = _Font->Map + _Font->Pos[*tx]; + uint16 cw = _Font->Wid[(unsigned char)*tx]; + uint8 *fp = _Font->Map + _Font->Pos[(unsigned char)*tx]; for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; -- cgit v1.2.3 From ec28ef04c467d45703296a610f7ef0e30154164d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 16:19:36 +1000 Subject: CGE: Merged mouse.* and keybd.* files to centralise event handling --- engines/cge/cge_main.cpp | 5 +- engines/cge/cge_main.h | 2 +- engines/cge/events.cpp | 318 +++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/events.h | 116 +++++++++++++++++ engines/cge/gettext.cpp | 3 +- engines/cge/keybd.cpp | 151 ---------------------- engines/cge/keybd.h | 63 ---------- engines/cge/mixer.cpp | 2 +- engines/cge/module.mk | 3 +- engines/cge/mouse.cpp | 194 ----------------------------- engines/cge/mouse.h | 85 ------------- engines/cge/snail.cpp | 3 +- engines/cge/vmenu.cpp | 2 +- 13 files changed, 443 insertions(+), 504 deletions(-) create mode 100644 engines/cge/events.cpp create mode 100644 engines/cge/events.h delete mode 100644 engines/cge/keybd.cpp delete mode 100644 engines/cge/keybd.h delete mode 100644 engines/cge/mouse.cpp delete mode 100644 engines/cge/mouse.h diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 0d8bef4b85..40bace9c51 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -36,8 +36,7 @@ #include "cge/snail.h" #include "cge/text.h" #include "cge/game.h" -#include "cge/mouse.h" -#include "cge/keybd.h" +#include "cge/events.h" #include "cge/cfile.h" #include "cge/vol.h" #include "cge/talk.h" @@ -1857,8 +1856,10 @@ void CGEEngine::cge_main(void) { if (Music && STARTUP::SoundOk) LoadMIDI(0); +/** *****DEBUG***** if (STARTUP::Mode < 2) movie(LGO_EXT); +*/ if (showTitle("WELCOME")) { if ((!_isDemo) && (STARTUP::Mode == 1)) movie("X02"); // intro diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 9b905ea360..1b77c05bf0 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -30,7 +30,7 @@ #include "cge/wav.h" #include "cge/vga13h.h" -#include "cge/mouse.h" +#include "cge/events.h" namespace CGE { diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp new file mode 100644 index 0000000000..e5ad00da5e --- /dev/null +++ b/engines/cge/events.cpp @@ -0,0 +1,318 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/events.h" +#include "cge/events.h" +#include "cge/text.h" +#include "cge/cge_main.h" + +namespace CGE { + +/*----------------- KEYBOARD interface -----------------*/ + +Sprite *Keyboard::_client = NULL; +uint8 Keyboard::_key[0x60] = { 0 }; +uint16 Keyboard::_current = 0; +uint16 Keyboard::_code[0x60] = { + 0, Esc, '1', '2', '3', + '4', '5', '6', '7', '8', + '9', '0', '-', '+', BSp, + Tab, 'Q', 'W', 'E', 'R', + 'T', 'Y', 'U', 'I', 'O', + 'P', '[', ']', Enter, 0/*Ctrl*/, + 'A', 'S', 'D', 'F', 'G', + 'H', 'J', 'K', 'L', ';', + '\'', '`', 0/*LShift*/, '\\', 'Z', + 'X', 'C', 'V', 'B', 'N', + 'M', ',', '.', '/', 0/*RShift*/, + '*', 0/*Alt*/, ' ', 0/*Caps*/, F1, + F2, F3, F4, F5, F6, + F7, F8, F9, F10, 0/*NumLock*/, + 0/*ScrollLock*/, Home, Up, PgUp, '-', + Left, Ctr, Right, '+', End, + Down, PgDn, Ins, Del, 0 * 0x54, + 0 * 0x55, 0 * 0x56, F11, F12, 0 * 0x59, + 0 * 0x5A, 0 * 0x5B, 0 * 0x5C, 0 * 0x5D, 0 * 0x5E, + 0 * 0x5F +}; + +void (* Keyboard::OldKeyboard)(...); + + +Keyboard::Keyboard() { + // steal keyboard interrupt + /* TODO replace totally by scummvm handling + OldKeyboard = getvect(KEYBD_INT); + setvect(KEYBD_INT, NewKeyboard); + */ + warning("STUB: Keyboard::Keyboard"); +} + + +Keyboard::~Keyboard() { + // bring back keyboard interrupt + /* TODO replace totally by scummvm handling + setvect(KEYBD_INT, OldKeyboard); + */ + // FIXME: STUB: KEYBOARD::~KEYBOARD +} + + +Sprite *Keyboard::setClient(Sprite *spr) { + Swap(_client, spr); + return spr; +} + + +void Keyboard::NewKeyboard(...) { + // table address + /* + _SI = (uint16) Key; + + // take keyboard code + asm in al,60h + asm mov bl,al + asm and bx,007Fh + asm cmp bl,60h + asm jae xit + asm cmp al,bl + asm je ok // key pressed + + // key released... + asm cmp [si+bx],bh // BH == 0 + asm jne ok + // ...but not pressed: call the original service + OldKeyboard(); + return; + + ok: + asm shl ax,1 + asm and ah,1 + asm xor ah,1 + asm mov [si+bx],ah + asm jz xit // released: exit + + // pressed: lock ASCII code + _SI = (uint16) Code; + asm add bx,bx // uint16 size + asm mov ax,[si+bx] + asm or ax,ax + asm jz xit // zero means NO KEY + Current = _AX; + + _SI = (uint16) Client; + asm or si,si + asm jz xit // if (Client) ... + //--- fill current event entry with mask, key code and sprite + asm mov bx,EvtHead // take queue head pointer + asm inc byte ptr EvtHead // update queue head pointer + asm shl bx,3 // * 8 + _AX = Current; + asm mov Evt[bx].(struct EVENT)X,ax // key code + asm mov ax,KEYB // event mask + asm mov Evt[bx].(struct EVENT)Msk,ax // event mask + //asm mov Evt[bx].(struct EVENT)Y,dx // row + asm mov Evt[bx].(struct EVENT)Ptr,si // SPRITE pointer + + xit: + + asm in al,61h // kbd control lines + asm push ax // save it + asm or al,80h // set the "enable kbd" bit + asm out 61h,al // and write it out + asm pop ax // original control port value + asm out 61h,al // write it back + asm mov al,20h // send End-Of-Interrupt + asm out 20h,al // to the 8259 IC + */ + warning("STUB: Keyboard::NewKeyboard"); +} + +/*----------------- MOUSE interface -----------------*/ + +Event Evt[EVT_MAX]; + +uint16 EvtHead = 0, EvtTail = 0; + +MOUSE_FUN *MOUSE::OldMouseFun = NULL; +uint16 MOUSE::OldMouseMask = 0; + + +MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { + static Seq ms[] = { + { 0, 0, 0, 0, 1 }, + { 1, 1, 0, 0, 1 } + }; + + setSeq(ms); + + /* TODO Mouse handling + // Mouse reset + _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work) + __int__(0x33); + Exist = (_AX != 0); + Buttons = _BX; +*/ + gotoxy(SCR_WID/2, SCR_HIG/2); + _z = 127; + step(1); + + Exist = true; + warning("STUB: MOUSE::MOUSE"); +} + + +MOUSE::~MOUSE(void) { + Off(); +} + + +//void MOUSE::SetFun (void) +//{ +//} + + +void MOUSE::On(void) { + /* + if (SeqPtr && Exist) + { + _CX = X + X; // horizontal position + _DX = Y; // vertical position + _AX = 0x0004; // Set Mouse Position + __int__(0x33); + // set new mouse fun + _ES = FP_SEG(NewMouseFun); + _DX = FP_OFF(NewMouseFun); + _CX = 0x001F; // 11111b = all events + _AX = 0x0014; // Swap User-Interrupt Vector + __int__(0x33); + // save old mouse fun + OldMouseMask = _CX; + OldMouseFun = (MOUSE_FUN *) MK_FP(_ES, _DX); + + // set X bounds + _DX = (SCR_WID - W) * 2; // right limit + _CX = 0; // left limit + _AX = 0x0007; // note: each pixel = 2 + __int__(0x33); + + // set Y bounds + _DX = SCR_HIG - H; // bottom limit + _CX = 0; // top limit + _AX = 0x0008; + __int__(0x33); + + Step(0); + if (Busy) Busy->Step(0); + } + */ + warning("STUB: MOUSE::On"); +} + + +void MOUSE::Off(void) { +/* + if (SeqPtr == 0) + { + if (Exist) + { + // bring back old mouse fun + _ES = FP_SEG(OldMouseFun); + _DX = FP_OFF(OldMouseFun); + _CX = OldMouseMask; + _AX = 0x0014; // Swap User-Interrupt Vector + __int__(0x33); + } + Step(1); + if (Busy) Busy->Step(1); + } + */ + warning("STUB: MOUSE::Off"); +} + + +void MOUSE::ClrEvt(Sprite *spr) { + if (spr) { + uint16 e; + for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) + if (Evt[e]._ptr == spr) + Evt[e]._msk = 0; + } else + EvtTail = EvtHead; +} + + +void MOUSE::Tick(void) { + step(); + while (EvtTail != EvtHead) { + Event e = Evt[EvtTail]; + if (e._msk) { + if (Hold && e._ptr != Hold) + Hold->touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y); + + // update mouse cursor position + if (e._msk & ROLL) + gotoxy(e._x, e._y); + + // activate current touched SPRITE + if (e._ptr) { + if (e._msk & KEYB) + e._ptr->touch(e._msk, e._x, e._y); + else + e._ptr->touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y); + } else if (Sys) + Sys->touch(e._msk, e._x, e._y); + + if (e._msk & L_DN) { + Hold = e._ptr; + if (Hold) { + Hold->_flags._hold = true; + hx = e._x - Hold->_x; + hy = e._y - Hold->_y; + } + } + + if (e._msk & L_UP) { + if (Hold) { + Hold->_flags._hold = false; + Hold = NULL; + } + } + ///Touched = e.Ptr; + + // discard Text if button released + if (e._msk & (L_UP | R_UP)) + KillText(); + } + EvtTail = (EvtTail + 1) % EVT_MAX; + } + if (Hold) + Hold->gotoxy(_x - hx, _y - hy); +} + + +} // End of namespace CGE diff --git a/engines/cge/events.h b/engines/cge/events.h new file mode 100644 index 0000000000..be4b15e133 --- /dev/null +++ b/engines/cge/events.h @@ -0,0 +1,116 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#ifndef __CGE_EVENTS__ +#define __CGE_EVENTS__ + +#include "cge/game.h" +#include "cge/talk.h" +#include "cge/jbw.h" +#include "cge/vga13h.h" + +namespace CGE { + +/*----------------- KEYBOARD interface -----------------*/ + +#define KEYBD_INT 9 +#define LSHIFT 42 +#define RSHIFT 54 +#define CTRL 29 +#define ALT 56 + + +class Keyboard { +public: + static void (* OldKeyboard)(...); + static void NewKeyboard(...); + static uint16 _code[0x60]; + static uint16 _current; + static Sprite *_client; + static uint8 _key[0x60]; + static uint16 last() { + uint16 cur = _current; + _current = 0; + return cur; + } + static Sprite *setClient(Sprite *spr); + Keyboard(); + ~Keyboard(); +}; + +/*----------------- MOUSE interface -----------------*/ + +#define EVT_MAX 256 +#define ROLL 0x01 +#define L_DN 0x02 +#define L_UP 0x04 +#define R_DN 0x08 +#define R_UP 0x10 +#define ATTN 0x20 // 0x40 +#define KEYB 0x80 + + +extern TALK *Talk; + +struct Event { + uint16 _msk; + uint16 _x; + uint16 _y; + Sprite *_ptr; +}; + +extern Event Evt[EVT_MAX]; +extern uint16 EvtHead, EvtTail; +typedef void (MOUSE_FUN)(void); + + +class MOUSE : public Sprite { + static MOUSE_FUN *OldMouseFun; + static MOUSE_FUN NewMouseFun; + static uint16 OldMouseMask; + Sprite *Hold; + int hx, hy; + //void SetFun (void); + //void ResetFun (void); +public: + bool Exist; + int Buttons; + Sprite *Busy; + //Sprite *Touched; + MOUSE(CGEEngine *vm, Bitmap **shpl = MC); + ~MOUSE(); + void On(); + void Off(); + static void ClrEvt(Sprite *spr = NULL); + void Tick(); +private: + CGEEngine *_vm; +}; + +} // End of namespace CGE + +#endif diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 1b609e2d8b..889aee4fed 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -26,8 +26,7 @@ */ #include "cge/gettext.h" -#include "cge/keybd.h" -#include "cge/mouse.h" +#include "cge/events.h" #include "cge/cge_main.h" #include diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp deleted file mode 100644 index 45237d15d1..0000000000 --- a/engines/cge/keybd.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/keybd.h" -#include "cge/mouse.h" - -namespace CGE { - -Sprite *Keyboard::_client = NULL; -uint8 Keyboard::_key[0x60] = { 0 }; -uint16 Keyboard::_current = 0; -uint16 Keyboard::_code[0x60] = { - 0, Esc, '1', '2', '3', - '4', '5', '6', '7', '8', - '9', '0', '-', '+', BSp, - Tab, 'Q', 'W', 'E', 'R', - 'T', 'Y', 'U', 'I', 'O', - 'P', '[', ']', Enter, 0/*Ctrl*/, - 'A', 'S', 'D', 'F', 'G', - 'H', 'J', 'K', 'L', ';', - '\'', '`', 0/*LShift*/, '\\', 'Z', - 'X', 'C', 'V', 'B', 'N', - 'M', ',', '.', '/', 0/*RShift*/, - '*', 0/*Alt*/, ' ', 0/*Caps*/, F1, - F2, F3, F4, F5, F6, - F7, F8, F9, F10, 0/*NumLock*/, - 0/*ScrollLock*/, Home, Up, PgUp, '-', - Left, Ctr, Right, '+', End, - Down, PgDn, Ins, Del, 0 * 0x54, - 0 * 0x55, 0 * 0x56, F11, F12, 0 * 0x59, - 0 * 0x5A, 0 * 0x5B, 0 * 0x5C, 0 * 0x5D, 0 * 0x5E, - 0 * 0x5F -}; - -void (* Keyboard::OldKeyboard)(...); - - -Keyboard::Keyboard() { - // steal keyboard interrupt - /* TODO replace totally by scummvm handling - OldKeyboard = getvect(KEYBD_INT); - setvect(KEYBD_INT, NewKeyboard); - */ - warning("STUB: Keyboard::Keyboard"); -} - - -Keyboard::~Keyboard() { - // bring back keyboard interrupt - /* TODO replace totally by scummvm handling - setvect(KEYBD_INT, OldKeyboard); - */ - // FIXME: STUB: KEYBOARD::~KEYBOARD -} - - -Sprite *Keyboard::setClient(Sprite *spr) { - Swap(_client, spr); - return spr; -} - - -void Keyboard::NewKeyboard(...) { - // table address - /* - _SI = (uint16) Key; - - // take keyboard code - asm in al,60h - asm mov bl,al - asm and bx,007Fh - asm cmp bl,60h - asm jae xit - asm cmp al,bl - asm je ok // key pressed - - // key released... - asm cmp [si+bx],bh // BH == 0 - asm jne ok - // ...but not pressed: call the original service - OldKeyboard(); - return; - - ok: - asm shl ax,1 - asm and ah,1 - asm xor ah,1 - asm mov [si+bx],ah - asm jz xit // released: exit - - // pressed: lock ASCII code - _SI = (uint16) Code; - asm add bx,bx // uint16 size - asm mov ax,[si+bx] - asm or ax,ax - asm jz xit // zero means NO KEY - Current = _AX; - - _SI = (uint16) Client; - asm or si,si - asm jz xit // if (Client) ... - //--- fill current event entry with mask, key code and sprite - asm mov bx,EvtHead // take queue head pointer - asm inc byte ptr EvtHead // update queue head pointer - asm shl bx,3 // * 8 - _AX = Current; - asm mov Evt[bx].(struct EVENT)X,ax // key code - asm mov ax,KEYB // event mask - asm mov Evt[bx].(struct EVENT)Msk,ax // event mask - //asm mov Evt[bx].(struct EVENT)Y,dx // row - asm mov Evt[bx].(struct EVENT)Ptr,si // SPRITE pointer - - xit: - - asm in al,61h // kbd control lines - asm push ax // save it - asm or al,80h // set the "enable kbd" bit - asm out 61h,al // and write it out - asm pop ax // original control port value - asm out 61h,al // write it back - asm mov al,20h // send End-Of-Interrupt - asm out 20h,al // to the 8259 IC - */ - warning("STUB: Keyboard::NewKeyboard"); -} - -} // End of namespace CGE diff --git a/engines/cge/keybd.h b/engines/cge/keybd.h deleted file mode 100644 index bb87ffb0ed..0000000000 --- a/engines/cge/keybd.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __KEYBD__ -#define __KEYBD__ - -#include "cge/jbw.h" -#include "cge/vga13h.h" - -namespace CGE { - -#define KEYBD_INT 9 -#define LSHIFT 42 -#define RSHIFT 54 -#define CTRL 29 -#define ALT 56 - - -class Keyboard { -public: - static void (* OldKeyboard)(...); - static void NewKeyboard(...); - static uint16 _code[0x60]; - static uint16 _current; - static Sprite *_client; - static uint8 _key[0x60]; - static uint16 last() { - uint16 cur = _current; - _current = 0; - return cur; - } - static Sprite *setClient(Sprite *spr); - Keyboard(); - ~Keyboard(); -}; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index b6442f3cd3..f8c0b9ceab 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -28,7 +28,7 @@ #include "cge/mixer.h" #include "cge/text.h" #include "cge/snail.h" -#include "cge/mouse.h" +#include "cge/events.h" #include "cge/snddrv.h" #include "cge/cge_main.h" #include diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 70967667a5..d9dea6534d 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -11,12 +11,11 @@ MODULE_OBJS := \ console.o \ detection.o \ ems.o \ + events.o \ game.o \ general.o \ gettext.o \ - keybd.o \ mixer.o \ - mouse.o \ snail.o \ sound.o \ startup.o \ diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp deleted file mode 100644 index a1b6b253ce..0000000000 --- a/engines/cge/mouse.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/mouse.h" -#include "cge/text.h" -#include "cge/cge_main.h" - -namespace CGE { - -Event Evt[EVT_MAX]; - -uint16 EvtHead = 0, EvtTail = 0; - -MOUSE_FUN *MOUSE::OldMouseFun = NULL; -uint16 MOUSE::OldMouseMask = 0; - - -MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { - static Seq ms[] = { - { 0, 0, 0, 0, 1 }, - { 1, 1, 0, 0, 1 } - }; - - setSeq(ms); - - /* TODO Mouse handling - // Mouse reset - _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work) - __int__(0x33); - Exist = (_AX != 0); - Buttons = _BX; -*/ - gotoxy(SCR_WID/2, SCR_HIG/2); - _z = 127; - step(1); - - Exist = true; - warning("STUB: MOUSE::MOUSE"); -} - - -MOUSE::~MOUSE(void) { - Off(); -} - - -//void MOUSE::SetFun (void) -//{ -//} - - -void MOUSE::On(void) { - /* - if (SeqPtr && Exist) - { - _CX = X + X; // horizontal position - _DX = Y; // vertical position - _AX = 0x0004; // Set Mouse Position - __int__(0x33); - // set new mouse fun - _ES = FP_SEG(NewMouseFun); - _DX = FP_OFF(NewMouseFun); - _CX = 0x001F; // 11111b = all events - _AX = 0x0014; // Swap User-Interrupt Vector - __int__(0x33); - // save old mouse fun - OldMouseMask = _CX; - OldMouseFun = (MOUSE_FUN *) MK_FP(_ES, _DX); - - // set X bounds - _DX = (SCR_WID - W) * 2; // right limit - _CX = 0; // left limit - _AX = 0x0007; // note: each pixel = 2 - __int__(0x33); - - // set Y bounds - _DX = SCR_HIG - H; // bottom limit - _CX = 0; // top limit - _AX = 0x0008; - __int__(0x33); - - Step(0); - if (Busy) Busy->Step(0); - } - */ - warning("STUB: MOUSE::On"); -} - - -void MOUSE::Off(void) { -/* - if (SeqPtr == 0) - { - if (Exist) - { - // bring back old mouse fun - _ES = FP_SEG(OldMouseFun); - _DX = FP_OFF(OldMouseFun); - _CX = OldMouseMask; - _AX = 0x0014; // Swap User-Interrupt Vector - __int__(0x33); - } - Step(1); - if (Busy) Busy->Step(1); - } - */ - warning("STUB: MOUSE::Off"); -} - - -void MOUSE::ClrEvt(Sprite *spr) { - if (spr) { - uint16 e; - for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) - if (Evt[e]._ptr == spr) - Evt[e]._msk = 0; - } else - EvtTail = EvtHead; -} - - -void MOUSE::Tick(void) { - step(); - while (EvtTail != EvtHead) { - Event e = Evt[EvtTail]; - if (e._msk) { - if (Hold && e._ptr != Hold) - Hold->touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y); - - // update mouse cursor position - if (e._msk & ROLL) - gotoxy(e._x, e._y); - - // activate current touched SPRITE - if (e._ptr) { - if (e._msk & KEYB) - e._ptr->touch(e._msk, e._x, e._y); - else - e._ptr->touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y); - } else if (Sys) - Sys->touch(e._msk, e._x, e._y); - - if (e._msk & L_DN) { - Hold = e._ptr; - if (Hold) { - Hold->_flags._hold = true; - hx = e._x - Hold->_x; - hy = e._y - Hold->_y; - } - } - - if (e._msk & L_UP) { - if (Hold) { - Hold->_flags._hold = false; - Hold = NULL; - } - } - ///Touched = e.Ptr; - - // discard Text if button released - if (e._msk & (L_UP | R_UP)) - KillText(); - } - EvtTail = (EvtTail + 1) % EVT_MAX; - } - if (Hold) - Hold->gotoxy(_x - hx, _y - hy); -} - -} // End of namespace CGE diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h deleted file mode 100644 index 4d95f10423..0000000000 --- a/engines/cge/mouse.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __MOUSE__ -#define __MOUSE__ - -#include "cge/game.h" -#include "cge/talk.h" - -namespace CGE { - -#define EVT_MAX 256 -#define ROLL 0x01 -#define L_DN 0x02 -#define L_UP 0x04 -#define R_DN 0x08 -#define R_UP 0x10 -#define ATTN 0x20 // 0x40 -#define KEYB 0x80 - - -extern TALK *Talk; - -struct Event { - uint16 _msk; - uint16 _x; - uint16 _y; - Sprite *_ptr; -}; - -extern Event Evt[EVT_MAX]; -extern uint16 EvtHead, EvtTail; -typedef void (MOUSE_FUN)(void); - - -class MOUSE : public Sprite { - static MOUSE_FUN *OldMouseFun; - static MOUSE_FUN NewMouseFun; - static uint16 OldMouseMask; - Sprite *Hold; - int hx, hy; - //void SetFun (void); - //void ResetFun (void); -public: - bool Exist; - int Buttons; - Sprite *Busy; - //Sprite *Touched; - MOUSE(CGEEngine *vm, Bitmap **shpl = MC); - ~MOUSE(); - void On(); - void Off(); - static void ClrEvt(Sprite *spr = NULL); - void Tick(); -private: - CGEEngine *_vm; -}; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 54b786722f..217acb2448 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -31,11 +31,10 @@ #include "cge/vga13h.h" #include "cge/bitmaps.h" #include "cge/text.h" -#include "cge/mouse.h" #include "cge/cge_main.h" #include #include -#include "cge/keybd.h" +#include "cge/events.h" namespace CGE { diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 7e1d327b69..149af901e8 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -26,7 +26,7 @@ */ #include "cge/vmenu.h" -#include "cge/mouse.h" +#include "cge/events.h" #include "cge/cge_main.h" #include -- cgit v1.2.3 From 6833daab84a39a3d5dd0afcb176245f8678b28de Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 16:23:32 +1000 Subject: CGE: Added engine prefix to header file #defines --- engines/cge/bitmap.h | 4 ++-- engines/cge/bitmaps.h | 4 ++-- engines/cge/boot.h | 4 ++-- engines/cge/btfile.h | 4 ++-- engines/cge/cfile.h | 4 ++-- engines/cge/cge_main.h | 4 ++-- engines/cge/config.h | 4 ++-- engines/cge/events.h | 4 ++-- engines/cge/game.cpp | 2 +- engines/cge/game.h | 4 ++-- engines/cge/general.h | 4 ++-- engines/cge/gettext.h | 4 ++-- engines/cge/ident.h | 4 ++-- engines/cge/jbw.h | 4 ++-- engines/cge/mixer.h | 4 ++-- engines/cge/snail.h | 4 ++-- engines/cge/snddrv.h | 4 ++-- engines/cge/sound.h | 4 ++-- engines/cge/startup.h | 4 ++-- engines/cge/talk.cpp | 2 +- engines/cge/talk.h | 4 ++-- engines/cge/text.h | 4 ++-- engines/cge/vga13h.h | 4 ++-- engines/cge/vmenu.h | 4 ++-- engines/cge/vol.h | 4 ++-- engines/cge/wav.h | 4 ++-- 26 files changed, 50 insertions(+), 50 deletions(-) diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 846f0149be..4c2b67b8df 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __BITMAP__ -#define __BITMAP__ +#ifndef __CGE_BITMAP__ +#define __CGE_BITMAP__ #include "cge/general.h" diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h index 40b1158b21..8569932134 100644 --- a/engines/cge/bitmaps.h +++ b/engines/cge/bitmaps.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __BITMAPS__ -#define __BITMAPS__ +#ifndef __CGE_BITMAPS__ +#define __CGE_BITMAPS__ #include "cge/vga13h.h" diff --git a/engines/cge/boot.h b/engines/cge/boot.h index 2dce0d6d16..5c03a626d8 100644 --- a/engines/cge/boot.h +++ b/engines/cge/boot.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __BOOT__ -#define __BOOT__ +#ifndef __CGE_BOOT__ +#define __CGE_BOOT__ #include "cge/jbw.h" diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index ac05c3a7e7..1ac093d897 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __BTFILE__ -#define __BTFILE__ +#ifndef __CGE_BTFILE__ +#define __CGE_BTFILE__ #include "cge/general.h" diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 376e50ae44..bf90633dd0 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CFILE__ -#define __CFILE__ +#ifndef __CGE_CFILE__ +#define __CGE_CFILE__ #include "cge/general.h" diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 1b77c05bf0..37d1a91e00 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE__ -#define __CGE__ +#ifndef __CGE_CGE__ +#define __CGE_CGE__ #include "cge/wav.h" #include "cge/vga13h.h" diff --git a/engines/cge/config.h b/engines/cge/config.h index 0f279ab047..4a1e5927e5 100644 --- a/engines/cge/config.h +++ b/engines/cge/config.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CONFIG__ -#define __CONFIG__ +#ifndef __CGE_CONFIG__ +#define __CGE_CONFIG__ namespace CGE { diff --git a/engines/cge/events.h b/engines/cge/events.h index be4b15e133..518c8c8bd1 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_EVENTS__ -#define __CGE_EVENTS__ +#ifndef __CGE_CGE_EVENTS__ +#define __CGE_CGE_EVENTS__ #include "cge/game.h" #include "cge/talk.h" diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index be93709f17..72233f746a 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -26,7 +26,7 @@ */ #include "cge/game.h" -#include "cge/mouse.h" +#include "cge/events.h" #include namespace CGE { diff --git a/engines/cge/game.h b/engines/cge/game.h index 3f86c97081..b26fc0d165 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __GAME__ -#define __GAME__ +#ifndef __CGE_GAME__ +#define __CGE_GAME__ #include "cge/vga13h.h" #include "cge/bitmaps.h" diff --git a/engines/cge/general.h b/engines/cge/general.h index cff00fb7f3..fae47eed42 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __GENERAL__ -#define __GENERAL__ +#ifndef __CGE_GENERAL__ +#define __CGE_GENERAL__ #include "common/system.h" #include "common/file.h" diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index 059d84be41..f743d0c66c 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __GETTEXT__ -#define __GETTEXT__ +#ifndef __CGE_GETTEXT__ +#define __CGE_GETTEXT__ #include "cge/general.h" #include "cge/talk.h" diff --git a/engines/cge/ident.h b/engines/cge/ident.h index afdb86d785..953f8a579d 100644 --- a/engines/cge/ident.h +++ b/engines/cge/ident.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __IDENT__ -#define __IDENT__ +#ifndef __CGE_IDENT__ +#define __CGE_IDENT__ namespace CGE { diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 359df8a216..93cdb75a4b 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __JBW__ -#define __JBW__ +#ifndef __CGE_JBW__ +#define __CGE_JBW__ #include "common/scummsys.h" diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index a86e65d3d1..8ded075514 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __MIXER__ -#define __MIXER__ +#ifndef __CGE_MIXER__ +#define __CGE_MIXER__ #include "cge/vga13h.h" diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 3221f5c02e..54a24ac1a9 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __SNAIL__ -#define __SNAIL__ +#ifndef __CGE_SNAIL__ +#define __CGE_SNAIL__ #include "cge/jbw.h" #include "cge/cge.h" diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 2de9014034..4cdac383be 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -34,8 +34,8 @@ // * Ver 1.40: 11-Mar-95 * // ****************************************************** -#ifndef __SNDDRV__ -#define __SNDDRV__ +#ifndef __CGE_SNDDRV__ +#define __CGE_SNDDRV__ namespace CGE { diff --git a/engines/cge/sound.h b/engines/cge/sound.h index b617891268..743fba0bb6 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __SOUND__ -#define __SOUND__ +#ifndef __CGE_SOUND__ +#define __CGE_SOUND__ #include "cge/wav.h" #include "cge/snddrv.h" diff --git a/engines/cge/startup.h b/engines/cge/startup.h index 5bfa9876d6..a1e44cc4af 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __STARTUP__ -#define __STARTUP__ +#ifndef __CGE_STARTUP__ +#define __CGE_STARTUP__ #include "cge/general.h" diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index ce6490cccf..0abff7752c 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -29,7 +29,7 @@ #include "cge/talk.h" #include "cge/vol.h" #include "cge/game.h" -#include "cge/mouse.h" +#include "cge/events.h" namespace CGE { diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 60f7f213d4..e5e32998cb 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __TALK__ -#define __TALK__ +#ifndef __CGE_TALK__ +#define __CGE_TALK__ #include "cge/vga13h.h" #include "cge/general.h" diff --git a/engines/cge/text.h b/engines/cge/text.h index 874a640ad0..5232084738 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __TEXT__ -#define __TEXT__ +#ifndef __CGE_TEXT__ +#define __CGE_TEXT__ #include "cge/talk.h" #include "cge/jbw.h" diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index a22dd9d57a..152f608c56 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __VGA13H__ -#define __VGA13H__ +#ifndef __CGE_VGA13H__ +#define __CGE_VGA13H__ #include "graphics/surface.h" #include "cge/general.h" diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 3c38576a40..2bb3cef88d 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __VMENU__ -#define __VMENU__ +#ifndef __CGE_VMENU__ +#define __CGE_VMENU__ #include "cge/talk.h" diff --git a/engines/cge/vol.h b/engines/cge/vol.h index c2e676130e..1e0b363ca5 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __VOL__ -#define __VOL__ +#ifndef __CGE_VOL__ +#define __CGE_VOL__ #include "cge/btfile.h" #include "cge/cfile.h" diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 980c7672c3..57187f7b87 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __WAV__ -#define __WAV__ +#ifndef __CGE_WAV__ +#define __CGE_WAV__ #include "cge/general.h" #include -- cgit v1.2.3 From d55401c2e10276827372f8df29418937cc2daf22 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 16:46:31 +1000 Subject: CGE: Changed MOUSE class from using static fields to an instantiated class --- engines/cge/cge.cpp | 6 ++++-- engines/cge/cge_main.cpp | 51 ++++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 3 ++- engines/cge/events.cpp | 11 +++++------ engines/cge/events.h | 20 +++++++++++-------- engines/cge/gettext.cpp | 6 +++--- engines/cge/mixer.cpp | 4 ++-- engines/cge/snail.cpp | 6 +++--- 8 files changed, 57 insertions(+), 50 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 43d74ab3a5..3feb8f64d2 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -96,7 +96,8 @@ void CGEEngine::setup() { Snail = new SNAIL(this, false); Snail_ = new SNAIL(this, true); - Mouse = new MOUSE(this); + _mouse = new MOUSE(this); + _keyboard = new Keyboard(); OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); } @@ -121,7 +122,8 @@ CGEEngine::~CGEEngine() { delete Hero; delete Sys; delete _pocLight; - delete Mouse; + delete _keyboard; + delete _mouse; for (int i = 0; i < POCKET_NX; i++) delete _pocket[i]; delete _sprite; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 40bace9c51..6e5c65b76f 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -66,7 +66,8 @@ Heart *_heart; WALK *Hero; SYSTEM *Sys; Sprite *_pocLight; -MOUSE *Mouse; +Keyboard *_keyboard; +MOUSE *_mouse; Sprite *_pocket[POCKET_NX]; Sprite *_sprite; Sprite *_miniCave; @@ -741,7 +742,7 @@ static void caveUp() { Vga->Sunrise(VGA::SysPal); Dark = false; if (! Startup) - Mouse->On(); + _mouse->On(); _heart->_enable = true; } @@ -792,7 +793,7 @@ void CGEEngine::switchCave(int cav) { warning("SwitchCave() - SNPOST"); } else { Now = cav; - Mouse->Off(); + _mouse->Off(); if (Hero) { Hero->park(); Hero->step(0); @@ -836,13 +837,13 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { pp0 = pp; switch (x) { case Del: - if (Keyboard::_key[ALT] && Keyboard::_key[CTRL]) + if (_keyboard->_key[ALT] && _keyboard->_key[CTRL]) AltCtrlDel(); else KillSprite(); break; case 'F': - if (Keyboard::_key[ALT]) { + if (_keyboard->_key[ALT]) { Sprite *m = Vga->ShowQ->Locate(17001); if (m) { m->step(1); @@ -860,7 +861,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { NextStep(); break; case '`': - if (Keyboard::_key[ALT]) + if (_keyboard->_key[ALT]) SaveMapping(); else _vm->switchMapping(); @@ -890,7 +891,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { Sys->FunDel = 1; break; case 'X': - if (Keyboard::_key[ALT]) + if (_keyboard->_key[ALT]) Finis = true; break; case '0': @@ -898,7 +899,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) { case '2': case '3': case '4': - if (Keyboard::_key[ALT]) { + if (_keyboard->_key[ALT]) { SNPOST(SNLEVEL, -1, x - '0', NULL); break; } @@ -1034,7 +1035,7 @@ static void SwitchColorMode(void) { static void SwitchMusic(void) { - if (Keyboard::_key[ALT]) { + if (_keyboard->_key[ALT]) { if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); else { @@ -1194,8 +1195,8 @@ static void SayDebug(void) { t = t1; } - dwtom(Mouse->_x, ABSX, 10, 3); - dwtom(Mouse->_y, ABSY, 10, 3); + dwtom(_mouse->_x, ABSX, 10, 3); + dwtom(_mouse->_y, ABSY, 10, 3); // dwtom(coreleft(), NFRE, 10, 5); // dwtom(farcoreleft(), FFRE, 10, 6); @@ -1663,9 +1664,9 @@ void CGEEngine::runGame() { _horzLine->_z = 126; Vga->ShowQ->Insert(_horzLine); - Mouse->Busy = Vga->SpareQ->Locate(BUSY_REF); - if (Mouse->Busy) - ExpandSprite(Mouse->Busy); + _mouse->Busy = Vga->SpareQ->Locate(BUSY_REF); + if (_mouse->Busy) + ExpandSprite(_mouse->Busy); Startup = 0; @@ -1674,7 +1675,7 @@ void CGEEngine::runGame() { CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); caveUp(); - Keyboard::setClient(Sys); + _keyboard->setClient(Sys); // main loop while (! Finis) { //TODO Change the SNPOST message send to a special way to send function pointer @@ -1683,11 +1684,11 @@ void CGEEngine::runGame() { mainLoop(); } - Keyboard::setClient(NULL); + _keyboard->setClient(NULL); _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); - Mouse->Off(); + _mouse->Off(); Vga->ShowQ->Clear(); Vga->SpareQ->Clear(); Hero = NULL; @@ -1706,11 +1707,11 @@ void CGEEngine::movie(const char *ext) { //Vga->ShowQ->Append(Mouse); _heart->_enable = true; - Keyboard::setClient(Sys); + _keyboard->setClient(Sys); while (!Snail->Idle()) mainLoop(); - Keyboard::setClient(NULL); + _keyboard->setClient(NULL); _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); @@ -1746,12 +1747,12 @@ bool CGEEngine::showTitle(const char *name) { if (STARTUP::Mode < 2 && !STARTUP::SoundOk) { Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); - Vga->ShowQ->Append(Mouse); + Vga->ShowQ->Append(_mouse); _heart->_enable = true; - Mouse->On(); + _mouse->On(); for (selectSound(); !Snail->Idle() || VMENU::Addr;) mainLoop(); - Mouse->Off(); + _mouse->Off(); _heart->_enable = false; Vga->ShowQ->Clear(); Vga->CopyPage(0, 2); @@ -1782,13 +1783,13 @@ bool CGEEngine::showTitle(const char *name) { movie("X00"); // paylist Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); - Vga->ShowQ->Append(Mouse); + Vga->ShowQ->Append(_mouse); //Mouse.On(); _heart->_enable = true; for (takeName(); GetText::_ptr;) mainLoop(); _heart->_enable = false; - if (Keyboard::last() == Enter && *UsrFnam) + if (_keyboard->last() == Enter && *UsrFnam) usr_ok = true; if (usr_ok) strcat(UsrFnam, SVG_EXT); @@ -1842,7 +1843,7 @@ void CGEEngine::cge_main(void) { //Debug( memset((void *) (-K(4)), 0, K(1)); ) memset(Barriers, 0xFF, sizeof(Barriers)); - if (!Mouse->Exist) + if (!_mouse->Exist) error("%s", Text->getText(NO_MOUSE_TEXT)); if (!SVG0FILE::exist(SVG0NAME)) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 37d1a91e00..3eea114420 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -172,7 +172,8 @@ extern Heart *_heart; extern SYSTEM *Sys; extern int OffUseCount; extern Sprite *_pocLight; -extern MOUSE *Mouse; +extern Keyboard *_keyboard; +extern MOUSE *_mouse; extern Sprite *_pocket[]; extern Sprite *_sprite; extern Sprite *_miniCave; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index e5ad00da5e..49b08e407b 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -34,10 +34,7 @@ namespace CGE { /*----------------- KEYBOARD interface -----------------*/ -Sprite *Keyboard::_client = NULL; -uint8 Keyboard::_key[0x60] = { 0 }; -uint16 Keyboard::_current = 0; -uint16 Keyboard::_code[0x60] = { +const uint16 Keyboard::_code[0x60] = { 0, Esc, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '+', BSp, @@ -60,10 +57,12 @@ uint16 Keyboard::_code[0x60] = { 0 * 0x5F }; -void (* Keyboard::OldKeyboard)(...); - Keyboard::Keyboard() { + _client = NULL; + Common::set_to(&_key[0], &_key[0x60], 0); + _current = 0; + // steal keyboard interrupt /* TODO replace totally by scummvm handling OldKeyboard = getvect(KEYBD_INT); diff --git a/engines/cge/events.h b/engines/cge/events.h index 518c8c8bd1..462571f5ad 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -46,18 +46,19 @@ namespace CGE { class Keyboard { public: - static void (* OldKeyboard)(...); - static void NewKeyboard(...); - static uint16 _code[0x60]; - static uint16 _current; - static Sprite *_client; - static uint8 _key[0x60]; - static uint16 last() { + static const uint16 _code[0x60]; + + void NewKeyboard(...); + uint16 _current; + Sprite *_client; + uint8 _key[0x60]; + uint16 last() { uint16 cur = _current; _current = 0; return cur; } - static Sprite *setClient(Sprite *spr); + Sprite *setClient(Sprite *spr); + Keyboard(); ~Keyboard(); }; @@ -111,6 +112,9 @@ private: CGEEngine *_vm; }; +/*----------------- Access variables -----------------*/ +// TODO: Move this into either the CGEEngine class or a suitable 'globals' + } // End of namespace CGE #endif diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 889aee4fed..9a6c1539d1 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -37,7 +37,7 @@ GetText *GetText::_ptr = NULL; GetText::GetText(CGEEngine *vm, const char *info, char *text, int size, void (*click)()) : TALK(vm), _text(text), _size(min(size, GTMAX)), _len(min(_size, strlen(text))), - _cntr(GTBLINK), _click(click), _oldKeybClient(Keyboard::setClient(this)), _vm(vm) { + _cntr(GTBLINK), _click(click), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { int i = 2 * TEXT_HM + _Font->Width(info); _ptr = this; Mode = RECT; @@ -54,7 +54,7 @@ GetText::GetText(CGEEngine *vm, const char *info, char *text, int size, void (*c GetText::~GetText() { - Keyboard::setClient(_oldKeybClient); + _keyboard->setClient(_oldKeybClient); _ptr = NULL; } @@ -101,7 +101,7 @@ void GetText::touch(uint16 mask, int x, int y) { if (_oldKeybClient) _oldKeybClient->touch(mask, x, y); } else { - if (Keyboard::_key[ALT]) { + if (_keyboard->_key[ALT]) { p = strchr(bezo, x); if (p) x = ogon[p - bezo]; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index f8c0b9ceab..18bbfb65b5 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -114,8 +114,8 @@ void Mixer::touch(uint16 mask, int x, int y) { void Mixer::tick() { - int x = Mouse->_x; - int y = Mouse->_y; + int x = _mouse->_x; + int y = _mouse->_y; if (SpriteAt(x, y) == this) { _fall = MIX_FALL; if (_flags._hold) diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 217acb2448..9db8f4af6f 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -180,7 +180,7 @@ static void SNGame(Sprite *spr, int num) { k2->step(new_random(6)); k3->step(new_random(6)); ///-------------------- - if (spr->_ref == 1 && Keyboard::_key[ALT]) { + if (spr->_ref == 1 && _keyboard->_key[ALT]) { k1->step(5); k2->step(5); k3->step(5); @@ -897,9 +897,9 @@ static void SNReach(Sprite *spr, int mode) { static void SNMouse(bool on) { if (on) - Mouse->On(); + _mouse->On(); else - Mouse->Off(); + _mouse->Off(); } -- cgit v1.2.3 From bb3d61b137aea4cab3e82d4f9f93b1dbea27c54e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 18:38:25 +1000 Subject: CGE: Created an EventManager class and hooked it up to the Keyboard class --- engines/cge/cge.cpp | 4 ++ engines/cge/cge.h | 2 + engines/cge/cge_main.cpp | 42 ++++++++++--- engines/cge/cge_main.h | 1 + engines/cge/events.cpp | 160 ++++++++++++++++++++++++----------------------- engines/cge/events.h | 26 ++++++-- 6 files changed, 142 insertions(+), 93 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 3feb8f64d2..f7e66183ce 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -51,6 +51,9 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) } void CGEEngine::setup() { + // Initialise fields + _lastFrame = 0; + // Create debugger console _console = new CGEConsole(this); @@ -98,6 +101,7 @@ void CGEEngine::setup() { _mouse = new MOUSE(this); _keyboard = new Keyboard(); + _eventManager = new EventManager(); OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 06c7fb2326..e4bb260bcc 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -43,6 +43,8 @@ enum { }; class CGEEngine : public Engine { +private: + uint32 _lastFrame; public: CGEEngine(OSystem *syst, const ADGameDescription *gameDescription); ~CGEEngine(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6e5c65b76f..0fa2b0cb0c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -66,6 +66,7 @@ Heart *_heart; WALK *Hero; SYSTEM *Sys; Sprite *_pocLight; +EventManager *_eventManager; Keyboard *_keyboard; MOUSE *_mouse; Sprite *_pocket[POCKET_NX]; @@ -1537,6 +1538,7 @@ void CGEEngine::loadScript(const char *fname) { error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname); } +#define GAME_FRAME_DELAY (1000 / 50) void CGEEngine::mainLoop() { SayDebug(); @@ -1558,8 +1560,17 @@ void CGEEngine::mainLoop() { Snail_->RunCom(); Snail->RunCom(); - // Delay to slow things down - g_system->delayMillis(10); + // Game frame delay + uint32 millis = g_system->getMillis(); + while (!_eventManager->_quitFlag && (millis < (_lastFrame + GAME_FRAME_DELAY))) { + // Handle any pending events + _eventManager->poll(); + + // Slight delay + g_system->delayMillis(10); + millis = g_system->getMillis(); + } + _lastFrame = millis; } @@ -1585,6 +1596,9 @@ void CGEEngine::loadUser() { void CGEEngine::runGame() { + if (_eventManager->_quitFlag) + return; + Text->Clear(); Text->Preload(100, 1000); LoadHeroXY(); @@ -1677,7 +1691,7 @@ void CGEEngine::runGame() { _keyboard->setClient(Sys); // main loop - while (! Finis) { + while (! Finis && !_eventManager->_quitFlag) { //TODO Change the SNPOST message send to a special way to send function pointer // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame); warning("RunGame: problematic use of SNPOST"); @@ -1697,6 +1711,9 @@ void CGEEngine::runGame() { void CGEEngine::movie(const char *ext) { + if (_eventManager->_quitFlag) + return; + const char *fn = progName(ext); if (INI_FILE::exist(fn)) { loadScript(fn); @@ -1708,7 +1725,7 @@ void CGEEngine::movie(const char *ext) { _heart->_enable = true; _keyboard->setClient(Sys); - while (!Snail->Idle()) + while (!Snail->Idle() && !_eventManager->_quitFlag) mainLoop(); _keyboard->setClient(NULL); @@ -1722,6 +1739,9 @@ void CGEEngine::movie(const char *ext) { bool CGEEngine::showTitle(const char *name) { + if (_eventManager->_quitFlag) + return false; + Bitmap::_pal = VGA::SysPal; BMP_PTR LB[] = { new Bitmap(name, true), NULL }; Bitmap::_pal = NULL; @@ -1750,8 +1770,12 @@ bool CGEEngine::showTitle(const char *name) { Vga->ShowQ->Append(_mouse); _heart->_enable = true; _mouse->On(); - for (selectSound(); !Snail->Idle() || VMENU::Addr;) + for (selectSound(); !Snail->Idle() || VMENU::Addr;) { mainLoop(); + if (_eventManager->_quitFlag) + return false; + } + _mouse->Off(); _heart->_enable = false; Vga->ShowQ->Clear(); @@ -1786,8 +1810,11 @@ bool CGEEngine::showTitle(const char *name) { Vga->ShowQ->Append(_mouse); //Mouse.On(); _heart->_enable = true; - for (takeName(); GetText::_ptr;) + for (takeName(); GetText::_ptr;) { mainLoop(); + if (_eventManager->_quitFlag) + return false; + } _heart->_enable = false; if (_keyboard->last() == Enter && *UsrFnam) usr_ok = true; @@ -1857,10 +1884,9 @@ void CGEEngine::cge_main(void) { if (Music && STARTUP::SoundOk) LoadMIDI(0); -/** *****DEBUG***** if (STARTUP::Mode < 2) movie(LGO_EXT); -*/ + if (showTitle("WELCOME")) { if ((!_isDemo) && (STARTUP::Mode == 1)) movie("X02"); // intro diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 3eea114420..effded84cc 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -174,6 +174,7 @@ extern int OffUseCount; extern Sprite *_pocLight; extern Keyboard *_keyboard; extern MOUSE *_mouse; +extern EventManager *_eventManager; extern Sprite *_pocket[]; extern Sprite *_sprite; extern Sprite *_miniCave; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 49b08e407b..92c356fa5f 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -25,6 +25,7 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ +#include "common/events.h" #include "cge/events.h" #include "cge/events.h" #include "cge/text.h" @@ -57,103 +58,85 @@ const uint16 Keyboard::_code[0x60] = { 0 * 0x5F }; +const uint16 Keyboard::_scummVmCodes[0x60] = { + 0, Common::KEYCODE_ESCAPE, Common::KEYCODE_1, Common::KEYCODE_2, Common::KEYCODE_3, + Common::KEYCODE_4, Common::KEYCODE_5, Common::KEYCODE_6, Common::KEYCODE_7, Common::KEYCODE_8, + Common::KEYCODE_9, Common::KEYCODE_0, Common::KEYCODE_MINUS, Common::KEYCODE_PLUS, Common::KEYCODE_BACKSPACE, + Common::KEYCODE_TAB, Common::KEYCODE_q, Common::KEYCODE_w, Common::KEYCODE_e, Common::KEYCODE_r, + Common::KEYCODE_t, Common::KEYCODE_y, Common::KEYCODE_u, Common::KEYCODE_i, Common::KEYCODE_o, + Common::KEYCODE_p, Common::KEYCODE_LEFTBRACKET, Common::KEYCODE_RIGHTBRACKET, Common::KEYCODE_RETURN, 0/*Ctrl*/, + Common::KEYCODE_a, Common::KEYCODE_s, Common::KEYCODE_d, Common::KEYCODE_f, Common::KEYCODE_g, + Common::KEYCODE_h, Common::KEYCODE_j, Common::KEYCODE_k, Common::KEYCODE_l, Common::KEYCODE_SEMICOLON, + Common::KEYCODE_BACKSLASH, Common::KEYCODE_TILDE, Common::KEYCODE_LSHIFT, Common::KEYCODE_BACKSLASH, Common::KEYCODE_z, + Common::KEYCODE_x, Common::KEYCODE_c, Common::KEYCODE_v, Common::KEYCODE_b, Common::KEYCODE_n, + Common::KEYCODE_m, Common::KEYCODE_COMMA, Common::KEYCODE_PERIOD, Common::KEYCODE_SLASH, Common::KEYCODE_RSHIFT, + Common::KEYCODE_KP_MULTIPLY, 0 /*Alt*/, Common::KEYCODE_SPACE, Common::KEYCODE_CAPSLOCK, Common::KEYCODE_F1, + Common::KEYCODE_F2, Common::KEYCODE_F3, Common::KEYCODE_F4, Common::KEYCODE_F5, Common::KEYCODE_F6, + Common::KEYCODE_F7, Common::KEYCODE_F8, Common::KEYCODE_F9, Common::KEYCODE_F10, Common::KEYCODE_NUMLOCK, + Common::KEYCODE_SCROLLOCK, Common::KEYCODE_KP7, Common::KEYCODE_KP8, Common::KEYCODE_KP9, Common::KEYCODE_KP_MINUS, + Common::KEYCODE_KP4, Common::KEYCODE_KP5, Common::KEYCODE_KP6, Common::KEYCODE_KP_PLUS, Common::KEYCODE_KP1, + Common::KEYCODE_KP2, Common::KEYCODE_KP3, Common::KEYCODE_KP0, Common::KEYCODE_KP_PERIOD, 0, + 0, 0, Common::KEYCODE_F11, Common::KEYCODE_F12, 0, + 0, 0, 0, 0, 0, + 0 +}; Keyboard::Keyboard() { _client = NULL; - Common::set_to(&_key[0], &_key[0x60], 0); + Common::set_to(&_key[0], &_key[0x60], false); _current = 0; - - // steal keyboard interrupt - /* TODO replace totally by scummvm handling - OldKeyboard = getvect(KEYBD_INT); - setvect(KEYBD_INT, NewKeyboard); - */ - warning("STUB: Keyboard::Keyboard"); } - Keyboard::~Keyboard() { - // bring back keyboard interrupt - /* TODO replace totally by scummvm handling - setvect(KEYBD_INT, OldKeyboard); - */ - // FIXME: STUB: KEYBOARD::~KEYBOARD } - Sprite *Keyboard::setClient(Sprite *spr) { Swap(_client, spr); return spr; } +bool Keyboard::getKey(uint16 keycode, int &cgeCode) { + if ((keycode == Common::KEYCODE_LCTRL) || (keycode == Common::KEYCODE_RCTRL)) { + cgeCode = 29; + return true; + } -void Keyboard::NewKeyboard(...) { - // table address - /* - _SI = (uint16) Key; - - // take keyboard code - asm in al,60h - asm mov bl,al - asm and bx,007Fh - asm cmp bl,60h - asm jae xit - asm cmp al,bl - asm je ok // key pressed - - // key released... - asm cmp [si+bx],bh // BH == 0 - asm jne ok - // ...but not pressed: call the original service - OldKeyboard(); - return; - - ok: - asm shl ax,1 - asm and ah,1 - asm xor ah,1 - asm mov [si+bx],ah - asm jz xit // released: exit - - // pressed: lock ASCII code - _SI = (uint16) Code; - asm add bx,bx // uint16 size - asm mov ax,[si+bx] - asm or ax,ax - asm jz xit // zero means NO KEY - Current = _AX; - - _SI = (uint16) Client; - asm or si,si - asm jz xit // if (Client) ... - //--- fill current event entry with mask, key code and sprite - asm mov bx,EvtHead // take queue head pointer - asm inc byte ptr EvtHead // update queue head pointer - asm shl bx,3 // * 8 - _AX = Current; - asm mov Evt[bx].(struct EVENT)X,ax // key code - asm mov ax,KEYB // event mask - asm mov Evt[bx].(struct EVENT)Msk,ax // event mask - //asm mov Evt[bx].(struct EVENT)Y,dx // row - asm mov Evt[bx].(struct EVENT)Ptr,si // SPRITE pointer - - xit: - - asm in al,61h // kbd control lines - asm push ax // save it - asm or al,80h // set the "enable kbd" bit - asm out 61h,al // and write it out - asm pop ax // original control port value - asm out 61h,al // write it back - asm mov al,20h // send End-Of-Interrupt - asm out 20h,al // to the 8259 IC - */ - warning("STUB: Keyboard::NewKeyboard"); + // Scan through the ScummVM mapping list + for (int idx = 0; idx < 0x60; ++idx) { + if (_scummVmCodes[idx] == keycode) { + cgeCode = idx; + return true; + } + } + + return false; +} + +void Keyboard::NewKeyboard(Common::Event &event) { + int keycode; + if (!getKey(event.kbd.keycode, keycode)) + return; + + if (event.type == Common::EVENT_KEYUP) { + // Key release + _key[event.kbd.keycode] = false; + } else if (event.type == Common::EVENT_KEYDOWN) { + // Key press + _key[event.kbd.keycode] = true; + _current = Keyboard::_code[event.kbd.keycode]; + + if (_client) { + CGEEvent &evt = Evt[EvtHead++]; + evt._x = _current; // Keycode + evt._msk = KEYB; // Event mask + evt._ptr = _client; // Sprite pointer + } + } } /*----------------- MOUSE interface -----------------*/ -Event Evt[EVT_MAX]; +CGEEvent Evt[EVT_MAX]; uint16 EvtHead = 0, EvtTail = 0; @@ -268,7 +251,7 @@ void MOUSE::ClrEvt(Sprite *spr) { void MOUSE::Tick(void) { step(); while (EvtTail != EvtHead) { - Event e = Evt[EvtTail]; + CGEEvent e = Evt[EvtTail]; if (e._msk) { if (Hold && e._ptr != Hold) Hold->touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y); @@ -313,5 +296,24 @@ void MOUSE::Tick(void) { Hold->gotoxy(_x - hx, _y - hy); } +/*----------------- EventManager interface -----------------*/ + +EventManager::EventManager() { + _quitFlag = false; +} + +void EventManager::poll() { + while (g_system->getEventManager()->pollEvent(_event)) { + switch (_event.type) { + case Common::EVENT_QUIT: + _quitFlag = true; + return; + case Common::EVENT_KEYDOWN: + case Common::EVENT_KEYUP: + _keyboard->NewKeyboard(_event); + break; + } + } +} } // End of namespace CGE diff --git a/engines/cge/events.h b/engines/cge/events.h index 462571f5ad..be003ea0d8 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -28,6 +28,7 @@ #ifndef __CGE_CGE_EVENTS__ #define __CGE_CGE_EVENTS__ +#include "common/events.h" #include "cge/game.h" #include "cge/talk.h" #include "cge/jbw.h" @@ -45,13 +46,17 @@ namespace CGE { class Keyboard { +private: + bool getKey(uint16 keycode, int &cgeCode); public: static const uint16 _code[0x60]; + static const uint16 _scummVmCodes[0x60]; - void NewKeyboard(...); uint16 _current; Sprite *_client; - uint8 _key[0x60]; + bool _key[0x60]; + + void NewKeyboard(Common::Event &event); uint16 last() { uint16 cur = _current; _current = 0; @@ -77,14 +82,14 @@ public: extern TALK *Talk; -struct Event { +struct CGEEvent { uint16 _msk; uint16 _x; uint16 _y; Sprite *_ptr; }; -extern Event Evt[EVT_MAX]; +extern CGEEvent Evt[EVT_MAX]; extern uint16 EvtHead, EvtTail; typedef void (MOUSE_FUN)(void); @@ -112,8 +117,17 @@ private: CGEEngine *_vm; }; -/*----------------- Access variables -----------------*/ -// TODO: Move this into either the CGEEngine class or a suitable 'globals' +/*----------------- EventManager interface -----------------*/ + +class EventManager { +private: + Common::Event _event; +public: + bool _quitFlag; + + EventManager(); + void poll(); +}; } // End of namespace CGE -- cgit v1.2.3 From 72ae475c97e6f0ba1cae2f7aa0bc2860e45de495 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 20:04:30 +1000 Subject: CGE: Fix naming of touch() virtual methods, and fixed keyboard handling --- engines/cge/cge_main.cpp | 6 ++-- engines/cge/cge_main.h | 2 +- engines/cge/events.cpp | 78 ++++++++++++++++++++++++++---------------------- engines/cge/events.h | 5 ++-- engines/cge/vmenu.cpp | 2 +- engines/cge/vmenu.h | 2 +- 6 files changed, 52 insertions(+), 43 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 0fa2b0cb0c..0ee8f3ef0b 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -552,7 +552,7 @@ void WALK::reach(Sprite *spr, int mode) { class SQUARE : public Sprite { public: SQUARE(CGEEngine *vm); - void Touch(uint16 mask, int x, int y); + virtual void touch(uint16 mask, int x, int y); private: CGEEngine *_vm; }; @@ -565,7 +565,7 @@ SQUARE::SQUARE(CGEEngine *vm) } -void SQUARE::Touch(uint16 mask, int x, int y) { +void SQUARE::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); if (mask & L_UP) { XZ(_x + x, _y + y).cell() = 0; @@ -822,7 +822,7 @@ SYSTEM::SYSTEM(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { Tick(); } -void SYSTEM::Touch(uint16 mask, int x, int y) { +void SYSTEM::touch(uint16 mask, int x, int y) { static int pp = 0; FunTouch(); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index effded84cc..6920f7b2d3 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -122,7 +122,7 @@ public: void SetPal(); void FunTouch(); - void Touch(uint16 mask, int x, int y); + virtual void touch(uint16 mask, int x, int y); void Tick(); private: CGEEngine *_vm; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 92c356fa5f..932c922c49 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -247,18 +247,46 @@ void MOUSE::ClrEvt(Sprite *spr) { EvtTail = EvtHead; } +/*----------------- EventManager interface -----------------*/ + +EventManager::EventManager() { + _quitFlag = false; +} + +void EventManager::poll() { + while (g_system->getEventManager()->pollEvent(_event)) { + switch (_event.type) { + case Common::EVENT_QUIT: + _quitFlag = true; + return; + case Common::EVENT_KEYDOWN: + case Common::EVENT_KEYUP: + _keyboard->NewKeyboard(_event); + handleEvents(); + break; + case Common::EVENT_MOUSEMOVE: + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_LBUTTONUP: + case Common::EVENT_RBUTTONDOWN: + case Common::EVENT_RBUTTONUP: + // TODO: Handle mouse events + //_mouse->NewMouse(event); + handleEvents(); + break; + } + } +} -void MOUSE::Tick(void) { - step(); +void EventManager::handleEvents(void) { while (EvtTail != EvtHead) { CGEEvent e = Evt[EvtTail]; if (e._msk) { - if (Hold && e._ptr != Hold) - Hold->touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y); + if (_mouse->Hold && e._ptr != _mouse->Hold) + _mouse->Hold->touch(e._msk | ATTN, e._x - _mouse->Hold->_x, e._y - _mouse->Hold->_y); // update mouse cursor position if (e._msk & ROLL) - gotoxy(e._x, e._y); + _mouse->gotoxy(e._x, e._y); // activate current touched SPRITE if (e._ptr) { @@ -270,18 +298,18 @@ void MOUSE::Tick(void) { Sys->touch(e._msk, e._x, e._y); if (e._msk & L_DN) { - Hold = e._ptr; - if (Hold) { - Hold->_flags._hold = true; - hx = e._x - Hold->_x; - hy = e._y - Hold->_y; + _mouse->Hold = e._ptr; + if (_mouse->Hold) { + _mouse->Hold->_flags._hold = true; + _mouse->hx = e._x - _mouse->Hold->_x; + _mouse->hy = e._y - _mouse->Hold->_y; } } if (e._msk & L_UP) { - if (Hold) { - Hold->_flags._hold = false; - Hold = NULL; + if (_mouse->Hold) { + _mouse->Hold->_flags._hold = false; + _mouse->Hold = NULL; } } ///Touched = e.Ptr; @@ -292,28 +320,8 @@ void MOUSE::Tick(void) { } EvtTail = (EvtTail + 1) % EVT_MAX; } - if (Hold) - Hold->gotoxy(_x - hx, _y - hy); -} - -/*----------------- EventManager interface -----------------*/ - -EventManager::EventManager() { - _quitFlag = false; -} - -void EventManager::poll() { - while (g_system->getEventManager()->pollEvent(_event)) { - switch (_event.type) { - case Common::EVENT_QUIT: - _quitFlag = true; - return; - case Common::EVENT_KEYDOWN: - case Common::EVENT_KEYUP: - _keyboard->NewKeyboard(_event); - break; - } - } + if (_mouse->Hold) + _mouse->Hold->gotoxy(_mouse->_x - _mouse->hx, _mouse->_y - _mouse->hy); } } // End of namespace CGE diff --git a/engines/cge/events.h b/engines/cge/events.h index be003ea0d8..4ed74469f2 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -98,11 +98,11 @@ class MOUSE : public Sprite { static MOUSE_FUN *OldMouseFun; static MOUSE_FUN NewMouseFun; static uint16 OldMouseMask; - Sprite *Hold; - int hx, hy; //void SetFun (void); //void ResetFun (void); public: + Sprite *Hold; + int hx, hy; bool Exist; int Buttons; Sprite *Busy; @@ -122,6 +122,7 @@ private: class EventManager { private: Common::Event _event; + void handleEvents(); public: bool _quitFlag; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 149af901e8..d999dfa760 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -125,7 +125,7 @@ VMENU::~VMENU(void) { } -void VMENU::Touch(uint16 mask, int x, int y) { +void VMENU::touch(uint16 mask, int x, int y) { uint16 h = FONT_HIG + TEXT_LS; bool ok = false; diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 2bb3cef88d..c2fc096e83 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -59,7 +59,7 @@ public: MENU_BAR *Bar; VMENU(CGEEngine *vm, CHOICE *list, int x, int y); ~VMENU(); - void Touch(uint16 mask, int x, int y); + virtual void touch(uint16 mask, int x, int y); private: CGEEngine *_vm; }; -- cgit v1.2.3 From adb27016294b995eb273663a2c33904050723f96 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 20:38:27 +1000 Subject: CGE: Graceful exit rather than an error --- engines/cge/cge.cpp | 22 +++++++++++----------- engines/cge/cge_main.cpp | 1 - engines/cge/vga13h.cpp | 4 ++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index f7e66183ce..da6365ca83 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -119,17 +119,7 @@ CGEEngine::~CGEEngine() { _console = new CGEConsole(this); - // Delete engine objects - delete Text; - delete Vga; - delete _heart; - delete Hero; - delete Sys; - delete _pocLight; - delete _keyboard; - delete _mouse; - for (int i = 0; i < POCKET_NX; i++) - delete _pocket[i]; + // Delete engine objects delete _sprite; delete _miniCave; delete _shadow; @@ -148,8 +138,18 @@ CGEEngine::~CGEEngine() { delete LI[1]; delete LI[2]; delete LI[3]; + delete Text; + delete _heart; + delete _pocLight; + delete _keyboard; + delete _mouse; + for (int i = 0; i < POCKET_NX; i++) + delete _pocket[i]; delete Snail; delete Snail_; + delete Hero; + delete Vga; + delete Sys; } Common::Error CGEEngine::run() { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 0ee8f3ef0b..6562dac041 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1896,7 +1896,6 @@ void CGEEngine::cge_main(void) { movie("X03"); } else Vga->Sunset(); - error("%s", Text->getText(EXIT_OK_TEXT + FINIS)); } } // End of namespace CGE diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 0e865ffd90..83c89892ca 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -366,6 +366,8 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) Sprite::~Sprite() { + if (_sprite == this) + _sprite = NULL; contract(); } @@ -970,11 +972,13 @@ VGA::~VGA(void) { Mono = 0; if (isVga()) { Common::String buffer = ""; +/* Clear(0); SetMode(OldMode); SetColors(); RestoreScreen(OldScreen); Sunrise(OldColors); +*/ if (OldColors) free(OldColors); if (NewColors) -- cgit v1.2.3 From 1e3c0725e4ed431f6e1336edb7e3976532f71160 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 21:34:40 +1000 Subject: CGE: Hooked up mouse event handler --- engines/cge/events.cpp | 72 ++++++++++++++++++++++++++++++++------------------ engines/cge/events.h | 9 ++----- engines/cge/snail.cpp | 2 +- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 932c922c49..2c675a69f8 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -140,31 +140,23 @@ CGEEvent Evt[EVT_MAX]; uint16 EvtHead = 0, EvtTail = 0; -MOUSE_FUN *MOUSE::OldMouseFun = NULL; -uint16 MOUSE::OldMouseMask = 0; - - MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { static Seq ms[] = { { 0, 0, 0, 0, 1 }, { 1, 1, 0, 0, 1 } }; + Hold = NULL; + hx = 0; hy = 0; + Exist = true; + Buttons = 0; + Busy = NULL; + setSeq(ms); - /* TODO Mouse handling - // Mouse reset - _AX = 0x0000; // soft & hard reset (0x0021 soft reset does not work) - __int__(0x33); - Exist = (_AX != 0); - Buttons = _BX; -*/ gotoxy(SCR_WID/2, SCR_HIG/2); _z = 127; step(1); - - Exist = true; - warning("STUB: MOUSE::MOUSE"); } @@ -236,15 +228,33 @@ void MOUSE::Off(void) { warning("STUB: MOUSE::Off"); } - -void MOUSE::ClrEvt(Sprite *spr) { - if (spr) { - uint16 e; - for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) - if (Evt[e]._ptr == spr) - Evt[e]._msk = 0; - } else - EvtTail = EvtHead; +void MOUSE::NewMouse(Common::Event &event) { + CGEEvent &evt = Evt[EvtHead++]; + evt._x = event.mouse.x; + evt._y = event.mouse.y; + evt._ptr = SpriteAt(evt._x, evt._y); + + switch (event.type) { + case Common::EVENT_MOUSEMOVE: + evt._msk = ROLL; + break; + case Common::EVENT_LBUTTONDOWN: + evt._msk = L_DN; + Buttons |= 1; + break; + case Common::EVENT_LBUTTONUP: + evt._msk = L_UP; + Buttons &= ~1; + break; + case Common::EVENT_RBUTTONDOWN: + evt._msk = R_DN; + Buttons |= 2; + break; + case Common::EVENT_RBUTTONUP: + evt._msk = R_UP; + Buttons &= ~2; + break; + } } /*----------------- EventManager interface -----------------*/ @@ -257,10 +267,12 @@ void EventManager::poll() { while (g_system->getEventManager()->pollEvent(_event)) { switch (_event.type) { case Common::EVENT_QUIT: + // Signal to quit _quitFlag = true; return; case Common::EVENT_KEYDOWN: case Common::EVENT_KEYUP: + // Handle keyboard events _keyboard->NewKeyboard(_event); handleEvents(); break; @@ -269,8 +281,8 @@ void EventManager::poll() { case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONUP: - // TODO: Handle mouse events - //_mouse->NewMouse(event); + // Handle mouse events + _mouse->NewMouse(_event); handleEvents(); break; } @@ -324,4 +336,14 @@ void EventManager::handleEvents(void) { _mouse->Hold->gotoxy(_mouse->_x - _mouse->hx, _mouse->_y - _mouse->hy); } +void EventManager::ClrEvt(Sprite *spr) { + if (spr) { + uint16 e; + for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) + if (Evt[e]._ptr == spr) + Evt[e]._msk = 0; + } else + EvtTail = EvtHead; +} + } // End of namespace CGE diff --git a/engines/cge/events.h b/engines/cge/events.h index 4ed74469f2..f1e02b0d09 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -91,15 +91,9 @@ struct CGEEvent { extern CGEEvent Evt[EVT_MAX]; extern uint16 EvtHead, EvtTail; -typedef void (MOUSE_FUN)(void); class MOUSE : public Sprite { - static MOUSE_FUN *OldMouseFun; - static MOUSE_FUN NewMouseFun; - static uint16 OldMouseMask; - //void SetFun (void); - //void ResetFun (void); public: Sprite *Hold; int hx, hy; @@ -111,8 +105,8 @@ public: ~MOUSE(); void On(); void Off(); - static void ClrEvt(Sprite *spr = NULL); void Tick(); + void NewMouse(Common::Event &event); private: CGEEngine *_vm; }; @@ -128,6 +122,7 @@ public: EventManager(); void poll(); + static void ClrEvt(Sprite *spr = NULL); }; } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 9db8f4af6f..4bf6f72489 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -747,7 +747,7 @@ void SNKill(Sprite *spr) { Sprite *nx = spr->_next; Hide1(spr); Vga->ShowQ->Remove(spr); - MOUSE::ClrEvt(spr); + EventManager::ClrEvt(spr); if (spr->_flags._kill) delete spr; else { -- cgit v1.2.3 From e782b53eab7d9c77f17e1393712bf8425f9349a0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 21:45:29 +1000 Subject: CGE: Added code for Mouse::On and Mouse::Off --- engines/cge/events.cpp | 66 ++++++++++++-------------------------------------- engines/cge/events.h | 1 + 2 files changed, 17 insertions(+), 50 deletions(-) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 2c675a69f8..99ada03bd5 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -151,6 +151,7 @@ MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold( Exist = true; Buttons = 0; Busy = NULL; + _active = false; setSeq(ms); @@ -171,64 +172,29 @@ MOUSE::~MOUSE(void) { void MOUSE::On(void) { - /* - if (SeqPtr && Exist) - { - _CX = X + X; // horizontal position - _DX = Y; // vertical position - _AX = 0x0004; // Set Mouse Position - __int__(0x33); - // set new mouse fun - _ES = FP_SEG(NewMouseFun); - _DX = FP_OFF(NewMouseFun); - _CX = 0x001F; // 11111b = all events - _AX = 0x0014; // Swap User-Interrupt Vector - __int__(0x33); - // save old mouse fun - OldMouseMask = _CX; - OldMouseFun = (MOUSE_FUN *) MK_FP(_ES, _DX); - - // set X bounds - _DX = (SCR_WID - W) * 2; // right limit - _CX = 0; // left limit - _AX = 0x0007; // note: each pixel = 2 - __int__(0x33); - - // set Y bounds - _DX = SCR_HIG - H; // bottom limit - _CX = 0; // top limit - _AX = 0x0008; - __int__(0x33); - - Step(0); - if (Busy) Busy->Step(0); - } - */ - warning("STUB: MOUSE::On"); + if (_seqPtr && Exist) { + _active = true; + step(0); + if (Busy) Busy->step(0); + } } void MOUSE::Off(void) { -/* - if (SeqPtr == 0) - { - if (Exist) - { - // bring back old mouse fun - _ES = FP_SEG(OldMouseFun); - _DX = FP_OFF(OldMouseFun); - _CX = OldMouseMask; - _AX = 0x0014; // Swap User-Interrupt Vector - __int__(0x33); - } - Step(1); - if (Busy) Busy->Step(1); + if (_seqPtr == 0) { + if (Exist) { + _active = false; + } + + step(1); + if (Busy) Busy->step(1); } - */ - warning("STUB: MOUSE::Off"); } void MOUSE::NewMouse(Common::Event &event) { + if (!_active) + return; + CGEEvent &evt = Evt[EvtHead++]; evt._x = event.mouse.x; evt._y = event.mouse.y; diff --git a/engines/cge/events.h b/engines/cge/events.h index f1e02b0d09..59a62803ba 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -96,6 +96,7 @@ extern uint16 EvtHead, EvtTail; class MOUSE : public Sprite { public: Sprite *Hold; + bool _active; int hx, hy; bool Exist; int Buttons; -- cgit v1.2.3 From d510d2505b7c9e4968020de6926dea19cfb7fa34 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 22:15:23 +1000 Subject: CGE: Fix for crash in BITMAP::solidAt when negative co-ordinates passed --- engines/cge/bitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index dc06d9944e..3bcf751b40 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -313,7 +313,7 @@ bool Bitmap::solidAt(int x, int y) { return false; m = _v; - r = x % 4; + r = static_cast(x) % 4; n0 = (SCR_WID * y + x) / 4, n = 0; while (r) { -- cgit v1.2.3 From f150126a0b209418d3a91ec5b5f1c1c0fdced9c7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 22:26:40 +1000 Subject: CGE: Bugfix for wrapping event queue when it reaches the 256th event --- engines/cge/events.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 99ada03bd5..2b9cc7fc6c 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -33,6 +33,10 @@ namespace CGE { +CGEEvent Evt[EVT_MAX]; + +uint16 EvtHead = 0, EvtTail = 0; + /*----------------- KEYBOARD interface -----------------*/ const uint16 Keyboard::_code[0x60] = { @@ -126,7 +130,8 @@ void Keyboard::NewKeyboard(Common::Event &event) { _current = Keyboard::_code[event.kbd.keycode]; if (_client) { - CGEEvent &evt = Evt[EvtHead++]; + CGEEvent &evt = Evt[EvtHead]; + EvtHead = (EvtHead + 1) % EVT_MAX; evt._x = _current; // Keycode evt._msk = KEYB; // Event mask evt._ptr = _client; // Sprite pointer @@ -136,10 +141,6 @@ void Keyboard::NewKeyboard(Common::Event &event) { /*----------------- MOUSE interface -----------------*/ -CGEEvent Evt[EVT_MAX]; - -uint16 EvtHead = 0, EvtTail = 0; - MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { static Seq ms[] = { { 0, 0, 0, 0, 1 }, @@ -195,7 +196,8 @@ void MOUSE::NewMouse(Common::Event &event) { if (!_active) return; - CGEEvent &evt = Evt[EvtHead++]; + CGEEvent &evt = Evt[EvtHead]; + EvtHead = (EvtHead + 1) % EVT_MAX; evt._x = event.mouse.x; evt._y = event.mouse.y; evt._ptr = SpriteAt(evt._x, evt._y); -- cgit v1.2.3 From bdc213846e1c35c7b6b7f5a397f97d8fe334c1b1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 2 Jul 2011 18:20:41 +0200 Subject: CGE: Some more renaming (WIP) --- engines/cge/cge.cpp | 8 +- engines/cge/cge_main.cpp | 224 ++++++++++++++++---------------- engines/cge/cge_main.h | 8 +- engines/cge/config.cpp | 10 +- engines/cge/general.cpp | 6 +- engines/cge/snail.cpp | 324 +++++++++++++++++++++++------------------------ engines/cge/snail.h | 82 ++++++------ engines/cge/snddrv.h | 10 +- engines/cge/sound.cpp | 8 +- engines/cge/sound.h | 10 +- engines/cge/vga13h.cpp | 46 +++---- engines/cge/vga13h.h | 4 +- 12 files changed, 365 insertions(+), 375 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index da6365ca83..4af10b2b8d 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -96,8 +96,8 @@ void CGEEngine::setup() { LI[2] = new Bitmap("LITE2", true); LI[3] = new Bitmap("LITE3", true); LI[4] = NULL; - Snail = new SNAIL(this, false); - Snail_ = new SNAIL(this, true); + _snail = new Snail(this, false); + _snail_ = new Snail(this, true); _mouse = new MOUSE(this); _keyboard = new Keyboard(); @@ -145,8 +145,8 @@ CGEEngine::~CGEEngine() { delete _mouse; for (int i = 0; i < POCKET_NX; i++) delete _pocket[i]; - delete Snail; - delete Snail_; + delete _snail; + delete _snail_; delete Hero; delete Vga; delete Sys; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6562dac041..22316d79b1 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -54,7 +54,7 @@ namespace CGE { #define STACK_SIZ (K(2)) -#define SVGCHKSUM (1956 + Now + OldLev + Game + Music + DemoText) +#define SVGCHKSUM (1956 + _now + _oldLev + _game + _music + _demoText) #define SVG0NAME ("{{INIT}}" SVG_EXT) #define SVG0FILE INI_FILE @@ -85,8 +85,8 @@ BMP_PTR PR[2]; BMP_PTR SP[3]; BMP_PTR LI[5]; -SNAIL *Snail; -SNAIL *Snail_; +Snail *_snail; +Snail *_snail_; // 0.75 - 17II95 - full sound support // 0.76 - 18II95 - small MiniEMS in DEMO, @@ -124,8 +124,8 @@ SNAIL *Snail_; char Copr[] = "To be fixed - Copr[]"; static char UsrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; -static int OldLev = 0; -static int DemoText = DEMO_TEXT; +static int _oldLev = 0; +static int _demoText = DEMO_TEXT; //-------------------------------------------------------------------------- @@ -142,16 +142,14 @@ static int Startup = 1; int OffUseCount; uint16 *intStackPtr = false; -HXY HeroXY[CAVE_MAX] = {{0, 0}}; -BAR Barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; +Hxy _heroXY[CAVE_MAX] = {{0, 0}}; +Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; +extern int findPocket(Sprite *); +extern Dac _stdPal[58]; -extern int FindPocket(Sprite *); - -extern Dac _stdPal[58]; - -void FeedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL -uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; +void feedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL +uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; uint8 &Cluster::cell(void) { @@ -161,7 +159,7 @@ uint8 &Cluster::cell(void) { bool Cluster::Protected(void) { /* - if (A == Barriers[Now].Vert || B == Barriers[Now].Horz) + if (A == Barriers[Now]._vert || B == Barriers[Now]._horz) return true; _DX = (MAP_ZCNT << 8) + MAP_XCNT; @@ -220,8 +218,8 @@ Cluster XZ(Couple xy) { } -int pocref[POCKET_NX]; -uint8 volume[2]; +int _pocref[POCKET_NX]; +uint8 _volume[2]; struct SavTab { void *Ptr; @@ -230,21 +228,21 @@ struct SavTab { }; SavTab _savTab[] = { - { &Now, sizeof(Now), 1 }, - { &OldLev, sizeof(OldLev), 1 }, - { &DemoText, sizeof(DemoText), 1 }, - { &Game, sizeof(Game), 1 }, - { &Game, sizeof(Game), 1 }, // spare 1 - { &Game, sizeof(Game), 1 }, // spare 2 - { &Game, sizeof(Game), 1 }, // spare 3 - { &Game, sizeof(Game), 1 }, // spare 4 + { &_now, sizeof(_now), 1 }, + { &_oldLev, sizeof(_oldLev), 1 }, + { &_demoText, sizeof(_demoText), 1 }, + { &_game, sizeof(_game), 1 }, + { &_game, sizeof(_game), 1 }, // spare 1 + { &_game, sizeof(_game), 1 }, // spare 2 + { &_game, sizeof(_game), 1 }, // spare 3 + { &_game, sizeof(_game), 1 }, // spare 4 // { &VGA::Mono, sizeof(VGA::Mono), 0 }, - { &Music, sizeof(Music), 1 }, - { volume, sizeof(volume), 1 }, - { Flag, sizeof(Flag), 1 }, - { HeroXY, sizeof(HeroXY), 1 }, - { Barriers, sizeof(Barriers), 1 }, - { pocref, sizeof(pocref), 1 }, + { &_music, sizeof(_music), 1 }, + { _volume, sizeof(_volume), 1 }, + { _flag, sizeof(_flag), 1 }, + { _heroXY, sizeof(_heroXY), 1 }, + { _barriers, sizeof(_barriers), 1 }, + { _pocref, sizeof(_pocref), 1 }, { NULL, 0, 0 } }; @@ -265,11 +263,11 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { error("%s", Text->getText(BADSVG_TEXT)); if (STARTUP::Core < CORE_HIG) - Music = false; + _music = false; if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) { - SNDDrvInfo.VOL2.D = volume[0]; - SNDDrvInfo.VOL2.M = volume[1]; + SNDDrvInfo.VOL2.D = _volume[0]; + SNDDrvInfo.VOL2.M = _volume[1]; SNDSetVolume(); } @@ -291,7 +289,7 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { } for (i = 0; i < POCKET_NX; i++) { - register int r = pocref[i]; + register int r = _pocref[i]; _pocket[i] = (r < 0) ? NULL : Vga->SpareQ->Locate(r); } } @@ -312,11 +310,11 @@ static void SaveGame(XFile &file) { for (i = 0; i < POCKET_NX; i++) { register Sprite *s = _pocket[i]; - pocref[i] = (s) ? s->_ref : -1; + _pocref[i] = (s) ? s->_ref : -1; } - volume[0] = SNDDrvInfo.VOL2.D; - volume[1] = SNDDrvInfo.VOL2.M; + _volume[0] = SNDDrvInfo.VOL2.D; + _volume[1] = SNDDrvInfo.VOL2.M; for (st = _savTab; st->Ptr; st++) { if (file._error) @@ -366,18 +364,18 @@ static void noWay() { static void LoadHeroXY(void) { INI_FILE cf(progName(".HXY")); - memset(HeroXY, 0, sizeof(HeroXY)); + memset(_heroXY, 0, sizeof(_heroXY)); if (!cf._error) - cf.CFREAD(&HeroXY); + cf.CFREAD(&_heroXY); } static void LoadMapping(void) { - if (Now <= CAVE_MAX) { + if (_now <= CAVE_MAX) { INI_FILE cf(progName(".TAB")); if (!cf._error) { memset(Cluster::_map, 0, sizeof(Cluster::_map)); - cf.seek((Now - 1) * sizeof(Cluster::_map)); + cf.seek((_now - 1) * sizeof(Cluster::_map)); cf.read((uint8 *) Cluster::_map, sizeof(Cluster::_map)); } } @@ -405,7 +403,7 @@ void WALK::tick() { for (spr = Vga->ShowQ->First(); spr; spr = spr->_next) { if (distance(spr) < 2) { if (!spr->_flags._near) { - FeedSnail(spr, NEAR); + feedSnail(spr, NEAR); spr->_flags._near = true; } } else { @@ -614,7 +612,7 @@ void CGEEngine::quit() { { NULL, &CGEEngine::dummy } }; - if (Snail->Idle() && ! Hero->_flags._hide) { + if (_snail->idle() && ! Hero->_flags._hide) { if (VMENU::Addr) { SNPOST_(SNKILL, -1, 0, VMENU::Addr); resetQSwitch(); @@ -640,8 +638,8 @@ static void miniStep(int stp) { else { &*Mini; *MiniShp[0] = *MiniShpList[stp]; - if (Fx.Current) - &*(Fx.Current->EAddr()); + if (_fx.Current) + &*(_fx.Current->EAddr()); _miniCave->_flags._hide = false; } @@ -688,9 +686,9 @@ static void ShowBak(int ref) { static void caveUp() { - int BakRef = 1000 * Now; - if (Music) - LoadMIDI(Now); + int BakRef = 1000 * _now; + if (_music) + LoadMIDI(_now); ShowBak(BakRef); LoadMapping(); @@ -698,7 +696,7 @@ static void caveUp() { Sprite *spr = Vga->SpareQ->First(); while (spr) { Sprite *n = spr->_next; - if (spr->_cave == Now || spr->_cave == 0) + if (spr->_cave == _now || spr->_cave == 0) if (spr->_ref != BakRef) { if (spr->_flags._back) spr->backShow(); @@ -708,25 +706,25 @@ static void caveUp() { spr = n; } if (SNDDrvInfo.DDEV) { - Sound.Stop(); - Fx.Clear(); - Fx.Preload(0); - Fx.Preload(BakRef); + _sound.Stop(); + _fx.Clear(); + _fx.Preload(0); + _fx.Preload(BakRef); } if (Hero) { - Hero->gotoxy(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); + Hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); // following 2 lines trims Hero's Z position! Hero->tick(); Hero->_time = 1; Hero->_flags._hide = false; } - if (! Dark) + if (!_dark) Vga->Sunset(); Vga->CopyPage(0, 1); - SelectPocket(-1); + selectPocket(-1); if (Hero) Vga->ShowQ->Insert(Vga->ShowQ->Remove(Hero)); @@ -736,12 +734,12 @@ static void caveUp() { Vga->ShowQ->Insert(_shadow, Hero); _shadow->_z = Hero->_z; } - FeedSnail(Vga->ShowQ->Locate(BakRef + 999), TAKE); + feedSnail(Vga->ShowQ->Locate(BakRef + 999), TAKE); Vga->Show(); Vga->CopyPage(1, 0); Vga->Show(); Vga->Sunrise(VGA::SysPal); - Dark = false; + _dark = false; if (! Startup) _mouse->On(); @@ -758,7 +756,7 @@ void CGEEngine::caveDown() { Sprite *n = spr->_next; if (spr->_ref >= 1000 /*&& spr->_cave*/) { if (spr->_ref % 1000 == 999) - FeedSnail(spr, TAKE); + feedSnail(spr, TAKE); Vga->SpareQ->Append(Vga->ShowQ->Remove(spr)); } spr = n; @@ -775,7 +773,7 @@ void CGEEngine::xCave() { void CGEEngine::qGame() { caveDown(); - OldLev = Lev; + _oldLev = _lev; SaveSound(); CFile file = CFile(UsrPath(UsrFnam), WRI, RCrypt); SaveGame(file); @@ -785,7 +783,7 @@ void CGEEngine::qGame() { void CGEEngine::switchCave(int cav) { - if (cav != Now) { + if (cav != _now) { _heart->_enable = false; if (cav < 0) { SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint @@ -793,7 +791,7 @@ void CGEEngine::switchCave(int cav) { //SNPOST(SNEXEC, -1, 0, (void *)&QGame); // switch cave warning("SwitchCave() - SNPOST"); } else { - Now = cav; + _now = cav; _mouse->Off(); if (Hero) { Hero->park(); @@ -803,8 +801,8 @@ void CGEEngine::switchCave(int cav) { Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX); /////-------------------------------------------------------- } - _cavLight->gotoxy(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, - CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); + _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); KillText(); if (! Startup) KeyClick(); @@ -913,7 +911,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { _sprite->step(x - '0'); break; case F10 : - if (Snail->Idle() && ! Hero->_flags._hide) + if (_snail->idle() && ! Hero->_flags._hide) _vm->startCountDown(); break; case 'J': @@ -939,9 +937,9 @@ void SYSTEM::touch(uint16 mask, int x, int y) { if (y >= WORLD_HIG) { if (x < BUTTON_X) { // select cave? if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && - x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && ! Game) { + x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && !_game) { cav = ((y - CAVE_Y) / CAVE_DY) * CAVE_NX + (x - CAVE_X) / CAVE_DX + 1; - if (cav > MaxCave) + if (cav > _maxCave) cav = 0; } else { cav = 0; @@ -950,7 +948,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { if (y >= POCKET_Y && y < POCKET_Y + POCKET_NY * POCKET_DY && x >= POCKET_X && x < POCKET_X + POCKET_NX * POCKET_DX) { int n = ((y - POCKET_Y) / POCKET_DY) * POCKET_NX + (x - POCKET_X) / POCKET_DX; - SelectPocket(n); + selectPocket(n); } } } @@ -958,7 +956,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { PostMiniStep(cav - 1); if (mask & L_UP) { - if (cav && Snail->Idle() && Hero->_tracePtr < 0) + if (cav && _snail->idle() && Hero->_tracePtr < 0) _vm->switchCave(cav); if (!_horzLine->_flags._hide) { @@ -970,8 +968,8 @@ void SYSTEM::touch(uint16 mask, int x, int y) { } } else { - if (! Talk && Snail->Idle() && Hero - && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && ! Game) { + if (! Talk && _snail->idle() && Hero + && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_game) { Hero->findWay(XZ(x, y)); } } @@ -983,7 +981,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { void SYSTEM::Tick(void) { if (! Startup) if (-- FunDel == 0) { KillText(); - if (Snail->Idle()) { + if (_snail->idle()) { if (PAIN) HeroCover(9); else if (STARTUP::Core >= CORE_MID) { @@ -1040,7 +1038,7 @@ static void SwitchMusic(void) { if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); else { - SNPOST_(SNSEQ, 122, (Music = false), NULL); + SNPOST_(SNSEQ, 122, (_music = false), NULL); //TODO Change the SNPOST message send to a special way to send function pointer // SNPOST(SNEXEC, -1, 0, (void *)&selectSound); warning("SwitchMusic() - SNPOST"); @@ -1049,12 +1047,12 @@ static void SwitchMusic(void) { if (STARTUP::Core < CORE_HIG) SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL); else { - SNPOST_(SNSEQ, 122, (Music = ! Music), NULL); + SNPOST_(SNSEQ, 122, (_music = !_music), NULL); KeyClick(); } } - if (Music) - LoadMIDI(Now); + if (_music) + LoadMIDI(_now); else KillMIDI(); } @@ -1148,16 +1146,16 @@ static void SaveMapping() { { IoHand cf(progName(".TAB"), UPD); if (!cf._error) { - cf.seek((Now - 1) * sizeof(Cluster::_map)); + cf.seek((_now - 1) * sizeof(Cluster::_map)); cf.write((uint8 *) Cluster::_map, sizeof(Cluster::_map)); } } { IoHand cf(progName(".HXY"), WRI); if (!cf._error) { - HeroXY[Now - 1]._x = Hero->_x; - HeroXY[Now - 1]._y = Hero->_y; - cf.write((uint8 *) HeroXY, sizeof(HeroXY)); + _heroXY[_now - 1]._x = Hero->_x; + _heroXY[_now - 1]._y = Hero->_y; + cf.write((uint8 *) _heroXY, sizeof(_heroXY)); } } } @@ -1265,19 +1263,19 @@ void Sprite::touch(uint16 mask, int x, int y) { } if (_flags._syst) return; // cannot access system sprites - if (Game) if (mask & L_UP) { + if (_game) if (mask & L_UP) { mask &= ~L_UP; mask |= R_UP; } - if ((mask & R_UP) && Snail->Idle()) { + if ((mask & R_UP) && _snail->idle()) { Sprite *ps = (_pocLight->_seqPtr) ? _pocket[PocPtr] : NULL; if (ps) { if (_flags._kept || Hero->distance(this) < MAX_DISTANCE) { if (works(ps)) { - FeedSnail(ps, TAKE); + feedSnail(ps, TAKE); } else OffUse(); - SelectPocket(-1); + selectPocket(-1); } else TooFar(); } else { @@ -1287,8 +1285,8 @@ void Sprite::touch(uint16 mask, int x, int y) { if (Hero->distance(this) < MAX_DISTANCE) { /// if (_flags._port) { - if (FindPocket(NULL) < 0) - PocFul(); + if (findPocket(NULL) < 0) + pocFul(); else { SNPOST(SNREACH, -1, -1, this); SNPOST(SNKEEP, -1, -1, this); @@ -1296,10 +1294,10 @@ void Sprite::touch(uint16 mask, int x, int y) { } } else { if (_takePtr != NO_PTR) { - if (snList(TAKE)[_takePtr].Com == SNNEXT) + if (snList(TAKE)[_takePtr]._com == SNNEXT) OffUse(); else - FeedSnail(this, TAKE); + feedSnail(this, TAKE); } else OffUse(); } @@ -1309,12 +1307,12 @@ void Sprite::touch(uint16 mask, int x, int y) { } } } - if ((mask & L_UP) && Snail->Idle()) { + if ((mask & L_UP) && _snail->idle()) { if (_flags._kept) { int n; for (n = 0; n < POCKET_NX; n++) { if (_pocket[n] == this) { - SelectPocket(n); + selectPocket(n); break; } } @@ -1545,20 +1543,20 @@ void CGEEngine::mainLoop() { if (_isDemo) { // static uint32 tc = 0; - if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ Talk == NULL && Snail->Idle()) { - if (Text->getText(DemoText)) { + if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ Talk == NULL && _snail->idle()) { + if (Text->getText(_demoText)) { SNPOST(SNSOUND, -1, 4, NULL); // drumla - SNPOST(SNINF, -1, DemoText, NULL); + SNPOST(SNINF, -1, _demoText, NULL); SNPOST(SNLABEL, -1, -1, NULL); - if (Text->getText(++ DemoText) == NULL) - DemoText = DEMO_TEXT + 1; + if (Text->getText(++_demoText) == NULL) + _demoText = DEMO_TEXT + 1; } //FIXME: tc = TimerCount; } } Vga->Show(); - Snail_->RunCom(); - Snail->RunCom(); + _snail_->runCom(); + _snail->runCom(); // Game frame delay uint32 millis = g_system->getMillis(); @@ -1585,7 +1583,7 @@ void CGEEngine::loadUser() { loadGame(file); } else { loadScript(progName(INI_EXT)); - Music = true; + _music = true; CFile file = CFile(SVG0NAME, WRI); SaveGame(file); error("Ok [%s]", SVG0NAME); @@ -1620,7 +1618,7 @@ void CGEEngine::runGame() { _pocLight->_time = 1; _pocLight->_z = 120; Vga->ShowQ->Append(_pocLight); - SelectPocket(-1); + selectPocket(-1); // FIXME: Allow ScummVM to handle mouse display // Vga->ShowQ->Append(Mouse); @@ -1632,9 +1630,9 @@ void CGEEngine::runGame() { if ((_sprite = Vga->SpareQ->Locate(121)) != NULL) SNPOST_(SNSEQ, -1, Vga->Mono, _sprite); if ((_sprite = Vga->SpareQ->Locate(122)) != NULL) - _sprite->step(Music); - SNPOST_(SNSEQ, -1, Music, _sprite); - if (! Music) + _sprite->step(_music); + SNPOST_(SNSEQ, -1, _music, _sprite); + if (!_music) KillMIDI(); if (Mini && INI_FILE::exist("MINI.SPR")) { @@ -1654,7 +1652,7 @@ void CGEEngine::runGame() { if (Hero) { ExpandSprite(Hero); - Hero->gotoxy(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y); + Hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); if (INI_FILE::exist("00SHADOW.SPR")) { loadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51); if ((_shadow = _sprite) != NULL) { @@ -1684,9 +1682,9 @@ void CGEEngine::runGame() { Startup = 0; - SNPOST(SNLEVEL, -1, OldLev, &_cavLight); - _cavLight->gotoxy(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, - CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); + SNPOST(SNLEVEL, -1, _oldLev, &_cavLight); + _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, + CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); caveUp(); _keyboard->setClient(Sys); @@ -1718,14 +1716,14 @@ void CGEEngine::movie(const char *ext) { if (INI_FILE::exist(fn)) { loadScript(fn); ExpandSprite(Vga->SpareQ->Locate(999)); - FeedSnail(Vga->ShowQ->Locate(999), TAKE); + feedSnail(Vga->ShowQ->Locate(999), TAKE); // FIXME: Allow ScummVM to handle mouse display //Vga->ShowQ->Append(Mouse); _heart->_enable = true; _keyboard->setClient(Sys); - while (!Snail->Idle() && !_eventManager->_quitFlag) + while (!_snail->idle() && !_eventManager->_quitFlag) mainLoop(); _keyboard->setClient(NULL); @@ -1761,7 +1759,7 @@ bool CGEEngine::showTitle(const char *name) { Vga->Sunset(); Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); - SelectPocket(-1); + selectPocket(-1); Vga->Sunrise(VGA::SysPal); if (STARTUP::Mode < 2 && !STARTUP::SoundOk) { @@ -1770,7 +1768,7 @@ bool CGEEngine::showTitle(const char *name) { Vga->ShowQ->Append(_mouse); _heart->_enable = true; _mouse->On(); - for (selectSound(); !Snail->Idle() || VMENU::Addr;) { + for (selectSound(); !_snail->idle() || VMENU::Addr;) { mainLoop(); if (_eventManager->_quitFlag) return false; @@ -1781,7 +1779,7 @@ bool CGEEngine::showTitle(const char *name) { Vga->ShowQ->Clear(); Vga->CopyPage(0, 2); STARTUP::SoundOk = 2; - if (Music) + if (_music) LoadMIDI(0); } @@ -1868,7 +1866,7 @@ void CGEEngine::cge_main(void) { //Debug( memset((void *) (-K(2)), 0, K(1)); ) //Debug( memset((void *) (-K(4)), 0, K(1)); ) - memset(Barriers, 0xFF, sizeof(Barriers)); + memset(_barriers, 0xFF, sizeof(_barriers)); if (!_mouse->Exist) error("%s", Text->getText(NO_MOUSE_TEXT)); @@ -1882,7 +1880,7 @@ void CGEEngine::cge_main(void) { //srand((uint16) Timer()); Sys = new SYSTEM(this); - if (Music && STARTUP::SoundOk) + if (_music && STARTUP::SoundOk) LoadMIDI(0); if (STARTUP::Mode < 2) movie(LGO_EXT); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 6920f7b2d3..5e3eb6bf1c 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -109,8 +109,8 @@ namespace CGE { #define SYSTIMERATE 6 // 12 Hz #define HEROFUN0 (40 * 12) #define HEROFUN1 ( 2 * 12) -#define PAIN (Flag[0]) -#define FINIS (Flag[3]) +#define PAIN (_flag[0]) +#define FINIS (_flag[3]) class SYSTEM : public Sprite { @@ -190,8 +190,8 @@ extern BMP_PTR MC[3]; extern BMP_PTR PR[2]; extern BMP_PTR SP[3]; extern BMP_PTR LI[5]; -extern SNAIL *Snail; -extern SNAIL *Snail_; +extern Snail *_snail; +extern Snail *_snail_; } // End of namespace CGE diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 8110e1702f..4f5284b69b 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -143,7 +143,7 @@ static CHOICE BlsterDMA[] = { void CGEEngine::selectSound() { int i; - Sound.Close(); + _sound.Close(); if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); inf(Text->getText(STYPE_TEXT)); @@ -201,7 +201,7 @@ static void Select(CHOICE *cho, int hlp) { void CGEEngine::NONE() { SNDDrvInfo.DDEV = DEV_QUIET; SNDDrvInfo.MDEV = DEV_QUIET; - Sound.Open(); + _sound.Open(); } @@ -249,7 +249,7 @@ void CGEEngine::AUTO() { SNDDrvInfo.DDEV = DEV_AUTO; SNDDrvInfo.MDEV = DEV_AUTO; Reset(); - Sound.Open(); + _sound.Open(); } @@ -261,7 +261,7 @@ void CGEEngine::setPortD() { void CGEEngine::setPortM() { SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text); - Sound.Open(); + _sound.Open(); } @@ -276,7 +276,7 @@ void CGEEngine::setDMA() { if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) Select(MIDIPorts, MPORT_TEXT); else - Sound.Open(); + _sound.Open(); } } // End of namespace CGE diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index b285278842..faff3ada57 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -93,7 +93,7 @@ Dac _stdPal[] = {// R G B { 255, 255, 255}, // 255 }; -DRVINFO SNDDrvInfo; +DrvInfo SNDDrvInfo; void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) { warning("STUB: _fqsort"); @@ -311,11 +311,11 @@ void SNDSetVolume() { warning("STUB: SNDSetVolume"); } -void SNDDigiStart(SMPINFO *PSmpInfo) { +void SNDDigiStart(SmpInfo *PSmpInfo) { warning("STUB: SNDDigitStart"); } -void SNDDigiStop(SMPINFO *PSmpInfo) { +void SNDDigiStop(SmpInfo *PSmpInfo) { warning("STUB: SNDDigiStop"); } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 4bf6f72489..fbde5bd846 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -46,14 +46,13 @@ static void _disable() { warning("STUB: _disable"); } -int MaxCave = 0; +int _maxCave = 0; -SCB Scb = { NULL, 0, NULL }; -bool Flag[4]; -bool Dark = false; -bool Game = false; -int Now = 1; -int Lev = -1; +bool _flag[4]; +bool _dark = false; +bool _game = false; +int _now = 1; +int _lev = -1; extern Sprite *_pocLight; @@ -86,7 +85,7 @@ static void SNGame(Sprite *spr, int num) { dup[2] = Vga->ShowQ->Locate(16004); // pani } - if (Game) { // continue game + if (_game) { // continue game int i = new_random(3), hand = (dup[0]->_shpCnt == 6); Stage++; if (hand && Stage > DRESSED) @@ -131,7 +130,7 @@ static void SNGame(Sprite *spr, int num) { SNPOST(SNSEQ, -1, 0, dup[2]); // odstaw J† SNPOST(SNSETXY, -1, 182 + SCR_WID * 62, dup[2]); SNPOST(SNSETZ, -1, 9, dup[2]); - Game = 0; + _game = 0; return; } else { SNPOST(SNSEQ, -1, 2, dup[0]); // no @@ -152,9 +151,9 @@ static void SNGame(Sprite *spr, int num) { SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask SNPOST(SNWAIT, 16101, -1, NULL); // stoi SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS - if (! Game) { + if (!_game) { SNPOST(SNSAY, buref, 16008, NULL); // zgadnij! - Game = true; + _game = true; } #undef STEPS #undef DRESSED @@ -172,9 +171,9 @@ static void SNGame(Sprite *spr, int num) { k3 = Vga->ShowQ->Locate(20703); } - if (! Game) { // init + if (!_game) { // init SNPOST(SNGAME, 20002, 2, NULL); - Game = true; + _game = true; } else { // cont k1->step(new_random(6)); k2->step(new_random(6)); @@ -203,7 +202,7 @@ static void SNGame(Sprite *spr, int num) { SNPOST(SNSEND, 20010, 20, NULL); // papier SNPOST(SNSOUND, 20010, 20003, NULL); // papier! SNPOST(SNSAY, 20001, 20005, NULL); - Game = false; + _game = false; return; } else k3->step(new_random(5)); @@ -285,7 +284,7 @@ void ContractSprite(Sprite *spr) { Vga->SpareQ->Append(Vga->ShowQ->Remove(spr)); } -int FindPocket(Sprite *spr) { +int findPocket(Sprite *spr) { for (int i = 0; i < POCKET_NX; i++) if (_pocket[i] == spr) return i; @@ -293,10 +292,10 @@ int FindPocket(Sprite *spr) { } -void SelectPocket(int n) { +void selectPocket(int n) { if (n < 0 || (_pocLight->_seqPtr && PocPtr == n)) { _pocLight->step(0); - n = FindPocket(NULL); + n = findPocket(NULL); if (n >= 0) PocPtr = n; } else { @@ -309,7 +308,7 @@ void SelectPocket(int n) { } -void PocFul(void) { +void pocFul() { Hero->park(); SNPOST(SNWAIT, -1, -1, Hero); SNPOST(SNSEQ, -1, POC_FUL, Hero); @@ -333,38 +332,38 @@ void SNGhost(Bitmap *bmp) { } -void FeedSnail(Sprite *spr, SNLIST snq) { +void feedSnail(Sprite *spr, SNLIST snq) { if (spr) if (spr->active()) { uint8 ptr = (snq == TAKE) ? spr->_takePtr : spr->_nearPtr; if (ptr != NO_PTR) { - SNAIL::COM *comtab = spr->snList(snq); - SNAIL::COM *c = comtab + ptr; - - if (FindPocket(NULL) < 0) { // no empty pockets? - SNAIL::COM *p; - for (p = c; p->Com != SNNEXT; p++) { // find KEEP command - if (p->Com == SNKEEP) { - PocFul(); + Snail::Com *comtab = spr->snList(snq); + Snail::Com *c = comtab + ptr; + + if (findPocket(NULL) < 0) { // no empty pockets? + Snail::Com *p; + for (p = c; p->_com != SNNEXT; p++) { // find KEEP command + if (p->_com == SNKEEP) { + pocFul(); return; } - if (p->Ptr) + if (p->_ptr) break; } } while (true) { - if (c->Com == SNTALK) { - if ((Snail->TalkEnable = (c->Val != 0)) == false) + if (c->_com == SNTALK) { + if ((_snail->_talkEnable = (c->_val != 0)) == false) KillText(); } - if (c->Com == SNNEXT) { - Sprite *s = (c->Ref < 0) ? spr : Locate(c->Ref); + if (c->_com == SNNEXT) { + Sprite *s = (c->_ref < 0) ? spr : Locate(c->_ref); if (s) { uint8 *idx = (snq == TAKE) ? &s->_takePtr : &s->_nearPtr; if (*idx != NO_PTR) { int v; - switch (c->Val) { + switch (c->_val) { case -1 : v = c - comtab + 1; break; @@ -375,7 +374,7 @@ void FeedSnail(Sprite *spr, SNLIST snq) { v = -1; break; default : - v = c->Val; + v = c->_val; break; } if (v >= 0) @@ -385,18 +384,18 @@ void FeedSnail(Sprite *spr, SNLIST snq) { if (s == spr) break; } - if (c->Com == SNIF) { - Sprite *s = (c->Ref < 0) ? spr : Locate(c->Ref); + if (c->_com == SNIF) { + Sprite *s = (c->_ref < 0) ? spr : Locate(c->_ref); if (s) { // sprite extsts if (! s->seqTest(-1)) - c = comtab + c->Val; // not parked + c = comtab + c->_val; // not parked else ++c; } else ++c; } else { - SNPOST(c->Com, c->Ref, c->Val, spr); - if (c->Ptr) + SNPOST(c->_com, c->_ref, c->_val, spr); + if (c->_ptr) break; else ++c; @@ -407,7 +406,7 @@ void FeedSnail(Sprite *spr, SNLIST snq) { } -const char *SNAIL::ComTxt[] = { +const char *Snail::_comTxt[] = { "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", "SAY", "INF", "TIME", "CAVE", "KILL", "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", @@ -422,28 +421,28 @@ const char *SNAIL::ComTxt[] = { }; -SNAIL::SNAIL(CGEEngine *vm, bool turbo) - : Turbo(turbo), Busy(false), TextDelay(false), - _timerExpiry(0), TalkEnable(true), - Head(0), Tail(0), SNList(farnew(COM, 256)), _vm(vm) { +Snail::Snail(CGEEngine *vm, bool turbo) + : _turbo(turbo), _busy(false), _textDelay(false), + _timerExpiry(0), _talkEnable(true), + _head(0), _tail(0), _snList(farnew(Com, 256)), _vm(vm) { } -SNAIL::~SNAIL(void) { - if (SNList) - free(SNList); +Snail::~Snail() { + if (_snList) + free(_snList); } -void SNAIL::AddCom(SNCOM com, int ref, int val, void *ptr) { +void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { _disable(); - COM *snc = &SNList[Head++]; - snc->Com = com; - snc->Ref = ref; - snc->Val = val; - snc->Ptr = ptr; + Com *snc = &_snList[_head++]; + snc->_com = com; + snc->_ref = ref; + snc->_val = val; + snc->_ptr = ptr; if (com == SNCLEAR) { - Tail = Head; + _tail = _head; KillText(); _timerExpiry = 0; } @@ -451,22 +450,22 @@ void SNAIL::AddCom(SNCOM com, int ref, int val, void *ptr) { } -void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { - COM *snc; +void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { + Com *snc; _disable(); - if (Busy) { - SNList[(Tail - 1) & 0xFF] = SNList[Tail]; - snc = &SNList[Tail]; + if (_busy) { + _snList[(_tail - 1) & 0xFF] = _snList[_tail]; + snc = &_snList[_tail]; } else - snc = &SNList[(Tail - 1) & 0xFF]; - --Tail; - snc->Com = com; - snc->Ref = ref; - snc->Val = val; - snc->Ptr = ptr; + snc = &_snList[(_tail - 1) & 0xFF]; + _tail--; + snc->_com = com; + snc->_ref = ref; + snc->_val = val; + snc->_ptr = ptr; if (com == SNCLEAR) { - Tail = Head; + _tail = _head; KillText(); _timerExpiry = 0; } @@ -559,13 +558,13 @@ void SNRSeq(Sprite *spr, int val) { void SNSend(Sprite *spr, int val) { if (spr) { int was = spr->_cave; - bool was1 = (was == 0 || was == Now); - bool val1 = (val == 0 || val == Now); + bool was1 = (was == 0 || was == _now); + bool val1 = (val == 0 || val == _now); spr->_cave = val; if (val1 != was1) { if (was1) { if (spr->_flags._kept) { - int n = FindPocket(spr); + int n = findPocket(spr); if (n >= 0) _pocket[n] = NULL; } @@ -591,15 +590,15 @@ void SNSwap(Sprite *spr, int xref) { if (spr && xspr) { int was = spr->_cave; int xwas = xspr->_cave; - bool was1 = (was == 0 || was == Now); - bool xwas1 = (xwas == 0 || xwas == Now); + bool was1 = (was == 0 || was == _now); + bool xwas1 = (xwas == 0 || xwas == _now); Swap(spr->_cave, xspr->_cave); Swap(spr->_x, xspr->_x); Swap(spr->_y, xspr->_y); Swap(spr->_z, xspr->_z); if (spr->_flags._kept) { - int n = FindPocket(spr); + int n = findPocket(spr); if (n >= 0) _pocket[n] = xspr; xspr->_flags._kept = true; @@ -633,7 +632,7 @@ void SNCover(Sprite *spr, int xref) { Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr->_prev), xspr); spr->_flags._shad = false; } - FeedSnail(xspr, NEAR); + feedSnail(xspr, NEAR); } } @@ -656,12 +655,12 @@ void SNUncover(Sprite *spr, Sprite *xspr) { void SNSetX0(int cav, int x0) { - HeroXY[cav - 1]._x = x0; + _heroXY[cav - 1]._x = x0; } void SNSetY0(int cav, int y0) { - HeroXY[cav - 1]._y = y0; + _heroXY[cav - 1]._y = y0; } @@ -740,7 +739,7 @@ void SNPort(Sprite *spr, int port) { void SNKill(Sprite *spr) { if (spr) { if (spr->_flags._kept) { - int n = FindPocket(spr); + int n = findPocket(spr); if (n >= 0) _pocket[n] = NULL; } @@ -765,15 +764,15 @@ void SNKill(Sprite *spr) { static void SNSound(Sprite *spr, int wav, int cnt) { if (SNDDrvInfo.DDEV) { if (wav == -1) - Sound.Stop(); + _sound.Stop(); else - Sound.Play(Fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (SCR_WID / 16)) : 8, cnt); + _sound.Play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (SCR_WID / 16)) : 8, cnt); } } void SNKeep(Sprite *spr, int stp) { - SelectPocket(-1); + selectPocket(-1); if (spr && ! spr->_flags._kept && _pocket[PocPtr] == NULL) { SNSound(spr, 3, 1); _pocket[PocPtr] = spr; @@ -784,22 +783,22 @@ void SNKeep(Sprite *spr, int stp) { if (stp >= 0) spr->step(stp); } - SelectPocket(-1); + selectPocket(-1); } void SNGive(Sprite *spr, int stp) { if (spr) { - int p = FindPocket(spr); + int p = findPocket(spr); if (p >= 0) { _pocket[p] = NULL; - spr->_cave = Now; + spr->_cave = _now; spr->_flags._kept = false; if (stp >= 0) spr->step(stp); } } - SelectPocket(-1); + selectPocket(-1); } @@ -818,22 +817,22 @@ static void SNLevel(Sprite *spr, int lev) { #else static int maxcav[] = { 1, 8, 16, 23, 24 }; #endif - while (Lev < lev) { - ++Lev; - spr = Vga->SpareQ->Locate(100 + Lev); + while (_lev < lev) { + _lev++; + spr = Vga->SpareQ->Locate(100 + _lev); if (spr) { spr->backShow(true); spr->_cave = 0; } } - MaxCave = maxcav[Lev]; + _maxCave = maxcav[_lev]; if (spr) spr->_flags._hide = false; } static void SNFlag(int fn, bool v) { - Flag[fn] = v; + _flag[fn] = v; } @@ -861,7 +860,7 @@ void SNFlash(bool on) { } } else Vga->SetColors(VGA::SysPal, 64); - Dark = false; + _dark = false; } @@ -870,12 +869,12 @@ static void SNLight(bool in) { Vga->Sunrise(VGA::SysPal); else Vga->Sunset(); - Dark = ! in; + _dark = ! in; } static void SNBarrier(int cav, int bar, bool horz) { - ((uint8 *)(Barriers + ((cav > 0) ? cav : Now)))[horz] = bar; + ((uint8 *)(_barriers + ((cav > 0) ? cav : _now)))[horz] = bar; } @@ -903,15 +902,15 @@ static void SNMouse(bool on) { } -void SNAIL::RunCom(void) { +void Snail::runCom() { static int count = 1; - if (! Busy) { - Busy = true; - uint8 tmphea = Head; - while (Tail != tmphea) { - COM *snc = &SNList[Tail]; + if (!_busy) { + _busy = true; + uint8 tmphea = _head; + while (_tail != tmphea) { + Com *snc = &_snList[_tail]; - if (! Turbo) { // only for the slower one + if (!_turbo) { // only for the slower one if (_timerExpiry) { // Delay in progress if (_timerExpiry > g_system->getMillis()) @@ -921,150 +920,148 @@ void SNAIL::RunCom(void) { // Delay is finished _timerExpiry = 0; } else { - if (TextDelay) { + if (_textDelay) { KillText(); - TextDelay = false; + _textDelay = false; } } - if (Talk && snc->Com != SNPAUSE) + if (Talk && snc->_com != SNPAUSE) break; } - Sprite *sprel = ((snc->Ref >= 0) ? Locate(snc->Ref) : ((Sprite *) snc->Ptr)); - switch (snc->Com) { + Sprite *sprel = ((snc->_ref >= 0) ? Locate(snc->_ref) : ((Sprite *) snc->_ptr)); + switch (snc->_com) { case SNLABEL : break; case SNPAUSE : - _timerExpiry = g_system->getMillis() + snc->Val * SNAIL_FRAME_DELAY; + _timerExpiry = g_system->getMillis() + snc->_val * SNAIL_FRAME_DELAY; if (Talk) - TextDelay = true; + _textDelay = true; break; case SNWAIT : if (sprel) { - if (sprel->seqTest(snc->Val) && - (snc->Val >= 0 || sprel != Hero || Hero->_tracePtr < 0)) { + if (sprel->seqTest(snc->_val) && + (snc->_val >= 0 || sprel != Hero || Hero->_tracePtr < 0)) { _timerExpiry = g_system->getMillis() + sprel->_time * SNAIL_FRAME_DELAY; } else goto xit; } break; case SNLEVEL : - SNLevel(sprel, snc->Val); + SNLevel(sprel, snc->_val); break; case SNHIDE : - SNHide(sprel, snc->Val); + SNHide(sprel, snc->_val); break; case SNSAY : - if (sprel && TalkEnable) { + if (sprel && _talkEnable) { if (sprel == Hero && sprel->seqTest(-1)) sprel->step(HTALK); - Text->Say(Text->getText(snc->Val), sprel); + Text->Say(Text->getText(snc->_val), sprel); Sys->FunDel = HEROFUN0; } break; case SNINF : - if (TalkEnable) { - _vm->inf(Text->getText(snc->Val)); + if (_talkEnable) { + _vm->inf(Text->getText(snc->_val)); Sys->FunDel = HEROFUN0; } break; case SNTIME : - if (sprel && TalkEnable) { + if (sprel && _talkEnable) { if (sprel == Hero && sprel->seqTest(-1)) sprel->step(HTALK); SayTime(sprel); } break; case SNCAVE : - // SwitchCave(snc->Val); - warning("Problematic call of SwitchCave in SNAIL::RunCom"); + // SwitchCave(snc->_val); + warning("Problematic call of SwitchCave in SNAIL::runCom"); break; case SNKILL : SNKill(sprel); break; case SNSEQ : - SNSeq(sprel, snc->Val); + SNSeq(sprel, snc->_val); break; case SNRSEQ : - SNRSeq(sprel, snc->Val); + SNRSeq(sprel, snc->_val); break; case SNSEND : - SNSend(sprel, snc->Val); + SNSend(sprel, snc->_val); break; case SNSWAP : - SNSwap(sprel, snc->Val); + SNSwap(sprel, snc->_val); break; case SNCOVER : - SNCover(sprel, snc->Val); + SNCover(sprel, snc->_val); break; case SNUNCOVER : - SNUncover(sprel, (snc->Val >= 0) ? Locate(snc->Val) : ((Sprite *) snc->Ptr)); + SNUncover(sprel, (snc->_val >= 0) ? Locate(snc->_val) : ((Sprite *) snc->_ptr)); break; case SNKEEP : - SNKeep(sprel, snc->Val); + SNKeep(sprel, snc->_val); break; case SNGIVE : - SNGive(sprel, snc->Val); + SNGive(sprel, snc->_val); break; case SNGAME : - SNGame(sprel, snc->Val); + SNGame(sprel, snc->_val); break; case SNSETX0 : - SNSetX0(snc->Ref, snc->Val); + SNSetX0(snc->_ref, snc->_val); break; case SNSETY0 : - SNSetY0(snc->Ref, snc->Val); + SNSetY0(snc->_ref, snc->_val); break; case SNSETXY : - SNSetXY(sprel, snc->Val); + SNSetXY(sprel, snc->_val); break; case SNRELX : - SNRelX(sprel, snc->Val); + SNRelX(sprel, snc->_val); break; case SNRELY : - SNRelY(sprel, snc->Val); + SNRelY(sprel, snc->_val); break; case SNRELZ : - SNRelZ(sprel, snc->Val); + SNRelZ(sprel, snc->_val); break; case SNSETX : - SNSetX(sprel, snc->Val); + SNSetX(sprel, snc->_val); break; case SNSETY : - SNSetY(sprel, snc->Val); + SNSetY(sprel, snc->_val); break; case SNSETZ : - SNSetZ(sprel, snc->Val); + SNSetZ(sprel, snc->_val); break; case SNSLAVE : - SNSlave(sprel, snc->Val); + SNSlave(sprel, snc->_val); break; case SNTRANS : - SNTrans(sprel, snc->Val); + SNTrans(sprel, snc->_val); break; case SNPORT : - SNPort(sprel, snc->Val); + SNPort(sprel, snc->_val); break; case SNNEXT : - break; case SNIF : - break; case SNTALK : break; case SNMOUSE : - SNMouse(snc->Val != 0); + SNMouse(snc->_val != 0); break; case SNNNEXT : - SNNNext(sprel, snc->Val); + SNNNext(sprel, snc->_val); break; case SNTNEXT : - SNTNext(sprel, snc->Val); + SNTNext(sprel, snc->_val); break; case SNRNNEXT : - SNRNNext(sprel, snc->Val); + SNRNNext(sprel, snc->_val); break; case SNRTNEXT : - SNRTNext(sprel, snc->Val); + SNRTNext(sprel, snc->_val); break; case SNRMNEAR : SNRmNear(sprel); @@ -1073,43 +1070,44 @@ void SNAIL::RunCom(void) { SNRmTake(sprel); break; case SNFLAG : - SNFlag(snc->Ref & 3, snc->Val != 0); + SNFlag(snc->_ref & 3, snc->_val != 0); break; case SNSETREF : - SNSetRef(sprel, snc->Val); + SNSetRef(sprel, snc->_val); break; case SNBACKPT : - SNBackPt(sprel, snc->Val); + SNBackPt(sprel, snc->_val); break; case SNFLASH : - SNFlash(snc->Val != 0); + SNFlash(snc->_val != 0); break; case SNLIGHT : - SNLight(snc->Val != 0); + SNLight(snc->_val != 0); break; case SNSETHB : - SNBarrier(snc->Ref, snc->Val, true); + SNBarrier(snc->_ref, snc->_val, true); break; case SNSETVB : - SNBarrier(snc->Ref, snc->Val, false); + SNBarrier(snc->_ref, snc->_val, false); break; case SNWALK : - SNWalk(sprel, snc->Ref, snc->Val); + SNWalk(sprel, snc->_ref, snc->_val); break; case SNREACH : - SNReach(sprel, snc->Val); + SNReach(sprel, snc->_val); break; case SNSOUND : - SNSound(sprel, snc->Val, count); + SNSound(sprel, snc->_val, count); count = 1; break; case SNCOUNT : - count = snc->Val; + count = snc->_val; break; case SNEXEC : // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST - // ((void(*)(int)) (snc->Ptr))(snc->Val); break; + // ((void(*)(int)) (snc->_ptr))(snc->_val); warning("STUB: SNEXEC code"); + break; case SNSTEP : sprel->step(); break; @@ -1117,24 +1115,24 @@ void SNAIL::RunCom(void) { SNZTrim(sprel); break; case SNGHOST : - SNGhost((Bitmap *) snc->Ptr); + SNGhost((Bitmap *) snc->_ptr); break; default : - warning("Unhandled snc->Com in SNMouse(bool)"); + warning("Unhandled snc->_com in SNMouse(bool)"); break; } - Tail++; - if (!Turbo) + _tail++; + if (!_turbo) break; } xit: - Busy = false; + _busy = false; } } -bool SNAIL::Idle(void) { - return (Head == Tail); +bool Snail::idle() { + return (_head == _tail); } } // End of namespace CGE diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 54a24ac1a9..2e06149526 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -43,22 +43,16 @@ namespace CGE { #define POCKET_SX 8 #define POCKET_SY 3 -#define SNINSERT(c,r,v,p) Snail->InsCom(c,r,v,p) -#define SNPOST(c,r,v,p) Snail->AddCom(c,r,v,p) -#define SNPOST_(c,r,v,p) Snail_->AddCom(c,r,v,p) +#define SNINSERT(c, r, v, p) _snail->insCom(c, r, v, p) +#define SNPOST(c, r, v, p) _snail->addCom(c, r, v, p) +#define SNPOST_(c, r, v, p) _snail_->addCom(c, r, v, p) #define SNAIL_FRAME_RATE 62 #define SNAIL_FRAME_DELAY (1000 / SNAIL_FRAME_RATE) -typedef struct { - uint8 Horz, Vert; -} BAR; - - -struct SCB { - uint8 *Ptr; - uint16 Siz; - SCB *Nxt; +struct Bar { + uint8 _horz; + uint8 _vert; }; @@ -79,49 +73,49 @@ enum SNCOM { enum SNLIST { NEAR, TAKE }; -class SNAIL { +class Snail { public: - struct COM { - SNCOM Com; - int Ref; - int Val; - void *Ptr; - } *SNList; - uint8 Head, Tail; - bool Turbo, Busy, TextDelay; + struct Com { + SNCOM _com; + int _ref; + int _val; + void *_ptr; + } *_snList; + uint8 _head; + uint8 _tail; + bool _turbo; + bool _busy; + bool _textDelay; uint32 _timerExpiry; - static const char *ComTxt[]; - bool TalkEnable; - SNAIL(CGEEngine *vm, bool turbo = false); - ~SNAIL(); - void RunCom(void); - void AddCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL); - void InsCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL); - bool Idle(void); + static const char *_comTxt[]; + bool _talkEnable; + Snail(CGEEngine *vm, bool turbo); + ~Snail(); + void runCom(); + void addCom(SNCOM com, int ref, int val, void *ptr); + void insCom(SNCOM com, int ref, int val, void *ptr); + bool idle(); private: CGEEngine *_vm; }; -void SelectPocket(int n); -void PocFul(void); +void selectPocket(int n); +void pocFul(); -extern SCB Scb; -extern bool Flag[4]; -extern bool Game; -extern bool Dark; -//extern SNAIL *Snail; -//extern SNAIL *Snail_; -extern int Now; -extern int Lev; -extern int MaxCave; -extern int PocPtr; -extern BAR Barriers[]; -extern struct HXY { +extern bool _flag[4]; +extern bool _game; +extern bool _dark; +extern int _now; +extern int _lev; +extern int _maxCave; +extern int _pocPtr; +extern Bar _barriers[]; +extern struct Hxy { int _x; int _y; -} HeroXY[]; +} _heroXY[]; } // End of namespace CGE diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 4cdac383be..78d1434b40 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -56,7 +56,7 @@ enum DEV_TYPE { DEV_AUTO = -1, // auto-detect mode #define SERR_BADDDEV 128 // bad device // driver info -struct DRVINFO { +struct DrvInfo { DEV_TYPE DDEV; // digi device DEV_TYPE MDEV; // midi device uint16 DBASE; // digi base port @@ -78,7 +78,7 @@ struct DRVINFO { }; // sample info -struct SMPINFO { +struct SmpInfo { uint8 *saddr; // address uint16 slen; // length uint16 span; // left/right pan (0-15) @@ -89,7 +89,7 @@ struct SMPINFO { // * Data * // ****************************************************** // driver info -extern DRVINFO SNDDrvInfo; +extern DrvInfo SNDDrvInfo; // midi player flag (1 means we are playing) extern uint16 MIDIPlayFlag; @@ -110,10 +110,10 @@ void SNDDone(); void SNDSetVolume(); // Start Digi -void SNDDigiStart(SMPINFO *PSmpInfo); +void SNDDigiStart(SmpInfo *PSmpInfo); // Stop Digi -void SNDDigiStop(SMPINFO *PSmpInfo); +void SNDDigiStop(SmpInfo *PSmpInfo); // Start MIDI File void SNDMIDIStart(uint8 *MIDFile); diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 75adf3868a..60af9f7016 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -35,9 +35,9 @@ namespace CGE { -bool Music = true; -FX Fx = 16; // must precede SOUND!! -SOUND Sound; +bool _music = true; +FX _fx = 16; // must precede SOUND!! +SOUND _sound; SOUND::SOUND(void) { @@ -59,7 +59,7 @@ void SOUND::Close(void) { void SOUND::Open(void) { SNDInit(); - Play(Fx[30000], 8); + Play(_fx[30000], 8); } diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 743fba0bb6..55dd1615cc 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -39,7 +39,7 @@ namespace CGE { class SOUND { public: - SMPINFO smpinf; + SmpInfo smpinf; SOUND(void); ~SOUND(void); void Open(void); @@ -68,13 +68,13 @@ public: }; -extern bool Music; -extern SOUND Sound; -extern FX Fx; +extern bool _music; +extern SOUND _sound; +extern FX _fx; void LoadMIDI(int ref); -void KillMIDI(void); +void KillMIDI(); } // End of namespace CGE diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 83c89892ca..484d7118ef 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -251,7 +251,7 @@ extern "C" void TimerProc() { } for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { if (spr->Time) { - if (!spr->Flags.Hide) { + if (!spr->_flags.Hide) { if (-- spr->Time == 0) spr->Tick(); } @@ -326,7 +326,7 @@ void Engine_::newTimer(...) { for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { if (spr->Time) { - if (!spr->Flags.Hide) { + if (!spr->_flags.Hide) { if (--spr->Time == 0) spr->Tick(); } @@ -427,11 +427,11 @@ void Sprite::moveShapes(uint8 *buf) { bool Sprite::works(Sprite *spr) { if (spr) if (spr->_ext) { - SNAIL::COM *c = spr->_ext->_take; + Snail::Com *c = spr->_ext->_take; if (c != NULL) { c += spr->_takePtr; - if (c->Ref == _ref) - if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) + if (c->_ref == _ref) + if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _now)) return true; } } @@ -460,7 +460,7 @@ bool Sprite::seqTest(int n) { } -SNAIL::COM *Sprite::snList(SNLIST type) { +Snail::Com *Sprite::snList(SNLIST type) { register SprExt *e = _ext; if (e) return (type == NEAR) ? e->_near : e->_take; @@ -493,7 +493,7 @@ Sprite *Sprite::expand() { if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; - BMP_PTR *shplist = new BMP_PTR [_shpCnt + 1]; + BMP_PTR *shplist = new BMP_PTR[_shpCnt + 1]; Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -502,8 +502,8 @@ Sprite *Sprite::expand() { maxnow = 0, maxnxt = 0; - SNAIL::COM *nea = NULL; - SNAIL::COM *tak = NULL; + Snail::Com *nea = NULL; + Snail::Com *tak = NULL; mergeExt(fname, _file, SPR_EXT); if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); @@ -552,32 +552,32 @@ Sprite *Sprite::expand() { } case 3 : { // Near if (_nearPtr != NO_PTR) { - nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); + nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); if (nea == NULL) error("No core [%s]", fname); else { - SNAIL::COM *c = &nea[neacnt++]; - if ((c->Com = (SNCOM) takeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + Snail::Com *c = &nea[neacnt++]; + if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", (const char*)NumStr("Bad NEAR in ######", lcnt), (const char*)fname); - c->Ref = atoi(strtok(NULL, " \t,;/")); - c->Val = atoi(strtok(NULL, " \t,;/")); - c->Ptr = NULL; + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; } } } break; case 4 : { // Take if (_takePtr != NO_PTR) { - tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); + tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); if (tak == NULL) error("No core [%s]", fname); else { - SNAIL::COM *c = &tak[takcnt++]; - if ((c->Com = (SNCOM) takeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + Snail::Com *c = &tak[takcnt++]; + if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), (const char *)fname); - c->Ref = atoi(strtok(NULL, " \t,;/")); - c->Val = atoi(strtok(NULL, " \t,;/")); - c->Ptr = NULL; + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; } } break; @@ -601,11 +601,11 @@ Sprite *Sprite::expand() { setShapeList(shplist); //enable(); // enable interupt if (nea) - nea[neacnt - 1].Ptr = _ext->_near = nea; + nea[neacnt - 1]._ptr = _ext->_near = nea; else _nearPtr = NO_PTR; if (tak) - tak[takcnt - 1].Ptr = _ext->_take = tak; + tak[takcnt - 1]._ptr = _ext->_take = tak; else _takePtr = NO_PTR; } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 152f608c56..8bc24bc9fb 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -154,7 +154,7 @@ public: BMP_PTR *_shpList; Seq *_seq; char *_name; - SNAIL::COM *_near, *_take; + Snail::Com *_near, *_take; SprExt() : _x0(0), _y0(0), _x1(0), _y1(0), @@ -229,7 +229,7 @@ public: void killXlat(); void step(int nr = -1); Seq *setSeq(Seq *seq); - SNAIL::COM *snList(SNLIST type); + Snail::Com *snList(SNLIST type); virtual void touch(uint16 mask, int x, int y); virtual void tick(); private: -- cgit v1.2.3 From ada4556b9ae3b7d94ccac8ecec2ed31ba959ad55 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sat, 2 Jul 2011 20:25:39 +0200 Subject: CGE: Simplify error() calls This also silences a few GCC warnings. --- engines/cge/cge_main.cpp | 6 +++--- engines/cge/vga13h.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 22316d79b1..31a71cc16c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1357,7 +1357,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int continue; if ((i = takeEnum(Comd, strtok(line, " =\t"))) < 0) - error("%s [%s]", NumStr("Bad line ######", lcnt), (const char *)fname); + error("Bad line %d [%s]", lcnt, fname); switch (i) { @@ -1365,7 +1365,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int break; case 1 : // Type if ((type = takeEnum(Type, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad line ######", lcnt), (const char *)fname); + error("Bad line %d [%s]", lcnt, fname); break; case 2 : // Phase ++ shpcnt; @@ -1533,7 +1533,7 @@ void CGEEngine::loadScript(const char *fname) { _sprite->_flags._back = true; } if (! ok) - error("%s [%s]", NumStr("Bad INI line ######", lcnt), fname); + error("Bad INI line %d [%s]", lcnt, fname); } #define GAME_FRAME_DELAY (1000 / 50) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 484d7118ef..41d4b79469 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -558,7 +558,7 @@ Sprite *Sprite::expand() { else { Snail::Com *c = &nea[neacnt++]; if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", (const char*)NumStr("Bad NEAR in ######", lcnt), (const char*)fname); + error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); c->_ptr = NULL; @@ -574,7 +574,7 @@ Sprite *Sprite::expand() { else { Snail::Com *c = &tak[takcnt++]; if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), (const char *)fname); + error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); c->_ptr = NULL; -- cgit v1.2.3 From 5f64f3ff4743b91559756a319c4a41ab36851ac1 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sat, 2 Jul 2011 20:28:11 +0200 Subject: CGE: Removed unused NumStr() function. It was used, until my previous commit. :-) --- engines/cge/vga13h.cpp | 8 -------- engines/cge/vga13h.h | 1 - 2 files changed, 9 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 41d4b79469..a6275a3929 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -69,14 +69,6 @@ Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; extern "C" void SNDMIDIPlay(void); -char *NumStr(char *str, int num) { - char *p = strchr(str, '#'); - if (p) - wtom(num, p, 10, 5); - return str; -} - - /* static void Video() { static uint16 SP_S; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 8bc24bc9fb..b14edb9ba9 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -334,7 +334,6 @@ uint8 Closest(CBLK *pal, CBLK x) { #undef f } -char *NumStr(char *str, int num); //static void Video (void); uint16 *SaveScreen(void); void RestoreScreen(uint16 * &sav); -- cgit v1.2.3 From ac0caf757950b960cba058800fa42eebc7becbd8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 11:43:59 +1000 Subject: CGE: Implemented BITMAP::Hide method --- engines/cge/vga13h.cpp | 67 ++++---------------------------------------------- 1 file changed, 5 insertions(+), 62 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index a6275a3929..43de8dc9b7 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1319,69 +1319,12 @@ void Bitmap::show(int x, int y) { void Bitmap::hide(int x, int y) { - /* - uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); - HideDesc *b = B; - uint16 extra = ((x & 3) != 0); - uint16 h = H; - - // asm push bx - asm push si - asm push ds - - asm cld - asm les di,scr - asm mov si,di - asm add si,d // take bytes from background page - asm lds bx,b - - asm mov dx,VGAGRA_ - asm mov al,0x05 // R/W mode - asm out dx,al - asm inc dx - asm in al,dx - asm and al,0xF4 - asm push ax - asm push dx - asm or al,0x01 - asm out dx,al - - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // enable all planes - asm out dx,ax + for (int yp = y; yp < y + _h; ++yp) { + const byte *srcP = (const byte *)VGA::Page[2]->getBasePtr(x, yp); + byte *destP = (byte *)VGA::Page[1]->getBasePtr(x, yp); - asm mov dx,ds // save DS - - row: - // skip block - asm mov cx,[bx] - asm add si,cx - asm add di,cx - asm mov cx,[bx+2] - asm add bx,4 - asm add cx,extra - - asm push es - asm pop ds // set DS to video seg - asm rep movsb // move bytes fast - asm sub si,extra - asm sub di,extra - asm mov ds,dx // restore DS - - asm dec h - asm jnz row - - asm pop dx - asm pop ax - asm out dx,al // end of copy mode - - - asm pop ds - asm pop si - // asm pop bx - */ - warning("STUB: Bitmap::hide"); + Common::copy(srcP, srcP + _w, destP); + } } } // End of namespace CGE -- cgit v1.2.3 From bf6a5256fe325816626156703b389273e10f1ae5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 12:05:58 +1000 Subject: CGE: Removed code for boot sector based copy protection check --- engines/cge/boot.h | 75 ------------------------------------------------ engines/cge/cge_main.cpp | 38 ++---------------------- engines/cge/general.cpp | 19 ------------ engines/cge/general.h | 2 -- engines/cge/ident.h | 42 --------------------------- engines/cge/startup.cpp | 3 +- 6 files changed, 5 insertions(+), 174 deletions(-) delete mode 100644 engines/cge/boot.h delete mode 100644 engines/cge/ident.h diff --git a/engines/cge/boot.h b/engines/cge/boot.h deleted file mode 100644 index 5c03a626d8..0000000000 --- a/engines/cge/boot.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_BOOT__ -#define __CGE_BOOT__ - -#include "cge/jbw.h" - -namespace CGE { - -#define BOOTSECT_SIZ 512 -#define BOOTHEAD_SIZ 62 -#define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ -#define FreeBoot(b) free(b) - -struct Boot { - uint8 _jmp[3]; // NEAR jump machine code - char _idOEM[8]; // OEM name and version - uint16 _sectSize; // bytes per sector - uint8 _clustSize; // sectors per cluster - uint16 _resSecs; // sectors before 1st FAT - uint8 _fatCnt; // number of FATs - uint16 _rootSize; // root directory entries - uint16 _totSecs; // total sectors on disk - uint8 _media; // media descriptor byte - uint16 _fatSize; // sectors per FAT - uint16 _trkSecs; // sectors per track - uint16 _headCnt; // number of sufraces - uint16 _hidnSecs; // special hidden sectors - uint16 __; // (unknown: reserved?) - uint32 _lTotSecs; // total number of sectors - uint16 _driveNum; // physical drive number - uint8 _xSign; // extended boot signature - uint32 _serial; // volume serial number - char _label[11]; // volume label - char _fileSysID[8]; // file system ID - char _code[BOOTCODE_SIZ - 8]; // 8 = length of following - uint32 _secret; // long secret number - uint8 _bootCheck; // boot sector checksum - uint8 _bootFlags; // secret flags - uint16 _bootSig; // boot signature 0xAA55 -}; - - -Boot *readBoot(int drive); -uint8 checkBoot(Boot *boot); -bool writeBoot(int drive, Boot *boot); - -} // End of namespace CGE - -#endif diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 31a71cc16c..9f9bebad0c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -27,8 +27,6 @@ #include "common/scummsys.h" #include "cge/general.h" -#include "cge/boot.h" -#include "cge/ident.h" #include "cge/sound.h" #include "cge/startup.h" #include "cge/config.h" @@ -96,33 +94,6 @@ Snail *_snail_; // 1.01 - 17VII95 - default savegame with sound ON // coditionals EVA for 2-month evaluation version -/* - char Copr[] = "Common Game Engine " - #ifdef EVA - "ú" - #else - #ifdef CD - "ù" - #else - " " - #endif - #endif - " version 1.05 [" - #if sizeof(INI_FILE) == sizeof(VFILE) - "I" - #else - "i" - #endif - #if sizeof(PIC_FILE) == sizeof(VFILE) - "B" - #else - "b" - #endif - "]\n" - "Copyright (c) 1994 by Janusz B. Wi$niewski"; -*/ -char Copr[] = "To be fixed - Copr[]"; - static char UsrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; static int _oldLev = 0; static int _demoText = DEMO_TEXT; @@ -1793,12 +1764,9 @@ bool CGEEngine::showTitle(const char *name) { #ifdef CD STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; #else -// Boot * b = ReadBoot(getdisk()); - warning("ShowTitle: FIXME ReadBoot"); - Boot *b = readBoot(0); - uint32 sn = (b->_xSign == 0x29) ? b->_serial : b->_lTotSecs; - free(b); - sn -= ((Ident *)Copr)->_disk; + // At this point the game originally read the boot sector to get + // the serial number for it's copy protection check + uint32 sn = 0; STARTUP::Summa |= Lo(sn) | Hi(sn); #endif //----------------------------------------- diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index faff3ada57..fe94bd4598 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -25,7 +25,6 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/boot.h" #include "cge/general.h" #include "cge/snddrv.h" #include "cge/wav.h" @@ -344,24 +343,6 @@ int takeEnum(const char **tab, const char *txt) { return -1; } -Boot *readBoot(int drive) { - /* - struct fatinfo fi; Boot *b; - getfat(drive+1, &fi); - if (fi.fi_sclus & 0x80) - return NULL; - if ((b = malloc(fi.fi_bysec)) == NULL) - return NULL; - // read boot sector - if (absread(drive, 1, 0L, b) == 0) - return b; - free(b); - return NULL; - */ - warning("STUB: readBoot"); - return NULL; -} - long timer(void) { /* asm mov ax,0x40 diff --git a/engines/cge/general.h b/engines/cge/general.h index fae47eed42..63b94d3872 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -34,7 +34,6 @@ #include "common/textconsole.h" #include "common/str.h" #include "cge/jbw.h" -#include "cge/boot.h" namespace CGE { @@ -235,7 +234,6 @@ uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); char *dwtom(uint32 val, char * str, int radix, int len); int takeEnum(const char **tab, const char *txt); -Boot *readBoot(int drive); long timer(void); int new_random(int range); } // End of namespace CGE diff --git a/engines/cge/ident.h b/engines/cge/ident.h deleted file mode 100644 index 953f8a579d..0000000000 --- a/engines/cge/ident.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_IDENT__ -#define __CGE_IDENT__ - -namespace CGE { - -struct Ident { - char _copr[83]; - char _fill[8]; - unsigned long _disk; - unsigned char _cork; -}; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 028e4c61b1..b024701c93 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -28,7 +28,6 @@ #include "cge/startup.h" #include "cge/text.h" #include "cge/sound.h" -#include "cge/ident.h" #include "cge/cfile.h" #include "cge/snddrv.h" #include @@ -59,6 +58,8 @@ void quit_now(int ref) { bool STARTUP::get_parms(void) { + Summa = 0; + /* int i = _argc; while (i > 1) -- cgit v1.2.3 From 334de9626ae6e6e5cd66582993fe799b329a0a50 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 12:30:27 +1000 Subject: CGE: Removed C standard library includes --- engines/cge/bitmap.cpp | 2 +- engines/cge/btfile.cpp | 1 - engines/cge/cfile.cpp | 2 -- engines/cge/cge_main.cpp | 6 ------ engines/cge/game.cpp | 1 - engines/cge/gettext.cpp | 1 - engines/cge/mixer.cpp | 1 - engines/cge/snail.cpp | 2 -- engines/cge/startup.cpp | 3 --- engines/cge/text.cpp | 3 --- engines/cge/vga13h.cpp | 4 ---- engines/cge/vga13h.h | 1 - engines/cge/vmenu.cpp | 1 - engines/cge/vol.cpp | 3 --- engines/cge/wav.h | 1 - 15 files changed, 1 insertion(+), 31 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 3bcf751b40..e4e0a37eb3 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -471,7 +471,7 @@ bool Bitmap::loadBMP(XFile *f) { _w = hea.wid; if ((_m = farnew(byte, _h * _w)) != NULL) { int16 r = (4 - (hea.wid & 3)) % 4; - byte buf[3]; int i; + byte buf[3]; for (i = _h - 1; i >= 0; i--) { f->read(_m + (_w * i), _w); if (r && f->_error == 0) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 18bd2d72e7..3d0ce8a061 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -28,7 +28,6 @@ #include "cge/btfile.h" #include "common/system.h" #include "common/str.h" -#include namespace CGE { diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index ee2aecbc42..51e580a53b 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -26,8 +26,6 @@ */ #include "cge/cfile.h" -#include -#include #include "common/system.h" namespace CGE { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 9f9bebad0c..b8b0a2e3cc 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -43,10 +43,6 @@ #include "cge/mixer.h" #include "cge/cge_main.h" #include "cge/cge.h" -#include -#include -#include -#include #include "common/str.h" namespace CGE { @@ -1766,8 +1762,6 @@ bool CGEEngine::showTitle(const char *name) { #else // At this point the game originally read the boot sector to get // the serial number for it's copy protection check - uint32 sn = 0; - STARTUP::Summa |= Lo(sn) | Hi(sn); #endif //----------------------------------------- movie("X00"); // paylist diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 72233f746a..3acafd80e7 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -27,7 +27,6 @@ #include "cge/game.h" #include "cge/events.h" -#include namespace CGE { diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 9a6c1539d1..c48b281771 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -28,7 +28,6 @@ #include "cge/gettext.h" #include "cge/events.h" #include "cge/cge_main.h" -#include namespace CGE { diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 18bbfb65b5..e3fd2c07ed 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -31,7 +31,6 @@ #include "cge/events.h" #include "cge/snddrv.h" #include "cge/cge_main.h" -#include namespace CGE { diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index fbde5bd846..308ffb231c 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -32,8 +32,6 @@ #include "cge/bitmaps.h" #include "cge/text.h" #include "cge/cge_main.h" -#include -#include #include "cge/events.h" namespace CGE { diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index b024701c93..39a2b66e4b 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -30,9 +30,6 @@ #include "cge/sound.h" #include "cge/cfile.h" #include "cge/snddrv.h" -#include -#include -#include namespace CGE { diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index f98b7f5d1c..85ef17f4cf 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -33,9 +33,6 @@ #include "cge/game.h" #include "cge/snail.h" #include "cge/cge_main.h" -#include -#include -#include namespace CGE { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 43de8dc9b7..dc11ffbf6a 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -33,10 +33,6 @@ #include "cge/vol.h" #include "cge/text.h" #include "cge/cge_main.h" -#include -#include -#include -#include #include "cge/cge.h" namespace CGE { diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index b14edb9ba9..a063e40508 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -30,7 +30,6 @@ #include "graphics/surface.h" #include "cge/general.h" -#include #include "cge/bitmap.h" #include "cge/snail.h" #include "cge/cge.h" diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index d999dfa760..8ad3848cdb 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -28,7 +28,6 @@ #include "cge/vmenu.h" #include "cge/events.h" #include "cge/cge_main.h" -#include namespace CGE { diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 5f8573706b..332ae869c8 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -28,9 +28,6 @@ #include "cge/vol.h" #include "common/system.h" #include "common/str.h" -#include -#include -#include namespace CGE { diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 57187f7b87..062f83dfca 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -29,7 +29,6 @@ #define __CGE_WAV__ #include "cge/general.h" -#include namespace CGE { -- cgit v1.2.3 From 156c2d020fca74bb901e547a04ae2a9e2f8ec8cc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 14:55:49 +1000 Subject: CGE: Fix GCC compiler warnings --- engines/cge/cge_main.cpp | 2 +- engines/cge/config.cpp | 2 +- engines/cge/events.cpp | 4 ++++ engines/cge/vga13h.cpp | 12 ++++++------ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index b8b0a2e3cc..5f27f99c3c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -53,7 +53,7 @@ namespace CGE { #define SVG0NAME ("{{INIT}}" SVG_EXT) #define SVG0FILE INI_FILE -extern uint16 _stklen = (STACK_SIZ * 2); +uint16 _stklen = (STACK_SIZ * 2); VGA *Vga; Heart *_heart; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 4f5284b69b..9a8219dd6b 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -148,7 +148,7 @@ void CGEEngine::selectSound() { SNPOST_(SNKILL, -1, 0, VMENU::Addr); inf(Text->getText(STYPE_TEXT)); Talk->gotoxy(Talk->_x, FONT_HIG / 2); - for (i = 0; i < ArrayCount(DevName); i++) + for (i = 0; i < (int)ArrayCount(DevName); i++) DevMenu[i].Text = Text->getText(DevName[i]); (new VMENU(this, DevMenu, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->setName(Text->getText(MENU_TEXT)); } diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 2b9cc7fc6c..e18890625f 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -222,6 +222,8 @@ void MOUSE::NewMouse(Common::Event &event) { evt._msk = R_UP; Buttons &= ~2; break; + default: + break; } } @@ -253,6 +255,8 @@ void EventManager::poll() { _mouse->NewMouse(_event); handleEvents(); break; + default: + break; } } } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index dc11ffbf6a..b4e9bff286 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -343,13 +343,13 @@ void Heart::setXTimer(uint16 *ptr, uint16 time) { } -Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) +Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; - setShapeList(shp); + setShapeList(shpP); } @@ -378,16 +378,16 @@ BMP_PTR Sprite::shp() { } -BMP_PTR *Sprite::setShapeList(BMP_PTR *shp) { +BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; _shpCnt = 0; _w = 0; _h = 0; - if (shp) { + if (shpP) { BMP_PTR *p; - for (p = shp; *p; p++) { + for (p = shpP; *p; p++) { BMP_PTR b = (*p); // ->Code(); if (b->_w > _w) _w = b->_w; @@ -396,7 +396,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shp) { _shpCnt++; } expand(); - _ext->_shpList = shp; + _ext->_shpList = shpP; if (!_ext->_seq) setSeq((_shpCnt < 2) ? _seq1 : _seq2); } -- cgit v1.2.3 From 900e8cbf5b95ceea36c44296bc0de12e32687745 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 15:32:27 +1000 Subject: CGE: Fixed GCC compiler warnings --- engines/cge/bitmap.cpp | 13 +++++++++++-- engines/cge/text.cpp | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index e4e0a37eb3..c94b8503cf 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -102,9 +102,18 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) *(uint16 *) v = CPY | dsiz; // data chunk hader memset(v + 2, fill, dsiz); // data bytes *(uint16 *)(v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap - memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines + + // Replicate lines + byte *destP; + for (destP = v + lsiz; destP < (v + psiz); destP += lsiz) + Common::copy(v, v + lsiz, destP); + *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 - memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes + + // Repliccate planes + for (destP = v + psiz; destP < (v + 4 * psiz); destP += psiz) + Common::copy(v, v + psiz, destP); + HideDesc *b = (HideDesc *)(v + 4 * psiz); b->skip = (SCR_WID - _w) >> 2; b->hide = _w >> 2; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 85ef17f4cf..e17688c6ee 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -63,7 +63,7 @@ void TEXT::Clear(int from, int upto) { for (p = Cache, q = p + Size; p < q; p++) { if (p->Ref && p->Ref >= from && p->Ref < upto) { p->Ref = 0; - delete p->Txt; + delete[] p->Txt; p->Txt = NULL; } } -- cgit v1.2.3 From d53142d95e793861d2891f8a7d16ac11b9b94126 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 15:41:07 +1000 Subject: CGE: Fixed code using memory overruns to do duplication --- engines/cge/bitmap.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index c94b8503cf..833d0f1f1b 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -117,6 +117,11 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) HideDesc *b = (HideDesc *)(v + 4 * psiz); b->skip = (SCR_WID - _w) >> 2; b->hide = _w >> 2; + + // Replicate across the entire table + for (HideDesc *hdP = b + 1; hdP < (b + _h); ++hdP) + *hdP = *b; + memcpy(b + 1, b, (_h - 1) * sizeof(*b)); // tricky fill entire table b->skip = 0; // fix the first entry _v = v; -- cgit v1.2.3 From dff8bd5474905c924f4039ab079c20b3f145b364 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 17:14:47 +1000 Subject: CGE: Fix some memory leaks --- engines/cge/bitmap.cpp | 1 - engines/cge/cge.cpp | 2 +- engines/cge/vga13h.cpp | 11 ++++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 833d0f1f1b..d0c7ba6ab5 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -122,7 +122,6 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) for (HideDesc *hdP = b + 1; hdP < (b + _h); ++hdP) *hdP = *b; - memcpy(b + 1, b, (_h - 1) * sizeof(*b)); // tricky fill entire table b->skip = 0; // fix the first entry _v = v; _b = b; diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 4af10b2b8d..89d5c0a86e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -117,7 +117,7 @@ CGEEngine::~CGEEngine() { // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); - _console = new CGEConsole(this); + delete _console; // Delete engine objects delete _sprite; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index b4e9bff286..35d9688bd3 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -912,8 +912,10 @@ void VGA::init() { } void VGA::deinit() { - for (int idx = 0; idx < 4; ++idx) + for (int idx = 0; idx < 4; ++idx) { + Page[idx]->free(); delete Page[idx]; + } delete[] SysPal; } @@ -931,7 +933,7 @@ VGA::VGA(int mode) for (i = 10; i < 20; i++) { char *txt = Text->getText(i); if (txt) { - warning("%s", txt); + debugN("%s", txt); std = false; } } @@ -976,8 +978,11 @@ VGA::~VGA(void) { if (Nam) buffer = buffer + " [" + Nam + "]"; - warning("%s", buffer.c_str()); + debugN("%s", buffer.c_str()); } + + delete ShowQ; + delete SpareQ; } -- cgit v1.2.3 From 4116189395a87959f1981ca7ebae0604aa4ca9a4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 3 Jul 2011 11:28:22 +0200 Subject: CGE: Some more renaming (WIP) --- engines/cge/cge.cpp | 18 +-- engines/cge/cge_main.cpp | 309 ++++++++++++++++++++++++----------------------- engines/cge/cge_main.h | 6 +- engines/cge/config.cpp | 60 ++++----- engines/cge/events.cpp | 2 +- engines/cge/events.h | 2 +- engines/cge/general.cpp | 18 +-- engines/cge/gettext.cpp | 16 +-- engines/cge/gettext.h | 2 +- engines/cge/mixer.cpp | 30 ++--- engines/cge/snail.cpp | 72 +++++------ engines/cge/snddrv.h | 58 ++++----- engines/cge/sound.cpp | 22 ++-- engines/cge/startup.cpp | 39 +++--- engines/cge/startup.h | 18 +-- engines/cge/talk.cpp | 144 +++++++++++----------- engines/cge/talk.h | 56 ++++----- engines/cge/text.cpp | 166 ++++++++++++------------- engines/cge/text.h | 42 +++---- engines/cge/vga13h.cpp | 136 ++++++++++----------- engines/cge/vga13h.h | 73 +++++------ engines/cge/vmenu.cpp | 12 +- engines/cge/vmenu.h | 4 +- 23 files changed, 654 insertions(+), 651 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 89d5c0a86e..6eae8f3c0e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -61,10 +61,10 @@ void CGEEngine::setup() { VGA::init(); VFILE::init(); Bitmap::init(); - TALK::init(); + Talk::init(); // Initialise engine objects - Text = new TEXT(this, progName(), 128); + _text = new Text(this, progName(), 128); Vga = new VGA(M13H); _heart = new Heart; Hero = new WALK(this, NULL); @@ -76,9 +76,9 @@ void CGEEngine::setup() { _miniCave = new Sprite(this, NULL); _shadow = new Sprite(this, NULL); _horzLine = new Sprite(this, HL); - InfoLine = new INFO_LINE(this, INFO_W); + _infoLine = new InfoLine(this, INFO_W); _cavLight = new Sprite(this, PR); - DebugLine = new INFO_LINE(this, SCR_WID); + _debugLine = new InfoLine(this, SCR_WID); MB[0] = new Bitmap("BRICK", true); MB[1] = NULL; HL[0] = new Bitmap("HLINE", true); @@ -102,14 +102,14 @@ void CGEEngine::setup() { _mouse = new MOUSE(this); _keyboard = new Keyboard(); _eventManager = new EventManager(); - OffUseCount = atoi(Text->getText(OFF_USE_COUNT)); + _offUseCount = atoi(_text->getText(OFF_USE_COUNT)); } CGEEngine::~CGEEngine() { debug("CGEEngine::~CGEEngine"); // Call classes with static members to clear them up - TALK::deinit(); + Talk::deinit(); Bitmap::deinit(); VFILE::deinit(); VGA::deinit(); @@ -124,9 +124,9 @@ CGEEngine::~CGEEngine() { delete _miniCave; delete _shadow; delete _horzLine; - delete InfoLine; + delete _infoLine; delete _cavLight; - delete DebugLine; + delete _debugLine; delete MB[0]; delete HL[0]; delete MC[0]; @@ -138,7 +138,7 @@ CGEEngine::~CGEEngine() { delete LI[1]; delete LI[2]; delete LI[3]; - delete Text; + delete _text; delete _heart; delete _pocLight; delete _keyboard; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 5f27f99c3c..33abf7917d 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -68,9 +68,9 @@ Sprite *_sprite; Sprite *_miniCave; Sprite *_shadow; Sprite *_horzLine; -INFO_LINE *InfoLine; +InfoLine *_infoLine; Sprite *_cavLight; -INFO_LINE *DebugLine; +InfoLine *_debugLine; BMP_PTR MB[2]; BMP_PTR HL[2]; @@ -90,24 +90,24 @@ Snail *_snail_; // 1.01 - 17VII95 - default savegame with sound ON // coditionals EVA for 2-month evaluation version -static char UsrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; +static char _usrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; static int _oldLev = 0; static int _demoText = DEMO_TEXT; //-------------------------------------------------------------------------- -bool JBW = false; +bool _jbw = false; //------------------------------------------------------------------------- -int PocPtr = 0; +int _pocPtr = 0; -static EMS *Mini = MiniEmm.alloc((uint16)MINI_EMM_SIZE); -static BMP_PTR *MiniShpList = NULL; -static BMP_PTR MiniShp[] = { NULL, NULL }; -static bool Finis = false; -static int Startup = 1; -int OffUseCount; -uint16 *intStackPtr = false; +static EMS *_mini = _miniEmm.alloc((uint16)MINI_EMM_SIZE); +static BMP_PTR *_miniShpList = NULL; +static BMP_PTR _miniShp[] = { NULL, NULL }; +static bool _finis = false; +static int _startup = 1; +int _offUseCount; +uint16 *_intStackPtr = false; Hxy _heroXY[CAVE_MAX] = {{0, 0}}; Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; @@ -119,7 +119,7 @@ void feedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; -uint8 &Cluster::cell(void) { +uint8 &Cluster::cell() { return _map[_b][_a]; } @@ -227,15 +227,15 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { file.read((uint8 *) &i, sizeof(i)); if (i != SVGCHKSUM) - error("%s", Text->getText(BADSVG_TEXT)); + error("%s", _text->getText(BADSVG_TEXT)); - if (STARTUP::Core < CORE_HIG) + if (Startup::_core < CORE_HIG) _music = false; - if (STARTUP::SoundOk == 1 && STARTUP::Mode == 0) { - SNDDrvInfo.VOL2.D = _volume[0]; - SNDDrvInfo.VOL2.M = _volume[1]; - SNDSetVolume(); + if (Startup::_soundOk == 1 && Startup::_mode == 0) { + _sndDrvInfo.Vol2._d = _volume[0]; + _sndDrvInfo.Vol2._m = _volume[1]; + sndSetVolume(); } if (! tiny) { // load sprites & pocket @@ -252,21 +252,21 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { if (spr == NULL) error("No core"); *spr = S; - Vga->SpareQ->Append(spr); + Vga->_spareQ->append(spr); } for (i = 0; i < POCKET_NX; i++) { register int r = _pocref[i]; - _pocket[i] = (r < 0) ? NULL : Vga->SpareQ->Locate(r); + _pocket[i] = (r < 0) ? NULL : Vga->_spareQ->locate(r); } } } static void SaveSound(void) { - CFile cfg(UsrPath(progName(CFG_EXT)), WRI); + CFile cfg(usrPath(progName(CFG_EXT)), WRI); if (!cfg._error) - cfg.write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2)); + cfg.write(&_sndDrvInfo, sizeof(_sndDrvInfo) - sizeof(_sndDrvInfo.Vol2)); } @@ -280,8 +280,8 @@ static void SaveGame(XFile &file) { _pocref[i] = (s) ? s->_ref : -1; } - _volume[0] = SNDDrvInfo.VOL2.D; - _volume[1] = SNDDrvInfo.VOL2.M; + _volume[0] = _sndDrvInfo.Vol2._d; + _volume[1] = _sndDrvInfo.Vol2._m; for (st = _savTab; st->Ptr; st++) { if (file._error) @@ -291,7 +291,7 @@ static void SaveGame(XFile &file) { file.write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); - for (spr = Vga->SpareQ->First(); spr; spr = spr->_next) + for (spr = Vga->_spareQ->first(); spr; spr = spr->_next) if (spr->_ref >= 1000) if (!file._error) file.write((uint8 *)spr, sizeof(*spr)); @@ -303,7 +303,7 @@ static void HeroCover(int cvr) { } -static void Trouble(int seq, int txt) { +static void trouble(int seq, int txt) { Hero->park(); SNPOST(SNWAIT, -1, -1, Hero); SNPOST(SNSEQ, -1, seq, Hero); @@ -313,23 +313,23 @@ static void Trouble(int seq, int txt) { } -static void OffUse(void) { - Trouble(OFF_USE, OFF_USE_TEXT + new_random(OffUseCount)); +static void offUse() { + trouble(OFF_USE, OFF_USE_TEXT + new_random(_offUseCount)); } -static void TooFar(void) { - Trouble(TOO_FAR, TOO_FAR_TEXT); +static void tooFar() { + trouble(TOO_FAR, TOO_FAR_TEXT); } // Used in stubbed function, do not remove! static void noWay() { - Trouble(NO_WAY, NO_WAY_TEXT); + trouble(NO_WAY, NO_WAY_TEXT); } -static void LoadHeroXY(void) { +static void loadHeroXY() { INI_FILE cf(progName(".HXY")); memset(_heroXY, 0, sizeof(_heroXY)); if (!cf._error) @@ -337,7 +337,7 @@ static void LoadHeroXY(void) { } -static void LoadMapping(void) { +static void loadMapping() { if (_now <= CAVE_MAX) { INI_FILE cf(progName(".TAB")); if (!cf._error) { @@ -367,7 +367,7 @@ void WALK::tick() { if (Dir != NO_DIR) { Sprite *spr; Sys->FunTouch(); - for (spr = Vga->ShowQ->First(); spr; spr = spr->_next) { + for (spr = Vga->_showQ->first(); spr; spr = spr->_next) { if (distance(spr) < 2) { if (!spr->_flags._near) { feedSnail(spr, NEAR); @@ -548,7 +548,7 @@ void CGEEngine::setMapBrick(int x, int z) { wtom(z, n + 3, 10, 2); Cluster::_map[z][x] = 1; s->setName(n); - Vga->ShowQ->Insert(s, Vga->ShowQ->First()); + Vga->_showQ->insert(s, Vga->_showQ->first()); } } @@ -584,9 +584,9 @@ void CGEEngine::quit() { SNPOST_(SNKILL, -1, 0, VMENU::Addr); resetQSwitch(); } else { - QuitMenu[0].Text = Text->getText(QUIT_TEXT); - QuitMenu[1].Text = Text->getText(NOQUIT_TEXT); - (new VMENU(this, QuitMenu, -1, -1))->setName(Text->getText(QUIT_TITLE)); + QuitMenu[0].Text = _text->getText(QUIT_TEXT); + QuitMenu[1].Text = _text->getText(NOQUIT_TEXT); + (new VMENU(this, QuitMenu, -1, -1))->setName(_text->getText(QUIT_TITLE)); SNPOST_(SNSEQ, 123, 1, NULL); KeyClick(); } @@ -594,7 +594,7 @@ void CGEEngine::quit() { } -static void AltCtrlDel(void) { +static void AltCtrlDel() { SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero); } @@ -603,8 +603,8 @@ static void miniStep(int stp) { if (stp < 0) _miniCave->_flags._hide = true; else { - &*Mini; - *MiniShp[0] = *MiniShpList[stp]; + &*_mini; + *_miniShp[0] = *_miniShpList[stp]; if (_fx.Current) &*(_fx.Current->EAddr()); @@ -633,13 +633,13 @@ void SYSTEM::SetPal(void) { void SYSTEM::FunTouch(void) { uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0; - if (Talk == NULL || n > FunDel) + if (_talk == NULL || n > FunDel) FunDel = n; } static void ShowBak(int ref) { - Sprite *spr = Vga->SpareQ->Locate(ref); + Sprite *spr = Vga->_spareQ->locate(ref); if (spr) { Bitmap::_pal = VGA::SysPal; spr->expand(); @@ -658,9 +658,9 @@ static void caveUp() { LoadMIDI(_now); ShowBak(BakRef); - LoadMapping(); - Text->Preload(BakRef, BakRef + 1000); - Sprite *spr = Vga->SpareQ->First(); + loadMapping(); + _text->preload(BakRef, BakRef + 1000); + Sprite *spr = Vga->_spareQ->first(); while (spr) { Sprite *n = spr->_next; if (spr->_cave == _now || spr->_cave == 0) @@ -672,7 +672,7 @@ static void caveUp() { } spr = n; } - if (SNDDrvInfo.DDEV) { + if (_sndDrvInfo._dDev) { _sound.Stop(); _fx.Clear(); _fx.Preload(0); @@ -693,21 +693,21 @@ static void caveUp() { Vga->CopyPage(0, 1); selectPocket(-1); if (Hero) - Vga->ShowQ->Insert(Vga->ShowQ->Remove(Hero)); + Vga->_showQ->insert(Vga->_showQ->remove(Hero)); if (_shadow) { - Vga->ShowQ->Remove(_shadow); + Vga->_showQ->remove(_shadow); _shadow->makeXlat(glass(VGA::SysPal, 204, 204, 204)); - Vga->ShowQ->Insert(_shadow, Hero); + Vga->_showQ->insert(_shadow, Hero); _shadow->_z = Hero->_z; } - feedSnail(Vga->ShowQ->Locate(BakRef + 999), TAKE); + feedSnail(Vga->_showQ->locate(BakRef + 999), TAKE); Vga->Show(); Vga->CopyPage(1, 0); Vga->Show(); Vga->Sunrise(VGA::SysPal); _dark = false; - if (! Startup) + if (!_startup) _mouse->On(); _heart->_enable = true; @@ -719,16 +719,16 @@ void CGEEngine::caveDown() { if (!_horzLine->_flags._hide) switchMapping(); - for (spr = Vga->ShowQ->First(); spr;) { + for (spr = Vga->_showQ->first(); spr;) { Sprite *n = spr->_next; if (spr->_ref >= 1000 /*&& spr->_cave*/) { if (spr->_ref % 1000 == 999) feedSnail(spr, TAKE); - Vga->SpareQ->Append(Vga->ShowQ->Remove(spr)); + Vga->_spareQ->append(Vga->_showQ->remove(spr)); } spr = n; } - Text->Clear(1000); + _text->clear(1000); } @@ -742,10 +742,10 @@ void CGEEngine::qGame() { caveDown(); _oldLev = _lev; SaveSound(); - CFile file = CFile(UsrPath(UsrFnam), WRI, RCrypt); + CFile file = CFile(usrPath(_usrFnam), WRI, RCrypt); SaveGame(file); Vga->Sunset(); - Finis = true; + _finis = true; } @@ -765,13 +765,13 @@ void CGEEngine::switchCave(int cav) { Hero->step(0); if (!_isDemo) ///// protection: auto-destruction on! ---------------------- - Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX); + Vga->_spareQ->_show = Startup::_summa * (cav <= CAVE_MAX); /////-------------------------------------------------------- } _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); - KillText(); - if (! Startup) + killText(); + if (!_startup) KeyClick(); SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer @@ -795,8 +795,8 @@ void SYSTEM::touch(uint16 mask, int x, int y) { if (mask & KEYB) { int pp0; KeyClick(); - KillText(); - if (Startup == 1) { + killText(); + if (_startup == 1) { SNPOST(SNCLEAR, -1, 0, NULL); return; } @@ -810,7 +810,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { break; case 'F': if (_keyboard->_key[ALT]) { - Sprite *m = Vga->ShowQ->Locate(17001); + Sprite *m = Vga->_showQ->locate(17001); if (m) { m->step(1); m->_time = 216; // 3s @@ -858,7 +858,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { break; case 'X': if (_keyboard->_key[ALT]) - Finis = true; + _finis = true; break; case '0': case '1': @@ -891,16 +891,16 @@ void SYSTEM::touch(uint16 mask, int x, int y) { break; case 'W': if (pp == 2) - JBW = !JBW; + _jbw = !_jbw; break; } if (pp == pp0) pp = 0; } else { - if (Startup) + if (_startup) return; int cav = 0; - InfoLine->Update(NULL); + _infoLine->update(NULL); if (y >= WORLD_HIG) { if (x < BUTTON_X) { // select cave? if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && @@ -935,7 +935,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { } } else { - if (! Talk && _snail->idle() && Hero + if (!_talk && _snail->idle() && Hero && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_game) { Hero->findWay(XZ(x, y)); } @@ -946,12 +946,13 @@ void SYSTEM::touch(uint16 mask, int x, int y) { void SYSTEM::Tick(void) { - if (! Startup) if (-- FunDel == 0) { - KillText(); + if (!_startup) + if (--FunDel == 0) { + killText(); if (_snail->idle()) { if (PAIN) HeroCover(9); - else if (STARTUP::Core >= CORE_MID) { + else if (Startup::_core >= CORE_MID) { int n = new_random(100); if (n > 96) HeroCover(6 + (Hero->_x + Hero->_w / 2 < SCR_WID / 2)); @@ -1011,7 +1012,7 @@ static void SwitchMusic(void) { warning("SwitchMusic() - SNPOST"); } } else { - if (STARTUP::Core < CORE_HIG) + if (Startup::_core < CORE_HIG) SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL); else { SNPOST_(SNSEQ, 122, (_music = !_music), NULL); @@ -1035,13 +1036,13 @@ void CGEEngine::takeName() { if (GetText::_ptr) SNPOST_(SNKILL, -1, 0, GetText::_ptr); else { - GetText *tn = new GetText(this, Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick); + GetText *tn = new GetText(this, _text->getText(GETNAME_PROMPT), _usrFnam, 8, KeyClick); if (tn) { - tn->setName(Text->getText(GETNAME_TITLE)); + tn->setName(_text->getText(GETNAME_TITLE)); tn->center(); tn->gotoxy(tn->_x, tn->_y - 10); tn->_z = 126; - Vga->ShowQ->Insert(tn); + Vga->_showQ->insert(tn); } } } @@ -1059,7 +1060,7 @@ void CGEEngine::switchMapping() { } } else { Sprite *s; - for (s = Vga->ShowQ->First(); s; s = s->_next) + for (s = Vga->_showQ->first(); s; s = s->_next) if (s->_w == MAP_XGRID && s->_h == MAP_ZGRID) SNPOST_(SNKILL, -1, 0, s); } @@ -1078,7 +1079,7 @@ static void KillSprite(void) { static void PushSprite(void) { Sprite *spr = _sprite->_prev; if (spr) { - Vga->ShowQ->Insert(Vga->ShowQ->Remove(_sprite), spr); + Vga->_showQ->insert(Vga->_showQ->remove(_sprite), spr); while (_sprite->_z > _sprite->_next->_z) _sprite->_z--; } else @@ -1095,7 +1096,7 @@ static void PullSprite(void) { ok = (!spr->_flags._slav); } if (ok) { - Vga->ShowQ->Insert(Vga->ShowQ->Remove(_sprite), spr); + Vga->_showQ->insert(Vga->_showQ->remove(_sprite), spr); if (_sprite->_prev) while (_sprite->_z < _sprite->_prev->_z) _sprite->_z++; @@ -1148,8 +1149,8 @@ static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 0 #define SP_F (DebugText + 67) #define SP__ (DebugText + 70) -static void SayDebug(void) { - if (!DebugLine->_flags._hide) { +static void sayDebug() { + if (!_debugLine->_flags._hide) { static long t = -1L; long t1 = timer(); @@ -1169,7 +1170,7 @@ static void SayDebug(void) { // sprite queue size uint16 n = 0; Sprite *spr; - for (spr = Vga->ShowQ->First(); spr; spr = spr->_next) { + for (spr = Vga->_showQ->first(); spr; spr = spr->_next) { ++ n; if (spr == _sprite) { *XSPR = ' '; @@ -1184,13 +1185,13 @@ static void SayDebug(void) { } dwtom(n, SP_S, 10, 2); // *SP__ = (heapcheck() < 0) ? '!' : ' '; - DebugLine->Update(DebugText); + _debugLine->update(DebugText); } } static void SwitchDebug(void) { - DebugLine->_flags._hide = ! DebugLine->_flags._hide; + _debugLine->_flags._hide = !_debugLine->_flags._hide; } @@ -1221,7 +1222,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { void Sprite::touch(uint16 mask, int x, int y) { Sys->FunTouch(); if ((mask & ATTN) == 0) { - InfoLine->Update(name()); + _infoLine->update(name()); if (mask & (R_DN | L_DN)) _sprite = this; if (_ref / 10 == 12) { @@ -1235,16 +1236,16 @@ void Sprite::touch(uint16 mask, int x, int y) { mask |= R_UP; } if ((mask & R_UP) && _snail->idle()) { - Sprite *ps = (_pocLight->_seqPtr) ? _pocket[PocPtr] : NULL; + Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_pocPtr] : NULL; if (ps) { if (_flags._kept || Hero->distance(this) < MAX_DISTANCE) { if (works(ps)) { feedSnail(ps, TAKE); } else - OffUse(); + offUse(); selectPocket(-1); } else - TooFar(); + tooFar(); } else { if (_flags._kept) mask |= L_UP; @@ -1262,15 +1263,15 @@ void Sprite::touch(uint16 mask, int x, int y) { } else { if (_takePtr != NO_PTR) { if (snList(TAKE)[_takePtr]._com == SNNEXT) - OffUse(); + offUse(); else feedSnail(this, TAKE); } else - OffUse(); + offUse(); } }/// else - TooFar(); + tooFar(); } } } @@ -1439,7 +1440,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int *p = '\0'; _sprite->_shpCnt = shpcnt; - Vga->SpareQ->Append(_sprite); + Vga->_spareQ->append(_sprite); } } @@ -1506,16 +1507,16 @@ void CGEEngine::loadScript(const char *fname) { #define GAME_FRAME_DELAY (1000 / 50) void CGEEngine::mainLoop() { - SayDebug(); + sayDebug(); if (_isDemo) { // static uint32 tc = 0; - if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ Talk == NULL && _snail->idle()) { - if (Text->getText(_demoText)) { + if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ _talk == NULL && _snail->idle()) { + if (_text->getText(_demoText)) { SNPOST(SNSOUND, -1, 4, NULL); // drumla SNPOST(SNINF, -1, _demoText, NULL); SNPOST(SNLABEL, -1, -1, NULL); - if (Text->getText(++_demoText) == NULL) + if (_text->getText(++_demoText) == NULL) _demoText = DEMO_TEXT + 1; } //FIXME: tc = TimerCount; @@ -1541,11 +1542,11 @@ void CGEEngine::mainLoop() { void CGEEngine::loadUser() { // set scene - if (STARTUP::Mode == 0) { // user .SVG file found - CFile cfile = CFile(UsrPath(UsrFnam), REA, RCrypt); + if (Startup::_mode == 0) { // user .SVG file found + CFile cfile = CFile(usrPath(_usrFnam), REA, RCrypt); loadGame(cfile); } else { - if (STARTUP::Mode == 1) { + if (Startup::_mode == 1) { SVG0FILE file = SVG0FILE(SVG0NAME); loadGame(file); } else { @@ -1564,12 +1565,12 @@ void CGEEngine::runGame() { if (_eventManager->_quitFlag) return; - Text->Clear(); - Text->Preload(100, 1000); - LoadHeroXY(); + _text->clear(); + _text->preload(100, 1000); + loadHeroXY(); _cavLight->_flags._tran = true; - Vga->ShowQ->Append(_cavLight); + Vga->_showQ->append(_cavLight); _cavLight->_flags._hide = true; static Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, @@ -1584,7 +1585,7 @@ void CGEEngine::runGame() { _pocLight->_flags._tran = true; _pocLight->_time = 1; _pocLight->_z = 120; - Vga->ShowQ->Append(_pocLight); + Vga->_showQ->append(_pocLight); selectPocket(-1); // FIXME: Allow ScummVM to handle mouse display @@ -1594,24 +1595,24 @@ void CGEEngine::runGame() { loadUser(); // ~~~~~~~~~~~ - if ((_sprite = Vga->SpareQ->Locate(121)) != NULL) + if ((_sprite = Vga->_spareQ->locate(121)) != NULL) SNPOST_(SNSEQ, -1, Vga->Mono, _sprite); - if ((_sprite = Vga->SpareQ->Locate(122)) != NULL) + if ((_sprite = Vga->_spareQ->locate(122)) != NULL) _sprite->step(_music); SNPOST_(SNSEQ, -1, _music, _sprite); if (!_music) KillMIDI(); - if (Mini && INI_FILE::exist("MINI.SPR")) { - uint8 *ptr = (uint8 *) &*Mini; + if (_mini && INI_FILE::exist("MINI.SPR")) { + uint8 *ptr = (uint8 *) &*_mini; if (ptr != NULL) { loadSprite("MINI", -1, 0, MINI_X, MINI_Y); ExpandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { _miniCave->_flags._hide = true; _miniCave->moveShapes(ptr); - MiniShp[0] = new Bitmap(*_miniCave->shp()); - MiniShpList = _miniCave->setShapeList(MiniShp); + _miniShp[0] = new Bitmap(*_miniCave->shp()); + _miniShpList = _miniCave->setShapeList(_miniShp); PostMiniStep(-1); } } @@ -1626,28 +1627,28 @@ void CGEEngine::runGame() { _shadow->_ref = 2; _shadow->_flags._tran = true; Hero->_flags._shad = true; - Vga->ShowQ->Insert(Vga->SpareQ->Remove(_shadow), Hero); + Vga->_showQ->insert(Vga->_spareQ->remove(_shadow), Hero); } } } - InfoLine->gotoxy(INFO_X, INFO_Y); - InfoLine->_flags._tran = true; - InfoLine->Update(NULL); - Vga->ShowQ->Insert(InfoLine); + _infoLine->gotoxy(INFO_X, INFO_Y); + _infoLine->_flags._tran = true; + _infoLine->update(NULL); + Vga->_showQ->insert(_infoLine); - DebugLine->_z = 126; - Vga->ShowQ->Insert(DebugLine); + _debugLine->_z = 126; + Vga->_showQ->insert(_debugLine); _horzLine->_y = MAP_TOP - (MAP_TOP > 0); _horzLine->_z = 126; - Vga->ShowQ->Insert(_horzLine); + Vga->_showQ->insert(_horzLine); - _mouse->Busy = Vga->SpareQ->Locate(BUSY_REF); + _mouse->Busy = Vga->_spareQ->locate(BUSY_REF); if (_mouse->Busy) ExpandSprite(_mouse->Busy); - Startup = 0; + _startup = 0; SNPOST(SNLEVEL, -1, _oldLev, &_cavLight); _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, @@ -1656,7 +1657,7 @@ void CGEEngine::runGame() { _keyboard->setClient(Sys); // main loop - while (! Finis && !_eventManager->_quitFlag) { + while (!_finis && !_eventManager->_quitFlag) { //TODO Change the SNPOST message send to a special way to send function pointer // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame); warning("RunGame: problematic use of SNPOST"); @@ -1668,8 +1669,8 @@ void CGEEngine::runGame() { SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); _mouse->Off(); - Vga->ShowQ->Clear(); - Vga->SpareQ->Clear(); + Vga->_showQ->clear(); + Vga->_spareQ->clear(); Hero = NULL; _shadow = NULL; } @@ -1682,8 +1683,8 @@ void CGEEngine::movie(const char *ext) { const char *fn = progName(ext); if (INI_FILE::exist(fn)) { loadScript(fn); - ExpandSprite(Vga->SpareQ->Locate(999)); - feedSnail(Vga->ShowQ->Locate(999), TAKE); + ExpandSprite(Vga->_spareQ->locate(999)); + feedSnail(Vga->_showQ->locate(999), TAKE); // FIXME: Allow ScummVM to handle mouse display //Vga->ShowQ->Append(Mouse); @@ -1697,8 +1698,8 @@ void CGEEngine::movie(const char *ext) { _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); - Vga->ShowQ->Clear(); - Vga->SpareQ->Clear(); + Vga->_showQ->clear(); + Vga->_spareQ->clear(); } } @@ -1718,9 +1719,9 @@ bool CGEEngine::showTitle(const char *name) { D.center(); D.show(2); - if (STARTUP::Mode == 2) { + if (Startup::_mode == 2) { inf(SVG0NAME); - Talk->show(2); + _talk->show(2); } Vga->Sunset(); @@ -1729,10 +1730,10 @@ bool CGEEngine::showTitle(const char *name) { selectPocket(-1); Vga->Sunrise(VGA::SysPal); - if (STARTUP::Mode < 2 && !STARTUP::SoundOk) { + if (Startup::_mode < 2 && !Startup::_soundOk) { Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); - Vga->ShowQ->Append(_mouse); + Vga->_showQ->append(_mouse); _heart->_enable = true; _mouse->On(); for (selectSound(); !_snail->idle() || VMENU::Addr;) { @@ -1743,22 +1744,22 @@ bool CGEEngine::showTitle(const char *name) { _mouse->Off(); _heart->_enable = false; - Vga->ShowQ->Clear(); + Vga->_showQ->clear(); Vga->CopyPage(0, 2); - STARTUP::SoundOk = 2; + Startup::_soundOk = 2; if (_music) LoadMIDI(0); } - if (STARTUP::Mode < 2) { + if (Startup::_mode < 2) { if (_isDemo) { - strcpy(UsrFnam, progName(SVG_EXT)); + strcpy(_usrFnam, progName(SVG_EXT)); usr_ok = true; } else { //----------------------------------------- #ifndef EVA #ifdef CD - STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; + Startup::_summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; #else // At this point the game originally read the boot sector to get // the serial number for it's copy protection check @@ -1767,7 +1768,7 @@ bool CGEEngine::showTitle(const char *name) { movie("X00"); // paylist Vga->CopyPage(1, 2); Vga->CopyPage(0, 1); - Vga->ShowQ->Append(_mouse); + Vga->_showQ->append(_mouse); //Mouse.On(); _heart->_enable = true; for (takeName(); GetText::_ptr;) { @@ -1776,33 +1777,33 @@ bool CGEEngine::showTitle(const char *name) { return false; } _heart->_enable = false; - if (_keyboard->last() == Enter && *UsrFnam) + if (_keyboard->last() == Enter && *_usrFnam) usr_ok = true; if (usr_ok) - strcat(UsrFnam, SVG_EXT); + strcat(_usrFnam, SVG_EXT); //Mouse.Off(); - Vga->ShowQ->Clear(); + Vga->_showQ->clear(); Vga->CopyPage(0, 2); #endif } - if (usr_ok && STARTUP::Mode == 0) { - const char *n = UsrPath(UsrFnam); + if (usr_ok && Startup::_mode == 0) { + const char *n = usrPath(_usrFnam); if (CFile::exist(n)) { CFile file = CFile(n, REA, RCrypt); loadGame(file, true); // only system vars Vga->SetColors(VGA::SysPal, 64); Vga->Update(); if (FINIS) { - ++ STARTUP::Mode; + Startup::_mode++; FINIS = false; } } else - ++STARTUP::Mode; + Startup::_mode++; } } - if (STARTUP::Mode < 2) + if (Startup::_mode < 2) movie("X01"); // wink Vga->CopyPage(0, 2); @@ -1810,7 +1811,7 @@ bool CGEEngine::showTitle(const char *name) { if (_isDemo) return true; else - return (STARTUP::Mode == 2 || usr_ok); + return (Startup::_mode == 2 || usr_ok); } @@ -1824,34 +1825,34 @@ void StkDump (void) { void CGEEngine::cge_main(void) { uint16 intStack[STACK_SIZ / 2]; - intStackPtr = intStack; + _intStackPtr = intStack; //Debug( memset((void *) (-K(2)), 0, K(1)); ) //Debug( memset((void *) (-K(4)), 0, K(1)); ) memset(_barriers, 0xFF, sizeof(_barriers)); if (!_mouse->Exist) - error("%s", Text->getText(NO_MOUSE_TEXT)); + error("%s", _text->getText(NO_MOUSE_TEXT)); if (!SVG0FILE::exist(SVG0NAME)) - STARTUP::Mode = 2; + Startup::_mode = 2; - DebugLine->_flags._hide = true; + _debugLine->_flags._hide = true; _horzLine->_flags._hide = true; //srand((uint16) Timer()); Sys = new SYSTEM(this); - if (_music && STARTUP::SoundOk) + if (_music && Startup::_soundOk) LoadMIDI(0); - if (STARTUP::Mode < 2) + if (Startup::_mode < 2) movie(LGO_EXT); if (showTitle("WELCOME")) { - if ((!_isDemo) && (STARTUP::Mode == 1)) + if ((!_isDemo) && (Startup::_mode == 1)) movie("X02"); // intro runGame(); - Startup = 2; + _startup = 2; if (FINIS) movie("X03"); } else diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 5e3eb6bf1c..0684a886e5 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -170,7 +170,7 @@ extern WALK *Hero; extern VGA *Vga; extern Heart *_heart; extern SYSTEM *Sys; -extern int OffUseCount; +extern int _offUseCount; extern Sprite *_pocLight; extern Keyboard *_keyboard; extern MOUSE *_mouse; @@ -180,9 +180,9 @@ extern Sprite *_sprite; extern Sprite *_miniCave; extern Sprite *_shadow; extern Sprite *_horzLine; -extern INFO_LINE *InfoLine; +extern InfoLine *_infoLine; extern Sprite *_cavLight; -extern INFO_LINE *DebugLine; +extern InfoLine *_debugLine; extern BMP_PTR MB[2]; extern BMP_PTR MB[2]; extern BMP_PTR HL[2]; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 9a8219dd6b..f32c3b7195 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -146,16 +146,16 @@ void CGEEngine::selectSound() { _sound.Close(); if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); - inf(Text->getText(STYPE_TEXT)); - Talk->gotoxy(Talk->_x, FONT_HIG / 2); + inf(_text->getText(STYPE_TEXT)); + _talk->gotoxy(_talk->_x, FONT_HIG / 2); for (i = 0; i < (int)ArrayCount(DevName); i++) - DevMenu[i].Text = Text->getText(DevName[i]); - (new VMENU(this, DevMenu, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->setName(Text->getText(MENU_TEXT)); + DevMenu[i].Text = _text->getText(DevName[i]); + (new VMENU(this, DevMenu, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); } static void Reset(void) { - SNDDrvInfo.DBASE = SNDDrvInfo.DIRQ = SNDDrvInfo.DDMA = SNDDrvInfo.MBASE = DETECT; + _sndDrvInfo._dBase = _sndDrvInfo._dIrq = _sndDrvInfo._dDma = _sndDrvInfo._mBase = DETECT; } @@ -183,9 +183,9 @@ static CHOICE *Cho; static int Hlp; void CGEEngine::SNSelect() { - inf(Text->getText(Hlp)); - Talk->gotoxy(Talk->_x, FONT_HIG / 2); - (new VMENU(this, Cho, SCR_WID / 2, Talk->_y + Talk->_h + TEXT_VM + FONT_HIG))->setName(Text->getText(MENU_TEXT)); + inf(_text->getText(Hlp)); + _talk->gotoxy(_talk->_x, FONT_HIG / 2); + (new VMENU(this, Cho, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); } @@ -199,81 +199,81 @@ static void Select(CHOICE *cho, int hlp) { void CGEEngine::NONE() { - SNDDrvInfo.DDEV = DEV_QUIET; - SNDDrvInfo.MDEV = DEV_QUIET; + _sndDrvInfo._dDev = DEV_QUIET; + _sndDrvInfo._mDev = DEV_QUIET; _sound.Open(); } void CGEEngine::SB() { - SNDDrvInfo.DDEV = DEV_SB; - SNDDrvInfo.MDEV = DEV_SB; + _sndDrvInfo._dDev = DEV_SB; + _sndDrvInfo._mDev = DEV_SB; Reset(); Select(DigiPorts, SPORT_TEXT); } void CGEEngine::SBM() { - SNDDrvInfo.DDEV = DEV_SB; - SNDDrvInfo.MDEV = DEV_GM; + _sndDrvInfo._dDev = DEV_SB; + _sndDrvInfo._mDev = DEV_GM; Reset(); Select(DigiPorts, SPORT_TEXT); } void CGEEngine::GUS() { - SNDDrvInfo.DDEV = DEV_GUS; - SNDDrvInfo.MDEV = DEV_GUS; + _sndDrvInfo._dDev = DEV_GUS; + _sndDrvInfo._mDev = DEV_GUS; Reset(); Select(DigiPorts, SPORT_TEXT); } void CGEEngine::GUSM() { - SNDDrvInfo.DDEV = DEV_GUS; - SNDDrvInfo.MDEV = DEV_GM; + _sndDrvInfo._dDev = DEV_GUS; + _sndDrvInfo._mDev = DEV_GM; Reset(); Select(DigiPorts, SPORT_TEXT); } void CGEEngine::MIDI() { - SNDDrvInfo.DDEV = DEV_QUIET; - SNDDrvInfo.MDEV = DEV_GM; - SNDDrvInfo.MBASE = DETECT; + _sndDrvInfo._dDev = DEV_QUIET; + _sndDrvInfo._mDev = DEV_GM; + _sndDrvInfo._mBase = DETECT; Select(MIDIPorts, MPORT_TEXT); } void CGEEngine::AUTO() { - SNDDrvInfo.DDEV = DEV_AUTO; - SNDDrvInfo.MDEV = DEV_AUTO; + _sndDrvInfo._dDev = DEV_AUTO; + _sndDrvInfo._mDev = DEV_AUTO; Reset(); _sound.Open(); } void CGEEngine::setPortD() { - SNDDrvInfo.DBASE = xdeco(DigiPorts[VMENU::Recent].Text); - Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); + _sndDrvInfo._dBase = xdeco(DigiPorts[VMENU::Recent].Text); + Select((_sndDrvInfo._dDev == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); } void CGEEngine::setPortM() { - SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text); + _sndDrvInfo._mBase = xdeco(MIDIPorts[VMENU::Recent].Text); _sound.Open(); } void CGEEngine::setIRQ() { - SNDDrvInfo.DIRQ = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); - Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); + _sndDrvInfo._dIrq = ddeco(((_sndDrvInfo._dDev == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); + Select((_sndDrvInfo._dDev == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); } void CGEEngine::setDMA() { - SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); - if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) + _sndDrvInfo._dDma = ddeco(((_sndDrvInfo._dDev == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); + if (_sndDrvInfo._mDev != _sndDrvInfo._dDev) Select(MIDIPorts, MPORT_TEXT); else _sound.Open(); diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index e18890625f..97385c3ae1 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -300,7 +300,7 @@ void EventManager::handleEvents(void) { // discard Text if button released if (e._msk & (L_UP | R_UP)) - KillText(); + killText(); } EvtTail = (EvtTail + 1) % EVT_MAX; } diff --git a/engines/cge/events.h b/engines/cge/events.h index 59a62803ba..cfb1023d6b 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -80,7 +80,7 @@ public: #define KEYB 0x80 -extern TALK *Talk; +extern Talk *_talk; struct CGEEvent { uint16 _msk; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index fe94bd4598..6b0327ff23 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -92,7 +92,7 @@ Dac _stdPal[] = {// R G B { 255, 255, 255}, // 255 }; -DrvInfo SNDDrvInfo; +DrvInfo _sndDrvInfo; void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) { warning("STUB: _fqsort"); @@ -298,32 +298,32 @@ bool isVga() { return true; } -void SNDInit() { +void sndInit() { warning("STUB: SNDInit"); } -void SNDDone() { +void sndDone() { // FIXME: STUB: SNDDone } -void SNDSetVolume() { +void sndSetVolume() { warning("STUB: SNDSetVolume"); } -void SNDDigiStart(SmpInfo *PSmpInfo) { +void sndDigiStart(SmpInfo *PSmpInfo) { warning("STUB: SNDDigitStart"); } -void SNDDigiStop(SmpInfo *PSmpInfo) { +void sndDigiStop(SmpInfo *PSmpInfo) { warning("STUB: SNDDigiStop"); } -void SNDMIDIStart(uint8 *MIDFile) { +void sndMidiStart(uint8 *MIDFile) { warning("STUB: SNDMIDIStart"); } -void SNDMIDIStop() { - // FIXME: STUB: SNDMIDIStop +void sndMidiStop() { + // FIXME: STUB: sndMIDIStop } DATACK *LoadWave(XFile *file, EMM *emm) { diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index c48b281771..508175ccd5 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -35,19 +35,19 @@ GetText *GetText::_ptr = NULL; GetText::GetText(CGEEngine *vm, const char *info, char *text, int size, void (*click)()) - : TALK(vm), _text(text), _size(min(size, GTMAX)), _len(min(_size, strlen(text))), + : Talk(vm), _text(text), _size(min(size, GTMAX)), _len(min(_size, strlen(text))), _cntr(GTBLINK), _click(click), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { - int i = 2 * TEXT_HM + _Font->Width(info); + int i = 2 * TEXT_HM + _font->width(info); _ptr = this; - Mode = RECT; - TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); - setShapeList(TS); + _mode = RECT; + _ts[0] = box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); + setShapeList(_ts); _flags._bDel = true; _flags._kill = true; memcpy(_buff, text, _len); _buff[_len] = ' '; _buff[_len + 1] = '\0'; - PutLine(0, info); + putLine(0, info); tick(); } @@ -63,7 +63,7 @@ void GetText::tick() { _buff[_len] ^= (' ' ^ '_'); _cntr = 0; } - PutLine(1, _buff); + putLine(1, _buff); _time = GTTIME; } @@ -105,7 +105,7 @@ void GetText::touch(uint16 mask, int x, int y) { if (p) x = ogon[p - bezo]; } - if (_len < _size && 2 * TEXT_HM + _Font->Width(_buff) + _Font->Wid[x] <= _w) { + if (_len < _size && 2 * TEXT_HM + _font->width(_buff) + _font->_wid[x] <= _w) { _buff[_len + 2] = _buff[_len + 1]; _buff[_len + 1] = _buff[_len]; _buff[_len++] = x; diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index f743d0c66c..d29d11abb7 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -37,7 +37,7 @@ namespace CGE { #define GTBLINK 6 #define GTTIME 6 -class GetText : public TALK { +class GetText : public Talk { char _buff[GTMAX + 2]; char *_text; uint16 _size; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index e3fd2c07ed..a49f7c5c7f 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -44,7 +44,7 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _ _mb[0] = new Bitmap("VOLUME", true); _mb[1] = NULL; setShapeList(_mb); - setName(Text->getText(MIX_NAME)); + setName(_text->getText(MIX_NAME)); _flags._syst = true; _flags._kill = true; _flags._bDel = true; @@ -58,8 +58,8 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _ static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); _lb[i] = new Bitmap(fn, true); - _ls[i].Now = _ls[i].Next = i; - _ls[i].Dx = _ls[i].Dy = _ls[i].Dly = 0; + _ls[i]._now = _ls[i]._next = i; + _ls[i]._dx = _ls[i]._dy = _ls[i]._dly = 0; } _lb[i] = NULL; @@ -75,17 +75,17 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _ } _led[ArrayCount(_led) - 1]->_flags._bDel = true; - Vga->ShowQ->Insert(this); + Vga->_showQ->insert(this); for (i = 0; i < ArrayCount(_led); i++) - Vga->ShowQ->Insert(_led[i]); + Vga->_showQ->insert(_led[i]); //--- reset balance - i = (SNDDrvInfo.VOL4.ML + SNDDrvInfo.VOL4.MR) / 2; - SNDDrvInfo.VOL4.ML = i; - SNDDrvInfo.VOL4.MR = i; - i = (SNDDrvInfo.VOL4.DL + SNDDrvInfo.VOL4.DR) / 2; - SNDDrvInfo.VOL4.DL = i; - SNDDrvInfo.VOL4.DR = i; + i = (_sndDrvInfo.Vol4._ml + _sndDrvInfo.Vol4._mr) / 2; + _sndDrvInfo.Vol4._ml = i; + _sndDrvInfo.Vol4._mr = i; + i = (_sndDrvInfo.Vol4._dl + _sndDrvInfo.Vol4._dr) / 2; + _sndDrvInfo.Vol4._dl = i; + _sndDrvInfo.Vol4._dr = i; update(); _time = MIX_DELAY; } @@ -99,7 +99,7 @@ Mixer::~Mixer() { void Mixer::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); if (mask & L_UP) { - uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < _w / 2); + uint8 *vol = (&_sndDrvInfo.Vol2._d) + (x < _w / 2); if (y < MIX_BHIG) { if (*vol < 0xFF) *vol += 0x11; @@ -133,11 +133,11 @@ void Mixer::tick() { void Mixer::update(void) { - _led[0]->step(SNDDrvInfo.VOL4.ML); - _led[1]->step(SNDDrvInfo.VOL4.DL); + _led[0]->step(_sndDrvInfo.Vol4._ml); + _led[1]->step(_sndDrvInfo.Vol4._dl); //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST_(SNEXEC, -1, 0, (void*)&SNDSetVolume); + //SNPOST_(SNEXEC, -1, 0, (void*)&sndSetVolume); warning("STUB: Mixer::Update"); } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 308ffb231c..01be69386f 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -57,10 +57,10 @@ extern Sprite *_pocLight; //------------------------------------------------------------------------- // SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, // NULL, NULL, NULL, NULL, }; -// int PocPtr = 0; +// int _pocPtr = 0; //------------------------------------------------------------------------- extern Sprite *_pocket[]; -extern int PocPtr; +extern int _pocPtr; static void SNGame(Sprite *spr, int num) { switch (num) { @@ -71,7 +71,7 @@ static void SNGame(Sprite *spr, int num) { int buref = 0; int Stage = 0; - for (dup[0] = Vga->ShowQ->First(); dup[0]; dup[0] = dup[0]->_next) { + for (dup[0] = Vga->_showQ->first(); dup[0]; dup[0] = dup[0]->_next) { buref = dup[0]->_ref; if (buref / 1000 == 16 && buref % 100 == 6) { Stage = (buref / 100) % 10; @@ -79,8 +79,8 @@ static void SNGame(Sprite *spr, int num) { } } if (dup[1] == NULL) { - dup[1] = Vga->ShowQ->Locate(16003); // pan - dup[2] = Vga->ShowQ->Locate(16004); // pani + dup[1] = Vga->_showQ->locate(16003); // pan + dup[2] = Vga->_showQ->locate(16004); // pani } if (_game) { // continue game @@ -163,10 +163,10 @@ static void SNGame(Sprite *spr, int num) { static int count = 0; if (k == NULL) { - k = Vga->ShowQ->Locate(20700); - k1 = Vga->ShowQ->Locate(20701); - k2 = Vga->ShowQ->Locate(20702); - k3 = Vga->ShowQ->Locate(20703); + k = Vga->_showQ->locate(20700); + k1 = Vga->_showQ->locate(20701); + k2 = Vga->_showQ->locate(20702); + k3 = Vga->_showQ->locate(20703); } if (!_game) { // init @@ -273,13 +273,13 @@ static void SNGame(Sprite *spr, int num) { void ExpandSprite(Sprite *spr) { if (spr) - Vga->ShowQ->Insert(Vga->SpareQ->Remove(spr)); + Vga->_showQ->insert(Vga->_spareQ->remove(spr)); } void ContractSprite(Sprite *spr) { if (spr) - Vga->SpareQ->Append(Vga->ShowQ->Remove(spr)); + Vga->_spareQ->append(Vga->_showQ->remove(spr)); } int findPocket(Sprite *spr) { @@ -291,18 +291,18 @@ int findPocket(Sprite *spr) { void selectPocket(int n) { - if (n < 0 || (_pocLight->_seqPtr && PocPtr == n)) { + if (n < 0 || (_pocLight->_seqPtr && _pocPtr == n)) { _pocLight->step(0); n = findPocket(NULL); if (n >= 0) - PocPtr = n; + _pocPtr = n; } else { if (_pocket[n] != NULL) { - PocPtr = n; + _pocPtr = n; _pocLight->step(1); } } - _pocLight->gotoxy(POCKET_X + PocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); + _pocLight->gotoxy(POCKET_X + _pocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); } @@ -353,7 +353,7 @@ void feedSnail(Sprite *spr, SNLIST snq) { while (true) { if (c->_com == SNTALK) { if ((_snail->_talkEnable = (c->_val != 0)) == false) - KillText(); + killText(); } if (c->_com == SNNEXT) { Sprite *s = (c->_ref < 0) ? spr : Locate(c->_ref); @@ -441,7 +441,7 @@ void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { snc->_ptr = ptr; if (com == SNCLEAR) { _tail = _head; - KillText(); + killText(); _timerExpiry = 0; } _enable(); @@ -464,7 +464,7 @@ void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { snc->_ptr = ptr; if (com == SNCLEAR) { _tail = _head; - KillText(); + killText(); _timerExpiry = 0; } _enable(); @@ -506,10 +506,10 @@ static void SNZTrim(Sprite *spr) { Sprite *s; _heart->_enable = false; s = (spr->_flags._shad) ? spr->_prev : NULL; - Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr)); + Vga->_showQ->insert(Vga->_showQ->remove(spr)); if (s) { s->_z = spr->_z; - Vga->ShowQ->Insert(Vga->ShowQ->Remove(s), spr); + Vga->_showQ->insert(Vga->_showQ->remove(s), spr); } _heart->_enable = en; } @@ -627,7 +627,7 @@ void SNCover(Sprite *spr, int xref) { xspr->gotoxy(spr->_x, spr->_y); ExpandSprite(xspr); if ((xspr->_flags._shad = spr->_flags._shad) == 1) { - Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr->_prev), xspr); + Vga->_showQ->insert(Vga->_showQ->remove(spr->_prev), xspr); spr->_flags._shad = false; } feedSnail(xspr, NEAR); @@ -641,7 +641,7 @@ void SNUncover(Sprite *spr, Sprite *xspr) { spr->_cave = xspr->_cave; spr->gotoxy(xspr->_x, xspr->_y); if ((spr->_flags._shad = xspr->_flags._shad) == 1) { - Vga->ShowQ->Insert(Vga->ShowQ->Remove(xspr->_prev), spr); + Vga->_showQ->insert(Vga->_showQ->remove(xspr->_prev), spr); xspr->_flags._shad = false; } spr->_z = xspr->_z; @@ -716,7 +716,7 @@ void SNSlave(Sprite *spr, int ref) { SNSend(slv, spr->_cave); slv->_flags._slav = true; slv->_z = spr->_z; - Vga->ShowQ->Insert(Vga->ShowQ->Remove(slv), spr->_next); + Vga->_showQ->insert(Vga->_showQ->remove(slv), spr->_next); } } } @@ -743,13 +743,13 @@ void SNKill(Sprite *spr) { } Sprite *nx = spr->_next; Hide1(spr); - Vga->ShowQ->Remove(spr); + Vga->_showQ->remove(spr); EventManager::ClrEvt(spr); if (spr->_flags._kill) delete spr; else { spr->_cave = -1; - Vga->SpareQ->Append(spr); + Vga->_spareQ->append(spr); } if (nx) { if (nx->_flags._slav) @@ -760,7 +760,7 @@ void SNKill(Sprite *spr) { static void SNSound(Sprite *spr, int wav, int cnt) { - if (SNDDrvInfo.DDEV) { + if (_sndDrvInfo._dDev) { if (wav == -1) _sound.Stop(); else @@ -771,12 +771,12 @@ static void SNSound(Sprite *spr, int wav, int cnt) { void SNKeep(Sprite *spr, int stp) { selectPocket(-1); - if (spr && ! spr->_flags._kept && _pocket[PocPtr] == NULL) { + if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) { SNSound(spr, 3, 1); - _pocket[PocPtr] = spr; + _pocket[_pocPtr] = spr; spr->_cave = 0; spr->_flags._kept = true; - spr->gotoxy(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->_w / 2, + spr->gotoxy(POCKET_X + POCKET_DX * _pocPtr + POCKET_DX / 2 - spr->_w / 2, POCKET_Y + POCKET_DY / 2 - spr->_h / 2); if (stp >= 0) spr->step(stp); @@ -817,7 +817,7 @@ static void SNLevel(Sprite *spr, int lev) { #endif while (_lev < lev) { _lev++; - spr = Vga->SpareQ->Locate(100 + _lev); + spr = Vga->_spareQ->locate(100 + _lev); if (spr) { spr->backShow(true); spr->_cave = 0; @@ -919,11 +919,11 @@ void Snail::runCom() { _timerExpiry = 0; } else { if (_textDelay) { - KillText(); + killText(); _textDelay = false; } } - if (Talk && snc->_com != SNPAUSE) + if (_talk && snc->_com != SNPAUSE) break; } @@ -933,7 +933,7 @@ void Snail::runCom() { break; case SNPAUSE : _timerExpiry = g_system->getMillis() + snc->_val * SNAIL_FRAME_DELAY; - if (Talk) + if (_talk) _textDelay = true; break; case SNWAIT : @@ -955,13 +955,13 @@ void Snail::runCom() { if (sprel && _talkEnable) { if (sprel == Hero && sprel->seqTest(-1)) sprel->step(HTALK); - Text->Say(Text->getText(snc->_val), sprel); + _text->say(_text->getText(snc->_val), sprel); Sys->FunDel = HEROFUN0; } break; case SNINF : if (_talkEnable) { - _vm->inf(Text->getText(snc->_val)); + _vm->inf(_text->getText(snc->_val)); Sys->FunDel = HEROFUN0; } break; @@ -969,7 +969,7 @@ void Snail::runCom() { if (sprel && _talkEnable) { if (sprel == Hero && sprel->seqTest(-1)) sprel->step(HTALK); - SayTime(sprel); + sayTime(sprel); } break; case SNCAVE : diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 78d1434b40..0ea776b784 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -57,73 +57,73 @@ enum DEV_TYPE { DEV_AUTO = -1, // auto-detect mode // driver info struct DrvInfo { - DEV_TYPE DDEV; // digi device - DEV_TYPE MDEV; // midi device - uint16 DBASE; // digi base port - uint16 DDMA; // digi dma no - uint16 DIRQ; // digi irq no - uint16 MBASE; // midi base port + DEV_TYPE _dDev; // digi device + DEV_TYPE _mDev; // midi device + uint16 _dBase; // digi base port + uint16 _dDma; // digi dma no + uint16 _dIrq; // digi irq no + uint16 _mBase; // midi base port union { struct { - uint16 DR : 4; - uint16 DL : 4; - uint16 MR : 4; - uint16 ML : 4; - } VOL4; + uint16 _dr : 4; + uint16 _dl : 4; + uint16 _mr : 4; + uint16 _ml : 4; + } Vol4; struct { - uint8 D; // digi volume - uint8 M; // midi volume - } VOL2; + uint8 _d; // digi volume + uint8 _m; // midi volume + } Vol2; }; }; // sample info struct SmpInfo { - uint8 *saddr; // address - uint16 slen; // length - uint16 span; // left/right pan (0-15) - int sflag; // flag + uint8 *_saddr; // address + uint16 _slen; // length + uint16 _span; // left/right pan (0-15) + int _sflag; // flag }; // ****************************************************** // * Data * // ****************************************************** // driver info -extern DrvInfo SNDDrvInfo; +extern DrvInfo _sndDrvInfo; // midi player flag (1 means we are playing) -extern uint16 MIDIPlayFlag; +extern uint16 _midiPlayFlag; // midi song end flag (1 means we have crossed end mark) -extern uint16 MIDIEndFlag; +extern uint16 _midiEndFlag; // ****************************************************** // * Driver Code * // ****************************************************** // Init Digi Device -void SNDInit(); +void sndInit(); // Close Digi Device -void SNDDone(); +void sndDone(); // Set Volume -void SNDSetVolume(); +void sndSetVolume(); // Start Digi -void SNDDigiStart(SmpInfo *PSmpInfo); +void sndDigiStart(SmpInfo *PSmpInfo); // Stop Digi -void SNDDigiStop(SmpInfo *PSmpInfo); +void sndDigiStop(SmpInfo *PSmpInfo); // Start MIDI File -void SNDMIDIStart(uint8 *MIDFile); +void sndMidiStart(uint8 *MIDFile); // Stop MIDI File -void SNDMIDIStop(); +void sndMidiStop(); // Play MIDI File (to be called while interrupting) // WARNING: Uses ALL registers! -void SNDMIDIPlay(); +void sndMidiPlay(); } // End of namespace CGE diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 60af9f7016..aca4b4d534 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -41,7 +41,7 @@ SOUND _sound; SOUND::SOUND(void) { - if (STARTUP::SoundOk) + if (Startup::_soundOk) Open(); } @@ -53,12 +53,12 @@ SOUND::~SOUND(void) { void SOUND::Close(void) { KillMIDI(); - SNDDone(); + sndDone(); } void SOUND::Open(void) { - SNDInit(); + sndInit(); Play(_fx[30000], 8); } @@ -66,17 +66,17 @@ void SOUND::Open(void) { void SOUND::Play(DATACK *wav, int pan, int cnt) { if (wav) { Stop(); - smpinf.saddr = (uint8 *) &*(wav->EAddr()); - smpinf.slen = (uint16)wav->Size(); - smpinf.span = pan; - smpinf.sflag = cnt; - SNDDigiStart(&smpinf); + smpinf._saddr = (uint8 *) &*(wav->EAddr()); + smpinf._slen = (uint16)wav->Size(); + smpinf._span = pan; + smpinf._sflag = cnt; + sndDigiStart(&smpinf); } } void SOUND::Stop(void) { - SNDDigiStop(&smpinf); + sndDigiStop(&smpinf); } @@ -176,7 +176,7 @@ static uint8 *midi = NULL; void KillMIDI(void) { - SNDMIDIStop(); + sndMidiStop(); if (midi) { delete[] midi; midi = NULL; @@ -198,7 +198,7 @@ void LoadMIDI(int ref) { if (mid._error) KillMIDI(); else - SNDMIDIStart(midi); + sndMidiStart(midi); } } } diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 39a2b66e4b..0dfbc67916 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -33,29 +33,28 @@ namespace CGE { -extern char Copr[]; +extern char _copr[]; -#define id (*(Ident*)Copr) +#define id (*(Ident*)_copr) -EMM MiniEmm = MINI_EMM_SIZE; +EMM _miniEmm = MINI_EMM_SIZE; -static STARTUP StartUp; +// static Startup _startUp; +int Startup::_mode = 0; +int Startup::_core; +int Startup::_soundOk = 0; +uint16 Startup::_summa; -int STARTUP::Mode = 0; -int STARTUP::Core; -int STARTUP::SoundOk = 0; -uint16 STARTUP::Summa; - -void quit_now(int ref) { - error("%s", Text->getText(ref)); +void quitNow(int ref) { + error("%s", _text->getText(ref)); } -bool STARTUP::get_parms(void) { - Summa = 0; +bool Startup::getParms() { + _summa = 0; /* int i = _argc; @@ -103,12 +102,12 @@ bool STARTUP::get_parms(void) { if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; return true; */ - warning("STUB: STARTUP::get_parms"); + warning("STUB: Startup::get_parms"); return true; } -STARTUP::STARTUP(void) { +Startup::Startup() { /* uint32 m = farcoreleft() >> 10; if (m < 0x7FFF) @@ -125,21 +124,21 @@ STARTUP::STARTUP(void) { if (! get_parms()) quit_now(BAD_ARG_TEXT); //--- load sound configuration - const char * fn = UsrPath(ProgName(CFG_EXT)); - if (! STARTUP::SoundOk && CFILE::Exist(fn)) { + const char * fn = usrPath(ProgName(CFG_EXT)); + if (!Startup::_soundOk && CFILE::Exist(fn)) { CFILE cfg(fn, REA); if (! cfg.Error) { cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); if (! cfg.Error) - STARTUP::SoundOk = 1; + Startup::_soundOk = 1; } } */ - warning("STUB: STARTUP::STARTUP"); + warning("STUB: Startup::Startup"); } -const char *UsrPath(const char *nam) { +const char *usrPath(const char *nam) { static char buf[MAXPATH] = ".\\", *p = buf + 2; #if defined(CD) if (DriveCD(0)) { diff --git a/engines/cge/startup.h b/engines/cge/startup.h index a1e44cc4af..96c7388070 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -59,20 +59,20 @@ namespace CGE { #define CORE_LOW (CORE_MID - 20) -class STARTUP { - static bool get_parms(void); +class Startup { + static bool getParms(); public: - static int Mode; - static int Core; - static int SoundOk; - static uint16 Summa; - STARTUP(void); + static int _mode; + static int _core; + static int _soundOk; + static uint16 _summa; + Startup(); }; -extern EMM MiniEmm; +extern EMM _miniEmm; -const char *UsrPath(const char *nam); +const char *usrPath(const char *nam); } // End of namespace CGE diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 0abff7752c..7c0f9563a6 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -42,106 +42,106 @@ namespace CGE { //uint8 FONT::Map[MAP_SIZ]; -FONT::FONT(const char *name) { - Map = farnew(uint8, MAP_SIZ); - Pos = farnew(uint16, POS_SIZ); - Wid = farnew(uint8, WID_SIZ); - if ((Map == NULL) || (Pos == NULL) || (Wid == NULL)) +Font::Font(const char *name) { + _map = farnew(uint8, MAP_SIZ); + _pos = farnew(uint16, POS_SIZ); + _wid = farnew(uint8, WID_SIZ); + if ((_map == NULL) || (_pos == NULL) || (_wid == NULL)) error("No core"); - mergeExt(Path, name, FONT_EXT); - Load(); + mergeExt(_path, name, FONT_EXT); + load(); } -FONT::~FONT() { - free(Map); - free(Pos); - free(Wid); +Font::~Font() { + free(_map); + free(_pos); + free(_wid); } -void FONT::Load() { - INI_FILE f(Path); +void Font::load() { + INI_FILE f(_path); if (!f._error) { - f.read(Wid, WID_SIZ); + f.read(_wid, WID_SIZ); if (!f._error) { uint16 i, p = 0; for (i = 0; i < POS_SIZ; i++) { - Pos[i] = p; - p += Wid[i]; + _pos[i] = p; + p += _wid[i]; } - f.read(Map, p); + f.read(_map, p); } } } -uint16 FONT::Width(const char *text) { +uint16 Font::width(const char *text) { uint16 w = 0; if (text) while (* text) - w += Wid[(unsigned char)*(text++)]; + w += _wid[(unsigned char)*(text++)]; return w; } /* -void FONT::Save(void) { - CFILE f((const char *) Path, WRI); - if (! f.Error) { - f.Write(Wid, WID_SIZ); - if (! f.Error) - f.Write(Map, Pos[POS_SIZ - 1] + Wid[WID_SIZ - 1]); +void Font::save() { + CFILE f((const char *) _path, WRI); + if (!f._error) { + f.Write(_wid, WID_SIZ); + if (!f._error) + f.Write(_map, _pos[POS_SIZ - 1] + _wid[WID_SIZ - 1]); } } */ -TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode) - : Sprite(vm, NULL), Mode(mode), _vm(vm) { - TS[0] = TS[1] = NULL; +Talk::Talk(CGEEngine *vm, const char *tx, TBOX_STYLE mode) + : Sprite(vm, NULL), _mode(mode), _vm(vm) { + _ts[0] = _ts[1] = NULL; _flags._syst = true; - Update(tx); + update(tx); } -TALK::TALK(CGEEngine *vm) - : Sprite(vm, NULL), Mode(PURE), _vm(vm) { - TS[0] = TS[1] = NULL; +Talk::Talk(CGEEngine *vm) + : Sprite(vm, NULL), _mode(PURE), _vm(vm) { + _ts[0] = _ts[1] = NULL; _flags._syst = true; } /* -TALK::~TALK (void) { +Talk::~Talk() { for (uint16 i = 0; i < ShpCnt; i++) { - if (FP_SEG(ShpList[i]) != _DS) { // small model: always false - delete ShpList[i]; + if (FP_SEG(_shpList[i]) != _DS) { // small model: always false + delete _shpList[i]; ShpList[i] = NULL; } } } */ -FONT *TALK::_Font; +Font *Talk::_font; -void TALK::init() { - _Font = new FONT(progName()); +void Talk::init() { + _font = new Font(progName()); } -void TALK::deinit() { - delete _Font; +void Talk::deinit() { + delete _font; } -void TALK::Update(const char *tx) { - uint16 vmarg = (Mode) ? TEXT_VM : 0; - uint16 hmarg = (Mode) ? TEXT_HM : 0; +void Talk::update(const char *tx) { + uint16 vmarg = (_mode) ? TEXT_VM : 0; + uint16 hmarg = (_mode) ? TEXT_HM : 0; uint16 mw = 0, mh, ln = vmarg; const char *p; uint8 *m; - if (!TS[0]) { + if (!_ts[0]) { uint16 k = 2 * hmarg; mh = 2 * vmarg + FONT_HIG; for (p = tx; *p; p++) { @@ -151,21 +151,21 @@ void TALK::Update(const char *tx) { mw = k; k = 2 * hmarg; } else - k += _Font->Wid[(unsigned char)*p]; + k += _font->_wid[(unsigned char)*p]; } if (k > mw) mw = k; - TS[0] = Box(mw, mh); + _ts[0] = box(mw, mh); } - m = TS[0]->_m + ln * mw + hmarg; + m = _ts[0]->_m + ln * mw + hmarg; while (* tx) { if (*tx == '|' || *tx == '\n') - m = TS[0]->_m + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; + m = _ts[0]->_m + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; else { - int cw = _Font->Wid[(unsigned char)*tx], i; - uint8 *f = _Font->Map + _Font->Pos[(unsigned char)*tx]; + int cw = _font->_wid[(unsigned char)*tx], i; + uint8 *f = _font->_map + _font->_pos[(unsigned char)*tx]; for (i = 0; i < cw; i++) { uint8 *pp = m; uint16 n; @@ -181,16 +181,16 @@ void TALK::Update(const char *tx) { } tx++; } - TS[0]->code(); - setShapeList(TS); + _ts[0]->code(); + setShapeList(_ts); } -Bitmap *TALK::Box(uint16 w, uint16 h) { +Bitmap *Talk::box(uint16 w, uint16 h) { uint8 *b, * p, * q; - uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0; + uint16 n, r = (_mode == ROUND) ? TEXT_RD : 0; if (w < 8) w = 8; @@ -201,7 +201,7 @@ Bitmap *TALK::Box(uint16 w, uint16 h) { error("No core"); memset(b, TEXT_BG, n); - if (Mode) { + if (_mode) { p = b; q = b + n - w; memset(p, LGRAY, w); @@ -232,10 +232,11 @@ Bitmap *TALK::Box(uint16 w, uint16 h) { } -void TALK::PutLine(int line, const char *text) { +void Talk::putLine(int line, const char *text) { // Note: (TS[0].W % 4) have to be 0 - uint16 w = TS[0]->_w, h = TS[0]->_h; - uint8 *v = TS[0]->_v, * p; + uint16 w = _ts[0]->_w; + uint16 h = _ts[0]->_h; + uint8 *v = _ts[0]->_v, * p; uint16 dsiz = w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap uint16 psiz = h * lsiz; // - last gap, but + plane trailer @@ -262,8 +263,8 @@ void TALK::PutLine(int line, const char *text) { q = v + size; while (* text) { - uint16 cw = _Font->Wid[(unsigned char)*text], i; - uint8 *fp = _Font->Map + _Font->Pos[(unsigned char)*text]; + uint16 cw = _font->_wid[(unsigned char)*text], i; + uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text]; for (i = 0; i < cw; i++) { register uint16 b = fp[i]; @@ -284,22 +285,23 @@ void TALK::PutLine(int line, const char *text) { } -INFO_LINE::INFO_LINE(CGEEngine *vm, uint16 w) : TALK(vm), OldTxt(NULL), _vm(vm) { - TS[0] = new Bitmap(w, FONT_HIG, TEXT_BG); - setShapeList(TS); +InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldTxt(NULL), _vm(vm) { + _ts[0] = new Bitmap(w, FONT_HIG, TEXT_BG); + setShapeList(_ts); } -void INFO_LINE::Update(const char *tx) { - if (tx != OldTxt) { - uint16 w = TS[0]->_w, h = TS[0]->_h; - uint8 *v = (uint8 *) TS[0]->_v; +void InfoLine::update(const char *tx) { + if (tx != _oldTxt) { + uint16 w = _ts[0]->_w; + uint16 h = _ts[0]->_h; + uint8 *v = (uint8 *) _ts[0]->_v; uint16 dsiz = w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap uint16 psiz = h * lsiz; // - last gape, but + plane trailer uint16 size = 4 * psiz; // whole map size - // claer whole rectangle + // clear whole rectangle memset(v + 2, TEXT_BG, dsiz); // data bytes memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 @@ -310,8 +312,8 @@ void INFO_LINE::Update(const char *tx) { uint8 *p = v + 2, * q = p + size; while (*tx) { - uint16 cw = _Font->Wid[(unsigned char)*tx]; - uint8 *fp = _Font->Map + _Font->Pos[(unsigned char)*tx]; + uint16 cw = _font->_wid[(unsigned char)*tx]; + uint8 *fp = _font->_map + _font->_pos[(unsigned char)*tx]; for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; @@ -327,7 +329,7 @@ void INFO_LINE::Update(const char *tx) { tx++; } } - OldTxt = tx; + _oldTxt = tx; } } diff --git a/engines/cge/talk.h b/engines/cge/talk.h index e5e32998cb..2f70471359 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -48,53 +48,53 @@ namespace CGE { #define MAXPATH 128 -class FONT { - char Path[MAXPATH]; - void Load(void); +class Font { + char _path[MAXPATH]; + void load(); public: -// static uint8 Wid[256]; -// static uint16 Pos[256]; -// static uint8 Map[256*8]; - uint8 *Wid; - uint16 *Pos; - uint8 *Map; - FONT(const char *name); - ~FONT(void); - uint16 Width(const char *text); - void Save(void); +// static uint8 _wid[256]; +// static uint16 _pos[256]; +// static uint8 _map[256*8]; + uint8 *_wid; + uint16 *_pos; + uint8 *_map; + Font(const char *name); + ~Font(); + uint16 width(const char *text); + void save(); }; enum TBOX_STYLE { PURE, RECT, ROUND }; -class TALK : public Sprite { +class Talk : public Sprite { protected: - TBOX_STYLE Mode; - Bitmap *TS[2]; - Bitmap *Box(uint16 w, uint16 h); + TBOX_STYLE _mode; + Bitmap *_ts[2]; + Bitmap *box(uint16 w, uint16 h); public: - TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode = PURE); - TALK(CGEEngine *vm); - //~TALK (void); + Talk(CGEEngine *vm, const char *tx, TBOX_STYLE mode); + Talk(CGEEngine *vm); + //~TALK(); - static FONT *_Font; + static Font *_font; static void init(); static void deinit(); - virtual void Update(const char *tx); - virtual void Update(void) {} - void PutLine(int line, const char *text); + virtual void update(const char *tx); + virtual void update() {} + void putLine(int line, const char *text); private: CGEEngine *_vm; }; -class INFO_LINE : public TALK { - const char *OldTxt; +class InfoLine : public Talk { + const char *_oldTxt; public: - INFO_LINE(CGEEngine *vm, uint16 wid); - void Update(const char *tx); + InfoLine(CGEEngine *vm, uint16 wid); + void update(const char *tx); private: CGEEngine *_vm; }; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index e17688c6ee..f112493278 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -36,57 +36,57 @@ namespace CGE { -TEXT *Text; -TALK *Talk = NULL; - -TEXT::TEXT(CGEEngine *vm, const char *fname, int size) : _vm(vm) { - Cache = new HAN[size]; - mergeExt(FileName, fname, SAY_EXT); - if (!INI_FILE::exist(FileName)) - error("No talk (%s)\n", FileName); - - for (Size = 0; Size < size; Size++) { - Cache[Size].Ref = 0; - Cache[Size].Txt = NULL; +Text *_text; +Talk *_talk = NULL; + +Text::Text(CGEEngine *vm, const char *fname, int size) : _vm(vm) { + _cache = new Han[size]; + mergeExt(_fileName, fname, SAY_EXT); + if (!INI_FILE::exist(_fileName)) + error("No talk (%s)\n", _fileName); + + for (_size = 0; _size < size; _size++) { + _cache[_size]._ref = 0; + _cache[_size]._txt = NULL; } } -TEXT::~TEXT() { - Clear(); - delete[] Cache; +Text::~Text() { + clear(); + delete[] _cache; } -void TEXT::Clear(int from, int upto) { - HAN *p, * q; - for (p = Cache, q = p + Size; p < q; p++) { - if (p->Ref && p->Ref >= from && p->Ref < upto) { - p->Ref = 0; - delete[] p->Txt; - p->Txt = NULL; +void Text::clear(int from, int upto) { + Han *p, * q; + for (p = _cache, q = p + _size; p < q; p++) { + if (p->_ref && p->_ref >= from && p->_ref < upto) { + p->_ref = 0; + delete[] p->_txt; + p->_txt = NULL; } } } -int TEXT::Find(int ref) { - HAN *p, * q; +int Text::find(int ref) { + Han *p, * q; int i = 0; - for (p = Cache, q = p + Size; p < q; p++) { - if (p->Ref == ref) + for (p = _cache, q = p + _size; p < q; p++) { + if (p->_ref == ref) break; else - ++i; + i++; } return i; } -void TEXT::Preload(int from, int upto) { - INI_FILE tf = FileName; +void Text::preload(int from, int upto) { + INI_FILE tf = _fileName; if (!tf._error) { - HAN *CacheLim = Cache + Size; + Han *CacheLim = _cache + _size; char line[LINE_MAX + 1]; int n; @@ -102,33 +102,33 @@ void TEXT::Preload(int from, int upto) { continue; ref = atoi(s); if (ref && ref >= from && ref < upto) { - HAN *p; + Han *p; - p = &Cache[Find(ref)]; + p = &_cache[find(ref)]; if (p < CacheLim) { - delete[] p->Txt; - p->Txt = NULL; + delete[] p->_txt; + p->_txt = NULL; } else - p = &Cache[Find(0)]; + p = &_cache[find(0)]; if (p >= CacheLim) break; s += strlen(s); if (s < line + n) ++s; - if ((p->Txt = new char[strlen(s) + 1]) == NULL) + if ((p->_txt = new char[strlen(s) + 1]) == NULL) break; - p->Ref = ref; - strcpy(p->Txt, s); + p->_ref = ref; + strcpy(p->_txt, s); } } } } -char *TEXT::Load(int idx, int ref) { - INI_FILE tf = FileName; +char *Text::load(int idx, int ref) { + INI_FILE tf = _fileName; if (!tf._error) { - HAN *p = &Cache[idx]; + Han *p = &_cache[idx]; char line[LINE_MAX + 1]; int n; @@ -151,36 +151,36 @@ char *TEXT::Load(int idx, int ref) { s += strlen(s); if (s < line + n) ++s; - p->Ref = ref; - if ((p->Txt = new char[strlen(s) + 1]) == NULL) + p->_ref = ref; + if ((p->_txt = new char[strlen(s) + 1]) == NULL) return NULL; - return strcpy(p->Txt, s); + return strcpy(p->_txt, s); } } return NULL; } -char *TEXT::getText(int ref) { +char *Text::getText(int ref) { int i; - if ((i = Find(ref)) < Size) - return Cache[i].Txt; + if ((i = find(ref)) < _size) + return _cache[i]._txt; - if ((i = Find(0)) >= Size) { - Clear(SYSTXT_MAX); // clear non-system - if ((i = Find(0)) >= Size) { - Clear(); // clear all + if ((i = find(0)) >= _size) { + clear(SYSTXT_MAX); // clear non-system + if ((i = find(0)) >= _size) { + clear(); // clear all i = 0; } } - return Load(i, ref); + return load(i, ref); } -void TEXT::Say(const char *txt, Sprite *spr) { - KillText(); - Talk = new TALK(_vm, txt, ROUND); - if (Talk) { +void Text::say(const char *txt, Sprite *spr) { + killText(); + _talk = new Talk(_vm, txt, ROUND); + if (_talk) { bool east = spr->_flags._east; int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); int y = spr->_y + 2; @@ -198,43 +198,43 @@ void TEXT::Say(const char *txt, Sprite *spr) { if (spr->_ref == 1) x += ((east) ? -10 : 10); // Hero - Talk->_flags._kill = true; - Talk->_flags._bDel = true; - Talk->setName(Text->getText(SAY_NAME)); - Talk->gotoxy(x - (Talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - Talk->_h + 1); - Talk->_z = 125; - Talk->_ref = SAY_REF; + _talk->_flags._kill = true; + _talk->_flags._bDel = true; + _talk->setName(_text->getText(SAY_NAME)); + _talk->gotoxy(x - (_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _talk->_h + 1); + _talk->_z = 125; + _talk->_ref = SAY_REF; - spike->gotoxy(x, Talk->_y + Talk->_h - 1); + spike->gotoxy(x, _talk->_y + _talk->_h - 1); spike->_z = 126; spike->_flags._slav = true; spike->_flags._kill = true; - spike->setName(Text->getText(SAY_NAME)); + spike->setName(_text->getText(SAY_NAME)); spike->step(east); spike->_ref = SAY_REF; - Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); - Vga->ShowQ->Insert(spike, Vga->ShowQ->Last()); + Vga->_showQ->insert(_talk, Vga->_showQ->last()); + Vga->_showQ->insert(spike, Vga->_showQ->last()); } } void CGEEngine::inf(const char *txt) { - KillText(); - Talk = new TALK(this, txt, RECT); - if (Talk) { - Talk->_flags._kill = true; - Talk->_flags._bDel = true; - Talk->setName(Text->getText(INF_NAME)); - Talk->center(); - Talk->gotoxy(Talk->_x, Talk->_y - 20); - Talk->_z = 126; - Talk->_ref = INF_REF; - Vga->ShowQ->Insert(Talk, Vga->ShowQ->Last()); + killText(); + _talk = new Talk(this, txt, RECT); + if (_talk) { + _talk->_flags._kill = true; + _talk->_flags._bDel = true; + _talk->setName(_text->getText(INF_NAME)); + _talk->center(); + _talk->gotoxy(_talk->_x, _talk->_y - 20); + _talk->_z = 126; + _talk->_ref = INF_REF; + Vga->_showQ->insert(_talk, Vga->_showQ->last()); } } -void SayTime(Sprite *spr) { +void sayTime(Sprite *spr) { /* static char t[] = "00:00"; struct time ti; @@ -243,13 +243,13 @@ void SayTime(Sprite *spr) { wtom(ti.ti_min, t+3, 10, 2); Say((*t == '0') ? (t+1) : t, spr); */ - warning("STUB: SayTime"); + warning("STUB: sayTime"); } -void KillText(void) { - if (Talk) { - SNPOST_(SNKILL, -1, 0, Talk); - Talk = NULL; +void killText() { + if (_talk) { + SNPOST_(SNKILL, -1, 0, _talk); + _talk = NULL; } } diff --git a/engines/cge/text.h b/engines/cge/text.h index 5232084738..cf917ece61 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -51,35 +51,33 @@ namespace CGE { #define SAY_REF 302 -class TEXT { - struct HAN { - int Ref; - char *Txt; - } *Cache; - int Size; - char FileName[MAXPATH]; - char *Load(int idx, int ref); - int Find(int ref); +class Text { + struct Han { + int _ref; + char *_txt; + } *_cache; + int _size; + char _fileName[MAXPATH]; + char *load(int idx, int ref); + int find(int ref); public: - TEXT(CGEEngine *vm, const char *fname, int size); - ~TEXT(void); - void Clear(int from = 1, int upto = 0x7FFF); - void Preload(int from = 1, int upto = 0x7FFF); + Text(CGEEngine *vm, const char *fname, int size); + ~Text(); + void clear(int from = 1, int upto = 0x7FFF); + void preload(int from = 1, int upto = 0x7FFF); char *getText(int ref); - void Say(const char *txt, Sprite *spr); + void say(const char *txt, Sprite *spr); private: CGEEngine *_vm; }; +extern Talk *_talk; +extern Text *_text; -extern TALK *Talk; -extern TEXT *Text; - - -void Say(const char *txt, Sprite *spr); -void SayTime(Sprite *spr); -void Inf(const char *txt); -void KillText(void); +void say(const char *txt, Sprite *spr); +void sayTime(Sprite *spr); +void inf(const char *txt); +void killText(); } // End of namespace CGE diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 35d9688bd3..36661e756e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -187,17 +187,17 @@ Dac MkDAC(uint8 r, uint8 g, uint8 b) { Rgb MkRGB(uint8 r, uint8 g, uint8 b) { - static TRGB x; - x.dac._r = r; - x.dac._g = g; - x.dac._b = b; - return x.rgb; + static Trgb x; + x._dac._r = r; + x._dac._g = g; + x._dac._b = b; + return x._rgb; } Sprite *Locate(int ref) { - Sprite *spr = Vga->ShowQ->Locate(ref); - return (spr) ? spr : Vga->SpareQ->Locate(ref); + Sprite *spr = Vga->_showQ->locate(ref); + return (spr) ? spr : Vga->_spareQ->locate(ref); } @@ -364,7 +364,7 @@ BMP_PTR Sprite::shp() { register SprExt *e = _ext; if (e) if (e->_seq) { - int i = e->_seq[_seqPtr].Now; + int i = e->_seq[_seqPtr]._now; if (i >= _shpCnt) { //char s[256]; //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", @@ -443,7 +443,7 @@ bool Sprite::seqTest(int n) { if (n >= 0) return (_seqPtr == n); if (_ext) - return (_ext->_seq[_seqPtr].Next == _seqPtr); + return (_ext->_seq[_seqPtr]._next == _seqPtr); return true; } @@ -519,23 +519,23 @@ Sprite *Sprite::expand() { if (seq == NULL) error("No core [%s]", fname); Seq *s = &seq[seqcnt++]; - s->Now = atoi(strtok(NULL, " \t,;/")); - if (s->Now > maxnow) - maxnow = s->Now; - s->Next = atoi(strtok(NULL, " \t,;/")); - switch (s->Next) { + s->_now = atoi(strtok(NULL, " \t,;/")); + if (s->_now > maxnow) + maxnow = s->_now; + s->_next = atoi(strtok(NULL, " \t,;/")); + switch (s->_next) { case 0xFF : - s->Next = seqcnt; + s->_next = seqcnt; break; case 0xFE : - s->Next = seqcnt - 1; + s->_next = seqcnt - 1; break; } - if (s->Next > maxnxt) - maxnxt = s->Next; - s->Dx = atoi(strtok(NULL, " \t,;/")); - s->Dy = atoi(strtok(NULL, " \t,;/")); - s->Dly = atoi(strtok(NULL, " \t,;/")); + if (s->_next > maxnxt) + maxnxt = s->_next; + s->_dx = atoi(strtok(NULL, " \t,;/")); + s->_dy = atoi(strtok(NULL, " \t,;/")); + s->_dly = atoi(strtok(NULL, " \t,;/")); break; } case 3 : { // Near @@ -645,11 +645,11 @@ void Sprite::step(int nr) { if (_ext) { Seq *seq; if (nr < 0) - _seqPtr = _ext->_seq[_seqPtr].Next; + _seqPtr = _ext->_seq[_seqPtr]._next; seq = _ext->_seq + _seqPtr; - if (seq->Dly >= 0) { - gotoxy(_x + (seq->Dx), _y + (seq->Dy)); - _time = seq->Dly; + if (seq->_dly >= 0) { + gotoxy(_x + (seq->_dx), _y + (seq->_dy)); + _time = seq->_dly; } } } @@ -781,7 +781,7 @@ BMP_PTR Sprite::ghost() { Sprite *SpriteAt(int x, int y) { - Sprite *spr = NULL, * tail = Vga->ShowQ->Last(); + Sprite *spr = NULL, * tail = Vga->_showQ->last(); if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { if (! spr->_flags._hide && ! spr->_flags._tran) { @@ -794,26 +794,26 @@ Sprite *SpriteAt(int x, int y) { } -QUEUE::QUEUE(bool show) : Head(NULL), Tail(NULL), Show(show) { +Queue::Queue(bool show) : _head(NULL), _tail(NULL), _show(show) { } -QUEUE::~QUEUE(void) { - Clear(); +Queue::~Queue() { + clear(); } -void QUEUE::Clear(void) { - while (Head) { - Sprite *s = Remove(Head); +void Queue::clear() { + while (_head) { + Sprite *s = remove(_head); if (s->_flags._kill) delete s; } } -void QUEUE::ForAll(void (*fun)(Sprite *)) { - Sprite *s = Head; +void Queue::forAll(void (*fun)(Sprite *)) { + Sprite *s = _head; while (s) { Sprite *n = s->_next; fun(s); @@ -822,26 +822,26 @@ void QUEUE::ForAll(void (*fun)(Sprite *)) { } -void QUEUE::Append(Sprite *spr) { - if (Tail) { - spr->_prev = Tail; - Tail->_next = spr; +void Queue::append(Sprite *spr) { + if (_tail) { + spr->_prev = _tail; + _tail->_next = spr; } else - Head = spr; - Tail = spr; - if (Show) + _head = spr; + _tail = spr; + if (_show) spr->expand(); else spr->contract(); } -void QUEUE::Insert(Sprite *spr, Sprite *nxt) { - if (nxt == Head) { - spr->_next = Head; - Head = spr; - if (! Tail) - Tail = spr; +void Queue::insert(Sprite *spr, Sprite *nxt) { + if (nxt == _head) { + spr->_next = _head; + _head = spr; + if (!_tail) + _tail = spr; } else { spr->_next = nxt; spr->_prev = nxt->_prev; @@ -850,34 +850,34 @@ void QUEUE::Insert(Sprite *spr, Sprite *nxt) { } if (spr->_next) spr->_next->_prev = spr; - if (Show) + if (_show) spr->expand(); else spr->contract(); } -void QUEUE::Insert(Sprite *spr) { +void Queue::insert(Sprite *spr) { Sprite *s; - for (s = Head; s; s = s->_next) + for (s = _head; s; s = s->_next) if (s->_z > spr->_z) break; if (s) - Insert(spr, s); + insert(spr, s); else - Append(spr); - if (Show) + append(spr); + if (_show) spr->expand(); else spr->contract(); } -Sprite *QUEUE::Remove(Sprite *spr) { - if (spr == Head) - Head = spr->_next; - if (spr == Tail) - Tail = spr->_prev; +Sprite *Queue::remove(Sprite *spr) { + if (spr == _head) + _head = spr->_next; + if (spr == _tail) + _tail = spr->_prev; if (spr->_next) spr->_next->_prev = spr->_prev; if (spr->_prev) @@ -888,9 +888,9 @@ Sprite *QUEUE::Remove(Sprite *spr) { } -Sprite *QUEUE::Locate(int ref) { +Sprite *Queue::locate(int ref) { Sprite *spr; - for (spr = Head; spr; spr = spr->_next) { + for (spr = _head; spr; spr = spr->_next) { if (spr->_ref == ref) return spr; } @@ -925,13 +925,13 @@ VGA::VGA(int mode) Msg(NULL), Nam(NULL), SetPal(false), Mono(0) { OldColors = NULL; NewColors = NULL; - ShowQ = new QUEUE(true); - SpareQ = new QUEUE(false); + _showQ = new Queue(true); + _spareQ = new Queue(false); bool std = true; int i; for (i = 10; i < 20; i++) { - char *txt = Text->getText(i); + char *txt = _text->getText(i); if (txt) { debugN("%s", txt); std = false; @@ -981,8 +981,8 @@ VGA::~VGA(void) { debugN("%s", buffer.c_str()); } - delete ShowQ; - delete SpareQ; + delete _showQ; + delete _spareQ; } @@ -1131,12 +1131,12 @@ void VGA::Sunset(void) { void VGA::Show(void) { - Sprite *spr = ShowQ->First(); + Sprite *spr = _showQ->first(); - for (spr = ShowQ->First(); spr; spr = spr->_next) + for (spr = _showQ->first(); spr; spr = spr->_next) spr->show(); Update(); - for (spr = ShowQ->First(); spr; spr = spr->_next) + for (spr = _showQ->first(); spr; spr = spr->_next) spr->hide(); ++ FrmCnt; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index a063e40508..9e49b3d918 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -81,32 +81,32 @@ namespace CGE { struct Rgb { - uint16 r : 2; - uint16 R : 6; - uint16 g : 2; - uint16 G : 6; - uint16 b : 2; - uint16 B : 6; + uint16 _r : 2; + uint16 _R : 6; + uint16 _g : 2; + uint16 _G : 6; + uint16 _b : 2; + uint16 _B : 6; }; typedef union { - Dac dac; - Rgb rgb; -} TRGB; + Dac _dac; + Rgb _rgb; +} Trgb; struct VgaRegBlk { - uint8 idx; - uint8 adr; - uint8 clr; - uint8 set; + uint8 _idx; + uint8 _adr; + uint8 _clr; + uint8 _set; }; struct Seq { - uint8 Now; - uint8 Next; - int8 Dx; - int8 Dy; - int Dly; + uint8 _now; + uint8 _next; + int8 _dx; + int8 _dy; + int _dly; }; extern Seq _seq1[]; @@ -236,25 +236,27 @@ private: }; -class QUEUE { - Sprite *Head, * Tail; +class Queue { + Sprite *_head, *_tail; public: - bool Show; - QUEUE(bool show); - ~QUEUE(void); - void Append(Sprite *spr); - void Insert(Sprite *spr, Sprite *nxt); - void Insert(Sprite *spr); - Sprite *Remove(Sprite *spr); - void ForAll(void (*fun)(Sprite *)); - Sprite *First(void) { - return Head; + Queue(bool show); + ~Queue(); + + bool _show; + + void append(Sprite *spr); + void insert(Sprite *spr, Sprite *nxt); + void insert(Sprite *spr); + Sprite *remove(Sprite *spr); + void forAll(void (*fun)(Sprite *)); + Sprite *first() { + return _head; } - Sprite *Last(void) { - return Tail; + Sprite *last() { + return _tail; } - Sprite *Locate(int ref); - void Clear(void); + Sprite *locate(int ref); + void clear(); }; @@ -275,7 +277,8 @@ class VGA { void WaitVR(bool on); public: uint32 FrmCnt; - QUEUE *ShowQ, *SpareQ; + Queue *_showQ; + Queue *_spareQ; int Mono; static Graphics::Surface *Page[4]; static Dac *SysPal; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 8ad3848cdb..7ea32ff023 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -44,7 +44,7 @@ namespace CGE { -MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : TALK(vm), _vm(vm) { +MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; uint8 *p = farnew(uint8, i), * p1, * p2; @@ -59,8 +59,8 @@ MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : TALK(vm), _vm(vm) { p1 += w; p2 -= w; } - TS[0] = new Bitmap(w, h, p); - setShapeList(TS); + _ts[0] = new Bitmap(w, h, p); + setShapeList(_ts); _flags._slav = true; _flags._tran = true; _flags._kill = true; @@ -98,7 +98,7 @@ int VMENU::Recent = -1; VMENU::VMENU(CGEEngine *vm, CHOICE *list, int x, int y) - : TALK(vm, VMGather(list), RECT), Menu(list), Bar(NULL), _vm(vm) { + : Talk(vm, VMGather(list), RECT), Menu(list), Bar(NULL), _vm(vm) { CHOICE *cp; Addr = this; @@ -112,10 +112,10 @@ VMENU::VMENU(CGEEngine *vm, CHOICE *list, int x, int y) center(); else gotoxy(x - _w / 2, y - (TEXT_VM + FONT_HIG / 2)); - Vga->ShowQ->Insert(this, Vga->ShowQ->Last()); + Vga->_showQ->insert(this, Vga->_showQ->last()); Bar = new MENU_BAR(_vm, _w - 2 * TEXT_HM); Bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM - MB_VM); - Vga->ShowQ->Insert(Bar, Vga->ShowQ->Last()); + Vga->_showQ->insert(Bar, Vga->_showQ->last()); } diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index c2fc096e83..88a2766040 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -42,7 +42,7 @@ typedef struct { } CHOICE; -class MENU_BAR : public TALK { +class MENU_BAR : public Talk { public: MENU_BAR(CGEEngine *vm, uint16 w); private: @@ -50,7 +50,7 @@ private: }; -class VMENU : public TALK { +class VMENU : public Talk { uint16 Items; CHOICE *Menu; public: -- cgit v1.2.3 From ecad39e246475603b7ee55f7df73a77c32b60ba6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 20:20:01 +1000 Subject: CGE: Implemented code for game tick --- engines/cge/cge.h | 1 + engines/cge/cge_main.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index e4bb260bcc..ba6326726a 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -45,6 +45,7 @@ enum { class CGEEngine : public Engine { private: uint32 _lastFrame; + void tick(); public: CGEEngine(OSystem *syst, const ADGameDescription *gameDescription); ~CGEEngine(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 33abf7917d..4bb954eaed 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1537,8 +1537,21 @@ void CGEEngine::mainLoop() { millis = g_system->getMillis(); } _lastFrame = millis; + + // Dispatch the tick to any active objects + tick(); } +void CGEEngine::tick() { + for (Sprite *spr = Vga->ShowQ->First(); spr; spr = spr->_next) { + if (spr->_time) { + if (!spr->_flags._hide) { + if (--spr->_time == 0) + spr->tick(); + } + } + } +} void CGEEngine::loadUser() { // set scene -- cgit v1.2.3 From d1ef4021bc320cf1a328e58fabfbf4da60c1468e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 20:20:16 +1000 Subject: CGE: Bugfix for keyboard entry --- engines/cge/events.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 97385c3ae1..5f98cf34fb 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -126,8 +126,8 @@ void Keyboard::NewKeyboard(Common::Event &event) { _key[event.kbd.keycode] = false; } else if (event.type == Common::EVENT_KEYDOWN) { // Key press - _key[event.kbd.keycode] = true; - _current = Keyboard::_code[event.kbd.keycode]; + _key[keycode] = true; + _current = Keyboard::_code[keycode]; if (_client) { CGEEvent &evt = Evt[EvtHead]; -- cgit v1.2.3 From 665b12ff8dfac9fc1d8fb97f80327e3bdcd20fb6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 20:23:19 +1000 Subject: CGE: Compilation fix after merge --- engines/cge/cge_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4bb954eaed..a2209e72e9 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1543,7 +1543,7 @@ void CGEEngine::mainLoop() { } void CGEEngine::tick() { - for (Sprite *spr = Vga->ShowQ->First(); spr; spr = spr->_next) { + for (Sprite *spr = Vga->_showQ->first(); spr; spr = spr->_next) { if (spr->_time) { if (!spr->_flags._hide) { if (--spr->_time == 0) -- cgit v1.2.3 From c313d2cce8d647265f192400c667d72824874dbc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 3 Jul 2011 16:22:26 +0200 Subject: CGE: Even more renaming (WIP) --- engines/cge/cge.cpp | 20 ++-- engines/cge/cge_main.cpp | 278 +++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 6 +- engines/cge/config.cpp | 74 ++++++------- engines/cge/events.cpp | 6 +- engines/cge/game.cpp | 8 +- engines/cge/jbw.h | 4 +- engines/cge/mixer.cpp | 6 +- engines/cge/snail.cpp | 112 +++++++++---------- engines/cge/text.cpp | 6 +- engines/cge/vga13h.cpp | 198 ++++++++++++++++----------------- engines/cge/vga13h.h | 87 +++++++-------- engines/cge/vmenu.cpp | 58 +++++----- engines/cge/vmenu.h | 26 ++--- engines/cge/vol.cpp | 34 +++--- engines/cge/vol.h | 24 ++-- 16 files changed, 474 insertions(+), 473 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 6eae8f3c0e..0487441517 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -58,17 +58,17 @@ void CGEEngine::setup() { _console = new CGEConsole(this); // Initialise classes that have static members - VGA::init(); - VFILE::init(); + Vga::init(); + VFile::init(); Bitmap::init(); Talk::init(); // Initialise engine objects _text = new Text(this, progName(), 128); - Vga = new VGA(M13H); + _vga = new Vga(M13H); _heart = new Heart; - Hero = new WALK(this, NULL); - Sys = new SYSTEM(this); + _hero = new WALK(this, NULL); + _sys = new SYSTEM(this); _pocLight = new Sprite(this, LI); for (int i = 0; i < POCKET_NX; i++) _pocket[i] = new Sprite(this, NULL); @@ -111,8 +111,8 @@ CGEEngine::~CGEEngine() { // Call classes with static members to clear them up Talk::deinit(); Bitmap::deinit(); - VFILE::deinit(); - VGA::deinit(); + VFile::deinit(); + Vga::deinit(); // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); @@ -147,9 +147,9 @@ CGEEngine::~CGEEngine() { delete _pocket[i]; delete _snail; delete _snail_; - delete Hero; - delete Vga; - delete Sys; + delete _hero; + delete _vga; + delete _sys; } Common::Error CGEEngine::run() { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index a2209e72e9..2caa9e0a98 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -55,10 +55,10 @@ namespace CGE { uint16 _stklen = (STACK_SIZ * 2); -VGA *Vga; +Vga *_vga; Heart *_heart; -WALK *Hero; -SYSTEM *Sys; +WALK *_hero; +SYSTEM *_sys; Sprite *_pocLight; EventManager *_eventManager; Keyboard *_keyboard; @@ -252,12 +252,12 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { if (spr == NULL) error("No core"); *spr = S; - Vga->_spareQ->append(spr); + _vga->_spareQ->append(spr); } for (i = 0; i < POCKET_NX; i++) { register int r = _pocref[i]; - _pocket[i] = (r < 0) ? NULL : Vga->_spareQ->locate(r); + _pocket[i] = (r < 0) ? NULL : _vga->_spareQ->locate(r); } } } @@ -291,7 +291,7 @@ static void SaveGame(XFile &file) { file.write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); - for (spr = Vga->_spareQ->first(); spr; spr = spr->_next) + for (spr = _vga->_spareQ->first(); spr; spr = spr->_next) if (spr->_ref >= 1000) if (!file._error) file.write((uint8 *)spr, sizeof(*spr)); @@ -304,12 +304,12 @@ static void HeroCover(int cvr) { static void trouble(int seq, int txt) { - Hero->park(); - SNPOST(SNWAIT, -1, -1, Hero); - SNPOST(SNSEQ, -1, seq, Hero); - SNPOST(SNSOUND, -1, 2, Hero); - SNPOST(SNWAIT, -1, -1, Hero); - SNPOST(SNSAY, 1, txt, Hero); + _hero->park(); + SNPOST(SNWAIT, -1, -1, _hero); + SNPOST(SNSEQ, -1, seq, _hero); + SNPOST(SNSOUND, -1, 2, _hero); + SNPOST(SNWAIT, -1, -1, _hero); + SNPOST(SNSAY, 1, txt, _hero); } @@ -366,8 +366,8 @@ void WALK::tick() { if (Dir != NO_DIR) { Sprite *spr; - Sys->FunTouch(); - for (spr = Vga->_showQ->first(); spr; spr = spr->_next) { + _sys->FunTouch(); + for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (distance(spr) < 2) { if (!spr->_flags._near) { feedSnail(spr, NEAR); @@ -495,7 +495,7 @@ bool WALK::lower(Sprite *spr) { void WALK::reach(Sprite *spr, int mode) { if (spr) { - Hero->findWay(spr); + _hero->findWay(spr); if (mode < 0) { mode = spr->_flags._east; if (lower(spr)) @@ -506,7 +506,7 @@ void WALK::reach(Sprite *spr, int mode) { SNINSERT(SNPAUSE, -1, 64, NULL); SNINSERT(SNSEQ, -1, TSEQ + mode, this); if (spr) { - SNINSERT(SNWAIT, -1, -1, Hero); /////--------$$$$$$$ + SNINSERT(SNWAIT, -1, -1, _hero); /////--------$$$$$$$ //SNINSERT(SNWALK, -1, -1, spr); } // sequence is not finished, @@ -548,12 +548,12 @@ void CGEEngine::setMapBrick(int x, int z) { wtom(z, n + 3, 10, 2); Cluster::_map[z][x] = 1; s->setName(n); - Vga->_showQ->insert(s, Vga->_showQ->first()); + _vga->_showQ->insert(s, _vga->_showQ->first()); } } static void SwitchColorMode(void); -static void SwitchDebug(void); +static void switchDebug(); static void SwitchMusic(void); static void KillSprite(void); static void PushSprite(void); @@ -573,20 +573,20 @@ void CGEEngine::resetQSwitch() { void CGEEngine::quit() { - static CHOICE QuitMenu[] = { + static Choice QuitMenu[] = { { NULL, &CGEEngine::startCountDown }, { NULL, &CGEEngine::resetQSwitch }, { NULL, &CGEEngine::dummy } }; - if (_snail->idle() && ! Hero->_flags._hide) { - if (VMENU::Addr) { - SNPOST_(SNKILL, -1, 0, VMENU::Addr); + if (_snail->idle() && !_hero->_flags._hide) { + if (Vmenu::_addr) { + SNPOST_(SNKILL, -1, 0, Vmenu::_addr); resetQSwitch(); } else { - QuitMenu[0].Text = _text->getText(QUIT_TEXT); - QuitMenu[1].Text = _text->getText(NOQUIT_TEXT); - (new VMENU(this, QuitMenu, -1, -1))->setName(_text->getText(QUIT_TITLE)); + QuitMenu[0]._text = _text->getText(QUIT_TEXT); + QuitMenu[1]._text = _text->getText(NOQUIT_TEXT); + (new Vmenu(this, QuitMenu, -1, -1))->setName(_text->getText(QUIT_TITLE)); SNPOST_(SNSEQ, 123, 1, NULL); KeyClick(); } @@ -595,7 +595,7 @@ void CGEEngine::quit() { static void AltCtrlDel() { - SNPOST_(SNSAY, -1, A_C_D_TEXT, Hero); + SNPOST_(SNSAY, -1, A_C_D_TEXT, _hero); } // Used in stubbed function, do not remove! @@ -622,7 +622,7 @@ static void PostMiniStep(int stp) { void SYSTEM::SetPal(void) { uint i; - Dac *p = VGA::SysPal + 256 - ArrayCount(_stdPal); + Dac *p = Vga::_sysPal + 256 - ArrayCount(_stdPal); for (i = 0; i < ArrayCount(_stdPal); i++) { p[i]._r = _stdPal[i]._r >> 2; p[i]._g = _stdPal[i]._g >> 2; @@ -639,14 +639,14 @@ void SYSTEM::FunTouch(void) { static void ShowBak(int ref) { - Sprite *spr = Vga->_spareQ->locate(ref); + Sprite *spr = _vga->_spareQ->locate(ref); if (spr) { - Bitmap::_pal = VGA::SysPal; + Bitmap::_pal = Vga::_sysPal; spr->expand(); Bitmap::_pal = NULL; spr->show(2); - Vga->CopyPage(1, 2); - Sys->SetPal(); + _vga->copyPage(1, 2); + _sys->SetPal(); spr->contract(); } } @@ -660,7 +660,7 @@ static void caveUp() { ShowBak(BakRef); loadMapping(); _text->preload(BakRef, BakRef + 1000); - Sprite *spr = Vga->_spareQ->first(); + Sprite *spr = _vga->_spareQ->first(); while (spr) { Sprite *n = spr->_next; if (spr->_cave == _now || spr->_cave == 0) @@ -679,33 +679,33 @@ static void caveUp() { _fx.Preload(BakRef); } - if (Hero) { - Hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); + if (_hero) { + _hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); // following 2 lines trims Hero's Z position! - Hero->tick(); - Hero->_time = 1; - Hero->_flags._hide = false; + _hero->tick(); + _hero->_time = 1; + _hero->_flags._hide = false; } if (!_dark) - Vga->Sunset(); + _vga->sunset(); - Vga->CopyPage(0, 1); + _vga->copyPage(0, 1); selectPocket(-1); - if (Hero) - Vga->_showQ->insert(Vga->_showQ->remove(Hero)); + if (_hero) + _vga->_showQ->insert(_vga->_showQ->remove(_hero)); if (_shadow) { - Vga->_showQ->remove(_shadow); - _shadow->makeXlat(glass(VGA::SysPal, 204, 204, 204)); - Vga->_showQ->insert(_shadow, Hero); - _shadow->_z = Hero->_z; + _vga->_showQ->remove(_shadow); + _shadow->makeXlat(glass(Vga::_sysPal, 204, 204, 204)); + _vga->_showQ->insert(_shadow, _hero); + _shadow->_z = _hero->_z; } - feedSnail(Vga->_showQ->locate(BakRef + 999), TAKE); - Vga->Show(); - Vga->CopyPage(1, 0); - Vga->Show(); - Vga->Sunrise(VGA::SysPal); + feedSnail(_vga->_showQ->locate(BakRef + 999), TAKE); + _vga->show(); + _vga->copyPage(1, 0); + _vga->show(); + _vga->sunrise(Vga::_sysPal); _dark = false; if (!_startup) _mouse->On(); @@ -719,12 +719,12 @@ void CGEEngine::caveDown() { if (!_horzLine->_flags._hide) switchMapping(); - for (spr = Vga->_showQ->first(); spr;) { + for (spr = _vga->_showQ->first(); spr;) { Sprite *n = spr->_next; if (spr->_ref >= 1000 /*&& spr->_cave*/) { if (spr->_ref % 1000 == 999) feedSnail(spr, TAKE); - Vga->_spareQ->append(Vga->_showQ->remove(spr)); + _vga->_spareQ->append(_vga->_showQ->remove(spr)); } spr = n; } @@ -744,7 +744,7 @@ void CGEEngine::qGame() { SaveSound(); CFile file = CFile(usrPath(_usrFnam), WRI, RCrypt); SaveGame(file); - Vga->Sunset(); + _vga->sunset(); _finis = true; } @@ -760,12 +760,12 @@ void CGEEngine::switchCave(int cav) { } else { _now = cav; _mouse->Off(); - if (Hero) { - Hero->park(); - Hero->step(0); + if (_hero) { + _hero->park(); + _hero->step(0); if (!_isDemo) ///// protection: auto-destruction on! ---------------------- - Vga->_spareQ->_show = Startup::_summa * (cav <= CAVE_MAX); + _vga->_spareQ->_show = Startup::_summa * (cav <= CAVE_MAX); /////-------------------------------------------------------- } _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, @@ -810,7 +810,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { break; case 'F': if (_keyboard->_key[ALT]) { - Sprite *m = Vga->_showQ->locate(17001); + Sprite *m = _vga->_showQ->locate(17001); if (m) { m->step(1); m->_time = 216; // 3s @@ -833,28 +833,28 @@ void SYSTEM::touch(uint16 mask, int x, int y) { _vm->switchMapping(); break; case F1: - SwitchDebug(); + switchDebug(); break; case F3: - Hero->step(TSEQ + 4); + _hero->step(TSEQ + 4); break; case F4: - Hero->step(TSEQ + 5); + _hero->step(TSEQ + 5); break; case F5: - Hero->step(TSEQ + 0); + _hero->step(TSEQ + 0); break; case F6: - Hero->step(TSEQ + 1); + _hero->step(TSEQ + 1); break; case F7: - Hero->step(TSEQ + 2); + _hero->step(TSEQ + 2); break; case F8: - Hero->step(TSEQ + 3); + _hero->step(TSEQ + 3); break; case F9: - Sys->FunDel = 1; + _sys->FunDel = 1; break; case 'X': if (_keyboard->_key[ALT]) @@ -878,16 +878,16 @@ void SYSTEM::touch(uint16 mask, int x, int y) { _sprite->step(x - '0'); break; case F10 : - if (_snail->idle() && ! Hero->_flags._hide) + if (_snail->idle() && !_hero->_flags._hide) _vm->startCountDown(); break; case 'J': if (pp == 0) - ++pp; + pp++; break; case 'B': if (pp == 1) - ++pp; + pp++; break; case 'W': if (pp == 2) @@ -923,7 +923,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { PostMiniStep(cav - 1); if (mask & L_UP) { - if (cav && _snail->idle() && Hero->_tracePtr < 0) + if (cav && _snail->idle() && _hero->_tracePtr < 0) _vm->switchCave(cav); if (!_horzLine->_flags._hide) { @@ -935,9 +935,9 @@ void SYSTEM::touch(uint16 mask, int x, int y) { } } else { - if (!_talk && _snail->idle() && Hero + if (!_talk && _snail->idle() && _hero && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_game) { - Hero->findWay(XZ(x, y)); + _hero->findWay(XZ(x, y)); } } } @@ -955,7 +955,7 @@ void SYSTEM::Tick(void) { else if (Startup::_core >= CORE_MID) { int n = new_random(100); if (n > 96) - HeroCover(6 + (Hero->_x + Hero->_w / 2 < SCR_WID / 2)); + HeroCover(6 + (_hero->_x + _hero->_w / 2 < SCR_WID / 2)); else { if (n > 90) HeroCover(5); @@ -994,17 +994,17 @@ static void SpkClose(void) { static void SwitchColorMode(void) { - SNPOST_(SNSEQ, 121, Vga->Mono = !Vga->Mono, NULL); + SNPOST_(SNSEQ, 121, _vga->_mono = !_vga->_mono, NULL); KeyClick(); - Vga->SetColors(VGA::SysPal, 64); + _vga->setColors(Vga::_sysPal, 64); } static void SwitchMusic(void) { if (_keyboard->_key[ALT]) { - if (VMENU::Addr) - SNPOST_(SNKILL, -1, 0, VMENU::Addr); + if (Vmenu::_addr) + SNPOST_(SNKILL, -1, 0, Vmenu::_addr); else { SNPOST_(SNSEQ, 122, (_music = false), NULL); //TODO Change the SNPOST message send to a special way to send function pointer @@ -1042,7 +1042,7 @@ void CGEEngine::takeName() { tn->center(); tn->gotoxy(tn->_x, tn->_y - 10); tn->_z = 126; - Vga->_showQ->insert(tn); + _vga->_showQ->insert(tn); } } } @@ -1060,7 +1060,7 @@ void CGEEngine::switchMapping() { } } else { Sprite *s; - for (s = Vga->_showQ->first(); s; s = s->_next) + for (s = _vga->_showQ->first(); s; s = s->_next) if (s->_w == MAP_XGRID && s->_h == MAP_ZGRID) SNPOST_(SNKILL, -1, 0, s); } @@ -1079,7 +1079,7 @@ static void KillSprite(void) { static void PushSprite(void) { Sprite *spr = _sprite->_prev; if (spr) { - Vga->_showQ->insert(Vga->_showQ->remove(_sprite), spr); + _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); while (_sprite->_z > _sprite->_next->_z) _sprite->_z--; } else @@ -1096,7 +1096,7 @@ static void PullSprite(void) { ok = (!spr->_flags._slav); } if (ok) { - Vga->_showQ->insert(Vga->_showQ->remove(_sprite), spr); + _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); if (_sprite->_prev) while (_sprite->_z < _sprite->_prev->_z) _sprite->_z++; @@ -1121,8 +1121,8 @@ static void SaveMapping() { { IoHand cf(progName(".HXY"), WRI); if (!cf._error) { - _heroXY[_now - 1]._x = Hero->_x; - _heroXY[_now - 1]._y = Hero->_y; + _heroXY[_now - 1]._x = _hero->_x; + _heroXY[_now - 1]._y = _hero->_y; cf.write((uint8 *) _heroXY, sizeof(_heroXY)); } } @@ -1156,7 +1156,7 @@ static void sayDebug() { if (t1 - t >= 18) { static uint32 old = 0L; - uint32 now = Vga->FrmCnt; + uint32 now = _vga->_frmCnt; dwtom(now - old, FRPS, 10, 4); old = now; t = t1; @@ -1170,7 +1170,7 @@ static void sayDebug() { // sprite queue size uint16 n = 0; Sprite *spr; - for (spr = Vga->_showQ->first(); spr; spr = spr->_next) { + for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { ++ n; if (spr == _sprite) { *XSPR = ' '; @@ -1190,7 +1190,7 @@ static void sayDebug() { } -static void SwitchDebug(void) { +static void switchDebug() { _debugLine->_flags._hide = !_debugLine->_flags._hide; } @@ -1220,7 +1220,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { #pragma argsused void Sprite::touch(uint16 mask, int x, int y) { - Sys->FunTouch(); + _sys->FunTouch(); if ((mask & ATTN) == 0) { _infoLine->update(name()); if (mask & (R_DN | L_DN)) @@ -1238,7 +1238,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if ((mask & R_UP) && _snail->idle()) { Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_pocPtr] : NULL; if (ps) { - if (_flags._kept || Hero->distance(this) < MAX_DISTANCE) { + if (_flags._kept || _hero->distance(this) < MAX_DISTANCE) { if (works(ps)) { feedSnail(ps, TAKE); } else @@ -1250,7 +1250,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if (_flags._kept) mask |= L_UP; else { - if (Hero->distance(this) < MAX_DISTANCE) { + if (_hero->distance(this) < MAX_DISTANCE) { /// if (_flags._port) { if (findPocket(NULL) < 0) @@ -1369,9 +1369,9 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int WALK *w = new WALK(this, NULL); if (w && ref == 1) { w->gotoxy(col, row); - if (Hero) + if (_hero) error("2nd HERO [%s]", fname); - Hero = w; + _hero = w; } _sprite = w; break; @@ -1440,7 +1440,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int *p = '\0'; _sprite->_shpCnt = shpcnt; - Vga->_spareQ->append(_sprite); + _vga->_spareQ->append(_sprite); } } @@ -1522,7 +1522,7 @@ void CGEEngine::mainLoop() { //FIXME: tc = TimerCount; } } - Vga->Show(); + _vga->show(); _snail_->runCom(); _snail->runCom(); @@ -1543,7 +1543,7 @@ void CGEEngine::mainLoop() { } void CGEEngine::tick() { - for (Sprite *spr = Vga->_showQ->first(); spr; spr = spr->_next) { + for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (spr->_time) { if (!spr->_flags._hide) { if (--spr->_time == 0) @@ -1583,7 +1583,7 @@ void CGEEngine::runGame() { loadHeroXY(); _cavLight->_flags._tran = true; - Vga->_showQ->append(_cavLight); + _vga->_showQ->append(_cavLight); _cavLight->_flags._hide = true; static Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, @@ -1598,7 +1598,7 @@ void CGEEngine::runGame() { _pocLight->_flags._tran = true; _pocLight->_time = 1; _pocLight->_z = 120; - Vga->_showQ->append(_pocLight); + _vga->_showQ->append(_pocLight); selectPocket(-1); // FIXME: Allow ScummVM to handle mouse display @@ -1608,9 +1608,9 @@ void CGEEngine::runGame() { loadUser(); // ~~~~~~~~~~~ - if ((_sprite = Vga->_spareQ->locate(121)) != NULL) - SNPOST_(SNSEQ, -1, Vga->Mono, _sprite); - if ((_sprite = Vga->_spareQ->locate(122)) != NULL) + if ((_sprite = _vga->_spareQ->locate(121)) != NULL) + SNPOST_(SNSEQ, -1, _vga->_mono, _sprite); + if ((_sprite = _vga->_spareQ->locate(122)) != NULL) _sprite->step(_music); SNPOST_(SNSEQ, -1, _music, _sprite); if (!_music) @@ -1631,16 +1631,16 @@ void CGEEngine::runGame() { } } - if (Hero) { - ExpandSprite(Hero); - Hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); + if (_hero) { + ExpandSprite(_hero); + _hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); if (INI_FILE::exist("00SHADOW.SPR")) { - loadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51); + loadSprite("00SHADOW", -1, 0, _hero->_x + 14, _hero->_y + 51); if ((_shadow = _sprite) != NULL) { _shadow->_ref = 2; _shadow->_flags._tran = true; - Hero->_flags._shad = true; - Vga->_showQ->insert(Vga->_spareQ->remove(_shadow), Hero); + _hero->_flags._shad = true; + _vga->_showQ->insert(_vga->_spareQ->remove(_shadow), _hero); } } } @@ -1648,16 +1648,16 @@ void CGEEngine::runGame() { _infoLine->gotoxy(INFO_X, INFO_Y); _infoLine->_flags._tran = true; _infoLine->update(NULL); - Vga->_showQ->insert(_infoLine); + _vga->_showQ->insert(_infoLine); _debugLine->_z = 126; - Vga->_showQ->insert(_debugLine); + _vga->_showQ->insert(_debugLine); _horzLine->_y = MAP_TOP - (MAP_TOP > 0); _horzLine->_z = 126; - Vga->_showQ->insert(_horzLine); + _vga->_showQ->insert(_horzLine); - _mouse->Busy = Vga->_spareQ->locate(BUSY_REF); + _mouse->Busy = _vga->_spareQ->locate(BUSY_REF); if (_mouse->Busy) ExpandSprite(_mouse->Busy); @@ -1668,7 +1668,7 @@ void CGEEngine::runGame() { CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); caveUp(); - _keyboard->setClient(Sys); + _keyboard->setClient(_sys); // main loop while (!_finis && !_eventManager->_quitFlag) { //TODO Change the SNPOST message send to a special way to send function pointer @@ -1682,9 +1682,9 @@ void CGEEngine::runGame() { SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); _mouse->Off(); - Vga->_showQ->clear(); - Vga->_spareQ->clear(); - Hero = NULL; + _vga->_showQ->clear(); + _vga->_spareQ->clear(); + _hero = NULL; _shadow = NULL; } @@ -1696,14 +1696,14 @@ void CGEEngine::movie(const char *ext) { const char *fn = progName(ext); if (INI_FILE::exist(fn)) { loadScript(fn); - ExpandSprite(Vga->_spareQ->locate(999)); - feedSnail(Vga->_showQ->locate(999), TAKE); + ExpandSprite(_vga->_spareQ->locate(999)); + feedSnail(_vga->_showQ->locate(999), TAKE); // FIXME: Allow ScummVM to handle mouse display //Vga->ShowQ->Append(Mouse); _heart->_enable = true; - _keyboard->setClient(Sys); + _keyboard->setClient(_sys); while (!_snail->idle() && !_eventManager->_quitFlag) mainLoop(); @@ -1711,8 +1711,8 @@ void CGEEngine::movie(const char *ext) { _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); - Vga->_showQ->clear(); - Vga->_spareQ->clear(); + _vga->_showQ->clear(); + _vga->_spareQ->clear(); } } @@ -1721,7 +1721,7 @@ bool CGEEngine::showTitle(const char *name) { if (_eventManager->_quitFlag) return false; - Bitmap::_pal = VGA::SysPal; + Bitmap::_pal = Vga::_sysPal; BMP_PTR LB[] = { new Bitmap(name, true), NULL }; Bitmap::_pal = NULL; bool usr_ok = false; @@ -1737,19 +1737,19 @@ bool CGEEngine::showTitle(const char *name) { _talk->show(2); } - Vga->Sunset(); - Vga->CopyPage(1, 2); - Vga->CopyPage(0, 1); + _vga->sunset(); + _vga->copyPage(1, 2); + _vga->copyPage(0, 1); selectPocket(-1); - Vga->Sunrise(VGA::SysPal); + _vga->sunrise(Vga::_sysPal); if (Startup::_mode < 2 && !Startup::_soundOk) { - Vga->CopyPage(1, 2); - Vga->CopyPage(0, 1); - Vga->_showQ->append(_mouse); + _vga->copyPage(1, 2); + _vga->copyPage(0, 1); + _vga->_showQ->append(_mouse); _heart->_enable = true; _mouse->On(); - for (selectSound(); !_snail->idle() || VMENU::Addr;) { + for (selectSound(); !_snail->idle() || Vmenu::_addr;) { mainLoop(); if (_eventManager->_quitFlag) return false; @@ -1757,8 +1757,8 @@ bool CGEEngine::showTitle(const char *name) { _mouse->Off(); _heart->_enable = false; - Vga->_showQ->clear(); - Vga->CopyPage(0, 2); + _vga->_showQ->clear(); + _vga->copyPage(0, 2); Startup::_soundOk = 2; if (_music) LoadMIDI(0); @@ -1779,9 +1779,9 @@ bool CGEEngine::showTitle(const char *name) { #endif //----------------------------------------- movie("X00"); // paylist - Vga->CopyPage(1, 2); - Vga->CopyPage(0, 1); - Vga->_showQ->append(_mouse); + _vga->copyPage(1, 2); + _vga->copyPage(0, 1); + _vga->_showQ->append(_mouse); //Mouse.On(); _heart->_enable = true; for (takeName(); GetText::_ptr;) { @@ -1795,8 +1795,8 @@ bool CGEEngine::showTitle(const char *name) { if (usr_ok) strcat(_usrFnam, SVG_EXT); //Mouse.Off(); - Vga->_showQ->clear(); - Vga->CopyPage(0, 2); + _vga->_showQ->clear(); + _vga->copyPage(0, 2); #endif } @@ -1805,8 +1805,8 @@ bool CGEEngine::showTitle(const char *name) { if (CFile::exist(n)) { CFile file = CFile(n, REA, RCrypt); loadGame(file, true); // only system vars - Vga->SetColors(VGA::SysPal, 64); - Vga->Update(); + _vga->setColors(Vga::_sysPal, 64); + _vga->update(); if (FINIS) { Startup::_mode++; FINIS = false; @@ -1819,7 +1819,7 @@ bool CGEEngine::showTitle(const char *name) { if (Startup::_mode < 2) movie("X01"); // wink - Vga->CopyPage(0, 2); + _vga->copyPage(0, 2); if (_isDemo) return true; @@ -1854,7 +1854,7 @@ void CGEEngine::cge_main(void) { _horzLine->_flags._hide = true; //srand((uint16) Timer()); - Sys = new SYSTEM(this); + _sys = new SYSTEM(this); if (_music && Startup::_soundOk) LoadMIDI(0); @@ -1869,7 +1869,7 @@ void CGEEngine::cge_main(void) { if (FINIS) movie("X03"); } else - Vga->Sunset(); + _vga->sunset(); } } // End of namespace CGE diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 0684a886e5..c5be2adc26 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -166,10 +166,10 @@ Cluster XZ(Couple xy); void ExpandSprite(Sprite *spr); void ContractSprite(Sprite *spr); -extern WALK *Hero; -extern VGA *Vga; +extern WALK *_hero; +extern Vga *_vga; extern Heart *_heart; -extern SYSTEM *Sys; +extern SYSTEM *_sys; extern int _offUseCount; extern Sprite *_pocLight; extern Keyboard *_keyboard; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index f32c3b7195..8812207371 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -64,7 +64,7 @@ static int DevName[] = { MIDI_TEXT, AUTO_TEXT }; -static CHOICE DevMenu[] = { +static Choice DevMenu[] = { { NULL, &CGEEngine::NONE }, { NULL, &CGEEngine::SB }, { NULL, &CGEEngine::SBM }, @@ -76,7 +76,7 @@ static CHOICE DevMenu[] = { }; -static CHOICE DigiPorts[] = { +static Choice DigiPorts[] = { { " 210h", &CGEEngine::setPortD }, { " 220h", &CGEEngine::setPortD }, { " 230h", &CGEEngine::setPortD }, @@ -87,7 +87,7 @@ static CHOICE DigiPorts[] = { { NULL, NULL } }; -static CHOICE MIDIPorts[] = { +static Choice MIDIPorts[] = { { " 220h", &CGEEngine::setPortM }, { " 230h", &CGEEngine::setPortM }, { " 240h", &CGEEngine::setPortM }, @@ -102,7 +102,7 @@ static CHOICE MIDIPorts[] = { { NULL, NULL } }; -static CHOICE BlsterIRQ[] = { +static Choice BlsterIRQ[] = { { "IRQ 2", &CGEEngine::setIRQ }, { "IRQ 5", &CGEEngine::setIRQ }, { "IRQ 7", &CGEEngine::setIRQ }, @@ -111,7 +111,7 @@ static CHOICE BlsterIRQ[] = { { NULL, NULL } }; -static CHOICE GravisIRQ[] = { +static Choice GravisIRQ[] = { { "IRQ 2", &CGEEngine::setIRQ }, { "IRQ 5", &CGEEngine::setIRQ }, { "IRQ 7", &CGEEngine::setIRQ }, @@ -122,7 +122,7 @@ static CHOICE GravisIRQ[] = { { NULL, NULL } }; -static CHOICE GravisDMA[] = { +static Choice GravisDMA[] = { { "DMA 1", &CGEEngine::setDMA }, { "DMA 3", &CGEEngine::setDMA }, { "DMA 5", &CGEEngine::setDMA }, @@ -132,7 +132,7 @@ static CHOICE GravisDMA[] = { { NULL, NULL } }; -static CHOICE BlsterDMA[] = { +static Choice BlsterDMA[] = { { "DMA 0", &CGEEngine::setDMA }, { "DMA 1", &CGEEngine::setDMA }, { "DMA 3", &CGEEngine::setDMA }, @@ -144,17 +144,17 @@ static CHOICE BlsterDMA[] = { void CGEEngine::selectSound() { int i; _sound.Close(); - if (VMENU::Addr) - SNPOST_(SNKILL, -1, 0, VMENU::Addr); + if (Vmenu::_addr) + SNPOST_(SNKILL, -1, 0, Vmenu::_addr); inf(_text->getText(STYPE_TEXT)); _talk->gotoxy(_talk->_x, FONT_HIG / 2); for (i = 0; i < (int)ArrayCount(DevName); i++) - DevMenu[i].Text = _text->getText(DevName[i]); - (new VMENU(this, DevMenu, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); + DevMenu[i]._text = _text->getText(DevName[i]); + (new Vmenu(this, DevMenu, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); } -static void Reset(void) { +static void reset(void) { _sndDrvInfo._dBase = _sndDrvInfo._dIrq = _sndDrvInfo._dDma = _sndDrvInfo._mBase = DETECT; } @@ -179,22 +179,22 @@ static uint16 xdeco(const char *str) { } -static CHOICE *Cho; -static int Hlp; +static Choice *_cho; +static int _hlp; void CGEEngine::SNSelect() { - inf(_text->getText(Hlp)); + inf(_text->getText(_hlp)); _talk->gotoxy(_talk->_x, FONT_HIG / 2); - (new VMENU(this, Cho, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); + (new Vmenu(this, _cho, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); } -static void Select(CHOICE *cho, int hlp) { - Cho = cho; - Hlp = hlp; +static void select(Choice *cho, int hlp) { + _cho = cho; + _hlp = hlp; //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect); - warning("STUB: Select"); + warning("STUB: select"); } @@ -208,32 +208,32 @@ void CGEEngine::NONE() { void CGEEngine::SB() { _sndDrvInfo._dDev = DEV_SB; _sndDrvInfo._mDev = DEV_SB; - Reset(); - Select(DigiPorts, SPORT_TEXT); + reset(); + select(DigiPorts, SPORT_TEXT); } void CGEEngine::SBM() { _sndDrvInfo._dDev = DEV_SB; _sndDrvInfo._mDev = DEV_GM; - Reset(); - Select(DigiPorts, SPORT_TEXT); + reset(); + select(DigiPorts, SPORT_TEXT); } void CGEEngine::GUS() { _sndDrvInfo._dDev = DEV_GUS; _sndDrvInfo._mDev = DEV_GUS; - Reset(); - Select(DigiPorts, SPORT_TEXT); + reset(); + select(DigiPorts, SPORT_TEXT); } void CGEEngine::GUSM() { _sndDrvInfo._dDev = DEV_GUS; _sndDrvInfo._mDev = DEV_GM; - Reset(); - Select(DigiPorts, SPORT_TEXT); + reset(); + select(DigiPorts, SPORT_TEXT); } @@ -241,40 +241,40 @@ void CGEEngine::MIDI() { _sndDrvInfo._dDev = DEV_QUIET; _sndDrvInfo._mDev = DEV_GM; _sndDrvInfo._mBase = DETECT; - Select(MIDIPorts, MPORT_TEXT); + select(MIDIPorts, MPORT_TEXT); } void CGEEngine::AUTO() { _sndDrvInfo._dDev = DEV_AUTO; _sndDrvInfo._mDev = DEV_AUTO; - Reset(); + reset(); _sound.Open(); } void CGEEngine::setPortD() { - _sndDrvInfo._dBase = xdeco(DigiPorts[VMENU::Recent].Text); - Select((_sndDrvInfo._dDev == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); + _sndDrvInfo._dBase = xdeco(DigiPorts[Vmenu::_recent]._text); + select((_sndDrvInfo._dDev == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); } void CGEEngine::setPortM() { - _sndDrvInfo._mBase = xdeco(MIDIPorts[VMENU::Recent].Text); + _sndDrvInfo._mBase = xdeco(MIDIPorts[Vmenu::_recent]._text); _sound.Open(); } void CGEEngine::setIRQ() { - _sndDrvInfo._dIrq = ddeco(((_sndDrvInfo._dDev == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text); - Select((_sndDrvInfo._dDev == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); + _sndDrvInfo._dIrq = ddeco(((_sndDrvInfo._dDev == DEV_SB) ? BlsterIRQ : GravisIRQ)[Vmenu::_recent]._text); + select((_sndDrvInfo._dDev == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); } void CGEEngine::setDMA() { - _sndDrvInfo._dDma = ddeco(((_sndDrvInfo._dDev == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); + _sndDrvInfo._dDma = ddeco(((_sndDrvInfo._dDev == DEV_SB) ? BlsterDMA : GravisDMA)[Vmenu::_recent]._text); if (_sndDrvInfo._mDev != _sndDrvInfo._dDev) - Select(MIDIPorts, MPORT_TEXT); + select(MIDIPorts, MPORT_TEXT); else _sound.Open(); } diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 5f98cf34fb..5bafd46884 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -200,7 +200,7 @@ void MOUSE::NewMouse(Common::Event &event) { EvtHead = (EvtHead + 1) % EVT_MAX; evt._x = event.mouse.x; evt._y = event.mouse.y; - evt._ptr = SpriteAt(evt._x, evt._y); + evt._ptr = spriteAt(evt._x, evt._y); switch (event.type) { case Common::EVENT_MOUSEMOVE: @@ -278,8 +278,8 @@ void EventManager::handleEvents(void) { e._ptr->touch(e._msk, e._x, e._y); else e._ptr->touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y); - } else if (Sys) - Sys->touch(e._msk, e._x, e._y); + } else if (_sys) + _sys->touch(e._msk, e._x, e._y); if (e._msk & L_DN) { _mouse->Hold = e._ptr; diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 3acafd80e7..f2ebc0b4f8 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -35,7 +35,7 @@ uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b) { if (x) { uint16 i; for (i = 0; i < 256; i++) { - x[i] = Closest(pal, MkDAC(((uint16)(pal[i]._r) * r) / 255, + x[i] = closest(pal, mkDac(((uint16)(pal[i]._r) * r) / 255, ((uint16)(pal[i]._g) * g) / 255, ((uint16)(pal[i]._b) * b) / 255)); } @@ -50,9 +50,9 @@ uint8 *Mark(DAC *pal) { if (x) { uint16 i; for (i = 0; i < 256; i++) { - x[i] = Closest(pal, MkDAC(f(pal[i].R), - f(pal[i].G), - f(pal[i].B))); + x[i] = closest(pal, mkDax(f(pal[i]._R), + f(pal[i]._G), + f(pal[i]._B))); } } return x; diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 93cdb75a4b..74084fb905 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -34,8 +34,8 @@ namespace CGE { // Defines found in cge.mak #define VOL -#define INI_FILE VFILE // Or is it CFILE? -#define PIC_FILE VFILE +#define INI_FILE VFile // Or is it CFile? +#define PIC_FILE VFile #define BMP_MODE 0 // diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index a49f7c5c7f..b7c4b8ca83 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -75,9 +75,9 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _ } _led[ArrayCount(_led) - 1]->_flags._bDel = true; - Vga->_showQ->insert(this); + _vga->_showQ->insert(this); for (i = 0; i < ArrayCount(_led); i++) - Vga->_showQ->insert(_led[i]); + _vga->_showQ->insert(_led[i]); //--- reset balance i = (_sndDrvInfo.Vol4._ml + _sndDrvInfo.Vol4._mr) / 2; @@ -115,7 +115,7 @@ void Mixer::touch(uint16 mask, int x, int y) { void Mixer::tick() { int x = _mouse->_x; int y = _mouse->_y; - if (SpriteAt(x, y) == this) { + if (spriteAt(x, y) == this) { _fall = MIX_FALL; if (_flags._hold) touch(L_UP, x - _x, y - _y); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 01be69386f..edafd59111 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -71,7 +71,7 @@ static void SNGame(Sprite *spr, int num) { int buref = 0; int Stage = 0; - for (dup[0] = Vga->_showQ->first(); dup[0]; dup[0] = dup[0]->_next) { + for (dup[0] = _vga->_showQ->first(); dup[0]; dup[0] = dup[0]->_next) { buref = dup[0]->_ref; if (buref / 1000 == 16 && buref % 100 == 6) { Stage = (buref / 100) % 10; @@ -79,8 +79,8 @@ static void SNGame(Sprite *spr, int num) { } } if (dup[1] == NULL) { - dup[1] = Vga->_showQ->locate(16003); // pan - dup[2] = Vga->_showQ->locate(16004); // pani + dup[1] = _vga->_showQ->locate(16003); // pan + dup[2] = _vga->_showQ->locate(16004); // pani } if (_game) { // continue game @@ -163,10 +163,10 @@ static void SNGame(Sprite *spr, int num) { static int count = 0; if (k == NULL) { - k = Vga->_showQ->locate(20700); - k1 = Vga->_showQ->locate(20701); - k2 = Vga->_showQ->locate(20702); - k3 = Vga->_showQ->locate(20703); + k = _vga->_showQ->locate(20700); + k1 = _vga->_showQ->locate(20701); + k2 = _vga->_showQ->locate(20702); + k3 = _vga->_showQ->locate(20703); } if (!_game) { // init @@ -217,7 +217,7 @@ static void SNGame(Sprite *spr, int num) { SNPOST(SNSAY, 20003, 20022, NULL); break; } - ++ count; + count++; } switch (spr->_ref) { case 1 : @@ -273,13 +273,13 @@ static void SNGame(Sprite *spr, int num) { void ExpandSprite(Sprite *spr) { if (spr) - Vga->_showQ->insert(Vga->_spareQ->remove(spr)); + _vga->_showQ->insert(_vga->_spareQ->remove(spr)); } void ContractSprite(Sprite *spr) { if (spr) - Vga->_spareQ->append(Vga->_showQ->remove(spr)); + _vga->_spareQ->append(_vga->_showQ->remove(spr)); } int findPocket(Sprite *spr) { @@ -307,12 +307,12 @@ void selectPocket(int n) { void pocFul() { - Hero->park(); - SNPOST(SNWAIT, -1, -1, Hero); - SNPOST(SNSEQ, -1, POC_FUL, Hero); - SNPOST(SNSOUND, -1, 2, Hero); - SNPOST(SNWAIT, -1, -1, Hero); - SNPOST(SNSAY, 1, POC_FUL_TEXT, Hero); + _hero->park(); + SNPOST(SNWAIT, -1, -1, _hero); + SNPOST(SNSEQ, -1, POC_FUL, _hero); + SNPOST(SNSOUND, -1, 2, _hero); + SNPOST(SNWAIT, -1, -1, _hero); + SNPOST(SNSAY, 1, POC_FUL_TEXT, _hero); } @@ -356,7 +356,7 @@ void feedSnail(Sprite *spr, SNLIST snq) { killText(); } if (c->_com == SNNEXT) { - Sprite *s = (c->_ref < 0) ? spr : Locate(c->_ref); + Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); if (s) { uint8 *idx = (snq == TAKE) ? &s->_takePtr : &s->_nearPtr; if (*idx != NO_PTR) { @@ -383,7 +383,7 @@ void feedSnail(Sprite *spr, SNLIST snq) { break; } if (c->_com == SNIF) { - Sprite *s = (c->_ref < 0) ? spr : Locate(c->_ref); + Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); if (s) { // sprite extsts if (! s->seqTest(-1)) c = comtab + c->_val; // not parked @@ -506,10 +506,10 @@ static void SNZTrim(Sprite *spr) { Sprite *s; _heart->_enable = false; s = (spr->_flags._shad) ? spr->_prev : NULL; - Vga->_showQ->insert(Vga->_showQ->remove(spr)); + _vga->_showQ->insert(_vga->_showQ->remove(spr)); if (s) { s->_z = spr->_z; - Vga->_showQ->insert(Vga->_showQ->remove(s), spr); + _vga->_showQ->insert(_vga->_showQ->remove(s), spr); } _heart->_enable = en; } @@ -539,8 +539,8 @@ static void SNRmTake(Sprite *spr) { void SNSeq(Sprite *spr, int val) { if (spr) { - if (spr == Hero && val == 0) - Hero->park(); + if (spr == _hero && val == 0) + _hero->park(); else spr->step(val); } @@ -571,7 +571,7 @@ void SNSend(Sprite *spr, int val) { spr->_flags._slav = false; } else { if (spr->_ref % 1000 == 0) - Bitmap::_pal = VGA::SysPal; + Bitmap::_pal = Vga::_sysPal; if (spr->_flags._back) spr->backShow(true); else @@ -584,7 +584,7 @@ void SNSend(Sprite *spr, int val) { void SNSwap(Sprite *spr, int xref) { - Sprite *xspr = Locate(xref); + Sprite *xspr = locate(xref); if (spr && xspr) { int was = spr->_cave; int xwas = xspr->_cave; @@ -619,7 +619,7 @@ void SNSwap(Sprite *spr, int xref) { void SNCover(Sprite *spr, int xref) { - Sprite *xspr = Locate(xref); + Sprite *xspr = locate(xref); if (spr && xspr) { spr->_flags._hide = true; xspr->_z = spr->_z; @@ -627,7 +627,7 @@ void SNCover(Sprite *spr, int xref) { xspr->gotoxy(spr->_x, spr->_y); ExpandSprite(xspr); if ((xspr->_flags._shad = spr->_flags._shad) == 1) { - Vga->_showQ->insert(Vga->_showQ->remove(spr->_prev), xspr); + _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr); spr->_flags._shad = false; } feedSnail(xspr, NEAR); @@ -641,13 +641,13 @@ void SNUncover(Sprite *spr, Sprite *xspr) { spr->_cave = xspr->_cave; spr->gotoxy(xspr->_x, xspr->_y); if ((spr->_flags._shad = xspr->_flags._shad) == 1) { - Vga->_showQ->insert(Vga->_showQ->remove(xspr->_prev), spr); + _vga->_showQ->insert(_vga->_showQ->remove(xspr->_prev), spr); xspr->_flags._shad = false; } spr->_z = xspr->_z; SNSend(xspr, -1); if (spr->_time == 0) - ++spr->_time; + spr->_time++; } } @@ -669,20 +669,20 @@ void SNSetXY(Sprite *spr, uint16 xy) { void SNRelX(Sprite *spr, int x) { - if (spr && Hero) - spr->gotoxy(Hero->_x + x, spr->_y); + if (spr && _hero) + spr->gotoxy(_hero->_x + x, spr->_y); } void SNRelY(Sprite *spr, int y) { - if (spr && Hero) - spr->gotoxy(spr->_x, Hero->_y + y); + if (spr && _hero) + spr->gotoxy(spr->_x, _hero->_y + y); } void SNRelZ(Sprite *spr, int z) { - if (spr && Hero) { - spr->_z = Hero->_z + z; + if (spr && _hero) { + spr->_z = _hero->_z + z; SNZTrim(spr); } } @@ -710,13 +710,13 @@ void SNSetZ(Sprite *spr, int z) { void SNSlave(Sprite *spr, int ref) { - Sprite *slv = Locate(ref); + Sprite *slv = locate(ref); if (spr && slv) { if (spr->active()) { SNSend(slv, spr->_cave); slv->_flags._slav = true; slv->_z = spr->_z; - Vga->_showQ->insert(Vga->_showQ->remove(slv), spr->_next); + _vga->_showQ->insert(_vga->_showQ->remove(slv), spr->_next); } } } @@ -743,13 +743,13 @@ void SNKill(Sprite *spr) { } Sprite *nx = spr->_next; Hide1(spr); - Vga->_showQ->remove(spr); + _vga->_showQ->remove(spr); EventManager::ClrEvt(spr); if (spr->_flags._kill) delete spr; else { spr->_cave = -1; - Vga->_spareQ->append(spr); + _vga->_spareQ->append(spr); } if (nx) { if (nx->_flags._slav) @@ -817,7 +817,7 @@ static void SNLevel(Sprite *spr, int lev) { #endif while (_lev < lev) { _lev++; - spr = Vga->_spareQ->locate(100 + _lev); + spr = _vga->_spareQ->locate(100 + _lev); if (spr) { spr->backShow(true); spr->_cave = 0; @@ -844,7 +844,7 @@ void SNFlash(bool on) { if (on) { Dac *pal = farnew(Dac, PAL_CNT); if (pal) { - memcpy(pal, VGA::SysPal, PAL_SIZ); + memcpy(pal, Vga::_sysPal, PAL_SIZ); for (int i = 0; i < PAL_CNT; i++) { register int c; c = pal[i]._r << 1; @@ -854,19 +854,19 @@ void SNFlash(bool on) { c = pal[i]._b << 1; pal[i]._b = (c < 64) ? c : 63; } - Vga->SetColors(pal, 64); + _vga->setColors(pal, 64); } } else - Vga->SetColors(VGA::SysPal, 64); + _vga->setColors(Vga::_sysPal, 64); _dark = false; } static void SNLight(bool in) { if (in) - Vga->Sunrise(VGA::SysPal); + _vga->sunrise(Vga::_sysPal); else - Vga->Sunset(); + _vga->sunset(); _dark = ! in; } @@ -877,18 +877,18 @@ static void SNBarrier(int cav, int bar, bool horz) { static void SNWalk(Sprite *spr, int x, int y) { - if (Hero) { + if (_hero) { if (spr && y < 0) - Hero->findWay(spr); + _hero->findWay(spr); else - Hero->findWay(XZ(x, y)); + _hero->findWay(XZ(x, y)); } } static void SNReach(Sprite *spr, int mode) { - if (Hero) - Hero->reach(spr, mode); + if (_hero) + _hero->reach(spr, mode); } @@ -927,7 +927,7 @@ void Snail::runCom() { break; } - Sprite *sprel = ((snc->_ref >= 0) ? Locate(snc->_ref) : ((Sprite *) snc->_ptr)); + Sprite *sprel = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr)); switch (snc->_com) { case SNLABEL : break; @@ -939,7 +939,7 @@ void Snail::runCom() { case SNWAIT : if (sprel) { if (sprel->seqTest(snc->_val) && - (snc->_val >= 0 || sprel != Hero || Hero->_tracePtr < 0)) { + (snc->_val >= 0 || sprel != _hero || _hero->_tracePtr < 0)) { _timerExpiry = g_system->getMillis() + sprel->_time * SNAIL_FRAME_DELAY; } else goto xit; @@ -953,21 +953,21 @@ void Snail::runCom() { break; case SNSAY : if (sprel && _talkEnable) { - if (sprel == Hero && sprel->seqTest(-1)) + if (sprel == _hero && sprel->seqTest(-1)) sprel->step(HTALK); _text->say(_text->getText(snc->_val), sprel); - Sys->FunDel = HEROFUN0; + _sys->FunDel = HEROFUN0; } break; case SNINF : if (_talkEnable) { _vm->inf(_text->getText(snc->_val)); - Sys->FunDel = HEROFUN0; + _sys->FunDel = HEROFUN0; } break; case SNTIME : if (sprel && _talkEnable) { - if (sprel == Hero && sprel->seqTest(-1)) + if (sprel == _hero && sprel->seqTest(-1)) sprel->step(HTALK); sayTime(sprel); } @@ -995,7 +995,7 @@ void Snail::runCom() { SNCover(sprel, snc->_val); break; case SNUNCOVER : - SNUncover(sprel, (snc->_val >= 0) ? Locate(snc->_val) : ((Sprite *) snc->_ptr)); + SNUncover(sprel, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); break; case SNKEEP : SNKeep(sprel, snc->_val); diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index f112493278..5f370150ca 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -213,8 +213,8 @@ void Text::say(const char *txt, Sprite *spr) { spike->step(east); spike->_ref = SAY_REF; - Vga->_showQ->insert(_talk, Vga->_showQ->last()); - Vga->_showQ->insert(spike, Vga->_showQ->last()); + _vga->_showQ->insert(_talk, _vga->_showQ->last()); + _vga->_showQ->insert(spike, _vga->_showQ->last()); } } @@ -229,7 +229,7 @@ void CGEEngine::inf(const char *txt) { _talk->gotoxy(_talk->_x, _talk->_y - 20); _talk->_z = 126; _talk->_ref = INF_REF; - Vga->_showQ->insert(_talk, Vga->_showQ->last()); + _vga->_showQ->insert(_talk, _vga->_showQ->last()); } } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 36661e756e..aa7cd8ad06 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -177,7 +177,7 @@ void RestoreScreen(uint16 * &sav) { } -Dac MkDAC(uint8 r, uint8 g, uint8 b) { +Dac mkDac(uint8 r, uint8 g, uint8 b) { static Dac x; x._r = r; x._g = g; @@ -186,7 +186,7 @@ Dac MkDAC(uint8 r, uint8 g, uint8 b) { } -Rgb MkRGB(uint8 r, uint8 g, uint8 b) { +Rgb mkRgb(uint8 r, uint8 g, uint8 b) { static Trgb x; x._dac._r = r; x._dac._g = g; @@ -195,9 +195,9 @@ Rgb MkRGB(uint8 r, uint8 g, uint8 b) { } -Sprite *Locate(int ref) { - Sprite *spr = Vga->_showQ->locate(ref); - return (spr) ? spr : Vga->_spareQ->locate(ref); +Sprite *locate(int ref) { + Sprite *spr = _vga->_showQ->locate(ref); + return (spr) ? spr : _vga->_spareQ->locate(ref); } @@ -746,10 +746,10 @@ void Sprite::show() { void Sprite::show(uint16 pg) { - Graphics::Surface *a = VGA::Page[1]; - VGA::Page[1] = VGA::Page[pg & 3]; + Graphics::Surface *a = Vga::_page[1]; + Vga::_page[1] = Vga::_page[pg & 3]; shp()->show(_x, _y); - VGA::Page[1] = a; + Vga::_page[1] = a; } @@ -780,8 +780,8 @@ BMP_PTR Sprite::ghost() { } -Sprite *SpriteAt(int x, int y) { - Sprite *spr = NULL, * tail = Vga->_showQ->last(); +Sprite *spriteAt(int x, int y) { + Sprite *spr = NULL, * tail = _vga->_showQ->last(); if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { if (! spr->_flags._hide && ! spr->_flags._tran) { @@ -899,32 +899,32 @@ Sprite *Queue::locate(int ref) { //extern const char Copr[]; -Graphics::Surface *VGA::Page[4]; -Dac *VGA::SysPal; +Graphics::Surface *Vga::_page[4]; +Dac *Vga::_sysPal; -void VGA::init() { +void Vga::init() { for (int idx = 0; idx < 4; ++idx) { - Page[idx] = new Graphics::Surface(); - Page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); + _page[idx] = new Graphics::Surface(); + _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - SysPal = new Dac[PAL_CNT]; + _sysPal = new Dac[PAL_CNT]; } -void VGA::deinit() { +void Vga::deinit() { for (int idx = 0; idx < 4; ++idx) { - Page[idx]->free(); - delete Page[idx]; + _page[idx]->free(); + delete _page[idx]; } - delete[] SysPal; + delete[] _sysPal; } -VGA::VGA(int mode) - : FrmCnt(0), OldMode(0), OldScreen(NULL), StatAdr(VGAST1_), - Msg(NULL), Nam(NULL), SetPal(false), Mono(0) { - OldColors = NULL; - NewColors = NULL; +Vga::Vga(int mode) + : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), + _msg(NULL), _nam(NULL), _setPal(false), _mono(0) { + _oldColors = NULL; + _newColors = NULL; _showQ = new Queue(true); _spareQ = new Queue(false); @@ -941,42 +941,42 @@ VGA::VGA(int mode) // warning(Copr); warning("TODO: Fix Copr"); - SetStatAdr(); - if (StatAdr != VGAST1_) - ++Mono; + setStatAdr(); + if (_statAdr != VGAST1_) + _mono++; if (isVga()) { - OldColors = farnew(Dac, 256); - NewColors = farnew(Dac, 256); - OldScreen = SaveScreen(); - GetColors(OldColors); - Sunset(); - OldMode = SetMode(mode); - SetColors(); - Setup(VideoMode); - Clear(0); + _oldColors = farnew(Dac, 256); + _newColors = farnew(Dac, 256); + _oldScreen = SaveScreen(); + getColors(_oldColors); + sunset(); + _oldMode = setMode(mode); + setColors(); + setup(VideoMode); + clear(0); } } -VGA::~VGA(void) { - Mono = 0; +Vga::~Vga() { + _mono = 0; if (isVga()) { Common::String buffer = ""; /* - Clear(0); - SetMode(OldMode); - SetColors(); - RestoreScreen(OldScreen); - Sunrise(OldColors); + clear(0); + setMode(_oldMode); + setColors(); + restoreScreen(_oldScreen); + sunrise(_oldColors); */ - if (OldColors) - free(OldColors); - if (NewColors) - free(NewColors); - if (Msg) - buffer = Common::String(Msg); - if (Nam) - buffer = buffer + " [" + Nam + "]"; + if (_oldColors) + free(_oldColors); + if (_newColors) + free(_newColors); + if (_msg) + buffer = Common::String(_msg); + if (_nam) + buffer = buffer + " [" + _nam + "]"; debugN("%s", buffer.c_str()); } @@ -986,7 +986,7 @@ VGA::~VGA(void) { } -void VGA::SetStatAdr(void) { +void Vga::setStatAdr() { /* asm mov dx,VGAMIr_ asm in al,dx @@ -997,21 +997,21 @@ void VGA::SetStatAdr(void) { set_mode_adr: StatAdr = _AX; */ - warning("STUB: VGA::SetStatADR"); + warning("STUB: VGA::setStatADR"); } #pragma argsused -void VGA::WaitVR(bool on) { +void Vga::waitVR(bool on) { // Since some of the game parts rely on using vertical sync as a delay mechanism, // we're introducing a short delay to simulate it g_system->delayMillis(10); } -void VGA::Setup(VgaRegBlk *vrb) { +void Vga::setup(VgaRegBlk *vrb) { /* - WaitVR(); // *--LOOK!--* resets VGAATR logic + waitVR(); // *--LOOK!--* resets VGAATR logic asm cld asm mov si, vrb // take address of parameter table asm mov dh,0x03 // higher byte of I/O address is always 3 @@ -1048,23 +1048,23 @@ void VGA::Setup(VgaRegBlk *vrb) { xit: */ - warning("STUB: VGA::Setup"); + warning("STUB: VGA::setup"); } -int VGA::SetMode(int mode) { +int Vga::setMode(int mode) { // ScummVM provides it's own vieo services return 0; } -void VGA::GetColors(Dac *tab) { +void Vga::getColors(Dac *tab) { byte palData[PAL_SIZ]; g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT); - pal2DAC(palData, tab); + palToDac(palData, tab); } -void VGA::pal2DAC(const byte *palData, Dac *tab) { +void Vga::palToDac(const byte *palData, Dac *tab) { const byte *colP = palData; for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { tab[idx]._r = *colP >> 2; @@ -1073,7 +1073,7 @@ void VGA::pal2DAC(const byte *palData, Dac *tab) { } } -void VGA::DAC2pal(const Dac *tab, byte *palData) { +void Vga::dacToPal(const Dac *tab, byte *palData) { for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { *palData = tab[idx]._r << 2; *(palData + 1) = tab[idx]._g << 2; @@ -1081,16 +1081,16 @@ void VGA::DAC2pal(const Dac *tab, byte *palData) { } } -void VGA::SetColors(Dac *tab, int lum) { - Dac *palP = tab, *destP = NewColors; +void Vga::setColors(Dac *tab, int lum) { + Dac *palP = tab, *destP = _newColors; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP, ++destP) { destP->_r = (palP->_r * lum) >> 6; destP->_g = (palP->_g * lum) >> 6; destP->_b = (palP->_b * lum) >> 6; } - if (Mono) { - destP = NewColors; + if (_mono) { + destP = _newColors; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { // Form a greyscalce colour from 30% R, 59% G, 11% B uint8 intensity = (destP->_r * 77) + (destP->_g * 151) + (destP->_b * 28); @@ -1100,77 +1100,77 @@ void VGA::SetColors(Dac *tab, int lum) { } } - SetPal = true; + _setPal = true; } -void VGA::SetColors(void) { - memset(NewColors, 0, PAL_SIZ); - UpdateColors(); +void Vga::setColors(void) { + memset(_newColors, 0, PAL_SIZ); + updateColors(); } -void VGA::Sunrise(Dac *tab) { +void Vga::sunrise(Dac *tab) { for (int i = 0; i <= 64; i += FADE_STEP) { - SetColors(tab, i); - WaitVR(true); - UpdateColors(); + setColors(tab, i); + waitVR(true); + updateColors(); } } -void VGA::Sunset(void) { +void Vga::sunset() { Dac tab[256]; - GetColors(tab); + getColors(tab); for (int i = 64; i >= 0; i -= FADE_STEP) { - SetColors(tab, i); - WaitVR(true); - UpdateColors(); + setColors(tab, i); + waitVR(true); + updateColors(); } } -void VGA::Show(void) { +void Vga::show() { Sprite *spr = _showQ->first(); for (spr = _showQ->first(); spr; spr = spr->_next) spr->show(); - Update(); + update(); for (spr = _showQ->first(); spr; spr = spr->_next) spr->hide(); - ++ FrmCnt; + _frmCnt++; } -void VGA::UpdateColors(void) { +void Vga::updateColors() { byte palData[PAL_SIZ]; - DAC2pal(NewColors, palData); + dacToPal(_newColors, palData); g_system->getPaletteManager()->setPalette(palData, 0, 256); } -void VGA::Update(void) { - SWAP(VGA::Page[0], VGA::Page[1]); +void Vga::update() { + SWAP(Vga::_page[0], Vga::_page[1]); - if (SetPal) { - UpdateColors(); - SetPal = false; + if (_setPal) { + updateColors(); + _setPal = false; } - g_system->copyRectToScreen((const byte *)VGA::Page[0]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); + g_system->copyRectToScreen((const byte *)Vga::_page[0]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); g_system->updateScreen(); } -void VGA::Clear(uint8 color) { +void Vga::clear(uint8 color) { for (int paneNum = 0; paneNum < 4; ++paneNum) - Page[paneNum]->fillRect(Common::Rect(0, 0, SCR_WID, SCR_HIG), color); + _page[paneNum]->fillRect(Common::Rect(0, 0, SCR_WID, SCR_HIG), color); } -void VGA::CopyPage(uint16 d, uint16 s) { - Page[d]->copyFrom(*Page[s]); +void Vga::copyPage(uint16 d, uint16 s) { + _page[d]->copyFrom(*_page[s]); } //-------------------------------------------------------------------------- @@ -1259,13 +1259,13 @@ void Bitmap::xShow(int x, int y) { void Bitmap::show(int x, int y) { const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG); + byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { - byte *destP = (byte *)VGA::Page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -1321,8 +1321,8 @@ void Bitmap::show(int x, int y) { void Bitmap::hide(int x, int y) { for (int yp = y; yp < y + _h; ++yp) { - const byte *srcP = (const byte *)VGA::Page[2]->getBasePtr(x, yp); - byte *destP = (byte *)VGA::Page[1]->getBasePtr(x, yp); + const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); + byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); Common::copy(srcP, srcP + _w, destP); } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 9e49b3d918..5ef7f99c69 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -170,7 +170,7 @@ protected: public: int _ref; signed char _cave; - struct FLAGS { + struct Flags { uint16 _hide : 1; // general visibility switch uint16 _near : 1; // Near action lock uint16 _drag : 1; // sprite is moveable @@ -237,7 +237,8 @@ private: class Queue { - Sprite *_head, *_tail; + Sprite *_head; + Sprite *_tail; public: Queue(bool show); ~Queue(); @@ -260,55 +261,55 @@ public: }; -class VGA { - uint16 OldMode; - uint16 *OldScreen; - uint16 StatAdr; - bool SetPal; - Dac *OldColors; - Dac *NewColors; - const char *Msg; - const char *Nam; - - int SetMode(int mode); - void UpdateColors(void); - void SetColors(void); - void SetStatAdr(void); - void WaitVR(bool on); +class Vga { + uint16 _oldMode; + uint16 *_oldScreen; + uint16 _statAdr; + bool _setPal; + Dac *_oldColors; + Dac *_newColors; + const char *_msg; + const char *_nam; + + int setMode(int mode); + void updateColors(); + void setColors(); + void setStatAdr(); + void waitVR(bool on); public: - uint32 FrmCnt; + uint32 _frmCnt; Queue *_showQ; Queue *_spareQ; - int Mono; - static Graphics::Surface *Page[4]; - static Dac *SysPal; + int _mono; + static Graphics::Surface *_page[4]; + static Dac *_sysPal; - VGA(int mode); - ~VGA(void); + Vga(int mode); + ~Vga(void); static void init(); static void deinit(); - void Setup(VgaRegBlk *vrb); - void GetColors(Dac *tab); - void SetColors(Dac *tab, int lum); - void Clear(uint8 color); - void CopyPage(uint16 d, uint16 s); - void Sunrise(Dac *tab); - void Sunset(); - void Show(); - void Update(); - - static void pal2DAC(const byte *palData, Dac *tab); - static void DAC2pal(const Dac *tab, byte *palData); + void setup(VgaRegBlk *vrb); + void getColors(Dac *tab); + void setColors(Dac *tab, int lum); + void clear(uint8 color); + void copyPage(uint16 d, uint16 s); + void sunrise(Dac *tab); + void sunset(); + void show(); + void update(); + + static void palToDac(const byte *palData, Dac *tab); + static void dacToPal(const Dac *tab, byte *palData); }; -Dac MkDAC(uint8 r, uint8 g, uint8 b); -Rgb MkRGB(uint8 r, uint8 g, uint8 b); +Dac mkDac(uint8 r, uint8 g, uint8 b); +Rgb mkRgb(uint8 r, uint8 g, uint8 b); template -uint8 Closest(CBLK *pal, CBLK x) { +uint8 closest(CBLK *pal, CBLK x) { #define f(col, lum) ((((uint16)(col)) << 8) / lum) uint16 i, dif = 0xFFFF, found = 0; uint16 L = x._r + x._g + x._b; @@ -337,12 +338,12 @@ uint8 Closest(CBLK *pal, CBLK x) { } //static void Video (void); -uint16 *SaveScreen(void); -void RestoreScreen(uint16 * &sav); -Sprite *SpriteAt(int x, int y); -Sprite *Locate(int ref); +uint16 *saveScreen(); +void restoreScreen(uint16 * &sav); +Sprite *spriteAt(int x, int y); +Sprite *locate(int ref); -extern bool SpeedTest; +extern bool _speedTest; } // End of namespace CGE diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 7ea32ff023..49dbbbdab6 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -44,7 +44,7 @@ namespace CGE { -MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { +MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; uint8 *p = farnew(uint8, i), * p1, * p2; @@ -71,21 +71,21 @@ MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { static char *vmgt; -char *VMGather(CHOICE *list) { - CHOICE *cp; +char *VMGather(Choice *list) { + Choice *cp; int len = 0, h = 0; - for (cp = list; cp->Text; cp++) { - len += strlen(cp->Text); + for (cp = list; cp->_text; cp++) { + len += strlen(cp->_text); h++; } vmgt = new char[len + h]; if (vmgt) { *vmgt = '\0'; - for (cp = list; cp->Text; cp++) { + for (cp = list; cp->_text; cp++) { if (*vmgt) strcat(vmgt, "|"); - strcat(vmgt, cp->Text); + strcat(vmgt, cp->_text); h++; } } @@ -93,60 +93,60 @@ char *VMGather(CHOICE *list) { } -VMENU *VMENU::Addr = NULL; -int VMENU::Recent = -1; +Vmenu *Vmenu::_addr = NULL; +int Vmenu::_recent = -1; -VMENU::VMENU(CGEEngine *vm, CHOICE *list, int x, int y) - : Talk(vm, VMGather(list), RECT), Menu(list), Bar(NULL), _vm(vm) { - CHOICE *cp; +Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) + : Talk(vm, VMGather(list), RECT), _menu(list), _bar(NULL), _vm(vm) { + Choice *cp; - Addr = this; + _addr = this; delete[] vmgt; - Items = 0; - for (cp = list; cp->Text; cp++) - Items++; + _items = 0; + for (cp = list; cp->_text; cp++) + _items++; _flags._bDel = true; _flags._kill = true; if (x < 0 || y < 0) center(); else gotoxy(x - _w / 2, y - (TEXT_VM + FONT_HIG / 2)); - Vga->_showQ->insert(this, Vga->_showQ->last()); - Bar = new MENU_BAR(_vm, _w - 2 * TEXT_HM); - Bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM - MB_VM); - Vga->_showQ->insert(Bar, Vga->_showQ->last()); + _vga->_showQ->insert(this, _vga->_showQ->last()); + _bar = new MenuBar(_vm, _w - 2 * TEXT_HM); + _bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM - MB_VM); + _vga->_showQ->insert(_bar, _vga->_showQ->last()); } -VMENU::~VMENU(void) { - Addr = NULL; +Vmenu::~Vmenu(void) { + _addr = NULL; } -void VMENU::touch(uint16 mask, int x, int y) { +void Vmenu::touch(uint16 mask, int x, int y) { uint16 h = FONT_HIG + TEXT_LS; bool ok = false; - if (Items) { + if (_items) { Sprite::touch(mask, x, y); y -= TEXT_VM - 1; int n = 0; if (y >= 0) { n = y / h; - if (n < Items) + if (n < _items) ok = (x >= TEXT_HM && x < _w - TEXT_HM/* && y % h < FONT_HIG*/); else - n = Items - 1; + n = _items - 1; } - Bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM + n * h - MB_VM); + _bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM + n * h - MB_VM); if (ok && (mask & L_UP)) { - Items = 0; + _items = 0; SNPOST_(SNKILL, -1, 0, this); - //Menu[Recent = n].Proc(); + //_menu[_recent = n].Proc(); warning("Missing call to proc()"); } } diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 88a2766040..6b4eb85a53 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -36,29 +36,29 @@ namespace CGE { #define MB_HM 3 -typedef struct { - const char *Text; +struct Choice { + const char *_text; void (CGEEngine::*Proc)(); -} CHOICE; +}; -class MENU_BAR : public Talk { +class MenuBar : public Talk { public: - MENU_BAR(CGEEngine *vm, uint16 w); + MenuBar(CGEEngine *vm, uint16 w); private: CGEEngine *_vm; }; -class VMENU : public Talk { - uint16 Items; - CHOICE *Menu; +class Vmenu : public Talk { + uint16 _items; + Choice *_menu; public: - static VMENU *Addr; - static int Recent; - MENU_BAR *Bar; - VMENU(CGEEngine *vm, CHOICE *list, int x, int y); - ~VMENU(); + static Vmenu *_addr; + static int _recent; + MenuBar *_bar; + Vmenu(CGEEngine *vm, Choice *list, int x, int y); + ~Vmenu(); virtual void touch(uint16 mask, int x, int y); private: CGEEngine *_vm; diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 332ae869c8..2988f9ab11 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -31,25 +31,25 @@ namespace CGE { -DAT *VFILE::_dat = NULL; -BtFile *VFILE::_cat = NULL; -VFILE *VFILE::_recent = NULL; +Dat *VFile::_dat = NULL; +BtFile *VFile::_cat = NULL; +VFile *VFile::_recent = NULL; /*-----------------------------------------------------------------------*/ -DAT::DAT(): +Dat::Dat(): #ifdef VOL_UPD - _File(DAT_NAME, UPD, CRP) + _file(DAT_NAME, UPD, CRP) #else - _File(DAT_NAME, REA, CRP) + _file(DAT_NAME, REA, CRP) #endif { } /*-----------------------------------------------------------------------*/ -void VFILE::init() { - _dat = new DAT(); +void VFile::init() { + _dat = new Dat(); #ifdef VOL_UPD _cat = new BtFile(CAT_NAME, UPD, CRP); #else @@ -59,15 +59,15 @@ void VFILE::init() { _recent = NULL; } -void VFILE::deinit() { +void VFile::deinit() { delete _dat; delete _cat; } -VFILE::VFILE(const char *name, IOMODE mode) +VFile::VFile(const char *name, IOMODE mode) : IoBuf(mode) { if (mode == REA) { - if (_dat->_File._error || _cat->_error) + if (_dat->_file._error || _cat->_error) error("Bad volume data"); BtKeypack *kp = _cat->find(name); if (scumm_stricmp(kp->_key, name) != 0) @@ -81,27 +81,27 @@ VFILE::VFILE(const char *name, IOMODE mode) } -VFILE::~VFILE(void) { +VFile::~VFile() { if (_recent == this) _recent = NULL; } -bool VFILE::exist(const char *name) { +bool VFile::exist(const char *name) { return scumm_stricmp(_cat->find(name)->_key, name) == 0; } -void VFILE::readBuff(void) { +void VFile::readBuff() { if (_recent != this) { - _dat->_File.seek(_bufMark + _lim); + _dat->_file.seek(_bufMark + _lim); _recent = this; } - _bufMark = _dat->_File.mark(); + _bufMark = _dat->_file.mark(); long n = _endMark - _bufMark; if (n > IOBUF_SIZE) n = IOBUF_SIZE; - _lim = _dat->_File.read(_buff, (uint16) n); + _lim = _dat->_file.read(_buff, (uint16) n); _ptr = 0; } diff --git a/engines/cge/vol.h b/engines/cge/vol.h index 1e0b363ca5..d8ba0979cb 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -49,11 +49,11 @@ namespace CGE { #endif -class DAT { - friend class VFILE; - VOLBASE _File; +class Dat { + friend class VFile; + VOLBASE _file; public: - DAT(); + Dat(); bool append(uint8 *buf, uint16 len); bool write(CFile &f); @@ -61,11 +61,11 @@ public: }; -class VFILE : public IoBuf { +class VFile : public IoBuf { private: - static DAT *_dat; + static Dat *_dat; static BtFile *_cat; - static VFILE *_recent; + static VFile *_recent; long _begMark; long _endMark; @@ -74,17 +74,17 @@ private: void writeBuff(void) { } void make(const char *fspec); public: - VFILE(const char *name, IOMODE mode = REA); - ~VFILE(void); + VFile(const char *name, IOMODE mode = REA); + ~VFile(); static void init(); static void deinit(); static bool exist(const char *name); - static const char *next(void); - long mark(void) { + static const char *next(); + long mark() { return (_bufMark + _ptr) - _begMark; } - long size(void) { + long size() { return _endMark - _begMark; } long seek(long pos) { -- cgit v1.2.3 From fae1d7efd885eae98ee9b0c8ae9bc99612942430 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 4 Jul 2011 08:15:56 +0200 Subject: CGE: This ends the first renaming pass. Also move some functions to CGEEngine --- engines/cge/cge.cpp | 66 ++++++++++++++++++++- engines/cge/cge.h | 28 ++++++++- engines/cge/cge_main.cpp | 148 ++++++++++++++++++----------------------------- engines/cge/cge_main.h | 17 +++--- engines/cge/config.cpp | 10 ++-- engines/cge/ems.cpp | 24 ++++---- engines/cge/events.cpp | 2 +- engines/cge/general.cpp | 8 +-- engines/cge/general.h | 26 ++++----- engines/cge/snail.cpp | 27 +++++---- engines/cge/snail.h | 3 - engines/cge/sound.cpp | 129 ++++++++++++++++++++--------------------- engines/cge/sound.h | 56 +++++++++--------- engines/cge/startup.cpp | 2 +- engines/cge/startup.h | 2 +- engines/cge/vol.cpp | 14 +++++ engines/cge/vol.h | 20 ++----- engines/cge/wav.h | 125 +++++++++++++++++++-------------------- 18 files changed, 375 insertions(+), 332 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 0487441517..87c3964563 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -46,7 +46,12 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) // Debug/console setup DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); - _isDemo = _gameDescription->flags & ADGF_DEMO; + _isDemo = _gameDescription->flags & ADGF_DEMO; + _startupMode = 1; + _demoText = DEMO_TEXT; + _oldLev = 0; + _jbw = false; + _pocPtr = 0; } @@ -68,7 +73,7 @@ void CGEEngine::setup() { _vga = new Vga(M13H); _heart = new Heart; _hero = new WALK(this, NULL); - _sys = new SYSTEM(this); + _sys = new System(this); _pocLight = new Sprite(this, LI); for (int i = 0; i < POCKET_NX; i++) _pocket[i] = new Sprite(this, NULL); @@ -103,6 +108,63 @@ void CGEEngine::setup() { _keyboard = new Keyboard(); _eventManager = new EventManager(); _offUseCount = atoi(_text->getText(OFF_USE_COUNT)); + _music = true; + + for (int i = 0; i < POCKET_NX; i++) + _pocref[i] = -1; + _volume[0] = 0; + _volume[1] = 0; + + _savTab[0].Ptr = &_now; + _savTab[0].Len = sizeof(_now); + _savTab[0].Flg = 1; + _savTab[1].Ptr = &_oldLev; + _savTab[1].Len = sizeof(_oldLev); + _savTab[1].Flg = 1; + _savTab[2].Ptr = &_demoText; + _savTab[2].Len = sizeof(_demoText); + _savTab[2].Flg = 1; + _savTab[3].Ptr = &_game; + _savTab[3].Len = sizeof(_game); + _savTab[3].Flg = 1; + _savTab[4].Ptr = &_game; + _savTab[4].Len = sizeof(_game); + _savTab[4].Flg = 1; + _savTab[5].Ptr = &_game; + _savTab[5].Len = sizeof(_game); + _savTab[5].Flg = 1; + _savTab[6].Ptr = &_game; + _savTab[6].Len = sizeof(_game); + _savTab[6].Flg = 1; + _savTab[7].Ptr = &_game; + _savTab[7].Len = sizeof(_game); + _savTab[7].Flg = 1; + _savTab[8].Ptr = &_vga->_mono; + _savTab[8].Len = sizeof(_vga->_mono); + _savTab[8].Flg = 0; + _savTab[9].Ptr = &_music; + _savTab[9].Len = sizeof(_music); + _savTab[9].Flg = 1; + _savTab[10].Ptr = _volume; + _savTab[10].Len = sizeof(_volume); + _savTab[10].Flg = 1; + _savTab[11].Ptr = _flag; + _savTab[11].Len = sizeof(_flag); + _savTab[11].Flg = 1; + _savTab[12].Ptr = _heroXY; +// _savTab[12].Len = sizeof(_heroXY); FIXME: illegal sizeof + _savTab[12].Len = 0; + _savTab[12].Flg = 1; + _savTab[13].Ptr = _barriers; +// _savTab[13].Len = sizeof(_barriers); FIXME: illegal sizeof + _savTab[13].Len = 0; + _savTab[13].Flg = 1; + _savTab[14].Ptr = _pocref; + _savTab[14].Len = sizeof(_pocref); + _savTab[14].Flg = 1; + _savTab[15].Ptr = NULL; + _savTab[15].Len = 0; + _savTab[15].Flg = 0; } CGEEngine::~CGEEngine() { diff --git a/engines/cge/cge.h b/engines/cge/cge.h index ba6326726a..04f395559f 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -36,12 +36,21 @@ namespace CGE { class Console; +class Sprite; // our engine debug channels enum { kCGEDebug = 1 << 0 }; +#define POCKET_NX 8 + +struct SavTab { + void *Ptr; + int Len; + uint8 Flg; +}; + class CGEEngine : public Engine { private: uint32 _lastFrame; @@ -50,8 +59,17 @@ public: CGEEngine(OSystem *syst, const ADGameDescription *gameDescription); ~CGEEngine(); - const ADGameDescription *_gameDescription; - bool _isDemo; + const ADGameDescription *_gameDescription; + bool _isDemo; + int _startupMode; + int _demoText; + int _oldLev; + bool _jbw; + int _pocPtr; + SavTab _savTab[16]; + bool _music; + int _pocref[POCKET_NX]; + uint8 _volume[2]; virtual Common::Error run(); GUI::Debugger *getDebugger() { @@ -81,6 +99,7 @@ public: void NONE(); void SB(); void caveDown(); + void caveUp(); void xCave(); void qGame(); void SBM(); @@ -93,6 +112,11 @@ public: void setIRQ(); void setDMA(); void mainLoop(); + void SaveGame(XFile &file); + void switchMusic(); + void selectPocket(int n); + void SNKeep(Sprite *spr, int stp); + void SNGive(Sprite *spr, int stp); private: CGEConsole *_console; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 2caa9e0a98..6b02f82910 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -58,7 +58,7 @@ uint16 _stklen = (STACK_SIZ * 2); Vga *_vga; Heart *_heart; WALK *_hero; -SYSTEM *_sys; +System *_sys; Sprite *_pocLight; EventManager *_eventManager; Keyboard *_keyboard; @@ -91,21 +91,14 @@ Snail *_snail_; // coditionals EVA for 2-month evaluation version static char _usrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; -static int _oldLev = 0; -static int _demoText = DEMO_TEXT; //-------------------------------------------------------------------------- -bool _jbw = false; - -//------------------------------------------------------------------------- -int _pocPtr = 0; - -static EMS *_mini = _miniEmm.alloc((uint16)MINI_EMM_SIZE); +static Ems *_mini = _miniEmm.alloc((uint16)MINI_EMM_SIZE); static BMP_PTR *_miniShpList = NULL; static BMP_PTR _miniShp[] = { NULL, NULL }; static bool _finis = false; -static int _startup = 1; +//static int _startup = 1; int _offUseCount; uint16 *_intStackPtr = false; @@ -115,11 +108,11 @@ Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; extern int findPocket(Sprite *); extern Dac _stdPal[58]; -void feedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL -uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; +void feedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL +uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; -uint8 &Cluster::cell() { +uint8 &Cluster::cell() { return _map[_b][_a]; } @@ -184,36 +177,6 @@ Cluster XZ(Couple xy) { return XZ(x, y); } - -int _pocref[POCKET_NX]; -uint8 _volume[2]; - -struct SavTab { - void *Ptr; - int Len; - uint8 Flg; -}; - -SavTab _savTab[] = { - { &_now, sizeof(_now), 1 }, - { &_oldLev, sizeof(_oldLev), 1 }, - { &_demoText, sizeof(_demoText), 1 }, - { &_game, sizeof(_game), 1 }, - { &_game, sizeof(_game), 1 }, // spare 1 - { &_game, sizeof(_game), 1 }, // spare 2 - { &_game, sizeof(_game), 1 }, // spare 3 - { &_game, sizeof(_game), 1 }, // spare 4 -// { &VGA::Mono, sizeof(VGA::Mono), 0 }, - { &_music, sizeof(_music), 1 }, - { _volume, sizeof(_volume), 1 }, - { _flag, sizeof(_flag), 1 }, - { _heroXY, sizeof(_heroXY), 1 }, - { _barriers, sizeof(_barriers), 1 }, - { _pocref, sizeof(_pocref), 1 }, - { NULL, 0, 0 } -}; - - void CGEEngine::loadGame(XFile &file, bool tiny = false) { SavTab *st; Sprite *spr; @@ -270,7 +233,7 @@ static void SaveSound(void) { } -static void SaveGame(XFile &file) { +void CGEEngine::SaveGame(XFile &file) { SavTab *st; Sprite *spr; int i; @@ -366,7 +329,7 @@ void WALK::tick() { if (Dir != NO_DIR) { Sprite *spr; - _sys->FunTouch(); + _sys->funTouch(); for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (distance(spr) < 2) { if (!spr->_flags._near) { @@ -554,7 +517,6 @@ void CGEEngine::setMapBrick(int x, int z) { static void SwitchColorMode(void); static void switchDebug(); -static void SwitchMusic(void); static void KillSprite(void); static void PushSprite(void); static void PullSprite(void); @@ -605,22 +567,22 @@ static void miniStep(int stp) { else { &*_mini; *_miniShp[0] = *_miniShpList[stp]; - if (_fx.Current) - &*(_fx.Current->EAddr()); + if (_fx._current) + &*(_fx._current->eAddr()); _miniCave->_flags._hide = false; } } -static void PostMiniStep(int stp) { +static void postMiniStep(int stp) { //static int recent = -2; //TODO Change the SNPOST message send to a special way to send function pointer //if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep); warning("STUB: PostMiniStep()"); } -void SYSTEM::SetPal(void) { +void System::setPal() { uint i; Dac *p = Vga::_sysPal + 256 - ArrayCount(_stdPal); for (i = 0; i < ArrayCount(_stdPal); i++) { @@ -631,10 +593,10 @@ void SYSTEM::SetPal(void) { } -void SYSTEM::FunTouch(void) { +void System::funTouch() { uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0; - if (_talk == NULL || n > FunDel) - FunDel = n; + if (_talk == NULL || n > _funDel) + _funDel = n; } @@ -646,16 +608,16 @@ static void ShowBak(int ref) { Bitmap::_pal = NULL; spr->show(2); _vga->copyPage(1, 2); - _sys->SetPal(); + _sys->setPal(); spr->contract(); } } -static void caveUp() { +void CGEEngine::caveUp() { int BakRef = 1000 * _now; if (_music) - LoadMIDI(_now); + loadMidi(_now); ShowBak(BakRef); loadMapping(); @@ -673,10 +635,10 @@ static void caveUp() { spr = n; } if (_sndDrvInfo._dDev) { - _sound.Stop(); - _fx.Clear(); - _fx.Preload(0); - _fx.Preload(BakRef); + _sound.stop(); + _fx.clear(); + _fx.preload(0); + _fx.preload(BakRef); } if (_hero) { @@ -707,7 +669,7 @@ static void caveUp() { _vga->show(); _vga->sunrise(Vga::_sysPal); _dark = false; - if (!_startup) + if (!_startupMode) _mouse->On(); _heart->_enable = true; @@ -771,7 +733,7 @@ void CGEEngine::switchCave(int cav) { _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); killText(); - if (!_startup) + if (!_startupMode) KeyClick(); SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer @@ -781,22 +743,22 @@ void CGEEngine::switchCave(int cav) { } } -SYSTEM::SYSTEM(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { - FunDel = HEROFUN0; - SetPal(); - Tick(); +System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { + _funDel = HEROFUN0; + setPal(); + tick(); } -void SYSTEM::touch(uint16 mask, int x, int y) { +void System::touch(uint16 mask, int x, int y) { static int pp = 0; - FunTouch(); + funTouch(); if (mask & KEYB) { int pp0; KeyClick(); killText(); - if (_startup == 1) { + if (_vm->_startupMode == 1) { SNPOST(SNCLEAR, -1, 0, NULL); return; } @@ -854,7 +816,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) { _hero->step(TSEQ + 3); break; case F9: - _sys->FunDel = 1; + _sys->_funDel = 1; break; case 'X': if (_keyboard->_key[ALT]) @@ -891,13 +853,13 @@ void SYSTEM::touch(uint16 mask, int x, int y) { break; case 'W': if (pp == 2) - _jbw = !_jbw; + _vm->_jbw = !_vm->_jbw; break; } if (pp == pp0) pp = 0; } else { - if (_startup) + if (_vm->_startupMode) return; int cav = 0; _infoLine->update(NULL); @@ -915,12 +877,12 @@ void SYSTEM::touch(uint16 mask, int x, int y) { if (y >= POCKET_Y && y < POCKET_Y + POCKET_NY * POCKET_DY && x >= POCKET_X && x < POCKET_X + POCKET_NX * POCKET_DX) { int n = ((y - POCKET_Y) / POCKET_DY) * POCKET_NX + (x - POCKET_X) / POCKET_DX; - selectPocket(n); + _vm->selectPocket(n); } } } - PostMiniStep(cav - 1); + postMiniStep(cav - 1); if (mask & L_UP) { if (cav && _snail->idle() && _hero->_tracePtr < 0) @@ -945,9 +907,9 @@ void SYSTEM::touch(uint16 mask, int x, int y) { } -void SYSTEM::Tick(void) { - if (!_startup) - if (--FunDel == 0) { +void System::tick() { + if (!_vm->_startupMode) + if (--_funDel == 0) { killText(); if (_snail->idle()) { if (PAIN) @@ -968,7 +930,7 @@ void SYSTEM::Tick(void) { } } } - FunTouch(); + funTouch(); } _time = SYSTIMERATE; } @@ -1001,7 +963,7 @@ static void SwitchColorMode(void) { -static void SwitchMusic(void) { +void CGEEngine::switchMusic() { if (_keyboard->_key[ALT]) { if (Vmenu::_addr) SNPOST_(SNKILL, -1, 0, Vmenu::_addr); @@ -1020,9 +982,9 @@ static void SwitchMusic(void) { } } if (_music) - LoadMIDI(_now); + loadMidi(_now); else - KillMIDI(); + killMidi(); } @@ -1203,7 +1165,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { break; case 2 : if (mask & L_UP) - SwitchMusic(); + switchMusic(); else if (mask & R_UP) if (!Mixer::_appear) { Mixer::_appear = true; @@ -1220,7 +1182,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { #pragma argsused void Sprite::touch(uint16 mask, int x, int y) { - _sys->FunTouch(); + _sys->funTouch(); if ((mask & ATTN) == 0) { _infoLine->update(name()); if (mask & (R_DN | L_DN)) @@ -1236,14 +1198,14 @@ void Sprite::touch(uint16 mask, int x, int y) { mask |= R_UP; } if ((mask & R_UP) && _snail->idle()) { - Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_pocPtr] : NULL; + Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL; if (ps) { if (_flags._kept || _hero->distance(this) < MAX_DISTANCE) { if (works(ps)) { feedSnail(ps, TAKE); } else offUse(); - selectPocket(-1); + _vm->selectPocket(-1); } else tooFar(); } else { @@ -1280,7 +1242,7 @@ void Sprite::touch(uint16 mask, int x, int y) { int n; for (n = 0; n < POCKET_NX; n++) { if (_pocket[n] == this) { - selectPocket(n); + _vm->selectPocket(n); break; } } @@ -1614,7 +1576,7 @@ void CGEEngine::runGame() { _sprite->step(_music); SNPOST_(SNSEQ, -1, _music, _sprite); if (!_music) - KillMIDI(); + killMidi(); if (_mini && INI_FILE::exist("MINI.SPR")) { uint8 *ptr = (uint8 *) &*_mini; @@ -1626,7 +1588,7 @@ void CGEEngine::runGame() { _miniCave->moveShapes(ptr); _miniShp[0] = new Bitmap(*_miniCave->shp()); _miniShpList = _miniCave->setShapeList(_miniShp); - PostMiniStep(-1); + postMiniStep(-1); } } } @@ -1661,7 +1623,7 @@ void CGEEngine::runGame() { if (_mouse->Busy) ExpandSprite(_mouse->Busy); - _startup = 0; + _startupMode = 0; SNPOST(SNLEVEL, -1, _oldLev, &_cavLight); _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, @@ -1761,7 +1723,7 @@ bool CGEEngine::showTitle(const char *name) { _vga->copyPage(0, 2); Startup::_soundOk = 2; if (_music) - LoadMIDI(0); + loadMidi(0); } if (Startup::_mode < 2) { @@ -1854,10 +1816,10 @@ void CGEEngine::cge_main(void) { _horzLine->_flags._hide = true; //srand((uint16) Timer()); - _sys = new SYSTEM(this); + _sys = new System(this); if (_music && Startup::_soundOk) - LoadMIDI(0); + loadMidi(0); if (Startup::_mode < 2) movie(LGO_EXT); @@ -1865,7 +1827,7 @@ void CGEEngine::cge_main(void) { if ((!_isDemo) && (Startup::_mode == 1)) movie("X02"); // intro runGame(); - _startup = 2; + _startupMode = 2; if (FINIS) movie("X03"); } else diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index c5be2adc26..e9c96931c3 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -113,17 +113,17 @@ namespace CGE { #define FINIS (_flag[3]) -class SYSTEM : public Sprite { - int lum; +class System : public Sprite { + int _lum; public: - int FunDel; + int _funDel; - SYSTEM(CGEEngine *vm); + System(CGEEngine *vm); - void SetPal(); - void FunTouch(); + void setPal(); + void funTouch(); virtual void touch(uint16 mask, int x, int y); - void Tick(); + void tick(); private: CGEEngine *_vm; }; @@ -159,7 +159,6 @@ private: }; - Cluster XZ(int x, int y); Cluster XZ(Couple xy); @@ -169,7 +168,7 @@ void ContractSprite(Sprite *spr); extern WALK *_hero; extern Vga *_vga; extern Heart *_heart; -extern SYSTEM *_sys; +extern System *_sys; extern int _offUseCount; extern Sprite *_pocLight; extern Keyboard *_keyboard; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 8812207371..11f2088034 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -143,7 +143,7 @@ static Choice BlsterDMA[] = { void CGEEngine::selectSound() { int i; - _sound.Close(); + _sound.close(); if (Vmenu::_addr) SNPOST_(SNKILL, -1, 0, Vmenu::_addr); inf(_text->getText(STYPE_TEXT)); @@ -201,7 +201,7 @@ static void select(Choice *cho, int hlp) { void CGEEngine::NONE() { _sndDrvInfo._dDev = DEV_QUIET; _sndDrvInfo._mDev = DEV_QUIET; - _sound.Open(); + _sound.open(); } @@ -249,7 +249,7 @@ void CGEEngine::AUTO() { _sndDrvInfo._dDev = DEV_AUTO; _sndDrvInfo._mDev = DEV_AUTO; reset(); - _sound.Open(); + _sound.open(); } @@ -261,7 +261,7 @@ void CGEEngine::setPortD() { void CGEEngine::setPortM() { _sndDrvInfo._mBase = xdeco(MIDIPorts[Vmenu::_recent]._text); - _sound.Open(); + _sound.open(); } @@ -276,7 +276,7 @@ void CGEEngine::setDMA() { if (_sndDrvInfo._mDev != _sndDrvInfo._dDev) select(MIDIPorts, MPORT_TEXT); else - _sound.Open(); + _sound.open(); } } // End of namespace CGE diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index 158857c002..ddb4861f03 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -41,10 +41,10 @@ enum EMM_FUN { }; -void *EMM::_frame = NULL; +void *Emm::_frame = NULL; -EMM::EMM(long size): _han(-1), _top(0), _lim(0), _list(NULL) { +Emm::Emm(long size): _han(-1), _top(0), _lim(0), _list(NULL) { /* if (Test()) { @@ -82,7 +82,7 @@ EMM::EMM(long size): _han(-1), _top(0), _lim(0), _list(NULL) { } -EMM::~EMM(void) { +Emm::~Emm(void) { /* FIXME Release(); if (Han >= 0) @@ -97,7 +97,7 @@ EMM::~EMM(void) { } -bool EMM::test() { +bool Emm::test() { /* static char e[] = "EMMXXXX0"; @@ -130,7 +130,7 @@ bool EMM::test() { } -EMS *EMM::alloc(uint16 siz) { +Ems *Emm::alloc(uint16 siz) { /* long size = SIZ(siz), top = Top; @@ -167,14 +167,14 @@ EMS *EMM::alloc(uint16 siz) { } fail: return NULL; */ - warning("STUB: EMM::alloc"); + warning("STUB: Emm::alloc"); return NULL; } -void EMM::release() { +void Emm::release() { while (_list) { - EMS *e = _list; + Ems *e = _list; _list = e->_next; delete e; } @@ -182,11 +182,11 @@ void EMM::release() { } -EMS::EMS(void) : _ptr(0), _size(0), _next(NULL) { +Ems::Ems() : _ptr(0), _size(0), _next(NULL) { } -void *EMS::operator & () const { +void *Ems::operator & () const { /* uint16 pgn = (uint16) (Ptr >> 14), off = (uint16) Ptr & PAGE_MASK, @@ -213,12 +213,12 @@ void *EMS::operator & () const { return (void *) (EMM::Frame + (void *) off); */ - warning("STUB: EMS::operator &"); + warning("STUB: Ems::operator &"); return NULL; } -uint16 EMS::size() { +uint16 Ems::size() { return _size; } diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 5bafd46884..accd6fb4ab 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -95,7 +95,7 @@ Keyboard::~Keyboard() { } Sprite *Keyboard::setClient(Sprite *spr) { - Swap(_client, spr); + swap(_client, spr); return spr; } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 6b0327ff23..3c0dc8a802 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -326,7 +326,7 @@ void sndMidiStop() { // FIXME: STUB: sndMIDIStop } -DATACK *LoadWave(XFile *file, EMM *emm) { +DataCk *loadWave(XFile *file, Emm *emm) { warning("STUB: LoadWave"); return NULL; } @@ -394,9 +394,9 @@ Engine_::~Engine_() { warning("STUB: Engine_::~Engine_"); } -DATACK::~DATACK () { - if (!e && Buf) - free(Buf); +DataCk::~DataCk() { + if (!_e && _buf) + free(_buf); } } // End of namespace CGE diff --git a/engines/cge/general.h b/engines/cge/general.h index 63b94d3872..95660ad4df 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -109,41 +109,41 @@ public: }; -class EMS; +class Ems; -class EMM { - friend class EMS; +class Emm { + friend class Ems; bool test(); long _top; long _lim; - EMS *_list; + Ems *_list; int _han; static void *_frame; public: - EMM(long size = 0); - ~EMM(); - EMS *alloc(uint16 siz); + Emm(long size = 0); + ~Emm(); + Ems *alloc(uint16 siz); void release(); }; -class EMS { - friend class EMM; - EMM *_emm; +class Ems { + friend class Emm; + Emm *_emm; long _ptr; uint16 _size; - EMS *_next; + Ems *_next; public: - EMS(); + Ems(); void *operator & () const; uint16 size(void); }; template -void Swap(T &A, T &B) { +void swap(T &A, T &B) { T a = A; A = B; B = a; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index edafd59111..4c1b8d4c2f 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -60,7 +60,6 @@ extern Sprite *_pocLight; // int _pocPtr = 0; //------------------------------------------------------------------------- extern Sprite *_pocket[]; -extern int _pocPtr; static void SNGame(Sprite *spr, int num) { switch (num) { @@ -290,7 +289,7 @@ int findPocket(Sprite *spr) { } -void selectPocket(int n) { +void CGEEngine::selectPocket(int n) { if (n < 0 || (_pocLight->_seqPtr && _pocPtr == n)) { _pocLight->step(0); n = findPocket(NULL); @@ -591,10 +590,10 @@ void SNSwap(Sprite *spr, int xref) { bool was1 = (was == 0 || was == _now); bool xwas1 = (xwas == 0 || xwas == _now); - Swap(spr->_cave, xspr->_cave); - Swap(spr->_x, xspr->_x); - Swap(spr->_y, xspr->_y); - Swap(spr->_z, xspr->_z); + swap(spr->_cave, xspr->_cave); + swap(spr->_x, xspr->_x); + swap(spr->_y, xspr->_y); + swap(spr->_z, xspr->_z); if (spr->_flags._kept) { int n = findPocket(spr); if (n >= 0) @@ -762,14 +761,14 @@ void SNKill(Sprite *spr) { static void SNSound(Sprite *spr, int wav, int cnt) { if (_sndDrvInfo._dDev) { if (wav == -1) - _sound.Stop(); + _sound.stop(); else - _sound.Play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (SCR_WID / 16)) : 8, cnt); + _sound.play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (SCR_WID / 16)) : 8, cnt); } } -void SNKeep(Sprite *spr, int stp) { +void CGEEngine::SNKeep(Sprite *spr, int stp) { selectPocket(-1); if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) { SNSound(spr, 3, 1); @@ -785,7 +784,7 @@ void SNKeep(Sprite *spr, int stp) { } -void SNGive(Sprite *spr, int stp) { +void CGEEngine::SNGive(Sprite *spr, int stp) { if (spr) { int p = findPocket(spr); if (p >= 0) { @@ -956,13 +955,13 @@ void Snail::runCom() { if (sprel == _hero && sprel->seqTest(-1)) sprel->step(HTALK); _text->say(_text->getText(snc->_val), sprel); - _sys->FunDel = HEROFUN0; + _sys->_funDel = HEROFUN0; } break; case SNINF : if (_talkEnable) { _vm->inf(_text->getText(snc->_val)); - _sys->FunDel = HEROFUN0; + _sys->_funDel = HEROFUN0; } break; case SNTIME : @@ -998,10 +997,10 @@ void Snail::runCom() { SNUncover(sprel, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); break; case SNKEEP : - SNKeep(sprel, snc->_val); + _vm->SNKeep(sprel, snc->_val); break; case SNGIVE : - SNGive(sprel, snc->_val); + _vm->SNGive(sprel, snc->_val); break; case SNGAME : SNGame(sprel, snc->_val); diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 2e06149526..bd874a35b4 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -37,7 +37,6 @@ namespace CGE { #define POCKET_Y 176 #define POCKET_DX 18 #define POCKET_DY 22 -#define POCKET_NX 8 #define POCKET_NY 1 #define POCKET_SX 8 @@ -100,7 +99,6 @@ private: }; -void selectPocket(int n); void pocFul(); @@ -110,7 +108,6 @@ extern bool _dark; extern int _now; extern int _lev; extern int _maxCave; -extern int _pocPtr; extern Bar _barriers[]; extern struct Hxy { int _x; diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index aca4b4d534..a163949ddd 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -35,85 +35,84 @@ namespace CGE { -bool _music = true; -FX _fx = 16; // must precede SOUND!! -SOUND _sound; +Fx _fx = 16; // must precede SOUND!! +Sound _sound; -SOUND::SOUND(void) { +Sound::Sound() { if (Startup::_soundOk) - Open(); + open(); } -SOUND::~SOUND(void) { - Close(); +Sound::~Sound() { + close(); } -void SOUND::Close(void) { - KillMIDI(); +void Sound::close() { + killMidi(); sndDone(); } -void SOUND::Open(void) { +void Sound::open() { sndInit(); - Play(_fx[30000], 8); + play(_fx[30000], 8); } -void SOUND::Play(DATACK *wav, int pan, int cnt) { +void Sound::play(DataCk *wav, int pan, int cnt) { if (wav) { - Stop(); - smpinf._saddr = (uint8 *) &*(wav->EAddr()); - smpinf._slen = (uint16)wav->Size(); - smpinf._span = pan; - smpinf._sflag = cnt; - sndDigiStart(&smpinf); + stop(); + _smpinf._saddr = (uint8 *) &*(wav->eAddr()); + _smpinf._slen = (uint16)wav->size(); + _smpinf._span = pan; + _smpinf._sflag = cnt; + sndDigiStart(&_smpinf); } } -void SOUND::Stop(void) { - sndDigiStop(&smpinf); +void Sound::stop() { + sndDigiStop(&_smpinf); } -FX::FX(int size) : Emm(0L), Current(NULL) { - Cache = new HAN[size]; - for (Size = 0; Size < size; Size++) { - Cache[Size].Ref = 0; - Cache[Size].Wav = NULL; +Fx::Fx(int size) : _emm(0L), _current(NULL) { + _cache = new Han[size]; + for (_size = 0; _size < size; _size++) { + _cache[_size]._ref = 0; + _cache[_size]._wav = NULL; } } -FX::~FX(void) { - Clear(); - delete[] Cache; +Fx::~Fx() { + clear(); + delete[] _cache; } -void FX::Clear(void) { - HAN *p, * q; - for (p = Cache, q = p + Size; p < q; p++) { - if (p->Ref) { - p->Ref = 0; - delete p->Wav; - p->Wav = NULL; +void Fx::clear() { + Han *p, * q; + for (p = _cache, q = p + _size; p < q; p++) { + if (p->_ref) { + p->_ref = 0; + delete p->_wav; + p->_wav = NULL; } } - Emm.release(); - Current = NULL; + _emm.release(); + _current = NULL; } -int FX::Find(int ref) { - HAN *p, * q; +int Fx::find(int ref) { + Han *p, * q; int i = 0; - for (p = Cache, q = p + Size; p < q; p++) { - if (p->Ref == ref) + for (p = _cache, q = p + _size; p < q; p++) { + if (p->_ref == ref) break; else ++i; @@ -122,60 +121,60 @@ int FX::Find(int ref) { } -void FX::Preload(int ref0) { - HAN *CacheLim = Cache + Size; +void Fx::preload(int ref0) { + Han *cacheLim = _cache + _size; int ref; for (ref = ref0; ref < ref0 + 10; ref++) { static char fname[] = "FX00000.WAV"; wtom(ref, fname + 2, 10, 5); INI_FILE file = INI_FILE(fname); - DATACK *wav = LoadWave(&file, &Emm); + DataCk *wav = loadWave(&file, &_emm); if (wav) { - HAN *p = &Cache[Find(0)]; - if (p >= CacheLim) + Han *p = &_cache[find(0)]; + if (p >= cacheLim) break; - p->Wav = wav; - p->Ref = ref; + p->_wav = wav; + p->_ref = ref; } } } -DATACK *FX::Load(int idx, int ref) { +DataCk *Fx::load(int idx, int ref) { static char fname[] = "FX00000.WAV"; wtom(ref, fname + 2, 10, 5); INI_FILE file = INI_FILE(fname); - DATACK *wav = LoadWave(&file, &Emm); + DataCk *wav = loadWave(&file, &_emm); if (wav) { - HAN *p = &Cache[idx]; - p->Wav = wav; - p->Ref = ref; + Han *p = &_cache[idx]; + p->_wav = wav; + p->_ref = ref; } return wav; } -DATACK *FX::operator [](int ref) { +DataCk *Fx::operator [](int ref) { int i; - if ((i = Find(ref)) < Size) - Current = Cache[i].Wav; + if ((i = find(ref)) < _size) + _current = _cache[i]._wav; else { - if ((i = Find(0)) >= Size) { - Clear(); + if ((i = find(0)) >= _size) { + clear(); i = 0; } - Current = Load(i, ref); + _current = load(i, ref); } - return Current; + return _current; } -static uint8 *midi = NULL; +static uint8 *midi = NULL; -void KillMIDI(void) { +void killMidi() { sndMidiStop(); if (midi) { delete[] midi; @@ -184,11 +183,11 @@ void KillMIDI(void) { } -void LoadMIDI(int ref) { +void loadMidi(int ref) { static char fn[] = "00.MID"; wtom(ref, fn, 10, 2); if (INI_FILE::exist(fn)) { - KillMIDI(); + killMidi(); INI_FILE mid = fn; if (mid._error == 0) { uint16 siz = (uint16) mid.size(); @@ -196,7 +195,7 @@ void LoadMIDI(int ref) { if (midi) { mid.read(midi, siz); if (mid._error) - KillMIDI(); + killMidi(); else sndMidiStart(midi); } diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 55dd1615cc..fda8d4f128 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -37,44 +37,42 @@ namespace CGE { #define BAD_MIDI_TEXT 98 -class SOUND { +class Sound { public: - SmpInfo smpinf; - SOUND(void); - ~SOUND(void); - void Open(void); - void Close(void); - void Play(DATACK *wav, int pan, int cnt = 1); - void Stop(void); + SmpInfo _smpinf; + Sound(); + ~Sound(); + void open(); + void close(); + void play(DataCk *wav, int pan, int cnt = 1); + void stop(); }; -class FX { - EMM Emm; - struct HAN { - int Ref; - DATACK *Wav; - } *Cache; - int Size; - DATACK *Load(int idx, int ref); - int Find(int ref); +class Fx { + Emm _emm; + struct Han { + int _ref; + DataCk *_wav; + } *_cache; + int _size; + DataCk *load(int idx, int ref); + int find(int ref); public: - DATACK *Current; - FX(int size = 16); - ~FX(void); - void Clear(void); - void Preload(int ref0); - DATACK *operator[](int ref); + DataCk *_current; + Fx(int size = 16); + ~Fx(); + void clear(); + void preload(int ref0); + DataCk *operator[](int ref); }; +extern Sound _sound; +extern Fx _fx; -extern bool _music; -extern SOUND _sound; -extern FX _fx; - -void LoadMIDI(int ref); -void KillMIDI(); +void loadMidi(int ref); +void killMidi(); } // End of namespace CGE diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 0dfbc67916..6a06cbc537 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -38,7 +38,7 @@ extern char _copr[]; #define id (*(Ident*)_copr) -EMM _miniEmm = MINI_EMM_SIZE; +Emm _miniEmm = MINI_EMM_SIZE; // static Startup _startUp; diff --git a/engines/cge/startup.h b/engines/cge/startup.h index 96c7388070..cc16f2a123 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -70,7 +70,7 @@ public: }; -extern EMM _miniEmm; +extern Emm _miniEmm; const char *usrPath(const char *nam); diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 2988f9ab11..04a9189682 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -105,4 +105,18 @@ void VFile::readBuff() { _ptr = 0; } +long VFile::mark() { + return (_bufMark + _ptr) - _begMark; +} + +long VFile::size() { + return _endMark - _begMark; +} + +long VFile::seek(long pos) { + _recent = NULL; + _lim = 0; + return (_bufMark = _begMark + pos); +} + } // End of namespace CGE diff --git a/engines/cge/vol.h b/engines/cge/vol.h index d8ba0979cb..8ed33d0ab4 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -70,28 +70,20 @@ private: long _begMark; long _endMark; - void readBuff(void); - void writeBuff(void) { } + void readBuff(); + void writeBuff() { } void make(const char *fspec); public: VFile(const char *name, IOMODE mode = REA); ~VFile(); + static void init(); static void deinit(); - static bool exist(const char *name); static const char *next(); - long mark() { - return (_bufMark + _ptr) - _begMark; - } - long size() { - return _endMark - _begMark; - } - long seek(long pos) { - _recent = NULL; - _lim = 0; - return (_bufMark = _begMark + pos); - } + long mark(); + long size(); + long seek(long pos); }; diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 062f83dfca..c3e67f5f95 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -37,114 +37,111 @@ namespace CGE { #define IBM_FORMAT_ALAW 0x0102 #define IBM_FORMAT_ADPCM 0x0103 +typedef char FourCC[4]; // Four-character code -typedef char FOURCC[4]; // Four-character code -typedef uint32 CKSIZE; // 32-bit unsigned size - - -class CKID { // Chunk type identifier +class ChunkId { // Chunk type identifier union { - FOURCC Tx; - uint32 Id; + FourCC _tx; + uint32 _id; }; protected: static XFile *ckFile; public: - CKID(FOURCC t) { - memcpy(Tx, t, sizeof(Tx)); + ChunkId(FourCC t) { + memcpy(_tx, t, sizeof(_tx)); } - CKID(uint32 d) { - Id = d; + ChunkId(uint32 d) { + _id = d; } - CKID(XFile *xf) { - (ckFile = xf)->read(Tx, sizeof(Tx)); + ChunkId(XFile *xf) { + (ckFile = xf)->read(_tx, sizeof(_tx)); } - bool operator !=(CKID &X) { - return Id != X.Id; + bool operator !=(ChunkId &X) { + return _id != X._id; } - bool operator ==(CKID &X) { - return Id == X.Id; + bool operator ==(ChunkId &X) { + return _id == X._id; } - const char *Name(void); + const char *name(); }; -class CKHEA : public CKID { +class CkHea : public ChunkId { protected: - CKSIZE ckSize; // Chunk size field (size of ckData) + uint32 _ckSize; // Chunk size field (size of ckData) public: - CKHEA(XFile *xf) : CKID(xf) { - XRead(xf, &ckSize); + CkHea(XFile *xf) : ChunkId(xf) { + XRead(xf, &_ckSize); } - CKHEA(char id[]) : CKID(id), ckSize(0) { } - void Skip(void); - CKSIZE Size(void) { - return ckSize; + CkHea(char id[]) : ChunkId(id), _ckSize(0) { } + void skip(); + uint32 size() { + return _ckSize; } }; -class FMTCK : public CKHEA { - struct WAV { - uint16 wFormatTag; // Format category - uint16 wChannels; // Number of channels - uint32 dwSamplesPerSec; // Sampling rate - uint32 dwAvgBytesPerSec; // For buffer estimation - uint16 wBlockAlign; // Data block size - } Wav; +class FmtCk : public CkHea { + struct Wav { + uint16 _wFormatTag; // Format category + uint16 _wChannels; // Number of channels + uint32 _dwSamplesPerSec; // Sampling rate + uint32 _dwAvgBytesPerSec; // For buffer estimation + uint16 _wBlockAlign; // Data block size + } _wav; union { struct { - uint16 wBitsPerSample; // Sample size - } Pcm; + uint16 _wBitsPerSample; // Sample size + } _pcm; }; public: - FMTCK(CKHEA &hea); - inline uint16 Channels(void) { - return Wav.wChannels; + FmtCk(CkHea &hea); + inline uint16 channels() { + return _wav._wChannels; } - inline uint32 SmplRate(void) { - return Wav.dwSamplesPerSec; + inline uint32 smplRate() { + return _wav._dwSamplesPerSec; } - inline uint32 ByteRate(void) { - return Wav.dwAvgBytesPerSec; + inline uint32 byteRate() { + return _wav._dwAvgBytesPerSec; } - inline uint16 BlckSize(void) { - return Wav.wBlockAlign; + inline uint16 blckSize() { + return _wav._wBlockAlign; } - inline uint16 SmplSize(void) { - return Pcm.wBitsPerSample; + inline uint16 smplSize() { + return _pcm._wBitsPerSample; } }; -class DATACK : public CKHEA { - bool e; +class DataCk : public CkHea { + bool _e; union { - uint8 *Buf; - EMS *EBuf; + uint8 *_buf; + Ems *_eBuf; }; public: - DATACK(CKHEA &hea); - DATACK(CKHEA &hea, EMM *emm); - DATACK(int first, int last); - ~DATACK(void); - inline uint8 *Addr(void) { - return Buf; + DataCk(CkHea &hea); + DataCk(CkHea &hea, Emm *emm); + DataCk(int first, int last); + ~DataCk(); + inline uint8 *addr() { + return _buf; } - inline EMS *EAddr(void) { - return EBuf; + inline Ems *eAddr() { + return _eBuf; } }; -extern CKID RIFF; -extern CKID WAVE; -extern CKID FMT; -extern CKID DATA; +extern ChunkId _riff; +extern ChunkId _wave; +extern ChunkId _fmt; +extern ChunkId _data; -DATACK *LoadWave(XFile *file, EMM *emm = NULL); +DataCk *loadWave(XFile *file, Emm *emm = NULL); } // End of namespace CGE -- cgit v1.2.3 From dbf9e4679c694277be20dd1d1bc5db8d60f7fabd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 22:30:24 +1000 Subject: CGE: Started work on endifying savegame loading --- engines/cge/general.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engines/cge/general.h b/engines/cge/general.h index 95660ad4df..438e9c014d 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -176,6 +176,12 @@ public: virtual long mark() = 0; virtual long size() = 0; virtual long seek(long pos) = 0; + + uint16 readWord() { + uint16 v; + read(&v, sizeof(uint16)); + return FROM_LE_32(v); + } }; -- cgit v1.2.3 From fe0ff3b2e98b8a0ec68f497925aefbdea77aeed0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 20:26:34 +1000 Subject: CGE: Converted loadGame to use the ScummVM serialiser --- engines/cge/cge_main.cpp | 46 +++++++++++++++++++++++++++++++++++----------- engines/cge/general.cpp | 4 ++++ engines/cge/general.h | 6 ------ engines/cge/vga13h.cpp | 24 ++++++++++++++++++++++++ engines/cge/vga13h.h | 3 +++ 5 files changed, 66 insertions(+), 17 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6b02f82910..08e373d322 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -26,6 +26,8 @@ */ #include "common/scummsys.h" +#include "common/memstream.h" +#include "common/serializer.h" #include "cge/general.h" #include "cge/sound.h" #include "cge/startup.h" @@ -182,14 +184,39 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { Sprite *spr; int i; - for (st = _savTab; st->Ptr; st++) { - if (file._error) - error("Bad SVG"); - file.read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len); + // Read the data into a data buffer + int size = file.size() - file.mark(); + byte *dataBuffer = new byte[size]; + file.read(dataBuffer, size); + Common::MemoryReadStream readStream(dataBuffer, size, DisposeAfterUse::YES); + Common::Serializer s(&readStream, NULL); + + // Synchronise header data + s.syncAsUint16LE(_now); + s.syncAsUint16LE(_oldLev); + s.syncAsUint16LE(_demoText); + for (i = 0; i < 5; ++i) + s.syncAsUint16LE(_game); + s.syncAsSint16LE(i); // unused VGA::Mono variable + s.syncAsUint16LE(_music); + s.syncBytes(_volume, 2); + for (i = 0; i < 4; ++i) + s.syncAsUint16LE(_flag[i]); + + for (i = 0; i < CAVE_MAX; ++i) { + s.syncAsSint16LE(_heroXY[i]._x); + s.syncAsUint16LE(_heroXY[i]._y); } + for (i = 0; i < 1 + CAVE_MAX; ++i) { + s.syncAsByte(_barriers[i]._horz); + s.syncAsByte(_barriers[i]._vert); + } + for (i = 0; i < POCKET_NX; ++i) + s.syncAsUint16LE(_pocref[i]); - file.read((uint8 *) &i, sizeof(i)); - if (i != SVGCHKSUM) + uint16 checksum; + s.syncAsUint16LE(checksum); + if (checksum != SVGCHKSUM) error("%s", _text->getText(BADSVG_TEXT)); if (Startup::_core < CORE_HIG) @@ -202,12 +229,9 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { } if (! tiny) { // load sprites & pocket - while (!file._error) { + while (!readStream.eos()) { Sprite S(this, NULL); - uint16 n = file.read((uint8 *) &S, sizeof(S)); - - if (n != sizeof(S)) - break; + S.sync(s); S._prev = S._next = NULL; spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 3c0dc8a802..50dfeaeb5a 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -238,6 +238,10 @@ uint16 IoHand::read(void *buf, uint16 len) { error("Read %s - %d bytes", _file->getName(), len); if (_crypt) _seed = _crypt(buf, len, Seed); + + if (_file->eos()) + _error = 1; + return bytesRead; } diff --git a/engines/cge/general.h b/engines/cge/general.h index 438e9c014d..95660ad4df 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -176,12 +176,6 @@ public: virtual long mark() = 0; virtual long size() = 0; virtual long seek(long pos) = 0; - - uint16 readWord() { - uint16 v; - read(&v, sizeof(uint16)); - return FROM_LE_32(v); - } }; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index aa7cd8ad06..1aec1689bc 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -779,6 +779,30 @@ BMP_PTR Sprite::ghost() { return NULL; } +void Sprite::sync(Common::Serializer &s) { + uint16 unused; + + s.syncAsUint16LE(unused); + s.syncAsUint16LE(unused); // _ext + s.syncAsUint16LE(_ref); + s.syncAsByte(_cave); + s.syncBytes((byte *)&_flags, 2); + s.syncAsUint16LE(_x); + s.syncAsUint16LE(_y); + s.syncAsByte(_z); + s.syncAsUint16LE(_w); + s.syncAsUint16LE(_h); + s.syncAsUint16LE(_time); + s.syncAsByte(_nearPtr); + s.syncAsByte(_takePtr); + s.syncAsUint16LE(_seqPtr); + s.syncAsUint16LE(_shpCnt); + s.syncBytes((byte *)&_file[0], 9); + _file[8] = '\0'; + + s.syncAsUint16LE(unused); // _prev + s.syncAsUint16LE(unused); // _next +} Sprite *spriteAt(int x, int y) { Sprite *spr = NULL, * tail = _vga->_showQ->last(); diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 5ef7f99c69..d5a87e973d 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -28,6 +28,7 @@ #ifndef __CGE_VGA13H__ #define __CGE_VGA13H__ +#include "common/serializer.h" #include "graphics/surface.h" #include "cge/general.h" #include "cge/bitmap.h" @@ -201,6 +202,7 @@ public: char _file[MAXFILE]; Sprite *_prev; Sprite *_next; + bool works(Sprite *spr); bool seqTest(int n); inline bool active() { @@ -231,6 +233,7 @@ public: Snail::Com *snList(SNLIST type); virtual void touch(uint16 mask, int x, int y); virtual void tick(); + void sync(Common::Serializer &s); private: CGEEngine *_vm; }; -- cgit v1.2.3 From a1f177317c780f1223f153ccc3934eae2a76111b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 20:40:24 +1000 Subject: CGE: Bugfix for ProgName method --- engines/cge/general.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 50dfeaeb5a..c4552e6f23 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -99,12 +99,12 @@ void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, c } const char *progName(const char *ext) { - warning("progName"); - - static Common::String buf = "CGE"; + static char buf[MAXFILE]; + strcpy(buf, "CGE"); if (ext) - buf += ext; - return buf.c_str(); + strcat(buf, ext); + + return buf; } char *mergeExt(char *buf, const char *nam, const char *ext) { @@ -238,10 +238,6 @@ uint16 IoHand::read(void *buf, uint16 len) { error("Read %s - %d bytes", _file->getName(), len); if (_crypt) _seed = _crypt(buf, len, Seed); - - if (_file->eos()) - _error = 1; - return bytesRead; } -- cgit v1.2.3 From 41c7482a525951407dfa09b9793eeef140f21979 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 20:51:29 +1000 Subject: CGE: Implement random number source --- engines/cge/cge.cpp | 2 +- engines/cge/cge.h | 1 + engines/cge/general.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 87c3964563..7eeb20bebb 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -41,7 +41,7 @@ namespace CGE { CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) - : Engine(syst), _gameDescription(gameDescription) { + : Engine(syst), _gameDescription(gameDescription), _randomSource("cge") { // Debug/console setup DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 04f395559f..a3adf43dde 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -70,6 +70,7 @@ public: bool _music; int _pocref[POCKET_NX]; uint8 _volume[2]; + Common::RandomSource _randomSource; virtual Common::Error run(); GUI::Debugger *getDebugger() { diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index c4552e6f23..30b5f3186b 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -25,6 +25,7 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ +#include "cge/cge.h" #include "cge/general.h" #include "cge/snddrv.h" #include "cge/wav.h" @@ -356,8 +357,7 @@ long timer(void) { } int new_random(int range) { - warning("STUB: new_random(a)"); - return 0; + return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } #define TIMER_INT 0x08 -- cgit v1.2.3 From 44490c378dd78f8a51203ca8c3d45126bbd9fd08 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 21:07:14 +1000 Subject: CGE: _hero isn't meant to be instantiated during the engine setup --- engines/cge/cge.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 7eeb20bebb..df40db55e6 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -58,6 +58,7 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) void CGEEngine::setup() { // Initialise fields _lastFrame = 0; + _hero = NULL; // Create debugger console _console = new CGEConsole(this); @@ -72,7 +73,6 @@ void CGEEngine::setup() { _text = new Text(this, progName(), 128); _vga = new Vga(M13H); _heart = new Heart; - _hero = new WALK(this, NULL); _sys = new System(this); _pocLight = new Sprite(this, LI); for (int i = 0; i < POCKET_NX; i++) -- cgit v1.2.3 From 24fa551a71453dd712b5cb0223b2ff85026a2894 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 21:11:59 +1000 Subject: CGE: Fix synchronising Sprite::_seqPtr to be a signed int16 --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 1aec1689bc..c349950bee 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -795,7 +795,7 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(_time); s.syncAsByte(_nearPtr); s.syncAsByte(_takePtr); - s.syncAsUint16LE(_seqPtr); + s.syncAsSint16LE(_seqPtr); s.syncAsUint16LE(_shpCnt); s.syncBytes((byte *)&_file[0], 9); _file[8] = '\0'; -- cgit v1.2.3 From c676f88da02f56a8b7caecb83bcf9e1a9f7e663c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 21:39:14 +1000 Subject: CGE: Rearrange engine setup so sprite arrays are setup before they're needed --- engines/cge/cge.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index df40db55e6..eee359b74c 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -69,21 +69,7 @@ void CGEEngine::setup() { Bitmap::init(); Talk::init(); - // Initialise engine objects - _text = new Text(this, progName(), 128); - _vga = new Vga(M13H); - _heart = new Heart; - _sys = new System(this); - _pocLight = new Sprite(this, LI); - for (int i = 0; i < POCKET_NX; i++) - _pocket[i] = new Sprite(this, NULL); - _sprite = new Sprite(this, NULL); - _miniCave = new Sprite(this, NULL); - _shadow = new Sprite(this, NULL); - _horzLine = new Sprite(this, HL); - _infoLine = new InfoLine(this, INFO_W); - _cavLight = new Sprite(this, PR); - _debugLine = new InfoLine(this, SCR_WID); + // Initialise sprite arrays used by game objects MB[0] = new Bitmap("BRICK", true); MB[1] = NULL; HL[0] = new Bitmap("HLINE", true); @@ -101,6 +87,22 @@ void CGEEngine::setup() { LI[2] = new Bitmap("LITE2", true); LI[3] = new Bitmap("LITE3", true); LI[4] = NULL; + + // Initialise engine objects + _text = new Text(this, progName(), 128); + _vga = new Vga(M13H); + _heart = new Heart; + _sys = new System(this); + _pocLight = new Sprite(this, LI); + for (int i = 0; i < POCKET_NX; i++) + _pocket[i] = new Sprite(this, NULL); + _sprite = new Sprite(this, NULL); + _miniCave = new Sprite(this, NULL); + _shadow = new Sprite(this, NULL); + _horzLine = new Sprite(this, HL); + _infoLine = new InfoLine(this, INFO_W); + _cavLight = new Sprite(this, PR); + _debugLine = new InfoLine(this, SCR_WID); _snail = new Snail(this, false); _snail_ = new Snail(this, true); -- cgit v1.2.3 From 2997db0040d4c4e7ead02f37d8e7bd2c0ce6b206 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 22:06:26 +1000 Subject: CGE: Minor bugfixes for game loading --- engines/cge/cge_main.cpp | 2 +- engines/cge/vga13h.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 08e373d322..14109ddd6f 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -229,7 +229,7 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { } if (! tiny) { // load sprites & pocket - while (!readStream.eos()) { + while (readStream.pos() < readStream.size()) { Sprite S(this, NULL); S.sync(s); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index c349950bee..6c20a78cae 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -349,6 +349,14 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; + _ref = 0; + _x = _y = 0; + _w = _h = 0; + _time = 0; + _seqPtr = 0; + _shpCnt = 0; + _prev = _next = NULL; + setShapeList(shpP); } -- cgit v1.2.3 From c86c62b288dd3c8a1a630864142f99b177e4db3a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jul 2011 23:13:12 +0200 Subject: CGE: Cleanup and renaming. Also move some static and global functions to CGEEngine. --- engines/cge/bitmap.cpp | 4 +- engines/cge/btfile.cpp | 2 +- engines/cge/cfile.cpp | 12 +-- engines/cge/cge.cpp | 21 ++++ engines/cge/cge.h | 69 ++++++++++++- engines/cge/cge_main.cpp | 82 +++++++-------- engines/cge/cge_main.h | 13 +-- engines/cge/config.cpp | 4 +- engines/cge/console.h | 2 +- engines/cge/ems.cpp | 2 +- engines/cge/events.cpp | 10 +- engines/cge/general.cpp | 18 ++-- engines/cge/general.h | 10 +- engines/cge/mixer.cpp | 2 +- engines/cge/snail.cpp | 264 ++++++++++++++++++++--------------------------- engines/cge/snail.h | 9 -- engines/cge/vga13h.cpp | 10 +- engines/cge/vga13h.h | 5 +- engines/cge/vmenu.cpp | 2 +- 19 files changed, 281 insertions(+), 260 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index d0c7ba6ab5..4630f87456 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -142,7 +142,7 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL) { } -Bitmap::~Bitmap(void) { +Bitmap::~Bitmap() { if (memType(_m) == FAR_MEM) free(_m); @@ -196,7 +196,7 @@ uint16 Bitmap::moveVmap(uint8 *buf) { } -BMP_PTR Bitmap::code(void) { +BMP_PTR Bitmap::code() { if (_m) { uint16 i, cnt; diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 3d0ce8a061..eda18ebaaf 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -52,7 +52,7 @@ BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) } -BtFile::~BtFile(void) { +BtFile::~BtFile() { for (int i = 0; i < BT_LEVELS; i++) { putPage(i, false); delete _buff[i]._page; diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 51e580a53b..b235d552b2 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -51,7 +51,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) error("No core for I/O [%s]", name); } -IoBuf::~IoBuf(void) { +IoBuf::~IoBuf() { if (_mode > REA) writeBuff(); if (_buff) @@ -59,14 +59,14 @@ IoBuf::~IoBuf(void) { } -void IoBuf::readBuff(void) { +void IoBuf::readBuff() { _bufMark = IoHand::mark(); _lim = IoHand::read(_buff, IOBUF_SIZE); _ptr = 0; } -void IoBuf::writeBuff(void) { +void IoBuf::writeBuff() { if (_lim) { IoHand::write(_buff, _lim); _bufMark = IoHand::mark(); @@ -203,11 +203,11 @@ CFile::CFile(const char *name, IOMODE mode, CRYPT *crpt) } -CFile::~CFile(void) { +CFile::~CFile() { } -void CFile::flush(void) { +void CFile::flush() { if (_mode > REA) writeBuff(); else @@ -222,7 +222,7 @@ void CFile::flush(void) { } -long CFile::mark(void) { +long CFile::mark() { return _bufMark + ((_mode > REA) ? _lim : _ptr); } diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index eee359b74c..067b9eb6e9 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -167,6 +167,27 @@ void CGEEngine::setup() { _savTab[15].Ptr = NULL; _savTab[15].Len = 0; _savTab[15].Flg = 0; + + if (_isDemo) { + _maxCaveArr[0] = CAVE_MAX; + _maxCaveArr[1] = -1; + _maxCaveArr[2] = -1; + _maxCaveArr[3] = -1; + _maxCaveArr[4] = -1; + } else { + _maxCaveArr[0] = 1; + _maxCaveArr[1] = 8; + _maxCaveArr[2] = 16; + _maxCaveArr[3] = 23; + _maxCaveArr[4] = 24; + }; + _maxCave = 0; + _dark = false; + _game = false; + _now = 1; + _lev = -1; + + } CGEEngine::~CGEEngine() { diff --git a/engines/cge/cge.h b/engines/cge/cge.h index a3adf43dde..e4b8ef86c1 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -30,6 +30,7 @@ #include "graphics/surface.h" #include "engines/advancedDetector.h" #include "cge/console.h" +#include "cge/bitmap.h" #define CGE_SAVEGAME_VERSION 1 @@ -43,6 +44,8 @@ enum { kCGEDebug = 1 << 0 }; +enum SNLIST { NEAR, TAKE }; + #define POCKET_NX 8 struct SavTab { @@ -70,6 +73,15 @@ public: bool _music; int _pocref[POCKET_NX]; uint8 _volume[2]; + int _maxCaveArr[5]; + + int _maxCave; + bool _flag[4]; + bool _dark; + bool _game; + int _now; + int _lev; + Common::RandomSource _randomSource; virtual Common::Error run(); @@ -95,7 +107,6 @@ public: void takeName(); void inf(const char *txt); void selectSound(); - void SNSelect(); void dummy() {} void NONE(); void SB(); @@ -116,8 +127,58 @@ public: void SaveGame(XFile &file); void switchMusic(); void selectPocket(int n); - void SNKeep(Sprite *spr, int stp); - void SNGive(Sprite *spr, int stp); + void expandSprite(Sprite *spr); + void contractSprite(Sprite *spr); + int findPocket(Sprite *spr); + void feedSnail(Sprite *spr, SNLIST snq); + void pocFul(); + void hide1(Sprite *spr); + void loadMapping(); + void saveMapping(); + + void snBackPt(Sprite *spr, int stp); + void snBarrier(int cav, int bar, bool horz); + void snCover(Sprite *spr, int xref); + void snFlag(int fn, bool v); + void snFlash(bool on); + void snGame(Sprite *spr, int num); + void snGhost(Bitmap *bmp); + void snGive(Sprite *spr, int stp); + void snHide(Sprite *spr, int val); + void snKeep(Sprite *spr, int stp); + void snKill(Sprite *spr); + void snLevel(Sprite *spr, int lev); + void snLight(bool in); + void snMouse(bool on); + void snNNext(Sprite *sprel, int p); + void snPort(Sprite *spr, int port); + void snReach(Sprite *spr, int mode); + void snRelZ(Sprite *spr, int z); + void snRNNext(Sprite *sprel, int p); + void snRTNext(Sprite *sprel, int p); + void snSelect(); + void snSend(Sprite *spr, int val); + void snRelX(Sprite *spr, int x); + void snRelY(Sprite *spr, int y); + void snRmNear(Sprite *spr); + void snRmTake(Sprite *spr); + void snRSeq(Sprite *spr, int val); + void snSeq(Sprite *spr, int val); + void snSetRef(Sprite *spr, int nr); + void snSetX(Sprite *spr, int x); + void snSetX0(int cav, int x0); + void snSetXY(Sprite *spr, uint16 xy); + void snSetY(Sprite *spr, int y); + void snSetY0(int cav, int y0); + void snSetZ(Sprite *spr, int z); + void snSlave(Sprite *spr, int ref); + void snSound(Sprite *spr, int wav, int cnt); + void snSwap(Sprite *spr, int xref); + void snTNext(Sprite *sprel, int p); + void snTrans(Sprite *spr, int trans); + void snUncover(Sprite *spr, Sprite *xspr); + void snWalk(Sprite *spr, int x, int y); + void snZTrim(Sprite *spr); private: CGEConsole *_console; @@ -128,7 +189,7 @@ private: class Console : public GUI::Debugger { public: Console(CGEEngine *vm) {} - virtual ~Console(void) {} + virtual ~Console() {} }; } // End of namespace CGE diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 14109ddd6f..456a11092e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -100,17 +100,14 @@ static Ems *_mini = _miniEmm.alloc((uint16)MINI_EMM_SIZE); static BMP_PTR *_miniShpList = NULL; static BMP_PTR _miniShp[] = { NULL, NULL }; static bool _finis = false; -//static int _startup = 1; int _offUseCount; uint16 *_intStackPtr = false; Hxy _heroXY[CAVE_MAX] = {{0, 0}}; Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; -extern int findPocket(Sprite *); extern Dac _stdPal[58]; -void feedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; @@ -119,7 +116,7 @@ uint8 &Cluster::cell() { } -bool Cluster::Protected(void) { +bool Cluster::Protected() { /* if (A == Barriers[Now]._vert || B == Barriers[Now]._horz) return true; @@ -250,7 +247,7 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { } -static void SaveSound(void) { +static void SaveSound() { CFile cfg(usrPath(progName(CFG_EXT)), WRI); if (!cfg._error) cfg.write(&_sndDrvInfo, sizeof(_sndDrvInfo) - sizeof(_sndDrvInfo.Vol2)); @@ -324,7 +321,7 @@ static void loadHeroXY() { } -static void loadMapping() { +void CGEEngine::loadMapping() { if (_now <= CAVE_MAX) { INI_FILE cf(progName(".TAB")); if (!cf._error) { @@ -357,7 +354,7 @@ void WALK::tick() { for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (distance(spr) < 2) { if (!spr->_flags._near) { - feedSnail(spr, NEAR); + _vm->feedSnail(spr, NEAR); spr->_flags._near = true; } } else { @@ -423,7 +420,7 @@ void WALK::turn(DIR d) { } -void WALK::park(void) { +void WALK::park() { if (_time == 0) ++_time; @@ -438,7 +435,7 @@ void WALK::park(void) { void WALK::findWay(Cluster c) { warning("STUB: WALK::findWay"); /* - bool Find1Way(void); + bool Find1Way(); extern uint16 Target; if (c != Here) { @@ -539,15 +536,14 @@ void CGEEngine::setMapBrick(int x, int z) { } } -static void SwitchColorMode(void); +static void SwitchColorMode(); static void switchDebug(); -static void KillSprite(void); -static void PushSprite(void); -static void PullSprite(void); -static void NextStep(void); -static void SaveMapping(void); +static void KillSprite(); +static void PushSprite(); +static void PullSprite(); +static void NextStep(); -static void KeyClick(void) { +static void KeyClick() { SNPOST_(SNSOUND, -1, 5, NULL); } @@ -654,7 +650,7 @@ void CGEEngine::caveUp() { if (spr->_flags._back) spr->backShow(); else - ExpandSprite(spr); + expandSprite(spr); } spr = n; } @@ -814,7 +810,7 @@ void System::touch(uint16 mask, int x, int y) { break; case '`': if (_keyboard->_key[ALT]) - SaveMapping(); + _vm->saveMapping(); else _vm->switchMapping(); break; @@ -890,9 +886,9 @@ void System::touch(uint16 mask, int x, int y) { if (y >= WORLD_HIG) { if (x < BUTTON_X) { // select cave? if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && - x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && !_game) { + x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && !_vm->_game) { cav = ((y - CAVE_Y) / CAVE_DY) * CAVE_NX + (x - CAVE_X) / CAVE_DX + 1; - if (cav > _maxCave) + if (cav > _vm->_maxCave) cav = 0; } else { cav = 0; @@ -922,7 +918,7 @@ void System::touch(uint16 mask, int x, int y) { } else { if (!_talk && _snail->idle() && _hero - && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_game) { + && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_vm->_game) { _hero->findWay(XZ(x, y)); } } @@ -961,7 +957,7 @@ void System::tick() { /* -static void SpkOpen(void) { +static void SpkOpen() { asm in al,0x61 asm or al,0x03 asm out 0x61,al @@ -970,7 +966,7 @@ static void SpkOpen(void) { } -static void SpkClose(void) { +static void SpkClose() { asm in al,0x61 asm and al,0xFC asm out 0x61,al @@ -979,7 +975,7 @@ static void SpkClose(void) { */ -static void SwitchColorMode(void) { +static void SwitchColorMode() { SNPOST_(SNSEQ, 121, _vga->_mono = !_vga->_mono, NULL); KeyClick(); _vga->setColors(Vga::_sysPal, 64); @@ -1054,7 +1050,7 @@ void CGEEngine::switchMapping() { } -static void KillSprite(void) { +static void KillSprite() { _sprite->_flags._kill = true; _sprite->_flags._bDel = true; SNPOST_(SNKILL, -1, 0, _sprite); @@ -1062,7 +1058,7 @@ static void KillSprite(void) { } -static void PushSprite(void) { +static void PushSprite() { Sprite *spr = _sprite->_prev; if (spr) { _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); @@ -1073,7 +1069,7 @@ static void PushSprite(void) { } -static void PullSprite(void) { +static void PullSprite() { bool ok = false; Sprite *spr = _sprite->_next; if (spr) { @@ -1091,12 +1087,12 @@ static void PullSprite(void) { } -static void NextStep(void) { +static void NextStep() { SNPOST_(SNSTEP, 0, 0, _sprite); } -static void SaveMapping() { +void CGEEngine::saveMapping() { { IoHand cf(progName(".TAB"), UPD); if (!cf._error) { @@ -1217,7 +1213,7 @@ void Sprite::touch(uint16 mask, int x, int y) { } if (_flags._syst) return; // cannot access system sprites - if (_game) if (mask & L_UP) { + if (_vm->_game) if (mask & L_UP) { mask &= ~L_UP; mask |= R_UP; } @@ -1226,7 +1222,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if (ps) { if (_flags._kept || _hero->distance(this) < MAX_DISTANCE) { if (works(ps)) { - feedSnail(ps, TAKE); + _vm->feedSnail(ps, TAKE); } else offUse(); _vm->selectPocket(-1); @@ -1239,8 +1235,8 @@ void Sprite::touch(uint16 mask, int x, int y) { if (_hero->distance(this) < MAX_DISTANCE) { /// if (_flags._port) { - if (findPocket(NULL) < 0) - pocFul(); + if (_vm->findPocket(NULL) < 0) + _vm->pocFul(); else { SNPOST(SNREACH, -1, -1, this); SNPOST(SNKEEP, -1, -1, this); @@ -1251,7 +1247,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if (snList(TAKE)[_takePtr]._com == SNNEXT) offUse(); else - feedSnail(this, TAKE); + _vm->feedSnail(this, TAKE); } else offUse(); } @@ -1606,7 +1602,7 @@ void CGEEngine::runGame() { uint8 *ptr = (uint8 *) &*_mini; if (ptr != NULL) { loadSprite("MINI", -1, 0, MINI_X, MINI_Y); - ExpandSprite(_miniCave = _sprite); // NULL is ok + expandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { _miniCave->_flags._hide = true; _miniCave->moveShapes(ptr); @@ -1618,7 +1614,7 @@ void CGEEngine::runGame() { } if (_hero) { - ExpandSprite(_hero); + expandSprite(_hero); _hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); if (INI_FILE::exist("00SHADOW.SPR")) { loadSprite("00SHADOW", -1, 0, _hero->_x + 14, _hero->_y + 51); @@ -1645,7 +1641,7 @@ void CGEEngine::runGame() { _mouse->Busy = _vga->_spareQ->locate(BUSY_REF); if (_mouse->Busy) - ExpandSprite(_mouse->Busy); + expandSprite(_mouse->Busy); _startupMode = 0; @@ -1682,7 +1678,7 @@ void CGEEngine::movie(const char *ext) { const char *fn = progName(ext); if (INI_FILE::exist(fn)) { loadScript(fn); - ExpandSprite(_vga->_spareQ->locate(999)); + expandSprite(_vga->_spareQ->locate(999)); feedSnail(_vga->_showQ->locate(999), TAKE); // FIXME: Allow ScummVM to handle mouse display @@ -1793,9 +1789,9 @@ bool CGEEngine::showTitle(const char *name) { loadGame(file, true); // only system vars _vga->setColors(Vga::_sysPal, 64); _vga->update(); - if (FINIS) { + if (_flag[3]) { //flag FINIS Startup::_mode++; - FINIS = false; + _flag[3] = false; } } else Startup::_mode++; @@ -1815,14 +1811,14 @@ bool CGEEngine::showTitle(const char *name) { /* -void StkDump (void) { +void StkDump () { CFILE f("!STACK.DMP", BFW); f.Write((uint8 *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2); } */ -void CGEEngine::cge_main(void) { +void CGEEngine::cge_main() { uint16 intStack[STACK_SIZ / 2]; _intStackPtr = intStack; @@ -1852,7 +1848,7 @@ void CGEEngine::cge_main(void) { movie("X02"); // intro runGame(); _startupMode = 2; - if (FINIS) + if (_flag[3]) // Flag FINIS movie("X03"); } else _vga->sunset(); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index e9c96931c3..3ef3679e8e 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -109,8 +109,8 @@ namespace CGE { #define SYSTIMERATE 6 // 12 Hz #define HEROFUN0 (40 * 12) #define HEROFUN1 ( 2 * 12) -#define PAIN (_flag[0]) -#define FINIS (_flag[3]) +#define PAIN (_vm->_flag[0]) +//#define FINIS (_vm->_flag[3]) class System : public Sprite { @@ -132,10 +132,10 @@ private: class Cluster : public Couple { public: static uint8 _map[MAP_ZCNT][MAP_XCNT]; - uint8 &cell(void); - Cluster(void) : Couple() { } + uint8 &cell(); + Cluster() : Couple() { } Cluster(int a, int b) : Couple(a, b) { } - bool Protected(void); + bool Protected(); }; @@ -162,9 +162,6 @@ private: Cluster XZ(int x, int y); Cluster XZ(Couple xy); -void ExpandSprite(Sprite *spr); -void ContractSprite(Sprite *spr); - extern WALK *_hero; extern Vga *_vga; extern Heart *_heart; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 11f2088034..808d74ff9b 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -154,7 +154,7 @@ void CGEEngine::selectSound() { } -static void reset(void) { +static void reset() { _sndDrvInfo._dBase = _sndDrvInfo._dIrq = _sndDrvInfo._dDma = _sndDrvInfo._mBase = DETECT; } @@ -182,7 +182,7 @@ static uint16 xdeco(const char *str) { static Choice *_cho; static int _hlp; -void CGEEngine::SNSelect() { +void CGEEngine::snSelect() { inf(_text->getText(_hlp)); _talk->gotoxy(_talk->_x, FONT_HIG / 2); (new Vmenu(this, _cho, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); diff --git a/engines/cge/console.h b/engines/cge/console.h index 7f265202ea..25a1a4fae3 100644 --- a/engines/cge/console.h +++ b/engines/cge/console.h @@ -32,7 +32,7 @@ class CGEEngine; class CGEConsole : public GUI::Debugger { public: CGEConsole(CGEEngine *vm); - virtual ~CGEConsole(void); + virtual ~CGEConsole(); private: CGEEngine *_vm; diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index ddb4861f03..93342f77da 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -82,7 +82,7 @@ Emm::Emm(long size): _han(-1), _top(0), _lim(0), _list(NULL) { } -Emm::~Emm(void) { +Emm::~Emm() { /* FIXME Release(); if (Han >= 0) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index accd6fb4ab..e904b710ba 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -162,17 +162,17 @@ MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold( } -MOUSE::~MOUSE(void) { +MOUSE::~MOUSE() { Off(); } -//void MOUSE::SetFun (void) +//void MOUSE::SetFun() //{ //} -void MOUSE::On(void) { +void MOUSE::On() { if (_seqPtr && Exist) { _active = true; step(0); @@ -181,7 +181,7 @@ void MOUSE::On(void) { } -void MOUSE::Off(void) { +void MOUSE::Off() { if (_seqPtr == 0) { if (Exist) { _active = false; @@ -261,7 +261,7 @@ void EventManager::poll() { } } -void EventManager::handleEvents(void) { +void EventManager::handleEvents() { while (EvtTail != EvtHead) { CGEEvent e = Evt[EvtTail]; if (e._msk) { diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 30b5f3186b..8464d020e5 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -138,10 +138,10 @@ char *forceExt(char *buf, const char *nam, const char *ext) { static unsigned Seed = 0xA5; -unsigned FastRand(void) { +unsigned fastRand() { return Seed = 257 * Seed + 817; } -unsigned FastRand(unsigned s) { +unsigned fastRand(unsigned s) { return Seed = 257 * s + 817; } @@ -149,12 +149,12 @@ uint16 RCrypt(void *buf, uint16 siz, uint16 seed) { if (buf && siz) { byte *b = static_cast(buf); byte *q = b + (siz - 1); - seed = FastRand(seed); + seed = fastRand(seed); *b++ ^= seed; while (buf < q) - *b++ ^= FastRand(); + *b++ ^= fastRand(); if (buf == q) - *b ^= (seed = FastRand()); + *b ^= (seed = fastRand()); } return seed; } @@ -225,7 +225,7 @@ IoHand::IoHand(const char *name, IOMODE mode, CRYPT *crpt) _file->open(name); } -IoHand::~IoHand(void) { +IoHand::~IoHand() { _file->close(); delete _file; } @@ -258,7 +258,7 @@ uint16 IoHand::write(void *buf, uint16 len) { */ } -long IoHand::mark(void) { +long IoHand::mark() { return _file->pos(); } @@ -267,7 +267,7 @@ long IoHand::seek(long pos) { return _file->pos(); } -long IoHand::size(void) { +long IoHand::size() { return _file->size(); } @@ -344,7 +344,7 @@ int takeEnum(const char **tab, const char *txt) { return -1; } -long timer(void) { +long timer() { /* asm mov ax,0x40 asm mov es,ax diff --git a/engines/cge/general.h b/engines/cge/general.h index 95660ad4df..7cf3ec3e41 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -105,7 +105,7 @@ protected: static void newTimer(...); public: Engine_(uint16 tdiv); - ~Engine_(void); + ~Engine_(); }; @@ -138,7 +138,7 @@ class Ems { public: Ems(); void *operator & () const; - uint16 size(void); + uint16 size(); }; @@ -200,7 +200,7 @@ public: long mark(); long size(); long seek(long pos); - //timeb Time (void); + //timeb Time (); // void SetTime (timeb t); }; @@ -226,7 +226,7 @@ void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, c const char *progName(const char *ext = NULL); char *mergeExt(char *buf, const char *nam, const char *ext); char *forceExt(char *buf, const char *nam, const char *ext); -unsigned fastRand(void); +unsigned fastRand(); unsigned fastRand(unsigned s); uint16 rCrypt(void *buf, uint16 siz, uint16 seed); uint16 atow(const char *a); @@ -234,7 +234,7 @@ uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); char *dwtom(uint32 val, char * str, int radix, int len); int takeEnum(const char **tab, const char *txt); -long timer(void); +long timer(); int new_random(int range); } // End of namespace CGE diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index b7c4b8ca83..d4a5212552 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -132,7 +132,7 @@ void Mixer::tick() { } -void Mixer::update(void) { +void Mixer::update() { _led[0]->step(_sndDrvInfo.Vol4._ml); _led[1]->step(_sndDrvInfo.Vol4._dl); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 4c1b8d4c2f..683568e1a8 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -44,14 +44,6 @@ static void _disable() { warning("STUB: _disable"); } -int _maxCave = 0; - -bool _flag[4]; -bool _dark = false; -bool _game = false; -int _now = 1; -int _lev = -1; - extern Sprite *_pocLight; //------------------------------------------------------------------------- @@ -61,7 +53,7 @@ extern Sprite *_pocLight; //------------------------------------------------------------------------- extern Sprite *_pocket[]; -static void SNGame(Sprite *spr, int num) { +void CGEEngine::snGame(Sprite *spr, int num) { switch (num) { case 1 : { #define STAGES 8 @@ -270,18 +262,18 @@ static void SNGame(Sprite *spr, int num) { } -void ExpandSprite(Sprite *spr) { +void CGEEngine::expandSprite(Sprite *spr) { if (spr) _vga->_showQ->insert(_vga->_spareQ->remove(spr)); } -void ContractSprite(Sprite *spr) { +void CGEEngine::contractSprite(Sprite *spr) { if (spr) _vga->_spareQ->append(_vga->_showQ->remove(spr)); } -int findPocket(Sprite *spr) { +int CGEEngine::findPocket(Sprite *spr) { for (int i = 0; i < POCKET_NX; i++) if (_pocket[i] == spr) return i; @@ -304,8 +296,7 @@ void CGEEngine::selectPocket(int n) { _pocLight->gotoxy(POCKET_X + _pocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); } - -void pocFul() { +void CGEEngine::pocFul() { _hero->park(); SNPOST(SNWAIT, -1, -1, _hero); SNPOST(SNSEQ, -1, POC_FUL, _hero); @@ -314,13 +305,11 @@ void pocFul() { SNPOST(SNSAY, 1, POC_FUL_TEXT, _hero); } - -void Hide1(Sprite *spr) { +void CGEEngine::hide1(Sprite *spr) { SNPOST_(SNGHOST, -1, 0, spr->ghost()); } - -void SNGhost(Bitmap *bmp) { +void CGEEngine::snGhost(Bitmap *bmp) { // TODO : Get x and y from M but not using segment / offset //bmp->Hide(FP_OFF(bmp->_m), FP_SEG(bmp->_m)); bmp->_m = NULL; @@ -328,8 +317,7 @@ void SNGhost(Bitmap *bmp) { warning("STUB: SNGhost"); } - -void feedSnail(Sprite *spr, SNLIST snq) { +void CGEEngine::feedSnail(Sprite *spr, SNLIST snq) { if (spr) if (spr->active()) { uint8 ptr = (snq == TAKE) ? spr->_takePtr : spr->_nearPtr; @@ -402,7 +390,6 @@ void feedSnail(Sprite *spr, SNLIST snq) { } } - const char *Snail::_comTxt[] = { "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", "SAY", "INF", "TIME", "CAVE", "KILL", @@ -424,13 +411,11 @@ Snail::Snail(CGEEngine *vm, bool turbo) _head(0), _tail(0), _snList(farnew(Com, 256)), _vm(vm) { } - Snail::~Snail() { if (_snList) free(_snList); } - void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { _disable(); Com *snc = &_snList[_head++]; @@ -446,7 +431,6 @@ void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { _enable(); } - void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { Com *snc; @@ -469,36 +453,32 @@ void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { _enable(); } - -static void SNNNext(Sprite *sprel, int p) { +void CGEEngine::snNNext(Sprite *sprel, int p) { if (sprel) if (sprel->_nearPtr != NO_PTR) sprel->_nearPtr = p; } - -static void SNTNext(Sprite *sprel, int p) { +void CGEEngine::snTNext(Sprite *sprel, int p) { if (sprel) if (sprel->_takePtr != NO_PTR) sprel->_takePtr = p; } - -static void SNRNNext(Sprite *sprel, int p) { +void CGEEngine::snRNNext(Sprite *sprel, int p) { if (sprel) if (sprel->_nearPtr != NO_PTR) sprel->_nearPtr += p; } -static void SNRTNext(Sprite *sprel, int p) { +void CGEEngine::snRTNext(Sprite *sprel, int p) { if (sprel) if (sprel->_takePtr != NO_PTR) sprel->_takePtr += p; } - -static void SNZTrim(Sprite *spr) { +void CGEEngine::snZTrim(Sprite *spr) { if (spr) if (spr->active()) { bool en = _heart->_enable; @@ -514,8 +494,7 @@ static void SNZTrim(Sprite *spr) { } } - -static void SNHide(Sprite *spr, int val) { +void CGEEngine::snHide(Sprite *spr, int val) { if (spr) { spr->_flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags._hide); if (spr->_flags._shad) @@ -523,20 +502,17 @@ static void SNHide(Sprite *spr, int val) { } } - -static void SNRmNear(Sprite *spr) { +void CGEEngine::snRmNear(Sprite *spr) { if (spr) spr->_nearPtr = NO_PTR; } - -static void SNRmTake(Sprite *spr) { +void CGEEngine::snRmTake(Sprite *spr) { if (spr) spr->_takePtr = NO_PTR; } - -void SNSeq(Sprite *spr, int val) { +void CGEEngine::snSeq(Sprite *spr, int val) { if (spr) { if (spr == _hero && val == 0) _hero->park(); @@ -545,14 +521,12 @@ void SNSeq(Sprite *spr, int val) { } } - -void SNRSeq(Sprite *spr, int val) { +void CGEEngine::snRSeq(Sprite *spr, int val) { if (spr) - SNSeq(spr, spr->_seqPtr + val); + snSeq(spr, spr->_seqPtr + val); } - -void SNSend(Sprite *spr, int val) { +void CGEEngine::snSend(Sprite *spr, int val) { if (spr) { int was = spr->_cave; bool was1 = (was == 0 || was == _now); @@ -565,8 +539,8 @@ void SNSend(Sprite *spr, int val) { if (n >= 0) _pocket[n] = NULL; } - Hide1(spr); - ContractSprite(spr); + hide1(spr); + contractSprite(spr); spr->_flags._slav = false; } else { if (spr->_ref % 1000 == 0) @@ -574,7 +548,7 @@ void SNSend(Sprite *spr, int val) { if (spr->_flags._back) spr->backShow(true); else - ExpandSprite(spr); + expandSprite(spr); Bitmap::_pal = NULL; } } @@ -582,7 +556,7 @@ void SNSend(Sprite *spr, int val) { } -void SNSwap(Sprite *spr, int xref) { +void CGEEngine::snSwap(Sprite *spr, int xref) { Sprite *xspr = locate(xref); if (spr && xspr) { int was = spr->_cave; @@ -603,28 +577,28 @@ void SNSwap(Sprite *spr, int xref) { } if (xwas1 != was1) { if (was1) { - Hide1(spr); - ContractSprite(spr); + hide1(spr); + contractSprite(spr); } else - ExpandSprite(spr); + expandSprite(spr); if (xwas1) { - Hide1(xspr); - ContractSprite(xspr); + hide1(xspr); + contractSprite(xspr); } else - ExpandSprite(xspr); + expandSprite(xspr); } } } -void SNCover(Sprite *spr, int xref) { +void CGEEngine::snCover(Sprite *spr, int xref) { Sprite *xspr = locate(xref); if (spr && xspr) { spr->_flags._hide = true; xspr->_z = spr->_z; xspr->_cave = spr->_cave; xspr->gotoxy(spr->_x, spr->_y); - ExpandSprite(xspr); + expandSprite(xspr); if ((xspr->_flags._shad = spr->_flags._shad) == 1) { _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr); spr->_flags._shad = false; @@ -634,7 +608,7 @@ void SNCover(Sprite *spr, int xref) { } -void SNUncover(Sprite *spr, Sprite *xspr) { +void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) { if (spr && xspr) { spr->_flags._hide = false; spr->_cave = xspr->_cave; @@ -644,75 +618,71 @@ void SNUncover(Sprite *spr, Sprite *xspr) { xspr->_flags._shad = false; } spr->_z = xspr->_z; - SNSend(xspr, -1); + snSend(xspr, -1); if (spr->_time == 0) spr->_time++; } } -void SNSetX0(int cav, int x0) { +void CGEEngine::snSetX0(int cav, int x0) { _heroXY[cav - 1]._x = x0; } - -void SNSetY0(int cav, int y0) { +void CGEEngine::snSetY0(int cav, int y0) { _heroXY[cav - 1]._y = y0; } - -void SNSetXY(Sprite *spr, uint16 xy) { +void CGEEngine::snSetXY(Sprite *spr, uint16 xy) { if (spr) spr->gotoxy(xy % SCR_WID, xy / SCR_WID); } - -void SNRelX(Sprite *spr, int x) { +void CGEEngine::snRelX(Sprite *spr, int x) { if (spr && _hero) spr->gotoxy(_hero->_x + x, spr->_y); } - -void SNRelY(Sprite *spr, int y) { +void CGEEngine::snRelY(Sprite *spr, int y) { if (spr && _hero) spr->gotoxy(spr->_x, _hero->_y + y); } -void SNRelZ(Sprite *spr, int z) { +void CGEEngine::snRelZ(Sprite *spr, int z) { if (spr && _hero) { spr->_z = _hero->_z + z; - SNZTrim(spr); + snZTrim(spr); } } -void SNSetX(Sprite *spr, int x) { +void CGEEngine::snSetX(Sprite *spr, int x) { if (spr) spr->gotoxy(x, spr->_y); } -void SNSetY(Sprite *spr, int y) { +void CGEEngine::snSetY(Sprite *spr, int y) { if (spr) spr->gotoxy(spr->_x, y); } -void SNSetZ(Sprite *spr, int z) { +void CGEEngine::snSetZ(Sprite *spr, int z) { if (spr) { spr->_z = z; //SNPOST_(SNZTRIM, -1, 0, spr); - SNZTrim(spr); + snZTrim(spr); } } -void SNSlave(Sprite *spr, int ref) { +void CGEEngine::snSlave(Sprite *spr, int ref) { Sprite *slv = locate(ref); if (spr && slv) { if (spr->active()) { - SNSend(slv, spr->_cave); + snSend(slv, spr->_cave); slv->_flags._slav = true; slv->_z = spr->_z; _vga->_showQ->insert(_vga->_showQ->remove(slv), spr->_next); @@ -721,19 +691,17 @@ void SNSlave(Sprite *spr, int ref) { } -void SNTrans(Sprite *spr, int trans) { +void CGEEngine::snTrans(Sprite *spr, int trans) { if (spr) spr->_flags._tran = (trans < 0) ? !spr->_flags._tran : (trans != 0); } - -void SNPort(Sprite *spr, int port) { +void CGEEngine::snPort(Sprite *spr, int port) { if (spr) spr->_flags._port = (port < 0) ? !spr->_flags._port : (port != 0); } - -void SNKill(Sprite *spr) { +void CGEEngine::snKill(Sprite *spr) { if (spr) { if (spr->_flags._kept) { int n = findPocket(spr); @@ -741,7 +709,7 @@ void SNKill(Sprite *spr) { _pocket[n] = NULL; } Sprite *nx = spr->_next; - Hide1(spr); + hide1(spr); _vga->_showQ->remove(spr); EventManager::ClrEvt(spr); if (spr->_flags._kill) @@ -752,13 +720,13 @@ void SNKill(Sprite *spr) { } if (nx) { if (nx->_flags._slav) - SNKill(nx); + snKill(nx); } } } -static void SNSound(Sprite *spr, int wav, int cnt) { +void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { if (_sndDrvInfo._dDev) { if (wav == -1) _sound.stop(); @@ -768,10 +736,10 @@ static void SNSound(Sprite *spr, int wav, int cnt) { } -void CGEEngine::SNKeep(Sprite *spr, int stp) { +void CGEEngine::snKeep(Sprite *spr, int stp) { selectPocket(-1); if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) { - SNSound(spr, 3, 1); + snSound(spr, 3, 1); _pocket[_pocPtr] = spr; spr->_cave = 0; spr->_flags._kept = true; @@ -784,7 +752,7 @@ void CGEEngine::SNKeep(Sprite *spr, int stp) { } -void CGEEngine::SNGive(Sprite *spr, int stp) { +void CGEEngine::snGive(Sprite *spr, int stp) { if (spr) { int p = findPocket(spr); if (p >= 0) { @@ -799,7 +767,7 @@ void CGEEngine::SNGive(Sprite *spr, int stp) { } -static void SNBackPt(Sprite *spr, int stp) { +void CGEEngine::snBackPt(Sprite *spr, int stp) { if (spr) { if (stp >= 0) spr->step(stp); @@ -807,13 +775,7 @@ static void SNBackPt(Sprite *spr, int stp) { } } - -static void SNLevel(Sprite *spr, int lev) { -#ifdef DEMO - static int maxcav[] = { CAVE_MAX }; -#else - static int maxcav[] = { 1, 8, 16, 23, 24 }; -#endif +void CGEEngine::snLevel(Sprite *spr, int lev) { while (_lev < lev) { _lev++; spr = _vga->_spareQ->locate(100 + _lev); @@ -822,24 +784,22 @@ static void SNLevel(Sprite *spr, int lev) { spr->_cave = 0; } } - _maxCave = maxcav[_lev]; + _maxCave = _maxCaveArr[_lev]; if (spr) spr->_flags._hide = false; } -static void SNFlag(int fn, bool v) { +void CGEEngine::snFlag(int fn, bool v) { _flag[fn] = v; } - -static void SNSetRef(Sprite *spr, int nr) { +void CGEEngine::snSetRef(Sprite *spr, int nr) { if (spr) spr->_ref = nr; } - -void SNFlash(bool on) { +void CGEEngine::snFlash(bool on) { if (on) { Dac *pal = farnew(Dac, PAL_CNT); if (pal) { @@ -861,7 +821,7 @@ void SNFlash(bool on) { } -static void SNLight(bool in) { +void CGEEngine::snLight(bool in) { if (in) _vga->sunrise(Vga::_sysPal); else @@ -869,13 +829,11 @@ static void SNLight(bool in) { _dark = ! in; } - -static void SNBarrier(int cav, int bar, bool horz) { +void CGEEngine::snBarrier(int cav, int bar, bool horz) { ((uint8 *)(_barriers + ((cav > 0) ? cav : _now)))[horz] = bar; } - -static void SNWalk(Sprite *spr, int x, int y) { +void CGEEngine::snWalk(Sprite *spr, int x, int y) { if (_hero) { if (spr && y < 0) _hero->findWay(spr); @@ -884,14 +842,12 @@ static void SNWalk(Sprite *spr, int x, int y) { } } - -static void SNReach(Sprite *spr, int mode) { +void CGEEngine::snReach(Sprite *spr, int mode) { if (_hero) _hero->reach(spr, mode); } - -static void SNMouse(bool on) { +void CGEEngine::snMouse(bool on) { if (on) _mouse->On(); else @@ -945,10 +901,10 @@ void Snail::runCom() { } break; case SNLEVEL : - SNLevel(sprel, snc->_val); + _vm->snLevel(sprel, snc->_val); break; case SNHIDE : - SNHide(sprel, snc->_val); + _vm->snHide(sprel, snc->_val); break; case SNSAY : if (sprel && _talkEnable) { @@ -976,125 +932,125 @@ void Snail::runCom() { warning("Problematic call of SwitchCave in SNAIL::runCom"); break; case SNKILL : - SNKill(sprel); + _vm->snKill(sprel); break; case SNSEQ : - SNSeq(sprel, snc->_val); + _vm->snSeq(sprel, snc->_val); break; case SNRSEQ : - SNRSeq(sprel, snc->_val); + _vm->snRSeq(sprel, snc->_val); break; case SNSEND : - SNSend(sprel, snc->_val); + _vm->snSend(sprel, snc->_val); break; case SNSWAP : - SNSwap(sprel, snc->_val); + _vm->snSwap(sprel, snc->_val); break; case SNCOVER : - SNCover(sprel, snc->_val); + _vm->snCover(sprel, snc->_val); break; case SNUNCOVER : - SNUncover(sprel, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); + _vm->snUncover(sprel, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); break; case SNKEEP : - _vm->SNKeep(sprel, snc->_val); + _vm->snKeep(sprel, snc->_val); break; case SNGIVE : - _vm->SNGive(sprel, snc->_val); + _vm->snGive(sprel, snc->_val); break; case SNGAME : - SNGame(sprel, snc->_val); + _vm->snGame(sprel, snc->_val); break; case SNSETX0 : - SNSetX0(snc->_ref, snc->_val); + _vm->snSetX0(snc->_ref, snc->_val); break; case SNSETY0 : - SNSetY0(snc->_ref, snc->_val); + _vm->snSetY0(snc->_ref, snc->_val); break; case SNSETXY : - SNSetXY(sprel, snc->_val); + _vm->snSetXY(sprel, snc->_val); break; case SNRELX : - SNRelX(sprel, snc->_val); + _vm->snRelX(sprel, snc->_val); break; case SNRELY : - SNRelY(sprel, snc->_val); + _vm->snRelY(sprel, snc->_val); break; case SNRELZ : - SNRelZ(sprel, snc->_val); + _vm->snRelZ(sprel, snc->_val); break; case SNSETX : - SNSetX(sprel, snc->_val); + _vm->snSetX(sprel, snc->_val); break; case SNSETY : - SNSetY(sprel, snc->_val); + _vm->snSetY(sprel, snc->_val); break; case SNSETZ : - SNSetZ(sprel, snc->_val); + _vm->snSetZ(sprel, snc->_val); break; case SNSLAVE : - SNSlave(sprel, snc->_val); + _vm->snSlave(sprel, snc->_val); break; case SNTRANS : - SNTrans(sprel, snc->_val); + _vm->snTrans(sprel, snc->_val); break; case SNPORT : - SNPort(sprel, snc->_val); + _vm->snPort(sprel, snc->_val); break; case SNNEXT : case SNIF : case SNTALK : break; case SNMOUSE : - SNMouse(snc->_val != 0); + _vm->snMouse(snc->_val != 0); break; case SNNNEXT : - SNNNext(sprel, snc->_val); + _vm->snNNext(sprel, snc->_val); break; case SNTNEXT : - SNTNext(sprel, snc->_val); + _vm->snTNext(sprel, snc->_val); break; case SNRNNEXT : - SNRNNext(sprel, snc->_val); + _vm->snRNNext(sprel, snc->_val); break; case SNRTNEXT : - SNRTNext(sprel, snc->_val); + _vm->snRTNext(sprel, snc->_val); break; case SNRMNEAR : - SNRmNear(sprel); + _vm->snRmNear(sprel); break; case SNRMTAKE : - SNRmTake(sprel); + _vm->snRmTake(sprel); break; case SNFLAG : - SNFlag(snc->_ref & 3, snc->_val != 0); + _vm->snFlag(snc->_ref & 3, snc->_val != 0); break; case SNSETREF : - SNSetRef(sprel, snc->_val); + _vm->snSetRef(sprel, snc->_val); break; case SNBACKPT : - SNBackPt(sprel, snc->_val); + _vm->snBackPt(sprel, snc->_val); break; case SNFLASH : - SNFlash(snc->_val != 0); + _vm->snFlash(snc->_val != 0); break; case SNLIGHT : - SNLight(snc->_val != 0); + _vm->snLight(snc->_val != 0); break; case SNSETHB : - SNBarrier(snc->_ref, snc->_val, true); + _vm->snBarrier(snc->_ref, snc->_val, true); break; case SNSETVB : - SNBarrier(snc->_ref, snc->_val, false); + _vm->snBarrier(snc->_ref, snc->_val, false); break; case SNWALK : - SNWalk(sprel, snc->_ref, snc->_val); + _vm->snWalk(sprel, snc->_ref, snc->_val); break; case SNREACH : - SNReach(sprel, snc->_val); + _vm->snReach(sprel, snc->_val); break; case SNSOUND : - SNSound(sprel, snc->_val, count); + _vm->snSound(sprel, snc->_val, count); count = 1; break; case SNCOUNT : @@ -1109,10 +1065,10 @@ void Snail::runCom() { sprel->step(); break; case SNZTRIM : - SNZTrim(sprel); + _vm->snZTrim(sprel); break; case SNGHOST : - SNGhost((Bitmap *) snc->_ptr); + _vm->snGhost((Bitmap *) snc->_ptr); break; default : warning("Unhandled snc->_com in SNMouse(bool)"); diff --git a/engines/cge/snail.h b/engines/cge/snail.h index bd874a35b4..888fae6ce9 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -70,8 +70,6 @@ enum SNCOM { SNZTRIM, SNGHOST }; -enum SNLIST { NEAR, TAKE }; - class Snail { public: struct Com { @@ -99,15 +97,8 @@ private: }; -void pocFul(); - - -extern bool _flag[4]; -extern bool _game; extern bool _dark; -extern int _now; extern int _lev; -extern int _maxCave; extern Bar _barriers[]; extern struct Hxy { int _x; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6c20a78cae..36ac060111 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -63,7 +63,7 @@ bool SpeedTest = false; Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; -extern "C" void SNDMIDIPlay(void); +extern "C" void SNDMIDIPlay(); /* static void Video() { @@ -87,7 +87,7 @@ static void Video() { */ -uint16 *SaveScreen(void) { +uint16 *SaveScreen() { /* uint16 cxy, cur, siz, * scr = NULL, * sav; @@ -201,7 +201,7 @@ Sprite *locate(int ref) { } -Heart::Heart(void) +Heart::Heart() : Engine_(TMR_DIV) { _enable = false; _xTimer = NULL; @@ -427,7 +427,7 @@ bool Sprite::works(Sprite *spr) { if (c != NULL) { c += spr->_takePtr; if (c->_ref == _ref) - if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _now)) + if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _vm->_now)) return true; } } @@ -1136,7 +1136,7 @@ void Vga::setColors(Dac *tab, int lum) { } -void Vga::setColors(void) { +void Vga::setColors() { memset(_newColors, 0, PAL_SIZ); updateColors(); } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index d5a87e973d..b0cba4dcc0 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -209,7 +209,7 @@ public: return _ext != NULL; } Sprite(CGEEngine *vm, BMP_PTR *shp); - virtual ~Sprite(void); + virtual ~Sprite(); BMP_PTR shp(); BMP_PTR *setShapeList(BMP_PTR *shp); void moveShapes(uint8 *buf); @@ -288,7 +288,7 @@ public: static Dac *_sysPal; Vga(int mode); - ~Vga(void); + ~Vga(); static void init(); static void deinit(); @@ -340,7 +340,6 @@ uint8 closest(CBLK *pal, CBLK x) { #undef f } -//static void Video (void); uint16 *saveScreen(); void restoreScreen(uint16 * &sav); Sprite *spriteAt(int x, int y); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 49dbbbdab6..8fef6307b1 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -119,7 +119,7 @@ Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) } -Vmenu::~Vmenu(void) { +Vmenu::~Vmenu() { _addr = NULL; } -- cgit v1.2.3 From affaa1f4d6cf5f27f654029133b1aec7b9eca4b5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jul 2011 08:11:29 +0200 Subject: CGE: Some cleanup: Move some static functions to CGEEngine, remove parameters to GetText, rename members of SavTab --- engines/cge/cge.cpp | 102 ++++++++++++++++++++++---------------------- engines/cge/cge.h | 23 ++++++++-- engines/cge/cge_main.cpp | 109 +++++++++++++++++++++-------------------------- engines/cge/general.cpp | 9 ---- engines/cge/gettext.cpp | 7 ++- engines/cge/gettext.h | 3 +- engines/cge/startup.cpp | 107 +++++++++++++++++++++++++++------------------- 7 files changed, 187 insertions(+), 173 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 067b9eb6e9..b953f2f5b0 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -117,56 +117,56 @@ void CGEEngine::setup() { _volume[0] = 0; _volume[1] = 0; - _savTab[0].Ptr = &_now; - _savTab[0].Len = sizeof(_now); - _savTab[0].Flg = 1; - _savTab[1].Ptr = &_oldLev; - _savTab[1].Len = sizeof(_oldLev); - _savTab[1].Flg = 1; - _savTab[2].Ptr = &_demoText; - _savTab[2].Len = sizeof(_demoText); - _savTab[2].Flg = 1; - _savTab[3].Ptr = &_game; - _savTab[3].Len = sizeof(_game); - _savTab[3].Flg = 1; - _savTab[4].Ptr = &_game; - _savTab[4].Len = sizeof(_game); - _savTab[4].Flg = 1; - _savTab[5].Ptr = &_game; - _savTab[5].Len = sizeof(_game); - _savTab[5].Flg = 1; - _savTab[6].Ptr = &_game; - _savTab[6].Len = sizeof(_game); - _savTab[6].Flg = 1; - _savTab[7].Ptr = &_game; - _savTab[7].Len = sizeof(_game); - _savTab[7].Flg = 1; - _savTab[8].Ptr = &_vga->_mono; - _savTab[8].Len = sizeof(_vga->_mono); - _savTab[8].Flg = 0; - _savTab[9].Ptr = &_music; - _savTab[9].Len = sizeof(_music); - _savTab[9].Flg = 1; - _savTab[10].Ptr = _volume; - _savTab[10].Len = sizeof(_volume); - _savTab[10].Flg = 1; - _savTab[11].Ptr = _flag; - _savTab[11].Len = sizeof(_flag); - _savTab[11].Flg = 1; - _savTab[12].Ptr = _heroXY; -// _savTab[12].Len = sizeof(_heroXY); FIXME: illegal sizeof - _savTab[12].Len = 0; - _savTab[12].Flg = 1; - _savTab[13].Ptr = _barriers; -// _savTab[13].Len = sizeof(_barriers); FIXME: illegal sizeof - _savTab[13].Len = 0; - _savTab[13].Flg = 1; - _savTab[14].Ptr = _pocref; - _savTab[14].Len = sizeof(_pocref); - _savTab[14].Flg = 1; - _savTab[15].Ptr = NULL; - _savTab[15].Len = 0; - _savTab[15].Flg = 0; + _savTab[0]._ptr = &_now; + _savTab[0]._len = sizeof(_now); + _savTab[0]._flag = true; + _savTab[1]._ptr = &_oldLev; + _savTab[1]._len = sizeof(_oldLev); + _savTab[1]._flag = true; + _savTab[2]._ptr = &_demoText; + _savTab[2]._len = sizeof(_demoText); + _savTab[2]._flag = true; + _savTab[3]._ptr = &_game; + _savTab[3]._len = sizeof(_game); + _savTab[3]._flag = true; + _savTab[4]._ptr = &_game; + _savTab[4]._len = sizeof(_game); + _savTab[4]._flag = true; + _savTab[5]._ptr = &_game; + _savTab[5]._len = sizeof(_game); + _savTab[5]._flag = true; + _savTab[6]._ptr = &_game; + _savTab[6]._len = sizeof(_game); + _savTab[6]._flag = true; + _savTab[7]._ptr = &_game; + _savTab[7]._len = sizeof(_game); + _savTab[7]._flag = true; + _savTab[8]._ptr = &_vga->_mono; + _savTab[8]._len = sizeof(_vga->_mono); + _savTab[8]._flag = false; + _savTab[9]._ptr = &_music; + _savTab[9]._len = sizeof(_music); + _savTab[9]._flag = true; + _savTab[10]._ptr = _volume; + _savTab[10]._len = sizeof(_volume); + _savTab[10]._flag = true; + _savTab[11]._ptr = _flag; + _savTab[11]._len = sizeof(_flag); + _savTab[11]._flag = true; + _savTab[12]._ptr = _heroXY; +// _savTab[12]._len = sizeof(_heroXY); FIXME: illegal sizeof + _savTab[12]._len = 0; + _savTab[12]._flag = true; + _savTab[13]._ptr = _barriers; +// _savTab[13]._len = sizeof(_barriers); FIXME: illegal sizeof + _savTab[13]._len = 0; + _savTab[13]._flag = true; + _savTab[14]._ptr = _pocref; + _savTab[14]._len = sizeof(_pocref); + _savTab[14]._flag = true; + _savTab[15]._ptr = NULL; + _savTab[15]._len = 0; + _savTab[15]._flag = false; if (_isDemo) { _maxCaveArr[0] = CAVE_MAX; @@ -187,6 +187,8 @@ void CGEEngine::setup() { _now = 1; _lev = -1; + for (int i = 0; i < 4; i++) + _flag[i] = false; } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index e4b8ef86c1..4f6b452850 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -49,9 +49,9 @@ enum SNLIST { NEAR, TAKE }; #define POCKET_NX 8 struct SavTab { - void *Ptr; - int Len; - uint8 Flg; + void *_ptr; + int32 _len; + bool _flag; }; class CGEEngine : public Engine { @@ -124,7 +124,7 @@ public: void setIRQ(); void setDMA(); void mainLoop(); - void SaveGame(XFile &file); + void saveGame(XFile &file); void switchMusic(); void selectPocket(int n); void expandSprite(Sprite *spr); @@ -135,6 +135,21 @@ public: void hide1(Sprite *spr); void loadMapping(); void saveMapping(); + void saveSound(); + void heroCover(int cvr); + void trouble(int seq, int txt); + void offUse(); + void tooFar(); + void noWay(); + void loadHeroXY(); + void keyClick(); + void switchColorMode(); + void killSprite(); + void pushSprite(); + void pullSprite(); + void sayDebug(); + void nextStep(); + void switchDebug(); void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 456a11092e..e7ca76a98f 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -247,14 +247,14 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { } -static void SaveSound() { +void CGEEngine::saveSound() { CFile cfg(usrPath(progName(CFG_EXT)), WRI); if (!cfg._error) cfg.write(&_sndDrvInfo, sizeof(_sndDrvInfo) - sizeof(_sndDrvInfo.Vol2)); } -void CGEEngine::SaveGame(XFile &file) { +void CGEEngine::saveGame(XFile &file) { SavTab *st; Sprite *spr; int i; @@ -267,10 +267,10 @@ void CGEEngine::SaveGame(XFile &file) { _volume[0] = _sndDrvInfo.Vol2._d; _volume[1] = _sndDrvInfo.Vol2._m; - for (st = _savTab; st->Ptr; st++) { + for (st = _savTab; st->_ptr; st++) { if (file._error) error("Bad SVG"); - file.write((uint8 *) st->Ptr, st->Len); + file.write((uint8 *) st->_ptr, st->_len); } file.write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); @@ -281,13 +281,11 @@ void CGEEngine::SaveGame(XFile &file) { file.write((uint8 *)spr, sizeof(*spr)); } - -static void HeroCover(int cvr) { +void CGEEngine::heroCover(int cvr) { SNPOST(SNCOVER, 1, cvr, NULL); } - -static void trouble(int seq, int txt) { +void CGEEngine::trouble(int seq, int txt) { _hero->park(); SNPOST(SNWAIT, -1, -1, _hero); SNPOST(SNSEQ, -1, seq, _hero); @@ -296,31 +294,27 @@ static void trouble(int seq, int txt) { SNPOST(SNSAY, 1, txt, _hero); } - -static void offUse() { +void CGEEngine::offUse() { trouble(OFF_USE, OFF_USE_TEXT + new_random(_offUseCount)); } - -static void tooFar() { +void CGEEngine::tooFar() { trouble(TOO_FAR, TOO_FAR_TEXT); } - // Used in stubbed function, do not remove! -static void noWay() { +void CGEEngine::noWay() { trouble(NO_WAY, NO_WAY_TEXT); } -static void loadHeroXY() { +void CGEEngine::loadHeroXY() { INI_FILE cf(progName(".HXY")); memset(_heroXY, 0, sizeof(_heroXY)); if (!cf._error) cf.CFREAD(&_heroXY); } - void CGEEngine::loadMapping() { if (_now <= CAVE_MAX) { INI_FILE cf(progName(".TAB")); @@ -536,21 +530,19 @@ void CGEEngine::setMapBrick(int x, int z) { } } -static void SwitchColorMode(); -static void switchDebug(); -static void KillSprite(); -static void PushSprite(); -static void PullSprite(); -static void NextStep(); +//static void switchColorMode(); +//static void switchDebug(); +//static void pullSprite(); +//static void NextStep(); -static void KeyClick() { +void CGEEngine::keyClick() { SNPOST_(SNSOUND, -1, 5, NULL); } void CGEEngine::resetQSwitch() { SNPOST_(SNSEQ, 123, 0, NULL); - KeyClick(); + keyClick(); } @@ -570,7 +562,7 @@ void CGEEngine::quit() { QuitMenu[1]._text = _text->getText(NOQUIT_TEXT); (new Vmenu(this, QuitMenu, -1, -1))->setName(_text->getText(QUIT_TITLE)); SNPOST_(SNSEQ, 123, 1, NULL); - KeyClick(); + keyClick(); } } } @@ -723,9 +715,9 @@ void CGEEngine::xCave() { void CGEEngine::qGame() { caveDown(); _oldLev = _lev; - SaveSound(); + saveSound(); CFile file = CFile(usrPath(_usrFnam), WRI, RCrypt); - SaveGame(file); + saveGame(file); _vga->sunset(); _finis = true; } @@ -754,7 +746,7 @@ void CGEEngine::switchCave(int cav) { CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); killText(); if (!_startupMode) - KeyClick(); + keyClick(); SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave @@ -776,7 +768,7 @@ void System::touch(uint16 mask, int x, int y) { if (mask & KEYB) { int pp0; - KeyClick(); + _vm->keyClick(); killText(); if (_vm->_startupMode == 1) { SNPOST(SNCLEAR, -1, 0, NULL); @@ -788,7 +780,7 @@ void System::touch(uint16 mask, int x, int y) { if (_keyboard->_key[ALT] && _keyboard->_key[CTRL]) AltCtrlDel(); else - KillSprite(); + _vm->killSprite(); break; case 'F': if (_keyboard->_key[ALT]) { @@ -800,13 +792,13 @@ void System::touch(uint16 mask, int x, int y) { } break; case PgUp: - PushSprite(); + _vm->pushSprite(); break; case PgDn: - PullSprite(); + _vm->pullSprite(); break; case '+': - NextStep(); + _vm->nextStep(); break; case '`': if (_keyboard->_key[ALT]) @@ -815,7 +807,7 @@ void System::touch(uint16 mask, int x, int y) { _vm->switchMapping(); break; case F1: - switchDebug(); + _vm->switchDebug(); break; case F3: _hero->step(TSEQ + 4); @@ -933,19 +925,19 @@ void System::tick() { killText(); if (_snail->idle()) { if (PAIN) - HeroCover(9); + _vm->heroCover(9); else if (Startup::_core >= CORE_MID) { int n = new_random(100); if (n > 96) - HeroCover(6 + (_hero->_x + _hero->_w / 2 < SCR_WID / 2)); + _vm->heroCover(6 + (_hero->_x + _hero->_w / 2 < SCR_WID / 2)); else { if (n > 90) - HeroCover(5); + _vm->heroCover(5); else { if (n > 60) - HeroCover(4); + _vm->heroCover(4); else - HeroCover(3); + _vm->heroCover(3); } } } @@ -975,9 +967,9 @@ static void SpkClose() { */ -static void SwitchColorMode() { +void CGEEngine::switchColorMode() { SNPOST_(SNSEQ, 121, _vga->_mono = !_vga->_mono, NULL); - KeyClick(); + keyClick(); _vga->setColors(Vga::_sysPal, 64); } @@ -998,7 +990,7 @@ void CGEEngine::switchMusic() { SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL); else { SNPOST_(SNSEQ, 122, (_music = !_music), NULL); - KeyClick(); + keyClick(); } } if (_music) @@ -1018,7 +1010,7 @@ void CGEEngine::takeName() { if (GetText::_ptr) SNPOST_(SNKILL, -1, 0, GetText::_ptr); else { - GetText *tn = new GetText(this, _text->getText(GETNAME_PROMPT), _usrFnam, 8, KeyClick); + GetText *tn = new GetText(this, _text->getText(GETNAME_PROMPT), _usrFnam, 8); if (tn) { tn->setName(_text->getText(GETNAME_TITLE)); tn->center(); @@ -1049,16 +1041,14 @@ void CGEEngine::switchMapping() { _horzLine->_flags._hide = !_horzLine->_flags._hide; } - -static void KillSprite() { +void CGEEngine::killSprite() { _sprite->_flags._kill = true; _sprite->_flags._bDel = true; SNPOST_(SNKILL, -1, 0, _sprite); _sprite = NULL; } - -static void PushSprite() { +void CGEEngine::pushSprite() { Sprite *spr = _sprite->_prev; if (spr) { _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); @@ -1068,8 +1058,7 @@ static void PushSprite() { SNPOST_(SNSOUND, -1, 2, NULL); } - -static void PullSprite() { +void CGEEngine::pullSprite() { bool ok = false; Sprite *spr = _sprite->_next; if (spr) { @@ -1086,12 +1075,10 @@ static void PullSprite() { SNPOST_(SNSOUND, -1, 2, NULL); } - -static void NextStep() { +void CGEEngine::nextStep() { SNPOST_(SNSTEP, 0, 0, _sprite); } - void CGEEngine::saveMapping() { { IoHand cf(progName(".TAB"), UPD); @@ -1131,7 +1118,7 @@ static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 0 #define SP_F (DebugText + 67) #define SP__ (DebugText + 70) -static void sayDebug() { +void CGEEngine::sayDebug() { if (!_debugLine->_flags._hide) { static long t = -1L; long t1 = timer(); @@ -1172,7 +1159,7 @@ static void sayDebug() { } -static void switchDebug() { +void CGEEngine::switchDebug() { _debugLine->_flags._hide = !_debugLine->_flags._hide; } @@ -1181,7 +1168,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { switch (opt) { case 1 : if (mask & L_UP) - SwitchColorMode(); + switchColorMode(); break; case 2 : if (mask & L_UP) @@ -1224,10 +1211,10 @@ void Sprite::touch(uint16 mask, int x, int y) { if (works(ps)) { _vm->feedSnail(ps, TAKE); } else - offUse(); + _vm->offUse(); _vm->selectPocket(-1); } else - tooFar(); + _vm->tooFar(); } else { if (_flags._kept) mask |= L_UP; @@ -1245,15 +1232,15 @@ void Sprite::touch(uint16 mask, int x, int y) { } else { if (_takePtr != NO_PTR) { if (snList(TAKE)[_takePtr]._com == SNNEXT) - offUse(); + _vm->offUse(); else _vm->feedSnail(this, TAKE); } else - offUse(); + _vm->offUse(); } }/// else - tooFar(); + _vm->tooFar(); } } } @@ -1548,7 +1535,7 @@ void CGEEngine::loadUser() { loadScript(progName(INI_EXT)); _music = true; CFile file = CFile(SVG0NAME, WRI); - SaveGame(file); + saveGame(file); error("Ok [%s]", SVG0NAME); } } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 8464d020e5..6ed6884aba 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -109,11 +109,6 @@ const char *progName(const char *ext) { } char *mergeExt(char *buf, const char *nam, const char *ext) { -// char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; -// fnmerge(buf, dr, di, na, (fnsplit(nam, dr, di, na, ex) & EXTENSION) ? ex : ext); -// return buf; - warning("mergeExt"); - strcpy(buf, nam); char *dot = strrchr(buf, '.'); if (!dot) @@ -123,10 +118,6 @@ char *mergeExt(char *buf, const char *nam, const char *ext) { } char *forceExt(char *buf, const char *nam, const char *ext) { -// char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; -// fnsplit(nam, dr, di, na, ex); -// fnmerge(buf, dr, di, na, ext); -// return buf; strcpy(buf, nam); char *dot = strrchr(buf, '.'); if (dot) diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 508175ccd5..2ee6dc42eb 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -34,9 +34,9 @@ namespace CGE { GetText *GetText::_ptr = NULL; -GetText::GetText(CGEEngine *vm, const char *info, char *text, int size, void (*click)()) +GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) : Talk(vm), _text(text), _size(min(size, GTMAX)), _len(min(_size, strlen(text))), - _cntr(GTBLINK), _click(click), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { + _cntr(GTBLINK), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { int i = 2 * TEXT_HM + _font->width(info); _ptr = this; _mode = RECT; @@ -74,8 +74,7 @@ void GetText::touch(uint16 mask, int x, int y) { char *p; if (mask & KEYB) { - if (_click) - _click(); + _vm->keyClick(); switch (x) { case Enter : _buff[_len] = '\0'; diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index d29d11abb7..188e90c776 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -44,11 +44,10 @@ class GetText : public Talk { uint16 _len; uint16 _cntr; Sprite *_oldKeybClient; - void (*_click)(); public: static GetText *_ptr; - GetText(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void) = NULL); + GetText(CGEEngine *vm, const char *info, char *text, int size); ~GetText(); void touch(uint16 mask, int x, int y); void tick(); diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 6a06cbc537..9210b40c77 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -57,49 +57,70 @@ bool Startup::getParms() { _summa = 0; /* - int i = _argc; - while (i > 1) - { - static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", - "P", "D", "I", "M" }; - int n = takeEnum(PrmTab, strtok(_argv[--i], " =:(")); - uint16 p = xtow(strtok(NULL, " h,)")); - switch (n) - { - case 0 : if (Mode != 2) Mode = 1; break; - case 1 : Mode = 2; break; - case 2 : SNDDrvInfo.DDEV = DEV_QUIET; break; - case 3 : SNDDrvInfo.DDEV = DEV_SB; break; - case 4 : SNDDrvInfo.DDEV = DEV_GUS; break; - case 5 : SNDDrvInfo.MDEV = DEV_GM; break; - case 6 : SNDDrvInfo.DBASE = p; break; - case 7 : SNDDrvInfo.DDMA = p; break; - case 8 : SNDDrvInfo.DIRQ = p; break; - case 9 : SNDDrvInfo.MBASE = p; - SNDDrvInfo.MDEV = DEV_GM; break; - default: return false; - } - if (n >= 2) SoundOk = 2; - } - #ifdef DEMO - // protection disabled - Summa = 0; - #else - #ifdef EVA - { - union { dosdate_t d; uint32 n; } today; - _dos_getdate(&today.d); - id.disk += (id.disk < today.n); - } - #endif - #ifdef CD - Summa = 0; - #else - // disk signature checksum - Summa = ChkSum(Copr, sizeof(Ident)); - #endif - #endif - if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; + int i = _argc; + while (i > 1) { + static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", "P", "D", "I", "M" }; + int n = takeEnum(PrmTab, strtok(_argv[--i], " =:(")); + uint16 p = xtow(strtok(NULL, " h,)")); + switch (n) { + case 0 : + if (Mode != 2) + Mode = 1; + break; + case 1 : + Mode = 2; + break; + case 2 : + SNDDrvInfo.DDEV = DEV_QUIET; + break; + case 3 : + SNDDrvInfo.DDEV = DEV_SB; + break; + case 4 : + SNDDrvInfo.DDEV = DEV_GUS; + break; + case 5 : + SNDDrvInfo.MDEV = DEV_GM; + break; + case 6 : + SNDDrvInfo.DBASE = p; + break; + case 7 : + SNDDrvInfo.DDMA = p; + break; + case 8 : + SNDDrvInfo.DIRQ = p; + break; + case 9 : + SNDDrvInfo.MBASE = p; + SNDDrvInfo.MDEV = DEV_GM; + break; + default: + return false; + } + + if (n >= 2) + SoundOk = 2; + } + if (_vm->_isDemo) + // protection disabled + Summa = 0; + else { +#ifdef EVA + union { dosdate_t d; uint32 n; } today; + _dos_getdate(&today.d); + id.disk += (id.disk < today.n); +#endif +#ifdef CD + Summa = 0; +#else + // disk signature checksum + Summa = ChkSum(Copr, sizeof(Ident)); +#endif + } + + if (SNDDrvInfo.MDEV != DEV_GM) + SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; return true; */ warning("STUB: Startup::get_parms"); -- cgit v1.2.3 From fe2e1bb2fd11d4f9e656f1e9392dc8e97c069d73 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jul 2011 20:43:09 +0200 Subject: CGE: Remove "bitmaps" files --- engines/cge/bitmaps.cpp | 229 ------------------------------------------------ engines/cge/bitmaps.h | 44 ---------- engines/cge/cge.cpp | 1 - engines/cge/events.h | 1 + engines/cge/game.h | 1 - engines/cge/module.mk | 1 - engines/cge/snail.cpp | 1 - engines/cge/text.cpp | 1 - 8 files changed, 1 insertion(+), 278 deletions(-) delete mode 100644 engines/cge/bitmaps.cpp delete mode 100644 engines/cge/bitmaps.h diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp deleted file mode 100644 index 5e8757ae73..0000000000 --- a/engines/cge/bitmaps.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/bitmaps.h" -/* - -#define W 255, -#define x 252, -#define _ TRANS, -#define o 0, -#define L LGRAY, -#define G GRAY, -#define D DGRAY, - -static uint8 MCDesign0[]= { W W W W W W _ - W W W W W o _ - W W W W o _ _ - W W W W W _ _ - W W o W W W _ - W o _ o W W W - o _ _ _ o W W - _ _ _ _ _ o o }; - - -static uint8 MCDesign1[]= { _ }; - - - -static uint8 SLDesign[] = { G G G G G G G G G _ _ _ _ _ _ - L G G G G G G G G D _ _ _ _ _ - _ L G G G G G G G D _ _ _ _ _ - _ _ L G G G G G G G D _ _ _ _ - _ _ _ L G G G G G G D _ _ _ _ - _ _ _ _ L G G G G G D _ _ _ _ - _ _ _ _ _ L G G G G G D _ _ _ - _ _ _ _ _ _ L G G G G D _ _ _ - _ _ _ _ _ _ _ L G G G D _ _ _ - _ _ _ _ _ _ _ _ L G G G D _ _ - _ _ _ _ _ _ _ _ _ L G G D _ _ - _ _ _ _ _ _ _ _ _ _ L G D _ _ - _ _ _ _ _ _ _ _ _ _ _ L G D _ - _ _ _ _ _ _ _ _ _ _ _ _ L D _ - _ _ _ _ _ _ _ _ _ _ _ _ _ L D - _ _ _ _ _ _ _ _ _ _ _ _ _ _ D - }; - -static uint8 SRDesign[] = { _ _ _ _ _ _ G G G G G G G G G - _ _ _ _ _ L G G G G G G G G D - _ _ _ _ _ L G G G G G G G D _ - _ _ _ _ L G G G G G G G D _ _ - _ _ _ _ L G G G G G G D _ _ _ - _ _ _ _ L G G G G G D _ _ _ _ - _ _ _ L G G G G G D _ _ _ _ _ - _ _ _ L G G G G D _ _ _ _ _ _ - _ _ _ L G G G D _ _ _ _ _ _ _ - _ _ L G G G D _ _ _ _ _ _ _ _ - _ _ L G G D _ _ _ _ _ _ _ _ _ - _ _ L G D _ _ _ _ _ _ _ _ _ _ - _ L G D _ _ _ _ _ _ _ _ _ _ _ - _ L D _ _ _ _ _ _ _ _ _ _ _ _ - L D _ _ _ _ _ _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ _ _ _ _ _ _ - }; - -static uint8 MapBrick[] = { L L L L L L L G - L G G G G G G D - L G G G G G G D - G D D D D D D D - }; - -#undef W -#undef _ -#undef x -#undef o -#undef L -#undef G -#undef D - - -#if 0 - -#define _ TRANS, -#define A 213, -#define B 207, -#define C 225, -#define D 219, -#define E 231, - -static uint8 PRDesign[] = { A E E E C C D A B - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - C _ _ _ _ _ _ D A - B A A A A A A A B - B B B B B B B B B - }; - -#else - -#define _ TRANS, -#define A 213, -#define B 207, -#define C 225, // DGRAY -#define D 219, -#define E 231, -#define F 237, - -static uint8 PRDesign[] = { D D D D D D D D _ - D D D D D D D D _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ _ _ - D _ _ _ _ _ _ C _ - D C C C C C C C _ - _ _ _ _ _ _ _ _ _ - }; -#endif - - -#undef _ -#undef A -#undef B -#undef C -#undef D -#undef E - - - -#define _ 0x00, -#define x 0xFF, -#define A _ x _ x _ x _ x -#define B A A A A A A A A - -static uint8 HLDesign[] = { B B B B B }; - -#undef _ -#undef x -#undef A -#undef B - - -// 228 yellow -// 211 red -// 226 light green -// 221 blue - -#define A 208, -#define B 214, -#define C 220, -#define D 226, -#define E 255, - -static uint8 LIDesign[][9] = { { A A A - A B A - A A A }, - - { A B A - B C B - A B A }, - - { B C B - C D C - B C B }, - - { C D C - D E D - C D C }, - }; - -#undef A -#undef B -#undef C -#undef D -#undef E - - -#define R 211, -#define G 0, -//226, - -static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 - { R R R R R R R R G }, // 1 - { R R R R R R R G G }, // 2 - { R R R R R R G G G }, // 3 - { R R R R R G G G G }, // 4 - { R R R R G G G G G }, // 5 - { R R R G G G G G G }, // 6 - { R R G G G G G G G }, // 7 - { R G G G G G G G G }, // 8 - { G G G G G G G G G }, // 9 - }; - -#undef R -#undef G -*/ - -namespace CGE { - - - -} // End of namespace CGE diff --git a/engines/cge/bitmaps.h b/engines/cge/bitmaps.h deleted file mode 100644 index 8569932134..0000000000 --- a/engines/cge/bitmaps.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_BITMAPS__ -#define __CGE_BITMAPS__ - -#include "cge/vga13h.h" - -namespace CGE { - -extern Bitmap *MB[]; -extern Bitmap *HL[]; -extern Bitmap *MC[]; -extern Bitmap *PR[]; -extern Bitmap *SP[]; -extern Bitmap *LI[]; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index b953f2f5b0..4c21b21f87 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -34,7 +34,6 @@ #include "cge/cge_main.h" #include "cge/talk.h" #include "cge/text.h" -#include "cge/bitmaps.h" #include "cge/vol.h" diff --git a/engines/cge/events.h b/engines/cge/events.h index cfb1023d6b..6df2c94d4a 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -91,6 +91,7 @@ struct CGEEvent { extern CGEEvent Evt[EVT_MAX]; extern uint16 EvtHead, EvtTail; +extern Bitmap *MC[]; class MOUSE : public Sprite { diff --git a/engines/cge/game.h b/engines/cge/game.h index b26fc0d165..c442d81577 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -29,7 +29,6 @@ #define __CGE_GAME__ #include "cge/vga13h.h" -#include "cge/bitmaps.h" namespace CGE { diff --git a/engines/cge/module.mk b/engines/cge/module.mk index d9dea6534d..95ffd6d906 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -2,7 +2,6 @@ MODULE := engines/cge MODULE_OBJS := \ bitmap.o \ - bitmaps.o \ btfile.o \ cfile.o \ cge.o \ diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 683568e1a8..a0b5c4bdd6 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -29,7 +29,6 @@ #include "cge/sound.h" #include "cge/snail.h" #include "cge/vga13h.h" -#include "cge/bitmaps.h" #include "cge/text.h" #include "cge/cge_main.h" #include "cge/events.h" diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 5f370150ca..c1d32d15cd 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -29,7 +29,6 @@ #include "cge/text.h" #include "cge/talk.h" #include "cge/vol.h" -#include "cge/bitmaps.h" #include "cge/game.h" #include "cge/snail.h" #include "cge/cge_main.h" -- cgit v1.2.3 From dd778667096d2bfab50ac8171d1ee3a45d46fb55 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Thu, 7 Jul 2011 20:51:31 +0200 Subject: CGE: Remove unused variable --- engines/cge/cge_main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index e7ca76a98f..d08fa67400 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -177,7 +177,6 @@ Cluster XZ(Couple xy) { } void CGEEngine::loadGame(XFile &file, bool tiny = false) { - SavTab *st; Sprite *spr; int i; -- cgit v1.2.3 From 080d7cf7f082b5faa245da965211a099ed37fd2b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 8 Jul 2011 08:21:35 +0200 Subject: CGE: Rename Mouse class --- engines/cge/cge.cpp | 2 +- engines/cge/cge_main.cpp | 20 +++++++------- engines/cge/cge_main.h | 2 +- engines/cge/events.cpp | 69 +++++++++++++++++++++++++----------------------- engines/cge/events.h | 25 +++++++++--------- engines/cge/mixer.cpp | 2 +- engines/cge/snail.cpp | 4 +-- engines/cge/vga13h.cpp | 8 +++--- 8 files changed, 68 insertions(+), 64 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 4c21b21f87..2c173b8990 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -105,7 +105,7 @@ void CGEEngine::setup() { _snail = new Snail(this, false); _snail_ = new Snail(this, true); - _mouse = new MOUSE(this); + _mouse = new Mouse(this); _keyboard = new Keyboard(); _eventManager = new EventManager(); _offUseCount = atoi(_text->getText(OFF_USE_COUNT)); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index d08fa67400..0135b0441a 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -64,7 +64,7 @@ System *_sys; Sprite *_pocLight; EventManager *_eventManager; Keyboard *_keyboard; -MOUSE *_mouse; +Mouse *_mouse; Sprite *_pocket[POCKET_NX]; Sprite *_sprite; Sprite *_miniCave; @@ -681,7 +681,7 @@ void CGEEngine::caveUp() { _vga->sunrise(Vga::_sysPal); _dark = false; if (!_startupMode) - _mouse->On(); + _mouse->on(); _heart->_enable = true; } @@ -732,7 +732,7 @@ void CGEEngine::switchCave(int cav) { warning("SwitchCave() - SNPOST"); } else { _now = cav; - _mouse->Off(); + _mouse->off(); if (_hero) { _hero->park(); _hero->step(0); @@ -1625,9 +1625,9 @@ void CGEEngine::runGame() { _horzLine->_z = 126; _vga->_showQ->insert(_horzLine); - _mouse->Busy = _vga->_spareQ->locate(BUSY_REF); - if (_mouse->Busy) - expandSprite(_mouse->Busy); + _mouse->_busy = _vga->_spareQ->locate(BUSY_REF); + if (_mouse->_busy) + expandSprite(_mouse->_busy); _startupMode = 0; @@ -1649,7 +1649,7 @@ void CGEEngine::runGame() { _heart->_enable = false; SNPOST(SNCLEAR, -1, 0, NULL); SNPOST_(SNCLEAR, -1, 0, NULL); - _mouse->Off(); + _mouse->off(); _vga->_showQ->clear(); _vga->_spareQ->clear(); _hero = NULL; @@ -1716,14 +1716,14 @@ bool CGEEngine::showTitle(const char *name) { _vga->copyPage(0, 1); _vga->_showQ->append(_mouse); _heart->_enable = true; - _mouse->On(); + _mouse->on(); for (selectSound(); !_snail->idle() || Vmenu::_addr;) { mainLoop(); if (_eventManager->_quitFlag) return false; } - _mouse->Off(); + _mouse->off(); _heart->_enable = false; _vga->_showQ->clear(); _vga->copyPage(0, 2); @@ -1812,7 +1812,7 @@ void CGEEngine::cge_main() { //Debug( memset((void *) (-K(4)), 0, K(1)); ) memset(_barriers, 0xFF, sizeof(_barriers)); - if (!_mouse->Exist) + if (!_mouse->_exist) error("%s", _text->getText(NO_MOUSE_TEXT)); if (!SVG0FILE::exist(SVG0NAME)) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 3ef3679e8e..17925f76f9 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -169,7 +169,7 @@ extern System *_sys; extern int _offUseCount; extern Sprite *_pocLight; extern Keyboard *_keyboard; -extern MOUSE *_mouse; +extern Mouse *_mouse; extern EventManager *_eventManager; extern Sprite *_pocket[]; extern Sprite *_sprite; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index e904b710ba..82d0203e5e 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -141,17 +141,18 @@ void Keyboard::NewKeyboard(Common::Event &event) { /*----------------- MOUSE interface -----------------*/ -MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { +Mouse::Mouse(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) { static Seq ms[] = { { 0, 0, 0, 0, 1 }, { 1, 1, 0, 0, 1 } }; - Hold = NULL; - hx = 0; hy = 0; - Exist = true; - Buttons = 0; - Busy = NULL; + _hold = NULL; + _hx = 0; + _hy = 0; + _exist = true; + _buttons = 0; + _busy = NULL; _active = false; setSeq(ms); @@ -162,37 +163,39 @@ MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold( } -MOUSE::~MOUSE() { - Off(); +Mouse::~Mouse() { + off(); } -//void MOUSE::SetFun() +//void Mouse::setFun() //{ //} -void MOUSE::On() { - if (_seqPtr && Exist) { +void Mouse::on() { + if (_seqPtr && _exist) { _active = true; step(0); - if (Busy) Busy->step(0); + if (_busy) + _busy->step(0); } } -void MOUSE::Off() { +void Mouse::off() { if (_seqPtr == 0) { - if (Exist) { + if (_exist) { _active = false; } step(1); - if (Busy) Busy->step(1); + if (_busy) + _busy->step(1); } } -void MOUSE::NewMouse(Common::Event &event) { +void Mouse::newMouse(Common::Event &event) { if (!_active) return; @@ -208,19 +211,19 @@ void MOUSE::NewMouse(Common::Event &event) { break; case Common::EVENT_LBUTTONDOWN: evt._msk = L_DN; - Buttons |= 1; + _buttons |= 1; break; case Common::EVENT_LBUTTONUP: evt._msk = L_UP; - Buttons &= ~1; + _buttons &= ~1; break; case Common::EVENT_RBUTTONDOWN: evt._msk = R_DN; - Buttons |= 2; + _buttons |= 2; break; case Common::EVENT_RBUTTONUP: evt._msk = R_UP; - Buttons &= ~2; + _buttons &= ~2; break; default: break; @@ -252,7 +255,7 @@ void EventManager::poll() { case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONUP: // Handle mouse events - _mouse->NewMouse(_event); + _mouse->newMouse(_event); handleEvents(); break; default: @@ -265,8 +268,8 @@ void EventManager::handleEvents() { while (EvtTail != EvtHead) { CGEEvent e = Evt[EvtTail]; if (e._msk) { - if (_mouse->Hold && e._ptr != _mouse->Hold) - _mouse->Hold->touch(e._msk | ATTN, e._x - _mouse->Hold->_x, e._y - _mouse->Hold->_y); + if (_mouse->_hold && e._ptr != _mouse->_hold) + _mouse->_hold->touch(e._msk | ATTN, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y); // update mouse cursor position if (e._msk & ROLL) @@ -282,18 +285,18 @@ void EventManager::handleEvents() { _sys->touch(e._msk, e._x, e._y); if (e._msk & L_DN) { - _mouse->Hold = e._ptr; - if (_mouse->Hold) { - _mouse->Hold->_flags._hold = true; - _mouse->hx = e._x - _mouse->Hold->_x; - _mouse->hy = e._y - _mouse->Hold->_y; + _mouse->_hold = e._ptr; + if (_mouse->_hold) { + _mouse->_hold->_flags._hold = true; + _mouse->_hx = e._x - _mouse->_hold->_x; + _mouse->_hy = e._y - _mouse->_hold->_y; } } if (e._msk & L_UP) { - if (_mouse->Hold) { - _mouse->Hold->_flags._hold = false; - _mouse->Hold = NULL; + if (_mouse->_hold) { + _mouse->_hold->_flags._hold = false; + _mouse->_hold = NULL; } } ///Touched = e.Ptr; @@ -304,8 +307,8 @@ void EventManager::handleEvents() { } EvtTail = (EvtTail + 1) % EVT_MAX; } - if (_mouse->Hold) - _mouse->Hold->gotoxy(_mouse->_x - _mouse->hx, _mouse->_y - _mouse->hy); + if (_mouse->_hold) + _mouse->_hold->gotoxy(_mouse->_x - _mouse->_hx, _mouse->_y - _mouse->_hy); } void EventManager::ClrEvt(Sprite *spr) { diff --git a/engines/cge/events.h b/engines/cge/events.h index 6df2c94d4a..374c28aebc 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -94,21 +94,22 @@ extern uint16 EvtHead, EvtTail; extern Bitmap *MC[]; -class MOUSE : public Sprite { +class Mouse : public Sprite { public: - Sprite *Hold; + Sprite *_hold; bool _active; - int hx, hy; - bool Exist; - int Buttons; - Sprite *Busy; + int _hx; + int _hy; + bool _exist; + int _buttons; + Sprite *_busy; //Sprite *Touched; - MOUSE(CGEEngine *vm, Bitmap **shpl = MC); - ~MOUSE(); - void On(); - void Off(); - void Tick(); - void NewMouse(Common::Event &event); + Mouse(CGEEngine *vm, Bitmap **shpl = MC); + ~Mouse(); + void on(); + void off(); + void tick(); + void newMouse(Common::Event &event); private: CGEEngine *_vm; }; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index d4a5212552..aea033ebc9 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -34,7 +34,7 @@ namespace CGE { -extern MOUSE *Mouse; +extern Mouse *Mouse; bool Mixer::_appear = false; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index a0b5c4bdd6..15ba714369 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -848,9 +848,9 @@ void CGEEngine::snReach(Sprite *spr, int mode) { void CGEEngine::snMouse(bool on) { if (on) - _mouse->On(); + _mouse->on(); else - _mouse->Off(); + _mouse->off(); } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 36ac060111..e1309c96f0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -234,14 +234,14 @@ extern "C" void TimerProc() { if (Sys) { if (Sys->Time) { if (--Sys->Time == 0) - Sys->Tick(); + Sys->tick(); } } for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { if (spr->Time) { if (!spr->_flags.Hide) { if (-- spr->Time == 0) - spr->Tick(); + spr->tick(); } } } @@ -308,7 +308,7 @@ void Engine_::newTimer(...) { if (Sys) { if (Sys->Time) { if (--Sys->Time == 0) - Sys->Tick(); + Sys->tick(); } } @@ -316,7 +316,7 @@ void Engine_::newTimer(...) { if (spr->Time) { if (!spr->_flags.Hide) { if (--spr->Time == 0) - spr->Tick(); + spr->tick(); } } } -- cgit v1.2.3 From 0b27de942b9dcb9cd3ea75955c02bb1bf813ddd8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 9 Jul 2011 00:25:09 +0200 Subject: CGE: replace some 'tricky replicate lines' memcpy by two, in order to avoid overlapping --- engines/cge/events.h | 1 - engines/cge/talk.cpp | 29 +++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/engines/cge/events.h b/engines/cge/events.h index 374c28aebc..90b8ed1db0 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -108,7 +108,6 @@ public: ~Mouse(); void on(); void off(); - void tick(); void newMouse(Common::Event &event); private: CGEEngine *_vm; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 7c0f9563a6..61de47e48a 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -248,13 +248,22 @@ void Talk::putLine(int line, const char *text) { // clear whole rectangle p = v; // assume blanked line above text - memcpy(p, p - lsiz, rsiz); + + byte *tmpBuf = new byte[rsiz]; + + memcpy(tmpBuf, p - lsiz, rsiz); + memcpy(p, tmpBuf, rsiz); p += psiz; // tricky replicate lines for plane 0 - memcpy(p, p - lsiz, rsiz); + memcpy(tmpBuf, p - lsiz, rsiz); + memcpy(p, tmpBuf, rsiz); p += psiz; // same for plane 1 - memcpy(p, p - lsiz, rsiz); + memcpy(tmpBuf, p - lsiz, rsiz); + memcpy(p, tmpBuf, rsiz); p += psiz; // same for plane 2 - memcpy(p, p - lsiz, rsiz); // same for plane 3 + memcpy(tmpBuf, p - lsiz, rsiz); + memcpy(p, tmpBuf, rsiz); + + delete[] tmpBuf; // paint text line if (text) { @@ -302,10 +311,18 @@ void InfoLine::update(const char *tx) { uint16 size = 4 * psiz; // whole map size // clear whole rectangle + byte *tmpBuf = new byte[size]; memset(v + 2, TEXT_BG, dsiz); // data bytes - memcpy(v + lsiz, v, psiz - lsiz); // tricky replicate lines + + memcpy(tmpBuf, v, psiz - lsiz); + memcpy(v + lsiz, tmpBuf, psiz - lsiz); + *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 - memcpy(v + psiz, v, 3 * psiz); // tricky replicate planes + + memcpy(tmpBuf, v, 3 * psiz); + memcpy(v + psiz, tmpBuf, 3 * psiz); + + delete[] tmpBuf; // paint text line if (tx) { -- cgit v1.2.3 From 6ed9dd0d04b8513ad44e3541afc6db758100310c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 9 Jul 2011 00:41:47 +0200 Subject: CGE: Cleanup: rename a couple of forgotten class members --- engines/cge/events.cpp | 6 +++--- engines/cge/events.h | 6 ++---- engines/cge/snail.cpp | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 82d0203e5e..116eb34b52 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -116,7 +116,7 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) { return false; } -void Keyboard::NewKeyboard(Common::Event &event) { +void Keyboard::newKeyboard(Common::Event &event) { int keycode; if (!getKey(event.kbd.keycode, keycode)) return; @@ -246,7 +246,7 @@ void EventManager::poll() { case Common::EVENT_KEYDOWN: case Common::EVENT_KEYUP: // Handle keyboard events - _keyboard->NewKeyboard(_event); + _keyboard->newKeyboard(_event); handleEvents(); break; case Common::EVENT_MOUSEMOVE: @@ -311,7 +311,7 @@ void EventManager::handleEvents() { _mouse->_hold->gotoxy(_mouse->_x - _mouse->_hx, _mouse->_y - _mouse->_hy); } -void EventManager::ClrEvt(Sprite *spr) { +void EventManager::clrEvt(Sprite *spr) { if (spr) { uint16 e; for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) diff --git a/engines/cge/events.h b/engines/cge/events.h index 90b8ed1db0..75c504f030 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -56,7 +56,7 @@ public: Sprite *_client; bool _key[0x60]; - void NewKeyboard(Common::Event &event); + void newKeyboard(Common::Event &event); uint16 last() { uint16 cur = _current; _current = 0; @@ -89,8 +89,6 @@ struct CGEEvent { Sprite *_ptr; }; -extern CGEEvent Evt[EVT_MAX]; -extern uint16 EvtHead, EvtTail; extern Bitmap *MC[]; @@ -124,7 +122,7 @@ public: EventManager(); void poll(); - static void ClrEvt(Sprite *spr = NULL); + static void clrEvt(Sprite *spr = NULL); }; } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 15ba714369..242fb067e7 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -710,7 +710,7 @@ void CGEEngine::snKill(Sprite *spr) { Sprite *nx = spr->_next; hide1(spr); _vga->_showQ->remove(spr); - EventManager::ClrEvt(spr); + EventManager::clrEvt(spr); if (spr->_flags._kill) delete spr; else { -- cgit v1.2.3 From cf1a45f8a8ecfe758dfb6a420b004821528a19cc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 9 Jul 2011 09:39:02 +0200 Subject: CGE: replace the 2 memcpy previously used by a memmove (thanks eriktorbjorn for pointing that out) --- engines/cge/talk.cpp | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 61de47e48a..f41e31dce6 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -248,22 +248,13 @@ void Talk::putLine(int line, const char *text) { // clear whole rectangle p = v; // assume blanked line above text - - byte *tmpBuf = new byte[rsiz]; - - memcpy(tmpBuf, p - lsiz, rsiz); - memcpy(p, tmpBuf, rsiz); + memmove(p, p - lsiz, rsiz); p += psiz; // tricky replicate lines for plane 0 - memcpy(tmpBuf, p - lsiz, rsiz); - memcpy(p, tmpBuf, rsiz); + memmove(p, p - lsiz, rsiz); p += psiz; // same for plane 1 - memcpy(tmpBuf, p - lsiz, rsiz); - memcpy(p, tmpBuf, rsiz); + memmove(p, p - lsiz, rsiz); p += psiz; // same for plane 2 - memcpy(tmpBuf, p - lsiz, rsiz); - memcpy(p, tmpBuf, rsiz); - - delete[] tmpBuf; + memmove(p, p - lsiz, rsiz); // paint text line if (text) { @@ -311,18 +302,10 @@ void InfoLine::update(const char *tx) { uint16 size = 4 * psiz; // whole map size // clear whole rectangle - byte *tmpBuf = new byte[size]; memset(v + 2, TEXT_BG, dsiz); // data bytes - - memcpy(tmpBuf, v, psiz - lsiz); - memcpy(v + lsiz, tmpBuf, psiz - lsiz); - + memmove(v + lsiz, v, psiz - lsiz); *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 - - memcpy(tmpBuf, v, 3 * psiz); - memcpy(v + psiz, tmpBuf, 3 * psiz); - - delete[] tmpBuf; + memmove(v + psiz, v, 3 * psiz); // paint text line if (tx) { -- cgit v1.2.3 From 989e071bb9d101696f5498d1eeea5e32c7291e5d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 09:44:46 +1000 Subject: CGE: Implemented code for saving games, removing the need for the SavTab array --- engines/cge/cge.cpp | 51 ----------------------------- engines/cge/cge.h | 5 +-- engines/cge/cge_main.cpp | 83 +++++++++++++++++++++++++++++++----------------- 3 files changed, 57 insertions(+), 82 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 2c173b8990..25fc4f7c00 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -116,57 +116,6 @@ void CGEEngine::setup() { _volume[0] = 0; _volume[1] = 0; - _savTab[0]._ptr = &_now; - _savTab[0]._len = sizeof(_now); - _savTab[0]._flag = true; - _savTab[1]._ptr = &_oldLev; - _savTab[1]._len = sizeof(_oldLev); - _savTab[1]._flag = true; - _savTab[2]._ptr = &_demoText; - _savTab[2]._len = sizeof(_demoText); - _savTab[2]._flag = true; - _savTab[3]._ptr = &_game; - _savTab[3]._len = sizeof(_game); - _savTab[3]._flag = true; - _savTab[4]._ptr = &_game; - _savTab[4]._len = sizeof(_game); - _savTab[4]._flag = true; - _savTab[5]._ptr = &_game; - _savTab[5]._len = sizeof(_game); - _savTab[5]._flag = true; - _savTab[6]._ptr = &_game; - _savTab[6]._len = sizeof(_game); - _savTab[6]._flag = true; - _savTab[7]._ptr = &_game; - _savTab[7]._len = sizeof(_game); - _savTab[7]._flag = true; - _savTab[8]._ptr = &_vga->_mono; - _savTab[8]._len = sizeof(_vga->_mono); - _savTab[8]._flag = false; - _savTab[9]._ptr = &_music; - _savTab[9]._len = sizeof(_music); - _savTab[9]._flag = true; - _savTab[10]._ptr = _volume; - _savTab[10]._len = sizeof(_volume); - _savTab[10]._flag = true; - _savTab[11]._ptr = _flag; - _savTab[11]._len = sizeof(_flag); - _savTab[11]._flag = true; - _savTab[12]._ptr = _heroXY; -// _savTab[12]._len = sizeof(_heroXY); FIXME: illegal sizeof - _savTab[12]._len = 0; - _savTab[12]._flag = true; - _savTab[13]._ptr = _barriers; -// _savTab[13]._len = sizeof(_barriers); FIXME: illegal sizeof - _savTab[13]._len = 0; - _savTab[13]._flag = true; - _savTab[14]._ptr = _pocref; - _savTab[14]._len = sizeof(_pocref); - _savTab[14]._flag = true; - _savTab[15]._ptr = NULL; - _savTab[15]._len = 0; - _savTab[15]._flag = false; - if (_isDemo) { _maxCaveArr[0] = CAVE_MAX; _maxCaveArr[1] = -1; diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 4f6b452850..49f2c46e40 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -25,6 +25,7 @@ #include "cge/general.h" #include "common/random.h" +#include "common/serializer.h" #include "engines/engine.h" #include "gui/debugger.h" #include "graphics/surface.h" @@ -58,6 +59,7 @@ class CGEEngine : public Engine { private: uint32 _lastFrame; void tick(); + void syncHeader(Common::Serializer &s); public: CGEEngine(OSystem *syst, const ADGameDescription *gameDescription); ~CGEEngine(); @@ -69,7 +71,6 @@ public: int _oldLev; bool _jbw; int _pocPtr; - SavTab _savTab[16]; bool _music; int _pocref[POCKET_NX]; uint8 _volume[2]; @@ -124,7 +125,7 @@ public: void setIRQ(); void setDMA(); void mainLoop(); - void saveGame(XFile &file); + void saveGame(Common::WriteStream *file); void switchMusic(); void selectPocket(int n); void expandSprite(Sprite *spr); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 0135b0441a..256cee6795 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -27,6 +27,7 @@ #include "common/scummsys.h" #include "common/memstream.h" +#include "common/savefile.h" #include "common/serializer.h" #include "cge/general.h" #include "cge/sound.h" @@ -176,18 +177,9 @@ Cluster XZ(Couple xy) { return XZ(x, y); } -void CGEEngine::loadGame(XFile &file, bool tiny = false) { - Sprite *spr; +void CGEEngine::syncHeader(Common::Serializer &s) { int i; - // Read the data into a data buffer - int size = file.size() - file.mark(); - byte *dataBuffer = new byte[size]; - file.read(dataBuffer, size); - Common::MemoryReadStream readStream(dataBuffer, size, DisposeAfterUse::YES); - Common::Serializer s(&readStream, NULL); - - // Synchronise header data s.syncAsUint16LE(_now); s.syncAsUint16LE(_oldLev); s.syncAsUint16LE(_demoText); @@ -210,10 +202,32 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { for (i = 0; i < POCKET_NX; ++i) s.syncAsUint16LE(_pocref[i]); - uint16 checksum; - s.syncAsUint16LE(checksum); - if (checksum != SVGCHKSUM) - error("%s", _text->getText(BADSVG_TEXT)); + if (s.isSaving()) { + // Write checksum + int checksum = SVGCHKSUM; + s.syncAsUint16LE(checksum); + } else { + // Read checksum and validate it + uint16 checksum; + s.syncAsUint16LE(checksum); + if (checksum != SVGCHKSUM) + error("%s", _text->getText(BADSVG_TEXT)); + } +} + +void CGEEngine::loadGame(XFile &file, bool tiny = false) { + Sprite *spr; + int i; + + // Read the data into a data buffer + int size = file.size() - file.mark(); + byte *dataBuffer = new byte[size]; + file.read(dataBuffer, size); + Common::MemoryReadStream readStream(dataBuffer, size, DisposeAfterUse::YES); + Common::Serializer s(&readStream, NULL); + + // Synchronise header data + syncHeader(s); if (Startup::_core < CORE_HIG) _music = false; @@ -253,7 +267,7 @@ void CGEEngine::saveSound() { } -void CGEEngine::saveGame(XFile &file) { +void CGEEngine::saveGame(Common::WriteStream *file) { SavTab *st; Sprite *spr; int i; @@ -266,18 +280,19 @@ void CGEEngine::saveGame(XFile &file) { _volume[0] = _sndDrvInfo.Vol2._d; _volume[1] = _sndDrvInfo.Vol2._m; - for (st = _savTab; st->_ptr; st++) { - if (file._error) - error("Bad SVG"); - file.write((uint8 *) st->_ptr, st->_len); - } + Common::Serializer s(NULL, file); + + // Synchronise header data + syncHeader(s); - file.write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); + // Loop through saving the sprite data + for (spr = _vga->_spareQ->first(); spr; spr = spr->_next) { + if ((spr->_ref >= 1000) && !s.err()) + spr->sync(s); + } - for (spr = _vga->_spareQ->first(); spr; spr = spr->_next) - if (spr->_ref >= 1000) - if (!file._error) - file.write((uint8 *)spr, sizeof(*spr)); + // Finish writing out game data + file->finalize(); } void CGEEngine::heroCover(int cvr) { @@ -715,8 +730,12 @@ void CGEEngine::qGame() { caveDown(); _oldLev = _lev; saveSound(); - CFile file = CFile(usrPath(_usrFnam), WRI, RCrypt); - saveGame(file); + + // Write out the user's progress + Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(Common::String(_usrFnam)); + saveGame(saveFile); + delete saveFile; + _vga->sunset(); _finis = true; } @@ -1531,10 +1550,16 @@ void CGEEngine::loadUser() { SVG0FILE file = SVG0FILE(SVG0NAME); loadGame(file); } else { + // TODO: I think this was only used by the original developers to create the initial + // game state savegame. Verify this is the case, and if so remove this block loadScript(progName(INI_EXT)); _music = true; - CFile file = CFile(SVG0NAME, WRI); - saveGame(file); + + Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving( + Common::String(SVG0NAME)); + saveGame(saveFile); + delete saveFile; + error("Ok [%s]", SVG0NAME); } } -- cgit v1.2.3 From 1e83e27925e121ee50b3ee66f5fb007e2d6b338f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 09:51:18 +1000 Subject: CGE: Moved MB sprite array into Square class --- engines/cge/cge.cpp | 3 --- engines/cge/cge_main.cpp | 8 ++++++-- engines/cge/cge_main.h | 2 -- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 25fc4f7c00..4fca901873 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -69,8 +69,6 @@ void CGEEngine::setup() { Talk::init(); // Initialise sprite arrays used by game objects - MB[0] = new Bitmap("BRICK", true); - MB[1] = NULL; HL[0] = new Bitmap("HLINE", true); HL[1] = NULL; MC[0] = new Bitmap("MOUSE", true); @@ -162,7 +160,6 @@ CGEEngine::~CGEEngine() { delete _infoLine; delete _cavLight; delete _debugLine; - delete MB[0]; delete HL[0]; delete MC[0]; delete MC[1]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 256cee6795..5f56899bc8 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -75,7 +75,6 @@ InfoLine *_infoLine; Sprite *_cavLight; InfoLine *_debugLine; -BMP_PTR MB[2]; BMP_PTR HL[2]; BMP_PTR MC[3]; BMP_PTR PR[2]; @@ -516,9 +515,14 @@ private: SQUARE::SQUARE(CGEEngine *vm) - : Sprite(vm, MB), _vm(vm) { + : Sprite(vm, NULL), _vm(vm) { _flags._kill = true; _flags._bDel = false; + + BMP_PTR *MB = new BMP_PTR[2]; + MB[0] = new Bitmap("BRICK", true); + MB[1] = NULL; + setShapeList(MB); } diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 17925f76f9..ff2e5a0492 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -179,8 +179,6 @@ extern Sprite *_horzLine; extern InfoLine *_infoLine; extern Sprite *_cavLight; extern InfoLine *_debugLine; -extern BMP_PTR MB[2]; -extern BMP_PTR MB[2]; extern BMP_PTR HL[2]; extern BMP_PTR MC[3]; extern BMP_PTR PR[2]; -- cgit v1.2.3 From 817a52ed56abc172b158d794501f2bff0ab70e94 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 09:57:19 +1000 Subject: CGE: Created a HorizLine stub class to hold the HL sprite array --- engines/cge/cge.cpp | 5 +---- engines/cge/cge_main.cpp | 3 +-- engines/cge/cge_main.h | 3 +-- engines/cge/vga13h.cpp | 11 +++++++++++ engines/cge/vga13h.h | 4 ++++ 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 4fca901873..1fba9dfdc2 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -69,8 +69,6 @@ void CGEEngine::setup() { Talk::init(); // Initialise sprite arrays used by game objects - HL[0] = new Bitmap("HLINE", true); - HL[1] = NULL; MC[0] = new Bitmap("MOUSE", true); MC[1] = new Bitmap("DUMMY", true); MC[2] = NULL; @@ -96,7 +94,7 @@ void CGEEngine::setup() { _sprite = new Sprite(this, NULL); _miniCave = new Sprite(this, NULL); _shadow = new Sprite(this, NULL); - _horzLine = new Sprite(this, HL); + _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, INFO_W); _cavLight = new Sprite(this, PR); _debugLine = new InfoLine(this, SCR_WID); @@ -160,7 +158,6 @@ CGEEngine::~CGEEngine() { delete _infoLine; delete _cavLight; delete _debugLine; - delete HL[0]; delete MC[0]; delete MC[1]; delete PR[0]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 5f56899bc8..f74eda259e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -70,12 +70,11 @@ Sprite *_pocket[POCKET_NX]; Sprite *_sprite; Sprite *_miniCave; Sprite *_shadow; -Sprite *_horzLine; +HorizLine *_horzLine; InfoLine *_infoLine; Sprite *_cavLight; InfoLine *_debugLine; -BMP_PTR HL[2]; BMP_PTR MC[3]; BMP_PTR PR[2]; BMP_PTR SP[3]; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index ff2e5a0492..6455b0d3ca 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -175,11 +175,10 @@ extern Sprite *_pocket[]; extern Sprite *_sprite; extern Sprite *_miniCave; extern Sprite *_shadow; -extern Sprite *_horzLine; +extern HorizLine *_horzLine; extern InfoLine *_infoLine; extern Sprite *_cavLight; extern InfoLine *_debugLine; -extern BMP_PTR HL[2]; extern BMP_PTR MC[3]; extern BMP_PTR PR[2]; extern BMP_PTR SP[3]; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e1309c96f0..fb1c89ef5e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1360,4 +1360,15 @@ void Bitmap::hide(int x, int y) { } } +/*--------------------------------------------------------------------------*/ + +HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { + // Set the sprite list + BMP_PTR *HL = new BMP_PTR[2]; + HL[0] = new Bitmap("HLINE", true); + HL[1] = NULL; + + setShapeList(HL); +} + } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index b0cba4dcc0..d9aba0468e 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -306,6 +306,10 @@ public: static void dacToPal(const Dac *tab, byte *palData); }; +class HorizLine: public Sprite { +public: + HorizLine(CGEEngine *vm); +}; Dac mkDac(uint8 r, uint8 g, uint8 b); Rgb mkRgb(uint8 r, uint8 g, uint8 b); -- cgit v1.2.3 From 9d40a1ba9d79fd8623dc0525cf25cfc4756a36d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:00:57 +1000 Subject: CGE: Mouse MC sprite array into the Mouse class --- engines/cge/cge.cpp | 5 ----- engines/cge/cge_main.cpp | 1 - engines/cge/events.cpp | 8 +++++++- engines/cge/events.h | 4 +--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 1fba9dfdc2..5ce83f109d 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -69,9 +69,6 @@ void CGEEngine::setup() { Talk::init(); // Initialise sprite arrays used by game objects - MC[0] = new Bitmap("MOUSE", true); - MC[1] = new Bitmap("DUMMY", true); - MC[2] = NULL; PR[0] = new Bitmap("PRESS", true); PR[1] = NULL; SP[0] = new Bitmap("SPK_L", true); @@ -158,8 +155,6 @@ CGEEngine::~CGEEngine() { delete _infoLine; delete _cavLight; delete _debugLine; - delete MC[0]; - delete MC[1]; delete PR[0]; delete SP[0]; delete SP[1]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index f74eda259e..7edfd9b1d1 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -75,7 +75,6 @@ InfoLine *_infoLine; Sprite *_cavLight; InfoLine *_debugLine; -BMP_PTR MC[3]; BMP_PTR PR[2]; BMP_PTR SP[3]; BMP_PTR LI[5]; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 116eb34b52..6168dd15a8 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -141,7 +141,7 @@ void Keyboard::newKeyboard(Common::Event &event) { /*----------------- MOUSE interface -----------------*/ -Mouse::Mouse(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) { +Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) { static Seq ms[] = { { 0, 0, 0, 0, 1 }, { 1, 1, 0, 0, 1 } @@ -157,6 +157,12 @@ Mouse::Mouse(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), _busy(NULL), _hol setSeq(ms); + BMP_PTR *MC = new BMP_PTR[3]; + MC[0] = new Bitmap("MOUSE", true); + MC[1] = new Bitmap("DUMMY", true); + MC[2] = NULL; + setShapeList(MC); + gotoxy(SCR_WID/2, SCR_HIG/2); _z = 127; step(1); diff --git a/engines/cge/events.h b/engines/cge/events.h index 75c504f030..671878f69a 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -89,8 +89,6 @@ struct CGEEvent { Sprite *_ptr; }; -extern Bitmap *MC[]; - class Mouse : public Sprite { public: @@ -102,7 +100,7 @@ public: int _buttons; Sprite *_busy; //Sprite *Touched; - Mouse(CGEEngine *vm, Bitmap **shpl = MC); + Mouse(CGEEngine *vm); ~Mouse(); void on(); void off(); -- cgit v1.2.3 From 622dc2d503c247e750d82fb9dea885bcf14881ed Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:04:41 +1000 Subject: CGE: Created a CavLight class to encapsulate the PR sprite array --- engines/cge/cge.cpp | 5 +---- engines/cge/cge_main.cpp | 1 - engines/cge/cge_main.h | 1 - engines/cge/vga13h.cpp | 9 +++++++++ engines/cge/vga13h.h | 5 +++++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 5ce83f109d..6dbe12d9c6 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -69,8 +69,6 @@ void CGEEngine::setup() { Talk::init(); // Initialise sprite arrays used by game objects - PR[0] = new Bitmap("PRESS", true); - PR[1] = NULL; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; @@ -93,7 +91,7 @@ void CGEEngine::setup() { _shadow = new Sprite(this, NULL); _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, INFO_W); - _cavLight = new Sprite(this, PR); + _cavLight = new CavLight(this); _debugLine = new InfoLine(this, SCR_WID); _snail = new Snail(this, false); _snail_ = new Snail(this, true); @@ -155,7 +153,6 @@ CGEEngine::~CGEEngine() { delete _infoLine; delete _cavLight; delete _debugLine; - delete PR[0]; delete SP[0]; delete SP[1]; delete LI[0]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 7edfd9b1d1..4632caabfa 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -75,7 +75,6 @@ InfoLine *_infoLine; Sprite *_cavLight; InfoLine *_debugLine; -BMP_PTR PR[2]; BMP_PTR SP[3]; BMP_PTR LI[5]; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 6455b0d3ca..d7594c94d9 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -180,7 +180,6 @@ extern InfoLine *_infoLine; extern Sprite *_cavLight; extern InfoLine *_debugLine; extern BMP_PTR MC[3]; -extern BMP_PTR PR[2]; extern BMP_PTR SP[3]; extern BMP_PTR LI[5]; extern Snail *_snail; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index fb1c89ef5e..1f12dd8aa9 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1371,4 +1371,13 @@ HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(HL); } +CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { + // Set the sprite list + BMP_PTR *PR = new BMP_PTR[2]; + PR[0] = new Bitmap("PRESS", true); + PR[1] = NULL; + + setShapeList(PR); +} + } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index d9aba0468e..6ee4c6f320 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -311,6 +311,11 @@ public: HorizLine(CGEEngine *vm); }; +class CavLight: public Sprite { +public: + CavLight(CGEEngine *vm); +}; + Dac mkDac(uint8 r, uint8 g, uint8 b); Rgb mkRgb(uint8 r, uint8 g, uint8 b); -- cgit v1.2.3 From 47b17cd1cec22dfaafe80ce23805587d3a6e4821 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:07:35 +1000 Subject: CGE: Create Spike class to encapsulate the SP spite array --- engines/cge/cge.cpp | 5 ----- engines/cge/cge_main.cpp | 1 - engines/cge/cge_main.h | 1 - engines/cge/text.cpp | 2 +- engines/cge/vga13h.cpp | 10 ++++++++++ engines/cge/vga13h.h | 6 ++++++ 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 6dbe12d9c6..1df0165e5d 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -69,9 +69,6 @@ void CGEEngine::setup() { Talk::init(); // Initialise sprite arrays used by game objects - SP[0] = new Bitmap("SPK_L", true); - SP[1] = new Bitmap("SPK_R", true); - SP[2] = NULL; LI[0] = new Bitmap("LITE0", true); LI[1] = new Bitmap("LITE1", true); LI[2] = new Bitmap("LITE2", true); @@ -153,8 +150,6 @@ CGEEngine::~CGEEngine() { delete _infoLine; delete _cavLight; delete _debugLine; - delete SP[0]; - delete SP[1]; delete LI[0]; delete LI[1]; delete LI[2]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4632caabfa..452791b99e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -75,7 +75,6 @@ InfoLine *_infoLine; Sprite *_cavLight; InfoLine *_debugLine; -BMP_PTR SP[3]; BMP_PTR LI[5]; Snail *_snail; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index d7594c94d9..9706e4c0ec 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -180,7 +180,6 @@ extern InfoLine *_infoLine; extern Sprite *_cavLight; extern InfoLine *_debugLine; extern BMP_PTR MC[3]; -extern BMP_PTR SP[3]; extern BMP_PTR LI[5]; extern Snail *_snail; extern Snail *_snail_; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index c1d32d15cd..63d618b5d5 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -183,7 +183,7 @@ void Text::say(const char *txt, Sprite *spr) { bool east = spr->_flags._east; int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); int y = spr->_y + 2; - Sprite *spike = new Sprite(_vm, SP); + Sprite *spike = new Spike(_vm); uint16 sw = spike->_w; if (east) { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 1f12dd8aa9..ce4465a416 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1380,4 +1380,14 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(PR); } +Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { + // Set the sprite list + BMP_PTR *SP = new BMP_PTR[2]; + SP[0] = new Bitmap("SPK_L", true); + SP[1] = new Bitmap("SPK_R", true); + SP[2] = NULL; + + setShapeList(SP); +} + } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 6ee4c6f320..ec8b81fe0b 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -316,6 +316,12 @@ public: CavLight(CGEEngine *vm); }; +class Spike: public Sprite { +public: + Spike(CGEEngine *vm); +}; + + Dac mkDac(uint8 r, uint8 g, uint8 b); Rgb mkRgb(uint8 r, uint8 g, uint8 b); -- cgit v1.2.3 From 0bbefbef901e5bf5686f6fe0b49ebbdc9f89a3df Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:10:51 +1000 Subject: CGE: Created PocLight class to encapsulate the LI sprite array --- engines/cge/cge.cpp | 13 +------------ engines/cge/cge_main.cpp | 2 -- engines/cge/cge_main.h | 1 - engines/cge/vga13h.cpp | 12 ++++++++++++ engines/cge/vga13h.h | 5 +++++ 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 1df0165e5d..2957ba87f1 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -68,19 +68,12 @@ void CGEEngine::setup() { Bitmap::init(); Talk::init(); - // Initialise sprite arrays used by game objects - LI[0] = new Bitmap("LITE0", true); - LI[1] = new Bitmap("LITE1", true); - LI[2] = new Bitmap("LITE2", true); - LI[3] = new Bitmap("LITE3", true); - LI[4] = NULL; - // Initialise engine objects _text = new Text(this, progName(), 128); _vga = new Vga(M13H); _heart = new Heart; _sys = new System(this); - _pocLight = new Sprite(this, LI); + _pocLight = new PocLight(this); for (int i = 0; i < POCKET_NX; i++) _pocket[i] = new Sprite(this, NULL); _sprite = new Sprite(this, NULL); @@ -150,10 +143,6 @@ CGEEngine::~CGEEngine() { delete _infoLine; delete _cavLight; delete _debugLine; - delete LI[0]; - delete LI[1]; - delete LI[2]; - delete LI[3]; delete _text; delete _heart; delete _pocLight; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 452791b99e..33a85ae8ac 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -75,8 +75,6 @@ InfoLine *_infoLine; Sprite *_cavLight; InfoLine *_debugLine; -BMP_PTR LI[5]; - Snail *_snail; Snail *_snail_; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 9706e4c0ec..8495ef8786 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -180,7 +180,6 @@ extern InfoLine *_infoLine; extern Sprite *_cavLight; extern InfoLine *_debugLine; extern BMP_PTR MC[3]; -extern BMP_PTR LI[5]; extern Snail *_snail; extern Snail *_snail_; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ce4465a416..ed87da1c82 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1390,4 +1390,16 @@ Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(SP); } +PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { + // Set the sprite list + BMP_PTR *LI = new BMP_PTR[5]; + LI[0] = new Bitmap("LITE0", true); + LI[1] = new Bitmap("LITE1", true); + LI[2] = new Bitmap("LITE2", true); + LI[3] = new Bitmap("LITE3", true); + LI[4] = NULL; + + setShapeList(LI); +} + } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index ec8b81fe0b..003be7c800 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -321,6 +321,11 @@ public: Spike(CGEEngine *vm); }; +class PocLight: public Sprite { +public: + PocLight(CGEEngine *vm); +}; + Dac mkDac(uint8 r, uint8 g, uint8 b); Rgb mkRgb(uint8 r, uint8 g, uint8 b); -- cgit v1.2.3 From 319ff2ca4911a68b7d21246699c31ca26b8e59a2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:11:50 +1000 Subject: CGE: Changed Sprite::contract to always destroy the sprite array --- engines/cge/vga13h.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ed87da1c82..2530bf970a 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -620,8 +620,7 @@ Sprite *Sprite::contract() { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; - if (memType(e->_shpList) == NEAR_MEM) - delete[] e->_shpList; + delete[] e->_shpList; } if (memType(e->_seq) == NEAR_MEM) free(e->_seq); -- cgit v1.2.3 From 6039e8a24546d0cd58f20454ee41862908f09caf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:12:46 +1000 Subject: CGE: Removed the definition of the now unused SavTab structure --- engines/cge/cge.h | 6 ------ engines/cge/cge_main.cpp | 1 - 2 files changed, 7 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 49f2c46e40..29a7a11b9d 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -49,12 +49,6 @@ enum SNLIST { NEAR, TAKE }; #define POCKET_NX 8 -struct SavTab { - void *_ptr; - int32 _len; - bool _flag; -}; - class CGEEngine : public Engine { private: uint32 _lastFrame; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 33a85ae8ac..5b6a49ee4a 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -261,7 +261,6 @@ void CGEEngine::saveSound() { void CGEEngine::saveGame(Common::WriteStream *file) { - SavTab *st; Sprite *spr; int i; -- cgit v1.2.3 From 8628b154a7cb06ec6a3a185392dc3ae8ef87ab1b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 11:40:06 +1000 Subject: CGE: Fixed compiler warning --- engines/cge/cge_main.h | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 8495ef8786..a60ba0515e 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -179,7 +179,6 @@ extern HorizLine *_horzLine; extern InfoLine *_infoLine; extern Sprite *_cavLight; extern InfoLine *_debugLine; -extern BMP_PTR MC[3]; extern Snail *_snail; extern Snail *_snail_; -- cgit v1.2.3 From ef83c248d386ec75b4e3ddf3d1178e82a38b6b76 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 11:45:17 +1000 Subject: CGE: Added extra event processing call to fix non-responsiveness when running under Valgrind --- engines/cge/cge_main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 5b6a49ee4a..c800d242ae 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1524,6 +1524,9 @@ void CGEEngine::mainLoop() { // Dispatch the tick to any active objects tick(); + + // Handle any pending events + _eventManager->poll(); } void CGEEngine::tick() { -- cgit v1.2.3 From 1870f09d3131ea6b9e2646343e5191cda614b49b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 14:51:22 +1000 Subject: CGE: Fix several allocation mismatches and Valgrind issues --- engines/cge/cge_main.cpp | 4 +++- engines/cge/events.cpp | 2 +- engines/cge/talk.cpp | 15 ++++++++++++--- engines/cge/talk.h | 2 +- engines/cge/vga13h.cpp | 2 +- engines/cge/vmenu.cpp | 4 ++++ 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index c800d242ae..a4d110eac6 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1715,7 +1715,9 @@ bool CGEEngine::showTitle(const char *name) { return false; Bitmap::_pal = Vga::_sysPal; - BMP_PTR LB[] = { new Bitmap(name, true), NULL }; + BMP_PTR *LB = new BMP_PTR[2]; + LB[0] = new Bitmap(name, true); + LB[1] = NULL; Bitmap::_pal = NULL; bool usr_ok = false; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 6168dd15a8..71110c4067 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -154,7 +154,7 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) _buttons = 0; _busy = NULL; _active = false; - + _flags._kill = true; setSeq(ms); BMP_PTR *MC = new BMP_PTR[3]; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index f41e31dce6..b6f276c452 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -99,7 +99,8 @@ void Font::save() { Talk::Talk(CGEEngine *vm, const char *tx, TBOX_STYLE mode) : Sprite(vm, NULL), _mode(mode), _vm(vm) { - _ts[0] = _ts[1] = NULL; + + _ts = NULL; _flags._syst = true; update(tx); } @@ -107,7 +108,7 @@ Talk::Talk(CGEEngine *vm, const char *tx, TBOX_STYLE mode) Talk::Talk(CGEEngine *vm) : Sprite(vm, NULL), _mode(PURE), _vm(vm) { - _ts[0] = _ts[1] = NULL; + _ts = NULL; _flags._syst = true; } @@ -141,7 +142,7 @@ void Talk::update(const char *tx) { const char *p; uint8 *m; - if (!_ts[0]) { + if (!_ts) { uint16 k = 2 * hmarg; mh = 2 * vmarg + FONT_HIG; for (p = tx; *p; p++) { @@ -155,7 +156,10 @@ void Talk::update(const char *tx) { } if (k > mw) mw = k; + + _ts = new BMP_PTR[2]; _ts[0] = box(mw, mh); + _ts[1] = NULL; } m = _ts[0]->_m + ln * mw + hmarg; @@ -286,6 +290,11 @@ void Talk::putLine(int line, const char *text) { InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldTxt(NULL), _vm(vm) { + if (!_ts) { + _ts = new BMP_PTR[2]; + _ts[1] = NULL; + } + _ts[0] = new Bitmap(w, FONT_HIG, TEXT_BG); setShapeList(_ts); } diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 2f70471359..4d30047ea1 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -71,7 +71,7 @@ enum TBOX_STYLE { PURE, RECT, ROUND }; class Talk : public Sprite { protected: TBOX_STYLE _mode; - Bitmap *_ts[2]; + BMP_PTR *_ts; Bitmap *box(uint16 w, uint16 h); public: Talk(CGEEngine *vm, const char *tx, TBOX_STYLE mode); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 2530bf970a..6e0493695a 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -619,7 +619,7 @@ Sprite *Sprite::contract() { if (_flags._bDel && e->_shpList) { int i; for (i = 0; e->_shpList[i]; i++) - delete e->_shpList[i]; + delete e->_shpList[i]; delete[] e->_shpList; } if (memType(e->_seq) == NEAR_MEM) diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 8fef6307b1..f802916657 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -59,8 +59,12 @@ MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { p1 += w; p2 -= w; } + + _ts = new BMP_PTR[2]; _ts[0] = new Bitmap(w, h, p); + _ts[1] = NULL; setShapeList(_ts); + _flags._slav = true; _flags._tran = true; _flags._kill = true; -- cgit v1.2.3 From 88c7b25e5b0cdf8bb0709f0f7e728f637e72b33c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 17:56:29 +1000 Subject: CGE: Fixed more free/delete[] mismatches identified by Valgrind --- engines/cge/bitmap.cpp | 8 ++++---- engines/cge/cge.cpp | 4 ++-- engines/cge/events.cpp | 2 +- engines/cge/vga13h.cpp | 16 ++++++++++++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 4630f87456..a8264e6c3f 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -151,7 +151,7 @@ Bitmap::~Bitmap() { delete[](uint8 *) _v; break; case FAR_MEM : - free(_v); + delete[] _v; default: warning("Unhandled MemType in Bitmap destructor"); break; @@ -206,7 +206,7 @@ BMP_PTR Bitmap::code() { delete[](uint8 *) _v; break; case FAR_MEM : - free(_v); + delete[] _v; break; default: warning("Unhandled MemType in Bitmap::Code()"); @@ -294,7 +294,7 @@ BMP_PTR Bitmap::code() { break; uint16 sizV = (uint16)(im - 2 - _v); - _v = farnew(uint8, sizV + _h * sizeof(*_b)); + _v = new uint8[sizV + _h * sizeof(*_b)]; if (!_v) error("No core"); @@ -436,7 +436,7 @@ bool Bitmap::loadVBM(XFile *f) { f->seek(f->mark() + PAL_SIZ); } } - if ((_v = farnew(uint8, n)) == NULL) + if ((_v = new uint8[n]) == NULL) return false; if (f->_error == 0) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 2957ba87f1..731f92854e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -136,6 +136,8 @@ CGEEngine::~CGEEngine() { delete _console; // Delete engine objects + delete _vga; + delete _sys; delete _sprite; delete _miniCave; delete _shadow; @@ -153,8 +155,6 @@ CGEEngine::~CGEEngine() { delete _snail; delete _snail_; delete _hero; - delete _vga; - delete _sys; } Common::Error CGEEngine::run() { diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 71110c4067..e12031bb38 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -154,7 +154,7 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) _buttons = 0; _busy = NULL; _active = false; - _flags._kill = true; + _flags._kill = false; setSeq(ms); BMP_PTR *MC = new BMP_PTR[3]; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6e0493695a..73a753b600 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -356,12 +356,14 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) _seqPtr = 0; _shpCnt = 0; _prev = _next = NULL; - +static int ctr = 1; +debug("create %d %x", ctr++, this); setShapeList(shpP); } Sprite::~Sprite() { +debug("destroy %x", this); if (_sprite == this) _sprite = NULL; contract(); @@ -775,7 +777,7 @@ BMP_PTR Sprite::ghost() { error("No core"); bmp->_w = e->_b1->_w; bmp->_h = e->_b1->_h; - if ((bmp->_b = farnew(HideDesc, bmp->_h)) == NULL) + if ((bmp->_b = new HideDesc[bmp->_h]) == NULL) error("No Core"); bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment @@ -903,8 +905,18 @@ void Queue::insert(Sprite *spr) { spr->contract(); } +template +inline bool contains(const Common::List &l, const T &v) { + return (Common::find(l.begin(), l.end(), v) != l.end()); +} +Common::List l; Sprite *Queue::remove(Sprite *spr) { + if (contains(l, spr)) { + debug("N"); + } + l.push_back(spr); + if (spr == _head) _head = spr->_next; if (spr == _tail) -- cgit v1.2.3 From 32c8962d62162e79f5c27fbf2b5bbc843be4ad92 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 17:58:39 +1000 Subject: CGE: Removed some accidentally added debugging statements --- engines/cge/vga13h.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 73a753b600..526faed566 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -356,14 +356,12 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) _seqPtr = 0; _shpCnt = 0; _prev = _next = NULL; -static int ctr = 1; -debug("create %d %x", ctr++, this); + setShapeList(shpP); } Sprite::~Sprite() { -debug("destroy %x", this); if (_sprite == this) _sprite = NULL; contract(); -- cgit v1.2.3 From 66c7777dfedd4ec7a251b4a47e9b581a3e7570d4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 18:17:40 +1000 Subject: CGE: Fix Valgrind identified errors --- engines/cge/vga13h.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 526faed566..9498b04e8c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -362,8 +362,6 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) Sprite::~Sprite() { - if (_sprite == this) - _sprite = NULL; contract(); } @@ -405,6 +403,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { } expand(); _ext->_shpList = shpP; + _flags._bDel = true; if (!_ext->_seq) setSeq((_shpCnt < 2) ? _seq1 : _seq2); } @@ -907,14 +906,8 @@ template inline bool contains(const Common::List &l, const T &v) { return (Common::find(l.begin(), l.end(), v) != l.end()); } -Common::List l; Sprite *Queue::remove(Sprite *spr) { - if (contains(l, spr)) { - debug("N"); - } - l.push_back(spr); - if (spr == _head) _head = spr->_next; if (spr == _tail) -- cgit v1.2.3 From a693ff2ecfa960b25ac33a936ef8b7b6055e68ae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 19:23:14 +1000 Subject: CGE: A few more fixes for memory leaks identified by Valgrind --- engines/cge/cge.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 731f92854e..55b79d5b35 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -78,7 +78,9 @@ void CGEEngine::setup() { _pocket[i] = new Sprite(this, NULL); _sprite = new Sprite(this, NULL); _miniCave = new Sprite(this, NULL); + _miniCave->_flags._kill = false; _shadow = new Sprite(this, NULL); + _shadow->_flags._kill = false; _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, INFO_W); _cavLight = new CavLight(this); @@ -138,7 +140,7 @@ CGEEngine::~CGEEngine() { // Delete engine objects delete _vga; delete _sys; - delete _sprite; + //delete _sprite; Sprite is destroyed by the queue it's added to delete _miniCave; delete _shadow; delete _horzLine; -- cgit v1.2.3 From 9efefdbced8af533e09f7cba703ccbe31dfa6f80 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 20:02:17 +1000 Subject: CGE: Fixed the display of text in the name entry dialog Whilst the 'melting' effect of entered text was very amusing, it did need to be fixed. --- engines/cge/talk.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index b6f276c452..146c720667 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -249,16 +249,14 @@ void Talk::putLine(int line, const char *text) { // set desired line pointer v += (TEXT_VM + (FONT_HIG + TEXT_LS) * line) * lsiz; + p = v; // assume blanked line above text // clear whole rectangle - p = v; // assume blanked line above text - memmove(p, p - lsiz, rsiz); - p += psiz; // tricky replicate lines for plane 0 - memmove(p, p - lsiz, rsiz); - p += psiz; // same for plane 1 - memmove(p, p - lsiz, rsiz); - p += psiz; // same for plane 2 - memmove(p, p - lsiz, rsiz); + assert((rsiz % lsiz) == 0); + for (int planeCtr = 0; planeCtr < 4; ++planeCtr, p += psiz) { + for (byte *pDest = p; pDest < (p + (rsiz - lsiz)); pDest += lsiz) + Common::copy(p - lsiz, p, pDest); + } // paint text line if (text) { -- cgit v1.2.3 From f33ac85e795a0f5abba29bcca365315f3b343310 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 20:07:45 +1000 Subject: CGE: Bugfixes for some crashes --- engines/cge/gettext.cpp | 4 ++++ engines/cge/vga13h.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 2ee6dc42eb..f5c62809db 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -40,8 +40,12 @@ GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) int i = 2 * TEXT_HM + _font->width(info); _ptr = this; _mode = RECT; + + _ts = new BMP_PTR[2]; _ts[0] = box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); + _ts[1] = NULL; setShapeList(_ts); + _flags._bDel = true; _flags._kill = true; memcpy(_buff, text, _len); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9498b04e8c..d92b9e97f0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1402,6 +1402,8 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { LI[4] = NULL; setShapeList(LI); + + _flags._kill = false; } } // End of namespace CGE -- cgit v1.2.3 From 9b5b88274e4d0f76b280133624343f8ce7222937 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 20:13:11 +1000 Subject: CGE: Bugfix for correctly flagging key release --- engines/cge/events.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index e12031bb38..433f7c6db9 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -123,7 +123,7 @@ void Keyboard::newKeyboard(Common::Event &event) { if (event.type == Common::EVENT_KEYUP) { // Key release - _key[event.kbd.keycode] = false; + _key[keycode] = false; } else if (event.type == Common::EVENT_KEYDOWN) { // Key press _key[keycode] = true; -- cgit v1.2.3 From c3a4ba8b053b93a3f759af2a77922a886bba986e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 20:28:22 +1000 Subject: CGE: More fixes for free/delete[] mismatches --- engines/cge/cge_main.cpp | 2 +- engines/cge/game.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index a4d110eac6..68a69ff64e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -214,7 +214,7 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { // Read the data into a data buffer int size = file.size() - file.mark(); - byte *dataBuffer = new byte[size]; + byte *dataBuffer = (byte *)malloc(size); file.read(dataBuffer, size); Common::MemoryReadStream readStream(dataBuffer, size, DisposeAfterUse::YES); Common::Serializer s(&readStream, NULL); diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index f2ebc0b4f8..18c4efbe00 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -31,7 +31,7 @@ namespace CGE { uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b) { - uint8 *x = new uint8[256]; + uint8 *x = (uint8 *)malloc(256); if (x) { uint16 i; for (i = 0; i < 256; i++) { -- cgit v1.2.3 From 10ca53a00c3ae13c520dbf871bb7f6ec65318706 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 21:07:57 +1000 Subject: CGE: Fix cursor to show on-screen once the game starts --- engines/cge/cge_main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 68a69ff64e..4c20f31cac 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1594,8 +1594,7 @@ void CGEEngine::runGame() { _vga->_showQ->append(_pocLight); selectPocket(-1); - // FIXME: Allow ScummVM to handle mouse display -// Vga->ShowQ->Append(Mouse); + _vga->_showQ->append(_mouse); // ___________ loadUser(); -- cgit v1.2.3 From 18077762d738178795c99d38010052b95cb1cef5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jul 2011 20:37:37 +1000 Subject: CGE: Standardised Sprite::seq on always allocating/freeing data --- engines/cge/cge_main.cpp | 5 ++++- engines/cge/events.cpp | 14 ++++++++------ engines/cge/talk.cpp | 7 ++++++- engines/cge/vga13h.cpp | 29 ++++++++++++++++++++++------- engines/cge/vga13h.h | 2 ++ 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4c20f31cac..76d1b7dbcd 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1587,7 +1587,10 @@ void CGEEngine::runGame() { { 1, 6, 0, 0, 4 }, { 0, 1, 0, 0, 16 }, }; - _pocLight->setSeq(pocSeq); + Seq *seq = (Seq *)malloc(7 * sizeof(Seq)); + Common::copy(&pocSeq[0], &pocSeq[7], seq); + _pocLight->setSeq(seq); + _pocLight->_flags._tran = true; _pocLight->_time = 1; _pocLight->_z = 120; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 433f7c6db9..0bf5191530 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -142,11 +142,6 @@ void Keyboard::newKeyboard(Common::Event &event) { /*----------------- MOUSE interface -----------------*/ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) { - static Seq ms[] = { - { 0, 0, 0, 0, 1 }, - { 1, 1, 0, 0, 1 } - }; - _hold = NULL; _hx = 0; _hy = 0; @@ -155,7 +150,14 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) _busy = NULL; _active = false; _flags._kill = false; - setSeq(ms); + + static Seq ms[] = { + { 0, 0, 0, 0, 1 }, + { 1, 1, 0, 0, 1 } + }; + Seq *seq = (Seq *)malloc(2 * sizeof(Seq)); + Common::copy(&ms[0], &ms[2], seq); + setSeq(seq); BMP_PTR *MC = new BMP_PTR[3]; MC[0] = new Bitmap("MOUSE", true); diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 146c720667..152f4a7123 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -310,7 +310,12 @@ void InfoLine::update(const char *tx) { // clear whole rectangle memset(v + 2, TEXT_BG, dsiz); // data bytes - memmove(v + lsiz, v, psiz - lsiz); + + for (byte *pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) + *pDest = 0; +// Common::set_to(pDest, pDest + lsiz, 0); + //Common::copy(v, v + lsiz, pDest); + *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 memmove(v + psiz, v, 3 * psiz); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d92b9e97f0..ff21f5cce8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -60,8 +60,6 @@ static VgaRegBlk VideoMode[] = { }; bool SpeedTest = false; -Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; -Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; extern "C" void SNDMIDIPlay(); @@ -383,6 +381,23 @@ BMP_PTR Sprite::shp() { return NULL; } +Seq *Sprite::getConstantSeq(bool seqFlag) { + Seq seq1[] = { { 0, 0, 0, 0, 0 } }; + Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; + + // Make a copy of the given seq list and return it + Seq *seq; + if (seqFlag) { + seq = (Seq *)malloc(sizeof(Seq)); + seq[0] = seq1[0]; + } else { + seq = (Seq *)malloc(2 * sizeof(Seq)); + seq[0] = seq2[0]; + seq[1] = seq2[1]; + } + + return seq; +} BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; @@ -405,7 +420,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { _ext->_shpList = shpP; _flags._bDel = true; if (!_ext->_seq) - setSeq((_shpCnt < 2) ? _seq1 : _seq2); + setSeq(getConstantSeq(_shpCnt < 2)); } return r; } @@ -590,7 +605,7 @@ Sprite *Sprite::expand() { error("Bad JUMP in SEQ [%s]", fname); setSeq(seq); } else - setSeq((_shpCnt == 1) ? _seq1 : _seq2); + setSeq(getConstantSeq(_shpCnt == 1)); //disable(); // disable interupt setShapeList(shplist); @@ -621,8 +636,8 @@ Sprite *Sprite::contract() { delete e->_shpList[i]; delete[] e->_shpList; } - if (memType(e->_seq) == NEAR_MEM) - free(e->_seq); + free(e->_seq); + if (e->_near) free(e->_near); if (e->_take) @@ -1384,7 +1399,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *SP = new BMP_PTR[2]; + BMP_PTR *SP = new BMP_PTR[3]; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 003be7c800..177165689e 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -166,6 +166,8 @@ public: class Sprite { +private: + Seq *getConstantSeq(bool seqFlag); protected: SprExt *_ext; public: -- cgit v1.2.3 From 9ba5e2b304e6ba7ca9d0b782ad8e5dfd98317b02 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jul 2011 20:56:32 +1000 Subject: CGE: Reverted last commit due to extra memory leaks --- engines/cge/cge_main.cpp | 5 +---- engines/cge/events.cpp | 14 ++++++-------- engines/cge/talk.cpp | 7 +------ engines/cge/vga13h.cpp | 29 +++++++---------------------- engines/cge/vga13h.h | 2 -- 5 files changed, 15 insertions(+), 42 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 76d1b7dbcd..4c20f31cac 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1587,10 +1587,7 @@ void CGEEngine::runGame() { { 1, 6, 0, 0, 4 }, { 0, 1, 0, 0, 16 }, }; - Seq *seq = (Seq *)malloc(7 * sizeof(Seq)); - Common::copy(&pocSeq[0], &pocSeq[7], seq); - _pocLight->setSeq(seq); - + _pocLight->setSeq(pocSeq); _pocLight->_flags._tran = true; _pocLight->_time = 1; _pocLight->_z = 120; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 0bf5191530..433f7c6db9 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -142,6 +142,11 @@ void Keyboard::newKeyboard(Common::Event &event) { /*----------------- MOUSE interface -----------------*/ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) { + static Seq ms[] = { + { 0, 0, 0, 0, 1 }, + { 1, 1, 0, 0, 1 } + }; + _hold = NULL; _hx = 0; _hy = 0; @@ -150,14 +155,7 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) _busy = NULL; _active = false; _flags._kill = false; - - static Seq ms[] = { - { 0, 0, 0, 0, 1 }, - { 1, 1, 0, 0, 1 } - }; - Seq *seq = (Seq *)malloc(2 * sizeof(Seq)); - Common::copy(&ms[0], &ms[2], seq); - setSeq(seq); + setSeq(ms); BMP_PTR *MC = new BMP_PTR[3]; MC[0] = new Bitmap("MOUSE", true); diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 152f4a7123..146c720667 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -310,12 +310,7 @@ void InfoLine::update(const char *tx) { // clear whole rectangle memset(v + 2, TEXT_BG, dsiz); // data bytes - - for (byte *pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) - *pDest = 0; -// Common::set_to(pDest, pDest + lsiz, 0); - //Common::copy(v, v + lsiz, pDest); - + memmove(v + lsiz, v, psiz - lsiz); *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 memmove(v + psiz, v, 3 * psiz); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ff21f5cce8..d92b9e97f0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -60,6 +60,8 @@ static VgaRegBlk VideoMode[] = { }; bool SpeedTest = false; +Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; +Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; extern "C" void SNDMIDIPlay(); @@ -381,23 +383,6 @@ BMP_PTR Sprite::shp() { return NULL; } -Seq *Sprite::getConstantSeq(bool seqFlag) { - Seq seq1[] = { { 0, 0, 0, 0, 0 } }; - Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; - - // Make a copy of the given seq list and return it - Seq *seq; - if (seqFlag) { - seq = (Seq *)malloc(sizeof(Seq)); - seq[0] = seq1[0]; - } else { - seq = (Seq *)malloc(2 * sizeof(Seq)); - seq[0] = seq2[0]; - seq[1] = seq2[1]; - } - - return seq; -} BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; @@ -420,7 +405,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { _ext->_shpList = shpP; _flags._bDel = true; if (!_ext->_seq) - setSeq(getConstantSeq(_shpCnt < 2)); + setSeq((_shpCnt < 2) ? _seq1 : _seq2); } return r; } @@ -605,7 +590,7 @@ Sprite *Sprite::expand() { error("Bad JUMP in SEQ [%s]", fname); setSeq(seq); } else - setSeq(getConstantSeq(_shpCnt == 1)); + setSeq((_shpCnt == 1) ? _seq1 : _seq2); //disable(); // disable interupt setShapeList(shplist); @@ -636,8 +621,8 @@ Sprite *Sprite::contract() { delete e->_shpList[i]; delete[] e->_shpList; } - free(e->_seq); - + if (memType(e->_seq) == NEAR_MEM) + free(e->_seq); if (e->_near) free(e->_near); if (e->_take) @@ -1399,7 +1384,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *SP = new BMP_PTR[3]; + BMP_PTR *SP = new BMP_PTR[2]; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 177165689e..003be7c800 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -166,8 +166,6 @@ public: class Sprite { -private: - Seq *getConstantSeq(bool seqFlag); protected: SprExt *_ext; public: -- cgit v1.2.3 From dab96401ad352512a8ffa8c1d7baeb431ade7b8c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jul 2011 07:24:20 +0200 Subject: CGE: Implement snGhost by splitting _m field in two. Some cleanup. --- engines/cge/bitmap.cpp | 317 +++++++++++++++++++++++-------------------------- engines/cge/bitmap.h | 9 +- engines/cge/general.h | 15 +-- engines/cge/snail.cpp | 5 +- engines/cge/vga13h.cpp | 25 ++-- engines/cge/vga13h.h | 8 -- 6 files changed, 167 insertions(+), 212 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index a8264e6c3f..48bfe1fafb 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -46,7 +46,7 @@ void Bitmap::deinit() { } #pragma argsused -Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { +Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { char pat[MAXPATH]; forceExt(pat, fname, ".VBM"); @@ -78,7 +78,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) { } -Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL) { +Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL), _map(0) { if (map) code(); } @@ -90,7 +90,8 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL) Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) : _w((w + 3) & ~3), // only full uint32 allowed! _h(h), - _m(NULL) { + _m(NULL), + _map(0) { uint16 dsiz = _w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap uint16 psiz = _h * lsiz; // - last gape, but + plane trailer @@ -128,7 +129,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) } -Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL) { +Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), _map(0) { uint8 *v0 = bmp._v; if (v0) { uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); @@ -143,20 +144,9 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL) { Bitmap::~Bitmap() { - if (memType(_m) == FAR_MEM) + if (_m) free(_m); - - switch (memType(_v)) { - case NEAR_MEM : - delete[](uint8 *) _v; - break; - case FAR_MEM : - delete[] _v; - default: - warning("Unhandled MemType in Bitmap destructor"); - break; - break; - } + delete[] _v; } @@ -165,6 +155,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { _w = bmp._w; _h = bmp._h; _m = NULL; + _map = 0; if (memType(_v) == FAR_MEM) free(_v); if (v0 == NULL) @@ -197,128 +188,120 @@ uint16 Bitmap::moveVmap(uint8 *buf) { BMP_PTR Bitmap::code() { - if (_m) { - uint16 i, cnt; - - if (_v) { // old X-map exists, so remove it - switch (memType(_v)) { - case NEAR_MEM : - delete[](uint8 *) _v; - break; - case FAR_MEM : - delete[] _v; - break; - default: - warning("Unhandled MemType in Bitmap::Code()"); - break; - } - _v = NULL; - } + if (!_m) + return false; - while (true) { // at most 2 times: for (V == NULL) & for allocated block; - uint8 *im = _v + 2; - uint16 *cp = (uint16 *) _v; - int bpl; + uint16 i, cnt; - if (_v) { // 2nd pass - fill the hide table - for (i = 0; i < _h; i++) { - _b[i].skip = 0xFFFF; - _b[i].hide = 0x0000; - } + if (_v) { // old X-map exists, so remove it + delete[] _v; + _v = NULL; + } + + while (true) { // at most 2 times: for (V == NULL) & for allocated block; + uint8 *im = _v + 2; + uint16 *cp = (uint16 *) _v; + int bpl; + + if (_v) { // 2nd pass - fill the hide table + for (i = 0; i < _h; i++) { + _b[i].skip = 0xFFFF; + _b[i].hide = 0x0000; } - for (bpl = 0; bpl < 4; bpl++) { // once per each bitplane - uint8 *bm = _m; - bool skip = (bm[bpl] == TRANS); - uint16 j; - - cnt = 0; - for (i = 0; i < _h; i++) { // once per each line - uint8 pix; - for (j = bpl; j < _w; j += 4) { - pix = bm[j]; - if (_v && pix != TRANS) { - if (j < _b[i].skip) - _b[i].skip = j; - - if (j >= _b[i].hide) - _b[i].hide = j + 1; - } - if ((pix == TRANS) != skip || cnt >= 0x3FF0) { // end of block - cnt |= (skip) ? SKP : CPY; - if (_v) - *cp = cnt; // store block description uint16 - - cp = (uint16 *) im; - im += 2; - skip = (pix == TRANS); - cnt = 0; - } - if (! skip) { - if (_v) - *im = pix; - ++ im; - } - ++ cnt; + } + for (bpl = 0; bpl < 4; bpl++) { // once per each bitplane + uint8 *bm = _m; + bool skip = (bm[bpl] == TRANS); + uint16 j; + + cnt = 0; + for (i = 0; i < _h; i++) { // once per each line + uint8 pix; + for (j = bpl; j < _w; j += 4) { + pix = bm[j]; + if (_v && pix != TRANS) { + if (j < _b[i].skip) + _b[i].skip = j; + + if (j >= _b[i].hide) + _b[i].hide = j + 1; } - - bm += _w; - if (_w < SCR_WID) { - if (skip) { - cnt += (SCR_WID - j + 3) / 4; - } else { - cnt |= CPY; - if (_v) - *cp = cnt; - - cp = (uint16 *) im; - im += 2; - skip = true; - cnt = (SCR_WID - j + 3) / 4; - } + if ((pix == TRANS) != skip || cnt >= 0x3FF0) { // end of block + cnt |= (skip) ? SKP : CPY; + if (_v) + *cp = cnt; // store block description uint16 + + cp = (uint16 *) im; + im += 2; + skip = (pix == TRANS); + cnt = 0; } + if (! skip) { + if (_v) + *im = pix; + ++ im; + } + ++ cnt; } - if (cnt && ! skip) { - cnt |= CPY; - if (_v) - *cp = cnt; - cp = (uint16 *) im; - im += 2; + bm += _w; + if (_w < SCR_WID) { + if (skip) { + cnt += (SCR_WID - j + 3) / 4; + } else { + cnt |= CPY; + if (_v) + *cp = cnt; + + cp = (uint16 *) im; + im += 2; + skip = true; + cnt = (SCR_WID - j + 3) / 4; + } } + } + if (cnt && ! skip) { + cnt |= CPY; if (_v) - *cp = EOI; + *cp = cnt; + cp = (uint16 *) im; im += 2; } if (_v) - break; + *cp = EOI; + cp = (uint16 *) im; + im += 2; + } + if (_v) + break; - uint16 sizV = (uint16)(im - 2 - _v); - _v = new uint8[sizV + _h * sizeof(*_b)]; - if (!_v) - error("No core"); + uint16 sizV = (uint16)(im - 2 - _v); + _v = new uint8[sizV + _h * sizeof(*_b)]; + if (!_v) + error("No core"); - _b = (HideDesc *)(_v + sizV); - } - cnt = 0; - for (i = 0; i < _h; i++) { - if (_b[i].skip == 0xFFFF) { // whole line is skipped - _b[i].skip = (cnt + SCR_WID) >> 2; - cnt = 0; - } else { - uint16 s = _b[i].skip & ~3; - uint16 h = (_b[i].hide + 3) & ~3; - _b[i].skip = (cnt + s) >> 2; - _b[i].hide = (h - s) >> 2; - cnt = SCR_WID - h; - } + _b = (HideDesc *)(_v + sizV); + } + cnt = 0; + for (i = 0; i < _h; i++) { + if (_b[i].skip == 0xFFFF) { // whole line is skipped + _b[i].skip = (cnt + SCR_WID) >> 2; + cnt = 0; + } else { + uint16 s = _b[i].skip & ~3; + uint16 h = (_b[i].hide + 3) & ~3; + _b[i].skip = (cnt + s) >> 2; + _b[i].hide = (h - s) >> 2; + cnt = SCR_WID - h; } } + return this; } -bool Bitmap::solidAt(int x, int y) { +bool Bitmap::solidAt(int16 x, int16 y) { uint8 *m; uint16 r, n, n0; @@ -447,58 +430,58 @@ bool Bitmap::loadVBM(XFile *f) { } bool Bitmap::loadBMP(XFile *f) { - struct { - char BM[2]; - union { int16 len; int32 len_; }; - union { int16 _06; int32 _06_; }; - union { int16 hdr; int32 hdr_; }; - union { int16 _0E; int32 _0E_; }; - union { int16 wid; int32 wid_; }; - union { int16 hig; int32 hig_; }; - union { int16 _1A; int32 _1A_; }; - union { int16 _1E; int32 _1E_; }; - union { int16 _22; int32 _22_; }; - union { int16 _26; int32 _26_; }; - union { int16 _2A; int32 _2A_; }; - union { int16 _2E; int32 _2E_; }; - union { int16 _32; int32 _32_; }; - } hea; - - Bgr4 bpal[256]; - - f->read((byte *)&hea, sizeof(hea)); - if (f->_error == 0) { - if (hea.hdr == 0x436L) { - int16 i = (hea.hdr - sizeof(hea)) / sizeof(Bgr4); - f->read((byte *)&bpal, sizeof(bpal)); - if (f->_error == 0) { - if (_pal) { - for (i = 0; i < 256; i ++) { - _pal[i]._r = bpal[i]._R; - _pal[i]._g = bpal[i]._G; - _pal[i]._b = bpal[i]._B; + struct { + char BM[2]; + union { int16 len; int32 len_; }; + union { int16 _06; int32 _06_; }; + union { int16 hdr; int32 hdr_; }; + union { int16 _0E; int32 _0E_; }; + union { int16 wid; int32 wid_; }; + union { int16 hig; int32 hig_; }; + union { int16 _1A; int32 _1A_; }; + union { int16 _1E; int32 _1E_; }; + union { int16 _22; int32 _22_; }; + union { int16 _26; int32 _26_; }; + union { int16 _2A; int32 _2A_; }; + union { int16 _2E; int32 _2E_; }; + union { int16 _32; int32 _32_; }; + } hea; + + Bgr4 bpal[256]; + + f->read((byte *)&hea, sizeof(hea)); + if (f->_error == 0) { + if (hea.hdr == 0x436L) { + int16 i = (hea.hdr - sizeof(hea)) / sizeof(Bgr4); + f->read((byte *)&bpal, sizeof(bpal)); + if (f->_error == 0) { + if (_pal) { + for (i = 0; i < 256; i ++) { + _pal[i]._r = bpal[i]._R; + _pal[i]._g = bpal[i]._G; + _pal[i]._b = bpal[i]._B; + } + _pal = NULL; + } + _h = hea.hig; + _w = hea.wid; + if ((_m = farnew(byte, _h * _w)) != NULL) { + int16 r = (4 - (hea.wid & 3)) % 4; + byte buf[3]; + for (i = _h - 1; i >= 0; i--) { + f->read(_m + (_w * i), _w); + if (r && f->_error == 0) + f->read(buf, r); + if (f->_error) + break; + } + if (i < 0) + return true; + } } - _pal = NULL; - } - _h = hea.hig; - _w = hea.wid; - if ((_m = farnew(byte, _h * _w)) != NULL) { - int16 r = (4 - (hea.wid & 3)) % 4; - byte buf[3]; - for (i = _h - 1; i >= 0; i--) { - f->read(_m + (_w * i), _w); - if (r && f->_error == 0) - f->read(buf, r); - if (f->_error) - break; - } - if (i < 0) - return true; } - } } - } - return false; + return false; } } // End of namespace CGE diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 4c2b67b8df..3fdb673396 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -68,6 +68,7 @@ public: uint16 _h; uint8 *_m; uint8 *_v; + int32 _map; HideDesc *_b; Bitmap(const char *fname, bool rem); @@ -81,10 +82,10 @@ public: Bitmap *flipH(); Bitmap *code(); Bitmap &operator = (const Bitmap &bmp); - void hide(int x, int y); - void show(int x, int y); - void xShow(int x, int y); - bool solidAt(int x, int y); + void hide(int16 x, int16 y); + void show(int16 x, int16 y); + void xShow(int16 x, int16 y); + bool solidAt(int16 x, int16 y); bool saveVBM(XFile *f); uint16 moveVmap(uint8 *buf); }; diff --git a/engines/cge/general.h b/engines/cge/general.h index 7cf3ec3e41..2eebc01c62 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -39,22 +39,13 @@ namespace CGE { #define SEED 0xA5 -#define SCR_WID_ 320 -#define SCR_HIG_ 200 -#define SCR_WID ((uint16)SCR_WID_) -#define SCR_HIG ((uint16)SCR_HIG_) -#define SCR_SEG 0xA000 -#define SCR_ADR ((uint8 *) MK_FP(SCR_SEG, 0)) - - - -//enum CPU { _8086, _80186, _80286, _80386, _80486 }; enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM }; -enum ALLOC_MODE { FIRST_FIT, BEST_FIT, LAST_FIT }; enum IOMODE { REA, WRI, UPD }; struct Dac { - uint8 _r, _g, _b; + uint8 _r; + uint8 _g; + uint8 _b; }; typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 242fb067e7..bc9d212468 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -309,11 +309,10 @@ void CGEEngine::hide1(Sprite *spr) { } void CGEEngine::snGhost(Bitmap *bmp) { - // TODO : Get x and y from M but not using segment / offset - //bmp->Hide(FP_OFF(bmp->_m), FP_SEG(bmp->_m)); + bmp->hide(bmp->_map & 0xFFFF, bmp->_map >> 16); bmp->_m = NULL; + bmp->_map = 0; delete bmp; - warning("STUB: SNGhost"); } void CGEEngine::feedSnail(Sprite *spr, SNLIST snq) { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d92b9e97f0..e85e13d20c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -683,18 +683,9 @@ void Sprite::killXlat() { if (_flags._xlat && _ext) { BMP_PTR *b; uint8 *m = (*_ext->_shpList)->_m; - - switch (memType(m)) { - case NEAR_MEM : - delete[](uint8 *) m; - break; - case FAR_MEM : + if (m) free(m); - break; - default: - warning("Unhandled MemType in Sprite::KillXlat()"); - break; - } + for (b = _ext->_shpList; *b; b++) (*b)->_m = NULL; _flags._xlat = false; @@ -777,9 +768,7 @@ BMP_PTR Sprite::ghost() { if ((bmp->_b = new HideDesc[bmp->_h]) == NULL) error("No Core"); bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); - // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment - //bmp->_m = (uint8 *) MK_FP(e->y1, e->x1); - warning("FIXME: SPRITE::Ghost"); + bmp->_map = (e->_y1 << 16) + e->_x1; return bmp; } return NULL; @@ -1209,7 +1198,7 @@ void Vga::copyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- -void Bitmap::xShow(int x, int y) { +void Bitmap::xShow(int16 x, int16 y) { /* uint8 rmsk = x % 4, mask = 1 << rmsk, @@ -1291,7 +1280,7 @@ void Bitmap::xShow(int x, int y) { } -void Bitmap::show(int x, int y) { +void Bitmap::show(int16 x, int16 y) { const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1353,8 +1342,8 @@ void Bitmap::show(int x, int y) { } -void Bitmap::hide(int x, int y) { - for (int yp = y; yp < y + _h; ++yp) { +void Bitmap::hide(int16 x, int16 y) { + for (int yp = y; yp < y + _h; yp++) { const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 003be7c800..e29fa2eea4 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -57,19 +57,11 @@ namespace CGE { #endif -#if 0 -#define LIGHT 0xFF -#define DARK 0x00 -#define DGRAY 0xF6 -#define GRAY 0xFC -#define LGRAY 0xFF -#else #define LIGHT 0xFF #define DARK 207 #define DGRAY 225 /*219*/ #define GRAY 231 #define LGRAY 237 -#endif #define NO_SEQ (-1) #define NO_PTR ((uint8)-1) -- cgit v1.2.3 From a524adcaee89678ba99b294fcbc5efdf9e137c04 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jul 2011 08:02:18 +0200 Subject: CGE: Suppress isVga() and memType() --- engines/cge/bitmap.cpp | 9 +++---- engines/cge/cfile.cpp | 3 +-- engines/cge/general.cpp | 23 ----------------- engines/cge/general.h | 9 ------- engines/cge/snail.cpp | 5 ++-- engines/cge/vga13h.cpp | 65 +++++++++++++++++++++---------------------------- 6 files changed, 34 insertions(+), 80 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 48bfe1fafb..8474924366 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -144,8 +144,7 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), Bitmap::~Bitmap() { - if (_m) - free(_m); + free(_m); delete[] _v; } @@ -156,8 +155,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { _h = bmp._h; _m = NULL; _map = 0; - if (memType(_v) == FAR_MEM) - free(_v); + free(_v); if (v0 == NULL) _v = NULL; else { @@ -178,8 +176,7 @@ uint16 Bitmap::moveVmap(uint8 *buf) { uint16 vsiz = (uint8 *)_b - (uint8 *)_v; uint16 siz = vsiz + _h * sizeof(HideDesc); memcpy(buf, _v, siz); - if (memType(_v) == FAR_MEM) - free(_v); + free(_v); _b = (HideDesc *)((_v = buf) + vsiz); return siz; } diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index b235d552b2..f0a0ef3b8f 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -54,8 +54,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) IoBuf::~IoBuf() { if (_mode > REA) writeBuff(); - if (_buff) - free(_buff); + free(_buff); } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 6ed6884aba..f17ebf799c 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -267,29 +267,6 @@ bool IoHand::exist(const char *name) { return f.exists(name); } -//#define EMS_ADR(a) (FP_SEG(a) > 0xA000) -//#define HNODE_OK(p) (heapchecknode(p)==4) - -MEM_TYPE memType(void *mem) { - /* if (FP_SEG(mem) == _DS) { - if (heapchecknode((void *)mem)==4) - return NEAR_MEM; - } else { - if (FP_SEG(mem) > 0xA000) - return EMS_MEM; - else if (farheapchecknode(mem)==4) - return FAR_MEM; - } - return BAD_MEM; - */ - warning("STUB: memType"); - return FAR_MEM; -} - -bool isVga() { - return true; -} - void sndInit() { warning("STUB: SNDInit"); } diff --git a/engines/cge/general.h b/engines/cge/general.h index 2eebc01c62..a3cc12080d 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -39,7 +39,6 @@ namespace CGE { #define SEED 0xA5 -enum MEM_TYPE { BAD_MEM, EMS_MEM, NEAR_MEM, FAR_MEM }; enum IOMODE { REA, WRI, UPD }; struct Dac { @@ -140,8 +139,6 @@ void swap(T &A, T &B) { B = a; } - -#ifdef __cplusplus template T max(T A, T B) { return (A > B) ? A : B; @@ -151,8 +148,6 @@ template T min(T A, T B) { return (A < B) ? A : B; } -#endif - class XFile { public: @@ -195,10 +190,8 @@ public: // void SetTime (timeb t); }; - CRYPT XCrypt; CRYPT RCrypt; -MEM_TYPE memType(void *mem); uint16 atow(const char *a); uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); @@ -209,8 +202,6 @@ long timer(); char *mergeExt(char *buf, const char *nam, const char *ext); char *forceExt(char *buf, const char *nam, const char *ext); int driveCD(unsigned drv); -bool isVga(); - // MISSING FUNCTIONS void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index bc9d212468..a568110de7 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -381,7 +381,7 @@ void CGEEngine::feedSnail(Sprite *spr, SNLIST snq) { if (c->_ptr) break; else - ++c; + c++; } } } @@ -410,8 +410,7 @@ Snail::Snail(CGEEngine *vm, bool turbo) } Snail::~Snail() { - if (_snList) - free(_snList); + free(_snList); } void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e85e13d20c..4d8b5bf628 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -621,12 +621,9 @@ Sprite *Sprite::contract() { delete e->_shpList[i]; delete[] e->_shpList; } - if (memType(e->_seq) == NEAR_MEM) - free(e->_seq); - if (e->_near) - free(e->_near); - if (e->_take) - free(e->_take); +// free(e->_seq); + free(e->_near); + free(e->_take); delete e; _ext = NULL; } @@ -683,8 +680,7 @@ void Sprite::killXlat() { if (_flags._xlat && _ext) { BMP_PTR *b; uint8 *m = (*_ext->_shpList)->_m; - if (m) - free(m); + free(m); for (b = _ext->_shpList; *b; b++) (*b)->_m = NULL; @@ -967,42 +963,37 @@ Vga::Vga(int mode) setStatAdr(); if (_statAdr != VGAST1_) _mono++; - if (isVga()) { - _oldColors = farnew(Dac, 256); - _newColors = farnew(Dac, 256); - _oldScreen = SaveScreen(); - getColors(_oldColors); - sunset(); - _oldMode = setMode(mode); - setColors(); - setup(VideoMode); - clear(0); - } + _oldColors = farnew(Dac, 256); + _newColors = farnew(Dac, 256); + _oldScreen = SaveScreen(); + getColors(_oldColors); + sunset(); + _oldMode = setMode(mode); + setColors(); + setup(VideoMode); + clear(0); } Vga::~Vga() { _mono = 0; - if (isVga()) { - Common::String buffer = ""; + + Common::String buffer = ""; /* - clear(0); - setMode(_oldMode); - setColors(); - restoreScreen(_oldScreen); - sunrise(_oldColors); + clear(0); + setMode(_oldMode); + setColors(); + restoreScreen(_oldScreen); + sunrise(_oldColors); */ - if (_oldColors) - free(_oldColors); - if (_newColors) - free(_newColors); - if (_msg) - buffer = Common::String(_msg); - if (_nam) - buffer = buffer + " [" + _nam + "]"; - - debugN("%s", buffer.c_str()); - } + free(_oldColors); + free(_newColors); + if (_msg) + buffer = Common::String(_msg); + if (_nam) + buffer = buffer + " [" + _nam + "]"; + + debugN("%s", buffer.c_str()); delete _showQ; delete _spareQ; -- cgit v1.2.3 From daae033e0156f19b3bdbb46aa7b0785c40f1e094 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 21:16:23 +1000 Subject: CGE: Converted SprExt::_Seq to use dynamically allocated data --- engines/cge/cge_main.cpp | 7 +++++-- engines/cge/events.cpp | 14 ++++++++------ engines/cge/mixer.cpp | 12 +++++++++--- engines/cge/mixer.h | 1 - engines/cge/vga13h.cpp | 28 +++++++++++++++++++++++----- 5 files changed, 45 insertions(+), 17 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4c20f31cac..d35a985d89 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1579,7 +1579,7 @@ void CGEEngine::runGame() { _vga->_showQ->append(_cavLight); _cavLight->_flags._hide = true; - static Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, + const Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, { 1, 2, 0, 0, 4 }, { 2, 3, 0, 0, 4 }, { 3, 4, 0, 0, 16 }, @@ -1587,7 +1587,10 @@ void CGEEngine::runGame() { { 1, 6, 0, 0, 4 }, { 0, 1, 0, 0, 16 }, }; - _pocLight->setSeq(pocSeq); + Seq *seq = (Seq *)malloc(7 * sizeof(Seq)); + Common::copy(pocSeq, pocSeq + 7, seq); + _pocLight->setSeq(seq); + _pocLight->_flags._tran = true; _pocLight->_time = 1; _pocLight->_z = 120; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 433f7c6db9..9c1741189f 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -142,11 +142,6 @@ void Keyboard::newKeyboard(Common::Event &event) { /*----------------- MOUSE interface -----------------*/ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) { - static Seq ms[] = { - { 0, 0, 0, 0, 1 }, - { 1, 1, 0, 0, 1 } - }; - _hold = NULL; _hx = 0; _hy = 0; @@ -155,7 +150,14 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) _busy = NULL; _active = false; _flags._kill = false; - setSeq(ms); + + const Seq ms[] = { + { 0, 0, 0, 0, 1 }, + { 1, 1, 0, 0, 1 } + }; + Seq *seq = (Seq *)malloc(2 * sizeof(Seq)); + Common::copy(ms, ms + 2, seq); + setSeq(seq); BMP_PTR *MC = new BMP_PTR[3]; MC[0] = new Bitmap("MOUSE", true); diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index aea033ebc9..0e3a613e60 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -54,18 +54,24 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _ // slaves uint i; + Seq ls[MIX_MAX]; + for (i = 0; i < MIX_MAX; i++) { static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); _lb[i] = new Bitmap(fn, true); - _ls[i]._now = _ls[i]._next = i; - _ls[i]._dx = _ls[i]._dy = _ls[i]._dly = 0; + ls[i]._now = ls[i]._next = i; + ls[i]._dx = ls[i]._dy = ls[i]._dly = 0; } _lb[i] = NULL; for (i = 0; i < ArrayCount(_led); i++) { register Sprite *spr = new Sprite(_vm, _lb); - spr->setSeq(_ls); + + Seq *seq = (Seq *)malloc(MIX_MAX * sizeof(Seq)); + Common::copy(ls, ls + MIX_MAX, seq); + spr->setSeq(seq); + spr->gotoxy(x + 2 + 12 * i, y + 8); spr->_flags._tran = true; spr->_flags._kill = true; diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index 8ded075514..ef53eec070 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -42,7 +42,6 @@ namespace CGE { class Mixer : public Sprite { BMP_PTR _mb[2]; BMP_PTR _lb[MIX_MAX + 1]; - Seq _ls[MIX_MAX]; Sprite *_led[2]; int _fall; void update(); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 4d8b5bf628..2cdca0004f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -60,8 +60,24 @@ static VgaRegBlk VideoMode[] = { }; bool SpeedTest = false; -Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; -Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; + +Seq *getConstantSeq(bool seqFlag) { + const Seq seq1[] = { { 0, 0, 0, 0, 0 } }; + const Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; + + Seq *seq; + if (seqFlag) { + seq = (Seq *)malloc(1 * sizeof(Seq)); + *seq = seq1[0]; + } else { + seq = (Seq *)malloc(2 * sizeof(Seq)); + seq[0] = seq2[0]; + seq[1] = seq2[1]; + } + + return seq; +} + extern "C" void SNDMIDIPlay(); @@ -405,7 +421,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { _ext->_shpList = shpP; _flags._bDel = true; if (!_ext->_seq) - setSeq((_shpCnt < 2) ? _seq1 : _seq2); + setSeq(getConstantSeq(_shpCnt < 2)); } return r; } @@ -590,7 +606,7 @@ Sprite *Sprite::expand() { error("Bad JUMP in SEQ [%s]", fname); setSeq(seq); } else - setSeq((_shpCnt == 1) ? _seq1 : _seq2); + setSeq(getConstantSeq(_shpCnt == 1)); //disable(); // disable interupt setShapeList(shplist); @@ -621,9 +637,11 @@ Sprite *Sprite::contract() { delete e->_shpList[i]; delete[] e->_shpList; } -// free(e->_seq); + + free(e->_seq); free(e->_near); free(e->_take); + delete e; _ext = NULL; } -- cgit v1.2.3 From b6be90326d31030ac364edeb8538aecaef51e378 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 21:41:11 +1000 Subject: CGE: Fixed a memory leak with Sprite::setSeq --- engines/cge/vga13h.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 2cdca0004f..96642b4540 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -451,6 +451,11 @@ bool Sprite::works(Sprite *spr) { Seq *Sprite::setSeq(Seq *seq) { + if (_ext) { + free(_ext->_seq); + _ext->_seq = NULL; + } + expand(); register Seq *s = _ext->_seq; _ext->_seq = seq; -- cgit v1.2.3 From 891032053a19f0962771f4374cd79ee66f2f9b0f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 21:43:53 +1000 Subject: CGE: Removed redundant disable/enable calls --- engines/cge/snail.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index a568110de7..2fe2d22d5b 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -35,14 +35,6 @@ namespace CGE { -static void _enable() { - warning("STUB: _enable"); -} - -static void _disable() { - warning("STUB: _disable"); -} - extern Sprite *_pocLight; //------------------------------------------------------------------------- @@ -414,7 +406,6 @@ Snail::~Snail() { } void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { - _disable(); Com *snc = &_snList[_head++]; snc->_com = com; snc->_ref = ref; @@ -425,13 +416,11 @@ void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { killText(); _timerExpiry = 0; } - _enable(); } void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { Com *snc; - _disable(); if (_busy) { _snList[(_tail - 1) & 0xFF] = _snList[_tail]; snc = &_snList[_tail]; @@ -447,7 +436,6 @@ void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { killText(); _timerExpiry = 0; } - _enable(); } void CGEEngine::snNNext(Sprite *sprel, int p) { -- cgit v1.2.3 From e2b19ad9b0bc3e2a437eaab3aaa62302e0e892d3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 21:53:07 +1000 Subject: CGE: Fixed several memory leaks of main objects --- engines/cge/cge.cpp | 4 +++- engines/cge/cge_main.cpp | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 55b79d5b35..884af2cd46 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -74,8 +74,10 @@ void CGEEngine::setup() { _heart = new Heart; _sys = new System(this); _pocLight = new PocLight(this); - for (int i = 0; i < POCKET_NX; i++) + for (int i = 0; i < POCKET_NX; i++) { _pocket[i] = new Sprite(this, NULL); + _pocket[i]->_flags._kill = false; + } _sprite = new Sprite(this, NULL); _miniCave = new Sprite(this, NULL); _miniCave->_flags._kill = false; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index d35a985d89..6f741f1598 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1631,6 +1631,7 @@ void CGEEngine::runGame() { _hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); if (INI_FILE::exist("00SHADOW.SPR")) { loadSprite("00SHADOW", -1, 0, _hero->_x + 14, _hero->_y + 51); + delete _shadow; if ((_shadow = _sprite) != NULL) { _shadow->_ref = 2; _shadow->_flags._tran = true; @@ -1850,9 +1851,6 @@ void CGEEngine::cge_main() { _debugLine->_flags._hide = true; _horzLine->_flags._hide = true; - //srand((uint16) Timer()); - _sys = new System(this); - if (_music && Startup::_soundOk) loadMidi(0); if (Startup::_mode < 2) -- cgit v1.2.3 From 11c9e64885faed3c3d7ba5888e3f129548f789e8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 22:02:00 +1000 Subject: CGE: More bugfixes for memory leaks --- engines/cge/cge_main.cpp | 1 + engines/cge/vga13h.cpp | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6f741f1598..ed5ee8eeb1 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -247,6 +247,7 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { for (i = 0; i < POCKET_NX; i++) { register int r = _pocref[i]; + delete _pocket[i]; _pocket[i] = (r < 0) ? NULL : _vga->_spareQ->locate(r); } } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 96642b4540..5bdb50fa9e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -612,10 +612,9 @@ Sprite *Sprite::expand() { setSeq(seq); } else setSeq(getConstantSeq(_shpCnt == 1)); - //disable(); // disable interupt setShapeList(shplist); - //enable(); // enable interupt + if (nea) nea[neacnt - 1]._ptr = _ext->_near = nea; else -- cgit v1.2.3 From 700dbe021ed98939d52649c4961744f2172a1986 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 22:43:24 +1000 Subject: CGE: Fix ProgName method to handle extensions without a leading period --- engines/cge/general.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index f17ebf799c..4ca1ef57ca 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -102,8 +102,12 @@ void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, c const char *progName(const char *ext) { static char buf[MAXFILE]; strcpy(buf, "CGE"); - if (ext) + if (ext) { + strcat(buf, "."); + if (*ext == '.') + ++ext; strcat(buf, ext); + } return buf; } -- cgit v1.2.3 From 4d96ec70340b5f3dbf875ed3a3f6832faffd796c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 22:44:04 +1000 Subject: CGE: Fixed a previously commented adding of mouse object to show queue --- engines/cge/cge_main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index ed5ee8eeb1..05e936e4e5 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1696,8 +1696,7 @@ void CGEEngine::movie(const char *ext) { expandSprite(_vga->_spareQ->locate(999)); feedSnail(_vga->_showQ->locate(999), TAKE); - // FIXME: Allow ScummVM to handle mouse display - //Vga->ShowQ->Append(Mouse); + _vga->_showQ->append(_mouse); _heart->_enable = true; _keyboard->setClient(_sys); -- cgit v1.2.3 From 5148f80fa5077e2bdffba44dabac793c9cbe4666 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 Jul 2011 00:28:17 +0200 Subject: CGE: add a new SNPOST to fix the function pointer issue --- engines/cge/cge.h | 2 ++ engines/cge/cge_main.cpp | 30 +++++++++++------------------- engines/cge/config.cpp | 4 +--- engines/cge/general.h | 2 +- engines/cge/mixer.cpp | 4 +--- engines/cge/snail.cpp | 41 ++++++++++++++++++++++++++++++++++++----- engines/cge/snail.h | 4 ++++ engines/cge/startup.h | 1 - 8 files changed, 56 insertions(+), 32 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 29a7a11b9d..644e06e7e7 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -46,6 +46,7 @@ enum { }; enum SNLIST { NEAR, TAKE }; +enum CALLBACK { NULLCB = 0, QGAME, MINISTEP, XCAVE, SELECTSOUND, SNSELECT, SNDSETVOLUME }; #define POCKET_NX 8 @@ -145,6 +146,7 @@ public: void sayDebug(); void nextStep(); void switchDebug(); + void miniStep(int stp); void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 05e936e4e5..f2aca3ed8b 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -584,8 +584,7 @@ static void AltCtrlDel() { SNPOST_(SNSAY, -1, A_C_D_TEXT, _hero); } -// Used in stubbed function, do not remove! -static void miniStep(int stp) { +void CGEEngine::miniStep(int stp) { if (stp < 0) _miniCave->_flags._hide = true; else { @@ -600,10 +599,9 @@ static void miniStep(int stp) { static void postMiniStep(int stp) { - //static int recent = -2; - //TODO Change the SNPOST message send to a special way to send function pointer - //if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep); - warning("STUB: PostMiniStep()"); + static int recent = -2; + if (_miniCave && stp != recent) + SNPOST2_(SNEXEC, -1, recent = stp, MINISTEP); } void System::setPal() { @@ -744,9 +742,7 @@ void CGEEngine::switchCave(int cav) { _heart->_enable = false; if (cav < 0) { SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST(SNEXEC, -1, 0, (void *)&QGame); // switch cave - warning("SwitchCave() - SNPOST"); + SNPOST2(SNEXEC, -1, 0, QGAME); // switch cave } else { _now = cav; _mouse->off(); @@ -764,9 +760,7 @@ void CGEEngine::switchCave(int cav) { if (!_startupMode) keyClick(); SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave - warning("SwitchCave() - SNPOST"); + SNPOST2(SNEXEC, 0, 0, XCAVE); // switch cave } } } @@ -997,9 +991,7 @@ void CGEEngine::switchMusic() { SNPOST_(SNKILL, -1, 0, Vmenu::_addr); else { SNPOST_(SNSEQ, 122, (_music = false), NULL); - //TODO Change the SNPOST message send to a special way to send function pointer - // SNPOST(SNEXEC, -1, 0, (void *)&selectSound); - warning("SwitchMusic() - SNPOST"); + SNPOST2(SNEXEC, -1, 0, SELECTSOUND); } } else { if (Startup::_core < CORE_HIG) @@ -1580,7 +1572,8 @@ void CGEEngine::runGame() { _vga->_showQ->append(_cavLight); _cavLight->_flags._hide = true; - const Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, + const Seq pocSeq[] = { + { 0, 0, 0, 0, 20 }, { 1, 2, 0, 0, 4 }, { 2, 3, 0, 0, 4 }, { 3, 4, 0, 0, 16 }, @@ -1668,9 +1661,8 @@ void CGEEngine::runGame() { _keyboard->setClient(_sys); // main loop while (!_finis && !_eventManager->_quitFlag) { - //TODO Change the SNPOST message send to a special way to send function pointer - // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame); - warning("RunGame: problematic use of SNPOST"); + if (_finis) + SNPOST2(SNEXEC, -1, 0, QGAME); mainLoop(); } diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 808d74ff9b..0152961982 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -192,9 +192,7 @@ void CGEEngine::snSelect() { static void select(Choice *cho, int hlp) { _cho = cho; _hlp = hlp; - //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect); - warning("STUB: select"); + SNPOST2(SNEXEC, -1, 0, SNSELECT); } diff --git a/engines/cge/general.h b/engines/cge/general.h index a3cc12080d..b4f73726ee 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -112,7 +112,7 @@ class Emm { int _han; static void *_frame; public: - Emm(long size = 0); + Emm(long size); ~Emm(); Ems *alloc(uint16 siz); void release(); diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 0e3a613e60..8b11dbcc4c 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -142,9 +142,7 @@ void Mixer::update() { _led[0]->step(_sndDrvInfo.Vol4._ml); _led[1]->step(_sndDrvInfo.Vol4._dl); - //TODO Change the SNPOST message send to a special way to send function pointer - //SNPOST_(SNEXEC, -1, 0, (void*)&sndSetVolume); - warning("STUB: Mixer::Update"); + SNPOST2_(SNEXEC, -1, 0, SNDSETVOLUME); } } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 2fe2d22d5b..23a182cbd5 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -411,6 +411,21 @@ void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { snc->_ref = ref; snc->_val = val; snc->_ptr = ptr; + snc->_cbType = NULLCB; + if (com == SNCLEAR) { + _tail = _head; + killText(); + _timerExpiry = 0; + } +} + +void Snail::addCom2(SNCOM com, int ref, int val, CALLBACK cbType) { + Com *snc = &_snList[_head++]; + snc->_com = com; + snc->_ref = ref; + snc->_val = val; + snc->_ptr = NULL; + snc->_cbType = cbType; if (com == SNCLEAR) { _tail = _head; killText(); @@ -913,8 +928,7 @@ void Snail::runCom() { } break; case SNCAVE : - // SwitchCave(snc->_val); - warning("Problematic call of SwitchCave in SNAIL::runCom"); + _vm->switchCave(snc->_val); break; case SNKILL : _vm->snKill(sprel); @@ -1042,9 +1056,26 @@ void Snail::runCom() { count = snc->_val; break; case SNEXEC : - // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST - // ((void(*)(int)) (snc->_ptr))(snc->_val); - warning("STUB: SNEXEC code"); + switch (snc->_cbType) { + case QGAME: + _vm->qGame(); + break; + case MINISTEP: + _vm->miniStep(snc->_val); + break; + case XCAVE: + _vm->xCave(); + break; + case SELECTSOUND: + _vm->selectSound(); + break; + case SNSELECT: + _vm->snSelect(); + break; + case SNDSETVOLUME: + sndSetVolume(); + break; + } break; case SNSTEP : sprel->step(); diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 888fae6ce9..48e5900248 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -44,7 +44,9 @@ namespace CGE { #define SNINSERT(c, r, v, p) _snail->insCom(c, r, v, p) #define SNPOST(c, r, v, p) _snail->addCom(c, r, v, p) +#define SNPOST2(c, r, v, p) _snail->addCom2(c, r, v, p) #define SNPOST_(c, r, v, p) _snail_->addCom(c, r, v, p) +#define SNPOST2_(c, r, v, p) _snail_->addCom2(c, r, v, p) #define SNAIL_FRAME_RATE 62 #define SNAIL_FRAME_DELAY (1000 / SNAIL_FRAME_RATE) @@ -77,6 +79,7 @@ public: int _ref; int _val; void *_ptr; + CALLBACK _cbType; } *_snList; uint8 _head; uint8 _tail; @@ -90,6 +93,7 @@ public: ~Snail(); void runCom(); void addCom(SNCOM com, int ref, int val, void *ptr); + void addCom2(SNCOM com, int ref, int val, CALLBACK cbType); void insCom(SNCOM com, int ref, int val, void *ptr); bool idle(); private: diff --git a/engines/cge/startup.h b/engines/cge/startup.h index cc16f2a123..5479945104 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -56,7 +56,6 @@ namespace CGE { #endif #define CORE_MID (CORE_HIG - 20) -#define CORE_LOW (CORE_MID - 20) class Startup { -- cgit v1.2.3 From 4d0f83babb923527c67157204ba0b8b678b6732a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 Jul 2011 08:44:58 +0200 Subject: CGE: Rename some constants --- engines/cge/cge.h | 12 +++++++++--- engines/cge/cge_main.cpp | 24 ++++++++++++------------ engines/cge/config.cpp | 2 +- engines/cge/mixer.cpp | 2 +- engines/cge/snail.cpp | 26 ++++++++++++++------------ engines/cge/snail.h | 4 ++-- engines/cge/vga13h.cpp | 4 ++-- engines/cge/vga13h.h | 2 +- 8 files changed, 42 insertions(+), 34 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 644e06e7e7..7dd218e258 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -45,8 +45,14 @@ enum { kCGEDebug = 1 << 0 }; -enum SNLIST { NEAR, TAKE }; -enum CALLBACK { NULLCB = 0, QGAME, MINISTEP, XCAVE, SELECTSOUND, SNSELECT, SNDSETVOLUME }; +enum SnList { + kNear, kTake +}; + +enum CallbackType { + kNullCB = 0, kQGame, kMiniStep, kXCave, kSelectSound, + kSnSelect, kSndSetVolume +}; #define POCKET_NX 8 @@ -126,7 +132,7 @@ public: void expandSprite(Sprite *spr); void contractSprite(Sprite *spr); int findPocket(Sprite *spr); - void feedSnail(Sprite *spr, SNLIST snq); + void feedSnail(Sprite *spr, SnList snq); void pocFul(); void hide1(Sprite *spr); void loadMapping(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index f2aca3ed8b..16e21e1f73 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -355,7 +355,7 @@ void WALK::tick() { for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (distance(spr) < 2) { if (!spr->_flags._near) { - _vm->feedSnail(spr, NEAR); + _vm->feedSnail(spr, kNear); spr->_flags._near = true; } } else { @@ -601,7 +601,7 @@ void CGEEngine::miniStep(int stp) { static void postMiniStep(int stp) { static int recent = -2; if (_miniCave && stp != recent) - SNPOST2_(SNEXEC, -1, recent = stp, MINISTEP); + SNPOST2_(SNEXEC, -1, recent = stp, kMiniStep); } void System::setPal() { @@ -685,7 +685,7 @@ void CGEEngine::caveUp() { _vga->_showQ->insert(_shadow, _hero); _shadow->_z = _hero->_z; } - feedSnail(_vga->_showQ->locate(BakRef + 999), TAKE); + feedSnail(_vga->_showQ->locate(BakRef + 999), kTake); _vga->show(); _vga->copyPage(1, 0); _vga->show(); @@ -707,7 +707,7 @@ void CGEEngine::caveDown() { Sprite *n = spr->_next; if (spr->_ref >= 1000 /*&& spr->_cave*/) { if (spr->_ref % 1000 == 999) - feedSnail(spr, TAKE); + feedSnail(spr, kTake); _vga->_spareQ->append(_vga->_showQ->remove(spr)); } spr = n; @@ -742,7 +742,7 @@ void CGEEngine::switchCave(int cav) { _heart->_enable = false; if (cav < 0) { SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - SNPOST2(SNEXEC, -1, 0, QGAME); // switch cave + SNPOST2(SNEXEC, -1, 0, kQGame); // switch cave } else { _now = cav; _mouse->off(); @@ -760,7 +760,7 @@ void CGEEngine::switchCave(int cav) { if (!_startupMode) keyClick(); SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - SNPOST2(SNEXEC, 0, 0, XCAVE); // switch cave + SNPOST2(SNEXEC, 0, 0, kXCave); // switch cave } } } @@ -991,7 +991,7 @@ void CGEEngine::switchMusic() { SNPOST_(SNKILL, -1, 0, Vmenu::_addr); else { SNPOST_(SNSEQ, 122, (_music = false), NULL); - SNPOST2(SNEXEC, -1, 0, SELECTSOUND); + SNPOST2(SNEXEC, -1, 0, kSelectSound); } } else { if (Startup::_core < CORE_HIG) @@ -1217,7 +1217,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if (ps) { if (_flags._kept || _hero->distance(this) < MAX_DISTANCE) { if (works(ps)) { - _vm->feedSnail(ps, TAKE); + _vm->feedSnail(ps, kTake); } else _vm->offUse(); _vm->selectPocket(-1); @@ -1239,10 +1239,10 @@ void Sprite::touch(uint16 mask, int x, int y) { } } else { if (_takePtr != NO_PTR) { - if (snList(TAKE)[_takePtr]._com == SNNEXT) + if (snList(kTake)[_takePtr]._com == SNNEXT) _vm->offUse(); else - _vm->feedSnail(this, TAKE); + _vm->feedSnail(this, kTake); } else _vm->offUse(); } @@ -1662,7 +1662,7 @@ void CGEEngine::runGame() { // main loop while (!_finis && !_eventManager->_quitFlag) { if (_finis) - SNPOST2(SNEXEC, -1, 0, QGAME); + SNPOST2(SNEXEC, -1, 0, kQGame); mainLoop(); } @@ -1686,7 +1686,7 @@ void CGEEngine::movie(const char *ext) { if (INI_FILE::exist(fn)) { loadScript(fn); expandSprite(_vga->_spareQ->locate(999)); - feedSnail(_vga->_showQ->locate(999), TAKE); + feedSnail(_vga->_showQ->locate(999), kTake); _vga->_showQ->append(_mouse); diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 0152961982..2941d36d2c 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -192,7 +192,7 @@ void CGEEngine::snSelect() { static void select(Choice *cho, int hlp) { _cho = cho; _hlp = hlp; - SNPOST2(SNEXEC, -1, 0, SNSELECT); + SNPOST2(SNEXEC, -1, 0, kSnSelect); } diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 8b11dbcc4c..eddc4a6570 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -142,7 +142,7 @@ void Mixer::update() { _led[0]->step(_sndDrvInfo.Vol4._ml); _led[1]->step(_sndDrvInfo.Vol4._dl); - SNPOST2_(SNEXEC, -1, 0, SNDSETVOLUME); + SNPOST2_(SNEXEC, -1, 0, kSndSetVolume); } } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 23a182cbd5..10d85bfc0f 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -307,10 +307,10 @@ void CGEEngine::snGhost(Bitmap *bmp) { delete bmp; } -void CGEEngine::feedSnail(Sprite *spr, SNLIST snq) { +void CGEEngine::feedSnail(Sprite *spr, SnList snq) { if (spr) if (spr->active()) { - uint8 ptr = (snq == TAKE) ? spr->_takePtr : spr->_nearPtr; + uint8 ptr = (snq == kTake) ? spr->_takePtr : spr->_nearPtr; if (ptr != NO_PTR) { Snail::Com *comtab = spr->snList(snq); @@ -335,7 +335,7 @@ void CGEEngine::feedSnail(Sprite *spr, SNLIST snq) { if (c->_com == SNNEXT) { Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); if (s) { - uint8 *idx = (snq == TAKE) ? &s->_takePtr : &s->_nearPtr; + uint8 *idx = (snq == kTake) ? &s->_takePtr : &s->_nearPtr; if (*idx != NO_PTR) { int v; switch (c->_val) { @@ -411,7 +411,7 @@ void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { snc->_ref = ref; snc->_val = val; snc->_ptr = ptr; - snc->_cbType = NULLCB; + snc->_cbType = kNullCB; if (com == SNCLEAR) { _tail = _head; killText(); @@ -419,7 +419,7 @@ void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { } } -void Snail::addCom2(SNCOM com, int ref, int val, CALLBACK cbType) { +void Snail::addCom2(SNCOM com, int ref, int val, CallbackType cbType) { Com *snc = &_snList[_head++]; snc->_com = com; snc->_ref = ref; @@ -603,7 +603,7 @@ void CGEEngine::snCover(Sprite *spr, int xref) { _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr); spr->_flags._shad = false; } - feedSnail(xspr, NEAR); + feedSnail(xspr, kNear); } } @@ -1057,24 +1057,26 @@ void Snail::runCom() { break; case SNEXEC : switch (snc->_cbType) { - case QGAME: + case kQGame: _vm->qGame(); break; - case MINISTEP: + case kMiniStep: _vm->miniStep(snc->_val); break; - case XCAVE: + case kXCave: _vm->xCave(); break; - case SELECTSOUND: + case kSelectSound: _vm->selectSound(); break; - case SNSELECT: + case kSnSelect: _vm->snSelect(); break; - case SNDSETVOLUME: + case kSndSetVolume: sndSetVolume(); break; + default: + error("Unknown Callback Type in SNEXEC"); } break; case SNSTEP : diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 48e5900248..08f20b9d07 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -79,7 +79,7 @@ public: int _ref; int _val; void *_ptr; - CALLBACK _cbType; + CallbackType _cbType; } *_snList; uint8 _head; uint8 _tail; @@ -93,7 +93,7 @@ public: ~Snail(); void runCom(); void addCom(SNCOM com, int ref, int val, void *ptr); - void addCom2(SNCOM com, int ref, int val, CALLBACK cbType); + void addCom2(SNCOM com, int ref, int val, CallbackType cbType); void insCom(SNCOM com, int ref, int val, void *ptr); bool idle(); private: diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 5bdb50fa9e..d0e267ef38 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -476,10 +476,10 @@ bool Sprite::seqTest(int n) { } -Snail::Com *Sprite::snList(SNLIST type) { +Snail::Com *Sprite::snList(SnList type) { register SprExt *e = _ext; if (e) - return (type == NEAR) ? e->_near : e->_take; + return (type == kNear) ? e->_near : e->_take; return NULL; } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index e29fa2eea4..6b56217a1e 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -222,7 +222,7 @@ public: void killXlat(); void step(int nr = -1); Seq *setSeq(Seq *seq); - Snail::Com *snList(SNLIST type); + Snail::Com *snList(SnList type); virtual void touch(uint16 mask, int x, int y); virtual void tick(); void sync(Common::Serializer &s); -- cgit v1.2.3 From 6c9719009223947572c8e81fdefe9e4cd17f717f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jul 2011 19:18:23 +1000 Subject: CGE: Fixed initialising of _shadow that was crashing the intro sequence --- engines/cge/cge.cpp | 3 +-- engines/cge/cge_main.cpp | 1 + engines/cge/vga13h.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 884af2cd46..527b16d288 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -58,6 +58,7 @@ void CGEEngine::setup() { // Initialise fields _lastFrame = 0; _hero = NULL; + _shadow = NULL; // Create debugger console _console = new CGEConsole(this); @@ -81,8 +82,6 @@ void CGEEngine::setup() { _sprite = new Sprite(this, NULL); _miniCave = new Sprite(this, NULL); _miniCave->_flags._kill = false; - _shadow = new Sprite(this, NULL); - _shadow->_flags._kill = false; _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, INFO_W); _cavLight = new CavLight(this); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 16e21e1f73..6e2721f8fc 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1629,6 +1629,7 @@ void CGEEngine::runGame() { if ((_shadow = _sprite) != NULL) { _shadow->_ref = 2; _shadow->_flags._tran = true; + _shadow->_flags._kill = false; _hero->_flags._shad = true; _vga->_showQ->insert(_vga->_spareQ->remove(_shadow), _hero); } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d0e267ef38..c36d747295 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -880,6 +880,7 @@ void Queue::insert(Sprite *spr, Sprite *nxt) { if (!_tail) _tail = spr; } else { + assert(nxt); spr->_next = nxt; spr->_prev = nxt->_prev; if (spr->_prev) -- cgit v1.2.3 From 9dc2cb87d98c801a773659af37dd1b84d73f4888 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jul 2011 19:21:34 +1000 Subject: CGE: Fix array size in Spike class constructor --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index c36d747295..eab50660dd 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1387,7 +1387,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *SP = new BMP_PTR[2]; + BMP_PTR *SP = new BMP_PTR[3]; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; -- cgit v1.2.3 From c3c8032c42958f73ef4370fb0476fd0f5a7e30dd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jul 2011 20:42:30 +1000 Subject: CGE: Implemented Bitmap::xShow method --- engines/cge/vga13h.cpp | 125 +++++++++++++++++++------------------------------ 1 file changed, 47 insertions(+), 78 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index eab50660dd..ec616a2551 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1213,84 +1213,53 @@ void Vga::copyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- void Bitmap::xShow(int16 x, int16 y) { - /* - uint8 rmsk = x % 4, - mask = 1 << rmsk, - *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint8 *m = (char *) M; - uint8 *v = V; - - asm push bx - asm push si - asm push ds - - asm cld - asm les di,scr - asm lds si,v - asm mov bx,m - - asm mov al,0x02 // map mask register - asm mov ah,mask - - plane: - // enable output plane - asm mov dx,VGASEQ_ - asm out dx,ax - asm push ax - - // select input plane - asm mov dx,VGAGRA_ - asm mov al,0x04 // read map select register - asm mov ah,rmsk - asm out dx,ax - - asm push di - - block: - asm lodsw - asm mov cx,ax - asm and ch,0x3F - asm test ah,0xC0 - asm jz endpl - asm jns skip - asm jnp incsi // replicate? - asm add si,cx // skip over data block - asm dec si // fix it before following inc - - incsi: - asm inc si - tint: - asm mov al,es:[di] - //----------------------------------------------- - // asm xlat ss:0 // unsupported with BASM! - __emit__(0x36, 0xD7); // this stands for above! - //----------------------------------------------- - asm stosb - asm loop tint - asm jmp block - - skip: - asm add di,cx - asm jmp block - - endpl: - asm pop di - asm pop ax - asm inc rmsk - asm shl ah,1 - asm test ah,0x10 - asm jz x_chk - asm mov ah,0x01 - asm mov rmsk,0 - asm inc di - x_chk: - asm cmp ah,mask - asm jne plane - asm pop ds - asm pop si - asm pop bx - */ - warning("STUB: BITMAP::xShow"); + const byte *srcP = (const byte *)_v; + byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); + byte *lookupTable = _m; + + // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a + // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data + // must be decompressed and inserted into the surface + for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { + byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); + + for (;;) { + uint16 v = READ_LE_UINT16(srcP); + srcP += 2; + int cmd = v >> 14; + int count = v & 0x3FFF; + + if (cmd == 0) { + // End of image + break; + } + + assert(destP < destEndP); + + if (cmd == 2) + ++srcP; + else if (cmd == 3) + srcP += count; + + // Handle a set of pixels + while (count-- > 0) { + // Transfer operation + switch (cmd) { + case 1: + // SKIP + break; + case 2: + case 3: + // TINT + *destP = lookupTable[*destP]; + break; + } + + // Move to next dest position + destP += 4; + } + } + } } -- cgit v1.2.3 From 324ccb1760b4915d91b58e643bd0d079eaa095f6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jul 2011 21:04:44 +1000 Subject: CGE: Split pathfinding related code into walk.cpp --- engines/cge/cge.cpp | 2 +- engines/cge/cge_main.cpp | 238 +-------------------------------------- engines/cge/cge_main.h | 40 ------- engines/cge/module.mk | 3 +- engines/cge/snail.cpp | 1 + engines/cge/walk.cpp | 281 +++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/walk.h | 82 ++++++++++++++ 7 files changed, 369 insertions(+), 278 deletions(-) create mode 100644 engines/cge/walk.cpp create mode 100644 engines/cge/walk.h diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 527b16d288..0861e3e7f2 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -35,7 +35,7 @@ #include "cge/talk.h" #include "cge/text.h" #include "cge/vol.h" - +#include "cge/walk.h" namespace CGE { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6e2721f8fc..0e2bcc451c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -29,6 +29,7 @@ #include "common/memstream.h" #include "common/savefile.h" #include "common/serializer.h" +#include "common/str.h" #include "cge/general.h" #include "cge/sound.h" #include "cge/startup.h" @@ -46,7 +47,7 @@ #include "cge/mixer.h" #include "cge/cge_main.h" #include "cge/cge.h" -#include "common/str.h" +#include "cge/walk.h" namespace CGE { @@ -60,7 +61,6 @@ uint16 _stklen = (STACK_SIZ * 2); Vga *_vga; Heart *_heart; -WALK *_hero; System *_sys; Sprite *_pocLight; EventManager *_eventManager; @@ -102,74 +102,6 @@ Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; extern Dac _stdPal[58]; -uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; - - -uint8 &Cluster::cell() { - return _map[_b][_a]; -} - - -bool Cluster::Protected() { -/* - if (A == Barriers[Now]._vert || B == Barriers[Now]._horz) - return true; - - _DX = (MAP_ZCNT << 8) + MAP_XCNT; - _BX = (uint16) this; - - asm mov ax,1 - asm mov cl,[bx].(COUPLE)A - asm mov ch,[bx].(COUPLE)B - asm test cx,0x8080 // (A < 0) || (B < 0) - asm jnz xit - - asm cmp cl,dl - asm jge xit - asm cmp ch,dh - asm jge xit - - // if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true; - - asm mov al,dl - asm mul ch - asm xor ch,ch - asm add ax,cx - asm mov bx,ax - _BX += (uint16) Map; - //asm add bx,offset CLUSTER::Map - asm mov al,[bx] - asm and ax,0xFF - asm jz xit - asm mov ax,1 - - // return Map[B][A] != 0; - - xit: return _AX; - */ - - warning("STUB: CLUSTER::Protected()"); - return true; -} - - -Cluster XZ(int x, int y) { - if (y < MAP_TOP) - y = MAP_TOP; - - if (y > MAP_TOP + MAP_HIG - MAP_ZGRID) - y = MAP_TOP + MAP_HIG - MAP_ZGRID; - - return Cluster(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID); -} - - -Cluster XZ(Couple xy) { - signed char x, y; - xy.split(x, y); - return XZ(x, y); -} - void CGEEngine::syncHeader(Common::Serializer &s) { int i; @@ -333,172 +265,6 @@ void CGEEngine::loadMapping() { } } - -Cluster Trace[MAX_FIND_LEVEL]; -int FindLevel; - - -WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) - : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _vm(vm) { -} - - -void WALK::tick() { - if (_flags._hide) - return; - - _here = XZ(_x + _w / 2, _y + _h); - - if (Dir != NO_DIR) { - Sprite *spr; - _sys->funTouch(); - for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { - if (distance(spr) < 2) { - if (!spr->_flags._near) { - _vm->feedSnail(spr, kNear); - spr->_flags._near = true; - } - } else { - spr->_flags._near = false; - } - } - } - - if (_flags._hold || _tracePtr < 0) - park(); - else { - if (_here == Trace[_tracePtr]) { - if (--_tracePtr < 0) - park(); - } else { - signed char dx, dz; - (Trace[_tracePtr] - _here).split(dx, dz); - DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN); - turn(d); - } - } - step(); - if ((Dir == WW && _x <= 0) || - (Dir == EE && _x + _w >= SCR_WID) || - (Dir == SS && _y + _w >= WORLD_HIG - 2)) - park(); - else { - signed char x; // dummy var - _here.split(x, _z); // take current Z position - SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue - } -} - - -int WALK::distance(Sprite *spr) { - int dx, dz; - dx = spr->_x - (_x + _w - WALKSIDE); - if (dx < 0) - dx = (_x + WALKSIDE) - (spr->_x + spr->_w); - - if (dx < 0) - dx = 0; - - dx /= MAP_XGRID; - dz = spr->_z - _z; - if (dz < 0) - dz = - dz; - - dx = dx * dx + dz * dz; - for (dz = 1; dz * dz < dx; dz++) - ; - - return dz - 1; -} - - -void WALK::turn(DIR d) { - DIR dir = (Dir == NO_DIR) ? SS : Dir; - if (d != Dir) { - step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); - Dir = d; - } -} - - -void WALK::park() { - if (_time == 0) - ++_time; - - if (Dir != NO_DIR) { - step(9 + 4 * Dir + Dir); - Dir = NO_DIR; - _tracePtr = -1; - } -} - - -void WALK::findWay(Cluster c) { - warning("STUB: WALK::findWay"); - /* - bool Find1Way(); - extern uint16 Target; - - if (c != Here) { - for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel++) { - signed char x, z; - Here.Split(x, z); - Target = (z << 8) | x; - c.Split(x, z); - _CX = (z << 8) | x; - if (Find1Way()) - break; - } - TracePtr = (FindLevel > MAX_FIND_LEVEL) ? -1 : (FindLevel - 1); - if (TracePtr < 0) - NoWay(); - Time = 1; - } -*/ -} - - -void WALK::findWay(Sprite *spr) { - if (spr && spr != this) { - int x = spr->_x; - int z = spr->_z; - if (spr->_flags._east) - x += spr->_w + _w / 2 - WALKSIDE; - else - x -= _w / 2 - WALKSIDE; - findWay(Cluster((x / MAP_XGRID), - ((z < MAP_ZCNT - MAX_DISTANCE) ? (z + 1) - : (z - 1)))); - } -} - - -bool WALK::lower(Sprite *spr) { - return (spr->_y > _y + (_h * 3) / 5); -} - - -void WALK::reach(Sprite *spr, int mode) { - if (spr) { - _hero->findWay(spr); - if (mode < 0) { - mode = spr->_flags._east; - if (lower(spr)) - mode += 2; - } - } - // note: insert SNAIL commands in reverse order - SNINSERT(SNPAUSE, -1, 64, NULL); - SNINSERT(SNSEQ, -1, TSEQ + mode, this); - if (spr) { - SNINSERT(SNWAIT, -1, -1, _hero); /////--------$$$$$$$ - //SNINSERT(SNWALK, -1, -1, spr); - } - // sequence is not finished, - // now it is just at sprite appear (disappear) point -} - - class SQUARE : public Sprite { public: SQUARE(CGEEngine *vm); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index a60ba0515e..bd57bd64bd 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -86,12 +86,6 @@ namespace CGE { #define BUTTON_NY 3 #define MINI_X 86 #define MINI_Y 162 -#define MAP_XCNT 40 -#define MAP_ZCNT 20 -#define MAP_TOP 80 -#define MAP_HIG 80 -#define MAP_XGRID (SCR_WID / MAP_XCNT) -#define MAP_ZGRID (MAP_HIG / MAP_ZCNT) #define LINE_MAX 512 #define USER_MAX 100 #define SHP_MAX 1024 @@ -129,40 +123,6 @@ private: }; -class Cluster : public Couple { -public: - static uint8 _map[MAP_ZCNT][MAP_XCNT]; - uint8 &cell(); - Cluster() : Couple() { } - Cluster(int a, int b) : Couple(a, b) { } - bool Protected(); -}; - - -class WALK : public Sprite { -public: - Cluster _here; - int _tracePtr; - - enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; - WALK(CGEEngine *vm, BMP_PTR *shpl); - void tick(); - void findWay(Cluster c); - void findWay(Sprite *spr); - int distance(Sprite *spr); - void turn(DIR d); - void park(); - bool lower(Sprite *spr); - void reach(Sprite *spr, int mode = -1); -private: - CGEEngine *_vm; - -}; - -Cluster XZ(int x, int y); -Cluster XZ(Couple xy); - -extern WALK *_hero; extern Vga *_vga; extern Heart *_heart; extern System *_sys; diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 95ffd6d906..584ab5a1b6 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -22,7 +22,8 @@ MODULE_OBJS := \ text.o \ vga13h.o \ vmenu.o \ - vol.o + vol.o \ + walk.o MODULE_DIRS += \ engines/cge diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 10d85bfc0f..977103d7a1 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -32,6 +32,7 @@ #include "cge/text.h" #include "cge/cge_main.h" #include "cge/events.h" +#include "cge/walk.h" namespace CGE { diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp new file mode 100644 index 0000000000..fc2ed277db --- /dev/null +++ b/engines/cge/walk.cpp @@ -0,0 +1,281 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "common/scummsys.h" +#include "cge/walk.h" +#include "cge/sound.h" +#include "cge/startup.h" +#include "cge/config.h" +#include "cge/vga13h.h" +#include "cge/snail.h" +#include "cge/text.h" +#include "cge/game.h" +#include "cge/events.h" +#include "cge/cfile.h" +#include "cge/vol.h" +#include "cge/talk.h" +#include "cge/vmenu.h" +#include "cge/gettext.h" +#include "cge/mixer.h" +#include "cge/cge_main.h" +#include "cge/cge.h" +#include "common/str.h" + +namespace CGE { + +WALK *_hero; +Cluster Trace[MAX_FIND_LEVEL]; +int FindLevel; + +uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; + + +uint8 &Cluster::cell() { + return _map[_b][_a]; +} + + +bool Cluster::Protected() { +/* + if (A == Barriers[Now]._vert || B == Barriers[Now]._horz) + return true; + + _DX = (MAP_ZCNT << 8) + MAP_XCNT; + _BX = (uint16) this; + + asm mov ax,1 + asm mov cl,[bx].(COUPLE)A + asm mov ch,[bx].(COUPLE)B + asm test cx,0x8080 // (A < 0) || (B < 0) + asm jnz xit + + asm cmp cl,dl + asm jge xit + asm cmp ch,dh + asm jge xit + + // if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true; + + asm mov al,dl + asm mul ch + asm xor ch,ch + asm add ax,cx + asm mov bx,ax + _BX += (uint16) Map; + //asm add bx,offset CLUSTER::Map + asm mov al,[bx] + asm and ax,0xFF + asm jz xit + asm mov ax,1 + + // return Map[B][A] != 0; + + xit: return _AX; + */ + + warning("STUB: CLUSTER::Protected()"); + return true; +} + + +Cluster XZ(int x, int y) { + if (y < MAP_TOP) + y = MAP_TOP; + + if (y > MAP_TOP + MAP_HIG - MAP_ZGRID) + y = MAP_TOP + MAP_HIG - MAP_ZGRID; + + return Cluster(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID); +} + + +Cluster XZ(Couple xy) { + signed char x, y; + xy.split(x, y); + return XZ(x, y); +} + +WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) + : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _vm(vm) { +} + + +void WALK::tick() { + if (_flags._hide) + return; + + _here = XZ(_x + _w / 2, _y + _h); + + if (Dir != NO_DIR) { + Sprite *spr; + _sys->funTouch(); + for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { + if (distance(spr) < 2) { + if (!spr->_flags._near) { + _vm->feedSnail(spr, kNear); + spr->_flags._near = true; + } + } else { + spr->_flags._near = false; + } + } + } + + if (_flags._hold || _tracePtr < 0) + park(); + else { + if (_here == Trace[_tracePtr]) { + if (--_tracePtr < 0) + park(); + } else { + signed char dx, dz; + (Trace[_tracePtr] - _here).split(dx, dz); + DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN); + turn(d); + } + } + step(); + if ((Dir == WW && _x <= 0) || + (Dir == EE && _x + _w >= SCR_WID) || + (Dir == SS && _y + _w >= WORLD_HIG - 2)) + park(); + else { + signed char x; // dummy var + _here.split(x, _z); // take current Z position + SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue + } +} + + +int WALK::distance(Sprite *spr) { + int dx, dz; + dx = spr->_x - (_x + _w - WALKSIDE); + if (dx < 0) + dx = (_x + WALKSIDE) - (spr->_x + spr->_w); + + if (dx < 0) + dx = 0; + + dx /= MAP_XGRID; + dz = spr->_z - _z; + if (dz < 0) + dz = - dz; + + dx = dx * dx + dz * dz; + for (dz = 1; dz * dz < dx; dz++) + ; + + return dz - 1; +} + + +void WALK::turn(DIR d) { + DIR dir = (Dir == NO_DIR) ? SS : Dir; + if (d != Dir) { + step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); + Dir = d; + } +} + + +void WALK::park() { + if (_time == 0) + ++_time; + + if (Dir != NO_DIR) { + step(9 + 4 * Dir + Dir); + Dir = NO_DIR; + _tracePtr = -1; + } +} + + +void WALK::findWay(Cluster c) { + /* + bool Find1Way(); + extern uint16 Target; + + if (c != _here) { + for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel++) { + signed char x, z; + _here.split(x, z); + Target = (z << 8) | x; + c.split(x, z); + _CX = (z << 8) | x; + if (Find1Way()) + break; + } + _tracePtr = (FindLevel > MAX_FIND_LEVEL) ? -1 : (FindLevel - 1); + if (_tracePtr < 0) + NoWay(); + Time = 1; + } + */ +} + + +void WALK::findWay(Sprite *spr) { + if (spr && spr != this) { + int x = spr->_x; + int z = spr->_z; + if (spr->_flags._east) + x += spr->_w + _w / 2 - WALKSIDE; + else + x -= _w / 2 - WALKSIDE; + findWay(Cluster((x / MAP_XGRID), + ((z < MAP_ZCNT - MAX_DISTANCE) ? (z + 1) + : (z - 1)))); + } +} + + +bool WALK::lower(Sprite *spr) { + return (spr->_y > _y + (_h * 3) / 5); +} + + +void WALK::reach(Sprite *spr, int mode) { + if (spr) { + _hero->findWay(spr); + if (mode < 0) { + mode = spr->_flags._east; + if (lower(spr)) + mode += 2; + } + } + // note: insert SNAIL commands in reverse order + SNINSERT(SNPAUSE, -1, 64, NULL); + SNINSERT(SNSEQ, -1, TSEQ + mode, this); + if (spr) { + SNINSERT(SNWAIT, -1, -1, _hero); /////--------$$$$$$$ + //SNINSERT(SNWALK, -1, -1, spr); + } + // sequence is not finished, + // now it is just at sprite appear (disappear) point +} + +} // End of namespace CGE diff --git a/engines/cge/walk.h b/engines/cge/walk.h new file mode 100644 index 0000000000..4573816bb4 --- /dev/null +++ b/engines/cge/walk.h @@ -0,0 +1,82 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#ifndef __CGE_WALK__ +#define __CGE_WALK__ + +#include "cge/wav.h" +#include "cge/vga13h.h" +#include "cge/events.h" + +namespace CGE { + +#define MAP_XCNT 40 +#define MAP_ZCNT 20 +#define MAP_TOP 80 +#define MAP_HIG 80 +#define MAP_XGRID (SCR_WID / MAP_XCNT) +#define MAP_ZGRID (MAP_HIG / MAP_ZCNT) + + +class Cluster : public Couple { +public: + static uint8 _map[MAP_ZCNT][MAP_XCNT]; + uint8 &cell(); + Cluster() : Couple() { } + Cluster(int a, int b) : Couple(a, b) { } + bool Protected(); +}; + + +class WALK : public Sprite { +public: + Cluster _here; + int _tracePtr; + + enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; + WALK(CGEEngine *vm, BMP_PTR *shpl); + void tick(); + void findWay(Cluster c); + void findWay(Sprite *spr); + int distance(Sprite *spr); + void turn(DIR d); + void park(); + bool lower(Sprite *spr); + void reach(Sprite *spr, int mode = -1); +private: + CGEEngine *_vm; + +}; + +Cluster XZ(int x, int y); +Cluster XZ(Couple xy); + +extern WALK *_hero; + +} // End of namespace CGE + +#endif -- cgit v1.2.3 From f0d10b62b37b7d3e35ebcd989745a2d0a9570a21 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Jul 2011 22:36:18 +1000 Subject: CGE: In progress work on pathfinder --- engines/cge/cge.h | 1 - engines/cge/cge_main.cpp | 6 ---- engines/cge/cge_main.h | 1 - engines/cge/general.h | 40 ---------------------- engines/cge/walk.cpp | 89 +++++++++++++++++++++++++++++++++++++++--------- engines/cge/walk.h | 51 +++++++++++++++++++++++++-- 6 files changed, 122 insertions(+), 66 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 7dd218e258..dc757ec5a0 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -142,7 +142,6 @@ public: void trouble(int seq, int txt); void offUse(); void tooFar(); - void noWay(); void loadHeroXY(); void keyClick(); void switchColorMode(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 0e2bcc451c..f532bd05e8 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -241,12 +241,6 @@ void CGEEngine::tooFar() { trouble(TOO_FAR, TOO_FAR_TEXT); } -// Used in stubbed function, do not remove! -void CGEEngine::noWay() { - trouble(NO_WAY, NO_WAY_TEXT); -} - - void CGEEngine::loadHeroXY() { INI_FILE cf(progName(".HXY")); memset(_heroXY, 0, sizeof(_heroXY)); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index bd57bd64bd..40e6d88668 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -92,7 +92,6 @@ namespace CGE { #define STD_DELAY 3 #define LEV_MAX 5 #define CAVE_MAX (CAVE_NX * CAVE_NY) -#define MAX_FIND_LEVEL 3 #define MAX_DISTANCE 3 #define INI_EXT ".INI" #define IN0_EXT ".IN0" diff --git a/engines/cge/general.h b/engines/cge/general.h index b4f73726ee..0639fe2a01 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -49,46 +49,6 @@ struct Dac { typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); -class Couple { -protected: - signed char _a; - signed char _b; -public: - Couple() { } - Couple(const signed char a, const signed char b) : _a(a), _b(b) { } - Couple operator + (Couple c) { - return Couple(_a + c._a, _b + c._b); - } - - void operator += (Couple c) { - _a += c._a; - _b += c._b; - } - - Couple operator - (Couple c) { - return Couple(_a - c._a, _b - c._b); - } - - void operator -= (Couple c) { - _a -= c._a; - _b -= c._b; - } - - bool operator == (Couple c) { - return ((_a - c._a) | (_b - c._b)) == 0; - } - - bool operator != (Couple c) { - return !(operator == (c)); - } - - void split(signed char &a, signed char &b) { - a = _a; - b = _b; - } -}; - - class Engine_ { protected: static void (* oldTimer)(...); diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index fc2ed277db..e33638b958 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -48,8 +48,10 @@ namespace CGE { WALK *_hero; -Cluster Trace[MAX_FIND_LEVEL]; -int FindLevel; + +struct TabDir { + int xd, yd; +}; uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; @@ -58,6 +60,9 @@ uint8 &Cluster::cell() { return _map[_b][_a]; } +bool Cluster::isValid() const { + return (_a >= 0) && (_a < MAP_XCNT) && (_b >= 0) && (_b < MAP_ZCNT); +} bool Cluster::Protected() { /* @@ -148,12 +153,12 @@ void WALK::tick() { if (_flags._hold || _tracePtr < 0) park(); else { - if (_here == Trace[_tracePtr]) { + if (_here == _trace[_tracePtr]) { if (--_tracePtr < 0) park(); } else { signed char dx, dz; - (Trace[_tracePtr] - _here).split(dx, dz); + (_trace[_tracePtr] - _here).split(dx, dz); DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN); turn(d); } @@ -215,26 +220,23 @@ void WALK::park() { void WALK::findWay(Cluster c) { - /* - bool Find1Way(); - extern uint16 Target; - if (c != _here) { - for (FindLevel = 1; FindLevel <= MAX_FIND_LEVEL; FindLevel++) { + _level = 0; + + for (_findLevel = 1; _findLevel <= MAX_FIND_LEVEL; _findLevel++) { signed char x, z; _here.split(x, z); - Target = (z << 8) | x; + _target = (z << 8) | x; c.split(x, z); - _CX = (z << 8) | x; - if (Find1Way()) + + if (find1Way(XZ(x, z))) break; } - _tracePtr = (FindLevel > MAX_FIND_LEVEL) ? -1 : (FindLevel - 1); + _tracePtr = (_findLevel > MAX_FIND_LEVEL) ? -1 : (_findLevel - 1); if (_tracePtr < 0) - NoWay(); - Time = 1; + noWay(); + _time = 1; } - */ } @@ -278,4 +280,59 @@ void WALK::reach(Sprite *spr, int mode) { // now it is just at sprite appear (disappear) point } +void WALK::noWay() { + _vm->trouble(NO_WAY, NO_WAY_TEXT); +} + +bool WALK::find1Way(Cluster c) { + Cluster start = c; + const Cluster tab[4] = { Cluster(-1, 0), Cluster(1, 0), Cluster(0, -1), Cluster(0, 1)}; + const int tabLen = 4; + + if (c == _here) + // Found destination + return true; + + if (_level >= _findLevel) + // Nesting limit + return false; + + // Look for barriers + if (c.Protected()) + return false; + + if (c.cell()) + // Location is occupied + return false; + + + // Loop through each direction + for (int i = 0; i < tabLen; ++i) { + // Reset to starting position + c = start; + + do { + c += tab[i]; + if (!c.isValid()) + // Break to check next direction + break; + + // Recursively check for further paths + ++_level; + ++c.cell(); + bool foundPath = find1Way(c); + --c.cell(); + --_level; + + if (foundPath) { + // Set route point + _trace[_level] = start; + return true; + } + } while (c.Protected() && !c.cell()); + } + + return false; +} + } // End of namespace CGE diff --git a/engines/cge/walk.h b/engines/cge/walk.h index 4573816bb4..30eb727e2c 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -40,7 +40,46 @@ namespace CGE { #define MAP_HIG 80 #define MAP_XGRID (SCR_WID / MAP_XCNT) #define MAP_ZGRID (MAP_HIG / MAP_ZCNT) +#define MAX_FIND_LEVEL 3 +class Couple { +protected: + signed char _a; + signed char _b; +public: + Couple() { } + Couple(const signed char a, const signed char b) : _a(a), _b(b) { } + Couple operator + (Couple c) { + return Couple(_a + c._a, _b + c._b); + } + + void operator += (Couple c) { + _a += c._a; + _b += c._b; + } + + Couple operator - (Couple c) { + return Couple(_a - c._a, _b - c._b); + } + + void operator -= (Couple c) { + _a -= c._a; + _b -= c._b; + } + + bool operator == (const Couple &c) { + return ((_a - c._a) | (_b - c._b)) == 0; + } + + bool operator != (Couple c) { + return !(operator == (c)); + } + + void split(signed char &a, signed char &b) { + a = _a; + b = _b; + } +}; class Cluster : public Couple { public: @@ -49,13 +88,21 @@ public: Cluster() : Couple() { } Cluster(int a, int b) : Couple(a, b) { } bool Protected(); + bool isValid() const; + }; class WALK : public Sprite { +private: + CGEEngine *_vm; public: Cluster _here; int _tracePtr; + int _level; + int _findLevel; + int _target; + Cluster _trace[MAX_FIND_LEVEL]; enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; WALK(CGEEngine *vm, BMP_PTR *shpl); @@ -67,9 +114,9 @@ public: void park(); bool lower(Sprite *spr); void reach(Sprite *spr, int mode = -1); -private: - CGEEngine *_vm; + void noWay(); + bool find1Way(Cluster c); }; Cluster XZ(int x, int y); -- cgit v1.2.3 From c3bed46ba06046c8ba76c12c42d016f63beb6331 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Jul 2011 19:38:58 +1000 Subject: CGE: Fix for all the game objects being draggable --- engines/cge/events.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 9c1741189f..73018aa2ea 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -296,8 +296,11 @@ void EventManager::handleEvents() { _mouse->_hold = e._ptr; if (_mouse->_hold) { _mouse->_hold->_flags._hold = true; - _mouse->_hx = e._x - _mouse->_hold->_x; - _mouse->_hy = e._y - _mouse->_hold->_y; + + if (_mouse->_hold->_flags._drag) { + _mouse->_hx = e._x - _mouse->_hold->_x; + _mouse->_hy = e._y - _mouse->_hold->_y; + } } } @@ -315,8 +318,10 @@ void EventManager::handleEvents() { } EvtTail = (EvtTail + 1) % EVT_MAX; } - if (_mouse->_hold) - _mouse->_hold->gotoxy(_mouse->_x - _mouse->_hx, _mouse->_y - _mouse->_hy); + if (_mouse->_hold) { + if (_mouse->_hold->_flags._drag) + _mouse->_hold->gotoxy(_mouse->_x - _mouse->_hx, _mouse->_y - _mouse->_hy); + } } void EventManager::clrEvt(Sprite *spr) { -- cgit v1.2.3 From 11fa6b941c520129c017c946474114afa71fe41f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Jul 2011 20:43:29 +1000 Subject: CGE: Fix some errors in the pathfinder setup --- engines/cge/cge.cpp | 2 ++ engines/cge/walk.cpp | 69 ++++++++++++---------------------------------------- engines/cge/walk.h | 8 ++++-- 3 files changed, 24 insertions(+), 55 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 0861e3e7f2..e192774f45 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -68,6 +68,7 @@ void CGEEngine::setup() { VFile::init(); Bitmap::init(); Talk::init(); + Cluster::init(this); // Initialise engine objects _text = new Text(this, progName(), 128); @@ -132,6 +133,7 @@ CGEEngine::~CGEEngine() { Bitmap::deinit(); VFile::deinit(); Vga::deinit(); + Cluster::init(this); // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index e33638b958..0e31e2e541 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -27,6 +27,7 @@ #include "common/scummsys.h" #include "cge/walk.h" +#include "cge/cge.h" #include "cge/sound.h" #include "cge/startup.h" #include "cge/config.h" @@ -47,14 +48,16 @@ namespace CGE { -WALK *_hero; +extern Bar _barriers[]; -struct TabDir { - int xd, yd; -}; +WALK *_hero; uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; +CGEEngine *Cluster::_vm; +void Cluster::init(CGEEngine *vm) { + _vm = vm; +} uint8 &Cluster::cell() { return _map[_b][_a]; @@ -64,49 +67,11 @@ bool Cluster::isValid() const { return (_a >= 0) && (_a < MAP_XCNT) && (_b >= 0) && (_b < MAP_ZCNT); } -bool Cluster::Protected() { -/* - if (A == Barriers[Now]._vert || B == Barriers[Now]._horz) - return true; - - _DX = (MAP_ZCNT << 8) + MAP_XCNT; - _BX = (uint16) this; - - asm mov ax,1 - asm mov cl,[bx].(COUPLE)A - asm mov ch,[bx].(COUPLE)B - asm test cx,0x8080 // (A < 0) || (B < 0) - asm jnz xit - - asm cmp cl,dl - asm jge xit - asm cmp ch,dh - asm jge xit - - // if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true; - - asm mov al,dl - asm mul ch - asm xor ch,ch - asm add ax,cx - asm mov bx,ax - _BX += (uint16) Map; - //asm add bx,offset CLUSTER::Map - asm mov al,[bx] - asm and ax,0xFF - asm jz xit - asm mov ax,1 - - // return Map[B][A] != 0; - - xit: return _AX; - */ - - warning("STUB: CLUSTER::Protected()"); - return true; +bool Cluster::chkBar() const { + assert(_vm->_now <= CAVE_MAX); + return (_a == _barriers[_vm->_now]._horz) && (_b == _barriers[_vm->_now]._vert); } - Cluster XZ(int x, int y) { if (y < MAP_TOP) y = MAP_TOP; @@ -125,7 +90,7 @@ Cluster XZ(Couple xy) { } WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) - : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _vm(vm) { + : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _level(0), _vm(vm) { } @@ -221,15 +186,13 @@ void WALK::park() { void WALK::findWay(Cluster c) { if (c != _here) { - _level = 0; - for (_findLevel = 1; _findLevel <= MAX_FIND_LEVEL; _findLevel++) { signed char x, z; _here.split(x, z); - _target = (z << 8) | x; + _target = Couple(x, z); c.split(x, z); - if (find1Way(XZ(x, z))) + if (find1Way(Cluster(x, z))) break; } _tracePtr = (_findLevel > MAX_FIND_LEVEL) ? -1 : (_findLevel - 1); @@ -289,7 +252,7 @@ bool WALK::find1Way(Cluster c) { const Cluster tab[4] = { Cluster(-1, 0), Cluster(1, 0), Cluster(0, -1), Cluster(0, 1)}; const int tabLen = 4; - if (c == _here) + if (c == _target) // Found destination return true; @@ -298,7 +261,7 @@ bool WALK::find1Way(Cluster c) { return false; // Look for barriers - if (c.Protected()) + if (c.chkBar()) return false; if (c.cell()) @@ -329,7 +292,7 @@ bool WALK::find1Way(Cluster c) { _trace[_level] = start; return true; } - } while (c.Protected() && !c.cell()); + } while (c.chkBar() && !c.cell()); } return false; diff --git a/engines/cge/walk.h b/engines/cge/walk.h index 30eb727e2c..eb29d9b462 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -84,10 +84,14 @@ public: class Cluster : public Couple { public: static uint8 _map[MAP_ZCNT][MAP_XCNT]; + static CGEEngine *_vm; + + static void init(CGEEngine *vm); +public: uint8 &cell(); Cluster() : Couple() { } Cluster(int a, int b) : Couple(a, b) { } - bool Protected(); + bool chkBar() const; bool isValid() const; }; @@ -101,7 +105,7 @@ public: int _tracePtr; int _level; int _findLevel; - int _target; + Couple _target; Cluster _trace[MAX_FIND_LEVEL]; enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; -- cgit v1.2.3 From b74e1b6af026bf0420e548e7d63e11968041e9a2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Jul 2011 21:25:03 +1000 Subject: CGE: Pathfinder now works --- engines/cge/walk.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index 0e31e2e541..b35864f16e 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -282,9 +282,9 @@ bool WALK::find1Way(Cluster c) { // Recursively check for further paths ++_level; - ++c.cell(); + ++start.cell(); bool foundPath = find1Way(c); - --c.cell(); + --start.cell(); --_level; if (foundPath) { @@ -292,7 +292,7 @@ bool WALK::find1Way(Cluster c) { _trace[_level] = start; return true; } - } while (c.chkBar() && !c.cell()); + } while (!c.chkBar() && !c.cell()); } return false; -- cgit v1.2.3 From 8c7130fdfaf6e7b6f93f158fc2399f81f2c12b71 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Jul 2011 22:12:56 +1000 Subject: CGE: Fix display of in-game hotspot description --- engines/cge/talk.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 146c720667..11dedf349b 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -309,11 +309,22 @@ void InfoLine::update(const char *tx) { uint16 size = 4 * psiz; // whole map size // clear whole rectangle + byte *pDest; + memset(v + 2, TEXT_BG, dsiz); // data bytes + for (pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) { + Common::copy(v, v + lsiz, pDest); + } + *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 + for (pDest = v + psiz; pDest < (v + 4 * psiz); pDest += psiz) { + Common::copy(v, v + psiz, pDest); + } + +/* memset(v + 2, TEXT_BG, dsiz); // data bytes memmove(v + lsiz, v, psiz - lsiz); *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 memmove(v + psiz, v, 3 * psiz); - +*/ // paint text line if (tx) { uint8 *p = v + 2, * q = p + size; -- cgit v1.2.3 From 4dd65c5e57df55edfabe4e71e487f164a9c5b150 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Jul 2011 22:14:33 +1000 Subject: CGE: Removed some commented out code from previous bugfix --- engines/cge/talk.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 11dedf349b..e2a5af5fde 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -319,12 +319,6 @@ void InfoLine::update(const char *tx) { Common::copy(v, v + psiz, pDest); } -/* - memset(v + 2, TEXT_BG, dsiz); // data bytes - memmove(v + lsiz, v, psiz - lsiz); - *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 - memmove(v + psiz, v, 3 * psiz); -*/ // paint text line if (tx) { uint8 *p = v + 2, * q = p + size; -- cgit v1.2.3 From 453fbb7454b5e6d517febd29aea4e589c44247bf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Jul 2011 22:56:49 +1000 Subject: CGE: Bugfixes for loading the room preview shapes list --- engines/cge/cge.cpp | 3 +++ engines/cge/cge.h | 1 + engines/cge/cge_main.cpp | 2 -- engines/cge/snail.h | 2 +- engines/cge/startup.cpp | 3 --- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index e192774f45..5c1bf2caf0 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -36,6 +36,7 @@ #include "cge/text.h" #include "cge/vol.h" #include "cge/walk.h" +#include "cge/startup.h" namespace CGE { @@ -95,6 +96,7 @@ void CGEEngine::setup() { _eventManager = new EventManager(); _offUseCount = atoi(_text->getText(OFF_USE_COUNT)); _music = true; + _mini = new byte[MINI_EMM_SIZE]; for (int i = 0; i < POCKET_NX; i++) _pocref[i] = -1; @@ -160,6 +162,7 @@ CGEEngine::~CGEEngine() { delete _snail; delete _snail_; delete _hero; + delete[] _mini; } Common::Error CGEEngine::run() { diff --git a/engines/cge/cge.h b/engines/cge/cge.h index dc757ec5a0..bb14251599 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -85,6 +85,7 @@ public: int _lev; Common::RandomSource _randomSource; + byte * _mini; virtual Common::Error run(); GUI::Debugger *getDebugger() { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index f532bd05e8..3c926a3f89 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -90,7 +90,6 @@ static char _usrFnam[15] = "\0ɱ%^ //-------------------------------------------------------------------------- -static Ems *_mini = _miniEmm.alloc((uint16)MINI_EMM_SIZE); static BMP_PTR *_miniShpList = NULL; static BMP_PTR _miniShp[] = { NULL, NULL }; static bool _finis = false; @@ -348,7 +347,6 @@ void CGEEngine::miniStep(int stp) { if (stp < 0) _miniCave->_flags._hide = true; else { - &*_mini; *_miniShp[0] = *_miniShpList[stp]; if (_fx._current) &*(_fx._current->eAddr()); diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 08f20b9d07..e8578e2b3d 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -48,7 +48,7 @@ namespace CGE { #define SNPOST_(c, r, v, p) _snail_->addCom(c, r, v, p) #define SNPOST2_(c, r, v, p) _snail_->addCom2(c, r, v, p) -#define SNAIL_FRAME_RATE 62 +#define SNAIL_FRAME_RATE 80 #define SNAIL_FRAME_DELAY (1000 / SNAIL_FRAME_RATE) struct Bar { diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 9210b40c77..37c6b4f62e 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -37,9 +37,6 @@ extern char _copr[]; #define id (*(Ident*)_copr) - -Emm _miniEmm = MINI_EMM_SIZE; - // static Startup _startUp; int Startup::_mode = 0; -- cgit v1.2.3 From c3f3120194151cdeb31d9b3622c76cd4e5b7ed6a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 15:17:18 +1000 Subject: CGE: Cleaned up room preview handling code and fixed memory leak --- engines/cge/cge.cpp | 5 +++-- engines/cge/cge.h | 4 +++- engines/cge/cge_main.cpp | 6 ++++-- engines/cge/vga13h.cpp | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 5c1bf2caf0..6924f0b14e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -60,6 +60,9 @@ void CGEEngine::setup() { _lastFrame = 0; _hero = NULL; _shadow = NULL; + _miniCave = NULL; + _miniShp = NULL; + _miniShpList = NULL; // Create debugger console _console = new CGEConsole(this); @@ -82,8 +85,6 @@ void CGEEngine::setup() { _pocket[i]->_flags._kill = false; } _sprite = new Sprite(this, NULL); - _miniCave = new Sprite(this, NULL); - _miniCave->_flags._kill = false; _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, INFO_W); _cavLight = new CavLight(this); diff --git a/engines/cge/cge.h b/engines/cge/cge.h index bb14251599..9894cc07bc 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -85,7 +85,9 @@ public: int _lev; Common::RandomSource _randomSource; - byte * _mini; + byte * _mini; + BMP_PTR * _miniShp; + BMP_PTR * _miniShpList; virtual Common::Error run(); GUI::Debugger *getDebugger() { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 3c926a3f89..e518c668f4 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -90,8 +90,6 @@ static char _usrFnam[15] = "\0ɱ%^ //-------------------------------------------------------------------------- -static BMP_PTR *_miniShpList = NULL; -static BMP_PTR _miniShp[] = { NULL, NULL }; static bool _finis = false; int _offUseCount; uint16 *_intStackPtr = false; @@ -1364,11 +1362,15 @@ void CGEEngine::runGame() { killMidi(); if (_mini && INI_FILE::exist("MINI.SPR")) { + _miniShp = new BMP_PTR[2]; + _miniShp[0] = _miniShp[1] = NULL; + uint8 *ptr = (uint8 *) &*_mini; if (ptr != NULL) { loadSprite("MINI", -1, 0, MINI_X, MINI_Y); expandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { + _miniCave->_flags._kill = false; _miniCave->_flags._hide = true; _miniCave->moveShapes(ptr); _miniShp[0] = new Bitmap(*_miniCave->shp()); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ec616a2551..716a6b584d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1378,4 +1378,4 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { _flags._kill = false; } -} // End of namespace CGE +} // End of namespace CGE \ No newline at end of file -- cgit v1.2.3 From b957eda759c060048ca2c1d371105c64776d1207 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 15:30:06 +1000 Subject: CGE: Map keypad Enter to be handled like the main Enter key --- engines/cge/events.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 73018aa2ea..eba043cdc8 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -104,6 +104,10 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) { cgeCode = 29; return true; } + if (keycode == Common::KEYCODE_KP_ENTER) { + cgeCode = 28; + return true; + } // Scan through the ScummVM mapping list for (int idx = 0; idx < 0x60; ++idx) { -- cgit v1.2.3 From 50d313a547ae1bec050be8d6b64ccc01161da22f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 15:44:17 +1000 Subject: CGE: Implement monochrome view mode button --- engines/cge/cge_main.cpp | 1 - engines/cge/vga13h.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index e518c668f4..b43360c0b5 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -299,7 +299,6 @@ void CGEEngine::setMapBrick(int x, int z) { } } -//static void switchColorMode(); //static void switchDebug(); //static void pullSprite(); //static void NextStep(); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 716a6b584d..a7b9d8c080 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1128,9 +1128,9 @@ void Vga::setColors(Dac *tab, int lum) { if (_mono) { destP = _newColors; - for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { + for (int idx = 0; idx < PAL_CNT; ++idx, ++destP) { // Form a greyscalce colour from 30% R, 59% G, 11% B - uint8 intensity = (destP->_r * 77) + (destP->_g * 151) + (destP->_b * 28); + uint8 intensity = (((int)destP->_r * 77) + ((int)destP->_g * 151) + ((int)destP->_b * 28)) >> 8; destP->_r = intensity; destP->_g = intensity; destP->_b = intensity; -- cgit v1.2.3 From 10627dccfa51eefccc6aa2a468f3a2fa246e88b6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 16:23:34 +1000 Subject: CGE: Fix the selection of menu items to call appropriate dispatch method --- engines/cge/vmenu.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index f802916657..0c0e1fb855 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -127,6 +127,7 @@ Vmenu::~Vmenu() { _addr = NULL; } +#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) void Vmenu::touch(uint16 mask, int x, int y) { uint16 h = FONT_HIG + TEXT_LS; @@ -150,8 +151,9 @@ void Vmenu::touch(uint16 mask, int x, int y) { if (ok && (mask & L_UP)) { _items = 0; SNPOST_(SNKILL, -1, 0, this); - //_menu[_recent = n].Proc(); - warning("Missing call to proc()"); + _recent = n; + assert(_menu[n].Proc); + CALL_MEMBER_FN(*_vm, _menu[n].Proc)(); } } } -- cgit v1.2.3 From ce070cdd3c664bc5fca80770a40e669fd07a83a0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 18:33:20 +1000 Subject: CGE: Implemented basic savegame support I've slightly modified the behaviour of the original - rather than prompting each time the user starts for a name, it now only prompts the first time, and uses the entered name as a save description for a slot 0 savegame --- engines/cge/cge.h | 23 +++- engines/cge/cge_main.cpp | 314 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 253 insertions(+), 84 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 9894cc07bc..2d67b2218a 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -25,7 +25,9 @@ #include "cge/general.h" #include "common/random.h" +#include "common/savefile.h" #include "common/serializer.h" +#include "common/str.h" #include "engines/engine.h" #include "gui/debugger.h" #include "graphics/surface.h" @@ -56,11 +58,27 @@ enum CallbackType { #define POCKET_NX 8 +#define CGE_SAVEGAME_VERSION 1 + +struct SavegameHeader { + uint8 version; + Common::String saveName; + Graphics::Surface *thumbnail; + int saveYear, saveMonth, saveDay; + int saveHour, saveMinutes; + int totalFrames; +}; + class CGEEngine : public Engine { private: uint32 _lastFrame; void tick(); void syncHeader(Common::Serializer &s); + bool readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header); + void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header); + void syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny = false); + bool savegameExists(int slotNumber); + Common::String generateSaveName(int slot); public: CGEEngine(OSystem *syst, const ADGameDescription *gameDescription); ~CGEEngine(); @@ -83,6 +101,7 @@ public: bool _game; int _now; int _lev; + char _usrFnam[15]; Common::RandomSource _randomSource; byte * _mini; @@ -100,7 +119,7 @@ public: void quit(); void resetQSwitch(); void optionTouch(int opt, uint16 mask); - void loadGame(XFile &file, bool tiny); + bool loadGame(int slotNumber, SavegameHeader *header = NULL, bool tiny = false); void setMapBrick(int x, int z); void switchMapping(); void loadSprite(const char *fname, int ref, int cav, int col, int row, int pos); @@ -129,7 +148,7 @@ public: void setIRQ(); void setDMA(); void mainLoop(); - void saveGame(Common::WriteStream *file); + void saveGame(int slotNumber, const Common::String &desc); void switchMusic(); void selectPocket(int n); void expandSprite(Sprite *spr); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index b43360c0b5..3ea82e3099 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -30,6 +30,9 @@ #include "common/savefile.h" #include "common/serializer.h" #include "common/str.h" +#include "graphics/palette.h" +#include "graphics/scaler.h" +#include "graphics/thumbnail.h" #include "cge/general.h" #include "cge/sound.h" #include "cge/startup.h" @@ -86,7 +89,8 @@ Snail *_snail_; // 1.01 - 17VII95 - default savegame with sound ON // coditionals EVA for 2-month evaluation version -static char _usrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ"; +const char *SAVEGAME_STR = "SCUMMVM_CGE"; +#define SAVEGAME_STR_SIZE 11 //-------------------------------------------------------------------------- @@ -137,84 +141,237 @@ void CGEEngine::syncHeader(Common::Serializer &s) { } } -void CGEEngine::loadGame(XFile &file, bool tiny = false) { - Sprite *spr; - int i; +bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { + Common::MemoryReadStream *readStream; + SavegameHeader saveHeader; - // Read the data into a data buffer - int size = file.size() - file.mark(); - byte *dataBuffer = (byte *)malloc(size); - file.read(dataBuffer, size); - Common::MemoryReadStream readStream(dataBuffer, size, DisposeAfterUse::YES); - Common::Serializer s(&readStream, NULL); + if (slotNumber == -1) { + // Loading the data for the initial game state + SVG0FILE file = SVG0FILE(SVG0NAME); + int size = file.size(); + byte *dataBuffer = (byte *)malloc(size); + file.read(dataBuffer, size); + readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES); - // Synchronise header data - syncHeader(s); + } else { + // Open up the savgame file + Common::String slotName = generateSaveName(slotNumber); + Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(slotName); + + // Read the data into a data buffer + int size = saveFile->size(); + byte *dataBuffer = (byte *)malloc(size); + saveFile->read(dataBuffer, size); + readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES); + } - if (Startup::_core < CORE_HIG) - _music = false; + // Check to see if it's a ScummVM savegame or not + char buffer[SAVEGAME_STR_SIZE + 1]; + readStream->read(buffer, SAVEGAME_STR_SIZE + 1); - if (Startup::_soundOk == 1 && Startup::_mode == 0) { - _sndDrvInfo.Vol2._d = _volume[0]; - _sndDrvInfo.Vol2._m = _volume[1]; - sndSetVolume(); - } + if (strncmp(buffer, SAVEGAME_STR, SAVEGAME_STR_SIZE + 1) != 0) { + // It's not, so rewind back to the start + readStream->seek(0); - if (! tiny) { // load sprites & pocket - while (readStream.pos() < readStream.size()) { - Sprite S(this, NULL); - S.sync(s); - - S._prev = S._next = NULL; - spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL) - : new Sprite(this, NULL); - if (spr == NULL) - error("No core"); - *spr = S; - _vga->_spareQ->append(spr); + if (header) + // Header wanted where none exists, so return false + return false; + } else { + // Found header + if (!readSavegameHeader(readStream, saveHeader)) { + delete readStream; + return false; } - for (i = 0; i < POCKET_NX; i++) { - register int r = _pocref[i]; - delete _pocket[i]; - _pocket[i] = (r < 0) ? NULL : _vga->_spareQ->locate(r); + if (header) { + *header = saveHeader; + delete readStream; + return true; } + + // Delete the thumbnail + delete saveHeader.thumbnail; + + // If we're loading the auto-save slot, load the name + if (slotNumber == 0) + strncpy(_usrFnam, saveHeader.saveName.c_str(), 8); } + + // Get in the savegame + syncGame(readStream, NULL, tiny); + + delete readStream; + return true; +} + +/** + * Returns true if a given savegame exists + */ +bool CGEEngine::savegameExists(int slotNumber) { + Common::String slotName = generateSaveName(slotNumber); + + Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(slotName); + bool result = saveFile != NULL; + delete saveFile; + return result; } +/** + * Support method that generates a savegame name + * @param slot Slot number + */ +Common::String CGEEngine::generateSaveName(int slot) { + return Common::String::format("%s.%03d", _targetName.c_str(), slot); +} void CGEEngine::saveSound() { + warning("STUB: CGEEngine::saveSound"); + /* Convert to saving any such needed data in ScummVM configuration file + CFile cfg(usrPath(progName(CFG_EXT)), WRI); if (!cfg._error) cfg.write(&_sndDrvInfo, sizeof(_sndDrvInfo) - sizeof(_sndDrvInfo.Vol2)); + */ +} + +void CGEEngine::saveGame(int slotNumber, const Common::String &desc) { + // Set up the serializer + Common::String slotName = generateSaveName(slotNumber); + Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(slotName); + + // Write out the ScummVM savegame header + SavegameHeader header; + header.saveName = desc; + header.version = CGE_SAVEGAME_VERSION; + writeSavegameHeader(saveFile, header); + + // Write out the data of the savegame + syncGame(NULL, saveFile); + + // Finish writing out game data + saveFile->finalize(); + delete saveFile; } +void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header) { + // Write out a savegame header + out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1); + + out->writeByte(CGE_SAVEGAME_VERSION); + + // Write savegame name + out->write(header.saveName.c_str(), header.saveName.size() + 1); + + // Get the active palette + uint8 thumbPalette[256 * 3]; + g_system->getPaletteManager()->grabPalette(thumbPalette, 0, 256); + + // Create a thumbnail and save it + Graphics::Surface *thumb = new Graphics::Surface(); + Graphics::Surface *s = _vga->_page[1]; + ::createThumbnail(thumb, (const byte *)s->pixels, SCR_WID, SCR_HIG, thumbPalette); + Graphics::saveThumbnail(*out, *thumb); + delete thumb; + + // Write out the save date/time + TimeDate td; + g_system->getTimeAndDate(td); + out->writeSint16LE(td.tm_year + 1900); + out->writeSint16LE(td.tm_mon + 1); + out->writeSint16LE(td.tm_mday); + out->writeSint16LE(td.tm_hour); + out->writeSint16LE(td.tm_min); +} -void CGEEngine::saveGame(Common::WriteStream *file) { +void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny) { Sprite *spr; int i; - for (i = 0; i < POCKET_NX; i++) { - register Sprite *s = _pocket[i]; - _pocref[i] = (s) ? s->_ref : -1; - } + Common::Serializer s(readStream, writeStream); - _volume[0] = _sndDrvInfo.Vol2._d; - _volume[1] = _sndDrvInfo.Vol2._m; + if (s.isSaving()) { + for (i = 0; i < POCKET_NX; i++) { + register Sprite *s = _pocket[i]; + _pocref[i] = (s) ? s->_ref : -1; + } - Common::Serializer s(NULL, file); + _volume[0] = _sndDrvInfo.Vol2._d; + _volume[1] = _sndDrvInfo.Vol2._m; + } // Synchronise header data syncHeader(s); - // Loop through saving the sprite data - for (spr = _vga->_spareQ->first(); spr; spr = spr->_next) { - if ((spr->_ref >= 1000) && !s.err()) - spr->sync(s); + if (s.isSaving()) { + // Loop through saving the sprite data + for (spr = _vga->_spareQ->first(); spr; spr = spr->_next) { + if ((spr->_ref >= 1000) && !s.err()) + spr->sync(s); + } + } else { + // Loading game + if (Startup::_core < CORE_HIG) + _music = false; + + if (Startup::_soundOk == 1 && Startup::_mode == 0) { + _sndDrvInfo.Vol2._d = _volume[0]; + _sndDrvInfo.Vol2._m = _volume[1]; + sndSetVolume(); + } + + if (! tiny) { // load sprites & pocket + while (readStream->pos() < readStream->size()) { + Sprite S(this, NULL); + S.sync(s); + + S._prev = S._next = NULL; + spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL) + : new Sprite(this, NULL); + if (spr == NULL) + error("No core"); + *spr = S; + _vga->_spareQ->append(spr); + } + + for (i = 0; i < POCKET_NX; i++) { + register int r = _pocref[i]; + delete _pocket[i]; + _pocket[i] = (r < 0) ? NULL : _vga->_spareQ->locate(r); + } + } } +} + +bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header) { + header.thumbnail = NULL; + + // Get the savegame version + header.version = in->readByte(); + if (header.version > CGE_SAVEGAME_VERSION) + return false; + + // Read in the string + header.saveName.clear(); + char ch; + while ((ch = (char)in->readByte()) != '\0') header.saveName += ch; + + // Get the thumbnail + header.thumbnail = new Graphics::Surface(); + if (!Graphics::loadThumbnail(*in, *header.thumbnail)) { + delete header.thumbnail; + header.thumbnail = NULL; + return false; + } + + // Read in save date/time + header.saveYear = in->readSint16LE(); + header.saveMonth = in->readSint16LE(); + header.saveDay = in->readSint16LE(); + header.saveHour = in->readSint16LE(); + header.saveMinutes = in->readSint16LE(); + + return true; - // Finish writing out game data - file->finalize(); } void CGEEngine::heroCover(int cvr) { @@ -483,9 +640,7 @@ void CGEEngine::qGame() { saveSound(); // Write out the user's progress - Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(Common::String(_usrFnam)); - saveGame(saveFile); - delete saveFile; + saveGame(0, _usrFnam); _vga->sunset(); _finis = true; @@ -773,6 +928,7 @@ void CGEEngine::takeName() { if (GetText::_ptr) SNPOST_(SNKILL, -1, 0, GetText::_ptr); else { + memset(_usrFnam, 0, 15); GetText *tn = new GetText(this, _text->getText(GETNAME_PROMPT), _usrFnam, 8); if (tn) { tn->setName(_text->getText(GETNAME_TITLE)); @@ -1290,25 +1446,15 @@ void CGEEngine::tick() { void CGEEngine::loadUser() { // set scene - if (Startup::_mode == 0) { // user .SVG file found - CFile cfile = CFile(usrPath(_usrFnam), REA, RCrypt); - loadGame(cfile); + if (Startup::_mode == 0) { + // user .SVG file found - load it from slot 0 + loadGame(0, NULL); } else { if (Startup::_mode == 1) { - SVG0FILE file = SVG0FILE(SVG0NAME); - loadGame(file); + // Load initial game state savegame + loadGame(-1, NULL); } else { - // TODO: I think this was only used by the original developers to create the initial - // game state savegame. Verify this is the case, and if so remove this block - loadScript(progName(INI_EXT)); - _music = true; - - Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving( - Common::String(SVG0NAME)); - saveGame(saveFile); - delete saveFile; - - error("Ok [%s]", SVG0NAME); + error("Creating setup savegames not supported"); } } loadScript(progName(IN0_EXT)); @@ -1533,17 +1679,22 @@ bool CGEEngine::showTitle(const char *name) { _vga->copyPage(0, 1); _vga->_showQ->append(_mouse); //Mouse.On(); - _heart->_enable = true; - for (takeName(); GetText::_ptr;) { - mainLoop(); - if (_eventManager->_quitFlag) - return false; - } - _heart->_enable = false; - if (_keyboard->last() == Enter && *_usrFnam) + + // For ScummVM, skip prompting for name if a savegame in slot 0 already exists + if (savegameExists(0)) { + strcpy(_usrFnam, "User"); usr_ok = true; - if (usr_ok) - strcat(_usrFnam, SVG_EXT); + } else { + _heart->_enable = true; + for (takeName(); GetText::_ptr;) { + mainLoop(); + if (_eventManager->_quitFlag) + return false; + } + _heart->_enable = false; + if (_keyboard->last() == Enter && *_usrFnam) + usr_ok = true; + } //Mouse.Off(); _vga->_showQ->clear(); _vga->copyPage(0, 2); @@ -1551,10 +1702,9 @@ bool CGEEngine::showTitle(const char *name) { } if (usr_ok && Startup::_mode == 0) { - const char *n = usrPath(_usrFnam); - if (CFile::exist(n)) { - CFile file = CFile(n, REA, RCrypt); - loadGame(file, true); // only system vars + if (savegameExists(0)) { + // Load the savegame + loadGame(0, NULL, true); // only system vars _vga->setColors(Vga::_sysPal, 64); _vga->update(); if (_flag[3]) { //flag FINIS -- cgit v1.2.3 From 00061bc5dd6492fcb3be9781b134f1928f69205b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 21:12:19 +1000 Subject: CGE: Added support for GMM save/load and launcher loading --- engines/cge/cge.cpp | 20 +++++++++-- engines/cge/cge.h | 13 +++++-- engines/cge/cge_main.cpp | 51 +++++++++++++++++++++------ engines/cge/detection.cpp | 90 +++++++++++++++++++---------------------------- 4 files changed, 105 insertions(+), 69 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 6924f0b14e..bb5b786330 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -126,6 +126,7 @@ void CGEEngine::setup() { for (int i = 0; i < 4; i++) _flag[i] = false; + _startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; } CGEEngine::~CGEEngine() { @@ -173,12 +174,25 @@ Common::Error CGEEngine::run() { // Setup necessary game objects setup(); - // Additional setup. - debug("CGEEngine::init"); - + // Run the game cge_main(); return Common::kNoError; } +bool CGEEngine::hasFeature(EngineFeature f) const { + return + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); +} + +bool CGEEngine::canLoadGameStateCurrently() { + return (_startupMode == 0) && _mouse->_active; +} + +bool CGEEngine::canSaveGameStateCurrently() { + return (_startupMode == 0) && _mouse->_active; +} + } // End of namespace CGE diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 2d67b2218a..851a1166ab 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -69,19 +69,26 @@ struct SavegameHeader { int totalFrames; }; +extern const char *SAVEGAME_STR; +#define SAVEGAME_STR_SIZE 11 + class CGEEngine : public Engine { private: uint32 _lastFrame; void tick(); void syncHeader(Common::Serializer &s); - bool readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header); - void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header); + static void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header); void syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny = false); bool savegameExists(int slotNumber); Common::String generateSaveName(int slot); public: CGEEngine(OSystem *syst, const ADGameDescription *gameDescription); ~CGEEngine(); + virtual bool hasFeature(EngineFeature f) const; + virtual bool canLoadGameStateCurrently(); + virtual bool canSaveGameStateCurrently(); + virtual Common::Error loadGameState(int slot); + virtual Common::Error saveGameState(int slot, const Common::String &desc); const ADGameDescription *_gameDescription; bool _isDemo; @@ -107,6 +114,7 @@ public: byte * _mini; BMP_PTR * _miniShp; BMP_PTR * _miniShpList; + int _startGameSlot; virtual Common::Error run(); GUI::Debugger *getDebugger() { @@ -149,6 +157,7 @@ public: void setDMA(); void mainLoop(); void saveGame(int slotNumber, const Common::String &desc); + static bool readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header); void switchMusic(); void selectPocket(int n); void expandSprite(Sprite *spr); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 3ea82e3099..f3b2784ca6 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -224,6 +224,24 @@ Common::String CGEEngine::generateSaveName(int slot) { return Common::String::format("%s.%03d", _targetName.c_str(), slot); } +Common::Error CGEEngine::loadGameState(int slot) { + // Clear current game activity + caveDown(); + + // Load the game + loadGame(slot, NULL, true); + caveUp(); + loadGame(slot, NULL); + + return Common::kNoError; +} + +Common::Error CGEEngine::saveGameState(int slot, const Common::String &desc) { + saveGame(slot, desc); + return Common::kNoError; +} + + void CGEEngine::saveSound() { warning("STUB: CGEEngine::saveSound"); /* Convert to saving any such needed data in ScummVM configuration file @@ -268,7 +286,7 @@ void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &he // Create a thumbnail and save it Graphics::Surface *thumb = new Graphics::Surface(); - Graphics::Surface *s = _vga->_page[1]; + Graphics::Surface *s = _vga->_page[0]; ::createThumbnail(thumb, (const byte *)s->pixels, SCR_WID, SCR_HIG, thumbPalette); Graphics::saveThumbnail(*out, *thumb); delete thumb; @@ -1451,8 +1469,8 @@ void CGEEngine::loadUser() { loadGame(0, NULL); } else { if (Startup::_mode == 1) { - // Load initial game state savegame - loadGame(-1, NULL); + // Load either initial game state savegame or launcher specified savegame + loadGame(_startGameSlot, NULL); } else { error("Creating setup savegames not supported"); } @@ -1681,7 +1699,7 @@ bool CGEEngine::showTitle(const char *name) { //Mouse.On(); // For ScummVM, skip prompting for name if a savegame in slot 0 already exists - if (savegameExists(0)) { + if ((_startGameSlot == -1) && savegameExists(0)) { strcpy(_usrFnam, "User"); usr_ok = true; } else { @@ -1755,18 +1773,29 @@ void CGEEngine::cge_main() { if (_music && Startup::_soundOk) loadMidi(0); - if (Startup::_mode < 2) - movie(LGO_EXT); - if (showTitle("WELCOME")) { - if ((!_isDemo) && (Startup::_mode == 1)) - movie("X02"); // intro + if (_startGameSlot != -1) { + // Starting up a savegame from the launcher + Startup::_mode++; runGame(); + _startupMode = 2; if (_flag[3]) // Flag FINIS movie("X03"); - } else - _vga->sunset(); + } else { + if (Startup::_mode < 2) + movie(LGO_EXT); + + if (showTitle("WELCOME")) { + if ((!_isDemo) && (Startup::_mode == 1)) + movie("X02"); // intro + runGame(); + _startupMode = 2; + if (_flag[3]) // Flag FINIS + movie("X03"); + } else + _vga->sunset(); + } } } // End of namespace CGE diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index 31bf629fcf..24fd3d2043 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -103,6 +103,8 @@ public: return "Soltys (c) 1994-1996 L.K. Avalon"; } + + virtual bool hasFeature(MetaEngineFeature f) const; virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; virtual int getMaximumSaveSlot() const; @@ -146,25 +148,26 @@ SaveStateList CGEMetaEngine::listSaves(const char *target) const { slotNum = atoi(filename->c_str() + filename->size() - 3); if (slotNum >= 0 && slotNum <= 99) { + Common::InSaveFile *file = saveFileMan->openForLoading(*filename); if (file) { - int32 version = file->readSint32BE(); - if (version != CGE_SAVEGAME_VERSION) { - delete file; - continue; - } - - // read name - uint16 nameSize = file->readUint16BE(); - if (nameSize >= 255) { - delete file; - continue; + CGE::SavegameHeader header; + + // Check to see if it's a ScummVM savegame or not + char buffer[SAVEGAME_STR_SIZE + 1]; + file->read(buffer, SAVEGAME_STR_SIZE + 1); + + if (!strncmp(buffer, CGE::SAVEGAME_STR, SAVEGAME_STR_SIZE + 1)) { + // Valid savegame + if (CGE::CGEEngine::readSavegameHeader(file, header)) { + saveList.push_back(SaveStateDescriptor(slotNum, header.saveName)); + delete header.thumbnail; + } + } else { + // Must be an original format savegame + saveList.push_back(SaveStateDescriptor(slotNum, "Unknown")); } - char name[256]; - file->read(name, nameSize); - name[nameSize] = 0; - saveList.push_back(SaveStateDescriptor(slotNum, name)); delete file; } } @@ -175,53 +178,34 @@ SaveStateList CGEMetaEngine::listSaves(const char *target) const { SaveStateDescriptor CGEMetaEngine::querySaveMetaInfos(const char *target, int slot) const { Common::String fileName = Common::String::format("%s.%03d", target, slot); - Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName); - - if (file) { - - int32 version = file->readSint32BE(); - if (version != CGE_SAVEGAME_VERSION) { - delete file; - return SaveStateDescriptor(); - } + Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName); + assert(f); - uint32 saveNameLength = file->readUint16BE(); - char saveName[256]; - file->read(saveName, saveNameLength); - saveName[saveNameLength] = 0; + CGE::SavegameHeader header; - SaveStateDescriptor desc(slot, saveName); + // Check to see if it's a ScummVM savegame or not + char buffer[SAVEGAME_STR_SIZE + 1]; + f->read(buffer, SAVEGAME_STR_SIZE + 1); - Graphics::Surface *thumbnail = new Graphics::Surface(); - assert(thumbnail); - if (!Graphics::loadThumbnail(*file, *thumbnail)) { - delete thumbnail; - thumbnail = 0; - } - desc.setThumbnail(thumbnail); + bool hasHeader = !strncmp(buffer, CGE::SAVEGAME_STR, SAVEGAME_STR_SIZE + 1) && + CGE::CGEEngine::readSavegameHeader(f, header); + delete f; + if (!hasHeader) { + // Original savegame perhaps? + SaveStateDescriptor desc(slot, "Unknown"); + return desc; + } else { + // Create the return descriptor + SaveStateDescriptor desc(slot, header.saveName); desc.setDeletableFlag(true); desc.setWriteProtectedFlag(false); + desc.setThumbnail(header.thumbnail); + desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay); + desc.setSaveTime(header.saveHour, header.saveMinutes); - uint32 saveDate = file->readUint32BE(); - uint16 saveTime = file->readUint16BE(); - - int day = (saveDate >> 24) & 0xFF; - int month = (saveDate >> 16) & 0xFF; - int year = saveDate & 0xFFFF; - - desc.setSaveDate(year, month, day); - - int hour = (saveTime >> 8) & 0xFF; - int minutes = saveTime & 0xFF; - - desc.setSaveTime(hour, minutes); - - delete file; return desc; } - - return SaveStateDescriptor(); } bool CGEMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { -- cgit v1.2.3 From e1df646ace3f0b487ef810a5489c3f0c2090da71 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 22:28:49 +1000 Subject: CGE: Set up a separate variable for the game tick speed, independent from frame rate --- engines/cge/cge.cpp | 1 + engines/cge/cge.h | 3 ++- engines/cge/cge_main.cpp | 25 ++++++++++++++++++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index bb5b786330..97712591fa 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -58,6 +58,7 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) void CGEEngine::setup() { // Initialise fields _lastFrame = 0; + _lastTick = 0; _hero = NULL; _shadow = NULL; _miniCave = NULL; diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 851a1166ab..5187e57c0f 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -74,7 +74,7 @@ extern const char *SAVEGAME_STR; class CGEEngine : public Engine { private: - uint32 _lastFrame; + uint32 _lastFrame, _lastTick; void tick(); void syncHeader(Common::Serializer &s); static void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header); @@ -156,6 +156,7 @@ public: void setIRQ(); void setDMA(); void mainLoop(); + void handleFrame(); void saveGame(int slotNumber, const Common::String &desc); static bool readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header); void switchMusic(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index f3b2784ca6..ad31a5c1e6 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1411,6 +1411,7 @@ void CGEEngine::loadScript(const char *fname) { } #define GAME_FRAME_DELAY (1000 / 50) +#define GAME_TICK_DELAY (1000 / 62) void CGEEngine::mainLoop() { sayDebug(); @@ -1432,23 +1433,37 @@ void CGEEngine::mainLoop() { _snail_->runCom(); _snail->runCom(); + // Handle a delay between game frames + handleFrame(); + + // Handle any pending events + _eventManager->poll(); +} + +void CGEEngine::handleFrame() { // Game frame delay uint32 millis = g_system->getMillis(); while (!_eventManager->_quitFlag && (millis < (_lastFrame + GAME_FRAME_DELAY))) { // Handle any pending events _eventManager->poll(); + if (millis >= (_lastTick + GAME_TICK_DELAY)) { + // Dispatch the tick to any active objects + tick(); + _lastTick = millis; + } + // Slight delay g_system->delayMillis(10); millis = g_system->getMillis(); } _lastFrame = millis; - // Dispatch the tick to any active objects - tick(); - - // Handle any pending events - _eventManager->poll(); + if (millis >= (_lastTick + GAME_TICK_DELAY)) { + // Dispatch the tick to any active objects + tick(); + _lastTick = millis; + } } void CGEEngine::tick() { -- cgit v1.2.3 From 8aa4f739af014303cc6a0fb90f13c22a1f77d33f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jul 2011 18:05:57 +0200 Subject: CGE: Add debug channels (WIP) --- engines/cge/bitmap.cpp | 54 +++++++++++++++++++++++++++++++------------- engines/cge/bitmap.h | 4 ++-- engines/cge/btfile.cpp | 22 +++++++++++------- engines/cge/cfile.cpp | 58 ++++++++++++++++++++++++++++++++++++++---------- engines/cge/cfile.h | 4 ++-- engines/cge/cge.cpp | 10 +++++++-- engines/cge/cge.h | 6 ++++- engines/cge/cge_main.cpp | 38 +++++++++++++++++++++++++------ engines/cge/general.cpp | 3 ++- engines/cge/vga13h.cpp | 8 ++++++- engines/cge/vol.cpp | 20 ++++++++++++++++- engines/cge/vol.h | 4 ++-- 12 files changed, 177 insertions(+), 54 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 8474924366..f280f61e3e 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -32,6 +32,8 @@ #include "cge/cfile.h" #include "cge/vga13h.h" #include "common/system.h" +#include "common/debug.h" +#include "common/debug-channels.h" namespace CGE { @@ -47,6 +49,8 @@ void Bitmap::deinit() { #pragma argsused Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { + debugC(1, kDebugBitmap, "Bitmap::Bitmap(%s, %s)", fname, rem ? "true" : "false"); + char pat[MAXPATH]; forceExt(pat, fname, ".VBM"); @@ -79,6 +83,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL), _map(0) { + debugC(1, kDebugBitmap, "Bitmap::Bitmap(%d, %d, map)", w, h); if (map) code(); } @@ -92,6 +97,8 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) _h(h), _m(NULL), _map(0) { + debugC(1, kDebugBitmap, "Bitmap::Bitmap(%d, %d, %d)", w, h, fill); + uint16 dsiz = _w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap uint16 psiz = _h * lsiz; // - last gape, but + plane trailer @@ -116,20 +123,21 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) Common::copy(v, v + psiz, destP); HideDesc *b = (HideDesc *)(v + 4 * psiz); - b->skip = (SCR_WID - _w) >> 2; - b->hide = _w >> 2; + b->_skip = (SCR_WID - _w) >> 2; + b->_hide = _w >> 2; // Replicate across the entire table for (HideDesc *hdP = b + 1; hdP < (b + _h); ++hdP) *hdP = *b; - b->skip = 0; // fix the first entry + b->_skip = 0; // fix the first entry _v = v; _b = b; } Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), _map(0) { + debugC(1, kDebugBitmap, "Bitmap::Bitmap(bmp)"); uint8 *v0 = bmp._v; if (v0) { uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); @@ -144,12 +152,16 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), Bitmap::~Bitmap() { + debugC(6, kDebugBitmap, "Bitmap::~Bitmap()"); + free(_m); delete[] _v; } Bitmap &Bitmap::operator = (const Bitmap &bmp) { + debugC(1, kDebugBitmap, "&Bitmap::operator ="); + uint8 *v0 = bmp._v; _w = bmp._w; _h = bmp._h; @@ -172,6 +184,8 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { uint16 Bitmap::moveVmap(uint8 *buf) { + debugC(1, kDebugBitmap, "Bitmap::moveVmap(buf)"); + if (_v) { uint16 vsiz = (uint8 *)_b - (uint8 *)_v; uint16 siz = vsiz + _h * sizeof(HideDesc); @@ -185,6 +199,8 @@ uint16 Bitmap::moveVmap(uint8 *buf) { BMP_PTR Bitmap::code() { + debugC(1, kDebugBitmap, "Bitmap::code()"); + if (!_m) return false; @@ -202,8 +218,8 @@ BMP_PTR Bitmap::code() { if (_v) { // 2nd pass - fill the hide table for (i = 0; i < _h; i++) { - _b[i].skip = 0xFFFF; - _b[i].hide = 0x0000; + _b[i]._skip = 0xFFFF; + _b[i]._hide = 0x0000; } } for (bpl = 0; bpl < 4; bpl++) { // once per each bitplane @@ -217,11 +233,11 @@ BMP_PTR Bitmap::code() { for (j = bpl; j < _w; j += 4) { pix = bm[j]; if (_v && pix != TRANS) { - if (j < _b[i].skip) - _b[i].skip = j; + if (j < _b[i]._skip) + _b[i]._skip = j; - if (j >= _b[i].hide) - _b[i].hide = j + 1; + if (j >= _b[i]._hide) + _b[i]._hide = j + 1; } if ((pix == TRANS) != skip || cnt >= 0x3FF0) { // end of block cnt |= (skip) ? SKP : CPY; @@ -282,14 +298,14 @@ BMP_PTR Bitmap::code() { } cnt = 0; for (i = 0; i < _h; i++) { - if (_b[i].skip == 0xFFFF) { // whole line is skipped - _b[i].skip = (cnt + SCR_WID) >> 2; + if (_b[i]._skip == 0xFFFF) { // whole line is skipped + _b[i]._skip = (cnt + SCR_WID) >> 2; cnt = 0; } else { - uint16 s = _b[i].skip & ~3; - uint16 h = (_b[i].hide + 3) & ~3; - _b[i].skip = (cnt + s) >> 2; - _b[i].hide = (h - s) >> 2; + uint16 s = _b[i]._skip & ~3; + uint16 h = (_b[i]._hide + 3) & ~3; + _b[i]._skip = (cnt + s) >> 2; + _b[i]._hide = (h - s) >> 2; cnt = SCR_WID - h; } } @@ -299,6 +315,8 @@ BMP_PTR Bitmap::code() { bool Bitmap::solidAt(int16 x, int16 y) { + debugC(6, kDebugBitmap, "Bitmap::solidAt(%d, %d)", x, y); + uint8 *m; uint16 r, n, n0; @@ -360,6 +378,8 @@ bool Bitmap::solidAt(int16 x, int16 y) { bool Bitmap::saveVBM(XFile *f) { + debugC(1, kDebugBitmap, "Bitmap::saveVBM(f)"); + uint16 p = (_pal != NULL), n = ((uint16)(((uint8 *)_b) - _v)) + _h * sizeof(HideDesc); if (f->_error == 0) @@ -386,6 +406,8 @@ bool Bitmap::saveVBM(XFile *f) { bool Bitmap::loadVBM(XFile *f) { + debugC(5, kDebugBitmap, "Bitmap::loadVBM(f)"); + uint16 p = 0, n = 0; if (f->_error == 0) f->read((uint8 *)&p, sizeof(p)); @@ -427,6 +449,8 @@ bool Bitmap::loadVBM(XFile *f) { } bool Bitmap::loadBMP(XFile *f) { + debugC(1, kDebugBitmap, "Bitmap::loadBMP(f)"); + struct { char BM[2]; union { int16 len; int32 len_; }; diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 3fdb673396..2728e27303 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -53,8 +53,8 @@ struct Bgr4 { struct HideDesc { - uint16 skip; - uint16 hide; + uint16 _skip; + uint16 _hide; }; #include "common/pack-end.h" diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index eda18ebaaf..68d3fe40e3 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -28,19 +28,16 @@ #include "cge/btfile.h" #include "common/system.h" #include "common/str.h" +#include "cge/cge.h" +#include "common/debug.h" +#include "common/debug-channels.h" namespace CGE { -#ifndef BT_SIZE -#define BT_SIZE K(1) -#endif - -#ifndef BT_KEYLEN -#define BT_KEYLEN 13 -#endif - BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) : IoHand(name, mode, crpt) { + debugC(1, kDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode); + for (int i = 0; i < BT_LEVELS; i++) { _buff[i]._page = new BtPage; _buff[i]._pgNo = BT_NONE; @@ -53,6 +50,7 @@ BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) BtFile::~BtFile() { + debugC(1, kDebugFile, "BtFile::~BtFile()"); for (int i = 0; i < BT_LEVELS; i++) { putPage(i, false); delete _buff[i]._page; @@ -61,6 +59,8 @@ BtFile::~BtFile() { void BtFile::putPage(int lev, bool hard) { + debugC(1, kDebugFile, "BtFile::putPage(%d, %s)", lev, hard ? "true" : "false"); + if (hard || _buff[lev]._updt) { seek(_buff[lev]._pgNo * sizeof(BtPage)); write((uint8 *) _buff[lev]._page, sizeof(BtPage)); @@ -70,6 +70,8 @@ void BtFile::putPage(int lev, bool hard) { BtPage *BtFile::getPage(int lev, uint16 pgn) { + debugC(1, kDebugFile, "BtFile::getPage(%d, %d)", lev, pgn); + if (_buff[lev]._pgNo != pgn) { int32 pos = pgn * sizeof(BtPage); putPage(lev, false); @@ -90,6 +92,8 @@ BtPage *BtFile::getPage(int lev, uint16 pgn) { } BtKeypack *BtFile::find(const char *key) { + debugC(1, kDebugFile, "BtFile::find(%s)", key); + int lev = 0; uint16 nxt = BT_ROOT; while (!_error) { @@ -125,6 +129,8 @@ int keycomp(const void *k1, const void *k2) { void BtFile::make(BtKeypack *keypack, uint16 count) { + debugC(1, kDebugFile, "BtFile::make(keypack, %d)", count); + #if BT_LEVELS != 2 #error This tiny BTREE implementation works with exactly 2 levels! #endif diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index f0a0ef3b8f..af29ec5df7 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -27,6 +27,9 @@ #include "cge/cfile.h" #include "common/system.h" +#include "cge/cge.h" +#include "common/debug.h" +#include "common/debug-channels.h" namespace CGE { @@ -35,6 +38,8 @@ IoBuf::IoBuf(IOMODE mode, CRYPT *crpt) _bufMark(0), _ptr(0), _lim(0) { + debugC(1, kDebugFile, "IoBuf::IoBuf(%d, crpt)", mode); + _buff = farnew(uint8, IOBUF_SIZE); if (_buff == NULL) error("No core for I/O"); @@ -46,26 +51,34 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) _bufMark(0), _ptr(0), _lim(0) { + debugC(1, kDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode); + _buff = farnew(uint8, IOBUF_SIZE); if (_buff == NULL) error("No core for I/O [%s]", name); } IoBuf::~IoBuf() { + debugC(6, kDebugFile, "IoBuf::~IoBuf()"); + if (_mode > REA) - writeBuff(); + writeBuf(); free(_buff); } -void IoBuf::readBuff() { +void IoBuf::readBuf() { + debugC(4, kDebugFile, "IoBuf::readBuf()"); + _bufMark = IoHand::mark(); _lim = IoHand::read(_buff, IOBUF_SIZE); _ptr = 0; } -void IoBuf::writeBuff() { +void IoBuf::writeBuf() { + debugC(4, kDebugFile, "IoBuf::writeBuf()"); + if (_lim) { IoHand::write(_buff, _lim); _bufMark = IoHand::mark(); @@ -75,10 +88,12 @@ void IoBuf::writeBuff() { uint16 IoBuf::read(void *buf, uint16 len) { + debugC(4, kDebugFile, "IoBuf::read(buf, %d)", len); + uint16 total = 0; while (len) { if (_ptr >= _lim) - readBuff(); + readBuf(); uint16 n = _lim - _ptr; if (n) { if (len < n) @@ -96,11 +111,13 @@ uint16 IoBuf::read(void *buf, uint16 len) { uint16 IoBuf::read(uint8 *buf) { + debugC(3, kDebugFile, "IoBuf::read(buf)"); + uint16 total = 0; while (total < LINE_MAX - 2) { if (_ptr >= _lim) - readBuff(); + readBuf(); uint8 *p = _buff + _ptr; uint16 n = _lim - _ptr; if (n) { @@ -126,7 +143,7 @@ uint16 IoBuf::read(uint8 *buf) { *(buf++) = '\n'; total++; if (_ptr >= _lim) - readBuff(); + readBuf(); if (_ptr < _lim) if (_buff[_ptr] == '\n') ++_ptr; @@ -141,6 +158,8 @@ uint16 IoBuf::read(uint8 *buf) { uint16 IoBuf::write(void *buf, uint16 len) { + debugC(1, kDebugFile, "IoBuf::write(buf, %d)", len); + uint16 tot = 0; while (len) { uint16 n = IOBUF_SIZE - _lim; @@ -153,13 +172,15 @@ uint16 IoBuf::write(void *buf, uint16 len) { buf = (uint8 *)buf + n; tot += n; } else - writeBuff(); + writeBuf(); } return tot; } uint16 IoBuf::write(uint8 *buf) { + debugC(1, kDebugFile, "IoBuf::write(buf)"); + uint16 len = 0; if (buf) { len = strlen((const char *) buf); @@ -178,8 +199,10 @@ uint16 IoBuf::write(uint8 *buf) { int IoBuf::read() { + debugC(1, kDebugFile, "IoBuf::read()"); + if (_ptr >= _lim) { - readBuff(); + readBuf(); if (_lim == 0) return -1; } @@ -188,8 +211,10 @@ int IoBuf::read() { void IoBuf::write(uint8 b) { + debugC(1, kDebugFile, "IoBuf::write(%d)", b); + if (_lim >= IOBUF_SIZE) - writeBuff(); + writeBuf(); _buff[_lim++] = b; } @@ -199,6 +224,7 @@ uint16 CFile::_maxLineLen = LINE_MAX; CFile::CFile(const char *name, IOMODE mode, CRYPT *crpt) : IoBuf(name, mode, crpt) { + debugC(1, kDebugFile, "CFile::CFile(%s, %d, crpt)", name, mode); } @@ -207,8 +233,10 @@ CFile::~CFile() { void CFile::flush() { + debugC(1, kDebugFile, "CFile::flush()"); + if (_mode > REA) - writeBuff(); + writeBuf(); else _lim = 0; @@ -222,17 +250,21 @@ void CFile::flush() { long CFile::mark() { + debugC(5, kDebugFile, "CFile::mark()"); + return _bufMark + ((_mode > REA) ? _lim : _ptr); } long CFile::seek(long pos) { + debugC(1, kDebugFile, "CFile::seek(%ld)", pos); + if (pos >= _bufMark && pos < _bufMark + _lim) { ((_mode == REA) ? _ptr : _lim) = (uint16)(pos - _bufMark); return pos; } else { if (_mode > REA) - writeBuff(); + writeBuf(); else _lim = 0; @@ -243,11 +275,13 @@ long CFile::seek(long pos) { void CFile::append(CFile &f) { + debugC(1, kDebugFile, "CFile::append(f)"); + seek(size()); if (f._error == 0) { while (true) { if ((_lim = f.IoHand::read(_buff, IOBUF_SIZE)) == IOBUF_SIZE) - writeBuff(); + writeBuf(); else break; if ((_error = f._error) != 0) diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index bf90633dd0..490e120afa 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -49,8 +49,8 @@ protected: long _bufMark; uint16 _seed; CRYPT *_crypt; - virtual void readBuff(); - virtual void writeBuff(); + virtual void readBuf(); + virtual void writeBuf(); public: IoBuf(IOMODE mode, CRYPT *crpt = NULL); IoBuf(const char *name, IOMODE mode, CRYPT *crpt = NULL); diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 97712591fa..7e8c8377a8 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -45,6 +45,9 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) // Debug/console setup DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); + DebugMan.addDebugChannel(kDebugBitmap, "bitmap", "CGE Bitmap debug channel"); + DebugMan.addDebugChannel(kDebugFile, "file", "CGE IO debug channel"); + DebugMan.addDebugChannel(kDebugEngine, "engine", "CGE Engine debug channel"); _isDemo = _gameDescription->flags & ADGF_DEMO; _startupMode = 1; @@ -56,6 +59,8 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) } void CGEEngine::setup() { + debugC(1, kDebugEngine, "CGEEngine::setup()"); + // Initialise fields _lastFrame = 0; _lastTick = 0; @@ -131,7 +136,7 @@ void CGEEngine::setup() { } CGEEngine::~CGEEngine() { - debug("CGEEngine::~CGEEngine"); + debugC(1, kDebugEngine, "CGEEngine::~CGEEngine()"); // Call classes with static members to clear them up Talk::deinit(); @@ -169,12 +174,13 @@ CGEEngine::~CGEEngine() { } Common::Error CGEEngine::run() { + debugC(1, kDebugEngine, "CGEEngine::run()"); + // Initialize graphics using following: initGraphics(320, 200, false); // Setup necessary game objects setup(); - // Run the game cge_main(); diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 5187e57c0f..e8451454a4 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -44,7 +44,10 @@ class Sprite; // our engine debug channels enum { - kCGEDebug = 1 << 0 + kCGEDebug = 1 << 0, + kDebugBitmap = 1 << 1, + kDebugFile = 1 << 2, + kDebugEngine = 1 << 3 }; enum SnList { @@ -184,6 +187,7 @@ public: void nextStep(); void switchDebug(); void miniStep(int stp); + void AltCtrlDel(); void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index ad31a5c1e6..34768e42a4 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -104,6 +104,8 @@ Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; extern Dac _stdPal[58]; void CGEEngine::syncHeader(Common::Serializer &s) { + debugC(1, kDebugEngine, "CGEEngine::syncHeader(s)"); + int i; s.syncAsUint16LE(_now); @@ -142,6 +144,8 @@ void CGEEngine::syncHeader(Common::Serializer &s) { } bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { + debugC(1, kDebugEngine, "CGEEngine::loadgame(file, %s)", tiny ? "true" : "false"); + Common::MemoryReadStream *readStream; SavegameHeader saveHeader; @@ -358,6 +362,8 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt } } } + debugC(1, kDebugEngine, "CGEEngine::saveSound()"); + } bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header) { @@ -393,10 +399,14 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade } void CGEEngine::heroCover(int cvr) { + debugC(1, kDebugEngine, "CGEEngine::heroCover(%d)", cvr); + SNPOST(SNCOVER, 1, cvr, NULL); } void CGEEngine::trouble(int seq, int txt) { + debugC(1, kDebugEngine, "CGEEngine::trouble(%d, %d)", seq, txt); + _hero->park(); SNPOST(SNWAIT, -1, -1, _hero); SNPOST(SNSEQ, -1, seq, _hero); @@ -406,14 +416,20 @@ void CGEEngine::trouble(int seq, int txt) { } void CGEEngine::offUse() { + debugC(1, kDebugEngine, "CGEEngine::offUse()"); + trouble(OFF_USE, OFF_USE_TEXT + new_random(_offUseCount)); } void CGEEngine::tooFar() { + debugC(1, kDebugEngine, "CGEEngine::tooFar()"); + trouble(TOO_FAR, TOO_FAR_TEXT); } void CGEEngine::loadHeroXY() { + debugC(1, kDebugEngine, "CGEEngine::loadHeroXY()"); + INI_FILE cf(progName(".HXY")); memset(_heroXY, 0, sizeof(_heroXY)); if (!cf._error) @@ -421,6 +437,8 @@ void CGEEngine::loadHeroXY() { } void CGEEngine::loadMapping() { + debugC(1, kDebugEngine, "CGEEngine::loadMapping()"); + if (_now <= CAVE_MAX) { INI_FILE cf(progName(".TAB")); if (!cf._error) { @@ -462,6 +480,8 @@ void SQUARE::touch(uint16 mask, int x, int y) { void CGEEngine::setMapBrick(int x, int z) { + debugC(1, kDebugEngine, "CGEEngine::setMapBrick(%d, %d)", x, z); + SQUARE *s = new SQUARE(this); if (s) { static char n[] = "00:00"; @@ -474,22 +494,24 @@ void CGEEngine::setMapBrick(int x, int z) { } } -//static void switchDebug(); -//static void pullSprite(); -//static void NextStep(); - void CGEEngine::keyClick() { + debugC(1, kDebugEngine, "CGEEngine::keyClick()"); + SNPOST_(SNSOUND, -1, 5, NULL); } void CGEEngine::resetQSwitch() { + debugC(1, kDebugEngine, "CGEEngine::resetQSwitch()"); + SNPOST_(SNSEQ, 123, 0, NULL); keyClick(); } void CGEEngine::quit() { + debugC(1, kDebugEngine, "CGEEngine::quit()"); + static Choice QuitMenu[] = { { NULL, &CGEEngine::startCountDown }, { NULL, &CGEEngine::resetQSwitch }, @@ -511,8 +533,10 @@ void CGEEngine::quit() { } -static void AltCtrlDel() { - SNPOST_(SNSAY, -1, A_C_D_TEXT, _hero); +void CGEEngine::AltCtrlDel() { + debugC(1, kDebugEngine, "CGEEngine::setup()"); + + SNPOST_(SNSAY, -1, A_C_D_TEXT, _hero); } void CGEEngine::miniStep(int stp) { @@ -716,7 +740,7 @@ void System::touch(uint16 mask, int x, int y) { switch (x) { case Del: if (_keyboard->_key[ALT] && _keyboard->_key[CTRL]) - AltCtrlDel(); + _vm->AltCtrlDel(); else _vm->killSprite(); break; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 4ca1ef57ca..25b7cc25a5 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -238,7 +238,8 @@ uint16 IoHand::read(void *buf, uint16 len) { } uint16 IoHand::write(void *buf, uint16 len) { - error("IOHAND::Write not supported"); + warning("IOHAND::Write not supported"); + return 0; /* if (len) { if (Mode == REA || Handle < 0) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index a7b9d8c080..ca6a9e3bdd 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1213,6 +1213,8 @@ void Vga::copyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- void Bitmap::xShow(int16 x, int16 y) { + debugC(4, kDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); + const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); byte *lookupTable = _m; @@ -1264,6 +1266,8 @@ void Bitmap::xShow(int16 x, int16 y) { void Bitmap::show(int16 x, int16 y) { + debugC(5, kDebugBitmap, "Bitmap::show(%d, %d)", x, y); + const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1326,6 +1330,8 @@ void Bitmap::show(int16 x, int16 y) { void Bitmap::hide(int16 x, int16 y) { + debugC(5, kDebugBitmap, "Bitmap::hide(%d, %d)", x, y); + for (int yp = y; yp < y + _h; yp++) { const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); @@ -1378,4 +1384,4 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { _flags._kill = false; } -} // End of namespace CGE \ No newline at end of file +} // End of namespace CGE diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 04a9189682..cff735abf5 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -28,6 +28,9 @@ #include "cge/vol.h" #include "common/system.h" #include "common/str.h" +#include "cge/cge.h" +#include "common/debug.h" +#include "common/debug-channels.h" namespace CGE { @@ -44,11 +47,14 @@ Dat::Dat(): _file(DAT_NAME, REA, CRP) #endif { + debugC(1, kDebugFile, "Dat::Dat()"); } /*-----------------------------------------------------------------------*/ void VFile::init() { + debugC(1, kDebugFile, "VFile::init()"); + _dat = new Dat(); #ifdef VOL_UPD _cat = new BtFile(CAT_NAME, UPD, CRP); @@ -66,6 +72,8 @@ void VFile::deinit() { VFile::VFile(const char *name, IOMODE mode) : IoBuf(mode) { + debugC(3, kDebugFile, "VFile::VFile(%s, %d)", name, mode); + if (mode == REA) { if (_dat->_file._error || _cat->_error) error("Bad volume data"); @@ -88,11 +96,15 @@ VFile::~VFile() { bool VFile::exist(const char *name) { + debugC(1, kDebugFile, "VFile::exist(%s)", name); + return scumm_stricmp(_cat->find(name)->_key, name) == 0; } -void VFile::readBuff() { +void VFile::readBuf() { + debugC(3, kDebugFile, "VFile::readBuf()"); + if (_recent != this) { _dat->_file.seek(_bufMark + _lim); _recent = this; @@ -106,14 +118,20 @@ void VFile::readBuff() { } long VFile::mark() { + debugC(5, kDebugFile, "VFile::mark()"); + return (_bufMark + _ptr) - _begMark; } long VFile::size() { + debugC(1, kDebugFile, "VFile::size()"); + return _endMark - _begMark; } long VFile::seek(long pos) { + debugC(1, kDebugFile, "VFile::seel(%ld)", pos); + _recent = NULL; _lim = 0; return (_bufMark = _begMark + pos); diff --git a/engines/cge/vol.h b/engines/cge/vol.h index 8ed33d0ab4..bbf3237721 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -70,8 +70,8 @@ private: long _begMark; long _endMark; - void readBuff(); - void writeBuff() { } + void readBuf(); + void writeBuf() { } void make(const char *fspec); public: VFile(const char *name, IOMODE mode = REA); -- cgit v1.2.3 From f884e578669ff85365b1e838ee8671ddac8ab112 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jul 2011 21:47:57 +0200 Subject: CGE: Remove a bunch of useless sound related menus --- engines/cge/cge_main.cpp | 2 +- engines/cge/config.cpp | 233 ----------------------------------------------- engines/cge/config.h | 3 - engines/cge/snail.cpp | 2 +- 4 files changed, 2 insertions(+), 238 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 34768e42a4..cb060891cf 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1702,7 +1702,7 @@ bool CGEEngine::showTitle(const char *name) { _vga->_showQ->append(_mouse); _heart->_enable = true; _mouse->on(); - for (selectSound(); !_snail->idle() || Vmenu::_addr;) { + for (; !_snail->idle() || Vmenu::_addr;) { mainLoop(); if (_eventManager->_quitFlag) return false; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 2941d36d2c..f8d5431ef0 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -33,152 +33,8 @@ namespace CGE { -/* - 51=wska§ typ posiadanej karty d¦wi‘kowej - 52=wybierz numer portu dla karty d¦wi‘kowej - 53=wybierz numer przerwania dla karty d¦wi‘kowej - 54=wybierz numer kana’u DMA dla karty d¦wi‘kowej - 55=wybierz numer portu dla General MIDI - 55=konfiguracja karty d¦wi‘kowej -*/ -#define STYPE_TEXT 51 -#define SPORT_TEXT 52 -#define SIRQ_TEXT 53 -#define SDMA_TEXT 54 -#define MPORT_TEXT 55 #define MENU_TEXT 56 -#define NONE_TEXT 60 -#define SB_TEXT 61 -#define SBM_TEXT 62 -#define GUS_TEXT 63 -#define GUSM_TEXT 64 -#define MIDI_TEXT 65 -#define AUTO_TEXT 66 - -#define DETECT 0xFFFF - - -static int DevName[] = { - NONE_TEXT, SB_TEXT, SBM_TEXT, GUS_TEXT, GUSM_TEXT, - MIDI_TEXT, AUTO_TEXT -}; - -static Choice DevMenu[] = { - { NULL, &CGEEngine::NONE }, - { NULL, &CGEEngine::SB }, - { NULL, &CGEEngine::SBM }, - { NULL, &CGEEngine::GUS }, - { NULL, &CGEEngine::GUSM }, - { NULL, &CGEEngine::MIDI }, - { NULL, &CGEEngine::AUTO }, - { NULL, NULL } -}; - - -static Choice DigiPorts[] = { - { " 210h", &CGEEngine::setPortD }, - { " 220h", &CGEEngine::setPortD }, - { " 230h", &CGEEngine::setPortD }, - { " 240h", &CGEEngine::setPortD }, - { " 250h", &CGEEngine::setPortD }, - { " 260h", &CGEEngine::setPortD }, - { "AUTO ", &CGEEngine::setPortD }, - { NULL, NULL } -}; - -static Choice MIDIPorts[] = { - { " 220h", &CGEEngine::setPortM }, - { " 230h", &CGEEngine::setPortM }, - { " 240h", &CGEEngine::setPortM }, - { " 250h", &CGEEngine::setPortM }, - { " 300h", &CGEEngine::setPortM }, - { " 320h", &CGEEngine::setPortM }, - { " 330h", &CGEEngine::setPortM }, - { " 340h", &CGEEngine::setPortM }, - { " 350h", &CGEEngine::setPortM }, - { " 360h", &CGEEngine::setPortM }, - { "AUTO ", &CGEEngine::setPortM }, - { NULL, NULL } -}; - -static Choice BlsterIRQ[] = { - { "IRQ 2", &CGEEngine::setIRQ }, - { "IRQ 5", &CGEEngine::setIRQ }, - { "IRQ 7", &CGEEngine::setIRQ }, - { "IRQ 10", &CGEEngine::setIRQ }, - { "AUTO ", &CGEEngine::setIRQ }, - { NULL, NULL } -}; - -static Choice GravisIRQ[] = { - { "IRQ 2", &CGEEngine::setIRQ }, - { "IRQ 5", &CGEEngine::setIRQ }, - { "IRQ 7", &CGEEngine::setIRQ }, - { "IRQ 11", &CGEEngine::setIRQ }, - { "IRQ 12", &CGEEngine::setIRQ }, - { "IRQ 15", &CGEEngine::setIRQ }, - { "AUTO ", &CGEEngine::setIRQ }, - { NULL, NULL } -}; - -static Choice GravisDMA[] = { - { "DMA 1", &CGEEngine::setDMA }, - { "DMA 3", &CGEEngine::setDMA }, - { "DMA 5", &CGEEngine::setDMA }, - { "DMA 6", &CGEEngine::setDMA }, - { "DMA 7", &CGEEngine::setDMA }, - { "AUTO ", &CGEEngine::setDMA }, - { NULL, NULL } -}; - -static Choice BlsterDMA[] = { - { "DMA 0", &CGEEngine::setDMA }, - { "DMA 1", &CGEEngine::setDMA }, - { "DMA 3", &CGEEngine::setDMA }, - { "AUTO ", &CGEEngine::setDMA }, - { NULL, NULL } -}; - - -void CGEEngine::selectSound() { - int i; - _sound.close(); - if (Vmenu::_addr) - SNPOST_(SNKILL, -1, 0, Vmenu::_addr); - inf(_text->getText(STYPE_TEXT)); - _talk->gotoxy(_talk->_x, FONT_HIG / 2); - for (i = 0; i < (int)ArrayCount(DevName); i++) - DevMenu[i]._text = _text->getText(DevName[i]); - (new Vmenu(this, DevMenu, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); -} - - -static void reset() { - _sndDrvInfo._dBase = _sndDrvInfo._dIrq = _sndDrvInfo._dDma = _sndDrvInfo._mBase = DETECT; -} - - -static uint16 deco(const char *str, uint16(*dco)(const char *)) { - while (*str && ! IsDigit(*str)) - ++str; - if (*str) - return dco(str); - else - return DETECT; -} - - -static uint16 ddeco(const char *str) { - return deco(str, atow); -} - - -static uint16 xdeco(const char *str) { - return deco(str, xtow); -} - - static Choice *_cho; static int _hlp; @@ -188,93 +44,4 @@ void CGEEngine::snSelect() { (new Vmenu(this, _cho, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); } - -static void select(Choice *cho, int hlp) { - _cho = cho; - _hlp = hlp; - SNPOST2(SNEXEC, -1, 0, kSnSelect); -} - - -void CGEEngine::NONE() { - _sndDrvInfo._dDev = DEV_QUIET; - _sndDrvInfo._mDev = DEV_QUIET; - _sound.open(); -} - - -void CGEEngine::SB() { - _sndDrvInfo._dDev = DEV_SB; - _sndDrvInfo._mDev = DEV_SB; - reset(); - select(DigiPorts, SPORT_TEXT); -} - - -void CGEEngine::SBM() { - _sndDrvInfo._dDev = DEV_SB; - _sndDrvInfo._mDev = DEV_GM; - reset(); - select(DigiPorts, SPORT_TEXT); -} - - -void CGEEngine::GUS() { - _sndDrvInfo._dDev = DEV_GUS; - _sndDrvInfo._mDev = DEV_GUS; - reset(); - select(DigiPorts, SPORT_TEXT); -} - - -void CGEEngine::GUSM() { - _sndDrvInfo._dDev = DEV_GUS; - _sndDrvInfo._mDev = DEV_GM; - reset(); - select(DigiPorts, SPORT_TEXT); -} - - -void CGEEngine::MIDI() { - _sndDrvInfo._dDev = DEV_QUIET; - _sndDrvInfo._mDev = DEV_GM; - _sndDrvInfo._mBase = DETECT; - select(MIDIPorts, MPORT_TEXT); -} - - -void CGEEngine::AUTO() { - _sndDrvInfo._dDev = DEV_AUTO; - _sndDrvInfo._mDev = DEV_AUTO; - reset(); - _sound.open(); -} - - -void CGEEngine::setPortD() { - _sndDrvInfo._dBase = xdeco(DigiPorts[Vmenu::_recent]._text); - select((_sndDrvInfo._dDev == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT); -} - - -void CGEEngine::setPortM() { - _sndDrvInfo._mBase = xdeco(MIDIPorts[Vmenu::_recent]._text); - _sound.open(); -} - - -void CGEEngine::setIRQ() { - _sndDrvInfo._dIrq = ddeco(((_sndDrvInfo._dDev == DEV_SB) ? BlsterIRQ : GravisIRQ)[Vmenu::_recent]._text); - select((_sndDrvInfo._dDev == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT); -} - - -void CGEEngine::setDMA() { - _sndDrvInfo._dDma = ddeco(((_sndDrvInfo._dDev == DEV_SB) ? BlsterDMA : GravisDMA)[Vmenu::_recent]._text); - if (_sndDrvInfo._mDev != _sndDrvInfo._dDev) - select(MIDIPorts, MPORT_TEXT); - else - _sound.open(); -} - } // End of namespace CGE diff --git a/engines/cge/config.h b/engines/cge/config.h index 4a1e5927e5..d7191a281d 100644 --- a/engines/cge/config.h +++ b/engines/cge/config.h @@ -29,9 +29,6 @@ #define __CGE_CONFIG__ namespace CGE { - -void selectSound(); - } // End of namespace CGE #endif diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 977103d7a1..9d5b188fe5 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -1068,7 +1068,7 @@ void Snail::runCom() { _vm->xCave(); break; case kSelectSound: - _vm->selectSound(); + warning("TODO: Select sound card"); break; case kSnSelect: _vm->snSelect(); -- cgit v1.2.3 From b3f0e72e25a3b738ab4af0f198ff78938dd4e5b3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jul 2011 23:09:57 +0200 Subject: CGE: Remove useless fields in DebugText, add some more debugC --- engines/cge/cge.h | 5 +- engines/cge/cge_main.cpp | 181 +++++++++++++++++++++-------------------------- 2 files changed, 83 insertions(+), 103 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index e8451454a4..b67b6b28a7 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -188,6 +188,8 @@ public: void switchDebug(); void miniStep(int stp); void AltCtrlDel(); + void postMiniStep(int stp); + void ShowBak(int ref); void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); @@ -232,7 +234,8 @@ public: void snUncover(Sprite *spr, Sprite *xspr); void snWalk(Sprite *spr, int x, int y); void snZTrim(Sprite *spr); - +protected: + int _recentStep; private: CGEConsole *_console; void setup(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index cb060891cf..10ec47e815 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -534,12 +534,14 @@ void CGEEngine::quit() { void CGEEngine::AltCtrlDel() { - debugC(1, kDebugEngine, "CGEEngine::setup()"); + debugC(1, kDebugEngine, "CGEEngine::AltCtrlDel()"); SNPOST_(SNSAY, -1, A_C_D_TEXT, _hero); } void CGEEngine::miniStep(int stp) { + debugC(1, kDebugEngine, "CGEEngine::miniStep(%d)", stp); + if (stp < 0) _miniCave->_flags._hide = true; else { @@ -551,32 +553,16 @@ void CGEEngine::miniStep(int stp) { } } +void CGEEngine::postMiniStep(int step) { + debugC(6, kDebugEngine, "CGEEngine::postMiniStep(%d)", step); -static void postMiniStep(int stp) { - static int recent = -2; - if (_miniCave && stp != recent) - SNPOST2_(SNEXEC, -1, recent = stp, kMiniStep); -} - -void System::setPal() { - uint i; - Dac *p = Vga::_sysPal + 256 - ArrayCount(_stdPal); - for (i = 0; i < ArrayCount(_stdPal); i++) { - p[i]._r = _stdPal[i]._r >> 2; - p[i]._g = _stdPal[i]._g >> 2; - p[i]._b = _stdPal[i]._b >> 2; - } -} - - -void System::funTouch() { - uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0; - if (_talk == NULL || n > _funDel) - _funDel = n; + if (_miniCave && step != _recentStep) + SNPOST2_(SNEXEC, -1, _recentStep = step, kMiniStep); } +void CGEEngine::ShowBak(int ref) { + debugC(1, kDebugEngine, "CGEEngine::ShowBack(%d)", ref); -static void ShowBak(int ref) { Sprite *spr = _vga->_spareQ->locate(ref); if (spr) { Bitmap::_pal = Vga::_sysPal; @@ -589,8 +575,9 @@ static void ShowBak(int ref) { } } - void CGEEngine::caveUp() { + debugC(1, kDebugEngine, "CGEEngine::caveUp()"); + int BakRef = 1000 * _now; if (_music) loadMidi(_now); @@ -653,6 +640,8 @@ void CGEEngine::caveUp() { void CGEEngine::caveDown() { + debugC(1, kDebugEngine, "CGEEngine::caveDown()"); + Sprite *spr; if (!_horzLine->_flags._hide) switchMapping(); @@ -669,14 +658,16 @@ void CGEEngine::caveDown() { _text->clear(1000); } - void CGEEngine::xCave() { + debugC(6, kDebugEngine, "CGEEngine::xCave()"); + caveDown(); caveUp(); } - void CGEEngine::qGame() { + debugC(1, kDebugEngine, "CGEEngine::qGame()"); + caveDown(); _oldLev = _lev; saveSound(); @@ -690,6 +681,8 @@ void CGEEngine::qGame() { void CGEEngine::switchCave(int cav) { + debugC(1, kDebugEngine, "CGEEngine::switchCave(%d)", cav); + if (cav != _now) { _heart->_enable = false; if (cav < 0) { @@ -723,6 +716,22 @@ System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { tick(); } +void System::setPal() { + uint i; + Dac *p = Vga::_sysPal + 256 - ArrayCount(_stdPal); + for (i = 0; i < ArrayCount(_stdPal); i++) { + p[i]._r = _stdPal[i]._r >> 2; + p[i]._g = _stdPal[i]._g >> 2; + p[i]._b = _stdPal[i]._b >> 2; + } +} + +void System::funTouch() { + uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0; + if (_talk == NULL || n > _funDel) + _funDel = n; +} + void System::touch(uint16 mask, int x, int y) { static int pp = 0; @@ -856,7 +865,7 @@ void System::touch(uint16 mask, int x, int y) { } } - postMiniStep(cav - 1); + _vm->postMiniStep(cav - 1); if (mask & L_UP) { if (cav && _snail->idle() && _hero->_tracePtr < 0) @@ -869,8 +878,7 @@ void System::touch(uint16 mask, int x, int y) { Cluster::_map[z1][x1] = 1; _vm->setMapBrick(x1, z1); } - } else - { + } else { if (!_talk && _snail->idle() && _hero && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_vm->_game) { _hero->findWay(XZ(x, y)); @@ -909,35 +917,17 @@ void System::tick() { _time = SYSTIMERATE; } - -/* -static void SpkOpen() { - asm in al,0x61 - asm or al,0x03 - asm out 0x61,al - asm mov al,0x90 - asm out 0x43,al -} - - -static void SpkClose() { - asm in al,0x61 - asm and al,0xFC - asm out 0x61,al -} - -*/ - - void CGEEngine::switchColorMode() { + debugC(1, kDebugEngine, "CGEEngine::switchColorMode()"); + SNPOST_(SNSEQ, 121, _vga->_mono = !_vga->_mono, NULL); keyClick(); _vga->setColors(Vga::_sysPal, 64); } - - void CGEEngine::switchMusic() { + debugC(1, kDebugEngine, "CGEEngine::switchMusic()"); + if (_keyboard->_key[ALT]) { if (Vmenu::_addr) SNPOST_(SNKILL, -1, 0, Vmenu::_addr); @@ -959,14 +949,16 @@ void CGEEngine::switchMusic() { killMidi(); } - void CGEEngine::startCountDown() { + debugC(1, kDebugEngine, "CGEEngine::startCountDown()"); + //SNPOST(SNSEQ, 123, 0, NULL); switchCave(-1); } - void CGEEngine::takeName() { + debugC(1, kDebugEngine, "CGEEngine::takeName()"); + if (GetText::_ptr) SNPOST_(SNKILL, -1, 0, GetText::_ptr); else { @@ -982,8 +974,9 @@ void CGEEngine::takeName() { } } - void CGEEngine::switchMapping() { + debugC(1, kDebugEngine, "CGEEngine::switchMapping()"); + if (_horzLine->_flags._hide) { int i; for (i = 0; i < MAP_ZCNT; i++) { @@ -1003,6 +996,8 @@ void CGEEngine::switchMapping() { } void CGEEngine::killSprite() { + debugC(1, kDebugEngine, "CGEEngine::killSprite()"); + _sprite->_flags._kill = true; _sprite->_flags._bDel = true; SNPOST_(SNKILL, -1, 0, _sprite); @@ -1010,6 +1005,8 @@ void CGEEngine::killSprite() { } void CGEEngine::pushSprite() { + debugC(1, kDebugEngine, "CGEEngine::pushSprite()"); + Sprite *spr = _sprite->_prev; if (spr) { _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); @@ -1020,6 +1017,8 @@ void CGEEngine::pushSprite() { } void CGEEngine::pullSprite() { + debugC(1, kDebugEngine, "CGEEngine::pullSprite()"); + bool ok = false; Sprite *spr = _sprite->_next; if (spr) { @@ -1037,65 +1036,45 @@ void CGEEngine::pullSprite() { } void CGEEngine::nextStep() { + debugC(1, kDebugEngine, "CGEEngine::nextStep()"); + SNPOST_(SNSTEP, 0, 0, _sprite); } void CGEEngine::saveMapping() { - { - IoHand cf(progName(".TAB"), UPD); - if (!cf._error) { - cf.seek((_now - 1) * sizeof(Cluster::_map)); - cf.write((uint8 *) Cluster::_map, sizeof(Cluster::_map)); - } + IoHand cfTab(progName(".TAB"), UPD); + if (!cfTab._error) { + cfTab.seek((_now - 1) * sizeof(Cluster::_map)); + cfTab.write((uint8 *) Cluster::_map, sizeof(Cluster::_map)); } - { - IoHand cf(progName(".HXY"), WRI); - if (!cf._error) { - _heroXY[_now - 1]._x = _hero->_x; - _heroXY[_now - 1]._y = _hero->_y; - cf.write((uint8 *) _heroXY, sizeof(_heroXY)); - } + + IoHand cfHxy(progName(".HXY"), WRI); + if (!cfHxy._error) { + _heroXY[_now - 1]._x = _hero->_x; + _heroXY[_now - 1]._y = _hero->_y; + cfHxy.write((uint8 *) _heroXY, sizeof(_heroXY)); } } -// 1111111111222222222233333333 334444444444555555555566666666667777777777 -// 01234567890123456789012345678901234567 890123456789012345678901234567890123456789 -static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 000:000:000 000:000 00 "; - -#define NFRE (DebugText + 3) -#define FFRE (DebugText + 11) -#define ABSX (DebugText + 20) -#define ABSY (DebugText + 26) -#define FRPS (DebugText + 34) -#define XSPR (DebugText + 38) -#define SP_N (DebugText + 41) -#define SP_S (DebugText + 44) - -#define SP_X (DebugText + 47) -#define SP_Y (DebugText + 51) -#define SP_Z (DebugText + 55) -#define SP_W (DebugText + 59) -#define SP_H (DebugText + 63) -#define SP_F (DebugText + 67) -#define SP__ (DebugText + 70) +// 1111111111222222222233333333334444444444555555555566666666667777777777 +// 01234567890123456789012345678901234567890123456789012345678901234567890123456789 +static char DebugText[] = " X=000 Y=000 S=00:00 000:000:000 000:000 00"; + +#define ABSX (DebugText + 3) +#define ABSY (DebugText + 9) +#define SP_N (DebugText + 15) +#define SP_S (DebugText + 18) +#define SP_X (DebugText + 21) +#define SP_Y (DebugText + 25) +#define SP_Z (DebugText + 29) +#define SP_W (DebugText + 33) +#define SP_H (DebugText + 37) +#define SP_F (DebugText + 41) void CGEEngine::sayDebug() { if (!_debugLine->_flags._hide) { - static long t = -1L; - long t1 = timer(); - - if (t1 - t >= 18) { - static uint32 old = 0L; - uint32 now = _vga->_frmCnt; - dwtom(now - old, FRPS, 10, 4); - old = now; - t = t1; - } - dwtom(_mouse->_x, ABSX, 10, 3); dwtom(_mouse->_y, ABSY, 10, 3); -// dwtom(coreleft(), NFRE, 10, 5); -// dwtom(farcoreleft(), FFRE, 10, 6); // sprite queue size uint16 n = 0; @@ -1103,7 +1082,6 @@ void CGEEngine::sayDebug() { for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { ++ n; if (spr == _sprite) { - *XSPR = ' '; dwtom(n, SP_N, 10, 2); dwtom(_sprite->_x, SP_X, 10, 3); dwtom(_sprite->_y, SP_Y, 10, 3); @@ -1114,7 +1092,6 @@ void CGEEngine::sayDebug() { } } dwtom(n, SP_S, 10, 2); -// *SP__ = (heapcheck() < 0) ? '!' : ' '; _debugLine->update(DebugText); } } -- cgit v1.2.3 From 17003d0e906f776996b483a18e463b1994c8fb61 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jul 2011 23:14:22 +0200 Subject: CGE: Fix name of showBak() --- engines/cge/cge.cpp | 11 ++++++----- engines/cge/cge.h | 4 ++-- engines/cge/cge_main.cpp | 8 +++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 7e8c8377a8..239fc89dfc 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -123,11 +123,12 @@ void CGEEngine::setup() { _maxCaveArr[3] = 23; _maxCaveArr[4] = 24; }; - _maxCave = 0; - _dark = false; - _game = false; - _now = 1; - _lev = -1; + _maxCave = 0; + _dark = false; + _game = false; + _now = 1; + _lev = -1; + _recentStep = -2; for (int i = 0; i < 4; i++) _flag[i] = false; diff --git a/engines/cge/cge.h b/engines/cge/cge.h index b67b6b28a7..d83025dd25 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -111,7 +111,7 @@ public: bool _game; int _now; int _lev; - char _usrFnam[15]; + char _usrFnam[15]; Common::RandomSource _randomSource; byte * _mini; @@ -189,7 +189,7 @@ public: void miniStep(int stp); void AltCtrlDel(); void postMiniStep(int stp); - void ShowBak(int ref); + void showBak(int ref); void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 10ec47e815..527d075ade 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -560,8 +560,8 @@ void CGEEngine::postMiniStep(int step) { SNPOST2_(SNEXEC, -1, _recentStep = step, kMiniStep); } -void CGEEngine::ShowBak(int ref) { - debugC(1, kDebugEngine, "CGEEngine::ShowBack(%d)", ref); +void CGEEngine::showBak(int ref) { + debugC(1, kDebugEngine, "CGEEngine::showBack(%d)", ref); Sprite *spr = _vga->_spareQ->locate(ref); if (spr) { @@ -582,7 +582,7 @@ void CGEEngine::caveUp() { if (_music) loadMidi(_now); - ShowBak(BakRef); + showBak(BakRef); loadMapping(); _text->preload(BakRef, BakRef + 1000); Sprite *spr = _vga->_spareQ->first(); @@ -1042,6 +1042,8 @@ void CGEEngine::nextStep() { } void CGEEngine::saveMapping() { + debugC(1, kDebugEngine, "CGEEngine::saveMapping()"); + IoHand cfTab(progName(".TAB"), UPD); if (!cfTab._error) { cfTab.seek((_now - 1) * sizeof(Cluster::_map)); -- cgit v1.2.3 From 5190bbb7bef0e5ad51880f24e9fab465d7343428 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Jul 2011 07:13:41 +0200 Subject: CGE: Finish adding debugc to CGEEngine class members --- engines/cge/cge.h | 10 +-- engines/cge/config.cpp | 2 + engines/cge/snail.cpp | 228 +++++++++++++++++++++++++++++++++++-------------- engines/cge/text.cpp | 2 + 4 files changed, 171 insertions(+), 71 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index d83025dd25..431dcc79ad 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -194,7 +194,7 @@ public: void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); void snCover(Sprite *spr, int xref); - void snFlag(int fn, bool v); + void snFlag(int indx, bool v); void snFlash(bool on); void snGame(Sprite *spr, int num); void snGhost(Bitmap *bmp); @@ -205,12 +205,12 @@ public: void snLevel(Sprite *spr, int lev); void snLight(bool in); void snMouse(bool on); - void snNNext(Sprite *sprel, int p); + void snNNext(Sprite *spr, int p); void snPort(Sprite *spr, int port); void snReach(Sprite *spr, int mode); void snRelZ(Sprite *spr, int z); - void snRNNext(Sprite *sprel, int p); - void snRTNext(Sprite *sprel, int p); + void snRNNext(Sprite *spr, int p); + void snRTNext(Sprite *spr, int p); void snSelect(); void snSend(Sprite *spr, int val); void snRelX(Sprite *spr, int x); @@ -229,7 +229,7 @@ public: void snSlave(Sprite *spr, int ref); void snSound(Sprite *spr, int wav, int cnt); void snSwap(Sprite *spr, int xref); - void snTNext(Sprite *sprel, int p); + void snTNext(Sprite *spr, int p); void snTrans(Sprite *spr, int trans); void snUncover(Sprite *spr, Sprite *xspr); void snWalk(Sprite *spr, int x, int y); diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index f8d5431ef0..1391c909eb 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -39,6 +39,8 @@ static Choice *_cho; static int _hlp; void CGEEngine::snSelect() { + debugC(1, kDebugEngine, "CGEEngine::snSelect()"); + inf(_text->getText(_hlp)); _talk->gotoxy(_talk->_x, FONT_HIG / 2); (new Vmenu(this, _cho, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 9d5b188fe5..1393daa392 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -46,6 +46,8 @@ extern Sprite *_pocLight; extern Sprite *_pocket[]; void CGEEngine::snGame(Sprite *spr, int num) { + debugC(1, kDebugEngine, "CGEEngine::snGame(spr, %d)", num); + switch (num) { case 1 : { #define STAGES 8 @@ -255,17 +257,23 @@ void CGEEngine::snGame(Sprite *spr, int num) { void CGEEngine::expandSprite(Sprite *spr) { + debugC(5, kDebugEngine, "CGEEngine::expandSprite(spr)"); + if (spr) _vga->_showQ->insert(_vga->_spareQ->remove(spr)); } void CGEEngine::contractSprite(Sprite *spr) { + debugC(1, kDebugEngine, "CGEEngine::contractSprite(spr)"); + if (spr) _vga->_spareQ->append(_vga->_showQ->remove(spr)); } int CGEEngine::findPocket(Sprite *spr) { + debugC(1, kDebugEngine, "CGEEngine::findPocket(spr)"); + for (int i = 0; i < POCKET_NX; i++) if (_pocket[i] == spr) return i; @@ -274,6 +282,8 @@ int CGEEngine::findPocket(Sprite *spr) { void CGEEngine::selectPocket(int n) { + debugC(1, kDebugEngine, "CGEEngine::selectPocket(%d)", n); + if (n < 0 || (_pocLight->_seqPtr && _pocPtr == n)) { _pocLight->step(0); n = findPocket(NULL); @@ -289,6 +299,8 @@ void CGEEngine::selectPocket(int n) { } void CGEEngine::pocFul() { + debugC(1, kDebugEngine, "CGEEngine::pocFul()"); + _hero->park(); SNPOST(SNWAIT, -1, -1, _hero); SNPOST(SNSEQ, -1, POC_FUL, _hero); @@ -298,10 +310,14 @@ void CGEEngine::pocFul() { } void CGEEngine::hide1(Sprite *spr) { + debugC(1, kDebugEngine, "CGEEngine::hide1(spr)"); + SNPOST_(SNGHOST, -1, 0, spr->ghost()); } void CGEEngine::snGhost(Bitmap *bmp) { + debugC(1, kDebugEngine, "CGEEngine::snGhost(bmp)"); + bmp->hide(bmp->_map & 0xFFFF, bmp->_map >> 16); bmp->_m = NULL; bmp->_map = 0; @@ -309,6 +325,8 @@ void CGEEngine::snGhost(Bitmap *bmp) { } void CGEEngine::feedSnail(Sprite *spr, SnList snq) { + debugC(1, kDebugEngine, "CGEEngine::feedSnail(spr, snq)"); + if (spr) if (spr->active()) { uint8 ptr = (snq == kTake) ? spr->_takePtr : spr->_nearPtr; @@ -454,32 +472,42 @@ void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { } } -void CGEEngine::snNNext(Sprite *sprel, int p) { - if (sprel) - if (sprel->_nearPtr != NO_PTR) - sprel->_nearPtr = p; +void CGEEngine::snNNext(Sprite *spr, int p) { + debugC(1, kDebugEngine, "CGEEngine::snNNext(spr, %d)", p); + + if (spr) + if (spr->_nearPtr != NO_PTR) + spr->_nearPtr = p; } -void CGEEngine::snTNext(Sprite *sprel, int p) { - if (sprel) - if (sprel->_takePtr != NO_PTR) - sprel->_takePtr = p; +void CGEEngine::snTNext(Sprite *spr, int p) { + debugC(1, kDebugEngine, "CGEEngine::snTNext(spr, %d)", p); + + if (spr) + if (spr->_takePtr != NO_PTR) + spr->_takePtr = p; } -void CGEEngine::snRNNext(Sprite *sprel, int p) { - if (sprel) - if (sprel->_nearPtr != NO_PTR) - sprel->_nearPtr += p; +void CGEEngine::snRNNext(Sprite *spr, int p) { + debugC(1, kDebugEngine, "CGEEngine::snRNNext(spr, %d)", p); + + if (spr) + if (spr->_nearPtr != NO_PTR) + spr->_nearPtr += p; } -void CGEEngine::snRTNext(Sprite *sprel, int p) { - if (sprel) - if (sprel->_takePtr != NO_PTR) - sprel->_takePtr += p; +void CGEEngine::snRTNext(Sprite *spr, int p) { + debugC(1, kDebugEngine, "CGEEngine::snRTNext(spr, %d)", p); + + if (spr) + if (spr->_takePtr != NO_PTR) + spr->_takePtr += p; } void CGEEngine::snZTrim(Sprite *spr) { + debugC(4, kDebugEngine, "CGEEngine::snZTrim(spr)"); + if (spr) if (spr->active()) { bool en = _heart->_enable; @@ -496,6 +524,8 @@ void CGEEngine::snZTrim(Sprite *spr) { } void CGEEngine::snHide(Sprite *spr, int val) { + debugC(1, kDebugEngine, "CGEEngine::snHide(spr, %d)", val); + if (spr) { spr->_flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags._hide); if (spr->_flags._shad) @@ -504,16 +534,22 @@ void CGEEngine::snHide(Sprite *spr, int val) { } void CGEEngine::snRmNear(Sprite *spr) { + debugC(1, kDebugEngine, "CGEEngine::snRmNear(spr)"); + if (spr) spr->_nearPtr = NO_PTR; } void CGEEngine::snRmTake(Sprite *spr) { + debugC(1, kDebugEngine, "CGEEngine::snRmTake(spr)"); + if (spr) spr->_takePtr = NO_PTR; } void CGEEngine::snSeq(Sprite *spr, int val) { + debugC(1, kDebugEngine, "CGEEngine::snSeq(spr, %d)", val); + if (spr) { if (spr == _hero && val == 0) _hero->park(); @@ -523,11 +559,15 @@ void CGEEngine::snSeq(Sprite *spr, int val) { } void CGEEngine::snRSeq(Sprite *spr, int val) { + debugC(1, kDebugEngine, "CGEEngine::snRSeq(spr, %d)", val); + if (spr) snSeq(spr, spr->_seqPtr + val); } void CGEEngine::snSend(Sprite *spr, int val) { + debugC(1, kDebugEngine, "CGEEngine::snSend(spr, %d)", val); + if (spr) { int was = spr->_cave; bool was1 = (was == 0 || was == _now); @@ -558,6 +598,8 @@ void CGEEngine::snSend(Sprite *spr, int val) { void CGEEngine::snSwap(Sprite *spr, int xref) { + debugC(1, kDebugEngine, "CGEEngine::snSwap(spr, %d)", xref); + Sprite *xspr = locate(xref); if (spr && xspr) { int was = spr->_cave; @@ -593,6 +635,8 @@ void CGEEngine::snSwap(Sprite *spr, int xref) { void CGEEngine::snCover(Sprite *spr, int xref) { + debugC(1, kDebugEngine, "CGEEngine::snCover(spr, %d)", xref); + Sprite *xspr = locate(xref); if (spr && xspr) { spr->_flags._hide = true; @@ -610,6 +654,8 @@ void CGEEngine::snCover(Sprite *spr, int xref) { void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) { + debugC(1, kDebugEngine, "CGEEngine::snUncover(spr, xspr)"); + if (spr && xspr) { spr->_flags._hide = false; spr->_cave = xspr->_cave; @@ -627,30 +673,42 @@ void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) { void CGEEngine::snSetX0(int cav, int x0) { + debugC(1, kDebugEngine, "CGEEngine::snSetX0(%d, %d)", cav, x0); + _heroXY[cav - 1]._x = x0; } void CGEEngine::snSetY0(int cav, int y0) { + debugC(1, kDebugEngine, "CGEEngine::snSetY0(%d, %d)", cav, y0); + _heroXY[cav - 1]._y = y0; } void CGEEngine::snSetXY(Sprite *spr, uint16 xy) { + debugC(1, kDebugEngine, "CGEEngine::snSetXY(spr, %d)", xy); + if (spr) spr->gotoxy(xy % SCR_WID, xy / SCR_WID); } void CGEEngine::snRelX(Sprite *spr, int x) { + debugC(1, kDebugEngine, "CGEEngine::snRelX(spr, %d)", x); + if (spr && _hero) spr->gotoxy(_hero->_x + x, spr->_y); } void CGEEngine::snRelY(Sprite *spr, int y) { + debugC(1, kDebugEngine, "CGEEngine::snRelY(spr, %d)", y); + if (spr && _hero) spr->gotoxy(spr->_x, _hero->_y + y); } void CGEEngine::snRelZ(Sprite *spr, int z) { + debugC(1, kDebugEngine, "CGEEngine::snRelZ(spr, %d)", z); + if (spr && _hero) { spr->_z = _hero->_z + z; snZTrim(spr); @@ -659,18 +717,24 @@ void CGEEngine::snRelZ(Sprite *spr, int z) { void CGEEngine::snSetX(Sprite *spr, int x) { + debugC(1, kDebugEngine, "CGEEngine::snSetX(spr, %d)", x); + if (spr) spr->gotoxy(x, spr->_y); } void CGEEngine::snSetY(Sprite *spr, int y) { + debugC(1, kDebugEngine, "CGEEngine::snSetY(spr, %d)", y); + if (spr) spr->gotoxy(spr->_x, y); } void CGEEngine::snSetZ(Sprite *spr, int z) { + debugC(1, kDebugEngine, "CGEEngine::snSetZ(spr, %d)", z); + if (spr) { spr->_z = z; //SNPOST_(SNZTRIM, -1, 0, spr); @@ -680,6 +744,8 @@ void CGEEngine::snSetZ(Sprite *spr, int z) { void CGEEngine::snSlave(Sprite *spr, int ref) { + debugC(1, kDebugEngine, "CGEEngine::snSlave(spr, %d)", ref); + Sprite *slv = locate(ref); if (spr && slv) { if (spr->active()) { @@ -693,16 +759,22 @@ void CGEEngine::snSlave(Sprite *spr, int ref) { void CGEEngine::snTrans(Sprite *spr, int trans) { + debugC(1, kDebugEngine, "CGEEngine::snTrans(spr, %d)", trans); + if (spr) spr->_flags._tran = (trans < 0) ? !spr->_flags._tran : (trans != 0); } void CGEEngine::snPort(Sprite *spr, int port) { + debugC(1, kDebugEngine, "CGEEngine::snPort(spr, %d)", port); + if (spr) spr->_flags._port = (port < 0) ? !spr->_flags._port : (port != 0); } void CGEEngine::snKill(Sprite *spr) { + debugC(1, kDebugEngine, "CGEEngine::snKill(spr)"); + if (spr) { if (spr->_flags._kept) { int n = findPocket(spr); @@ -728,6 +800,8 @@ void CGEEngine::snKill(Sprite *spr) { void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { + debugC(1, kDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt); + if (_sndDrvInfo._dDev) { if (wav == -1) _sound.stop(); @@ -738,6 +812,8 @@ void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { void CGEEngine::snKeep(Sprite *spr, int stp) { + debugC(1, kDebugEngine, "CGEEngine::snKeep(spr, %d)", stp); + selectPocket(-1); if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) { snSound(spr, 3, 1); @@ -754,6 +830,8 @@ void CGEEngine::snKeep(Sprite *spr, int stp) { void CGEEngine::snGive(Sprite *spr, int stp) { + debugC(1, kDebugEngine, "CGEEngine::snGive(spr, %d)", stp); + if (spr) { int p = findPocket(spr); if (p >= 0) { @@ -769,6 +847,8 @@ void CGEEngine::snGive(Sprite *spr, int stp) { void CGEEngine::snBackPt(Sprite *spr, int stp) { + debugC(1, kDebugEngine, "CGEEngine::snBackPt(spr, %d)", stp); + if (spr) { if (stp >= 0) spr->step(stp); @@ -777,6 +857,8 @@ void CGEEngine::snBackPt(Sprite *spr, int stp) { } void CGEEngine::snLevel(Sprite *spr, int lev) { + debugC(1, kDebugEngine, "CGEEngine::snLevel(spr, %d)", lev); + while (_lev < lev) { _lev++; spr = _vga->_spareQ->locate(100 + _lev); @@ -791,16 +873,20 @@ void CGEEngine::snLevel(Sprite *spr, int lev) { } -void CGEEngine::snFlag(int fn, bool v) { - _flag[fn] = v; +void CGEEngine::snFlag(int indx, bool v) { + _flag[indx] = v; } void CGEEngine::snSetRef(Sprite *spr, int nr) { + debugC(1, kDebugEngine, "CGEEngine::snSetRef(spr, %d)", nr); + if (spr) spr->_ref = nr; } void CGEEngine::snFlash(bool on) { + debugC(1, kDebugEngine, "CGEEngine::snFlash(%s)", on ? "true" : "false"); + if (on) { Dac *pal = farnew(Dac, PAL_CNT); if (pal) { @@ -823,6 +909,8 @@ void CGEEngine::snFlash(bool on) { void CGEEngine::snLight(bool in) { + debugC(1, kDebugEngine, "CGEEngine::snLight(%s)", in ? "true" : "false"); + if (in) _vga->sunrise(Vga::_sysPal); else @@ -831,10 +919,14 @@ void CGEEngine::snLight(bool in) { } void CGEEngine::snBarrier(int cav, int bar, bool horz) { + debugC(1, kDebugEngine, "CGEEngine::snBarrier(%d, %d, %s)", cav, bar, horz ? "true" : "false"); + ((uint8 *)(_barriers + ((cav > 0) ? cav : _now)))[horz] = bar; } void CGEEngine::snWalk(Sprite *spr, int x, int y) { + debugC(1, kDebugEngine, "CGEEngine::snWalk(spr, %d, %d)", x, y); + if (_hero) { if (spr && y < 0) _hero->findWay(spr); @@ -844,11 +936,15 @@ void CGEEngine::snWalk(Sprite *spr, int x, int y) { } void CGEEngine::snReach(Sprite *spr, int mode) { + debugC(1, kDebugEngine, "CGEEngine::snReach(spr, %d)", mode); + if (_hero) _hero->reach(spr, mode); } void CGEEngine::snMouse(bool on) { + debugC(1, kDebugEngine, "CGEEngine::snMouse(%s)", on ? "true" : "false"); + if (on) _mouse->on(); else @@ -883,7 +979,7 @@ void Snail::runCom() { break; } - Sprite *sprel = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr)); + Sprite *spr = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr)); switch (snc->_com) { case SNLABEL : break; @@ -893,25 +989,25 @@ void Snail::runCom() { _textDelay = true; break; case SNWAIT : - if (sprel) { - if (sprel->seqTest(snc->_val) && - (snc->_val >= 0 || sprel != _hero || _hero->_tracePtr < 0)) { - _timerExpiry = g_system->getMillis() + sprel->_time * SNAIL_FRAME_DELAY; + if (spr) { + if (spr->seqTest(snc->_val) && + (snc->_val >= 0 || spr != _hero || _hero->_tracePtr < 0)) { + _timerExpiry = g_system->getMillis() + spr->_time * SNAIL_FRAME_DELAY; } else goto xit; } break; case SNLEVEL : - _vm->snLevel(sprel, snc->_val); + _vm->snLevel(spr, snc->_val); break; case SNHIDE : - _vm->snHide(sprel, snc->_val); + _vm->snHide(spr, snc->_val); break; case SNSAY : - if (sprel && _talkEnable) { - if (sprel == _hero && sprel->seqTest(-1)) - sprel->step(HTALK); - _text->say(_text->getText(snc->_val), sprel); + if (spr && _talkEnable) { + if (spr == _hero && spr->seqTest(-1)) + spr->step(HTALK); + _text->say(_text->getText(snc->_val), spr); _sys->_funDel = HEROFUN0; } break; @@ -922,44 +1018,44 @@ void Snail::runCom() { } break; case SNTIME : - if (sprel && _talkEnable) { - if (sprel == _hero && sprel->seqTest(-1)) - sprel->step(HTALK); - sayTime(sprel); + if (spr && _talkEnable) { + if (spr == _hero && spr->seqTest(-1)) + spr->step(HTALK); + sayTime(spr); } break; case SNCAVE : _vm->switchCave(snc->_val); break; case SNKILL : - _vm->snKill(sprel); + _vm->snKill(spr); break; case SNSEQ : - _vm->snSeq(sprel, snc->_val); + _vm->snSeq(spr, snc->_val); break; case SNRSEQ : - _vm->snRSeq(sprel, snc->_val); + _vm->snRSeq(spr, snc->_val); break; case SNSEND : - _vm->snSend(sprel, snc->_val); + _vm->snSend(spr, snc->_val); break; case SNSWAP : - _vm->snSwap(sprel, snc->_val); + _vm->snSwap(spr, snc->_val); break; case SNCOVER : - _vm->snCover(sprel, snc->_val); + _vm->snCover(spr, snc->_val); break; case SNUNCOVER : - _vm->snUncover(sprel, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); + _vm->snUncover(spr, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); break; case SNKEEP : - _vm->snKeep(sprel, snc->_val); + _vm->snKeep(spr, snc->_val); break; case SNGIVE : - _vm->snGive(sprel, snc->_val); + _vm->snGive(spr, snc->_val); break; case SNGAME : - _vm->snGame(sprel, snc->_val); + _vm->snGame(spr, snc->_val); break; case SNSETX0 : _vm->snSetX0(snc->_ref, snc->_val); @@ -968,34 +1064,34 @@ void Snail::runCom() { _vm->snSetY0(snc->_ref, snc->_val); break; case SNSETXY : - _vm->snSetXY(sprel, snc->_val); + _vm->snSetXY(spr, snc->_val); break; case SNRELX : - _vm->snRelX(sprel, snc->_val); + _vm->snRelX(spr, snc->_val); break; case SNRELY : - _vm->snRelY(sprel, snc->_val); + _vm->snRelY(spr, snc->_val); break; case SNRELZ : - _vm->snRelZ(sprel, snc->_val); + _vm->snRelZ(spr, snc->_val); break; case SNSETX : - _vm->snSetX(sprel, snc->_val); + _vm->snSetX(spr, snc->_val); break; case SNSETY : - _vm->snSetY(sprel, snc->_val); + _vm->snSetY(spr, snc->_val); break; case SNSETZ : - _vm->snSetZ(sprel, snc->_val); + _vm->snSetZ(spr, snc->_val); break; case SNSLAVE : - _vm->snSlave(sprel, snc->_val); + _vm->snSlave(spr, snc->_val); break; case SNTRANS : - _vm->snTrans(sprel, snc->_val); + _vm->snTrans(spr, snc->_val); break; case SNPORT : - _vm->snPort(sprel, snc->_val); + _vm->snPort(spr, snc->_val); break; case SNNEXT : case SNIF : @@ -1005,31 +1101,31 @@ void Snail::runCom() { _vm->snMouse(snc->_val != 0); break; case SNNNEXT : - _vm->snNNext(sprel, snc->_val); + _vm->snNNext(spr, snc->_val); break; case SNTNEXT : - _vm->snTNext(sprel, snc->_val); + _vm->snTNext(spr, snc->_val); break; case SNRNNEXT : - _vm->snRNNext(sprel, snc->_val); + _vm->snRNNext(spr, snc->_val); break; case SNRTNEXT : - _vm->snRTNext(sprel, snc->_val); + _vm->snRTNext(spr, snc->_val); break; case SNRMNEAR : - _vm->snRmNear(sprel); + _vm->snRmNear(spr); break; case SNRMTAKE : - _vm->snRmTake(sprel); + _vm->snRmTake(spr); break; case SNFLAG : _vm->snFlag(snc->_ref & 3, snc->_val != 0); break; case SNSETREF : - _vm->snSetRef(sprel, snc->_val); + _vm->snSetRef(spr, snc->_val); break; case SNBACKPT : - _vm->snBackPt(sprel, snc->_val); + _vm->snBackPt(spr, snc->_val); break; case SNFLASH : _vm->snFlash(snc->_val != 0); @@ -1044,13 +1140,13 @@ void Snail::runCom() { _vm->snBarrier(snc->_ref, snc->_val, false); break; case SNWALK : - _vm->snWalk(sprel, snc->_ref, snc->_val); + _vm->snWalk(spr, snc->_ref, snc->_val); break; case SNREACH : - _vm->snReach(sprel, snc->_val); + _vm->snReach(spr, snc->_val); break; case SNSOUND : - _vm->snSound(sprel, snc->_val, count); + _vm->snSound(spr, snc->_val, count); count = 1; break; case SNCOUNT : @@ -1081,10 +1177,10 @@ void Snail::runCom() { } break; case SNSTEP : - sprel->step(); + spr->step(); break; case SNZTRIM : - _vm->snZTrim(sprel); + _vm->snZTrim(spr); break; case SNGHOST : _vm->snGhost((Bitmap *) snc->_ptr); diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 63d618b5d5..1cc25da5e1 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -218,6 +218,8 @@ void Text::say(const char *txt, Sprite *spr) { } void CGEEngine::inf(const char *txt) { + debugC(1, kDebugEngine, "CGEEngine::inf(%s)", txt); + killText(); _talk = new Talk(this, txt, RECT); if (_talk) { -- cgit v1.2.3 From a073e78ba1fb4be357660a03aa0c387d80df3aab Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Jul 2011 07:50:07 +0200 Subject: CGE: Rename constants (WIP) --- engines/cge/config.cpp | 4 ++-- engines/cge/gettext.cpp | 6 ++--- engines/cge/talk.cpp | 58 ++++++++++++++++++++----------------------------- engines/cge/talk.h | 21 ++++++++++-------- engines/cge/text.cpp | 4 ++-- engines/cge/vmenu.cpp | 41 ++++++++++++---------------------- engines/cge/vmenu.h | 6 +++-- 7 files changed, 61 insertions(+), 79 deletions(-) diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 1391c909eb..b49d2b77ea 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -42,8 +42,8 @@ void CGEEngine::snSelect() { debugC(1, kDebugEngine, "CGEEngine::snSelect()"); inf(_text->getText(_hlp)); - _talk->gotoxy(_talk->_x, FONT_HIG / 2); - (new Vmenu(this, _cho, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT)); + _talk->gotoxy(_talk->_x, kFontHigh / 2); + (new Vmenu(this, _cho, SCR_WID / 2, _talk->_y + _talk->_h + kTextVMargin + kFontHigh))->setName(_text->getText(MENU_TEXT)); } } // End of namespace CGE diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index f5c62809db..2f16cad86a 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -37,12 +37,12 @@ GetText *GetText::_ptr = NULL; GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) : Talk(vm), _text(text), _size(min(size, GTMAX)), _len(min(_size, strlen(text))), _cntr(GTBLINK), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { - int i = 2 * TEXT_HM + _font->width(info); + int i = 2 * kTextHMargin + _font->width(info); _ptr = this; _mode = RECT; _ts = new BMP_PTR[2]; - _ts[0] = box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS); + _ts[0] = box((i + 3) & ~3, 2 * kTextVMargin + 2 * kFontHigh + kTextLineSpace); _ts[1] = NULL; setShapeList(_ts); @@ -108,7 +108,7 @@ void GetText::touch(uint16 mask, int x, int y) { if (p) x = ogon[p - bezo]; } - if (_len < _size && 2 * TEXT_HM + _font->width(_buff) + _font->_wid[x] <= _w) { + if (_len < _size && 2 * kTextHMargin + _font->width(_buff) + _font->_wid[x] <= _w) { _buff[_len + 2] = _buff[_len + 1]; _buff[_len + 1] = _buff[_len]; _buff[_len++] = x; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index e2a5af5fde..aa342f8216 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -32,23 +32,13 @@ #include "cge/events.h" namespace CGE { - -#define WID_SIZ 256 -#define POS_SIZ 256 -#define MAP_SIZ (256*8) - -//uint8 FONT::Wid[WID_SIZ]; -//uint16 FONT::Pos[POS_SIZ]; -//uint8 FONT::Map[MAP_SIZ]; - - Font::Font(const char *name) { - _map = farnew(uint8, MAP_SIZ); - _pos = farnew(uint16, POS_SIZ); - _wid = farnew(uint8, WID_SIZ); + _map = farnew(uint8, kMapSize); + _pos = farnew(uint16, kPosSize); + _wid = farnew(uint8, kWidSize); if ((_map == NULL) || (_pos == NULL) || (_wid == NULL)) error("No core"); - mergeExt(_path, name, FONT_EXT); + mergeExt(_path, name, kFontExt); load(); } @@ -63,10 +53,10 @@ Font::~Font() { void Font::load() { INI_FILE f(_path); if (!f._error) { - f.read(_wid, WID_SIZ); + f.read(_wid, kWidSize); if (!f._error) { uint16 i, p = 0; - for (i = 0; i < POS_SIZ; i++) { + for (i = 0; i < kPosSize; i++) { _pos[i] = p; p += _wid[i]; } @@ -136,18 +126,18 @@ void Talk::deinit() { void Talk::update(const char *tx) { - uint16 vmarg = (_mode) ? TEXT_VM : 0; - uint16 hmarg = (_mode) ? TEXT_HM : 0; + uint16 vmarg = (_mode) ? kTextVMargin : 0; + uint16 hmarg = (_mode) ? kTextHMargin : 0; uint16 mw = 0, mh, ln = vmarg; const char *p; uint8 *m; if (!_ts) { uint16 k = 2 * hmarg; - mh = 2 * vmarg + FONT_HIG; + mh = 2 * vmarg + kFontHigh; for (p = tx; *p; p++) { if (*p == '|' || *p == '\n') { - mh += FONT_HIG + TEXT_LS; + mh += kFontHigh + kTextLineSpace; if (k > mw) mw = k; k = 2 * hmarg; @@ -166,7 +156,7 @@ void Talk::update(const char *tx) { while (* tx) { if (*tx == '|' || *tx == '\n') - m = _ts[0]->_m + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; + m = _ts[0]->_m + (ln += kFontHigh + kTextLineSpace) * mw + hmarg; else { int cw = _font->_wid[(unsigned char)*tx], i; uint8 *f = _font->_map + _font->_pos[(unsigned char)*tx]; @@ -174,9 +164,9 @@ void Talk::update(const char *tx) { uint8 *pp = m; uint16 n; register uint16 b = *(f++); - for (n = 0; n < FONT_HIG; n++) { + for (n = 0; n < kFontHigh; n++) { if (b & 1) - *pp = TEXT_FG; + *pp = kTextColFG; b >>= 1; pp += mw; } @@ -194,7 +184,7 @@ void Talk::update(const char *tx) { Bitmap *Talk::box(uint16 w, uint16 h) { uint8 *b, * p, * q; - uint16 n, r = (_mode == ROUND) ? TEXT_RD : 0; + uint16 n, r = (_mode == ROUND) ? kTextRoundCorner : 0; if (w < 8) w = 8; @@ -203,7 +193,7 @@ Bitmap *Talk::box(uint16 w, uint16 h) { b = farnew(uint8, n = w * h); if (! b) error("No core"); - memset(b, TEXT_BG, n); + memset(b, kTextColBG, n); if (_mode) { p = b; @@ -245,10 +235,10 @@ void Talk::putLine(int line, const char *text) { uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap uint16 psiz = h * lsiz; // - last gap, but + plane trailer uint16 size = 4 * psiz; // whole map size - uint16 rsiz = FONT_HIG * lsiz; // length of whole text row map + uint16 rsiz = kFontHigh * lsiz; // length of whole text row map // set desired line pointer - v += (TEXT_VM + (FONT_HIG + TEXT_LS) * line) * lsiz; + v += (kTextVMargin + (kFontHigh + kTextLineSpace) * line) * lsiz; p = v; // assume blanked line above text // clear whole rectangle @@ -261,7 +251,7 @@ void Talk::putLine(int line, const char *text) { // paint text line if (text) { uint8 *q; - p = v + 2 + TEXT_HM / 4 + (TEXT_HM % 4) * psiz; + p = v + 2 + kTextHMargin / 4 + (kTextHMargin % 4) * psiz; q = v + size; while (* text) { @@ -271,9 +261,9 @@ void Talk::putLine(int line, const char *text) { for (i = 0; i < cw; i++) { register uint16 b = fp[i]; uint16 n; - for (n = 0; n < FONT_HIG; n++) { + for (n = 0; n < kFontHigh; n++) { if (b & 1) - *p = TEXT_FG; + *p = kTextColFG; b >>= 1; p += lsiz; } @@ -293,7 +283,7 @@ InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldTxt(NULL), _vm(vm) { _ts[1] = NULL; } - _ts[0] = new Bitmap(w, FONT_HIG, TEXT_BG); + _ts[0] = new Bitmap(w, kFontHigh, kTextColBG); setShapeList(_ts); } @@ -310,7 +300,7 @@ void InfoLine::update(const char *tx) { // clear whole rectangle byte *pDest; - memset(v + 2, TEXT_BG, dsiz); // data bytes + memset(v + 2, kTextColBG, dsiz); // data bytes for (pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) { Common::copy(v, v + lsiz, pDest); } @@ -329,9 +319,9 @@ void InfoLine::update(const char *tx) { for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; - for (uint16 n = 0; n < FONT_HIG; n++) { + for (uint16 n = 0; n < kFontHigh; n++) { if (b & 1) - *p = TEXT_FG; + *p = kTextColFG; b >>= 1; p += lsiz; } diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 4d30047ea1..e8136271f6 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -34,15 +34,18 @@ namespace CGE { -#define TEXT_FG DARK // foreground color -#define TEXT_BG GRAY // background color -#define TEXT_HM (6&~1) // EVEN horizontal margins! -#define TEXT_VM 5 // vertical margins -#define TEXT_LS 2 // line spacing -#define TEXT_RD 3 // rounded corners - -#define FONT_HIG 8 -#define FONT_EXT ".CFT" +#define kTextColFG DARK // foreground color +#define kTextColBG GRAY // background color +#define kTextHMargin (6&~1) // EVEN horizontal margins! +#define kTextVMargin 5 // vertical margins +#define kTextLineSpace 2 // line spacing +#define kTextRoundCorner 3 // rounded corners +#define kWidSize 256 +#define kPosSize 256 +#define kMapSize (256*8) + +#define kFontHigh 8 +#define kFontExt ".CFT" diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 1cc25da5e1..fd37dada8b 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -187,10 +187,10 @@ void Text::say(const char *txt, Sprite *spr) { uint16 sw = spike->_w; if (east) { - if (x + sw + TEXT_RD + 5 >= SCR_WID) + if (x + sw + kTextRoundCorner + 5 >= SCR_WID) east = false; } else { - if (x <= 5 + TEXT_RD + sw) + if (x <= 5 + kTextRoundCorner + sw) east = true; } x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2 - sw); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 0c0e1fb855..bc5e5cfb6c 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -31,31 +31,18 @@ namespace CGE { - -#define RELIEF 1 -#if RELIEF -#define MB_LT LGRAY -#define MB_RB DGRAY -#else -#define MB_LT DGRAY -#define MB_RB LGRAY -#endif - - - - MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { - int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h; + int h = kFontHigh + 2 * kMenuBarVM, i = (w += 2 * kMenuBarHM) * h; uint8 *p = farnew(uint8, i), * p1, * p2; memset(p + w, TRANS, i - 2 * w); - memset(p, MB_LT, w); - memset(p + i - w, MB_RB, w); + memset(p, kMenuBarLT, w); + memset(p + i - w, kMenuBarRB, w); p1 = p; p2 = p + i - 1; for (i = 0; i < h; i++) { - *p1 = MB_LT; - *p2 = MB_RB; + *p1 = kMenuBarLT; + *p2 = kMenuBarRB; p1 += w; p2 -= w; } @@ -115,10 +102,10 @@ Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) if (x < 0 || y < 0) center(); else - gotoxy(x - _w / 2, y - (TEXT_VM + FONT_HIG / 2)); + gotoxy(x - _w / 2, y - (kTextVMargin + kFontHigh / 2)); _vga->_showQ->insert(this, _vga->_showQ->last()); - _bar = new MenuBar(_vm, _w - 2 * TEXT_HM); - _bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM - MB_VM); + _bar = new MenuBar(_vm, _w - 2 * kTextHMargin); + _bar->gotoxy(_x + kTextHMargin - kMenuBarHM, _y + kTextVMargin - kMenuBarVM); _vga->_showQ->insert(_bar, _vga->_showQ->last()); } @@ -130,23 +117,23 @@ Vmenu::~Vmenu() { #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) void Vmenu::touch(uint16 mask, int x, int y) { - uint16 h = FONT_HIG + TEXT_LS; - bool ok = false; - if (_items) { Sprite::touch(mask, x, y); - y -= TEXT_VM - 1; + y -= kTextVMargin - 1; int n = 0; + bool ok = false; + uint16 h = kFontHigh + kTextLineSpace; + if (y >= 0) { n = y / h; if (n < _items) - ok = (x >= TEXT_HM && x < _w - TEXT_HM/* && y % h < FONT_HIG*/); + ok = (x >= kTextHMargin && x < _w - kTextHMargin/* && y % h < FONT_HIG*/); else n = _items - 1; } - _bar->gotoxy(_x + TEXT_HM - MB_HM, _y + TEXT_VM + n * h - MB_VM); + _bar->gotoxy(_x + kTextHMargin - kMenuBarHM, _y + kTextVMargin + n * h - kMenuBarVM); if (ok && (mask & L_UP)) { _items = 0; diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 6b4eb85a53..93979b5895 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -32,8 +32,10 @@ namespace CGE { -#define MB_VM 1 -#define MB_HM 3 +#define kMenuBarVM 1 +#define kMenuBarHM 3 +#define kMenuBarLT LGRAY +#define kMenuBarRB DGRAY struct Choice { -- cgit v1.2.3 From 9a148a27cc44ba089e57ea07996a868c89c2287f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Jul 2011 08:09:16 +0200 Subject: CGE: Remove macro farnew --- engines/cge/bitmap.cpp | 6 +++--- engines/cge/cfile.cpp | 4 ++-- engines/cge/cge.h | 1 + engines/cge/jbw.h | 1 - engines/cge/snail.cpp | 4 ++-- engines/cge/talk.cpp | 9 +++++---- engines/cge/vga13h.cpp | 4 ++-- engines/cge/vmenu.cpp | 11 ++++++----- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index f280f61e3e..29fc4fd8d6 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -142,7 +142,7 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), if (v0) { uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); uint16 siz = vsiz + _h * sizeof(HideDesc); - uint8 *v1 = farnew(uint8, siz); + uint8 *v1 = (uint8 *) malloc(sizeof(uint8) * siz); if (v1 == NULL) error("No core"); memcpy(v1, v0, siz); @@ -173,7 +173,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { else { uint16 vsiz = (uint8 *)bmp._b - (uint8 *)v0; uint16 siz = vsiz + _h * sizeof(HideDesc); - uint8 *v1 = farnew(uint8, siz); + uint8 *v1 = (uint8 *) malloc(sizeof(uint8) * siz); if (v1 == NULL) error("No core"); memcpy(v1, v0, siz); @@ -486,7 +486,7 @@ bool Bitmap::loadBMP(XFile *f) { } _h = hea.hig; _w = hea.wid; - if ((_m = farnew(byte, _h * _w)) != NULL) { + if ((_m = (byte *) malloc(sizeof(byte) * (_h * _w))) != NULL) { int16 r = (4 - (hea.wid & 3)) % 4; byte buf[3]; for (i = _h - 1; i >= 0; i--) { diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index af29ec5df7..5cbf078610 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -40,7 +40,7 @@ IoBuf::IoBuf(IOMODE mode, CRYPT *crpt) _lim(0) { debugC(1, kDebugFile, "IoBuf::IoBuf(%d, crpt)", mode); - _buff = farnew(uint8, IOBUF_SIZE); + _buff = (uint8 *) malloc(sizeof(uint8) * IOBUF_SIZE); if (_buff == NULL) error("No core for I/O"); } @@ -53,7 +53,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) _lim(0) { debugC(1, kDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode); - _buff = farnew(uint8, IOBUF_SIZE); + _buff = (uint8 *) malloc(sizeof(uint8) * IOBUF_SIZE); if (_buff == NULL) error("No core for I/O [%s]", name); } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 431dcc79ad..011e08bb31 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -236,6 +236,7 @@ public: void snZTrim(Sprite *spr); protected: int _recentStep; + private: CGEConsole *_console; void setup(); diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 74084fb905..89bcb2b03e 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -55,7 +55,6 @@ namespace CGE { #define IsAlNum(c) (IsAlpha(c) || IsDigit(c)) #define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) -#define farnew(t, n) ((t *) malloc(sizeof(t) * (n))) #define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) #define MAX_TIMER 0x1800B0L diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 1393daa392..b0f56be476 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -417,7 +417,7 @@ const char *Snail::_comTxt[] = { Snail::Snail(CGEEngine *vm, bool turbo) : _turbo(turbo), _busy(false), _textDelay(false), _timerExpiry(0), _talkEnable(true), - _head(0), _tail(0), _snList(farnew(Com, 256)), _vm(vm) { + _head(0), _tail(0), _snList((Com *) malloc(sizeof(Com) * 256)), _vm(vm) { } Snail::~Snail() { @@ -888,7 +888,7 @@ void CGEEngine::snFlash(bool on) { debugC(1, kDebugEngine, "CGEEngine::snFlash(%s)", on ? "true" : "false"); if (on) { - Dac *pal = farnew(Dac, PAL_CNT); + Dac *pal = (Dac *) malloc(sizeof(Dac) * PAL_CNT); if (pal) { memcpy(pal, Vga::_sysPal, PAL_SIZ); for (int i = 0; i < PAL_CNT; i++) { diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index aa342f8216..c00e7f3a88 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -33,9 +33,9 @@ namespace CGE { Font::Font(const char *name) { - _map = farnew(uint8, kMapSize); - _pos = farnew(uint16, kPosSize); - _wid = farnew(uint8, kWidSize); + _map = (uint8 *) malloc(sizeof(uint8) * kMapSize); + _pos = (uint16 *) malloc(sizeof(uint16) * kPosSize); + _wid = (uint8 *) malloc(sizeof(uint8) * kWidSize); if ((_map == NULL) || (_pos == NULL) || (_wid == NULL)) error("No core"); mergeExt(_path, name, kFontExt); @@ -190,7 +190,8 @@ Bitmap *Talk::box(uint16 w, uint16 h) { w = 8; if (h < 8) h = 8; - b = farnew(uint8, n = w * h); + n = w * h; + b = (uint8 *) malloc(sizeof(uint8) * n); if (! b) error("No core"); memset(b, kTextColBG, n); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ca6a9e3bdd..6fc17dc37b 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -986,8 +986,8 @@ Vga::Vga(int mode) setStatAdr(); if (_statAdr != VGAST1_) _mono++; - _oldColors = farnew(Dac, 256); - _newColors = farnew(Dac, 256); + _oldColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT); + _newColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT); _oldScreen = SaveScreen(); getColors(_oldColors); sunset(); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index bc5e5cfb6c..c65ec6957e 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -32,15 +32,16 @@ namespace CGE { MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { - int h = kFontHigh + 2 * kMenuBarVM, i = (w += 2 * kMenuBarHM) * h; - uint8 *p = farnew(uint8, i), * p1, * p2; + int h = kFontHigh + 2 * kMenuBarVM; + int i = (w += 2 * kMenuBarHM) * h; + uint8 *p = (uint8 *) malloc(sizeof(uint8) * i); memset(p + w, TRANS, i - 2 * w); memset(p, kMenuBarLT, w); memset(p + i - w, kMenuBarRB, w); - p1 = p; - p2 = p + i - 1; - for (i = 0; i < h; i++) { + uint8 *p1 = p; + uint8 *p2 = p + i - 1; + for (int cpt = 0; cpt < h; cpt++) { *p1 = kMenuBarLT; *p2 = kMenuBarRB; p1 += w; -- cgit v1.2.3 From 2e6e7d81da3a2c81c80478edf1b7d2eee5b92340 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Jul 2011 08:24:06 +0200 Subject: CGE: cleanup in jbw.h --- engines/cge/btfile.h | 2 +- engines/cge/cfile.h | 5 +---- engines/cge/cge_main.cpp | 2 +- engines/cge/general.cpp | 4 ++-- engines/cge/jbw.h | 44 ++++++-------------------------------------- engines/cge/vga13h.h | 2 +- 6 files changed, 12 insertions(+), 47 deletions(-) diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 1ac093d897..1f3d7217ce 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -32,7 +32,7 @@ namespace CGE { -#define BT_SIZE K(1) +#define BT_SIZE 1024 #define BT_KEYLEN 13 #define BT_LEVELS 2 diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 490e120afa..b5bf9da603 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -33,10 +33,7 @@ namespace CGE { #define LINE_MAX 512 - -#ifndef IOBUF_SIZE -#define IOBUF_SIZE K(2) -#endif +#define IOBUF_SIZE 2048 #define CFREAD(x) read((uint8 *)(x),sizeof(*(x))) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 527d075ade..3958225583 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -54,7 +54,7 @@ namespace CGE { -#define STACK_SIZ (K(2)) +#define STACK_SIZ 2048 #define SVGCHKSUM (1956 + _now + _oldLev + _game + _music + _demoText) #define SVG0NAME ("{{INIT}}" SVG_EXT) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 25b7cc25a5..8639c66653 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -100,12 +100,12 @@ void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, c } const char *progName(const char *ext) { - static char buf[MAXFILE]; + static char buf[kMaxFile]; strcpy(buf, "CGE"); if (ext) { strcat(buf, "."); if (*ext == '.') - ++ext; + ext++; strcat(buf, ext); } diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 89bcb2b03e..d555c82c5a 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -39,33 +39,11 @@ namespace CGE { #define BMP_MODE 0 // -#define BEL 7 -#define BS 8 -#define HT 9 -#define LF 10 -#define FF 12 -#define CR 13 -#define MAXFILE 128 +#define kMaxFile 128 -#define IsWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') -#define IsUpper(c) ((c) >= 'A' && (c) <= 'Z') -#define IsLower(c) ((c) >= 'a' && (c) <= 'z') -#define IsDigit(c) ((c) >= '0' && (c) <= '9') -#define IsAlpha(c) (IsLower(c) || IsUpper(c) || (c) == '_') -#define IsAlNum(c) (IsAlpha(c) || IsDigit(c)) -#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) - -#define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) -#define MAX_TIMER 0x1800B0L - -typedef void (MouseFunType)(); - -#define Lo(d) (((int *) &d)[0]) -#define Hi(d) (((int *) &d)[1]) -#define LoWord(d) ((uint16) Lo(d)) -#define HiWord(d) ((uint16) Hi(d)) -#define K(n) (1024 * (n)) -#define MASK(n) ((1 << n) - 1) +#define IsDigit(c) ((c) >= '0' && (c) <= '9') +#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) +#define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) enum Keys { NoKey = 0, CtrlA, CtrlB, CtrlC, CtrlD, CtrlE, CtrlF, CtrlG, CtrlH, @@ -113,18 +91,8 @@ enum Keys { TwiceRight }; -#define HGC_Cursor 0x0B0C -#define CGA_Cursor 0x0607 -#define OFF_Cursor 0x2000 - -//#define TimerCount (*((volatile long *) ((void _seg *) 0x40 + (void *) 0x6C))) -//#define BreakFlag (*((volatile uint8 *) ((void _seg *) 0x40 + (void *) 0x71))) -//#define PostFlag (*((volatile uint16 *) ((void _seg *) 0x40 + (void *) 0x72))) -//#define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0)) - - -extern uint16 _stklen; -extern uint16 _heaplen; +//extern uint16 _stklen; +//extern uint16 _heaplen; } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 6b56217a1e..26969e7031 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -191,7 +191,7 @@ public: uint8 _takePtr; int _seqPtr; int _shpCnt; - char _file[MAXFILE]; + char _file[kMaxFile]; Sprite *_prev; Sprite *_next; -- cgit v1.2.3 From dc28d9debbd3abb1da176bc6ab0ba596bcbda520 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Jul 2011 08:42:58 +0200 Subject: CGE: rename constants in bitmap --- engines/cge/bitmap.cpp | 41 ++++++++++++++++++++--------------------- engines/cge/bitmap.h | 10 +++++----- engines/cge/jbw.h | 3 --- engines/cge/talk.cpp | 10 +++++----- engines/cge/vga13h.h | 1 + engines/cge/vmenu.cpp | 2 +- 6 files changed, 32 insertions(+), 35 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 29fc4fd8d6..9d898506da 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -38,7 +38,6 @@ namespace CGE { Dac *Bitmap::_pal = NULL; -#define MAXPATH 128 void Bitmap::init() { _pal = NULL; @@ -51,7 +50,7 @@ void Bitmap::deinit() { Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { debugC(1, kDebugBitmap, "Bitmap::Bitmap(%s, %s)", fname, rem ? "true" : "false"); - char pat[MAXPATH]; + char pat[kMaxPath]; forceExt(pat, fname, ".VBM"); #if (BMP_MODE < 2) @@ -107,16 +106,16 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) if (v == NULL) error("No core"); - *(uint16 *) v = CPY | dsiz; // data chunk hader + *(uint16 *) v = kBmpCPY | dsiz; // data chunk hader memset(v + 2, fill, dsiz); // data bytes - *(uint16 *)(v + lsiz - 2) = SKP | ((SCR_WID / 4) - dsiz); // gap + *(uint16 *)(v + lsiz - 2) = kBmpSKP | ((SCR_WID / 4) - dsiz); // gap // Replicate lines byte *destP; for (destP = v + lsiz; destP < (v + psiz); destP += lsiz) Common::copy(v, v + lsiz, destP); - *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 + *(uint16 *)(v + psiz - 2) = kBmpEOI; // plane trailer uint16 // Repliccate planes for (destP = v + psiz; destP < (v + 4 * psiz); destP += psiz) @@ -224,7 +223,7 @@ BMP_PTR Bitmap::code() { } for (bpl = 0; bpl < 4; bpl++) { // once per each bitplane uint8 *bm = _m; - bool skip = (bm[bpl] == TRANS); + bool skip = (bm[bpl] == kPixelTransp); uint16 j; cnt = 0; @@ -232,21 +231,21 @@ BMP_PTR Bitmap::code() { uint8 pix; for (j = bpl; j < _w; j += 4) { pix = bm[j]; - if (_v && pix != TRANS) { + if (_v && pix != kPixelTransp) { if (j < _b[i]._skip) _b[i]._skip = j; if (j >= _b[i]._hide) _b[i]._hide = j + 1; } - if ((pix == TRANS) != skip || cnt >= 0x3FF0) { // end of block - cnt |= (skip) ? SKP : CPY; + if ((pix == kPixelTransp) != skip || cnt >= 0x3FF0) { // end of block + cnt |= (skip) ? kBmpSKP : kBmpCPY; if (_v) *cp = cnt; // store block description uint16 cp = (uint16 *) im; im += 2; - skip = (pix == TRANS); + skip = (pix == kPixelTransp); cnt = 0; } if (! skip) { @@ -262,7 +261,7 @@ BMP_PTR Bitmap::code() { if (skip) { cnt += (SCR_WID - j + 3) / 4; } else { - cnt |= CPY; + cnt |= kBmpCPY; if (_v) *cp = cnt; @@ -274,7 +273,7 @@ BMP_PTR Bitmap::code() { } } if (cnt && ! skip) { - cnt |= CPY; + cnt |= kBmpCPY; if (_v) *cp = cnt; @@ -282,7 +281,7 @@ BMP_PTR Bitmap::code() { im += 2; } if (_v) - *cp = EOI; + *cp = kBmpEOI; cp = (uint16 *) im; im += 2; } @@ -336,12 +335,12 @@ bool Bitmap::solidAt(int16 x, int16 y) { w &= 0x3FFF; switch (t) { - case EOI : + case kBmpEOI: r--; - case SKP : + case kBmpSKP: w = 0; break; - case REP : + case kBmpREP: w = 1; break; } @@ -361,18 +360,18 @@ bool Bitmap::solidAt(int16 x, int16 y) { n += w; switch (t) { - case EOI : + case kBmpEOI: return false; - case SKP : + case kBmpSKP: w = 0; break; - case REP : - case CPY : + case kBmpREP: + case kBmpCPY: if (n - w <= n0 && n > n0) return true; break; } - m += ((t == REP) ? 1 : w); + m += ((t == kBmpREP) ? 1 : w); } } diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 2728e27303..6b931573f8 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -32,12 +32,12 @@ namespace CGE { -#define EOI 0x0000 -#define SKP 0x4000 -#define REP 0x8000 -#define CPY 0xC000 +#define kBmpEOI 0x0000 +#define kBmpSKP 0x4000 +#define kBmpREP 0x8000 +#define kBmpCPY 0xC000 -#define TRANS 0xFE +#define kMaxPath 128 #include "common/pack-start.h" diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index d555c82c5a..4540c1d8e5 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -91,9 +91,6 @@ enum Keys { TwiceRight }; -//extern uint16 _stklen; -//extern uint16 _heaplen; - } // End of namespace CGE #endif diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index c00e7f3a88..a164a69f99 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -210,10 +210,10 @@ Bitmap *Talk::box(uint16 w, uint16 h) { for (int i = 0; i < r; i++) { int j; for (j = 0; j < r - i; j++) { - p[j] = TRANS; - p[w - j - 1] = TRANS; - q[j] = TRANS; - q[w - j - 1] = TRANS; + p[j] = kPixelTransp; + p[w - j - 1] = kPixelTransp; + q[j] = kPixelTransp; + q[w - j - 1] = kPixelTransp; } p[j] = LGRAY; p[w - j - 1] = DGRAY; @@ -305,7 +305,7 @@ void InfoLine::update(const char *tx) { for (pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) { Common::copy(v, v + lsiz, pDest); } - *(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16 + *(uint16 *)(v + psiz - 2) = kBmpEOI; // plane trailer uint16 for (pDest = v + psiz; pDest < (v + 4 * psiz); pDest += psiz) { Common::copy(v, v + psiz, pDest); } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 26969e7031..13bfce4189 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -62,6 +62,7 @@ namespace CGE { #define DGRAY 225 /*219*/ #define GRAY 231 #define LGRAY 237 +#define kPixelTransp 0xFE #define NO_SEQ (-1) #define NO_PTR ((uint8)-1) diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index c65ec6957e..af3d5ff4f5 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -36,7 +36,7 @@ MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { int i = (w += 2 * kMenuBarHM) * h; uint8 *p = (uint8 *) malloc(sizeof(uint8) * i); - memset(p + w, TRANS, i - 2 * w); + memset(p + w, kPixelTransp, i - 2 * w); memset(p, kMenuBarLT, w); memset(p + i - w, kMenuBarRB, w); uint8 *p1 = p; -- cgit v1.2.3 From 32890064585c75bb796417fa87170ebf611897fe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Jul 2011 13:24:09 +0200 Subject: CGE: Rename constants in btfile and cfile --- engines/cge/btfile.cpp | 20 ++++++++++---------- engines/cge/btfile.h | 22 +++++++++++----------- engines/cge/cfile.cpp | 20 ++++++++++---------- engines/cge/cfile.h | 7 ++----- engines/cge/cge_main.cpp | 2 +- engines/cge/vol.cpp | 4 ++-- 6 files changed, 36 insertions(+), 39 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 68d3fe40e3..8e4e8a756f 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -38,9 +38,9 @@ BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) : IoHand(name, mode, crpt) { debugC(1, kDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode); - for (int i = 0; i < BT_LEVELS; i++) { + for (int i = 0; i < kBtLevel; i++) { _buff[i]._page = new BtPage; - _buff[i]._pgNo = BT_NONE; + _buff[i]._pgNo = kBtValNone; _buff[i]._indx = -1; _buff[i]._updt = false; if (_buff[i]._page == NULL) @@ -51,7 +51,7 @@ BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) BtFile::~BtFile() { debugC(1, kDebugFile, "BtFile::~BtFile()"); - for (int i = 0; i < BT_LEVELS; i++) { + for (int i = 0; i < kBtLevel; i++) { putPage(i, false); delete _buff[i]._page; } @@ -82,7 +82,7 @@ BtPage *BtFile::getPage(int lev, uint16 pgn) { _buff[lev]._updt = false; } else { _buff[lev]._page->_hea._count = 0; - _buff[lev]._page->_hea._down = BT_NONE; + _buff[lev]._page->_hea._down = kBtValNone; memset(_buff[lev]._page->_data, '\0', sizeof(_buff[lev]._page->_data)); _buff[lev]._updt = true; } @@ -95,15 +95,15 @@ BtKeypack *BtFile::find(const char *key) { debugC(1, kDebugFile, "BtFile::find(%s)", key); int lev = 0; - uint16 nxt = BT_ROOT; + uint16 nxt = kBtValRoot; while (!_error) { BtPage *pg = getPage(lev, nxt); // search - if (pg->_hea._down != BT_NONE) { + if (pg->_hea._down != kBtValNone) { int i; for (i = 0; i < pg->_hea._count; i++) { // Does this work, or does it have to compare the entire buffer? - if (scumm_strnicmp((const char *)key, (const char*)pg->_inn[i]._key, BT_KEYLEN) < 0) + if (scumm_strnicmp((const char *)key, (const char*)pg->_inn[i]._key, kBtKeySize) < 0) break; } nxt = (i) ? pg->_inn[i - 1]._down : pg->_hea._down; @@ -124,14 +124,14 @@ BtKeypack *BtFile::find(const char *key) { int keycomp(const void *k1, const void *k2) { - return scumm_strnicmp((const char *) k1, (const char*) k2, BT_KEYLEN); + return scumm_strnicmp((const char *) k1, (const char*) k2, kBtKeySize); } void BtFile::make(BtKeypack *keypack, uint16 count) { debugC(1, kDebugFile, "BtFile::make(keypack, %d)", count); -#if BT_LEVELS != 2 +#if kBtLevel != 2 #error This tiny BTREE implementation works with exactly 2 levels! #endif _fqsort(keypack, count, sizeof(*keypack), keycomp); @@ -144,7 +144,7 @@ void BtFile::make(BtKeypack *keypack, uint16 count) { if (Leaf->_hea._count >= ArrayCount(Leaf->_lea)) { putPage(1, true); // save filled page Leaf = getPage(1, ++n); // take empty page - memcpy(Root->_inn[Root->_hea._count]._key, keypack->_key, BT_KEYLEN); + memcpy(Root->_inn[Root->_hea._count]._key, keypack->_key, kBtKeySize); Root->_inn[Root->_hea._count++]._down = n; _buff[0]._updt = true; } diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 1f3d7217ce..4784ffd6ed 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -32,23 +32,23 @@ namespace CGE { -#define BT_SIZE 1024 -#define BT_KEYLEN 13 -#define BT_LEVELS 2 +#define kBtSize 1024 +#define kBtKeySize 13 +#define kBtLevel 2 -#define BT_NONE 0xFFFF -#define BT_ROOT 0 +#define kBtValNone 0xFFFF +#define kBtValRoot 0 #include "common/pack-start.h" // START STRUCT PACKING struct BtKeypack { - char _key[BT_KEYLEN]; + char _key[kBtKeySize]; uint32 _mark; uint16 _size; }; struct Inner { - uint8 _key[BT_KEYLEN]; + uint8 _key[kBtKeySize]; uint16 _down; }; @@ -61,11 +61,11 @@ struct BtPage { Hea _hea; union { // dummy filler to make proper size of union - uint8 _data[BT_SIZE - sizeof(Hea)]; + uint8 _data[kBtSize - sizeof(Hea)]; // inner version of data: key + word-sized page link - Inner _inn[(BT_SIZE - sizeof(Hea)) / sizeof(Inner)]; + Inner _inn[(kBtSize - sizeof(Hea)) / sizeof(Inner)]; // leaf version of data: key + all user data - BtKeypack _lea[(BT_SIZE - sizeof(Hea)) / sizeof(BtKeypack)]; + BtKeypack _lea[(kBtSize - sizeof(Hea)) / sizeof(BtKeypack)]; }; }; @@ -78,7 +78,7 @@ class BtFile : public IoHand { uint16 _pgNo; int _indx; bool _updt; - } _buff[BT_LEVELS]; + } _buff[kBtLevel]; void putPage(int lev, bool hard); BtPage *getPage(int lev, uint16 pgn); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 5cbf078610..1486b78902 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -40,7 +40,7 @@ IoBuf::IoBuf(IOMODE mode, CRYPT *crpt) _lim(0) { debugC(1, kDebugFile, "IoBuf::IoBuf(%d, crpt)", mode); - _buff = (uint8 *) malloc(sizeof(uint8) * IOBUF_SIZE); + _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); if (_buff == NULL) error("No core for I/O"); } @@ -53,7 +53,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) _lim(0) { debugC(1, kDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode); - _buff = (uint8 *) malloc(sizeof(uint8) * IOBUF_SIZE); + _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); if (_buff == NULL) error("No core for I/O [%s]", name); } @@ -71,7 +71,7 @@ void IoBuf::readBuf() { debugC(4, kDebugFile, "IoBuf::readBuf()"); _bufMark = IoHand::mark(); - _lim = IoHand::read(_buff, IOBUF_SIZE); + _lim = IoHand::read(_buff, kBufferSize); _ptr = 0; } @@ -115,14 +115,14 @@ uint16 IoBuf::read(uint8 *buf) { uint16 total = 0; - while (total < LINE_MAX - 2) { + while (total < kLineMaxSize - 2) { if (_ptr >= _lim) readBuf(); uint8 *p = _buff + _ptr; uint16 n = _lim - _ptr; if (n) { - if (total + n >= LINE_MAX - 2) - n = LINE_MAX - 2 - total; + if (total + n >= kLineMaxSize - 2) + n = kLineMaxSize - 2 - total; uint8 *eol = (uint8 *) memchr(p, '\r', n); if (eol) n = (uint16)(eol - p); @@ -162,7 +162,7 @@ uint16 IoBuf::write(void *buf, uint16 len) { uint16 tot = 0; while (len) { - uint16 n = IOBUF_SIZE - _lim; + uint16 n = kBufferSize - _lim; if (n > len) n = len; if (n) { @@ -213,13 +213,13 @@ int IoBuf::read() { void IoBuf::write(uint8 b) { debugC(1, kDebugFile, "IoBuf::write(%d)", b); - if (_lim >= IOBUF_SIZE) + if (_lim >= kBufferSize) writeBuf(); _buff[_lim++] = b; } -uint16 CFile::_maxLineLen = LINE_MAX; +uint16 CFile::_maxLineLen = kLineMaxSize; CFile::CFile(const char *name, IOMODE mode, CRYPT *crpt) @@ -280,7 +280,7 @@ void CFile::append(CFile &f) { seek(size()); if (f._error == 0) { while (true) { - if ((_lim = f.IoHand::read(_buff, IOBUF_SIZE)) == IOBUF_SIZE) + if ((_lim = f.IoHand::read(_buff, kBufferSize)) == kBufferSize) writeBuf(); else break; diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index b5bf9da603..227b0f6a63 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -32,11 +32,8 @@ namespace CGE { -#define LINE_MAX 512 -#define IOBUF_SIZE 2048 - -#define CFREAD(x) read((uint8 *)(x),sizeof(*(x))) - +#define kLineMaxSize 512 +#define kBufferSize 2048 class IoBuf : public IoHand { protected: diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 3958225583..a32356e08a 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -433,7 +433,7 @@ void CGEEngine::loadHeroXY() { INI_FILE cf(progName(".HXY")); memset(_heroXY, 0, sizeof(_heroXY)); if (!cf._error) - cf.CFREAD(&_heroXY); + cf.read((uint8 *)(&_heroXY),sizeof(*(&_heroXY))); } void CGEEngine::loadMapping() { diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index cff735abf5..94ec2fc7ad 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -111,8 +111,8 @@ void VFile::readBuf() { } _bufMark = _dat->_file.mark(); long n = _endMark - _bufMark; - if (n > IOBUF_SIZE) - n = IOBUF_SIZE; + if (n > kBufferSize) + n = kBufferSize; _lim = _dat->_file.read(_buff, (uint16) n); _ptr = 0; } -- cgit v1.2.3 From 420516b45e1822c249775c68f9c61b62aba5de0b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Jul 2011 14:22:56 +0200 Subject: CGE: Rename Debug channel constants --- engines/cge/bitmap.cpp | 24 ++++++------ engines/cge/btfile.cpp | 12 +++--- engines/cge/cfile.cpp | 32 ++++++++-------- engines/cge/cge.cpp | 13 +++---- engines/cge/cge.h | 7 ++-- engines/cge/cge_main.cpp | 64 ++++++++++++++++---------------- engines/cge/config.cpp | 2 +- engines/cge/snail.cpp | 96 ++++++++++++++++++++++++------------------------ engines/cge/text.cpp | 2 +- engines/cge/vga13h.cpp | 6 +-- engines/cge/vol.cpp | 16 ++++---- 11 files changed, 136 insertions(+), 138 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 9d898506da..8f335fed60 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -48,7 +48,7 @@ void Bitmap::deinit() { #pragma argsused Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { - debugC(1, kDebugBitmap, "Bitmap::Bitmap(%s, %s)", fname, rem ? "true" : "false"); + debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%s, %s)", fname, rem ? "true" : "false"); char pat[kMaxPath]; forceExt(pat, fname, ".VBM"); @@ -82,7 +82,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL), _map(0) { - debugC(1, kDebugBitmap, "Bitmap::Bitmap(%d, %d, map)", w, h); + debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%d, %d, map)", w, h); if (map) code(); } @@ -96,7 +96,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) _h(h), _m(NULL), _map(0) { - debugC(1, kDebugBitmap, "Bitmap::Bitmap(%d, %d, %d)", w, h, fill); + debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%d, %d, %d)", w, h, fill); uint16 dsiz = _w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap @@ -136,7 +136,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), _map(0) { - debugC(1, kDebugBitmap, "Bitmap::Bitmap(bmp)"); + debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(bmp)"); uint8 *v0 = bmp._v; if (v0) { uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); @@ -151,7 +151,7 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), Bitmap::~Bitmap() { - debugC(6, kDebugBitmap, "Bitmap::~Bitmap()"); + debugC(6, kCGEDebugBitmap, "Bitmap::~Bitmap()"); free(_m); delete[] _v; @@ -159,7 +159,7 @@ Bitmap::~Bitmap() { Bitmap &Bitmap::operator = (const Bitmap &bmp) { - debugC(1, kDebugBitmap, "&Bitmap::operator ="); + debugC(1, kCGEDebugBitmap, "&Bitmap::operator ="); uint8 *v0 = bmp._v; _w = bmp._w; @@ -183,7 +183,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { uint16 Bitmap::moveVmap(uint8 *buf) { - debugC(1, kDebugBitmap, "Bitmap::moveVmap(buf)"); + debugC(1, kCGEDebugBitmap, "Bitmap::moveVmap(buf)"); if (_v) { uint16 vsiz = (uint8 *)_b - (uint8 *)_v; @@ -198,7 +198,7 @@ uint16 Bitmap::moveVmap(uint8 *buf) { BMP_PTR Bitmap::code() { - debugC(1, kDebugBitmap, "Bitmap::code()"); + debugC(1, kCGEDebugBitmap, "Bitmap::code()"); if (!_m) return false; @@ -314,7 +314,7 @@ BMP_PTR Bitmap::code() { bool Bitmap::solidAt(int16 x, int16 y) { - debugC(6, kDebugBitmap, "Bitmap::solidAt(%d, %d)", x, y); + debugC(6, kCGEDebugBitmap, "Bitmap::solidAt(%d, %d)", x, y); uint8 *m; uint16 r, n, n0; @@ -377,7 +377,7 @@ bool Bitmap::solidAt(int16 x, int16 y) { bool Bitmap::saveVBM(XFile *f) { - debugC(1, kDebugBitmap, "Bitmap::saveVBM(f)"); + debugC(1, kCGEDebugBitmap, "Bitmap::saveVBM(f)"); uint16 p = (_pal != NULL), n = ((uint16)(((uint8 *)_b) - _v)) + _h * sizeof(HideDesc); @@ -405,7 +405,7 @@ bool Bitmap::saveVBM(XFile *f) { bool Bitmap::loadVBM(XFile *f) { - debugC(5, kDebugBitmap, "Bitmap::loadVBM(f)"); + debugC(5, kCGEDebugBitmap, "Bitmap::loadVBM(f)"); uint16 p = 0, n = 0; if (f->_error == 0) @@ -448,7 +448,7 @@ bool Bitmap::loadVBM(XFile *f) { } bool Bitmap::loadBMP(XFile *f) { - debugC(1, kDebugBitmap, "Bitmap::loadBMP(f)"); + debugC(1, kCGEDebugBitmap, "Bitmap::loadBMP(f)"); struct { char BM[2]; diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 8e4e8a756f..e3d9f729d9 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -36,7 +36,7 @@ namespace CGE { BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) : IoHand(name, mode, crpt) { - debugC(1, kDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode); + debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode); for (int i = 0; i < kBtLevel; i++) { _buff[i]._page = new BtPage; @@ -50,7 +50,7 @@ BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) BtFile::~BtFile() { - debugC(1, kDebugFile, "BtFile::~BtFile()"); + debugC(1, kCGEDebugFile, "BtFile::~BtFile()"); for (int i = 0; i < kBtLevel; i++) { putPage(i, false); delete _buff[i]._page; @@ -59,7 +59,7 @@ BtFile::~BtFile() { void BtFile::putPage(int lev, bool hard) { - debugC(1, kDebugFile, "BtFile::putPage(%d, %s)", lev, hard ? "true" : "false"); + debugC(1, kCGEDebugFile, "BtFile::putPage(%d, %s)", lev, hard ? "true" : "false"); if (hard || _buff[lev]._updt) { seek(_buff[lev]._pgNo * sizeof(BtPage)); @@ -70,7 +70,7 @@ void BtFile::putPage(int lev, bool hard) { BtPage *BtFile::getPage(int lev, uint16 pgn) { - debugC(1, kDebugFile, "BtFile::getPage(%d, %d)", lev, pgn); + debugC(1, kCGEDebugFile, "BtFile::getPage(%d, %d)", lev, pgn); if (_buff[lev]._pgNo != pgn) { int32 pos = pgn * sizeof(BtPage); @@ -92,7 +92,7 @@ BtPage *BtFile::getPage(int lev, uint16 pgn) { } BtKeypack *BtFile::find(const char *key) { - debugC(1, kDebugFile, "BtFile::find(%s)", key); + debugC(1, kCGEDebugFile, "BtFile::find(%s)", key); int lev = 0; uint16 nxt = kBtValRoot; @@ -129,7 +129,7 @@ int keycomp(const void *k1, const void *k2) { void BtFile::make(BtKeypack *keypack, uint16 count) { - debugC(1, kDebugFile, "BtFile::make(keypack, %d)", count); + debugC(1, kCGEDebugFile, "BtFile::make(keypack, %d)", count); #if kBtLevel != 2 #error This tiny BTREE implementation works with exactly 2 levels! diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 1486b78902..f0eeb30bff 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -38,7 +38,7 @@ IoBuf::IoBuf(IOMODE mode, CRYPT *crpt) _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kDebugFile, "IoBuf::IoBuf(%d, crpt)", mode); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crpt)", mode); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); if (_buff == NULL) @@ -51,7 +51,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); if (_buff == NULL) @@ -59,7 +59,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) } IoBuf::~IoBuf() { - debugC(6, kDebugFile, "IoBuf::~IoBuf()"); + debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()"); if (_mode > REA) writeBuf(); @@ -68,7 +68,7 @@ IoBuf::~IoBuf() { void IoBuf::readBuf() { - debugC(4, kDebugFile, "IoBuf::readBuf()"); + debugC(4, kCGEDebugFile, "IoBuf::readBuf()"); _bufMark = IoHand::mark(); _lim = IoHand::read(_buff, kBufferSize); @@ -77,7 +77,7 @@ void IoBuf::readBuf() { void IoBuf::writeBuf() { - debugC(4, kDebugFile, "IoBuf::writeBuf()"); + debugC(4, kCGEDebugFile, "IoBuf::writeBuf()"); if (_lim) { IoHand::write(_buff, _lim); @@ -88,7 +88,7 @@ void IoBuf::writeBuf() { uint16 IoBuf::read(void *buf, uint16 len) { - debugC(4, kDebugFile, "IoBuf::read(buf, %d)", len); + debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len); uint16 total = 0; while (len) { @@ -111,7 +111,7 @@ uint16 IoBuf::read(void *buf, uint16 len) { uint16 IoBuf::read(uint8 *buf) { - debugC(3, kDebugFile, "IoBuf::read(buf)"); + debugC(3, kCGEDebugFile, "IoBuf::read(buf)"); uint16 total = 0; @@ -158,7 +158,7 @@ uint16 IoBuf::read(uint8 *buf) { uint16 IoBuf::write(void *buf, uint16 len) { - debugC(1, kDebugFile, "IoBuf::write(buf, %d)", len); + debugC(1, kCGEDebugFile, "IoBuf::write(buf, %d)", len); uint16 tot = 0; while (len) { @@ -179,7 +179,7 @@ uint16 IoBuf::write(void *buf, uint16 len) { uint16 IoBuf::write(uint8 *buf) { - debugC(1, kDebugFile, "IoBuf::write(buf)"); + debugC(1, kCGEDebugFile, "IoBuf::write(buf)"); uint16 len = 0; if (buf) { @@ -199,7 +199,7 @@ uint16 IoBuf::write(uint8 *buf) { int IoBuf::read() { - debugC(1, kDebugFile, "IoBuf::read()"); + debugC(1, kCGEDebugFile, "IoBuf::read()"); if (_ptr >= _lim) { readBuf(); @@ -211,7 +211,7 @@ int IoBuf::read() { void IoBuf::write(uint8 b) { - debugC(1, kDebugFile, "IoBuf::write(%d)", b); + debugC(1, kCGEDebugFile, "IoBuf::write(%d)", b); if (_lim >= kBufferSize) writeBuf(); @@ -224,7 +224,7 @@ uint16 CFile::_maxLineLen = kLineMaxSize; CFile::CFile(const char *name, IOMODE mode, CRYPT *crpt) : IoBuf(name, mode, crpt) { - debugC(1, kDebugFile, "CFile::CFile(%s, %d, crpt)", name, mode); + debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crpt)", name, mode); } @@ -233,7 +233,7 @@ CFile::~CFile() { void CFile::flush() { - debugC(1, kDebugFile, "CFile::flush()"); + debugC(1, kCGEDebugFile, "CFile::flush()"); if (_mode > REA) writeBuf(); @@ -250,14 +250,14 @@ void CFile::flush() { long CFile::mark() { - debugC(5, kDebugFile, "CFile::mark()"); + debugC(5, kCGEDebugFile, "CFile::mark()"); return _bufMark + ((_mode > REA) ? _lim : _ptr); } long CFile::seek(long pos) { - debugC(1, kDebugFile, "CFile::seek(%ld)", pos); + debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos); if (pos >= _bufMark && pos < _bufMark + _lim) { ((_mode == REA) ? _ptr : _lim) = (uint16)(pos - _bufMark); @@ -275,7 +275,7 @@ long CFile::seek(long pos) { void CFile::append(CFile &f) { - debugC(1, kDebugFile, "CFile::append(f)"); + debugC(1, kCGEDebugFile, "CFile::append(f)"); seek(size()); if (f._error == 0) { diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 239fc89dfc..a3478b14f8 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -44,10 +44,9 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) : Engine(syst), _gameDescription(gameDescription), _randomSource("cge") { // Debug/console setup - DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel"); - DebugMan.addDebugChannel(kDebugBitmap, "bitmap", "CGE Bitmap debug channel"); - DebugMan.addDebugChannel(kDebugFile, "file", "CGE IO debug channel"); - DebugMan.addDebugChannel(kDebugEngine, "engine", "CGE Engine debug channel"); + DebugMan.addDebugChannel(kCGEDebugBitmap, "bitmap", "CGE Bitmap debug channel"); + DebugMan.addDebugChannel(kCGEDebugFile, "file", "CGE IO debug channel"); + DebugMan.addDebugChannel(kCGEDebugEngine, "engine", "CGE Engine debug channel"); _isDemo = _gameDescription->flags & ADGF_DEMO; _startupMode = 1; @@ -59,7 +58,7 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) } void CGEEngine::setup() { - debugC(1, kDebugEngine, "CGEEngine::setup()"); + debugC(1, kCGEDebugEngine, "CGEEngine::setup()"); // Initialise fields _lastFrame = 0; @@ -137,7 +136,7 @@ void CGEEngine::setup() { } CGEEngine::~CGEEngine() { - debugC(1, kDebugEngine, "CGEEngine::~CGEEngine()"); + debugC(1, kCGEDebugEngine, "CGEEngine::~CGEEngine()"); // Call classes with static members to clear them up Talk::deinit(); @@ -175,7 +174,7 @@ CGEEngine::~CGEEngine() { } Common::Error CGEEngine::run() { - debugC(1, kDebugEngine, "CGEEngine::run()"); + debugC(1, kCGEDebugEngine, "CGEEngine::run()"); // Initialize graphics using following: initGraphics(320, 200, false); diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 011e08bb31..5bc97d6eff 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -44,10 +44,9 @@ class Sprite; // our engine debug channels enum { - kCGEDebug = 1 << 0, - kDebugBitmap = 1 << 1, - kDebugFile = 1 << 2, - kDebugEngine = 1 << 3 + kCGEDebugBitmap = 1 << 0, + kCGEDebugFile = 1 << 1, + kCGEDebugEngine = 1 << 2 }; enum SnList { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index a32356e08a..4b1b0b695e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -104,7 +104,7 @@ Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; extern Dac _stdPal[58]; void CGEEngine::syncHeader(Common::Serializer &s) { - debugC(1, kDebugEngine, "CGEEngine::syncHeader(s)"); + debugC(1, kCGEDebugEngine, "CGEEngine::syncHeader(s)"); int i; @@ -144,7 +144,7 @@ void CGEEngine::syncHeader(Common::Serializer &s) { } bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { - debugC(1, kDebugEngine, "CGEEngine::loadgame(file, %s)", tiny ? "true" : "false"); + debugC(1, kCGEDebugEngine, "CGEEngine::loadgame(file, %s)", tiny ? "true" : "false"); Common::MemoryReadStream *readStream; SavegameHeader saveHeader; @@ -362,7 +362,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt } } } - debugC(1, kDebugEngine, "CGEEngine::saveSound()"); + debugC(1, kCGEDebugEngine, "CGEEngine::saveSound()"); } @@ -399,13 +399,13 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade } void CGEEngine::heroCover(int cvr) { - debugC(1, kDebugEngine, "CGEEngine::heroCover(%d)", cvr); + debugC(1, kCGEDebugEngine, "CGEEngine::heroCover(%d)", cvr); SNPOST(SNCOVER, 1, cvr, NULL); } void CGEEngine::trouble(int seq, int txt) { - debugC(1, kDebugEngine, "CGEEngine::trouble(%d, %d)", seq, txt); + debugC(1, kCGEDebugEngine, "CGEEngine::trouble(%d, %d)", seq, txt); _hero->park(); SNPOST(SNWAIT, -1, -1, _hero); @@ -416,19 +416,19 @@ void CGEEngine::trouble(int seq, int txt) { } void CGEEngine::offUse() { - debugC(1, kDebugEngine, "CGEEngine::offUse()"); + debugC(1, kCGEDebugEngine, "CGEEngine::offUse()"); trouble(OFF_USE, OFF_USE_TEXT + new_random(_offUseCount)); } void CGEEngine::tooFar() { - debugC(1, kDebugEngine, "CGEEngine::tooFar()"); + debugC(1, kCGEDebugEngine, "CGEEngine::tooFar()"); trouble(TOO_FAR, TOO_FAR_TEXT); } void CGEEngine::loadHeroXY() { - debugC(1, kDebugEngine, "CGEEngine::loadHeroXY()"); + debugC(1, kCGEDebugEngine, "CGEEngine::loadHeroXY()"); INI_FILE cf(progName(".HXY")); memset(_heroXY, 0, sizeof(_heroXY)); @@ -437,7 +437,7 @@ void CGEEngine::loadHeroXY() { } void CGEEngine::loadMapping() { - debugC(1, kDebugEngine, "CGEEngine::loadMapping()"); + debugC(1, kCGEDebugEngine, "CGEEngine::loadMapping()"); if (_now <= CAVE_MAX) { INI_FILE cf(progName(".TAB")); @@ -480,7 +480,7 @@ void SQUARE::touch(uint16 mask, int x, int y) { void CGEEngine::setMapBrick(int x, int z) { - debugC(1, kDebugEngine, "CGEEngine::setMapBrick(%d, %d)", x, z); + debugC(1, kCGEDebugEngine, "CGEEngine::setMapBrick(%d, %d)", x, z); SQUARE *s = new SQUARE(this); if (s) { @@ -495,14 +495,14 @@ void CGEEngine::setMapBrick(int x, int z) { } void CGEEngine::keyClick() { - debugC(1, kDebugEngine, "CGEEngine::keyClick()"); + debugC(1, kCGEDebugEngine, "CGEEngine::keyClick()"); SNPOST_(SNSOUND, -1, 5, NULL); } void CGEEngine::resetQSwitch() { - debugC(1, kDebugEngine, "CGEEngine::resetQSwitch()"); + debugC(1, kCGEDebugEngine, "CGEEngine::resetQSwitch()"); SNPOST_(SNSEQ, 123, 0, NULL); keyClick(); @@ -510,7 +510,7 @@ void CGEEngine::resetQSwitch() { void CGEEngine::quit() { - debugC(1, kDebugEngine, "CGEEngine::quit()"); + debugC(1, kCGEDebugEngine, "CGEEngine::quit()"); static Choice QuitMenu[] = { { NULL, &CGEEngine::startCountDown }, @@ -534,13 +534,13 @@ void CGEEngine::quit() { void CGEEngine::AltCtrlDel() { - debugC(1, kDebugEngine, "CGEEngine::AltCtrlDel()"); + debugC(1, kCGEDebugEngine, "CGEEngine::AltCtrlDel()"); SNPOST_(SNSAY, -1, A_C_D_TEXT, _hero); } void CGEEngine::miniStep(int stp) { - debugC(1, kDebugEngine, "CGEEngine::miniStep(%d)", stp); + debugC(1, kCGEDebugEngine, "CGEEngine::miniStep(%d)", stp); if (stp < 0) _miniCave->_flags._hide = true; @@ -554,14 +554,14 @@ void CGEEngine::miniStep(int stp) { } void CGEEngine::postMiniStep(int step) { - debugC(6, kDebugEngine, "CGEEngine::postMiniStep(%d)", step); + debugC(6, kCGEDebugEngine, "CGEEngine::postMiniStep(%d)", step); if (_miniCave && step != _recentStep) SNPOST2_(SNEXEC, -1, _recentStep = step, kMiniStep); } void CGEEngine::showBak(int ref) { - debugC(1, kDebugEngine, "CGEEngine::showBack(%d)", ref); + debugC(1, kCGEDebugEngine, "CGEEngine::showBack(%d)", ref); Sprite *spr = _vga->_spareQ->locate(ref); if (spr) { @@ -576,7 +576,7 @@ void CGEEngine::showBak(int ref) { } void CGEEngine::caveUp() { - debugC(1, kDebugEngine, "CGEEngine::caveUp()"); + debugC(1, kCGEDebugEngine, "CGEEngine::caveUp()"); int BakRef = 1000 * _now; if (_music) @@ -640,7 +640,7 @@ void CGEEngine::caveUp() { void CGEEngine::caveDown() { - debugC(1, kDebugEngine, "CGEEngine::caveDown()"); + debugC(1, kCGEDebugEngine, "CGEEngine::caveDown()"); Sprite *spr; if (!_horzLine->_flags._hide) @@ -659,14 +659,14 @@ void CGEEngine::caveDown() { } void CGEEngine::xCave() { - debugC(6, kDebugEngine, "CGEEngine::xCave()"); + debugC(6, kCGEDebugEngine, "CGEEngine::xCave()"); caveDown(); caveUp(); } void CGEEngine::qGame() { - debugC(1, kDebugEngine, "CGEEngine::qGame()"); + debugC(1, kCGEDebugEngine, "CGEEngine::qGame()"); caveDown(); _oldLev = _lev; @@ -681,7 +681,7 @@ void CGEEngine::qGame() { void CGEEngine::switchCave(int cav) { - debugC(1, kDebugEngine, "CGEEngine::switchCave(%d)", cav); + debugC(1, kCGEDebugEngine, "CGEEngine::switchCave(%d)", cav); if (cav != _now) { _heart->_enable = false; @@ -918,7 +918,7 @@ void System::tick() { } void CGEEngine::switchColorMode() { - debugC(1, kDebugEngine, "CGEEngine::switchColorMode()"); + debugC(1, kCGEDebugEngine, "CGEEngine::switchColorMode()"); SNPOST_(SNSEQ, 121, _vga->_mono = !_vga->_mono, NULL); keyClick(); @@ -926,7 +926,7 @@ void CGEEngine::switchColorMode() { } void CGEEngine::switchMusic() { - debugC(1, kDebugEngine, "CGEEngine::switchMusic()"); + debugC(1, kCGEDebugEngine, "CGEEngine::switchMusic()"); if (_keyboard->_key[ALT]) { if (Vmenu::_addr) @@ -950,14 +950,14 @@ void CGEEngine::switchMusic() { } void CGEEngine::startCountDown() { - debugC(1, kDebugEngine, "CGEEngine::startCountDown()"); + debugC(1, kCGEDebugEngine, "CGEEngine::startCountDown()"); //SNPOST(SNSEQ, 123, 0, NULL); switchCave(-1); } void CGEEngine::takeName() { - debugC(1, kDebugEngine, "CGEEngine::takeName()"); + debugC(1, kCGEDebugEngine, "CGEEngine::takeName()"); if (GetText::_ptr) SNPOST_(SNKILL, -1, 0, GetText::_ptr); @@ -975,7 +975,7 @@ void CGEEngine::takeName() { } void CGEEngine::switchMapping() { - debugC(1, kDebugEngine, "CGEEngine::switchMapping()"); + debugC(1, kCGEDebugEngine, "CGEEngine::switchMapping()"); if (_horzLine->_flags._hide) { int i; @@ -996,7 +996,7 @@ void CGEEngine::switchMapping() { } void CGEEngine::killSprite() { - debugC(1, kDebugEngine, "CGEEngine::killSprite()"); + debugC(1, kCGEDebugEngine, "CGEEngine::killSprite()"); _sprite->_flags._kill = true; _sprite->_flags._bDel = true; @@ -1005,7 +1005,7 @@ void CGEEngine::killSprite() { } void CGEEngine::pushSprite() { - debugC(1, kDebugEngine, "CGEEngine::pushSprite()"); + debugC(1, kCGEDebugEngine, "CGEEngine::pushSprite()"); Sprite *spr = _sprite->_prev; if (spr) { @@ -1017,7 +1017,7 @@ void CGEEngine::pushSprite() { } void CGEEngine::pullSprite() { - debugC(1, kDebugEngine, "CGEEngine::pullSprite()"); + debugC(1, kCGEDebugEngine, "CGEEngine::pullSprite()"); bool ok = false; Sprite *spr = _sprite->_next; @@ -1036,13 +1036,13 @@ void CGEEngine::pullSprite() { } void CGEEngine::nextStep() { - debugC(1, kDebugEngine, "CGEEngine::nextStep()"); + debugC(1, kCGEDebugEngine, "CGEEngine::nextStep()"); SNPOST_(SNSTEP, 0, 0, _sprite); } void CGEEngine::saveMapping() { - debugC(1, kDebugEngine, "CGEEngine::saveMapping()"); + debugC(1, kCGEDebugEngine, "CGEEngine::saveMapping()"); IoHand cfTab(progName(".TAB"), UPD); if (!cfTab._error) { diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index b49d2b77ea..2649afc241 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -39,7 +39,7 @@ static Choice *_cho; static int _hlp; void CGEEngine::snSelect() { - debugC(1, kDebugEngine, "CGEEngine::snSelect()"); + debugC(1, kCGEDebugEngine, "CGEEngine::snSelect()"); inf(_text->getText(_hlp)); _talk->gotoxy(_talk->_x, kFontHigh / 2); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index b0f56be476..c4b4b383d0 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -46,7 +46,7 @@ extern Sprite *_pocLight; extern Sprite *_pocket[]; void CGEEngine::snGame(Sprite *spr, int num) { - debugC(1, kDebugEngine, "CGEEngine::snGame(spr, %d)", num); + debugC(1, kCGEDebugEngine, "CGEEngine::snGame(spr, %d)", num); switch (num) { case 1 : { @@ -257,7 +257,7 @@ void CGEEngine::snGame(Sprite *spr, int num) { void CGEEngine::expandSprite(Sprite *spr) { - debugC(5, kDebugEngine, "CGEEngine::expandSprite(spr)"); + debugC(5, kCGEDebugEngine, "CGEEngine::expandSprite(spr)"); if (spr) _vga->_showQ->insert(_vga->_spareQ->remove(spr)); @@ -265,14 +265,14 @@ void CGEEngine::expandSprite(Sprite *spr) { void CGEEngine::contractSprite(Sprite *spr) { - debugC(1, kDebugEngine, "CGEEngine::contractSprite(spr)"); + debugC(1, kCGEDebugEngine, "CGEEngine::contractSprite(spr)"); if (spr) _vga->_spareQ->append(_vga->_showQ->remove(spr)); } int CGEEngine::findPocket(Sprite *spr) { - debugC(1, kDebugEngine, "CGEEngine::findPocket(spr)"); + debugC(1, kCGEDebugEngine, "CGEEngine::findPocket(spr)"); for (int i = 0; i < POCKET_NX; i++) if (_pocket[i] == spr) @@ -282,7 +282,7 @@ int CGEEngine::findPocket(Sprite *spr) { void CGEEngine::selectPocket(int n) { - debugC(1, kDebugEngine, "CGEEngine::selectPocket(%d)", n); + debugC(1, kCGEDebugEngine, "CGEEngine::selectPocket(%d)", n); if (n < 0 || (_pocLight->_seqPtr && _pocPtr == n)) { _pocLight->step(0); @@ -299,7 +299,7 @@ void CGEEngine::selectPocket(int n) { } void CGEEngine::pocFul() { - debugC(1, kDebugEngine, "CGEEngine::pocFul()"); + debugC(1, kCGEDebugEngine, "CGEEngine::pocFul()"); _hero->park(); SNPOST(SNWAIT, -1, -1, _hero); @@ -310,13 +310,13 @@ void CGEEngine::pocFul() { } void CGEEngine::hide1(Sprite *spr) { - debugC(1, kDebugEngine, "CGEEngine::hide1(spr)"); + debugC(1, kCGEDebugEngine, "CGEEngine::hide1(spr)"); SNPOST_(SNGHOST, -1, 0, spr->ghost()); } void CGEEngine::snGhost(Bitmap *bmp) { - debugC(1, kDebugEngine, "CGEEngine::snGhost(bmp)"); + debugC(1, kCGEDebugEngine, "CGEEngine::snGhost(bmp)"); bmp->hide(bmp->_map & 0xFFFF, bmp->_map >> 16); bmp->_m = NULL; @@ -325,7 +325,7 @@ void CGEEngine::snGhost(Bitmap *bmp) { } void CGEEngine::feedSnail(Sprite *spr, SnList snq) { - debugC(1, kDebugEngine, "CGEEngine::feedSnail(spr, snq)"); + debugC(1, kCGEDebugEngine, "CGEEngine::feedSnail(spr, snq)"); if (spr) if (spr->active()) { @@ -473,7 +473,7 @@ void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { } void CGEEngine::snNNext(Sprite *spr, int p) { - debugC(1, kDebugEngine, "CGEEngine::snNNext(spr, %d)", p); + debugC(1, kCGEDebugEngine, "CGEEngine::snNNext(spr, %d)", p); if (spr) if (spr->_nearPtr != NO_PTR) @@ -481,7 +481,7 @@ void CGEEngine::snNNext(Sprite *spr, int p) { } void CGEEngine::snTNext(Sprite *spr, int p) { - debugC(1, kDebugEngine, "CGEEngine::snTNext(spr, %d)", p); + debugC(1, kCGEDebugEngine, "CGEEngine::snTNext(spr, %d)", p); if (spr) if (spr->_takePtr != NO_PTR) @@ -489,7 +489,7 @@ void CGEEngine::snTNext(Sprite *spr, int p) { } void CGEEngine::snRNNext(Sprite *spr, int p) { - debugC(1, kDebugEngine, "CGEEngine::snRNNext(spr, %d)", p); + debugC(1, kCGEDebugEngine, "CGEEngine::snRNNext(spr, %d)", p); if (spr) if (spr->_nearPtr != NO_PTR) @@ -498,7 +498,7 @@ void CGEEngine::snRNNext(Sprite *spr, int p) { void CGEEngine::snRTNext(Sprite *spr, int p) { - debugC(1, kDebugEngine, "CGEEngine::snRTNext(spr, %d)", p); + debugC(1, kCGEDebugEngine, "CGEEngine::snRTNext(spr, %d)", p); if (spr) if (spr->_takePtr != NO_PTR) @@ -506,7 +506,7 @@ void CGEEngine::snRTNext(Sprite *spr, int p) { } void CGEEngine::snZTrim(Sprite *spr) { - debugC(4, kDebugEngine, "CGEEngine::snZTrim(spr)"); + debugC(4, kCGEDebugEngine, "CGEEngine::snZTrim(spr)"); if (spr) if (spr->active()) { @@ -524,7 +524,7 @@ void CGEEngine::snZTrim(Sprite *spr) { } void CGEEngine::snHide(Sprite *spr, int val) { - debugC(1, kDebugEngine, "CGEEngine::snHide(spr, %d)", val); + debugC(1, kCGEDebugEngine, "CGEEngine::snHide(spr, %d)", val); if (spr) { spr->_flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags._hide); @@ -534,21 +534,21 @@ void CGEEngine::snHide(Sprite *spr, int val) { } void CGEEngine::snRmNear(Sprite *spr) { - debugC(1, kDebugEngine, "CGEEngine::snRmNear(spr)"); + debugC(1, kCGEDebugEngine, "CGEEngine::snRmNear(spr)"); if (spr) spr->_nearPtr = NO_PTR; } void CGEEngine::snRmTake(Sprite *spr) { - debugC(1, kDebugEngine, "CGEEngine::snRmTake(spr)"); + debugC(1, kCGEDebugEngine, "CGEEngine::snRmTake(spr)"); if (spr) spr->_takePtr = NO_PTR; } void CGEEngine::snSeq(Sprite *spr, int val) { - debugC(1, kDebugEngine, "CGEEngine::snSeq(spr, %d)", val); + debugC(1, kCGEDebugEngine, "CGEEngine::snSeq(spr, %d)", val); if (spr) { if (spr == _hero && val == 0) @@ -559,14 +559,14 @@ void CGEEngine::snSeq(Sprite *spr, int val) { } void CGEEngine::snRSeq(Sprite *spr, int val) { - debugC(1, kDebugEngine, "CGEEngine::snRSeq(spr, %d)", val); + debugC(1, kCGEDebugEngine, "CGEEngine::snRSeq(spr, %d)", val); if (spr) snSeq(spr, spr->_seqPtr + val); } void CGEEngine::snSend(Sprite *spr, int val) { - debugC(1, kDebugEngine, "CGEEngine::snSend(spr, %d)", val); + debugC(1, kCGEDebugEngine, "CGEEngine::snSend(spr, %d)", val); if (spr) { int was = spr->_cave; @@ -598,7 +598,7 @@ void CGEEngine::snSend(Sprite *spr, int val) { void CGEEngine::snSwap(Sprite *spr, int xref) { - debugC(1, kDebugEngine, "CGEEngine::snSwap(spr, %d)", xref); + debugC(1, kCGEDebugEngine, "CGEEngine::snSwap(spr, %d)", xref); Sprite *xspr = locate(xref); if (spr && xspr) { @@ -635,7 +635,7 @@ void CGEEngine::snSwap(Sprite *spr, int xref) { void CGEEngine::snCover(Sprite *spr, int xref) { - debugC(1, kDebugEngine, "CGEEngine::snCover(spr, %d)", xref); + debugC(1, kCGEDebugEngine, "CGEEngine::snCover(spr, %d)", xref); Sprite *xspr = locate(xref); if (spr && xspr) { @@ -654,7 +654,7 @@ void CGEEngine::snCover(Sprite *spr, int xref) { void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) { - debugC(1, kDebugEngine, "CGEEngine::snUncover(spr, xspr)"); + debugC(1, kCGEDebugEngine, "CGEEngine::snUncover(spr, xspr)"); if (spr && xspr) { spr->_flags._hide = false; @@ -673,33 +673,33 @@ void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) { void CGEEngine::snSetX0(int cav, int x0) { - debugC(1, kDebugEngine, "CGEEngine::snSetX0(%d, %d)", cav, x0); + debugC(1, kCGEDebugEngine, "CGEEngine::snSetX0(%d, %d)", cav, x0); _heroXY[cav - 1]._x = x0; } void CGEEngine::snSetY0(int cav, int y0) { - debugC(1, kDebugEngine, "CGEEngine::snSetY0(%d, %d)", cav, y0); + debugC(1, kCGEDebugEngine, "CGEEngine::snSetY0(%d, %d)", cav, y0); _heroXY[cav - 1]._y = y0; } void CGEEngine::snSetXY(Sprite *spr, uint16 xy) { - debugC(1, kDebugEngine, "CGEEngine::snSetXY(spr, %d)", xy); + debugC(1, kCGEDebugEngine, "CGEEngine::snSetXY(spr, %d)", xy); if (spr) spr->gotoxy(xy % SCR_WID, xy / SCR_WID); } void CGEEngine::snRelX(Sprite *spr, int x) { - debugC(1, kDebugEngine, "CGEEngine::snRelX(spr, %d)", x); + debugC(1, kCGEDebugEngine, "CGEEngine::snRelX(spr, %d)", x); if (spr && _hero) spr->gotoxy(_hero->_x + x, spr->_y); } void CGEEngine::snRelY(Sprite *spr, int y) { - debugC(1, kDebugEngine, "CGEEngine::snRelY(spr, %d)", y); + debugC(1, kCGEDebugEngine, "CGEEngine::snRelY(spr, %d)", y); if (spr && _hero) spr->gotoxy(spr->_x, _hero->_y + y); @@ -707,7 +707,7 @@ void CGEEngine::snRelY(Sprite *spr, int y) { void CGEEngine::snRelZ(Sprite *spr, int z) { - debugC(1, kDebugEngine, "CGEEngine::snRelZ(spr, %d)", z); + debugC(1, kCGEDebugEngine, "CGEEngine::snRelZ(spr, %d)", z); if (spr && _hero) { spr->_z = _hero->_z + z; @@ -717,7 +717,7 @@ void CGEEngine::snRelZ(Sprite *spr, int z) { void CGEEngine::snSetX(Sprite *spr, int x) { - debugC(1, kDebugEngine, "CGEEngine::snSetX(spr, %d)", x); + debugC(1, kCGEDebugEngine, "CGEEngine::snSetX(spr, %d)", x); if (spr) spr->gotoxy(x, spr->_y); @@ -725,7 +725,7 @@ void CGEEngine::snSetX(Sprite *spr, int x) { void CGEEngine::snSetY(Sprite *spr, int y) { - debugC(1, kDebugEngine, "CGEEngine::snSetY(spr, %d)", y); + debugC(1, kCGEDebugEngine, "CGEEngine::snSetY(spr, %d)", y); if (spr) spr->gotoxy(spr->_x, y); @@ -733,7 +733,7 @@ void CGEEngine::snSetY(Sprite *spr, int y) { void CGEEngine::snSetZ(Sprite *spr, int z) { - debugC(1, kDebugEngine, "CGEEngine::snSetZ(spr, %d)", z); + debugC(1, kCGEDebugEngine, "CGEEngine::snSetZ(spr, %d)", z); if (spr) { spr->_z = z; @@ -744,7 +744,7 @@ void CGEEngine::snSetZ(Sprite *spr, int z) { void CGEEngine::snSlave(Sprite *spr, int ref) { - debugC(1, kDebugEngine, "CGEEngine::snSlave(spr, %d)", ref); + debugC(1, kCGEDebugEngine, "CGEEngine::snSlave(spr, %d)", ref); Sprite *slv = locate(ref); if (spr && slv) { @@ -759,21 +759,21 @@ void CGEEngine::snSlave(Sprite *spr, int ref) { void CGEEngine::snTrans(Sprite *spr, int trans) { - debugC(1, kDebugEngine, "CGEEngine::snTrans(spr, %d)", trans); + debugC(1, kCGEDebugEngine, "CGEEngine::snTrans(spr, %d)", trans); if (spr) spr->_flags._tran = (trans < 0) ? !spr->_flags._tran : (trans != 0); } void CGEEngine::snPort(Sprite *spr, int port) { - debugC(1, kDebugEngine, "CGEEngine::snPort(spr, %d)", port); + debugC(1, kCGEDebugEngine, "CGEEngine::snPort(spr, %d)", port); if (spr) spr->_flags._port = (port < 0) ? !spr->_flags._port : (port != 0); } void CGEEngine::snKill(Sprite *spr) { - debugC(1, kDebugEngine, "CGEEngine::snKill(spr)"); + debugC(1, kCGEDebugEngine, "CGEEngine::snKill(spr)"); if (spr) { if (spr->_flags._kept) { @@ -800,7 +800,7 @@ void CGEEngine::snKill(Sprite *spr) { void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { - debugC(1, kDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt); + debugC(1, kCGEDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt); if (_sndDrvInfo._dDev) { if (wav == -1) @@ -812,7 +812,7 @@ void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { void CGEEngine::snKeep(Sprite *spr, int stp) { - debugC(1, kDebugEngine, "CGEEngine::snKeep(spr, %d)", stp); + debugC(1, kCGEDebugEngine, "CGEEngine::snKeep(spr, %d)", stp); selectPocket(-1); if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) { @@ -830,7 +830,7 @@ void CGEEngine::snKeep(Sprite *spr, int stp) { void CGEEngine::snGive(Sprite *spr, int stp) { - debugC(1, kDebugEngine, "CGEEngine::snGive(spr, %d)", stp); + debugC(1, kCGEDebugEngine, "CGEEngine::snGive(spr, %d)", stp); if (spr) { int p = findPocket(spr); @@ -847,7 +847,7 @@ void CGEEngine::snGive(Sprite *spr, int stp) { void CGEEngine::snBackPt(Sprite *spr, int stp) { - debugC(1, kDebugEngine, "CGEEngine::snBackPt(spr, %d)", stp); + debugC(1, kCGEDebugEngine, "CGEEngine::snBackPt(spr, %d)", stp); if (spr) { if (stp >= 0) @@ -857,7 +857,7 @@ void CGEEngine::snBackPt(Sprite *spr, int stp) { } void CGEEngine::snLevel(Sprite *spr, int lev) { - debugC(1, kDebugEngine, "CGEEngine::snLevel(spr, %d)", lev); + debugC(1, kCGEDebugEngine, "CGEEngine::snLevel(spr, %d)", lev); while (_lev < lev) { _lev++; @@ -878,14 +878,14 @@ void CGEEngine::snFlag(int indx, bool v) { } void CGEEngine::snSetRef(Sprite *spr, int nr) { - debugC(1, kDebugEngine, "CGEEngine::snSetRef(spr, %d)", nr); + debugC(1, kCGEDebugEngine, "CGEEngine::snSetRef(spr, %d)", nr); if (spr) spr->_ref = nr; } void CGEEngine::snFlash(bool on) { - debugC(1, kDebugEngine, "CGEEngine::snFlash(%s)", on ? "true" : "false"); + debugC(1, kCGEDebugEngine, "CGEEngine::snFlash(%s)", on ? "true" : "false"); if (on) { Dac *pal = (Dac *) malloc(sizeof(Dac) * PAL_CNT); @@ -909,7 +909,7 @@ void CGEEngine::snFlash(bool on) { void CGEEngine::snLight(bool in) { - debugC(1, kDebugEngine, "CGEEngine::snLight(%s)", in ? "true" : "false"); + debugC(1, kCGEDebugEngine, "CGEEngine::snLight(%s)", in ? "true" : "false"); if (in) _vga->sunrise(Vga::_sysPal); @@ -919,13 +919,13 @@ void CGEEngine::snLight(bool in) { } void CGEEngine::snBarrier(int cav, int bar, bool horz) { - debugC(1, kDebugEngine, "CGEEngine::snBarrier(%d, %d, %s)", cav, bar, horz ? "true" : "false"); + debugC(1, kCGEDebugEngine, "CGEEngine::snBarrier(%d, %d, %s)", cav, bar, horz ? "true" : "false"); ((uint8 *)(_barriers + ((cav > 0) ? cav : _now)))[horz] = bar; } void CGEEngine::snWalk(Sprite *spr, int x, int y) { - debugC(1, kDebugEngine, "CGEEngine::snWalk(spr, %d, %d)", x, y); + debugC(1, kCGEDebugEngine, "CGEEngine::snWalk(spr, %d, %d)", x, y); if (_hero) { if (spr && y < 0) @@ -936,14 +936,14 @@ void CGEEngine::snWalk(Sprite *spr, int x, int y) { } void CGEEngine::snReach(Sprite *spr, int mode) { - debugC(1, kDebugEngine, "CGEEngine::snReach(spr, %d)", mode); + debugC(1, kCGEDebugEngine, "CGEEngine::snReach(spr, %d)", mode); if (_hero) _hero->reach(spr, mode); } void CGEEngine::snMouse(bool on) { - debugC(1, kDebugEngine, "CGEEngine::snMouse(%s)", on ? "true" : "false"); + debugC(1, kCGEDebugEngine, "CGEEngine::snMouse(%s)", on ? "true" : "false"); if (on) _mouse->on(); diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index fd37dada8b..1ed640be8a 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -218,7 +218,7 @@ void Text::say(const char *txt, Sprite *spr) { } void CGEEngine::inf(const char *txt) { - debugC(1, kDebugEngine, "CGEEngine::inf(%s)", txt); + debugC(1, kCGEDebugEngine, "CGEEngine::inf(%s)", txt); killText(); _talk = new Talk(this, txt, RECT); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6fc17dc37b..6093681292 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1213,7 +1213,7 @@ void Vga::copyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- void Bitmap::xShow(int16 x, int16 y) { - debugC(4, kDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); + debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1266,7 +1266,7 @@ void Bitmap::xShow(int16 x, int16 y) { void Bitmap::show(int16 x, int16 y) { - debugC(5, kDebugBitmap, "Bitmap::show(%d, %d)", x, y); + debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y); const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1330,7 +1330,7 @@ void Bitmap::show(int16 x, int16 y) { void Bitmap::hide(int16 x, int16 y) { - debugC(5, kDebugBitmap, "Bitmap::hide(%d, %d)", x, y); + debugC(5, kCGEDebugBitmap, "Bitmap::hide(%d, %d)", x, y); for (int yp = y; yp < y + _h; yp++) { const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 94ec2fc7ad..63f3fadd1c 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -47,13 +47,13 @@ Dat::Dat(): _file(DAT_NAME, REA, CRP) #endif { - debugC(1, kDebugFile, "Dat::Dat()"); + debugC(1, kCGEDebugFile, "Dat::Dat()"); } /*-----------------------------------------------------------------------*/ void VFile::init() { - debugC(1, kDebugFile, "VFile::init()"); + debugC(1, kCGEDebugFile, "VFile::init()"); _dat = new Dat(); #ifdef VOL_UPD @@ -72,7 +72,7 @@ void VFile::deinit() { VFile::VFile(const char *name, IOMODE mode) : IoBuf(mode) { - debugC(3, kDebugFile, "VFile::VFile(%s, %d)", name, mode); + debugC(3, kCGEDebugFile, "VFile::VFile(%s, %d)", name, mode); if (mode == REA) { if (_dat->_file._error || _cat->_error) @@ -96,14 +96,14 @@ VFile::~VFile() { bool VFile::exist(const char *name) { - debugC(1, kDebugFile, "VFile::exist(%s)", name); + debugC(1, kCGEDebugFile, "VFile::exist(%s)", name); return scumm_stricmp(_cat->find(name)->_key, name) == 0; } void VFile::readBuf() { - debugC(3, kDebugFile, "VFile::readBuf()"); + debugC(3, kCGEDebugFile, "VFile::readBuf()"); if (_recent != this) { _dat->_file.seek(_bufMark + _lim); @@ -118,19 +118,19 @@ void VFile::readBuf() { } long VFile::mark() { - debugC(5, kDebugFile, "VFile::mark()"); + debugC(5, kCGEDebugFile, "VFile::mark()"); return (_bufMark + _ptr) - _begMark; } long VFile::size() { - debugC(1, kDebugFile, "VFile::size()"); + debugC(1, kCGEDebugFile, "VFile::size()"); return _endMark - _begMark; } long VFile::seek(long pos) { - debugC(1, kDebugFile, "VFile::seel(%ld)", pos); + debugC(1, kCGEDebugFile, "VFile::seel(%ld)", pos); _recent = NULL; _lim = 0; -- cgit v1.2.3 From 9576e415e2779011ecfca77a2f9642c011a928a2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Jul 2011 14:27:36 +0200 Subject: CGE: Clean up Square class --- engines/cge/cge_main.cpp | 16 +++------------- engines/cge/cge_main.h | 8 +++++++- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4b1b0b695e..3ebec73030 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -449,17 +449,7 @@ void CGEEngine::loadMapping() { } } -class SQUARE : public Sprite { -public: - SQUARE(CGEEngine *vm); - virtual void touch(uint16 mask, int x, int y); -private: - CGEEngine *_vm; -}; - - -SQUARE::SQUARE(CGEEngine *vm) - : Sprite(vm, NULL), _vm(vm) { +Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { _flags._kill = true; _flags._bDel = false; @@ -470,7 +460,7 @@ SQUARE::SQUARE(CGEEngine *vm) } -void SQUARE::touch(uint16 mask, int x, int y) { +void Square::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); if (mask & L_UP) { XZ(_x + x, _y + y).cell() = 0; @@ -482,7 +472,7 @@ void SQUARE::touch(uint16 mask, int x, int y) { void CGEEngine::setMapBrick(int x, int z) { debugC(1, kCGEDebugEngine, "CGEEngine::setMapBrick(%d, %d)", x, z); - SQUARE *s = new SQUARE(this); + Square *s = new Square(this); if (s) { static char n[] = "00:00"; s->gotoxy(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 40e6d88668..103c718759 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -103,7 +103,6 @@ namespace CGE { #define HEROFUN0 (40 * 12) #define HEROFUN1 ( 2 * 12) #define PAIN (_vm->_flag[0]) -//#define FINIS (_vm->_flag[3]) class System : public Sprite { @@ -121,6 +120,13 @@ private: CGEEngine *_vm; }; +class Square : public Sprite { +public: + Square(CGEEngine *vm); + virtual void touch(uint16 mask, int x, int y); +private: + CGEEngine *_vm; +}; extern Vga *_vga; extern Heart *_heart; -- cgit v1.2.3 From 5d41ab8b5fd778f206633157ffa87efc31f643cf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 21 Jul 2011 01:56:40 +0200 Subject: CGE: Rename some more constants, remove some useless ones --- engines/cge/bitmap.cpp | 17 ++++----- engines/cge/cge.cpp | 10 +++--- engines/cge/cge.h | 18 ++++++---- engines/cge/cge_main.cpp | 54 ++++++++++++++-------------- engines/cge/cge_main.h | 94 ++++++++++++++++++++++-------------------------- engines/cge/config.cpp | 2 +- engines/cge/events.cpp | 2 +- engines/cge/snail.cpp | 20 +++++------ engines/cge/snail.h | 9 ----- engines/cge/startup.cpp | 2 +- engines/cge/talk.h | 4 +-- engines/cge/text.cpp | 6 ++-- engines/cge/text.h | 2 +- engines/cge/vga13h.cpp | 24 ++++++------- engines/cge/vga13h.h | 9 ----- engines/cge/walk.cpp | 14 ++++---- engines/cge/walk.h | 2 +- 17 files changed, 133 insertions(+), 156 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 8f335fed60..023e95a8f1 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -31,6 +31,7 @@ #include "cge/vol.h" #include "cge/cfile.h" #include "cge/vga13h.h" +#include "cge/cge_main.h" #include "common/system.h" #include "common/debug.h" #include "common/debug-channels.h" @@ -108,7 +109,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) *(uint16 *) v = kBmpCPY | dsiz; // data chunk hader memset(v + 2, fill, dsiz); // data bytes - *(uint16 *)(v + lsiz - 2) = kBmpSKP | ((SCR_WID / 4) - dsiz); // gap + *(uint16 *)(v + lsiz - 2) = kBmpSKP | ((kScrWidth / 4) - dsiz); // gap // Replicate lines byte *destP; @@ -122,7 +123,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) Common::copy(v, v + psiz, destP); HideDesc *b = (HideDesc *)(v + 4 * psiz); - b->_skip = (SCR_WID - _w) >> 2; + b->_skip = (kScrWidth - _w) >> 2; b->_hide = _w >> 2; // Replicate across the entire table @@ -257,9 +258,9 @@ BMP_PTR Bitmap::code() { } bm += _w; - if (_w < SCR_WID) { + if (_w < kScrWidth) { if (skip) { - cnt += (SCR_WID - j + 3) / 4; + cnt += (kScrWidth - j + 3) / 4; } else { cnt |= kBmpCPY; if (_v) @@ -268,7 +269,7 @@ BMP_PTR Bitmap::code() { cp = (uint16 *) im; im += 2; skip = true; - cnt = (SCR_WID - j + 3) / 4; + cnt = (kScrWidth - j + 3) / 4; } } } @@ -298,14 +299,14 @@ BMP_PTR Bitmap::code() { cnt = 0; for (i = 0; i < _h; i++) { if (_b[i]._skip == 0xFFFF) { // whole line is skipped - _b[i]._skip = (cnt + SCR_WID) >> 2; + _b[i]._skip = (cnt + kScrWidth) >> 2; cnt = 0; } else { uint16 s = _b[i]._skip & ~3; uint16 h = (_b[i]._hide + 3) & ~3; _b[i]._skip = (cnt + s) >> 2; _b[i]._hide = (h - s) >> 2; - cnt = SCR_WID - h; + cnt = kScrWidth - h; } } @@ -324,7 +325,7 @@ bool Bitmap::solidAt(int16 x, int16 y) { m = _v; r = static_cast(x) % 4; - n0 = (SCR_WID * y + x) / 4, n = 0; + n0 = (kScrWidth * y + x) / 4, n = 0; while (r) { uint16 w, t; diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index a3478b14f8..58c32dd575 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -85,15 +85,15 @@ void CGEEngine::setup() { _heart = new Heart; _sys = new System(this); _pocLight = new PocLight(this); - for (int i = 0; i < POCKET_NX; i++) { + for (int i = 0; i < kPocketNX; i++) { _pocket[i] = new Sprite(this, NULL); _pocket[i]->_flags._kill = false; } _sprite = new Sprite(this, NULL); _horzLine = new HorizLine(this); - _infoLine = new InfoLine(this, INFO_W); + _infoLine = new InfoLine(this, kInfoW); _cavLight = new CavLight(this); - _debugLine = new InfoLine(this, SCR_WID); + _debugLine = new InfoLine(this, kScrWidth); _snail = new Snail(this, false); _snail_ = new Snail(this, true); @@ -104,7 +104,7 @@ void CGEEngine::setup() { _music = true; _mini = new byte[MINI_EMM_SIZE]; - for (int i = 0; i < POCKET_NX; i++) + for (int i = 0; i < kPocketNX; i++) _pocref[i] = -1; _volume[0] = 0; _volume[1] = 0; @@ -165,7 +165,7 @@ CGEEngine::~CGEEngine() { delete _pocLight; delete _keyboard; delete _mouse; - for (int i = 0; i < POCKET_NX; i++) + for (int i = 0; i < kPocketNX; i++) delete _pocket[i]; delete _snail; delete _snail_; diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 5bc97d6eff..255dadfac6 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -35,13 +35,21 @@ #include "cge/console.h" #include "cge/bitmap.h" -#define CGE_SAVEGAME_VERSION 1 - namespace CGE { class Console; class Sprite; +#define CGE_SAVEGAME_VERSION 1 +#define kPocketX 174 +#define kPocketY 176 +#define kPocketDX 18 +#define kPocketDY 22 +#define kPocketNX 8 +#define kPocketNY 1 +#define kPocketSX 8 +#define kPocketSY 3 + // our engine debug channels enum { kCGEDebugBitmap = 1 << 0, @@ -58,10 +66,6 @@ enum CallbackType { kSnSelect, kSndSetVolume }; -#define POCKET_NX 8 - -#define CGE_SAVEGAME_VERSION 1 - struct SavegameHeader { uint8 version; Common::String saveName; @@ -100,7 +104,7 @@ public: bool _jbw; int _pocPtr; bool _music; - int _pocref[POCKET_NX]; + int _pocref[kPocketNX]; uint8 _volume[2]; int _maxCaveArr[5]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 3ebec73030..22e38618cb 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -57,7 +57,7 @@ namespace CGE { #define STACK_SIZ 2048 #define SVGCHKSUM (1956 + _now + _oldLev + _game + _music + _demoText) -#define SVG0NAME ("{{INIT}}" SVG_EXT) +#define SVG0NAME ("{{INIT}}" kSvgExt) #define SVG0FILE INI_FILE uint16 _stklen = (STACK_SIZ * 2); @@ -69,7 +69,7 @@ Sprite *_pocLight; EventManager *_eventManager; Keyboard *_keyboard; Mouse *_mouse; -Sprite *_pocket[POCKET_NX]; +Sprite *_pocket[kPocketNX]; Sprite *_sprite; Sprite *_miniCave; Sprite *_shadow; @@ -127,7 +127,7 @@ void CGEEngine::syncHeader(Common::Serializer &s) { s.syncAsByte(_barriers[i]._horz); s.syncAsByte(_barriers[i]._vert); } - for (i = 0; i < POCKET_NX; ++i) + for (i = 0; i < kPocketNX; ++i) s.syncAsUint16LE(_pocref[i]); if (s.isSaving()) { @@ -291,7 +291,7 @@ void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &he // Create a thumbnail and save it Graphics::Surface *thumb = new Graphics::Surface(); Graphics::Surface *s = _vga->_page[0]; - ::createThumbnail(thumb, (const byte *)s->pixels, SCR_WID, SCR_HIG, thumbPalette); + ::createThumbnail(thumb, (const byte *)s->pixels, kScrWidth, kScrHeight, thumbPalette); Graphics::saveThumbnail(*out, *thumb); delete thumb; @@ -312,7 +312,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt Common::Serializer s(readStream, writeStream); if (s.isSaving()) { - for (i = 0; i < POCKET_NX; i++) { + for (i = 0; i < kPocketNX; i++) { register Sprite *s = _pocket[i]; _pocref[i] = (s) ? s->_ref : -1; } @@ -355,7 +355,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt _vga->_spareQ->append(spr); } - for (i = 0; i < POCKET_NX; i++) { + for (i = 0; i < kPocketNX; i++) { register int r = _pocref[i]; delete _pocket[i]; _pocket[i] = (r < 0) ? NULL : _vga->_spareQ->locate(r); @@ -701,7 +701,7 @@ void CGEEngine::switchCave(int cav) { } System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { - _funDel = HEROFUN0; + _funDel = kHeroFun0; setPal(); tick(); } @@ -717,7 +717,7 @@ void System::setPal() { } void System::funTouch() { - uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0; + uint16 n = (PAIN) ? kHeroFun1 : kHeroFun0; if (_talk == NULL || n > _funDel) _funDel = n; } @@ -836,8 +836,8 @@ void System::touch(uint16 mask, int x, int y) { return; int cav = 0; _infoLine->update(NULL); - if (y >= WORLD_HIG) { - if (x < BUTTON_X) { // select cave? + if (y >= kWorldHeight ) { + if (x < kButtonX) { // select cave? if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && !_vm->_game) { cav = ((y - CAVE_Y) / CAVE_DY) * CAVE_NX + (x - CAVE_X) / CAVE_DX + 1; @@ -847,9 +847,9 @@ void System::touch(uint16 mask, int x, int y) { cav = 0; } } else if (mask & L_UP) { - if (y >= POCKET_Y && y < POCKET_Y + POCKET_NY * POCKET_DY && - x >= POCKET_X && x < POCKET_X + POCKET_NX * POCKET_DX) { - int n = ((y - POCKET_Y) / POCKET_DY) * POCKET_NX + (x - POCKET_X) / POCKET_DX; + if (y >= kPocketY && y < kPocketY + kPocketNY * kPocketDY && + x >= kPocketX && x < kPocketX + kPocketNX * kPocketDX) { + int n = ((y - kPocketY) / kPocketDY) * kPocketNX + (x - kPocketX) / kPocketDX; _vm->selectPocket(n); } } @@ -889,7 +889,7 @@ void System::tick() { else if (Startup::_core >= CORE_MID) { int n = new_random(100); if (n > 96) - _vm->heroCover(6 + (_hero->_x + _hero->_w / 2 < SCR_WID / 2)); + _vm->heroCover(6 + (_hero->_x + _hero->_w / 2 < kScrWidth / 2)); else { if (n > 90) _vm->heroCover(5); @@ -904,7 +904,7 @@ void System::tick() { } funTouch(); } - _time = SYSTIMERATE; + _time = kSystemRate; } void CGEEngine::switchColorMode() { @@ -1106,7 +1106,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { else if (mask & R_UP) if (!Mixer::_appear) { Mixer::_appear = true; - new Mixer(this, BUTTON_X, BUTTON_Y); + new Mixer(this, kButtonX, kButtonY); } break; case 3 : @@ -1137,7 +1137,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if ((mask & R_UP) && _snail->idle()) { Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL; if (ps) { - if (_flags._kept || _hero->distance(this) < MAX_DISTANCE) { + if (_flags._kept || _hero->distance(this) < kDistMax) { if (works(ps)) { _vm->feedSnail(ps, kTake); } else @@ -1149,7 +1149,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if (_flags._kept) mask |= L_UP; else { - if (_hero->distance(this) < MAX_DISTANCE) { + if (_hero->distance(this) < kDistMax) { /// if (_flags._port) { if (_vm->findPocket(NULL) < 0) @@ -1177,7 +1177,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if ((mask & L_UP) && _snail->idle()) { if (_flags._kept) { int n; - for (n = 0; n < POCKET_NX; n++) { + for (n = 0; n < kPocketNX; n++) { if (_pocket[n] == this) { _vm->selectPocket(n); break; @@ -1200,7 +1200,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int static const char *Type[] = { "DEAD", "AUTO", "WALK", "NEWTON", "LISSAJOUS", "FLY", NULL }; - char line[LINE_MAX]; + char line[kLineMax]; int shpcnt = 0; int type = 0; // DEAD @@ -1345,7 +1345,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int void CGEEngine::loadScript(const char *fname) { - char line[LINE_MAX]; + char line[kLineMax]; char *SpN; int SpI, SpA, SpX, SpY, SpZ; bool BkG = false; @@ -1483,7 +1483,7 @@ void CGEEngine::loadUser() { error("Creating setup savegames not supported"); } } - loadScript(progName(IN0_EXT)); + loadScript(progName(kIn0Ext)); } @@ -1538,7 +1538,7 @@ void CGEEngine::runGame() { uint8 *ptr = (uint8 *) &*_mini; if (ptr != NULL) { - loadSprite("MINI", -1, 0, MINI_X, MINI_Y); + loadSprite("MINI", -1, 0, kMiniX, kMiniY); expandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { _miniCave->_flags._kill = false; @@ -1567,7 +1567,7 @@ void CGEEngine::runGame() { } } - _infoLine->gotoxy(INFO_X, INFO_Y); + _infoLine->gotoxy(kInfoX, kInfoY); _infoLine->_flags._tran = true; _infoLine->update(NULL); _vga->_showQ->insert(_infoLine); @@ -1579,7 +1579,7 @@ void CGEEngine::runGame() { _horzLine->_z = 126; _vga->_showQ->insert(_horzLine); - _mouse->_busy = _vga->_spareQ->locate(BUSY_REF); + _mouse->_busy = _vga->_spareQ->locate(kBusyRef); if (_mouse->_busy) expandSprite(_mouse->_busy); @@ -1688,7 +1688,7 @@ bool CGEEngine::showTitle(const char *name) { if (Startup::_mode < 2) { if (_isDemo) { - strcpy(_usrFnam, progName(SVG_EXT)); + strcpy(_usrFnam, progName(kSvgExt)); usr_ok = true; } else { //----------------------------------------- @@ -1792,7 +1792,7 @@ void CGEEngine::cge_main() { movie("X03"); } else { if (Startup::_mode < 2) - movie(LGO_EXT); + movie(kLgoExt); if (showTitle("WELCOME")) { if ((!_isDemo) && (Startup::_mode == 1)) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 103c718759..68c6f1f1dc 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -33,34 +33,6 @@ #include "cge/events.h" namespace CGE { - -#define TSEQ 96 -#define HTALK (TSEQ + 4) -#define TOO_FAR (TSEQ + 5) -#define NO_WAY (TSEQ + 5) -#define POC_FUL (TSEQ + 5) -#define OFF_USE (TSEQ + 6) -#define EXIT_OK_TEXT 40 -#define NOMUSIC_TEXT 98 -#define BADSVG_TEXT 99 -#define OFF_USE_COUNT 600 -#define OFF_USE_TEXT 601 -#define NO_WAY_TEXT 671 -#define TOO_FAR_TEXT 681 -#define POC_FUL_TEXT 691 -#define A_C_D_TEXT 777 -#define GETNAME_PROMPT 50 -#define GETNAME_TITLE 51 -#define QUIT_TITLE 200 -#define QUIT_TEXT 201 -#define NOQUIT_TEXT 202 -#define DEMO_TEXT 300 -#define NOSOUND_TEXT 310 -#define PAN_HIG 40 -#define WORLD_HIG (SCR_HIG - PAN_HIG) -#define INFO_X 177 -#define INFO_Y 164 -#define INFO_W 140 #define CAVE_X 4 #define CAVE_Y 166 #define CAVE_SX 0 @@ -77,33 +49,51 @@ namespace CGE { #define CAVE_NX 8 #define CAVE_NY 3 #endif - -#define BUTTON_X 151 -#define BUTTON_Y 164 -#define BUTTON_DX 19 -#define BUTTON_DY 11 -#define BUTTON_NX 1 -#define BUTTON_NY 3 -#define MINI_X 86 -#define MINI_Y 162 -#define LINE_MAX 512 -#define USER_MAX 100 -#define SHP_MAX 1024 -#define STD_DELAY 3 -#define LEV_MAX 5 #define CAVE_MAX (CAVE_NX * CAVE_NY) -#define MAX_DISTANCE 3 -#define INI_EXT ".INI" -#define IN0_EXT ".IN0" -#define LGO_EXT ".LGO" -#define SVG_EXT ".SVG" -#define WALKSIDE 10 -#define BUSY_REF 500 -#define SYSTIMERATE 6 // 12 Hz -#define HEROFUN0 (40 * 12) -#define HEROFUN1 ( 2 * 12) #define PAIN (_vm->_flag[0]) +#define kInfoX 177 +#define kInfoY 164 +#define kInfoW 140 +#define kButtonX 151 +#define kButtonY 164 +#define kMiniX 86 +#define kMiniY 162 +#define kLineMax 512 +#define kDistMax 3 +#define kIn0Ext ".IN0" +#define kLgoExt ".LGO" +#define kSvgExt ".SVG" +#define kWalkSide 10 +#define kBusyRef 500 +#define kSystemRate 6 // 12 Hz +#define kHeroFun0 (40 * 12) +#define kHeroFun1 ( 2 * 12) +#define GETNAME_PROMPT 50 +#define GETNAME_TITLE 51 +#define TSEQ 96 +#define NOMUSIC_TEXT 98 +#define BADSVG_TEXT 99 +#define HTALK (TSEQ + 4) +#define TOO_FAR (TSEQ + 5) +#define NO_WAY (TSEQ + 5) +#define POC_FUL (TSEQ + 5) +#define OFF_USE (TSEQ + 6) +#define QUIT_TITLE 200 +#define QUIT_TEXT 201 +#define NOQUIT_TEXT 202 +#define DEMO_TEXT 300 +#define NOSOUND_TEXT 310 +#define OFF_USE_COUNT 600 +#define OFF_USE_TEXT 601 +#define NO_WAY_TEXT 671 +#define TOO_FAR_TEXT 681 +#define POC_FUL_TEXT 691 +#define A_C_D_TEXT 777 +#define kPanHeight 40 +#define kScrWidth 320 +#define kScrHeight 200 +#define kWorldHeight (kScrHeight - kPanHeight) class System : public Sprite { int _lum; diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 2649afc241..964b029b59 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -43,7 +43,7 @@ void CGEEngine::snSelect() { inf(_text->getText(_hlp)); _talk->gotoxy(_talk->_x, kFontHigh / 2); - (new Vmenu(this, _cho, SCR_WID / 2, _talk->_y + _talk->_h + kTextVMargin + kFontHigh))->setName(_text->getText(MENU_TEXT)); + (new Vmenu(this, _cho, kScrWidth / 2, _talk->_y + _talk->_h + kTextVMargin + kFontHigh))->setName(_text->getText(MENU_TEXT)); } } // End of namespace CGE diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index eba043cdc8..aa71782f77 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -169,7 +169,7 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) MC[2] = NULL; setShapeList(MC); - gotoxy(SCR_WID/2, SCR_HIG/2); + gotoxy(kScrWidth/2, kScrHeight/2); _z = 127; step(1); } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index c4b4b383d0..e9ae494811 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -107,11 +107,11 @@ void CGEEngine::snGame(Sprite *spr, int num) { SNPOST(SNPAUSE, -1, 72, NULL); // chwilk‘... SNPOST(SNSEQ, -1, 0, dup[1]); // odstaw Go - SNPOST(SNSETXY, -1, 203 + SCR_WID * 49, dup[1]); + SNPOST(SNSETXY, -1, 203 + kScrWidth * 49, dup[1]); SNPOST(SNSETZ, -1, 7, dup[1]); SNPOST(SNSEQ, -1, 0, dup[2]); // odstaw J† - SNPOST(SNSETXY, -1, 182 + SCR_WID * 62, dup[2]); + SNPOST(SNSETXY, -1, 182 + kScrWidth * 62, dup[2]); SNPOST(SNSETZ, -1, 9, dup[2]); _game = 0; return; @@ -274,7 +274,7 @@ void CGEEngine::contractSprite(Sprite *spr) { int CGEEngine::findPocket(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::findPocket(spr)"); - for (int i = 0; i < POCKET_NX; i++) + for (int i = 0; i < kPocketNX; i++) if (_pocket[i] == spr) return i; return -1; @@ -295,7 +295,7 @@ void CGEEngine::selectPocket(int n) { _pocLight->step(1); } } - _pocLight->gotoxy(POCKET_X + _pocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY); + _pocLight->gotoxy(kPocketX + _pocPtr * kPocketDX + kPocketSX, kPocketY + kPocketSY); } void CGEEngine::pocFul() { @@ -688,7 +688,7 @@ void CGEEngine::snSetXY(Sprite *spr, uint16 xy) { debugC(1, kCGEDebugEngine, "CGEEngine::snSetXY(spr, %d)", xy); if (spr) - spr->gotoxy(xy % SCR_WID, xy / SCR_WID); + spr->gotoxy(xy % kScrWidth, xy / kScrWidth); } void CGEEngine::snRelX(Sprite *spr, int x) { @@ -806,7 +806,7 @@ void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { if (wav == -1) _sound.stop(); else - _sound.play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (SCR_WID / 16)) : 8, cnt); + _sound.play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt); } } @@ -820,8 +820,8 @@ void CGEEngine::snKeep(Sprite *spr, int stp) { _pocket[_pocPtr] = spr; spr->_cave = 0; spr->_flags._kept = true; - spr->gotoxy(POCKET_X + POCKET_DX * _pocPtr + POCKET_DX / 2 - spr->_w / 2, - POCKET_Y + POCKET_DY / 2 - spr->_h / 2); + spr->gotoxy(kPocketX + kPocketDX * _pocPtr + kPocketDX / 2 - spr->_w / 2, + kPocketY + kPocketDY / 2 - spr->_h / 2); if (stp >= 0) spr->step(stp); } @@ -1008,13 +1008,13 @@ void Snail::runCom() { if (spr == _hero && spr->seqTest(-1)) spr->step(HTALK); _text->say(_text->getText(snc->_val), spr); - _sys->_funDel = HEROFUN0; + _sys->_funDel = kHeroFun0; } break; case SNINF : if (_talkEnable) { _vm->inf(_text->getText(snc->_val)); - _sys->_funDel = HEROFUN0; + _sys->_funDel = kHeroFun0; } break; case SNTIME : diff --git a/engines/cge/snail.h b/engines/cge/snail.h index e8578e2b3d..b8b4dc68ff 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -33,15 +33,6 @@ namespace CGE { -#define POCKET_X 174 -#define POCKET_Y 176 -#define POCKET_DX 18 -#define POCKET_DY 22 -#define POCKET_NY 1 - -#define POCKET_SX 8 -#define POCKET_SY 3 - #define SNINSERT(c, r, v, p) _snail->insCom(c, r, v, p) #define SNPOST(c, r, v, p) _snail->addCom(c, r, v, p) #define SNPOST2(c, r, v, p) _snail->addCom2(c, r, v, p) diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 37c6b4f62e..aca58a91ba 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -157,7 +157,7 @@ Startup::Startup() { const char *usrPath(const char *nam) { - static char buf[MAXPATH] = ".\\", *p = buf + 2; + static char buf[kPathMax] = ".\\", *p = buf + 2; #if defined(CD) if (DriveCD(0)) { bool ok = false; diff --git a/engines/cge/talk.h b/engines/cge/talk.h index e8136271f6..5eab6672e3 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -49,10 +49,10 @@ namespace CGE { -#define MAXPATH 128 +#define kPathMax 128 class Font { - char _path[MAXPATH]; + char _path[kPathMax]; void load(); public: // static uint8 _wid[256]; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 1ed640be8a..dd75ea3681 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -86,7 +86,7 @@ void Text::preload(int from, int upto) { INI_FILE tf = _fileName; if (!tf._error) { Han *CacheLim = _cache + _size; - char line[LINE_MAX + 1]; + char line[kLineMax + 1]; int n; while ((n = tf.read((uint8 *)line)) != 0) { @@ -128,7 +128,7 @@ char *Text::load(int idx, int ref) { INI_FILE tf = _fileName; if (!tf._error) { Han *p = &_cache[idx]; - char line[LINE_MAX + 1]; + char line[kLineMax + 1]; int n; while ((n = tf.read((uint8 *)line)) != 0) { @@ -187,7 +187,7 @@ void Text::say(const char *txt, Sprite *spr) { uint16 sw = spike->_w; if (east) { - if (x + sw + kTextRoundCorner + 5 >= SCR_WID) + if (x + sw + kTextRoundCorner + 5 >= kScrWidth) east = false; } else { if (x <= 5 + kTextRoundCorner + sw) diff --git a/engines/cge/text.h b/engines/cge/text.h index cf917ece61..196bfc4edb 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -57,7 +57,7 @@ class Text { char *_txt; } *_cache; int _size; - char _fileName[MAXPATH]; + char _fileName[kPathMax]; char *load(int idx, int ref); int find(int ref); public: diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6093681292..24c83f12ee 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -508,7 +508,7 @@ Sprite *Sprite::expand() { error("No core"); if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; - char line[LINE_MAX], fname[MAXPATH]; + char line[kLineMax], fname[kPathMax]; BMP_PTR *shplist = new BMP_PTR[_shpCnt + 1]; Seq *seq = NULL; int shpcnt = 0, @@ -713,18 +713,18 @@ void Sprite::killXlat() { void Sprite::gotoxy(int x, int y) { int xo = _x, yo = _y; - if (_x < SCR_WID) { + if (_x < kScrWidth) { if (x < 0) x = 0; - if (x + _w > SCR_WID) - x = (SCR_WID - _w); + if (x + _w > kScrWidth) + x = (kScrWidth - _w); _x = x; } - if (_h < SCR_HIG) { + if (_h < kScrHeight) { if (y < 0) y = 0; - if (y + _h > SCR_HIG) - y = (SCR_HIG - _h); + if (y + _h > kScrHeight) + y = (kScrHeight - _h); _y = y; } if (_next) @@ -736,7 +736,7 @@ void Sprite::gotoxy(int x, int y) { void Sprite::center() { - gotoxy((SCR_WID - _w) / 2, (SCR_HIG - _h) / 2); + gotoxy((kScrWidth - _w) / 2, (kScrHeight - _h) / 2); } @@ -1195,14 +1195,14 @@ void Vga::update() { _setPal = false; } - g_system->copyRectToScreen((const byte *)Vga::_page[0]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); + g_system->copyRectToScreen((const byte *)Vga::_page[0]->getBasePtr(0, 0), kScrWidth, 0, 0, kScrWidth, kScrHeight); g_system->updateScreen(); } void Vga::clear(uint8 color) { for (int paneNum = 0; paneNum < 4; ++paneNum) - _page[paneNum]->fillRect(Common::Rect(0, 0, SCR_WID, SCR_HIG), color); + _page[paneNum]->fillRect(Common::Rect(0, 0, kScrWidth, kScrHeight), color); } @@ -1216,7 +1216,7 @@ void Bitmap::xShow(int16 x, int16 y) { debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); + byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); byte *lookupTable = _m; // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a @@ -1269,7 +1269,7 @@ void Bitmap::show(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); + byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 13bfce4189..4884ae104e 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -48,15 +48,6 @@ namespace CGE { #define TEXT_MODE 0x03 #define M13H 0x13 -#ifndef SCR_WID -#define SCR_WID 320 -#endif - -#ifndef SCR_HIG -#define SCR_HIG 200 -#endif - - #define LIGHT 0xFF #define DARK 207 #define DGRAY 225 /*219*/ diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index b35864f16e..f07ed4ece2 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -130,8 +130,8 @@ void WALK::tick() { } step(); if ((Dir == WW && _x <= 0) || - (Dir == EE && _x + _w >= SCR_WID) || - (Dir == SS && _y + _w >= WORLD_HIG - 2)) + (Dir == EE && _x + _w >= kScrWidth) || + (Dir == SS && _y + _w >= kWorldHeight - 2)) park(); else { signed char x; // dummy var @@ -143,9 +143,9 @@ void WALK::tick() { int WALK::distance(Sprite *spr) { int dx, dz; - dx = spr->_x - (_x + _w - WALKSIDE); + dx = spr->_x - (_x + _w - kWalkSide); if (dx < 0) - dx = (_x + WALKSIDE) - (spr->_x + spr->_w); + dx = (_x + kWalkSide) - (spr->_x + spr->_w); if (dx < 0) dx = 0; @@ -208,11 +208,11 @@ void WALK::findWay(Sprite *spr) { int x = spr->_x; int z = spr->_z; if (spr->_flags._east) - x += spr->_w + _w / 2 - WALKSIDE; + x += spr->_w + _w / 2 - kWalkSide; else - x -= _w / 2 - WALKSIDE; + x -= _w / 2 - kWalkSide; findWay(Cluster((x / MAP_XGRID), - ((z < MAP_ZCNT - MAX_DISTANCE) ? (z + 1) + ((z < MAP_ZCNT - kDistMax) ? (z + 1) : (z - 1)))); } } diff --git a/engines/cge/walk.h b/engines/cge/walk.h index eb29d9b462..52f372c363 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -38,7 +38,7 @@ namespace CGE { #define MAP_ZCNT 20 #define MAP_TOP 80 #define MAP_HIG 80 -#define MAP_XGRID (SCR_WID / MAP_XCNT) +#define MAP_XGRID (kScrWidth / MAP_XCNT) #define MAP_ZGRID (MAP_HIG / MAP_ZCNT) #define MAX_FIND_LEVEL 3 -- cgit v1.2.3 From 3ef0558aa933ce20242b3f842c235f792a6d2d32 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 22 Jul 2011 11:54:46 +0200 Subject: CGE: Rename some more constants, some cleanup --- engines/cge/cge.cpp | 4 ++-- engines/cge/cge_main.cpp | 34 +++++++++++++++++----------------- engines/cge/cge_main.h | 41 ++++++++++++++++++++--------------------- engines/cge/config.cpp | 4 +--- engines/cge/config.h | 1 + engines/cge/ems.cpp | 4 ---- engines/cge/game.cpp | 19 ------------------- engines/cge/game.h | 8 -------- engines/cge/snail.cpp | 8 ++++---- engines/cge/walk.cpp | 4 ++-- 10 files changed, 47 insertions(+), 80 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 58c32dd575..6068dee46e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -50,7 +50,7 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) _isDemo = _gameDescription->flags & ADGF_DEMO; _startupMode = 1; - _demoText = DEMO_TEXT; + _demoText = kDemo; _oldLev = 0; _jbw = false; _pocPtr = 0; @@ -100,7 +100,7 @@ void CGEEngine::setup() { _mouse = new Mouse(this); _keyboard = new Keyboard(); _eventManager = new EventManager(); - _offUseCount = atoi(_text->getText(OFF_USE_COUNT)); + _offUseCount = atoi(_text->getText(kOffUseCount)); _music = true; _mini = new byte[MINI_EMM_SIZE]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 22e38618cb..ee561726a1 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -139,7 +139,7 @@ void CGEEngine::syncHeader(Common::Serializer &s) { uint16 checksum; s.syncAsUint16LE(checksum); if (checksum != SVGCHKSUM) - error("%s", _text->getText(BADSVG_TEXT)); + error("%s", _text->getText(kBadSVG)); } } @@ -418,13 +418,13 @@ void CGEEngine::trouble(int seq, int txt) { void CGEEngine::offUse() { debugC(1, kCGEDebugEngine, "CGEEngine::offUse()"); - trouble(OFF_USE, OFF_USE_TEXT + new_random(_offUseCount)); + trouble(kSeqOffUse, kOffUse + new_random(_offUseCount)); } void CGEEngine::tooFar() { debugC(1, kCGEDebugEngine, "CGEEngine::tooFar()"); - trouble(TOO_FAR, TOO_FAR_TEXT); + trouble(kSeqTooFar, kTooFar); } void CGEEngine::loadHeroXY() { @@ -513,9 +513,9 @@ void CGEEngine::quit() { SNPOST_(SNKILL, -1, 0, Vmenu::_addr); resetQSwitch(); } else { - QuitMenu[0]._text = _text->getText(QUIT_TEXT); - QuitMenu[1]._text = _text->getText(NOQUIT_TEXT); - (new Vmenu(this, QuitMenu, -1, -1))->setName(_text->getText(QUIT_TITLE)); + QuitMenu[0]._text = _text->getText(kQuit); + QuitMenu[1]._text = _text->getText(kNoQuit); + (new Vmenu(this, QuitMenu, -1, -1))->setName(_text->getText(kQuitTitle)); SNPOST_(SNSEQ, 123, 1, NULL); keyClick(); } @@ -526,7 +526,7 @@ void CGEEngine::quit() { void CGEEngine::AltCtrlDel() { debugC(1, kCGEDebugEngine, "CGEEngine::AltCtrlDel()"); - SNPOST_(SNSAY, -1, A_C_D_TEXT, _hero); + SNPOST_(SNSAY, -1, kAltCtrlDel, _hero); } void CGEEngine::miniStep(int stp) { @@ -771,22 +771,22 @@ void System::touch(uint16 mask, int x, int y) { _vm->switchDebug(); break; case F3: - _hero->step(TSEQ + 4); + _hero->step(kTSeq + 4); break; case F4: - _hero->step(TSEQ + 5); + _hero->step(kTSeq + 5); break; case F5: - _hero->step(TSEQ + 0); + _hero->step(kTSeq + 0); break; case F6: - _hero->step(TSEQ + 1); + _hero->step(kTSeq + 1); break; case F7: - _hero->step(TSEQ + 2); + _hero->step(kTSeq + 2); break; case F8: - _hero->step(TSEQ + 3); + _hero->step(kTSeq + 3); break; case F9: _sys->_funDel = 1; @@ -927,7 +927,7 @@ void CGEEngine::switchMusic() { } } else { if (Startup::_core < CORE_HIG) - SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL); + SNPOST(SNINF, -1, kNoMusic, NULL); else { SNPOST_(SNSEQ, 122, (_music = !_music), NULL); keyClick(); @@ -953,9 +953,9 @@ void CGEEngine::takeName() { SNPOST_(SNKILL, -1, 0, GetText::_ptr); else { memset(_usrFnam, 0, 15); - GetText *tn = new GetText(this, _text->getText(GETNAME_PROMPT), _usrFnam, 8); + GetText *tn = new GetText(this, _text->getText(kGetNamePrompt), _usrFnam, 8); if (tn) { - tn->setName(_text->getText(GETNAME_TITLE)); + tn->setName(_text->getText(kGetNameTitle)); tn->center(); tn->gotoxy(tn->_x, tn->_y - 10); tn->_z = 126; @@ -1417,7 +1417,7 @@ void CGEEngine::mainLoop() { SNPOST(SNINF, -1, _demoText, NULL); SNPOST(SNLABEL, -1, -1, NULL); if (_text->getText(++_demoText) == NULL) - _demoText = DEMO_TEXT + 1; + _demoText = kDemo + 1; } //FIXME: tc = TimerCount; } diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 68c6f1f1dc..2a467761b3 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -69,27 +69,26 @@ namespace CGE { #define kSystemRate 6 // 12 Hz #define kHeroFun0 (40 * 12) #define kHeroFun1 ( 2 * 12) -#define GETNAME_PROMPT 50 -#define GETNAME_TITLE 51 -#define TSEQ 96 -#define NOMUSIC_TEXT 98 -#define BADSVG_TEXT 99 -#define HTALK (TSEQ + 4) -#define TOO_FAR (TSEQ + 5) -#define NO_WAY (TSEQ + 5) -#define POC_FUL (TSEQ + 5) -#define OFF_USE (TSEQ + 6) -#define QUIT_TITLE 200 -#define QUIT_TEXT 201 -#define NOQUIT_TEXT 202 -#define DEMO_TEXT 300 -#define NOSOUND_TEXT 310 -#define OFF_USE_COUNT 600 -#define OFF_USE_TEXT 601 -#define NO_WAY_TEXT 671 -#define TOO_FAR_TEXT 681 -#define POC_FUL_TEXT 691 -#define A_C_D_TEXT 777 +#define kGetNamePrompt 50 +#define kGetNameTitle 51 +#define kTSeq 96 +#define kNoMusic 98 +#define kBadSVG 99 +#define kSeqHTalk (kTSeq + 4) +#define kSeqTooFar (kTSeq + 5) +#define kSeqNoWay (kTSeq + 5) +#define kSeqPocketFull (kTSeq + 5) +#define kSeqOffUse (kTSeq + 6) +#define kQuitTitle 200 +#define kQuit 201 +#define kNoQuit 202 +#define kDemo 300 +#define kOffUseCount 600 +#define kOffUse 601 +#define kNoWay 671 +#define kTooFar 681 +#define kPocketFull 691 +#define kAltCtrlDel 777 #define kPanHeight 40 #define kScrWidth 320 #define kScrHeight 200 diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index 964b029b59..b1cc5769d8 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -33,8 +33,6 @@ namespace CGE { -#define MENU_TEXT 56 - static Choice *_cho; static int _hlp; @@ -43,7 +41,7 @@ void CGEEngine::snSelect() { inf(_text->getText(_hlp)); _talk->gotoxy(_talk->_x, kFontHigh / 2); - (new Vmenu(this, _cho, kScrWidth / 2, _talk->_y + _talk->_h + kTextVMargin + kFontHigh))->setName(_text->getText(MENU_TEXT)); + (new Vmenu(this, _cho, kScrWidth / 2, _talk->_y + _talk->_h + kTextVMargin + kFontHigh))->setName(_text->getText(kMenu)); } } // End of namespace CGE diff --git a/engines/cge/config.h b/engines/cge/config.h index d7191a281d..5ea677b97d 100644 --- a/engines/cge/config.h +++ b/engines/cge/config.h @@ -29,6 +29,7 @@ #define __CGE_CONFIG__ namespace CGE { + #define kMenu 56 } // End of namespace CGE #endif diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index 93342f77da..0364758a12 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -29,10 +29,6 @@ namespace CGE { -#define EMS_INT 0x67 -#define PAGE_MASK 0x3FFF -#define SIZ(n) ((n) ? ((long)n) : (0x10000L)) - enum EMM_FUN { GET_STATUS = 0x40, GET_FRAME, GET_SIZE, OPEN_HANDLE, MAP_PAGE, diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 18c4efbe00..4107580691 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -43,36 +43,17 @@ uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b) { return x; } -/* Useless? -uint8 *Mark(DAC *pal) { -#define f(c) (c ^ 63) - uint8 *x = new uint8[256]; - if (x) { - uint16 i; - for (i = 0; i < 256; i++) { - x[i] = closest(pal, mkDax(f(pal[i]._R), - f(pal[i]._G), - f(pal[i]._B))); - } - } - return x; -#undef f -} -*/ - int Fly::_l = 20, Fly::_t = 40, Fly::_r = 110, Fly::_b = 100; - Fly::Fly(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), _tx(0), _ty(0), _vm(vm) { step(new_random(2)); gotoxy(_l + new_random(_r - _l - _w), _t + new_random(_b - _t - _h)); } - void Fly::tick() { step(); if (!_flags._kept) { diff --git a/engines/cge/game.h b/engines/cge/game.h index c442d81577..078f3880ea 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -33,15 +33,7 @@ namespace CGE { -//#define PAN_HIG 40 -//#define LBound(s) (s->X <= 0) -//#define RBound(s) (s->X+s->W >= SCR_WID) -//#define TBound(s) (s->Y <= 0) -//#define BBound(s) (s->Y+s->H >= SCR_HIG - PAN_HIG) - -//int sinus(long x); uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b); -//uint8 *mark(DAC *pal); class Fly : public Sprite { static int _l; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index e9ae494811..e694cab0b9 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -303,10 +303,10 @@ void CGEEngine::pocFul() { _hero->park(); SNPOST(SNWAIT, -1, -1, _hero); - SNPOST(SNSEQ, -1, POC_FUL, _hero); + SNPOST(SNSEQ, -1, kSeqPocketFull, _hero); SNPOST(SNSOUND, -1, 2, _hero); SNPOST(SNWAIT, -1, -1, _hero); - SNPOST(SNSAY, 1, POC_FUL_TEXT, _hero); + SNPOST(SNSAY, 1, kPocketFull, _hero); } void CGEEngine::hide1(Sprite *spr) { @@ -1006,7 +1006,7 @@ void Snail::runCom() { case SNSAY : if (spr && _talkEnable) { if (spr == _hero && spr->seqTest(-1)) - spr->step(HTALK); + spr->step(kSeqHTalk); _text->say(_text->getText(snc->_val), spr); _sys->_funDel = kHeroFun0; } @@ -1020,7 +1020,7 @@ void Snail::runCom() { case SNTIME : if (spr && _talkEnable) { if (spr == _hero && spr->seqTest(-1)) - spr->step(HTALK); + spr->step(kSeqHTalk); sayTime(spr); } break; diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index f07ed4ece2..2568a51df0 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -234,7 +234,7 @@ void WALK::reach(Sprite *spr, int mode) { } // note: insert SNAIL commands in reverse order SNINSERT(SNPAUSE, -1, 64, NULL); - SNINSERT(SNSEQ, -1, TSEQ + mode, this); + SNINSERT(SNSEQ, -1, kTSeq + mode, this); if (spr) { SNINSERT(SNWAIT, -1, -1, _hero); /////--------$$$$$$$ //SNINSERT(SNWALK, -1, -1, spr); @@ -244,7 +244,7 @@ void WALK::reach(Sprite *spr, int mode) { } void WALK::noWay() { - _vm->trouble(NO_WAY, NO_WAY_TEXT); + _vm->trouble(kSeqNoWay, kNoWay); } bool WALK::find1Way(Cluster c) { -- cgit v1.2.3 From c728a53148d436cfebb33d58a75f3146980a39e0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2011 14:31:39 +0200 Subject: CGE: Rename IOMode and SnCom enums --- engines/cge/btfile.cpp | 2 +- engines/cge/btfile.h | 2 +- engines/cge/cfile.cpp | 16 +- engines/cge/cfile.h | 6 +- engines/cge/cge_main.cpp | 96 ++++++------ engines/cge/general.cpp | 15 +- engines/cge/general.h | 18 +-- engines/cge/gettext.cpp | 10 +- engines/cge/gettext.h | 8 +- engines/cge/mixer.cpp | 32 ++-- engines/cge/mixer.h | 14 +- engines/cge/snail.cpp | 373 +++++++++++++++++++++++------------------------ engines/cge/snail.h | 48 +++--- engines/cge/text.cpp | 3 +- engines/cge/vga13h.cpp | 6 +- engines/cge/vmenu.cpp | 2 +- engines/cge/vol.cpp | 8 +- engines/cge/vol.h | 2 +- engines/cge/walk.cpp | 8 +- 19 files changed, 325 insertions(+), 344 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index e3d9f729d9..d5cdef1ba0 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -34,7 +34,7 @@ namespace CGE { -BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt) +BtFile::BtFile(const char *name, IOMode mode, CRYPT *crpt) : IoHand(name, mode, crpt) { debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode); diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 4784ffd6ed..b589e86aee 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -83,7 +83,7 @@ class BtFile : public IoHand { void putPage(int lev, bool hard); BtPage *getPage(int lev, uint16 pgn); public: - BtFile(const char *name, IOMODE mode, CRYPT *crpt); + BtFile(const char *name, IOMode mode, CRYPT *crpt); virtual ~BtFile(); BtKeypack *find(const char *key); BtKeypack *next(); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index f0eeb30bff..1c5cf1d358 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -33,7 +33,7 @@ namespace CGE { -IoBuf::IoBuf(IOMODE mode, CRYPT *crpt) +IoBuf::IoBuf(IOMode mode, CRYPT *crpt) : IoHand(mode, crpt), _bufMark(0), _ptr(0), @@ -46,7 +46,7 @@ IoBuf::IoBuf(IOMODE mode, CRYPT *crpt) } -IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) +IoBuf::IoBuf(const char *name, IOMode mode, CRYPT *crpt) : IoHand(name, mode, crpt), _bufMark(0), _ptr(0), @@ -61,7 +61,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt) IoBuf::~IoBuf() { debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()"); - if (_mode > REA) + if (_mode != kModeRead) writeBuf(); free(_buff); } @@ -222,7 +222,7 @@ void IoBuf::write(uint8 b) { uint16 CFile::_maxLineLen = kLineMaxSize; -CFile::CFile(const char *name, IOMODE mode, CRYPT *crpt) +CFile::CFile(const char *name, IOMode mode, CRYPT *crpt) : IoBuf(name, mode, crpt) { debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crpt)", name, mode); } @@ -235,7 +235,7 @@ CFile::~CFile() { void CFile::flush() { debugC(1, kCGEDebugFile, "CFile::flush()"); - if (_mode > REA) + if (_mode != kModeRead) writeBuf(); else _lim = 0; @@ -252,7 +252,7 @@ void CFile::flush() { long CFile::mark() { debugC(5, kCGEDebugFile, "CFile::mark()"); - return _bufMark + ((_mode > REA) ? _lim : _ptr); + return _bufMark + ((_mode != kModeRead) ? _lim : _ptr); } @@ -260,10 +260,10 @@ long CFile::seek(long pos) { debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos); if (pos >= _bufMark && pos < _bufMark + _lim) { - ((_mode == REA) ? _ptr : _lim) = (uint16)(pos - _bufMark); + ((_mode == kModeRead) ? _ptr : _lim) = (uint16)(pos - _bufMark); return pos; } else { - if (_mode > REA) + if (_mode != kModeRead) writeBuf(); else _lim = 0; diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 227b0f6a63..306ec5926b 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -46,8 +46,8 @@ protected: virtual void readBuf(); virtual void writeBuf(); public: - IoBuf(IOMODE mode, CRYPT *crpt = NULL); - IoBuf(const char *name, IOMODE mode, CRYPT *crpt = NULL); + IoBuf(IOMode mode, CRYPT *crpt = NULL); + IoBuf(const char *name, IOMode mode, CRYPT *crpt = NULL); virtual ~IoBuf(); uint16 read(void *buf, uint16 len); uint16 read(uint8 *buf); @@ -61,7 +61,7 @@ public: class CFile : public IoBuf { public: static uint16 _maxLineLen; - CFile(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL); + CFile(const char *name, IOMode mode = kModeRead, CRYPT *crpt = NULL); virtual ~CFile(); void flush(); long mark(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index ee561726a1..b6f342edff 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -401,18 +401,18 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade void CGEEngine::heroCover(int cvr) { debugC(1, kCGEDebugEngine, "CGEEngine::heroCover(%d)", cvr); - SNPOST(SNCOVER, 1, cvr, NULL); + _snail->addCom(kSnCover, 1, cvr, NULL); } void CGEEngine::trouble(int seq, int txt) { debugC(1, kCGEDebugEngine, "CGEEngine::trouble(%d, %d)", seq, txt); _hero->park(); - SNPOST(SNWAIT, -1, -1, _hero); - SNPOST(SNSEQ, -1, seq, _hero); - SNPOST(SNSOUND, -1, 2, _hero); - SNPOST(SNWAIT, -1, -1, _hero); - SNPOST(SNSAY, 1, txt, _hero); + _snail->addCom(kSnWait, -1, -1, _hero); + _snail->addCom(kSnSeq, -1, seq, _hero); + _snail->addCom(kSnSound, -1, 2, _hero); + _snail->addCom(kSnWait, -1, -1, _hero); + _snail->addCom(kSnSay, 1, txt, _hero); } void CGEEngine::offUse() { @@ -464,7 +464,7 @@ void Square::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); if (mask & L_UP) { XZ(_x + x, _y + y).cell() = 0; - SNPOST_(SNKILL, -1, 0, this); + _snail_->addCom(kSnKill, -1, 0, this); } } @@ -487,14 +487,14 @@ void CGEEngine::setMapBrick(int x, int z) { void CGEEngine::keyClick() { debugC(1, kCGEDebugEngine, "CGEEngine::keyClick()"); - SNPOST_(SNSOUND, -1, 5, NULL); + _snail_->addCom(kSnSound, -1, 5, NULL); } void CGEEngine::resetQSwitch() { debugC(1, kCGEDebugEngine, "CGEEngine::resetQSwitch()"); - SNPOST_(SNSEQ, 123, 0, NULL); + _snail_->addCom(kSnSeq, 123, 0, NULL); keyClick(); } @@ -510,13 +510,13 @@ void CGEEngine::quit() { if (_snail->idle() && !_hero->_flags._hide) { if (Vmenu::_addr) { - SNPOST_(SNKILL, -1, 0, Vmenu::_addr); + _snail_->addCom(kSnKill, -1, 0, Vmenu::_addr); resetQSwitch(); } else { QuitMenu[0]._text = _text->getText(kQuit); QuitMenu[1]._text = _text->getText(kNoQuit); (new Vmenu(this, QuitMenu, -1, -1))->setName(_text->getText(kQuitTitle)); - SNPOST_(SNSEQ, 123, 1, NULL); + _snail_->addCom(kSnSeq, 123, 1, NULL); keyClick(); } } @@ -526,7 +526,7 @@ void CGEEngine::quit() { void CGEEngine::AltCtrlDel() { debugC(1, kCGEDebugEngine, "CGEEngine::AltCtrlDel()"); - SNPOST_(SNSAY, -1, kAltCtrlDel, _hero); + _snail_->addCom(kSnSay, -1, kAltCtrlDel, _hero); } void CGEEngine::miniStep(int stp) { @@ -547,7 +547,7 @@ void CGEEngine::postMiniStep(int step) { debugC(6, kCGEDebugEngine, "CGEEngine::postMiniStep(%d)", step); if (_miniCave && step != _recentStep) - SNPOST2_(SNEXEC, -1, _recentStep = step, kMiniStep); + _snail_->addCom2(kSnExec, -1, _recentStep = step, kMiniStep); } void CGEEngine::showBak(int ref) { @@ -676,8 +676,8 @@ void CGEEngine::switchCave(int cav) { if (cav != _now) { _heart->_enable = false; if (cav < 0) { - SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - SNPOST2(SNEXEC, -1, 0, kQGame); // switch cave + _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint + _snail->addCom2(kSnExec, -1, 0, kQGame); // switch cave } else { _now = cav; _mouse->off(); @@ -694,8 +694,8 @@ void CGEEngine::switchCave(int cav) { killText(); if (!_startupMode) keyClick(); - SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint - SNPOST2(SNEXEC, 0, 0, kXCave); // switch cave + _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint + _snail->addCom2(kSnExec, 0, 0, kXCave); // switch cave } } } @@ -732,7 +732,7 @@ void System::touch(uint16 mask, int x, int y) { _vm->keyClick(); killText(); if (_vm->_startupMode == 1) { - SNPOST(SNCLEAR, -1, 0, NULL); + _snail->addCom(kSnClear, -1, 0, NULL); return; } pp0 = pp; @@ -801,7 +801,7 @@ void System::touch(uint16 mask, int x, int y) { case '3': case '4': if (_keyboard->_key[ALT]) { - SNPOST(SNLEVEL, -1, x - '0', NULL); + _snail->addCom(kSnLevel, -1, x - '0', NULL); break; } case '5': @@ -910,7 +910,7 @@ void System::tick() { void CGEEngine::switchColorMode() { debugC(1, kCGEDebugEngine, "CGEEngine::switchColorMode()"); - SNPOST_(SNSEQ, 121, _vga->_mono = !_vga->_mono, NULL); + _snail_->addCom(kSnSeq, 121, _vga->_mono = !_vga->_mono, NULL); keyClick(); _vga->setColors(Vga::_sysPal, 64); } @@ -920,16 +920,16 @@ void CGEEngine::switchMusic() { if (_keyboard->_key[ALT]) { if (Vmenu::_addr) - SNPOST_(SNKILL, -1, 0, Vmenu::_addr); + _snail_->addCom(kSnKill, -1, 0, Vmenu::_addr); else { - SNPOST_(SNSEQ, 122, (_music = false), NULL); - SNPOST2(SNEXEC, -1, 0, kSelectSound); + _snail_->addCom(kSnSeq, 122, (_music = false), NULL); + _snail->addCom2(kSnExec, -1, 0, kSelectSound); } } else { if (Startup::_core < CORE_HIG) - SNPOST(SNINF, -1, kNoMusic, NULL); + _snail->addCom(kSnInf, -1, kNoMusic, NULL); else { - SNPOST_(SNSEQ, 122, (_music = !_music), NULL); + _snail_->addCom(kSnSeq, 122, (_music = !_music), NULL); keyClick(); } } @@ -950,7 +950,7 @@ void CGEEngine::takeName() { debugC(1, kCGEDebugEngine, "CGEEngine::takeName()"); if (GetText::_ptr) - SNPOST_(SNKILL, -1, 0, GetText::_ptr); + _snail_->addCom(kSnKill, -1, 0, GetText::_ptr); else { memset(_usrFnam, 0, 15); GetText *tn = new GetText(this, _text->getText(kGetNamePrompt), _usrFnam, 8); @@ -980,7 +980,7 @@ void CGEEngine::switchMapping() { Sprite *s; for (s = _vga->_showQ->first(); s; s = s->_next) if (s->_w == MAP_XGRID && s->_h == MAP_ZGRID) - SNPOST_(SNKILL, -1, 0, s); + _snail_->addCom(kSnKill, -1, 0, s); } _horzLine->_flags._hide = !_horzLine->_flags._hide; } @@ -990,7 +990,7 @@ void CGEEngine::killSprite() { _sprite->_flags._kill = true; _sprite->_flags._bDel = true; - SNPOST_(SNKILL, -1, 0, _sprite); + _snail_->addCom(kSnKill, -1, 0, _sprite); _sprite = NULL; } @@ -1003,7 +1003,7 @@ void CGEEngine::pushSprite() { while (_sprite->_z > _sprite->_next->_z) _sprite->_z--; } else - SNPOST_(SNSOUND, -1, 2, NULL); + _snail_->addCom(kSnSound, -1, 2, NULL); } void CGEEngine::pullSprite() { @@ -1022,25 +1022,25 @@ void CGEEngine::pullSprite() { while (_sprite->_z < _sprite->_prev->_z) _sprite->_z++; } else - SNPOST_(SNSOUND, -1, 2, NULL); + _snail_->addCom(kSnSound, -1, 2, NULL); } void CGEEngine::nextStep() { debugC(1, kCGEDebugEngine, "CGEEngine::nextStep()"); - SNPOST_(SNSTEP, 0, 0, _sprite); + _snail_->addCom(kSnStep, 0, 0, _sprite); } void CGEEngine::saveMapping() { debugC(1, kCGEDebugEngine, "CGEEngine::saveMapping()"); - IoHand cfTab(progName(".TAB"), UPD); + IoHand cfTab(progName(".TAB"), kModeUpdate); if (!cfTab._error) { cfTab.seek((_now - 1) * sizeof(Cluster::_map)); cfTab.write((uint8 *) Cluster::_map, sizeof(Cluster::_map)); } - IoHand cfHxy(progName(".HXY"), WRI); + IoHand cfHxy(progName(".HXY"), kModeWrite); if (!cfHxy._error) { _heroXY[_now - 1]._x = _hero->_x; _heroXY[_now - 1]._y = _hero->_y; @@ -1155,13 +1155,13 @@ void Sprite::touch(uint16 mask, int x, int y) { if (_vm->findPocket(NULL) < 0) _vm->pocFul(); else { - SNPOST(SNREACH, -1, -1, this); - SNPOST(SNKEEP, -1, -1, this); + _snail->addCom(kSnReach, -1, -1, this); + _snail->addCom(kSnKeep, -1, -1, this); _flags._port = false; } } else { if (_takePtr != NO_PTR) { - if (snList(kTake)[_takePtr]._com == SNNEXT) + if (snList(kTake)[_takePtr]._com == kSnNext) _vm->offUse(); else _vm->feedSnail(this, kTake); @@ -1184,7 +1184,7 @@ void Sprite::touch(uint16 mask, int x, int y) { } } } else - SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this); + _snail->addCom(kSnWalk, -1, -1, this); // Hero->FindWay(this); } } } @@ -1413,9 +1413,9 @@ void CGEEngine::mainLoop() { // static uint32 tc = 0; if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ _talk == NULL && _snail->idle()) { if (_text->getText(_demoText)) { - SNPOST(SNSOUND, -1, 4, NULL); // drumla - SNPOST(SNINF, -1, _demoText, NULL); - SNPOST(SNLABEL, -1, -1, NULL); + _snail->addCom(kSnSound, -1, 4, NULL); // drumla + _snail->addCom(kSnInf, -1, _demoText, NULL); + _snail->addCom(kSnLabel, -1, -1, NULL); if (_text->getText(++_demoText) == NULL) _demoText = kDemo + 1; } @@ -1525,10 +1525,10 @@ void CGEEngine::runGame() { // ~~~~~~~~~~~ if ((_sprite = _vga->_spareQ->locate(121)) != NULL) - SNPOST_(SNSEQ, -1, _vga->_mono, _sprite); + _snail_->addCom(kSnSeq, -1, _vga->_mono, _sprite); if ((_sprite = _vga->_spareQ->locate(122)) != NULL) _sprite->step(_music); - SNPOST_(SNSEQ, -1, _music, _sprite); + _snail_->addCom(kSnSeq, -1, _music, _sprite); if (!_music) killMidi(); @@ -1585,7 +1585,7 @@ void CGEEngine::runGame() { _startupMode = 0; - SNPOST(SNLEVEL, -1, _oldLev, &_cavLight); + _snail->addCom(kSnLevel, -1, _oldLev, &_cavLight); _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); caveUp(); @@ -1594,14 +1594,14 @@ void CGEEngine::runGame() { // main loop while (!_finis && !_eventManager->_quitFlag) { if (_finis) - SNPOST2(SNEXEC, -1, 0, kQGame); + _snail->addCom2(kSnExec, -1, 0, kQGame); mainLoop(); } _keyboard->setClient(NULL); _heart->_enable = false; - SNPOST(SNCLEAR, -1, 0, NULL); - SNPOST_(SNCLEAR, -1, 0, NULL); + _snail->addCom(kSnClear, -1, 0, NULL); + _snail_->addCom(kSnClear, -1, 0, NULL); _mouse->off(); _vga->_showQ->clear(); _vga->_spareQ->clear(); @@ -1629,8 +1629,8 @@ void CGEEngine::movie(const char *ext) { _keyboard->setClient(NULL); _heart->_enable = false; - SNPOST(SNCLEAR, -1, 0, NULL); - SNPOST_(SNCLEAR, -1, 0, NULL); + _snail->addCom(kSnClear, -1, 0, NULL); + _snail_->addCom(kSnClear, -1, 0, NULL); _vga->_showQ->clear(); _vga->_spareQ->clear(); } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 8639c66653..909c517c32 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -206,15 +206,15 @@ char *dwtom(uint32 val, char *str, int radix, int len) { return str; } -IoHand::IoHand(IOMODE mode, CRYPT *crpt) - : XFile(mode), _crypt(crpt), _seed(SEED) { +IoHand::IoHand(IOMode mode, CRYPT *crpt) + : XFile(mode), _crypt(crpt), _seed(kCryptSeed) { _file = new Common::File(); } -IoHand::IoHand(const char *name, IOMODE mode, CRYPT *crpt) - : XFile(mode), _crypt(crpt), _seed(SEED) { +IoHand::IoHand(const char *name, IOMode mode, CRYPT *crpt) + : XFile(mode), _crypt(crpt), _seed(kCryptSeed) { // TODO: Check if WRI and/or UPD modes are needed, and map to a save file - assert(mode == REA); + assert(mode == kModeRead); _file = new Common::File(); _file->open(name); @@ -226,7 +226,7 @@ IoHand::~IoHand() { } uint16 IoHand::read(void *buf, uint16 len) { - if (_mode == WRI || !_file->isOpen()) + if (_mode == kModeWrite || !_file->isOpen()) return 0; uint16 bytesRead = _file->read(buf, len); @@ -242,7 +242,7 @@ uint16 IoHand::write(void *buf, uint16 len) { return 0; /* if (len) { - if (Mode == REA || Handle < 0) + if (Mode == kModeRead || Handle < 0) return 0; if (Crypt) Seed = Crypt(buf, len, Seed); @@ -333,7 +333,6 @@ int new_random(int range) { return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } -#define TIMER_INT 0x08 //void interrupt (* Engine_::oldTimer) (...) = NULL; Engine_::Engine_(uint16 tdiv) { diff --git a/engines/cge/general.h b/engines/cge/general.h index 0639fe2a01..63d43c4403 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -37,9 +37,9 @@ namespace CGE { -#define SEED 0xA5 +#define kCryptSeed 0xA5 -enum IOMODE { REA, WRI, UPD }; +enum IOMode { kModeRead, kModeWrite, kModeUpdate }; struct Dac { uint8 _r; @@ -47,7 +47,7 @@ struct Dac { uint8 _b; }; -typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); +typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); class Engine_ { protected: @@ -111,11 +111,11 @@ T min(T A, T B) { class XFile { public: - IOMODE _mode; + IOMode _mode; uint16 _error; - XFile() : _mode(REA), _error(0) { } - XFile(IOMODE mode) : _mode(mode), _error(0) { } + XFile() : _mode(kModeRead), _error(0) { } + XFile(IOMode mode) : _mode(mode), _error(0) { } virtual ~XFile() { } virtual uint16 read(void *buf, uint16 len) = 0; virtual uint16 write(void *buf, uint16 len) = 0; @@ -137,8 +137,8 @@ protected: uint16 _seed; CRYPT *_crypt; public: - IoHand(const char *name, IOMODE mode = REA, CRYPT crypt = NULL); - IoHand(IOMODE mode = REA, CRYPT *crpt = NULL); + IoHand(const char *name, IOMode mode = kModeRead, CRYPT crypt = NULL); + IoHand(IOMode mode = kModeRead, CRYPT *crpt = NULL); virtual ~IoHand(); static bool exist(const char *name); uint16 read(void *buf, uint16 len); @@ -146,8 +146,6 @@ public: long mark(); long size(); long seek(long pos); - //timeb Time (); -// void SetTime (timeb t); }; CRYPT XCrypt; diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 2f16cad86a..7a8cff3cb2 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -35,8 +35,8 @@ GetText *GetText::_ptr = NULL; GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) - : Talk(vm), _text(text), _size(min(size, GTMAX)), _len(min(_size, strlen(text))), - _cntr(GTBLINK), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { + : Talk(vm), _text(text), _size(min(size, kGetTextMax)), _len(min(_size, strlen(text))), + _cntr(kGetTextBlink), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { int i = 2 * kTextHMargin + _font->width(info); _ptr = this; _mode = RECT; @@ -63,12 +63,12 @@ GetText::~GetText() { void GetText::tick() { - if (++_cntr >= GTBLINK) { + if (++_cntr >= kGetTextBlink) { _buff[_len] ^= (' ' ^ '_'); _cntr = 0; } putLine(1, _buff); - _time = GTTIME; + _time = kGetTextTime; } @@ -89,7 +89,7 @@ void GetText::touch(uint16 mask, int x, int y) { *p = bezo[q - ogon]; } case Esc : - SNPOST_(SNKILL, -1, 0, this); + _snail_->addCom(kSnKill, -1, 0, this); break; case BSp : if (_len) { diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index 188e90c776..6afa9ccfec 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -33,12 +33,12 @@ namespace CGE { -#define GTMAX 24 -#define GTBLINK 6 -#define GTTIME 6 +#define kGetTextMax 24 +#define kGetTextBlink 6 +#define kGetTextTime 6 class GetText : public Talk { - char _buff[GTMAX + 2]; + char _buff[kGetTextMax + 2]; char *_text; uint16 _size; uint16 _len; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index eddc4a6570..aeaaa86593 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -39,24 +39,24 @@ extern Mouse *Mouse; bool Mixer::_appear = false; -Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _vm(vm) { +Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _vm(vm) { _appear = true; _mb[0] = new Bitmap("VOLUME", true); _mb[1] = NULL; setShapeList(_mb); - setName(_text->getText(MIX_NAME)); + setName(_text->getText(kMixName)); _flags._syst = true; _flags._kill = true; _flags._bDel = true; gotoxy(x, y); - _z = MIX_Z; + _z = kMixZ; // slaves uint i; - Seq ls[MIX_MAX]; + Seq ls[kMixMax]; - for (i = 0; i < MIX_MAX; i++) { + for (i = 0; i < kMixMax; i++) { static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); _lb[i] = new Bitmap(fn, true); @@ -68,15 +68,15 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _ for (i = 0; i < ArrayCount(_led); i++) { register Sprite *spr = new Sprite(_vm, _lb); - Seq *seq = (Seq *)malloc(MIX_MAX * sizeof(Seq)); - Common::copy(ls, ls + MIX_MAX, seq); + Seq *seq = (Seq *)malloc(kMixMax * sizeof(Seq)); + Common::copy(ls, ls + kMixMax, seq); spr->setSeq(seq); spr->gotoxy(x + 2 + 12 * i, y + 8); spr->_flags._tran = true; spr->_flags._kill = true; spr->_flags._bDel = false; - spr->_z = MIX_Z; + spr->_z = kMixZ; _led[i] = spr; } _led[ArrayCount(_led) - 1]->_flags._bDel = true; @@ -93,7 +93,7 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(MIX_FALL), _ _sndDrvInfo.Vol4._dl = i; _sndDrvInfo.Vol4._dr = i; update(); - _time = MIX_DELAY; + _time = kMixDelay; } Mixer::~Mixer() { @@ -106,10 +106,10 @@ void Mixer::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); if (mask & L_UP) { uint8 *vol = (&_sndDrvInfo.Vol2._d) + (x < _w / 2); - if (y < MIX_BHIG) { + if (y < kMixButtonHigh) { if (*vol < 0xFF) *vol += 0x11; - } else if (y >= _h - MIX_BHIG) { + } else if (y >= _h - kMixButtonHigh) { if (*vol > 0x00) *vol -= 0x11; } @@ -122,7 +122,7 @@ void Mixer::tick() { int x = _mouse->_x; int y = _mouse->_y; if (spriteAt(x, y) == this) { - _fall = MIX_FALL; + _fall = kMixFall; if (_flags._hold) touch(L_UP, x - _x, y - _y); } else { @@ -130,11 +130,11 @@ void Mixer::tick() { _fall--; else { for (uint i = 0; i < ArrayCount(_led); i++) - SNPOST_(SNKILL, -1, 0, _led[i]); - SNPOST_(SNKILL, -1, 0, this); + _snail_->addCom(kSnKill, -1, 0, _led[i]); + _snail_->addCom(kSnKill, -1, 0, this); } } - _time = MIX_DELAY; + _time = kMixDelay; } @@ -142,7 +142,7 @@ void Mixer::update() { _led[0]->step(_sndDrvInfo.Vol4._ml); _led[1]->step(_sndDrvInfo.Vol4._dl); - SNPOST2_(SNEXEC, -1, 0, kSndSetVolume); + _snail_->addCom2(kSnExec, -1, 0, kSndSetVolume); } } // End of namespace CGE diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index ef53eec070..d97a4f3dd3 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -32,16 +32,16 @@ namespace CGE { -#define MIX_MAX 16 // count of Leds -#define MIX_Z 64 // mixer Z position -#define MIX_DELAY 12 // 6/s -#define MIX_FALL 6 // in MIX_DELAY units -#define MIX_BHIG 6 // mixer button high -#define MIX_NAME 105 // sprite name +#define kMixMax 16 // count of Leds +#define kMixZ 64 // mixer Z position +#define kMixDelay 12 // 6/s +#define kMixFall 6 // in MIX_DELAY units +#define kMixButtonHigh 6 // mixer button high +#define kMixName 105 // sprite name class Mixer : public Sprite { BMP_PTR _mb[2]; - BMP_PTR _lb[MIX_MAX + 1]; + BMP_PTR _lb[kMixMax + 1]; Sprite *_led[2]; int _fall; void update(); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index e694cab0b9..d2ed77d755 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -50,8 +50,6 @@ void CGEEngine::snGame(Sprite *spr, int num) { switch (num) { case 1 : { -#define STAGES 8 -#define DRESSED 3 static Sprite *dup[3] = { NULL, NULL, NULL }; int buref = 0; int Stage = 0; @@ -71,71 +69,69 @@ void CGEEngine::snGame(Sprite *spr, int num) { if (_game) { // continue game int i = new_random(3), hand = (dup[0]->_shpCnt == 6); Stage++; - if (hand && Stage > DRESSED) + if (hand && Stage > kDressed) ++hand; if (i >= 0 || (dup[i] == spr && new_random(3) == 0)) { - SNPOST(SNSEQ, -1, 3, dup[0]); // yes - SNPOST(SNSEQ, -1, 3, dup[1]); // yes - SNPOST(SNSEQ, -1, 3, dup[2]); // yes - SNPOST(SNTNEXT, -1, 0, dup[0]); // reset Take - SNPOST(SNTNEXT, -1, 0, dup[1]); // reset Take - SNPOST(SNTNEXT, -1, 0, dup[2]); // reset Take - SNPOST(SNNNEXT, -1, 0, dup[0]); // reset Near - SNPOST(SNPAUSE, -1, 72, NULL); // little rest - SNPOST(SNSAY, 1, 16009, NULL); // hura - SNPOST(SNSAY, buref, 16010, NULL); // siadaj - SNPOST(SNSAY, 1, 16011, NULL); // postoj‘ + _snail->addCom(kSnSeq, -1, 3, dup[0]); // yes + _snail->addCom(kSnSeq, -1, 3, dup[1]); // yes + _snail->addCom(kSnSeq, -1, 3, dup[2]); // yes + _snail->addCom(kSnTNext, -1, 0, dup[0]); // reset Take + _snail->addCom(kSnTNext, -1, 0, dup[1]); // reset Take + _snail->addCom(kSnTNext, -1, 0, dup[2]); // reset Take + _snail->addCom(kSnNNext, -1, 0, dup[0]); // reset Near + _snail->addCom(kSnPause, -1, 72, NULL); // little rest + _snail->addCom(kSnSay, 1, 16009, NULL); // hura + _snail->addCom(kSnSay, buref, 16010, NULL); // siadaj + _snail->addCom(kSnSay, 1, 16011, NULL); // postoj‘ if (hand) { - SNPOST(SNSEND, 16060 + hand, 16, NULL); // dawaj r‘k‘ - SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie - SNPOST(SNSEQ, 16060 + hand, 1, NULL); // ruch - SNPOST(SNSOUND, 16060 + hand, 16002, NULL); // szelest - SNPOST(SNWAIT, 16060 + hand, 3, NULL); // podniesie - SNPOST(SNSWAP, buref, buref + 100, NULL); // rozdziana - SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa - SNPOST(SNSEND, 16060 + hand, -1, NULL); // chowaj r‘k‘ - SNPOST(SNWAIT, 16060 + hand, -1, NULL); // r‘ka zamar’a + _snail->addCom(kSnSend, 16060 + hand, 16, NULL); // dawaj r‘k‘ + _snail->addCom(kSnSeq, buref, 4, NULL); // zdejmowanie + _snail->addCom(kSnSeq, 16060 + hand, 1, NULL); // ruch + _snail->addCom(kSnSound, 16060 + hand, 16002, NULL); // szelest + _snail->addCom(kSnWait, 16060 + hand, 3, NULL); // podniesie + _snail->addCom(kSnSwap, buref, buref + 100, NULL); // rozdziana + _snail->addCom(kSnSeq, 16016, Stage, NULL); // rožnie kupa + _snail->addCom(kSnSend, 16060 + hand, -1, NULL); // chowaj r‘k‘ + _snail->addCom(kSnWait, 16060 + hand, -1, NULL); // r‘ka zamar’a } else { - SNPOST(SNSEQ, buref, 4, NULL); // zdejmowanie - SNPOST(SNSOUND, 16060 + hand, 16002, NULL); // szelest - SNPOST(SNWAIT, buref, -1, NULL); // zdejmie - SNPOST(SNSWAP, buref, buref + 100, NULL); // rozdziana - SNPOST(SNSEQ, 16016, Stage, NULL); // rožnie kupa + _snail->addCom(kSnSeq, buref, 4, NULL); // zdejmowanie + _snail->addCom(kSnSound, 16060 + hand, 16002, NULL); // szelest + _snail->addCom(kSnWait, buref, -1, NULL); // zdejmie + _snail->addCom(kSnSwap, buref, buref + 100, NULL); // rozdziana + _snail->addCom(kSnSeq, 16016, Stage, NULL); // rožnie kupa } //SNPOST(SNSEQ, buref+100, 0, NULL); // reset - SNPOST(SNPAUSE, -1, 72, NULL); // chwilk‘... - - SNPOST(SNSEQ, -1, 0, dup[1]); // odstaw Go - SNPOST(SNSETXY, -1, 203 + kScrWidth * 49, dup[1]); - SNPOST(SNSETZ, -1, 7, dup[1]); - - SNPOST(SNSEQ, -1, 0, dup[2]); // odstaw J† - SNPOST(SNSETXY, -1, 182 + kScrWidth * 62, dup[2]); - SNPOST(SNSETZ, -1, 9, dup[2]); + _snail->addCom(kSnPause, -1, 72, NULL); // chwilk‘... + _snail->addCom(kSnSeq, -1, 0, dup[1]); // odstaw Go + _snail->addCom(kSnSetXY, -1, 203 + kScrWidth * 49, dup[1]); + _snail->addCom(kSnSetZ, -1, 7, dup[1]); + _snail->addCom(kSnSeq, -1, 0, dup[2]); // odstaw J† + _snail->addCom(kSnSetXY, -1, 182 + kScrWidth * 62, dup[2]); + _snail->addCom(kSnSetZ, -1, 9, dup[2]); _game = 0; return; } else { - SNPOST(SNSEQ, -1, 2, dup[0]); // no - SNPOST(SNSEQ, -1, 2, dup[1]); // no - SNPOST(SNSEQ, -1, 2, dup[2]); // no - SNPOST(SNPAUSE, -1, 72, NULL); // 1 sec + _snail->addCom(kSnSeq, -1, 2, dup[0]); // no + _snail->addCom(kSnSeq, -1, 2, dup[1]); // no + _snail->addCom(kSnSeq, -1, 2, dup[2]); // no + _snail->addCom(kSnPause, -1, 72, NULL); // 1 sec } } - SNPOST(SNWALK, 198, 134, NULL); // na miejsce - SNPOST(SNWAIT, 1, -1, NULL); // stoi - SNPOST(SNCOVER, 1, 16101, NULL); // ch’op do bicia - SNPOST(SNSEQ, 16101, 1, NULL); // wystaw - SNPOST(SNWAIT, 16101, 5, NULL); // czekaj - SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘ - SNPOST(SNSEQ, 16040, 1, NULL); // plask - SNPOST(SNSOUND, 16101, 16001, NULL); // plask! - SNPOST(SNPAUSE, 16101, 24, NULL); // czekaj chwil‘ - SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask - SNPOST(SNWAIT, 16101, -1, NULL); // stoi - SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS + _snail->addCom(kSnWalk, 198, 134, NULL); // na miejsce + _snail->addCom(kSnWait, 1, -1, NULL); // stoi + _snail->addCom(kSnCover, 1, 16101, NULL); // ch’op do bicia + _snail->addCom(kSnSeq, 16101, 1, NULL); // wystaw + _snail->addCom(kSnWait, 16101, 5, NULL); // czekaj + _snail->addCom(kSnPause, 16101, 24, NULL); // czekaj chwil‘ + _snail->addCom(kSnSeq, 16040, 1, NULL); // plask + _snail->addCom(kSnSound, 16101, 16001, NULL); // plask! + _snail->addCom(kSnPause, 16101, 24, NULL); // czekaj chwil‘ + _snail->addCom(kSnSeq, 16040, 0, NULL); // schowaj plask + _snail->addCom(kSnWait, 16101, -1, NULL); // stoi + _snail->addCom(kSnUncover, 1, 16101, NULL); // SDS if (!_game) { - SNPOST(SNSAY, buref, 16008, NULL); // zgadnij! + _snail->addCom(kSnSay, buref, 16008, NULL); // zgadnij! _game = true; } #undef STEPS @@ -155,7 +151,7 @@ void CGEEngine::snGame(Sprite *spr, int num) { } if (!_game) { // init - SNPOST(SNGAME, 20002, 2, NULL); + _snail->addCom(kSnGame, 20002, 2, NULL); _game = true; } else { // cont k1->step(new_random(6)); @@ -168,23 +164,23 @@ void CGEEngine::snGame(Sprite *spr, int num) { k3->step(5); } ///-------------------- - SNPOST(SNSETZ, 20700, 0, NULL); + _snail->addCom(kSnSetZ, 20700, 0, NULL); bool hit = (k1->_seqPtr + k2->_seqPtr + k3->_seqPtr == 15); if (hit) { if (spr->_ref == 1) { - SNPOST(SNSAY, 1, 20003, NULL); // hura! - SNPOST(SNSEQ, 20011, 2, NULL); // kamera won - SNPOST(SNSEND, 20701, -1, NULL); // k1 won - SNPOST(SNSEND, 20702, -1, NULL); // k2 won - SNPOST(SNSEND, 20703, -1, NULL); // k3 won - SNPOST(SNSEND, 20700, -1, NULL); // tv won - SNPOST(SNKEEP, 20007, 0, NULL); // do kieszeni - SNPOST(SNSEND, 20006, 20, NULL); // bilon - SNPOST(SNSOUND, 20006, 20002, NULL); // bilon! - SNPOST(SNSAY, 20002, 20004, NULL); - SNPOST(SNSEND, 20010, 20, NULL); // papier - SNPOST(SNSOUND, 20010, 20003, NULL); // papier! - SNPOST(SNSAY, 20001, 20005, NULL); + _snail->addCom(kSnSay, 1, 20003, NULL); // hura! + _snail->addCom(kSnSeq, 20011, 2, NULL); // kamera won + _snail->addCom(kSnSend, 20701, -1, NULL); // k1 won + _snail->addCom(kSnSend, 20702, -1, NULL); // k2 won + _snail->addCom(kSnSend, 20703, -1, NULL); // k3 won + _snail->addCom(kSnSend, 20700, -1, NULL); // tv won + _snail->addCom(kSnKeep, 20007, 0, NULL); // do kieszeni + _snail->addCom(kSnSend, 20006, 20, NULL); // bilon + _snail->addCom(kSnSound, 20006, 20002, NULL); // bilon! + _snail->addCom(kSnSay, 20002, 20004, NULL); + _snail->addCom(kSnSend, 20010, 20, NULL); // papier + _snail->addCom(kSnSound, 20010, 20003, NULL); // papier! + _snail->addCom(kSnSay, 20001, 20005, NULL); _game = false; return; } else @@ -193,60 +189,60 @@ void CGEEngine::snGame(Sprite *spr, int num) { if (count < 100) { switch (count) { case 15 : - SNPOST(SNSAY, 20003, 20021, NULL); + _snail->addCom(kSnSay, 20003, 20021, NULL); break; case 30 : case 45 : case 60 : case 75 : - SNPOST(SNSAY, 20003, 20022, NULL); + _snail->addCom(kSnSay, 20003, 20022, NULL); break; } count++; } switch (spr->_ref) { case 1 : - SNPOST(SNSAY, 20001, 20011, NULL); // zapro - SNPOST(SNSEQ, 20001, 1, NULL); // rzu - SNPOST(SNWAIT, 20001, 1, NULL); // czekaj - SNPOST(SNSETZ, 20700, 2, NULL); // skryj k - SNPOST(SNHIDE, 20007, 1, NULL); // skryj k - SNPOST(SNWAIT, 20001, 16, NULL); // czekaj - SNPOST(SNSEQ, 20007, 1, NULL); // lec† - SNPOST(SNHIDE, 20007, 0, NULL); // poka§ - SNPOST(SNSOUND, 20007, 20001, NULL); // grzech - SNPOST(SNWAIT, 20007, -1, NULL); // koniec - SNPOST(SNGAME, 20001, 2, NULL); // again! + _snail->addCom(kSnSay, 20001, 20011, NULL); // zapro + _snail->addCom(kSnSeq, 20001, 1, NULL); // rzu + _snail->addCom(kSnWait, 20001, 1, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20001, 16, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech + _snail->addCom(kSnWait, 20007, -1, NULL); // koniec + _snail->addCom(kSnGame, 20001, 2, NULL); // again! break; case 20001: - SNPOST(SNSAY, 20002, 20012, NULL); // zapro - SNPOST(SNSEQ, 20002, 1, NULL); // rzu - SNPOST(SNWAIT, 20002, 3, NULL); // czekaj - SNPOST(SNSETZ, 20700, 2, NULL); // skryj k - SNPOST(SNHIDE, 20007, 1, NULL); // skryj k - SNPOST(SNWAIT, 20002, 10, NULL); // czekaj - SNPOST(SNSEQ, 20007, 2, NULL); // lec† - SNPOST(SNHIDE, 20007, 0, NULL); // poka§ - SNPOST(SNSOUND, 20007, 20001, NULL); // grzech - SNPOST(SNWAIT, 20007, -1, NULL); // koniec - SNPOST(SNGAME, 20002, 2, NULL); // again! + _snail->addCom(kSnSay, 20002, 20012, NULL); // zapro + _snail->addCom(kSnSeq, 20002, 1, NULL); // rzu + _snail->addCom(kSnWait, 20002, 3, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20002, 10, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 2, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech + _snail->addCom(kSnWait, 20007, -1, NULL); // koniec + _snail->addCom(kSnGame, 20002, 2, NULL); // again! break; case 20002: - SNPOST(SNSAY, 20002, 20010, NULL); // zapro - SNPOST(SNWALK, 20005, -1, NULL); // do stol - SNPOST(SNWAIT, 1, -1, NULL); // stoi - SNPOST(SNCOVER, 1, 20101, NULL); // grasol - SNPOST(SNSEQ, 20101, 1, NULL); // rzu - SNPOST(SNWAIT, 20101, 5, NULL); // czekaj - SNPOST(SNSETZ, 20700, 2, NULL); // skryj k - SNPOST(SNHIDE, 20007, 1, NULL); // skryj k - SNPOST(SNWAIT, 20101, 15, NULL); // czekaj - SNPOST(SNSEQ, 20007, 1, NULL); // lec† - SNPOST(SNHIDE, 20007, 0, NULL); // poka§ - SNPOST(SNSOUND, 20007, 20001, NULL); // grzech - SNPOST(SNWAIT, 20101, -1, NULL); // koniec - SNPOST(SNUNCOVER, 1, 20101, NULL); // SDS - SNPOST(SNGAME, 1, 2, NULL); // again! + _snail->addCom(kSnSay, 20002, 20010, NULL); // zapro + _snail->addCom(kSnWalk, 20005, -1, NULL); // do stol + _snail->addCom(kSnWait, 1, -1, NULL); // stoi + _snail->addCom(kSnCover, 1, 20101, NULL); // grasol + _snail->addCom(kSnSeq, 20101, 1, NULL); // rzu + _snail->addCom(kSnWait, 20101, 5, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20101, 15, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech + _snail->addCom(kSnWait, 20101, -1, NULL); // koniec + _snail->addCom(kSnUncover, 1, 20101, NULL); // SDS + _snail->addCom(kSnGame, 1, 2, NULL); // again! break; } } @@ -302,17 +298,17 @@ void CGEEngine::pocFul() { debugC(1, kCGEDebugEngine, "CGEEngine::pocFul()"); _hero->park(); - SNPOST(SNWAIT, -1, -1, _hero); - SNPOST(SNSEQ, -1, kSeqPocketFull, _hero); - SNPOST(SNSOUND, -1, 2, _hero); - SNPOST(SNWAIT, -1, -1, _hero); - SNPOST(SNSAY, 1, kPocketFull, _hero); + _snail->addCom(kSnWait, -1, -1, _hero); + _snail->addCom(kSnSeq, -1, kSeqPocketFull, _hero); + _snail->addCom(kSnSound, -1, 2, _hero); + _snail->addCom(kSnWait, -1, -1, _hero); + _snail->addCom(kSnSay, 1, kPocketFull, _hero); } void CGEEngine::hide1(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::hide1(spr)"); - SNPOST_(SNGHOST, -1, 0, spr->ghost()); + _snail_->addCom(kSnGhost, -1, 0, spr->ghost()); } void CGEEngine::snGhost(Bitmap *bmp) { @@ -337,8 +333,8 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) { if (findPocket(NULL) < 0) { // no empty pockets? Snail::Com *p; - for (p = c; p->_com != SNNEXT; p++) { // find KEEP command - if (p->_com == SNKEEP) { + for (p = c; p->_com != kSnNext; p++) { // find KEEP command + if (p->_com == kSnKeep) { pocFul(); return; } @@ -347,11 +343,11 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) { } } while (true) { - if (c->_com == SNTALK) { + if (c->_com == kSnTalk) { if ((_snail->_talkEnable = (c->_val != 0)) == false) killText(); } - if (c->_com == SNNEXT) { + if (c->_com == kSnNext) { Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); if (s) { uint8 *idx = (snq == kTake) ? &s->_takePtr : &s->_nearPtr; @@ -378,7 +374,7 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) { if (s == spr) break; } - if (c->_com == SNIF) { + if (c->_com == kSnIf) { Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); if (s) { // sprite extsts if (! s->seqTest(-1)) @@ -388,7 +384,7 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) { } else ++c; } else { - SNPOST(c->_com, c->_ref, c->_val, spr); + _snail->addCom(c->_com, c->_ref, c->_val, spr); if (c->_ptr) break; else @@ -424,35 +420,35 @@ Snail::~Snail() { free(_snList); } -void Snail::addCom(SNCOM com, int ref, int val, void *ptr) { +void Snail::addCom(SnCom com, int ref, int val, void *ptr) { Com *snc = &_snList[_head++]; snc->_com = com; snc->_ref = ref; snc->_val = val; snc->_ptr = ptr; snc->_cbType = kNullCB; - if (com == SNCLEAR) { + if (com == kSnClear) { _tail = _head; killText(); _timerExpiry = 0; } } -void Snail::addCom2(SNCOM com, int ref, int val, CallbackType cbType) { +void Snail::addCom2(SnCom com, int ref, int val, CallbackType cbType) { Com *snc = &_snList[_head++]; snc->_com = com; snc->_ref = ref; snc->_val = val; snc->_ptr = NULL; snc->_cbType = cbType; - if (com == SNCLEAR) { + if (com == kSnClear) { _tail = _head; killText(); _timerExpiry = 0; } } -void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { +void Snail::insCom(SnCom com, int ref, int val, void *ptr) { Com *snc; if (_busy) { @@ -465,7 +461,7 @@ void Snail::insCom(SNCOM com, int ref, int val, void *ptr) { snc->_ref = ref; snc->_val = val; snc->_ptr = ptr; - if (com == SNCLEAR) { + if (com == kSnClear) { _tail = _head; killText(); _timerExpiry = 0; @@ -596,7 +592,6 @@ void CGEEngine::snSend(Sprite *spr, int val) { } } - void CGEEngine::snSwap(Sprite *spr, int xref) { debugC(1, kCGEDebugEngine, "CGEEngine::snSwap(spr, %d)", xref); @@ -828,7 +823,6 @@ void CGEEngine::snKeep(Sprite *spr, int stp) { selectPocket(-1); } - void CGEEngine::snGive(Sprite *spr, int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::snGive(spr, %d)", stp); @@ -845,7 +839,6 @@ void CGEEngine::snGive(Sprite *spr, int stp) { selectPocket(-1); } - void CGEEngine::snBackPt(Sprite *spr, int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::snBackPt(spr, %d)", stp); @@ -956,8 +949,8 @@ void Snail::runCom() { static int count = 1; if (!_busy) { _busy = true; - uint8 tmphea = _head; - while (_tail != tmphea) { + uint8 tmpHead = _head; + while (_tail != tmpHead) { Com *snc = &_snList[_tail]; if (!_turbo) { // only for the slower one @@ -975,35 +968,35 @@ void Snail::runCom() { _textDelay = false; } } - if (_talk && snc->_com != SNPAUSE) + if (_talk && snc->_com != kSnPause) break; } Sprite *spr = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr)); switch (snc->_com) { - case SNLABEL : + case kSnLabel: break; - case SNPAUSE : - _timerExpiry = g_system->getMillis() + snc->_val * SNAIL_FRAME_DELAY; + case kSnPause : + _timerExpiry = g_system->getMillis() + snc->_val * kSnailFrameDelay; if (_talk) _textDelay = true; break; - case SNWAIT : + case kSnWait: if (spr) { if (spr->seqTest(snc->_val) && (snc->_val >= 0 || spr != _hero || _hero->_tracePtr < 0)) { - _timerExpiry = g_system->getMillis() + spr->_time * SNAIL_FRAME_DELAY; + _timerExpiry = g_system->getMillis() + spr->_time * kSnailFrameDelay; } else goto xit; } break; - case SNLEVEL : + case kSnLevel: _vm->snLevel(spr, snc->_val); break; - case SNHIDE : + case kSnHide: _vm->snHide(spr, snc->_val); break; - case SNSAY : + case kSnSay: if (spr && _talkEnable) { if (spr == _hero && spr->seqTest(-1)) spr->step(kSeqHTalk); @@ -1011,148 +1004,148 @@ void Snail::runCom() { _sys->_funDel = kHeroFun0; } break; - case SNINF : + case kSnInf: if (_talkEnable) { _vm->inf(_text->getText(snc->_val)); _sys->_funDel = kHeroFun0; } break; - case SNTIME : + case kSnTime: if (spr && _talkEnable) { if (spr == _hero && spr->seqTest(-1)) spr->step(kSeqHTalk); sayTime(spr); } break; - case SNCAVE : + case kSnCave: _vm->switchCave(snc->_val); break; - case SNKILL : + case kSnKill: _vm->snKill(spr); break; - case SNSEQ : + case kSnSeq: _vm->snSeq(spr, snc->_val); break; - case SNRSEQ : + case kSnRSeq: _vm->snRSeq(spr, snc->_val); break; - case SNSEND : + case kSnSend: _vm->snSend(spr, snc->_val); break; - case SNSWAP : + case kSnSwap: _vm->snSwap(spr, snc->_val); break; - case SNCOVER : + case kSnCover: _vm->snCover(spr, snc->_val); break; - case SNUNCOVER : + case kSnUncover: _vm->snUncover(spr, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); break; - case SNKEEP : + case kSnKeep: _vm->snKeep(spr, snc->_val); break; - case SNGIVE : + case kSnGive: _vm->snGive(spr, snc->_val); break; - case SNGAME : + case kSnGame: _vm->snGame(spr, snc->_val); break; - case SNSETX0 : + case kSnSetX0: _vm->snSetX0(snc->_ref, snc->_val); break; - case SNSETY0 : + case kSnSetY0: _vm->snSetY0(snc->_ref, snc->_val); break; - case SNSETXY : + case kSnSetXY: _vm->snSetXY(spr, snc->_val); break; - case SNRELX : + case kSnRelX: _vm->snRelX(spr, snc->_val); break; - case SNRELY : + case kSnRelY: _vm->snRelY(spr, snc->_val); break; - case SNRELZ : + case kSnRelZ: _vm->snRelZ(spr, snc->_val); break; - case SNSETX : + case kSnSetX: _vm->snSetX(spr, snc->_val); break; - case SNSETY : + case kSnSetY: _vm->snSetY(spr, snc->_val); break; - case SNSETZ : + case kSnSetZ: _vm->snSetZ(spr, snc->_val); break; - case SNSLAVE : + case kSnSlave: _vm->snSlave(spr, snc->_val); break; - case SNTRANS : + case kSnTrans: _vm->snTrans(spr, snc->_val); break; - case SNPORT : + case kSnPort: _vm->snPort(spr, snc->_val); break; - case SNNEXT : - case SNIF : - case SNTALK : + case kSnNext: + case kSnIf: + case kSnTalk: break; - case SNMOUSE : + case kSnMouse: _vm->snMouse(snc->_val != 0); break; - case SNNNEXT : + case kSnNNext: _vm->snNNext(spr, snc->_val); break; - case SNTNEXT : + case kSnTNext: _vm->snTNext(spr, snc->_val); break; - case SNRNNEXT : + case kSnRNNext: _vm->snRNNext(spr, snc->_val); break; - case SNRTNEXT : + case kSnRTNext: _vm->snRTNext(spr, snc->_val); break; - case SNRMNEAR : + case kSnRMNear: _vm->snRmNear(spr); break; - case SNRMTAKE : + case kSnRmTake: _vm->snRmTake(spr); break; - case SNFLAG : + case kSnFlag: _vm->snFlag(snc->_ref & 3, snc->_val != 0); break; - case SNSETREF : + case kSnSetRef: _vm->snSetRef(spr, snc->_val); break; - case SNBACKPT : + case kSnBackPt: _vm->snBackPt(spr, snc->_val); break; - case SNFLASH : + case kSnFlash: _vm->snFlash(snc->_val != 0); break; - case SNLIGHT : + case kSnLight: _vm->snLight(snc->_val != 0); break; - case SNSETHB : + case kSnSetHBarrier: _vm->snBarrier(snc->_ref, snc->_val, true); break; - case SNSETVB : + case kSnSetVBarrier: _vm->snBarrier(snc->_ref, snc->_val, false); break; - case SNWALK : + case kSnWalk: _vm->snWalk(spr, snc->_ref, snc->_val); break; - case SNREACH : + case kSnReach: _vm->snReach(spr, snc->_val); break; - case SNSOUND : + case kSnSound: _vm->snSound(spr, snc->_val, count); count = 1; break; - case SNCOUNT : + case kSnCount: count = snc->_val; break; - case SNEXEC : + case kSnExec: switch (snc->_cbType) { case kQGame: _vm->qGame(); @@ -1176,13 +1169,13 @@ void Snail::runCom() { error("Unknown Callback Type in SNEXEC"); } break; - case SNSTEP : + case kSnStep: spr->step(); break; - case SNZTRIM : + case kSnZTrim: _vm->snZTrim(spr); break; - case SNGHOST : + case kSnGhost: _vm->snGhost((Bitmap *) snc->_ptr); break; default : diff --git a/engines/cge/snail.h b/engines/cge/snail.h index b8b4dc68ff..ad63f55f36 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -33,40 +33,34 @@ namespace CGE { -#define SNINSERT(c, r, v, p) _snail->insCom(c, r, v, p) -#define SNPOST(c, r, v, p) _snail->addCom(c, r, v, p) -#define SNPOST2(c, r, v, p) _snail->addCom2(c, r, v, p) -#define SNPOST_(c, r, v, p) _snail_->addCom(c, r, v, p) -#define SNPOST2_(c, r, v, p) _snail_->addCom2(c, r, v, p) - -#define SNAIL_FRAME_RATE 80 -#define SNAIL_FRAME_DELAY (1000 / SNAIL_FRAME_RATE) +#define kSnailFrameRate 80 +#define kSnailFrameDelay (1000 / kSnailFrameRate) +#define kDressed 3 struct Bar { uint8 _horz; uint8 _vert; }; - -enum SNCOM { - SNLABEL, SNPAUSE, SNWAIT, SNLEVEL, SNHIDE, - SNSAY, SNINF, SNTIME, SNCAVE, SNKILL, - SNRSEQ, SNSEQ, SNSEND, SNSWAP, SNKEEP, - SNGIVE, SNIF, SNGAME, SNSETX0, SNSETY0, - SNSLAVE, SNSETXY, SNRELX, SNRELY, SNRELZ, - SNSETX, SNSETY, SNSETZ, SNTRANS, SNPORT, - SNNEXT, SNNNEXT, SNTNEXT, SNRNNEXT, SNRTNEXT, - SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, SNBACKPT, - SNFLASH, SNLIGHT, SNSETHB, SNSETVB, SNWALK, - SNREACH, SNCOVER, SNUNCOVER, SNCLEAR, SNTALK, - SNMOUSE, SNSOUND, SNCOUNT, SNEXEC, SNSTEP, - SNZTRIM, SNGHOST +enum SnCom { + kSnLabel, kSnPause, kSnWait, kSnLevel, kSnHide, + kSnSay, kSnInf, kSnTime, kSnCave, kSnKill, + kSnRSeq, kSnSeq, kSnSend, kSnSwap, kSnKeep, + kSnGive, kSnIf, kSnGame, kSnSetX0, kSnSetY0, + kSnSlave, kSnSetXY, kSnRelX, kSnRelY, kSnRelZ, + kSnSetX, kSnSetY, kSnSetZ, kSnTrans, kSnPort, + kSnNext, kSnNNext, kSnTNext, kSnRNNext, kSnRTNext, + kSnRMNear, kSnRmTake, kSnFlag, kSnSetRef, kSnBackPt, + kSnFlash, kSnLight, kSnSetHBarrier, kSnSetVBarrier, kSnWalk, + kSnReach, kSnCover, kSnUncover, kSnClear, kSnTalk, + kSnMouse, kSnSound, kSnCount, kSnExec, kSnStep, + kSnZTrim, kSnGhost }; class Snail { public: struct Com { - SNCOM _com; + SnCom _com; int _ref; int _val; void *_ptr; @@ -83,17 +77,15 @@ public: Snail(CGEEngine *vm, bool turbo); ~Snail(); void runCom(); - void addCom(SNCOM com, int ref, int val, void *ptr); - void addCom2(SNCOM com, int ref, int val, CallbackType cbType); - void insCom(SNCOM com, int ref, int val, void *ptr); + void addCom(SnCom com, int ref, int val, void *ptr); + void addCom2(SnCom com, int ref, int val, CallbackType cbType); + void insCom(SnCom com, int ref, int val, void *ptr); bool idle(); private: CGEEngine *_vm; }; -extern bool _dark; -extern int _lev; extern Bar _barriers[]; extern struct Hxy { int _x; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index dd75ea3681..edf7931278 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -234,7 +234,6 @@ void CGEEngine::inf(const char *txt) { } } - void sayTime(Sprite *spr) { /* static char t[] = "00:00"; @@ -249,7 +248,7 @@ void sayTime(Sprite *spr) { void killText() { if (_talk) { - SNPOST_(SNKILL, -1, 0, _talk); + _snail_->addCom(kSnKill, -1, 0, _talk); _talk = NULL; } } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 24c83f12ee..94a4963a5e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -442,7 +442,7 @@ bool Sprite::works(Sprite *spr) { if (c != NULL) { c += spr->_takePtr; if (c->_ref == _ref) - if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _vm->_now)) + if (c->_com != kSnLabel || (c->_val == 0 || c->_val == _vm->_now)) return true; } } @@ -573,7 +573,7 @@ Sprite *Sprite::expand() { error("No core [%s]", fname); else { Snail::Com *c = &nea[neacnt++]; - if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); @@ -589,7 +589,7 @@ Sprite *Sprite::expand() { error("No core [%s]", fname); else { Snail::Com *c = &tak[takcnt++]; - if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index af3d5ff4f5..2c22625ae3 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -138,7 +138,7 @@ void Vmenu::touch(uint16 mask, int x, int y) { if (ok && (mask & L_UP)) { _items = 0; - SNPOST_(SNKILL, -1, 0, this); + _snail_->addCom(kSnKill, -1, 0, this); _recent = n; assert(_menu[n].Proc); CALL_MEMBER_FN(*_vm, _menu[n].Proc)(); diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 63f3fadd1c..9074a8f061 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -44,7 +44,7 @@ Dat::Dat(): #ifdef VOL_UPD _file(DAT_NAME, UPD, CRP) #else - _file(DAT_NAME, REA, CRP) + _file(DAT_NAME, kModeRead, CRP) #endif { debugC(1, kCGEDebugFile, "Dat::Dat()"); @@ -59,7 +59,7 @@ void VFile::init() { #ifdef VOL_UPD _cat = new BtFile(CAT_NAME, UPD, CRP); #else - _cat = new BtFile(CAT_NAME, REA, CRP); + _cat = new BtFile(CAT_NAME, kModeRead, CRP); #endif _recent = NULL; @@ -70,11 +70,11 @@ void VFile::deinit() { delete _cat; } -VFile::VFile(const char *name, IOMODE mode) +VFile::VFile(const char *name, IOMode mode) : IoBuf(mode) { debugC(3, kCGEDebugFile, "VFile::VFile(%s, %d)", name, mode); - if (mode == REA) { + if (mode == kModeRead) { if (_dat->_file._error || _cat->_error) error("Bad volume data"); BtKeypack *kp = _cat->find(name); diff --git a/engines/cge/vol.h b/engines/cge/vol.h index bbf3237721..e975cc34e6 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -74,7 +74,7 @@ private: void writeBuf() { } void make(const char *fspec); public: - VFile(const char *name, IOMODE mode = REA); + VFile(const char *name, IOMode mode = kModeRead); ~VFile(); static void init(); diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index 2568a51df0..f9c542ec92 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -136,7 +136,7 @@ void WALK::tick() { else { signed char x; // dummy var _here.split(x, _z); // take current Z position - SNPOST_(SNZTRIM, -1, 0, this); // update Hero's pos in show queue + _snail_->addCom(kSnZTrim, -1, 0, this); // update Hero's pos in show queue } } @@ -233,10 +233,10 @@ void WALK::reach(Sprite *spr, int mode) { } } // note: insert SNAIL commands in reverse order - SNINSERT(SNPAUSE, -1, 64, NULL); - SNINSERT(SNSEQ, -1, kTSeq + mode, this); + _snail->insCom(kSnPause, -1, 64, NULL); + _snail->insCom(kSnSeq, -1, kTSeq + mode, this); if (spr) { - SNINSERT(SNWAIT, -1, -1, _hero); /////--------$$$$$$$ + _snail->insCom(kSnWait, -1, -1, _hero); /////--------$$$$$$$ //SNINSERT(SNWALK, -1, -1, spr); } // sequence is not finished, -- cgit v1.2.3 From 82adc025ea451f1fce2c0e0eed03d6e48a51e152 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Jul 2011 23:42:03 +0200 Subject: CGE: Remove DrvInfo, rename some enums --- engines/cge/cge_main.cpp | 25 ++++++++++++++----------- engines/cge/cge_main.h | 3 +++ engines/cge/general.cpp | 2 -- engines/cge/gettext.cpp | 2 +- engines/cge/mixer.cpp | 13 ++++++++++--- engines/cge/snail.cpp | 10 ++++------ engines/cge/snddrv.h | 36 ------------------------------------ engines/cge/sound.h | 4 ---- engines/cge/talk.cpp | 13 +++++-------- engines/cge/talk.h | 17 ++++------------- engines/cge/text.cpp | 4 ++-- engines/cge/vga13h.cpp | 5 ----- engines/cge/vga13h.h | 10 +++++----- engines/cge/vmenu.cpp | 2 +- engines/cge/vol.h | 2 -- engines/cge/walk.cpp | 42 ++++++++++++------------------------------ engines/cge/walk.h | 6 +++--- 17 files changed, 64 insertions(+), 132 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index b6f342edff..98de57597d 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -317,8 +317,11 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt _pocref[i] = (s) ? s->_ref : -1; } - _volume[0] = _sndDrvInfo.Vol2._d; - _volume[1] = _sndDrvInfo.Vol2._m; + warning("STUB: CGEEngine::syncGame Digital and Midi volume"); +// _volume[0] = _sndDrvInfo.Vol2._d; +// _volume[1] = _sndDrvInfo.Vol2._m; + _volume[0] = 0; + _volume[1] = 0; } // Synchronise header data @@ -336,8 +339,9 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt _music = false; if (Startup::_soundOk == 1 && Startup::_mode == 0) { - _sndDrvInfo.Vol2._d = _volume[0]; - _sndDrvInfo.Vol2._m = _volume[1]; +// _sndDrvInfo.Vol2._d = _volume[0]; +// _sndDrvInfo.Vol2._m = _volume[1]; + warning("STUB: CGEEngine::syncGame Digital and Midi volume"); sndSetVolume(); } @@ -587,12 +591,11 @@ void CGEEngine::caveUp() { } spr = n; } - if (_sndDrvInfo._dDev) { - _sound.stop(); - _fx.clear(); - _fx.preload(0); - _fx.preload(BakRef); - } + + _sound.stop(); + _fx.clear(); + _fx.preload(0); + _fx.preload(BakRef); if (_hero) { _hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); @@ -1265,7 +1268,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int break; } case 2 : { // WALK - WALK *w = new WALK(this, NULL); + Walk *w = new Walk(this, NULL); if (w && ref == 1) { w->gotoxy(col, row); if (_hero) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 2a467761b3..8586d84d50 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -72,6 +72,9 @@ namespace CGE { #define kGetNamePrompt 50 #define kGetNameTitle 51 #define kTSeq 96 +//Useless? +//#define kBadSnd 97 +//#define kBadMidi 98 #define kNoMusic 98 #define kBadSVG 99 #define kSeqHTalk (kTSeq + 4) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 909c517c32..46df263b93 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -93,8 +93,6 @@ Dac _stdPal[] = {// R G B { 255, 255, 255}, // 255 }; -DrvInfo _sndDrvInfo; - void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) { warning("STUB: _fqsort"); } diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 7a8cff3cb2..fa30b3a9d1 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -39,7 +39,7 @@ GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) _cntr(kGetTextBlink), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { int i = 2 * kTextHMargin + _font->width(info); _ptr = this; - _mode = RECT; + _mode = kTBRect; _ts = new BMP_PTR[2]; _ts[0] = box((i + 3) & ~3, 2 * kTextVMargin + 2 * kFontHigh + kTextLineSpace); diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index aeaaa86593..36f7a8e2f7 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -86,12 +86,14 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ _vga->_showQ->insert(_led[i]); //--- reset balance - i = (_sndDrvInfo.Vol4._ml + _sndDrvInfo.Vol4._mr) / 2; + warning("STUB: MIXER::MIXER() reset balance of digital and midi volumes"); +/* i = (_sndDrvInfo.Vol4._ml + _sndDrvInfo.Vol4._mr) / 2; _sndDrvInfo.Vol4._ml = i; _sndDrvInfo.Vol4._mr = i; i = (_sndDrvInfo.Vol4._dl + _sndDrvInfo.Vol4._dr) / 2; _sndDrvInfo.Vol4._dl = i; _sndDrvInfo.Vol4._dr = i; +*/ update(); _time = kMixDelay; } @@ -104,8 +106,10 @@ Mixer::~Mixer() { #pragma argsused void Mixer::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); + if (mask & L_UP) { - uint8 *vol = (&_sndDrvInfo.Vol2._d) + (x < _w / 2); + warning("STUB: Mixer::touch(): Digital Volume"); +/* uint8 *vol = (&_sndDrvInfo.Vol2._d) + (x < _w / 2); if (y < kMixButtonHigh) { if (*vol < 0xFF) *vol += 0x11; @@ -114,6 +118,7 @@ void Mixer::touch(uint16 mask, int x, int y) { *vol -= 0x11; } update(); +*/ } } @@ -139,9 +144,11 @@ void Mixer::tick() { void Mixer::update() { + warning("STUB: Mixer::Update"); +/* _led[0]->step(_sndDrvInfo.Vol4._ml); _led[1]->step(_sndDrvInfo.Vol4._dl); - +*/ _snail_->addCom2(kSnExec, -1, 0, kSndSetVolume); } diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index d2ed77d755..697e70bf8e 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -797,12 +797,10 @@ void CGEEngine::snKill(Sprite *spr) { void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { debugC(1, kCGEDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt); - if (_sndDrvInfo._dDev) { - if (wav == -1) - _sound.stop(); - else - _sound.play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt); - } + if (wav == -1) + _sound.stop(); + else + _sound.play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt); } diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 0ea776b784..07c4ccd0dd 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -42,40 +42,6 @@ namespace CGE { // ****************************************************** // * Constants * // ****************************************************** -// available devices - -enum DEV_TYPE { DEV_AUTO = -1, // auto-detect mode - DEV_QUIET, // disable sound - DEV_SB, // sb/pro/16/awe32 - DEV_GUS, // gus/max - DEV_GM // general midi - }; - -#define SERR_OK 0 // no error -#define SERR_INITFAIL 1 // couldn't initialize -#define SERR_BADDDEV 128 // bad device - -// driver info -struct DrvInfo { - DEV_TYPE _dDev; // digi device - DEV_TYPE _mDev; // midi device - uint16 _dBase; // digi base port - uint16 _dDma; // digi dma no - uint16 _dIrq; // digi irq no - uint16 _mBase; // midi base port - union { - struct { - uint16 _dr : 4; - uint16 _dl : 4; - uint16 _mr : 4; - uint16 _ml : 4; - } Vol4; - struct { - uint8 _d; // digi volume - uint8 _m; // midi volume - } Vol2; - }; -}; // sample info struct SmpInfo { @@ -88,8 +54,6 @@ struct SmpInfo { // ****************************************************** // * Data * // ****************************************************** -// driver info -extern DrvInfo _sndDrvInfo; // midi player flag (1 means we are playing) extern uint16 _midiPlayFlag; diff --git a/engines/cge/sound.h b/engines/cge/sound.h index fda8d4f128..5e1af71307 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -33,10 +33,6 @@ namespace CGE { -#define BAD_SND_TEXT 97 -#define BAD_MIDI_TEXT 98 - - class Sound { public: SmpInfo _smpinf; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index a164a69f99..4e367e3318 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -87,7 +87,7 @@ void Font::save() { */ -Talk::Talk(CGEEngine *vm, const char *tx, TBOX_STYLE mode) +Talk::Talk(CGEEngine *vm, const char *tx, TextBoxStyle mode) : Sprite(vm, NULL), _mode(mode), _vm(vm) { _ts = NULL; @@ -97,7 +97,7 @@ Talk::Talk(CGEEngine *vm, const char *tx, TBOX_STYLE mode) Talk::Talk(CGEEngine *vm) - : Sprite(vm, NULL), _mode(PURE), _vm(vm) { + : Sprite(vm, NULL), _mode(kTBPure), _vm(vm) { _ts = NULL; _flags._syst = true; } @@ -179,20 +179,17 @@ void Talk::update(const char *tx) { setShapeList(_ts); } - - - Bitmap *Talk::box(uint16 w, uint16 h) { uint8 *b, * p, * q; - uint16 n, r = (_mode == ROUND) ? kTextRoundCorner : 0; + uint16 r = (_mode == kTBRound) ? kTextRoundCorner : 0; if (w < 8) w = 8; if (h < 8) h = 8; - n = w * h; + uint16 n = w * h; b = (uint8 *) malloc(sizeof(uint8) * n); - if (! b) + if (!b) error("No core"); memset(b, kTextColBG, n); diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 5eab6672e3..d9c29261f6 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -46,18 +46,14 @@ namespace CGE { #define kFontHigh 8 #define kFontExt ".CFT" - - - #define kPathMax 128 +enum TextBoxStyle { kTBPure, kTBRect, kTBRound }; + class Font { char _path[kPathMax]; void load(); public: -// static uint8 _wid[256]; -// static uint16 _pos[256]; -// static uint8 _map[256*8]; uint8 *_wid; uint16 *_pos; uint8 *_map; @@ -67,17 +63,13 @@ public: void save(); }; - -enum TBOX_STYLE { PURE, RECT, ROUND }; - - class Talk : public Sprite { protected: - TBOX_STYLE _mode; + TextBoxStyle _mode; BMP_PTR *_ts; Bitmap *box(uint16 w, uint16 h); public: - Talk(CGEEngine *vm, const char *tx, TBOX_STYLE mode); + Talk(CGEEngine *vm, const char *tx, TextBoxStyle mode); Talk(CGEEngine *vm); //~TALK(); @@ -92,7 +84,6 @@ private: CGEEngine *_vm; }; - class InfoLine : public Talk { const char *_oldTxt; public: diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index edf7931278..f688546810 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -178,7 +178,7 @@ char *Text::getText(int ref) { void Text::say(const char *txt, Sprite *spr) { killText(); - _talk = new Talk(_vm, txt, ROUND); + _talk = new Talk(_vm, txt, kTBRound); if (_talk) { bool east = spr->_flags._east; int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); @@ -221,7 +221,7 @@ void CGEEngine::inf(const char *txt) { debugC(1, kCGEDebugEngine, "CGEEngine::inf(%s)", txt); killText(); - _talk = new Talk(this, txt, RECT); + _talk = new Talk(this, txt, kTBRect); if (_talk) { _talk->_flags._kill = true; _talk->_flags._bDel = true; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 94a4963a5e..f5a3fdd22f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -37,11 +37,6 @@ namespace CGE { -#define FADE_STEP 2 -#define TMR_DIV ((0x8000/TMR_RATE)*2) -#define NREP 9 -#define FREP 24 - static VgaRegBlk VideoMode[] = { { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 4884ae104e..f192d962ff 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -37,6 +37,11 @@ namespace CGE { +#define FADE_STEP 2 +#define TMR_DIV ((0x8000/TMR_RATE)*2) +#define NREP 9 +#define FREP 24 + #define TMR_RATE1 16 #define TMR_RATE2 4 #define TMR_RATE (TMR_RATE1 * TMR_RATE2) @@ -60,11 +65,6 @@ namespace CGE { #define SPR_EXT ".SPR" -#define IsFile(s) (access(s, 0) == 0) -#define IsWrit(s) (access(s, 2) == 0) - - - struct Rgb { uint16 _r : 2; uint16 _R : 6; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 2c22625ae3..f846b3d061 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -90,7 +90,7 @@ int Vmenu::_recent = -1; Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) - : Talk(vm, VMGather(list), RECT), _menu(list), _bar(NULL), _vm(vm) { + : Talk(vm, VMGather(list), kTBRect), _menu(list), _bar(NULL), _vm(vm) { Choice *cp; _addr = this; diff --git a/engines/cge/vol.h b/engines/cge/vol.h index e975cc34e6..f64e7eec54 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -36,9 +36,7 @@ namespace CGE { #define CAT_NAME "VOL.CAT" #define DAT_NAME "VOL.DAT" -#ifndef CRP #define CRP XCrypt -#endif #define XMASK 0xA5 diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index f9c542ec92..9bcc2be23d 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -25,32 +25,14 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "common/scummsys.h" #include "cge/walk.h" -#include "cge/cge.h" -#include "cge/sound.h" -#include "cge/startup.h" -#include "cge/config.h" -#include "cge/vga13h.h" -#include "cge/snail.h" -#include "cge/text.h" -#include "cge/game.h" -#include "cge/events.h" -#include "cge/cfile.h" -#include "cge/vol.h" -#include "cge/talk.h" -#include "cge/vmenu.h" -#include "cge/gettext.h" -#include "cge/mixer.h" #include "cge/cge_main.h" -#include "cge/cge.h" -#include "common/str.h" namespace CGE { extern Bar _barriers[]; -WALK *_hero; +Walk *_hero; uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; CGEEngine *Cluster::_vm; @@ -89,12 +71,12 @@ Cluster XZ(Couple xy) { return XZ(x, y); } -WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) +Walk::Walk(CGEEngine *vm, BMP_PTR *shpl) : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _level(0), _vm(vm) { } -void WALK::tick() { +void Walk::tick() { if (_flags._hide) return; @@ -141,7 +123,7 @@ void WALK::tick() { } -int WALK::distance(Sprite *spr) { +int Walk::distance(Sprite *spr) { int dx, dz; dx = spr->_x - (_x + _w - kWalkSide); if (dx < 0) @@ -163,7 +145,7 @@ int WALK::distance(Sprite *spr) { } -void WALK::turn(DIR d) { +void Walk::turn(DIR d) { DIR dir = (Dir == NO_DIR) ? SS : Dir; if (d != Dir) { step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); @@ -172,7 +154,7 @@ void WALK::turn(DIR d) { } -void WALK::park() { +void Walk::park() { if (_time == 0) ++_time; @@ -184,7 +166,7 @@ void WALK::park() { } -void WALK::findWay(Cluster c) { +void Walk::findWay(Cluster c) { if (c != _here) { for (_findLevel = 1; _findLevel <= MAX_FIND_LEVEL; _findLevel++) { signed char x, z; @@ -203,7 +185,7 @@ void WALK::findWay(Cluster c) { } -void WALK::findWay(Sprite *spr) { +void Walk::findWay(Sprite *spr) { if (spr && spr != this) { int x = spr->_x; int z = spr->_z; @@ -218,12 +200,12 @@ void WALK::findWay(Sprite *spr) { } -bool WALK::lower(Sprite *spr) { +bool Walk::lower(Sprite *spr) { return (spr->_y > _y + (_h * 3) / 5); } -void WALK::reach(Sprite *spr, int mode) { +void Walk::reach(Sprite *spr, int mode) { if (spr) { _hero->findWay(spr); if (mode < 0) { @@ -243,11 +225,11 @@ void WALK::reach(Sprite *spr, int mode) { // now it is just at sprite appear (disappear) point } -void WALK::noWay() { +void Walk::noWay() { _vm->trouble(kSeqNoWay, kNoWay); } -bool WALK::find1Way(Cluster c) { +bool Walk::find1Way(Cluster c) { Cluster start = c; const Cluster tab[4] = { Cluster(-1, 0), Cluster(1, 0), Cluster(0, -1), Cluster(0, 1)}; const int tabLen = 4; diff --git a/engines/cge/walk.h b/engines/cge/walk.h index 52f372c363..15ea9ee0ce 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -97,7 +97,7 @@ public: }; -class WALK : public Sprite { +class Walk : public Sprite { private: CGEEngine *_vm; public: @@ -109,7 +109,7 @@ public: Cluster _trace[MAX_FIND_LEVEL]; enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; - WALK(CGEEngine *vm, BMP_PTR *shpl); + Walk(CGEEngine *vm, BMP_PTR *shpl); void tick(); void findWay(Cluster c); void findWay(Sprite *spr); @@ -126,7 +126,7 @@ public: Cluster XZ(int x, int y); Cluster XZ(Couple xy); -extern WALK *_hero; +extern Walk *_hero; } // End of namespace CGE -- cgit v1.2.3 From cf619196484d7edc11dc6908ab81ebafcb65405f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2011 16:04:45 +0200 Subject: CGE: Replace 'no core' checks by asserts --- engines/cge/bitmap.cpp | 16 +++++-------- engines/cge/btfile.cpp | 3 +-- engines/cge/cfile.cpp | 6 ++--- engines/cge/cge_main.cpp | 11 ++++----- engines/cge/talk.cpp | 6 ++--- engines/cge/vga13h.cpp | 59 ++++++++++++++++++++---------------------------- 6 files changed, 41 insertions(+), 60 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 023e95a8f1..c02c66df8b 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -104,8 +104,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) uint16 psiz = _h * lsiz; // - last gape, but + plane trailer uint8 *v = new uint8[4 * psiz + _h * sizeof(*_b)];// the same for 4 planes // + room for wash table - if (v == NULL) - error("No core"); + assert(v != NULL); *(uint16 *) v = kBmpCPY | dsiz; // data chunk hader memset(v + 2, fill, dsiz); // data bytes @@ -143,8 +142,7 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); uint16 siz = vsiz + _h * sizeof(HideDesc); uint8 *v1 = (uint8 *) malloc(sizeof(uint8) * siz); - if (v1 == NULL) - error("No core"); + assert(v1 != NULL); memcpy(v1, v0, siz); _b = (HideDesc *)((_v = v1) + vsiz); } @@ -174,8 +172,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { uint16 vsiz = (uint8 *)bmp._b - (uint8 *)v0; uint16 siz = vsiz + _h * sizeof(HideDesc); uint8 *v1 = (uint8 *) malloc(sizeof(uint8) * siz); - if (v1 == NULL) - error("No core"); + assert(v1 != NULL); memcpy(v1, v0, siz); _b = (HideDesc *)((_v = v1) + vsiz); } @@ -252,9 +249,9 @@ BMP_PTR Bitmap::code() { if (! skip) { if (_v) *im = pix; - ++ im; + im++; } - ++ cnt; + cnt++; } bm += _w; @@ -291,8 +288,7 @@ BMP_PTR Bitmap::code() { uint16 sizV = (uint16)(im - 2 - _v); _v = new uint8[sizV + _h * sizeof(*_b)]; - if (!_v) - error("No core"); + assert(_v != NULL); _b = (HideDesc *)(_v + sizV); } diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index d5cdef1ba0..55511e6382 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -43,8 +43,7 @@ BtFile::BtFile(const char *name, IOMode mode, CRYPT *crpt) _buff[i]._pgNo = kBtValNone; _buff[i]._indx = -1; _buff[i]._updt = false; - if (_buff[i]._page == NULL) - error("No core"); + assert(_buff[i]._page != NULL); } } diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 1c5cf1d358..ac9f782d84 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -41,8 +41,7 @@ IoBuf::IoBuf(IOMode mode, CRYPT *crpt) debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crpt)", mode); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); - if (_buff == NULL) - error("No core for I/O"); + assert(_buff != NULL); } @@ -54,8 +53,7 @@ IoBuf::IoBuf(const char *name, IOMode mode, CRYPT *crpt) debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); - if (_buff == NULL) - error("No core for I/O [%s]", name); + assert(_buff != NULL); } IoBuf::~IoBuf() { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 98de57597d..352d2954dc 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -353,8 +353,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt S._prev = S._next = NULL; spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL) : new Sprite(this, NULL); - if (spr == NULL) - error("No core"); + assert(spr != NULL); *spr = S; _vga->_spareQ->append(spr); } @@ -1075,7 +1074,7 @@ void CGEEngine::sayDebug() { uint16 n = 0; Sprite *spr; for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { - ++ n; + n++; if (spr == _sprite) { dwtom(n, SP_N, 10, 2); dwtom(_sprite->_x, SP_X, 10, 3); @@ -1220,9 +1219,9 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int error("Bad SPR [%s]", line); while ((len = sprf.read((uint8 *)line)) != 0) { - ++ lcnt; + lcnt++; if (len && line[len - 1] == '\n') - line[-- len] = '\0'; + line[--len] = '\0'; if (len == 0 || *line == '.') continue; @@ -1238,7 +1237,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int error("Bad line %d [%s]", lcnt, fname); break; case 2 : // Phase - ++ shpcnt; + shpcnt++; break; case 3 : // East east = (atoi(strtok(NULL, " \t,;/")) != 0); diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 4e367e3318..4a2df79f24 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -36,8 +36,7 @@ Font::Font(const char *name) { _map = (uint8 *) malloc(sizeof(uint8) * kMapSize); _pos = (uint16 *) malloc(sizeof(uint16) * kPosSize); _wid = (uint8 *) malloc(sizeof(uint8) * kWidSize); - if ((_map == NULL) || (_pos == NULL) || (_wid == NULL)) - error("No core"); + assert((_map != NULL) && (_pos != NULL) && (_wid != NULL)); mergeExt(_path, name, kFontExt); load(); } @@ -189,8 +188,7 @@ Bitmap *Talk::box(uint16 w, uint16 h) { h = 8; uint16 n = w * h; b = (uint8 *) malloc(sizeof(uint8) * n); - if (!b) - error("No core"); + assert(b != NULL); memset(b, kTextColBG, n); if (_mode) { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f5a3fdd22f..d08f9bc8e8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -486,10 +486,9 @@ void Sprite::setName(char *n) { _ext->_name = NULL; } if (n) { - if ((_ext->_name = new char[strlen(n) + 1]) != NULL) - strcpy(_ext->_name, n); - else - error("No core [%s]", n); + _ext->_name = new char[strlen(n) + 1]; + assert(_ext->_name != NULL); + strcpy(_ext->_name, n); } } } @@ -499,8 +498,8 @@ Sprite *Sprite::expand() { if (!_ext) { bool enbl = _heart->_enable; _heart->_enable = false; - if ((_ext = new SprExt) == NULL) - error("No core"); + _ext = new SprExt; + assert(_ext != NULL); if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[kLineMax], fname[kPathMax]; @@ -522,9 +521,9 @@ Sprite *Sprite::expand() { error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; while ((len = sprf.read((uint8 *)line)) != 0) { - ++lcnt; + lcnt++; if (len && line[len - 1] == '\n') - line[-- len] = '\0'; + line[--len] = '\0'; if (len == 0 || *line == '.') continue; @@ -539,8 +538,7 @@ Sprite *Sprite::expand() { } case 2 : { // Seq seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); - if (seq == NULL) - error("No core [%s]", fname); + assert(seq != NULL); Seq *s = &seq[seqcnt++]; s->_now = atoi(strtok(NULL, " \t,;/")); if (s->_now > maxnow) @@ -564,32 +562,26 @@ Sprite *Sprite::expand() { case 3 : { // Near if (_nearPtr != NO_PTR) { nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - if (nea == NULL) - error("No core [%s]", fname); - else { - Snail::Com *c = &nea[neacnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) - error("Bad NEAR in %d [%s]", lcnt, fname); - c->_ref = atoi(strtok(NULL, " \t,;/")); - c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - } + assert(nea != NULL); + Snail::Com *c = &nea[neacnt++]; + if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + error("Bad NEAR in %d [%s]", lcnt, fname); + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; } } break; case 4 : { // Take if (_takePtr != NO_PTR) { tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - if (tak == NULL) - error("No core [%s]", fname); - else { - Snail::Com *c = &tak[takcnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) - error("Bad NEAR in %d [%s]", lcnt, fname); - c->_ref = atoi(strtok(NULL, " \t,;/")); - c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - } + assert(tak != NULL); + Snail::Com *c = &tak[takcnt++]; + if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + error("Bad NEAR in %d [%s]", lcnt, fname); + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; } break; } @@ -774,12 +766,11 @@ BMP_PTR Sprite::ghost() { register SprExt *e = _ext; if (e->_b1) { BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL); - if (bmp == NULL) - error("No core"); + assert(bmp != NULL); bmp->_w = e->_b1->_w; bmp->_h = e->_b1->_h; - if ((bmp->_b = new HideDesc[bmp->_h]) == NULL) - error("No Core"); + bmp->_b = new HideDesc[bmp->_h]; + assert(bmp->_b != NULL); bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); bmp->_map = (e->_y1 << 16) + e->_x1; return bmp; -- cgit v1.2.3 From 2e5a041046f69378da87fb8cab805fdee31a01e2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2011 17:50:58 +0200 Subject: CGE: Remove EMM and EMS classes --- engines/cge/cge_main.cpp | 2 +- engines/cge/ems.cpp | 190 ----------------------------------------------- engines/cge/general.cpp | 2 +- engines/cge/general.h | 34 --------- engines/cge/module.mk | 1 - engines/cge/sound.cpp | 9 +-- engines/cge/sound.h | 1 - engines/cge/startup.h | 2 - engines/cge/wav.h | 11 +-- 9 files changed, 8 insertions(+), 244 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 352d2954dc..60500b2b0e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -540,7 +540,7 @@ void CGEEngine::miniStep(int stp) { else { *_miniShp[0] = *_miniShpList[stp]; if (_fx._current) - &*(_fx._current->eAddr()); + &*(_fx._current->addr()); _miniCave->_flags._hide = false; } diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index 0364758a12..f545822a6b 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -28,194 +28,4 @@ #include "cge/general.h" namespace CGE { - - -enum EMM_FUN { - GET_STATUS = 0x40, GET_FRAME, GET_SIZE, OPEN_HANDLE, MAP_PAGE, - CLOSE_HANDLE, GET_VER, SAVE_CONTEXT, REST_CONTEXT, GET_PAGES = 0x4B, - GET_HANDLES, GET_INFO, CONTROL -}; - - -void *Emm::_frame = NULL; - - -Emm::Emm(long size): _han(-1), _top(0), _lim(0), _list(NULL) { - /* - if (Test()) - { - asm mov ah,GET_FRAME // get EMS frame segment - asm int EMS_INT // do it! - asm or ah,ah // see status - asm jnz xit // abort on error - Frame = (void _seg *) _BX; // save frame segment - - if (size == 0) - { - asm mov ah,GET_SIZE // get EMS memory size - asm int EMS_INT // do it! - asm or ah,ah // see status - asm jnz xit // abort on error - asm or bx,bx // test page count - asm jz xit // abort if no free pages - // number of available pages in BX is ready to use by OPEN - } - else _BX = (uint16) ((size + PAGE_MASK) >> 14); - asm mov ah,OPEN_HANDLE // open EMM handle - asm int EMS_INT // do it! - asm or ah,ah // see status - asm jnz xit // abort on error - Han = _DX; - Lim = _BX; - Lim <<= 14; - _DX = Han; - asm mov ah,SAVE_CONTEXT // save mapping context - asm int EMS_INT // do it! - } - xit: - */ - warning("STUB: EMM:EMM"); -} - - -Emm::~Emm() { - /* FIXME - Release(); - if (Han >= 0) - { - _DX = Han; - asm mov ah,REST_CONTEXT - asm int EMS_INT - asm mov ah,CLOSE_HANDLE - asm int EMS_INT - } - */ -} - - -bool Emm::test() { - /* - static char e[] = "EMMXXXX0"; - - asm mov ax,0x3D40 - asm mov dx,offset e - asm int 0x21 - asm jc fail - - asm push ax - asm mov bx,ax - asm mov ax,0x4407 - asm int 0x21 - - asm pop bx - asm push ax - asm mov ax,0x3E00 - asm int 0x21 - asm pop ax - - asm cmp al,0x00 - asm je fail - - success: - return TRUE; - fail: - return FALSE; - */ - warning("EMM::Test"); - return false; -} - - -Ems *Emm::alloc(uint16 siz) { - /* - long size = SIZ(siz), - top = Top; - - uint16 pgn = (uint16) (top >> 14), - cnt = (uint16) ((top + size + PAGE_MASK) >> 14) - pgn; - - if (cnt > 4) - { - top = (top + PAGE_MASK) & 0xFFFFC000L; - pgn++; - cnt--; - } - - if (size <= Lim - top) - { - EMS * e = new EMS, * f; - - if (e) - { - Top = (e->Ptr = top) + (e->Siz = siz); - e->Emm = this; - - if (List) - { - for (f = List; f->Nxt; f = f->Nxt); - return (f->Nxt = e); // existing list: link to the end - } - else - { - return (List = e); // empty list: link to the head - } - } - } - fail: return NULL; - */ - warning("STUB: Emm::alloc"); - return NULL; -} - - -void Emm::release() { - while (_list) { - Ems *e = _list; - _list = e->_next; - delete e; - } - _top = 0; -} - - -Ems::Ems() : _ptr(0), _size(0), _next(NULL) { -} - - -void *Ems::operator & () const { - /* - uint16 pgn = (uint16) (Ptr >> 14), - off = (uint16) Ptr & PAGE_MASK, - cnt = (uint16) ((Ptr + SIZ(Siz) + PAGE_MASK) >> 14) - pgn, - cmd = MAP_PAGE << 8; - - _DX = Emm->_han; // take EMM handle - asm dec cnt // prapare for deferred checking - asm or dx,dx // see if valid - asm jns more // negative handle = unavailable - - fail: return NULL; - - more: - asm mov ax,cmd // command + page frame index - asm mov bx,pgn // logical page number - asm int EMS_INT // do it! - asm or ah,ah // check error code - asm jnz fail // exit on error - asm inc cmd // advance page frame index - asm inc pgn // advance logical page number - asm cmp al,byte ptr cnt // all pages? - asm jb more - - return (void *) (EMM::Frame + (void *) off); - */ - warning("STUB: Ems::operator &"); - return NULL; -} - - -uint16 Ems::size() { - return _size; -} - } // End of namespace CGE diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 46df263b93..101c6cdd17 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -298,7 +298,7 @@ void sndMidiStop() { // FIXME: STUB: sndMIDIStop } -DataCk *loadWave(XFile *file, Emm *emm) { +DataCk *loadWave(XFile *file) { warning("STUB: LoadWave"); return NULL; } diff --git a/engines/cge/general.h b/engines/cge/general.h index 63d43c4403..e340c962bd 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -58,40 +58,6 @@ public: ~Engine_(); }; - -class Ems; - - -class Emm { - friend class Ems; - bool test(); - - long _top; - long _lim; - Ems *_list; - int _han; - static void *_frame; -public: - Emm(long size); - ~Emm(); - Ems *alloc(uint16 siz); - void release(); -}; - - -class Ems { - friend class Emm; - Emm *_emm; - long _ptr; - uint16 _size; - Ems *_next; -public: - Ems(); - void *operator & () const; - uint16 size(); -}; - - template void swap(T &A, T &B) { T a = A; diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 584ab5a1b6..c1112c7ec2 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -9,7 +9,6 @@ MODULE_OBJS := \ config.o \ console.o \ detection.o \ - ems.o \ events.o \ game.o \ general.o \ diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index a163949ddd..9bf0d59be0 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -65,7 +65,7 @@ void Sound::open() { void Sound::play(DataCk *wav, int pan, int cnt) { if (wav) { stop(); - _smpinf._saddr = (uint8 *) &*(wav->eAddr()); + _smpinf._saddr = (uint8 *) &*(wav->addr()); _smpinf._slen = (uint16)wav->size(); _smpinf._span = pan; _smpinf._sflag = cnt; @@ -79,7 +79,7 @@ void Sound::stop() { } -Fx::Fx(int size) : _emm(0L), _current(NULL) { +Fx::Fx(int size) : _current(NULL) { _cache = new Han[size]; for (_size = 0; _size < size; _size++) { _cache[_size]._ref = 0; @@ -103,7 +103,6 @@ void Fx::clear() { p->_wav = NULL; } } - _emm.release(); _current = NULL; } @@ -129,7 +128,7 @@ void Fx::preload(int ref0) { static char fname[] = "FX00000.WAV"; wtom(ref, fname + 2, 10, 5); INI_FILE file = INI_FILE(fname); - DataCk *wav = loadWave(&file, &_emm); + DataCk *wav = loadWave(&file); if (wav) { Han *p = &_cache[find(0)]; if (p >= cacheLim) @@ -146,7 +145,7 @@ DataCk *Fx::load(int idx, int ref) { wtom(ref, fname + 2, 10, 5); INI_FILE file = INI_FILE(fname); - DataCk *wav = loadWave(&file, &_emm); + DataCk *wav = loadWave(&file); if (wav) { Han *p = &_cache[idx]; p->_wav = wav; diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 5e1af71307..3ca4deaecc 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -46,7 +46,6 @@ public: class Fx { - Emm _emm; struct Han { int _ref; DataCk *_wav; diff --git a/engines/cge/startup.h b/engines/cge/startup.h index 5479945104..4b1f8662f3 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -69,8 +69,6 @@ public: }; -extern Emm _miniEmm; - const char *usrPath(const char *nam); } // End of namespace CGE diff --git a/engines/cge/wav.h b/engines/cge/wav.h index c3e67f5f95..739e102959 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -117,21 +117,14 @@ public: class DataCk : public CkHea { bool _e; - union { - uint8 *_buf; - Ems *_eBuf; - }; + uint8 *_buf; public: DataCk(CkHea &hea); - DataCk(CkHea &hea, Emm *emm); DataCk(int first, int last); ~DataCk(); inline uint8 *addr() { return _buf; } - inline Ems *eAddr() { - return _eBuf; - } }; @@ -141,7 +134,7 @@ extern ChunkId _fmt; extern ChunkId _data; -DataCk *loadWave(XFile *file, Emm *emm = NULL); +DataCk *loadWave(XFile *file); } // End of namespace CGE -- cgit v1.2.3 From dad302b640524224cb9381b3cfdcac7f430f0b21 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2011 19:09:12 +0200 Subject: CGE: Remove _core from Startup class --- engines/cge/cge.cpp | 4 +++- engines/cge/cge_main.cpp | 13 +++---------- engines/cge/startup.cpp | 1 - engines/cge/startup.h | 12 ------------ 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 6068dee46e..6542518a7e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -102,20 +102,22 @@ void CGEEngine::setup() { _eventManager = new EventManager(); _offUseCount = atoi(_text->getText(kOffUseCount)); _music = true; - _mini = new byte[MINI_EMM_SIZE]; for (int i = 0; i < kPocketNX; i++) _pocref[i] = -1; _volume[0] = 0; _volume[1] = 0; + if (_isDemo) { + _mini = new byte[16384]; _maxCaveArr[0] = CAVE_MAX; _maxCaveArr[1] = -1; _maxCaveArr[2] = -1; _maxCaveArr[3] = -1; _maxCaveArr[4] = -1; } else { + _mini = new byte[65536]; _maxCaveArr[0] = 1; _maxCaveArr[1] = 8; _maxCaveArr[2] = 16; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 60500b2b0e..3bffa1f732 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -335,9 +335,6 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt } } else { // Loading game - if (Startup::_core < CORE_HIG) - _music = false; - if (Startup::_soundOk == 1 && Startup::_mode == 0) { // _sndDrvInfo.Vol2._d = _volume[0]; // _sndDrvInfo.Vol2._m = _volume[1]; @@ -888,7 +885,7 @@ void System::tick() { if (_snail->idle()) { if (PAIN) _vm->heroCover(9); - else if (Startup::_core >= CORE_MID) { + else { // CHECKME: Before, was: if (Startup::_core >= CORE_MID) { int n = new_random(100); if (n > 96) _vm->heroCover(6 + (_hero->_x + _hero->_w / 2 < kScrWidth / 2)); @@ -928,12 +925,8 @@ void CGEEngine::switchMusic() { _snail->addCom2(kSnExec, -1, 0, kSelectSound); } } else { - if (Startup::_core < CORE_HIG) - _snail->addCom(kSnInf, -1, kNoMusic, NULL); - else { - _snail_->addCom(kSnSeq, 122, (_music = !_music), NULL); - keyClick(); - } + _snail_->addCom(kSnSeq, 122, (_music = !_music), NULL); + keyClick(); } if (_music) loadMidi(_now); diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index aca58a91ba..19ec2879c6 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -40,7 +40,6 @@ extern char _copr[]; // static Startup _startUp; int Startup::_mode = 0; -int Startup::_core; int Startup::_soundOk = 0; uint16 Startup::_summa; diff --git a/engines/cge/startup.h b/engines/cge/startup.h index 4b1f8662f3..d9416ff6a4 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -47,22 +47,10 @@ namespace CGE { #define CFG_EXT ".CFG" -#if defined(DEMO) -#define MINI_EMM_SIZE 0x00004000L -#define CORE_HIG 400 -#else -#define MINI_EMM_SIZE 0x00010000L -#define CORE_HIG 450 -#endif - -#define CORE_MID (CORE_HIG - 20) - - class Startup { static bool getParms(); public: static int _mode; - static int _core; static int _soundOk; static uint16 _summa; Startup(); -- cgit v1.2.3 From df7d771feb8ad9f532d6c8ba768d77cf491116b2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 28 Jul 2011 11:08:56 +0200 Subject: CGE: Remove summa variable, formerly used for the protection check --- engines/cge/cge_main.cpp | 14 +++----------- engines/cge/startup.cpp | 19 ------------------- engines/cge/startup.h | 1 - 3 files changed, 3 insertions(+), 31 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 3bffa1f732..d6dd82dbe0 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -684,9 +684,7 @@ void CGEEngine::switchCave(int cav) { _hero->park(); _hero->step(0); if (!_isDemo) - ///// protection: auto-destruction on! ---------------------- - _vga->_spareQ->_show = Startup::_summa * (cav <= CAVE_MAX); - /////-------------------------------------------------------- + _vga->_spareQ->_show = 0; } _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); @@ -1686,15 +1684,9 @@ bool CGEEngine::showTitle(const char *name) { strcpy(_usrFnam, progName(kSvgExt)); usr_ok = true; } else { - //----------------------------------------- #ifndef EVA -#ifdef CD - Startup::_summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF; -#else - // At this point the game originally read the boot sector to get - // the serial number for it's copy protection check -#endif - //----------------------------------------- + // At this point the game originally set the protection variables + // used by the copy protection check movie("X00"); // paylist _vga->copyPage(1, 2); _vga->copyPage(0, 1); diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 19ec2879c6..9a9d9ccfee 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -41,7 +41,6 @@ extern char _copr[]; int Startup::_mode = 0; int Startup::_soundOk = 0; -uint16 Startup::_summa; void quitNow(int ref) { @@ -50,8 +49,6 @@ void quitNow(int ref) { bool Startup::getParms() { - _summa = 0; - /* int i = _argc; while (i > 1) { @@ -98,22 +95,6 @@ bool Startup::getParms() { if (n >= 2) SoundOk = 2; } - if (_vm->_isDemo) - // protection disabled - Summa = 0; - else { -#ifdef EVA - union { dosdate_t d; uint32 n; } today; - _dos_getdate(&today.d); - id.disk += (id.disk < today.n); -#endif -#ifdef CD - Summa = 0; -#else - // disk signature checksum - Summa = ChkSum(Copr, sizeof(Ident)); -#endif - } if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; diff --git a/engines/cge/startup.h b/engines/cge/startup.h index d9416ff6a4..a9de89a5e2 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -52,7 +52,6 @@ class Startup { public: static int _mode; static int _soundOk; - static uint16 _summa; Startup(); }; -- cgit v1.2.3 From 7d5eb1ee639bf04e8f3b2ca280e631c3f67b1e9b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 28 Jul 2011 15:35:12 +0200 Subject: CGE: Janitorial: remove trailing spaces --- engines/cge/cge.cpp | 4 ++-- engines/cge/cge_main.cpp | 19 ++++--------------- engines/cge/events.cpp | 4 ++-- engines/cge/mixer.cpp | 2 +- engines/cge/startup.cpp | 6 +++--- engines/cge/startup.h | 2 +- engines/cge/vga13h.cpp | 16 ++++++++-------- engines/cge/vmenu.cpp | 2 +- 8 files changed, 22 insertions(+), 33 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 6542518a7e..3c3f14884d 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -152,10 +152,10 @@ CGEEngine::~CGEEngine() { delete _console; - // Delete engine objects + // Delete engine objects delete _vga; delete _sys; - //delete _sprite; Sprite is destroyed by the queue it's added to + //delete _sprite; Sprite is destroyed by the queue it's added to delete _miniCave; delete _shadow; delete _horzLine; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index d6dd82dbe0..8681a6314a 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -200,7 +200,7 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { if (slotNumber == 0) strncpy(_usrFnam, saveHeader.saveName.c_str(), 8); } - + // Get in the savegame syncGame(readStream, NULL, tiny); @@ -502,7 +502,7 @@ void CGEEngine::resetQSwitch() { void CGEEngine::quit() { debugC(1, kCGEDebugEngine, "CGEEngine::quit()"); - static Choice QuitMenu[] = { + static Choice QuitMenu[] = { { NULL, &CGEEngine::startCountDown }, { NULL, &CGEEngine::resetQSwitch }, { NULL, &CGEEngine::dummy } @@ -737,7 +737,7 @@ void System::touch(uint16 mask, int x, int y) { case Del: if (_keyboard->_key[ALT] && _keyboard->_key[CTRL]) _vm->AltCtrlDel(); - else + else _vm->killSprite(); break; case 'F': @@ -1465,7 +1465,7 @@ void CGEEngine::tick() { void CGEEngine::loadUser() { // set scene - if (Startup::_mode == 0) { + if (Startup::_mode == 0) { // user .SVG file found - load it from slot 0 loadGame(0, NULL); } else { @@ -1740,21 +1740,10 @@ bool CGEEngine::showTitle(const char *name) { return (Startup::_mode == 2 || usr_ok); } - -/* -void StkDump () { - CFILE f("!STACK.DMP", BFW); - f.Write((uint8 *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2); -} -*/ - - void CGEEngine::cge_main() { uint16 intStack[STACK_SIZ / 2]; _intStackPtr = intStack; - //Debug( memset((void *) (-K(2)), 0, K(1)); ) - //Debug( memset((void *) (-K(4)), 0, K(1)); ) memset(_barriers, 0xFF, sizeof(_barriers)); if (!_mouse->_exist) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index aa71782f77..dc6e65722d 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -147,14 +147,14 @@ void Keyboard::newKeyboard(Common::Event &event) { Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) { _hold = NULL; - _hx = 0; + _hx = 0; _hy = 0; _exist = true; _buttons = 0; _busy = NULL; _active = false; _flags._kill = false; - + const Seq ms[] = { { 0, 0, 0, 0, 1 }, { 1, 1, 0, 0, 1 } diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 36f7a8e2f7..decc516ae3 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -54,7 +54,7 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ // slaves uint i; - Seq ls[kMixMax]; + Seq ls[kMixMax]; for (i = 0; i < kMixMax; i++) { static char fn[] = "V00"; diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 9a9d9ccfee..5e1c8b8d64 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -56,7 +56,7 @@ bool Startup::getParms() { int n = takeEnum(PrmTab, strtok(_argv[--i], " =:(")); uint16 p = xtow(strtok(NULL, " h,)")); switch (n) { - case 0 : + case 0 : if (Mode != 2) Mode = 1; break; @@ -95,7 +95,7 @@ bool Startup::getParms() { if (n >= 2) SoundOk = 2; } - + if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; return true; @@ -109,7 +109,7 @@ Startup::Startup() { /* uint32 m = farcoreleft() >> 10; if (m < 0x7FFF) - Core = (int) m; + Core = (int) m; else Core = 0x7FFF; diff --git a/engines/cge/startup.h b/engines/cge/startup.h index a9de89a5e2..8a8305040c 100644 --- a/engines/cge/startup.h +++ b/engines/cge/startup.h @@ -49,10 +49,10 @@ namespace CGE { class Startup { static bool getParms(); + Startup(); public: static int _mode; static int _soundOk; - Startup(); }; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d08f9bc8e8..7e1d8f9962 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -228,7 +228,7 @@ extern "C" void TimerProc() { if (_heart->_xTimer) { if (*_heart->_xTimer) *_heart->_xTimer--; - else + else _heart->_xTimer = NULL; } @@ -324,9 +324,9 @@ void Engine_::newTimer(...) { } for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { - if (spr->Time) { + if (spr->Time) { if (!spr->_flags.Hide) { - if (--spr->Time == 0) + if (--spr->Time == 0) spr->tick(); } } @@ -949,7 +949,7 @@ void Vga::deinit() { } Vga::Vga(int mode) - : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), + : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), _msg(NULL), _nam(NULL), _setPal(false), _mono(0) { _oldColors = NULL; _newColors = NULL; @@ -1026,7 +1026,7 @@ void Vga::setStatAdr() { #pragma argsused void Vga::waitVR(bool on) { - // Since some of the game parts rely on using vertical sync as a delay mechanism, + // Since some of the game parts rely on using vertical sync as a delay mechanism, // we're introducing a short delay to simulate it g_system->delayMillis(10); } @@ -1244,7 +1244,7 @@ void Bitmap::xShow(int16 x, int16 y) { } // Move to next dest position - destP += 4; + destP += 4; } } } @@ -1294,7 +1294,7 @@ void Bitmap::show(int16 x, int16 y) { } // Move to next dest position - destP += 4; + destP += 4; } if (cmd == 2) @@ -1302,7 +1302,7 @@ void Bitmap::show(int16 x, int16 y) { } } /* - DEBUG code to display image immediately + DEBUG code to display image immediately // Temporary g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); byte palData[PAL_SIZ]; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index f846b3d061..934bd6299d 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -115,7 +115,7 @@ Vmenu::~Vmenu() { _addr = NULL; } -#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) +#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) void Vmenu::touch(uint16 mask, int x, int y) { if (_items) { -- cgit v1.2.3 From 316b73ee00091da6f0399bd7b446e859cd9d8c0d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2011 10:02:32 +0200 Subject: CGE: Remove Startup class, set _fx and _sound as dynamic --- engines/cge/cge.cpp | 10 ++- engines/cge/cge.h | 2 + engines/cge/cge_main.cpp | 54 +++++++-------- engines/cge/cge_main.h | 3 + engines/cge/module.mk | 1 - engines/cge/snail.cpp | 4 +- engines/cge/sound.cpp | 13 ++-- engines/cge/sound.h | 11 ++- engines/cge/startup.cpp | 176 ----------------------------------------------- engines/cge/startup.h | 63 ----------------- 10 files changed, 52 insertions(+), 285 deletions(-) delete mode 100644 engines/cge/startup.cpp delete mode 100644 engines/cge/startup.h diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 3c3f14884d..435a552bb4 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -36,7 +36,6 @@ #include "cge/text.h" #include "cge/vol.h" #include "cge/walk.h" -#include "cge/startup.h" namespace CGE { @@ -100,6 +99,9 @@ void CGEEngine::setup() { _mouse = new Mouse(this); _keyboard = new Keyboard(); _eventManager = new EventManager(); + _fx = new Fx(16); // must precede SOUND!! + _sound = new Sound(this); + _offUseCount = atoi(_text->getText(kOffUseCount)); _music = true; @@ -134,6 +136,9 @@ void CGEEngine::setup() { for (int i = 0; i < 4; i++) _flag[i] = false; + _mode = 0; + _soundOk = 0; + _startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; } @@ -167,6 +172,9 @@ CGEEngine::~CGEEngine() { delete _pocLight; delete _keyboard; delete _mouse; + delete _eventManager; + delete _fx; + delete _sound; for (int i = 0; i < kPocketNX; i++) delete _pocket[i]; delete _snail; diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 255dadfac6..6d2842c613 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -115,6 +115,8 @@ public: int _now; int _lev; char _usrFnam[15]; + int _mode; + int _soundOk; Common::RandomSource _randomSource; byte * _mini; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 8681a6314a..855834b489 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -35,7 +35,6 @@ #include "graphics/thumbnail.h" #include "cge/general.h" #include "cge/sound.h" -#include "cge/startup.h" #include "cge/config.h" #include "cge/vga13h.h" #include "cge/snail.h" @@ -51,6 +50,7 @@ #include "cge/cge_main.h" #include "cge/cge.h" #include "cge/walk.h" +#include "cge/sound.h" namespace CGE { @@ -81,6 +81,8 @@ InfoLine *_debugLine; Snail *_snail; Snail *_snail_; +Fx *_fx; +Sound *_sound; // 0.75 - 17II95 - full sound support // 0.76 - 18II95 - small MiniEMS in DEMO, // unhide CavLight in SNLEVEL @@ -335,7 +337,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt } } else { // Loading game - if (Startup::_soundOk == 1 && Startup::_mode == 0) { + if (_soundOk == 1 && _mode == 0) { // _sndDrvInfo.Vol2._d = _volume[0]; // _sndDrvInfo.Vol2._m = _volume[1]; warning("STUB: CGEEngine::syncGame Digital and Midi volume"); @@ -536,8 +538,8 @@ void CGEEngine::miniStep(int stp) { _miniCave->_flags._hide = true; else { *_miniShp[0] = *_miniShpList[stp]; - if (_fx._current) - &*(_fx._current->addr()); + if (_fx->_current) + &*(_fx->_current->addr()); _miniCave->_flags._hide = false; } @@ -588,10 +590,10 @@ void CGEEngine::caveUp() { spr = n; } - _sound.stop(); - _fx.clear(); - _fx.preload(0); - _fx.preload(BakRef); + _sound->stop(); + _fx->clear(); + _fx->preload(0); + _fx->preload(BakRef); if (_hero) { _hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); @@ -1465,16 +1467,14 @@ void CGEEngine::tick() { void CGEEngine::loadUser() { // set scene - if (Startup::_mode == 0) { + if (_mode == 0) { // user .SVG file found - load it from slot 0 loadGame(0, NULL); - } else { - if (Startup::_mode == 1) { + } else if (_mode == 1) { // Load either initial game state savegame or launcher specified savegame loadGame(_startGameSlot, NULL); - } else { + } else { error("Creating setup savegames not supported"); - } } loadScript(progName(kIn0Ext)); } @@ -1647,7 +1647,7 @@ bool CGEEngine::showTitle(const char *name) { D.center(); D.show(2); - if (Startup::_mode == 2) { + if (_mode == 2) { inf(SVG0NAME); _talk->show(2); } @@ -1658,7 +1658,7 @@ bool CGEEngine::showTitle(const char *name) { selectPocket(-1); _vga->sunrise(Vga::_sysPal); - if (Startup::_mode < 2 && !Startup::_soundOk) { + if (_mode < 2 && !_soundOk) { _vga->copyPage(1, 2); _vga->copyPage(0, 1); _vga->_showQ->append(_mouse); @@ -1674,12 +1674,12 @@ bool CGEEngine::showTitle(const char *name) { _heart->_enable = false; _vga->_showQ->clear(); _vga->copyPage(0, 2); - Startup::_soundOk = 2; + _soundOk = 2; if (_music) loadMidi(0); } - if (Startup::_mode < 2) { + if (_mode < 2) { if (_isDemo) { strcpy(_usrFnam, progName(kSvgExt)); usr_ok = true; @@ -1714,22 +1714,22 @@ bool CGEEngine::showTitle(const char *name) { #endif } - if (usr_ok && Startup::_mode == 0) { + if (usr_ok && _mode == 0) { if (savegameExists(0)) { // Load the savegame loadGame(0, NULL, true); // only system vars _vga->setColors(Vga::_sysPal, 64); _vga->update(); if (_flag[3]) { //flag FINIS - Startup::_mode++; + _mode++; _flag[3] = false; } } else - Startup::_mode++; + _mode++; } } - if (Startup::_mode < 2) + if (_mode < 2) movie("X01"); // wink _vga->copyPage(0, 2); @@ -1737,7 +1737,7 @@ bool CGEEngine::showTitle(const char *name) { if (_isDemo) return true; else - return (Startup::_mode == 2 || usr_ok); + return (_mode == 2 || usr_ok); } void CGEEngine::cge_main() { @@ -1750,28 +1750,28 @@ void CGEEngine::cge_main() { error("%s", _text->getText(NO_MOUSE_TEXT)); if (!SVG0FILE::exist(SVG0NAME)) - Startup::_mode = 2; + _mode = 2; _debugLine->_flags._hide = true; _horzLine->_flags._hide = true; - if (_music && Startup::_soundOk) + if (_music && _soundOk) loadMidi(0); if (_startGameSlot != -1) { // Starting up a savegame from the launcher - Startup::_mode++; + _mode++; runGame(); _startupMode = 2; if (_flag[3]) // Flag FINIS movie("X03"); } else { - if (Startup::_mode < 2) + if (_mode < 2) movie(kLgoExt); if (showTitle("WELCOME")) { - if ((!_isDemo) && (Startup::_mode == 1)) + if ((!_isDemo) && (_mode == 1)) movie("X02"); // intro runGame(); _startupMode = 2; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 8586d84d50..681e756c06 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -31,6 +31,7 @@ #include "cge/wav.h" #include "cge/vga13h.h" #include "cge/events.h" +#include "cge/sound.h" namespace CGE { #define CAVE_X 4 @@ -138,6 +139,8 @@ extern Sprite *_cavLight; extern InfoLine *_debugLine; extern Snail *_snail; extern Snail *_snail_; +extern Fx *_fx; +extern Sound *_sound; } // End of namespace CGE diff --git a/engines/cge/module.mk b/engines/cge/module.mk index c1112c7ec2..8829883e26 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -16,7 +16,6 @@ MODULE_OBJS := \ mixer.o \ snail.o \ sound.o \ - startup.o \ talk.o \ text.o \ vga13h.o \ diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 697e70bf8e..d1978ef845 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -798,9 +798,9 @@ void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { debugC(1, kCGEDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt); if (wav == -1) - _sound.stop(); + _sound->stop(); else - _sound.play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt); + _sound->play((*_fx)[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt); } diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 9bf0d59be0..56db1a6482 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -26,22 +26,17 @@ */ #include "cge/general.h" -#include "cge/startup.h" #include "cge/sound.h" #include "cge/text.h" #include "cge/cfile.h" #include "cge/vol.h" +#include "cge/cge_main.h" namespace CGE { -Fx _fx = 16; // must precede SOUND!! -Sound _sound; - - -Sound::Sound() { - if (Startup::_soundOk) - open(); +Sound::Sound(CGEEngine *vm) : _vm(vm) { + open(); } @@ -58,7 +53,7 @@ void Sound::close() { void Sound::open() { sndInit(); - play(_fx[30000], 8); + play((*_fx)[30000], 8); } diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 3ca4deaecc..292cb30e76 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -30,18 +30,21 @@ #include "cge/wav.h" #include "cge/snddrv.h" +#include "cge/cge.h" namespace CGE { class Sound { public: SmpInfo _smpinf; - Sound(); + Sound(CGEEngine *vm); ~Sound(); void open(); void close(); void play(DataCk *wav, int pan, int cnt = 1); void stop(); +private: + CGEEngine *_vm; }; @@ -55,17 +58,13 @@ class Fx { int find(int ref); public: DataCk *_current; - Fx(int size = 16); + Fx(int size); ~Fx(); void clear(); void preload(int ref0); DataCk *operator[](int ref); }; -extern Sound _sound; -extern Fx _fx; - - void loadMidi(int ref); void killMidi(); diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp deleted file mode 100644 index 5e1c8b8d64..0000000000 --- a/engines/cge/startup.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/startup.h" -#include "cge/text.h" -#include "cge/sound.h" -#include "cge/cfile.h" -#include "cge/snddrv.h" - -namespace CGE { - -extern char _copr[]; - -#define id (*(Ident*)_copr) - -// static Startup _startUp; - -int Startup::_mode = 0; -int Startup::_soundOk = 0; - - -void quitNow(int ref) { - error("%s", _text->getText(ref)); -} - - -bool Startup::getParms() { - /* - int i = _argc; - while (i > 1) { - static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", "P", "D", "I", "M" }; - int n = takeEnum(PrmTab, strtok(_argv[--i], " =:(")); - uint16 p = xtow(strtok(NULL, " h,)")); - switch (n) { - case 0 : - if (Mode != 2) - Mode = 1; - break; - case 1 : - Mode = 2; - break; - case 2 : - SNDDrvInfo.DDEV = DEV_QUIET; - break; - case 3 : - SNDDrvInfo.DDEV = DEV_SB; - break; - case 4 : - SNDDrvInfo.DDEV = DEV_GUS; - break; - case 5 : - SNDDrvInfo.MDEV = DEV_GM; - break; - case 6 : - SNDDrvInfo.DBASE = p; - break; - case 7 : - SNDDrvInfo.DDMA = p; - break; - case 8 : - SNDDrvInfo.DIRQ = p; - break; - case 9 : - SNDDrvInfo.MBASE = p; - SNDDrvInfo.MDEV = DEV_GM; - break; - default: - return false; - } - - if (n >= 2) - SoundOk = 2; - } - - if (SNDDrvInfo.MDEV != DEV_GM) - SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; - return true; - */ - warning("STUB: Startup::get_parms"); - return true; -} - - -Startup::Startup() { - /* - uint32 m = farcoreleft() >> 10; - if (m < 0x7FFF) - Core = (int) m; - else - Core = 0x7FFF; - - if (! IsVga()) - quit_now(NOT_VGA_TEXT); - if (Cpu() < _80286) - quit_now(BAD_CHIP_TEXT); - if (100 * _osmajor + _osminor < 330) - quit_now(BAD_DOS_TEXT); - if (! get_parms()) - quit_now(BAD_ARG_TEXT); - //--- load sound configuration - const char * fn = usrPath(ProgName(CFG_EXT)); - if (!Startup::_soundOk && CFILE::Exist(fn)) { - CFILE cfg(fn, REA); - if (! cfg.Error) { - cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2)); - if (! cfg.Error) - Startup::_soundOk = 1; - } - } - */ - warning("STUB: Startup::Startup"); -} - - -const char *usrPath(const char *nam) { - static char buf[kPathMax] = ".\\", *p = buf + 2; -#if defined(CD) - if (DriveCD(0)) { - bool ok = false; - CFILE ini = Text[CDINI_FNAME]; - if (!ini.Error) { - char *key = Text[GAME_ID]; - int i = strlen(key); - while (ini.Read(buf) && !ok) { - int j = strlen(buf); - if (j) - if (buf[--j] == '\n') - buf[j] = '\0'; - if (scumm_strnicmp((const char *) buf, (const char*) key, i) == 0) - ok = true; - } - if (ok) { - strcpy(buf, buf + i); - p = buf + strlen(buf); - if (*(p - 1) != '\\') - *(p++) = '\\'; - strcpy(p, "NUL"); - if (_dos_open(buf, 0, &i) == 0) - _dos_close(i); - else - ok = false; - } - } - if (!ok) - quit_now(BADCD_TEXT); - } -#endif - strcpy(p, nam); - return buf; -} - -} // End of namespace CGE diff --git a/engines/cge/startup.h b/engines/cge/startup.h deleted file mode 100644 index 8a8305040c..0000000000 --- a/engines/cge/startup.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_STARTUP__ -#define __CGE_STARTUP__ - - -#include "cge/general.h" - -namespace CGE { - -#define GAME_ID 45 -#define CDINI_FNAME 46 - -#define NOT_VGA_TEXT 90 -#define BAD_CHIP_TEXT 91 -#define BAD_DOS_TEXT 92 -#define NO_CORE_TEXT 93 -#define BAD_MIPS_TEXT 94 -#define NO_MOUSE_TEXT 95 -#define BAD_ARG_TEXT 96 -#define BADCD_TEXT 97 - -#define CFG_EXT ".CFG" - -class Startup { - static bool getParms(); - Startup(); -public: - static int _mode; - static int _soundOk; -}; - - -const char *usrPath(const char *nam); - -} // End of namespace CGE - -#endif -- cgit v1.2.3 From 5c7eb9a7686e6c701af083072fa944d3fc2e88fd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Jul 2011 12:52:04 +0200 Subject: CGE: un-static-fy several variables, clean Heart class --- engines/cge/cge.cpp | 2 + engines/cge/cge.h | 7 ++- engines/cge/general.cpp | 33 ------------ engines/cge/general.h | 9 ---- engines/cge/snail.cpp | 127 +++++++++++++++++++++---------------------- engines/cge/vga13h.cpp | 140 +----------------------------------------------- engines/cge/vga13h.h | 8 +-- 7 files changed, 71 insertions(+), 255 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 435a552bb4..168f45e45b 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -138,6 +138,8 @@ void CGEEngine::setup() { _mode = 0; _soundOk = 0; + _sprTv = NULL; + _gameCase2Cpt = 0; _startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 6d2842c613..835c47cb6e 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -107,7 +107,6 @@ public: int _pocref[kPocketNX]; uint8 _volume[2]; int _maxCaveArr[5]; - int _maxCave; bool _flag[4]; bool _dark; @@ -117,6 +116,12 @@ public: char _usrFnam[15]; int _mode; int _soundOk; + int _gameCase2Cpt; + + Sprite *_sprTv; + Sprite *_sprK1; + Sprite *_sprK2; + Sprite *_sprK3; Common::RandomSource _randomSource; byte * _mini; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 101c6cdd17..1947fc6061 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -331,39 +331,6 @@ int new_random(int range) { return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } -//void interrupt (* Engine_::oldTimer) (...) = NULL; - -Engine_::Engine_(uint16 tdiv) { -/* - // steal timer interrupt - OldTimer = getvect(TIMER_INT); - setvect(TIMER_INT, NewTimer); - - // set turbo-timer mode - asm mov al,0x36 - asm out 0x43,al - asm mov ax,TMR_DIV - asm out 0x40,al - asm mov al,ah - asm out 0x40,al -*/ - warning("STUB: Engine_::Engine_"); -} - -Engine_::~Engine_() { -/* - // reset timer - asm mov al,0x36 - asm out 0x43,al - asm xor al,al - asm out 0x40,al - asm out 0x40,al - // bring back timer interrupt - setvect(TIMER_INT, OldTimer); -*/ - warning("STUB: Engine_::~Engine_"); -} - DataCk::~DataCk() { if (!_e && _buf) free(_buf); diff --git a/engines/cge/general.h b/engines/cge/general.h index e340c962bd..d55193d85c 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -49,15 +49,6 @@ struct Dac { typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); -class Engine_ { -protected: - static void (* oldTimer)(...); - static void newTimer(...); -public: - Engine_(uint16 tdiv); - ~Engine_(); -}; - template void swap(T &A, T &B) { T a = A; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index d1978ef845..aa37922b70 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -134,60 +134,55 @@ void CGEEngine::snGame(Sprite *spr, int num) { _snail->addCom(kSnSay, buref, 16008, NULL); // zgadnij! _game = true; } -#undef STEPS -#undef DRESSED } break; //-------------------------------------------------------------------- case 2 : { - static Sprite *k = NULL, * k1, * k2, * k3; - static int count = 0; - - if (k == NULL) { - k = _vga->_showQ->locate(20700); - k1 = _vga->_showQ->locate(20701); - k2 = _vga->_showQ->locate(20702); - k3 = _vga->_showQ->locate(20703); + if (_sprTv == NULL) { + _sprTv = _vga->_showQ->locate(20700); + _sprK1 = _vga->_showQ->locate(20701); + _sprK2 = _vga->_showQ->locate(20702); + _sprK3 = _vga->_showQ->locate(20703); } if (!_game) { // init _snail->addCom(kSnGame, 20002, 2, NULL); _game = true; } else { // cont - k1->step(new_random(6)); - k2->step(new_random(6)); - k3->step(new_random(6)); + _sprK1->step(new_random(6)); + _sprK2->step(new_random(6)); + _sprK3->step(new_random(6)); ///-------------------- if (spr->_ref == 1 && _keyboard->_key[ALT]) { - k1->step(5); - k2->step(5); - k3->step(5); + _sprK1->step(5); + _sprK2->step(5); + _sprK3->step(5); } ///-------------------- _snail->addCom(kSnSetZ, 20700, 0, NULL); - bool hit = (k1->_seqPtr + k2->_seqPtr + k3->_seqPtr == 15); + bool hit = (_sprK1->_seqPtr + _sprK2->_seqPtr + _sprK3->_seqPtr == 15); if (hit) { if (spr->_ref == 1) { - _snail->addCom(kSnSay, 1, 20003, NULL); // hura! - _snail->addCom(kSnSeq, 20011, 2, NULL); // kamera won - _snail->addCom(kSnSend, 20701, -1, NULL); // k1 won - _snail->addCom(kSnSend, 20702, -1, NULL); // k2 won - _snail->addCom(kSnSend, 20703, -1, NULL); // k3 won - _snail->addCom(kSnSend, 20700, -1, NULL); // tv won - _snail->addCom(kSnKeep, 20007, 0, NULL); // do kieszeni - _snail->addCom(kSnSend, 20006, 20, NULL); // bilon + _snail->addCom(kSnSay, 1, 20003, NULL); // hura! + _snail->addCom(kSnSeq, 20011, 2, NULL); // kamera won + _snail->addCom(kSnSend, 20701, -1, NULL); // k1 won + _snail->addCom(kSnSend, 20702, -1, NULL); // k2 won + _snail->addCom(kSnSend, 20703, -1, NULL); // k3 won + _snail->addCom(kSnSend, 20700, -1, NULL); // tv won + _snail->addCom(kSnKeep, 20007, 0, NULL); // do kieszeni + _snail->addCom(kSnSend, 20006, 20, NULL); // bilon _snail->addCom(kSnSound, 20006, 20002, NULL); // bilon! - _snail->addCom(kSnSay, 20002, 20004, NULL); - _snail->addCom(kSnSend, 20010, 20, NULL); // papier + _snail->addCom(kSnSay, 20002, 20004, NULL); + _snail->addCom(kSnSend, 20010, 20, NULL); // papier _snail->addCom(kSnSound, 20010, 20003, NULL); // papier! - _snail->addCom(kSnSay, 20001, 20005, NULL); + _snail->addCom(kSnSay, 20001, 20005, NULL); _game = false; return; } else - k3->step(new_random(5)); + _sprK3->step(new_random(5)); } - if (count < 100) { - switch (count) { + if (_gameCase2Cpt < 100) { + switch (_gameCase2Cpt) { case 15 : _snail->addCom(kSnSay, 20003, 20021, NULL); break; @@ -198,51 +193,51 @@ void CGEEngine::snGame(Sprite *spr, int num) { _snail->addCom(kSnSay, 20003, 20022, NULL); break; } - count++; + _gameCase2Cpt++; } switch (spr->_ref) { case 1 : - _snail->addCom(kSnSay, 20001, 20011, NULL); // zapro - _snail->addCom(kSnSeq, 20001, 1, NULL); // rzu - _snail->addCom(kSnWait, 20001, 1, NULL); // czekaj - _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k - _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k - _snail->addCom(kSnWait, 20001, 16, NULL); // czekaj - _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† - _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSay, 20001, 20011, NULL); // zapro + _snail->addCom(kSnSeq, 20001, 1, NULL); // rzu + _snail->addCom(kSnWait, 20001, 1, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20001, 16, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech - _snail->addCom(kSnWait, 20007, -1, NULL); // koniec - _snail->addCom(kSnGame, 20001, 2, NULL); // again! + _snail->addCom(kSnWait, 20007, -1, NULL); // koniec + _snail->addCom(kSnGame, 20001, 2, NULL); // again! break; case 20001: - _snail->addCom(kSnSay, 20002, 20012, NULL); // zapro - _snail->addCom(kSnSeq, 20002, 1, NULL); // rzu - _snail->addCom(kSnWait, 20002, 3, NULL); // czekaj - _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k - _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k - _snail->addCom(kSnWait, 20002, 10, NULL); // czekaj - _snail->addCom(kSnSeq, 20007, 2, NULL); // lec† - _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSay, 20002, 20012, NULL); // zapro + _snail->addCom(kSnSeq, 20002, 1, NULL); // rzu + _snail->addCom(kSnWait, 20002, 3, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20002, 10, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 2, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech - _snail->addCom(kSnWait, 20007, -1, NULL); // koniec - _snail->addCom(kSnGame, 20002, 2, NULL); // again! + _snail->addCom(kSnWait, 20007, -1, NULL); // koniec + _snail->addCom(kSnGame, 20002, 2, NULL); // again! break; case 20002: - _snail->addCom(kSnSay, 20002, 20010, NULL); // zapro - _snail->addCom(kSnWalk, 20005, -1, NULL); // do stol - _snail->addCom(kSnWait, 1, -1, NULL); // stoi - _snail->addCom(kSnCover, 1, 20101, NULL); // grasol - _snail->addCom(kSnSeq, 20101, 1, NULL); // rzu - _snail->addCom(kSnWait, 20101, 5, NULL); // czekaj - _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k - _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k - _snail->addCom(kSnWait, 20101, 15, NULL); // czekaj - _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† - _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSay, 20002, 20010, NULL); // zapro + _snail->addCom(kSnWalk, 20005, -1, NULL); // do stol + _snail->addCom(kSnWait, 1, -1, NULL); // stoi + _snail->addCom(kSnCover, 1, 20101, NULL); // grasol + _snail->addCom(kSnSeq, 20101, 1, NULL); // rzu + _snail->addCom(kSnWait, 20101, 5, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20101, 15, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech - _snail->addCom(kSnWait, 20101, -1, NULL); // koniec - _snail->addCom(kSnUncover, 1, 20101, NULL); // SDS - _snail->addCom(kSnGame, 1, 2, NULL); // again! + _snail->addCom(kSnWait, 20101, -1, NULL); // koniec + _snail->addCom(kSnUncover, 1, 20101, NULL); // SDS + _snail->addCom(kSnGame, 1, 2, NULL); // again! break; } } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 7e1d8f9962..6e14666bd9 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -212,148 +212,10 @@ Sprite *locate(int ref) { } -Heart::Heart() - : Engine_(TMR_DIV) { +Heart::Heart() { _enable = false; - _xTimer = NULL; } - -/* -extern "C" void TimerProc() { - static SPRITE * spr; - static uint8 run = 0; - - // decrement external timer uint16 - if (_heart->_xTimer) { - if (*_heart->_xTimer) - *_heart->_xTimer--; - else - _heart->_xTimer = NULL; - } - - if (!run && _heart->_enable) { // check overrun flag - static uint16 oldSP, oldSS; - run++; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 - - // system pseudo-sprite - if (Sys) { - if (Sys->Time) { - if (--Sys->Time == 0) - Sys->tick(); - } - } - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { - if (spr->Time) { - if (!spr->_flags.Hide) { - if (-- spr->Time == 0) - spr->tick(); - } - } - } - asm mov ss,oldSS - asm mov sp,oldSP - run--; - } -} -*/ - - -void Engine_::newTimer(...) { - /* - static SPRITE *spr; - static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - ___1152_Hz___: - - SNDMIDIPlay(); - asm dec cntr1 - asm jz ___72_Hz___ - asm mov al,0x20 // send... - asm out 0x020,al // ...e-o-i - return; - - ___72_Hz___: - - asm mov cntr1,TMR_RATE1 - asm dec cntr2 - asm jnz my_eoi - - ___18_Hz___: - - OldTimer(); - asm mov cntr2,TMR_RATE2 - asm jmp short my_int - - // send E-O-I - my_eoi: - asm mov al,0x20 - asm out 0x020,al - asm sti // enable interrupts - - my_int: //------72Hz-------// - - // decrement external timer uint16 - if (_heart->XTimer) { - if (*_heart->XTimer) - *_heart->XTimer--; - else - _heart->XTimer = NULL; - } - - if (! run && _heart->Enable) { // check overrun flag - static uint16 oldSP, oldSS; - - run++; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 - - // system pseudo-sprite - if (Sys) { - if (Sys->Time) { - if (--Sys->Time == 0) - Sys->tick(); - } - } - - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { - if (spr->Time) { - if (!spr->_flags.Hide) { - if (--spr->Time == 0) - spr->tick(); - } - } - } - asm mov ss,oldSS - asm mov sp,oldSP - run--; - } - - */ - warning("STUB: Engine_::NewTimer"); -} - - -void Heart::setXTimer(uint16 *ptr) { - if (_xTimer && ptr != _xTimer) - *_xTimer = 0; - _xTimer = ptr; -} - - -void Heart::setXTimer(uint16 *ptr, uint16 time) { - setXTimer(ptr); - *ptr = time; -} - - Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index f192d962ff..535c7005d2 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -117,16 +117,10 @@ extern Seq _seq2[]; #define VGAST1 (VGAST1_ & 0xFF) -class Heart : public Engine_ { - friend class Engine_; +class Heart { public: Heart(); - bool _enable; - uint16 *_xTimer; - - void setXTimer(uint16 *ptr); - void setXTimer(uint16 *ptr, uint16 time); }; -- cgit v1.2.3 From 8b53899ca7d5ab1599f6bf3e1d4e49746876674b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Jul 2011 15:28:57 +0200 Subject: CGE: Remove Heart --- engines/cge/cge.cpp | 2 -- engines/cge/cge_main.cpp | 13 ------------- engines/cge/cge_main.h | 1 - engines/cge/snail.cpp | 3 --- engines/cge/vga13h.cpp | 8 -------- engines/cge/vga13h.h | 7 ------- 6 files changed, 34 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 168f45e45b..116bafcb64 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -81,7 +81,6 @@ void CGEEngine::setup() { // Initialise engine objects _text = new Text(this, progName(), 128); _vga = new Vga(M13H); - _heart = new Heart; _sys = new System(this); _pocLight = new PocLight(this); for (int i = 0; i < kPocketNX; i++) { @@ -170,7 +169,6 @@ CGEEngine::~CGEEngine() { delete _cavLight; delete _debugLine; delete _text; - delete _heart; delete _pocLight; delete _keyboard; delete _mouse; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 855834b489..dc573b8b2f 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -63,7 +63,6 @@ namespace CGE { uint16 _stklen = (STACK_SIZ * 2); Vga *_vga; -Heart *_heart; System *_sys; Sprite *_pocLight; EventManager *_eventManager; @@ -625,8 +624,6 @@ void CGEEngine::caveUp() { _dark = false; if (!_startupMode) _mouse->on(); - - _heart->_enable = true; } @@ -675,7 +672,6 @@ void CGEEngine::switchCave(int cav) { debugC(1, kCGEDebugEngine, "CGEEngine::switchCave(%d)", cav); if (cav != _now) { - _heart->_enable = false; if (cav < 0) { _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint _snail->addCom2(kSnExec, -1, 0, kQGame); // switch cave @@ -1592,7 +1588,6 @@ void CGEEngine::runGame() { } _keyboard->setClient(NULL); - _heart->_enable = false; _snail->addCom(kSnClear, -1, 0, NULL); _snail_->addCom(kSnClear, -1, 0, NULL); _mouse->off(); @@ -1612,16 +1607,12 @@ void CGEEngine::movie(const char *ext) { loadScript(fn); expandSprite(_vga->_spareQ->locate(999)); feedSnail(_vga->_showQ->locate(999), kTake); - _vga->_showQ->append(_mouse); - - _heart->_enable = true; _keyboard->setClient(_sys); while (!_snail->idle() && !_eventManager->_quitFlag) mainLoop(); _keyboard->setClient(NULL); - _heart->_enable = false; _snail->addCom(kSnClear, -1, 0, NULL); _snail_->addCom(kSnClear, -1, 0, NULL); _vga->_showQ->clear(); @@ -1662,7 +1653,6 @@ bool CGEEngine::showTitle(const char *name) { _vga->copyPage(1, 2); _vga->copyPage(0, 1); _vga->_showQ->append(_mouse); - _heart->_enable = true; _mouse->on(); for (; !_snail->idle() || Vmenu::_addr;) { mainLoop(); @@ -1671,7 +1661,6 @@ bool CGEEngine::showTitle(const char *name) { } _mouse->off(); - _heart->_enable = false; _vga->_showQ->clear(); _vga->copyPage(0, 2); _soundOk = 2; @@ -1698,13 +1687,11 @@ bool CGEEngine::showTitle(const char *name) { strcpy(_usrFnam, "User"); usr_ok = true; } else { - _heart->_enable = true; for (takeName(); GetText::_ptr;) { mainLoop(); if (_eventManager->_quitFlag) return false; } - _heart->_enable = false; if (_keyboard->last() == Enter && *_usrFnam) usr_ok = true; } diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 681e756c06..d811236485 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -122,7 +122,6 @@ private: }; extern Vga *_vga; -extern Heart *_heart; extern System *_sys; extern int _offUseCount; extern Sprite *_pocLight; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index aa37922b70..2cd38d671f 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -501,16 +501,13 @@ void CGEEngine::snZTrim(Sprite *spr) { if (spr) if (spr->active()) { - bool en = _heart->_enable; Sprite *s; - _heart->_enable = false; s = (spr->_flags._shad) ? spr->_prev : NULL; _vga->_showQ->insert(_vga->_showQ->remove(spr)); if (s) { s->_z = spr->_z; _vga->_showQ->insert(_vga->_showQ->remove(s), spr); } - _heart->_enable = en; } } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6e14666bd9..9b30e02e4d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -211,11 +211,6 @@ Sprite *locate(int ref) { return (spr) ? spr : _vga->_spareQ->locate(ref); } - -Heart::Heart() { - _enable = false; -} - Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), @@ -358,8 +353,6 @@ void Sprite::setName(char *n) { Sprite *Sprite::expand() { if (!_ext) { - bool enbl = _heart->_enable; - _heart->_enable = false; _ext = new SprExt; assert(_ext != NULL); if (*_file) { @@ -473,7 +466,6 @@ Sprite *Sprite::expand() { else _takePtr = NO_PTR; } - _heart->_enable = enbl; } return this; } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 535c7005d2..15da63efbc 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -117,13 +117,6 @@ extern Seq _seq2[]; #define VGAST1 (VGAST1_ & 0xFF) -class Heart { -public: - Heart(); - bool _enable; -}; - - class SprExt { public: int _x0, _y0; -- cgit v1.2.3 From b53ffa8f2c31d27ac5a7b3fd48143102be6ff4ff Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Jul 2011 15:43:49 +0200 Subject: CGE: Move some conditional defines to variables --- engines/cge/cge.cpp | 62 ++++++++++++++++++++++++++++++++++++------------ engines/cge/cge.h | 19 +++++++++++++++ engines/cge/cge_main.cpp | 18 ++++++++------ engines/cge/cge_main.h | 12 ---------- engines/cge/snail.h | 11 --------- engines/cge/walk.cpp | 6 ++--- 6 files changed, 79 insertions(+), 49 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 116bafcb64..8d2073b66f 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -56,6 +56,49 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) } +void CGEEngine::initCaveValues() { + if (_isDemo) { + _mini = new byte[16384]; + CAVE_DX = 23; + CAVE_DY = 29; + CAVE_NX = 3; + CAVE_NY = 1; + } else { + _mini = new byte[65536]; + CAVE_DX = 9; + CAVE_DY = 10; + CAVE_NX = 8; + CAVE_NY = 3; + } + CAVE_MAX = CAVE_NX * CAVE_NY; + + if (_isDemo) { + _maxCaveArr[0] = CAVE_MAX; + _maxCaveArr[1] = -1; + _maxCaveArr[2] = -1; + _maxCaveArr[3] = -1; + _maxCaveArr[4] = -1; + } else { + _maxCaveArr[0] = 1; + _maxCaveArr[1] = 8; + _maxCaveArr[2] = 16; + _maxCaveArr[3] = 23; + _maxCaveArr[4] = 24; + }; + + _heroXY = (Hxy *) malloc (sizeof(Hxy) * CAVE_MAX); + for (int i = 0; i < CAVE_MAX; i++) { + _heroXY[i]._x = 0; + _heroXY[i]._y = 0; + } + + _barriers = (Bar *) malloc (sizeof(Bar) * (1 + CAVE_MAX)); + for (int i = 0; i < CAVE_MAX + 1; i++) { + _barriers[i]._horz = 0xFF; + _barriers[i]._vert = 0xFF; + } +} + void CGEEngine::setup() { debugC(1, kCGEDebugEngine, "CGEEngine::setup()"); @@ -109,22 +152,8 @@ void CGEEngine::setup() { _volume[0] = 0; _volume[1] = 0; + initCaveValues(); - if (_isDemo) { - _mini = new byte[16384]; - _maxCaveArr[0] = CAVE_MAX; - _maxCaveArr[1] = -1; - _maxCaveArr[2] = -1; - _maxCaveArr[3] = -1; - _maxCaveArr[4] = -1; - } else { - _mini = new byte[65536]; - _maxCaveArr[0] = 1; - _maxCaveArr[1] = 8; - _maxCaveArr[2] = 16; - _maxCaveArr[3] = 23; - _maxCaveArr[4] = 24; - }; _maxCave = 0; _dark = false; _game = false; @@ -181,6 +210,9 @@ CGEEngine::~CGEEngine() { delete _snail_; delete _hero; delete[] _mini; + + free(_heroXY); + free(_barriers); } Common::Error CGEEngine::run() { diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 835c47cb6e..9d2503a5cf 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -78,6 +78,16 @@ struct SavegameHeader { extern const char *SAVEGAME_STR; #define SAVEGAME_STR_SIZE 11 +struct Bar { + uint8 _horz; + uint8 _vert; +}; + +struct Hxy { + int _x; + int _y; +}; + class CGEEngine : public Engine { private: uint32 _lastFrame, _lastTick; @@ -123,6 +133,14 @@ public: Sprite *_sprK2; Sprite *_sprK3; + uint8 CAVE_DX; + uint8 CAVE_DY; + uint8 CAVE_NX; + uint8 CAVE_NY; + uint16 CAVE_MAX; + Hxy *_heroXY; + Bar *_barriers; + Common::RandomSource _randomSource; byte * _mini; BMP_PTR * _miniShp; @@ -200,6 +218,7 @@ public: void AltCtrlDel(); void postMiniStep(int stp); void showBak(int ref); + void initCaveValues(); void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index dc573b8b2f..123501047a 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -99,9 +99,6 @@ static bool _finis = false; int _offUseCount; uint16 *_intStackPtr = false; -Hxy _heroXY[CAVE_MAX] = {{0, 0}}; -Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } }; - extern Dac _stdPal[58]; void CGEEngine::syncHeader(Common::Serializer &s) { @@ -120,6 +117,13 @@ void CGEEngine::syncHeader(Common::Serializer &s) { for (i = 0; i < 4; ++i) s.syncAsUint16LE(_flag[i]); + initCaveValues(); + if (s.isLoading()) { + //TODO: Fix the memory leak when the game is already running + _heroXY = (Hxy *) malloc (sizeof(Hxy) * CAVE_MAX); + _barriers = (Bar *) malloc (sizeof(Bar) * (1 + CAVE_MAX)); + } + for (i = 0; i < CAVE_MAX; ++i) { s.syncAsSint16LE(_heroXY[i]._x); s.syncAsUint16LE(_heroXY[i]._y); @@ -145,7 +149,7 @@ void CGEEngine::syncHeader(Common::Serializer &s) { } bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { - debugC(1, kCGEDebugEngine, "CGEEngine::loadgame(file, %s)", tiny ? "true" : "false"); + debugC(1, kCGEDebugEngine, "CGEEngine::loadgame(%d, header, %s)", slotNumber, tiny ? "true" : "false"); Common::MemoryReadStream *readStream; SavegameHeader saveHeader; @@ -833,9 +837,9 @@ void System::touch(uint16 mask, int x, int y) { _infoLine->update(NULL); if (y >= kWorldHeight ) { if (x < kButtonX) { // select cave? - if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY && - x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && !_vm->_game) { - cav = ((y - CAVE_Y) / CAVE_DY) * CAVE_NX + (x - CAVE_X) / CAVE_DX + 1; + if (y >= CAVE_Y && y < CAVE_Y + _vm->CAVE_NY * _vm->CAVE_DY && + x >= CAVE_X && x < CAVE_X + _vm->CAVE_NX * _vm->CAVE_DX && !_vm->_game) { + cav = ((y - CAVE_Y) / _vm->CAVE_DY) * _vm->CAVE_NX + (x - CAVE_X) / _vm->CAVE_DX + 1; if (cav > _vm->_maxCave) cav = 0; } else { diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index d811236485..e3d8d40846 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -39,18 +39,6 @@ namespace CGE { #define CAVE_SX 0 #define CAVE_SY 0 -#ifdef DEMO -#define CAVE_DX 23 -#define CAVE_DY 29 -#define CAVE_NX 3 -#define CAVE_NY 1 -#else -#define CAVE_DX 9 -#define CAVE_DY 10 -#define CAVE_NX 8 -#define CAVE_NY 3 -#endif -#define CAVE_MAX (CAVE_NX * CAVE_NY) #define PAIN (_vm->_flag[0]) #define kInfoX 177 diff --git a/engines/cge/snail.h b/engines/cge/snail.h index ad63f55f36..2b488cd5b2 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -37,11 +37,6 @@ namespace CGE { #define kSnailFrameDelay (1000 / kSnailFrameRate) #define kDressed 3 -struct Bar { - uint8 _horz; - uint8 _vert; -}; - enum SnCom { kSnLabel, kSnPause, kSnWait, kSnLevel, kSnHide, kSnSay, kSnInf, kSnTime, kSnCave, kSnKill, @@ -86,12 +81,6 @@ private: }; -extern Bar _barriers[]; -extern struct Hxy { - int _x; - int _y; -} _heroXY[]; - } // End of namespace CGE #endif diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index 9bcc2be23d..e2c62513dd 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -30,8 +30,6 @@ namespace CGE { -extern Bar _barriers[]; - Walk *_hero; uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; @@ -50,8 +48,8 @@ bool Cluster::isValid() const { } bool Cluster::chkBar() const { - assert(_vm->_now <= CAVE_MAX); - return (_a == _barriers[_vm->_now]._horz) && (_b == _barriers[_vm->_now]._vert); + assert(_vm->_now <= _vm->CAVE_MAX); + return (_a == _vm->_barriers[_vm->_now]._horz) && (_b == _vm->_barriers[_vm->_now]._vert); } Cluster XZ(int x, int y) { -- cgit v1.2.3 From 55df4d063596c774969a8d3537c999a95b7dfcc0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Jul 2011 00:52:35 +0200 Subject: CGE: Rename some class members, various clean up --- engines/cge/bitmap.cpp | 14 +++---- engines/cge/bitmap.h | 2 +- engines/cge/btfile.cpp | 2 +- engines/cge/btfile.h | 2 +- engines/cge/cfile.cpp | 18 ++++----- engines/cge/cfile.h | 8 ++-- engines/cge/cge.cpp | 28 +++++++------- engines/cge/cge.h | 22 +++++------ engines/cge/cge_main.cpp | 68 +++++++++++++++++----------------- engines/cge/events.cpp | 6 +-- engines/cge/general.cpp | 24 ++++++------ engines/cge/general.h | 23 +++++------- engines/cge/gettext.cpp | 2 +- engines/cge/mixer.h | 4 +- engines/cge/snail.cpp | 8 ++-- engines/cge/snail.h | 2 +- engines/cge/talk.cpp | 72 ++++++++++++------------------------ engines/cge/talk.h | 10 ++--- engines/cge/text.cpp | 34 ++++++++--------- engines/cge/text.h | 14 +++---- engines/cge/vga13h.cpp | 96 ++++++++++++++++++++++++------------------------ engines/cge/vga13h.h | 38 +++++++++---------- engines/cge/vmenu.cpp | 2 +- engines/cge/walk.cpp | 58 ++++++++++++++--------------- engines/cge/walk.h | 26 +++++++------ engines/cge/wav.h | 10 ++--- 26 files changed, 282 insertions(+), 311 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index c02c66df8b..ddde3bbd21 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -126,7 +126,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) b->_hide = _w >> 2; // Replicate across the entire table - for (HideDesc *hdP = b + 1; hdP < (b + _h); ++hdP) + for (HideDesc *hdP = b + 1; hdP < (b + _h); hdP++) *hdP = *b; b->_skip = 0; // fix the first entry @@ -195,7 +195,7 @@ uint16 Bitmap::moveVmap(uint8 *buf) { } -BMP_PTR Bitmap::code() { +BitmapPtr Bitmap::code() { debugC(1, kCGEDebugBitmap, "Bitmap::code()"); if (!_m) @@ -421,17 +421,17 @@ bool Bitmap::loadVBM(XFile *f) { if (p) { if (_pal) { // Read in the palette - byte palData[PAL_SIZ]; - f->read(palData, PAL_SIZ); + byte palData[kPalSize]; + f->read(palData, kPalSize); const byte *srcP = palData; - for (int idx = 0; idx < PAL_CNT; ++idx, srcP += 3) { + for (int idx = 0; idx < kPalCount; idx++, srcP += 3) { _pal[idx]._r = *srcP; _pal[idx]._g = *(srcP + 1); _pal[idx]._b = *(srcP + 2); } } else - f->seek(f->mark() + PAL_SIZ); + f->seek(f->mark() + kPalSize); } } if ((_v = new uint8[n]) == NULL) @@ -473,7 +473,7 @@ bool Bitmap::loadBMP(XFile *f) { f->read((byte *)&bpal, sizeof(bpal)); if (f->_error == 0) { if (_pal) { - for (i = 0; i < 256; i ++) { + for (i = 0; i < 256; i++) { _pal[i]._r = bpal[i]._R; _pal[i]._g = bpal[i]._G; _pal[i]._b = bpal[i]._B; diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 6b931573f8..30e11d08ec 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -91,7 +91,7 @@ public: }; -typedef Bitmap *BMP_PTR; +typedef Bitmap *BitmapPtr; } // End of namespace CGE diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 55511e6382..1f987340b7 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -34,7 +34,7 @@ namespace CGE { -BtFile::BtFile(const char *name, IOMode mode, CRYPT *crpt) +BtFile::BtFile(const char *name, IOMode mode, Crypt *crpt) : IoHand(name, mode, crpt) { debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode); diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index b589e86aee..6b7155d43d 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -83,7 +83,7 @@ class BtFile : public IoHand { void putPage(int lev, bool hard); BtPage *getPage(int lev, uint16 pgn); public: - BtFile(const char *name, IOMode mode, CRYPT *crpt); + BtFile(const char *name, IOMode mode, Crypt *crpt); virtual ~BtFile(); BtKeypack *find(const char *key); BtKeypack *next(); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index ac9f782d84..c6144f624b 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -33,24 +33,24 @@ namespace CGE { -IoBuf::IoBuf(IOMode mode, CRYPT *crpt) - : IoHand(mode, crpt), +IoBuf::IoBuf(IOMode mode, Crypt *crypt) + : IoHand(mode, crypt), _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crpt)", mode); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crypt)", mode); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); assert(_buff != NULL); } -IoBuf::IoBuf(const char *name, IOMode mode, CRYPT *crpt) - : IoHand(name, mode, crpt), +IoBuf::IoBuf(const char *name, IOMode mode, Crypt *crypt) + : IoHand(name, mode, crypt), _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crypt)", name, mode); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); assert(_buff != NULL); @@ -220,9 +220,9 @@ void IoBuf::write(uint8 b) { uint16 CFile::_maxLineLen = kLineMaxSize; -CFile::CFile(const char *name, IOMode mode, CRYPT *crpt) - : IoBuf(name, mode, crpt) { - debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crpt)", name, mode); +CFile::CFile(const char *name, IOMode mode, Crypt *crypt) + : IoBuf(name, mode, crypt) { + debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crypt)", name, mode); } diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 306ec5926b..6ed3b5e750 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -42,12 +42,12 @@ protected: uint16 _lim; long _bufMark; uint16 _seed; - CRYPT *_crypt; + Crypt *_crypt; virtual void readBuf(); virtual void writeBuf(); public: - IoBuf(IOMode mode, CRYPT *crpt = NULL); - IoBuf(const char *name, IOMode mode, CRYPT *crpt = NULL); + IoBuf(IOMode mode, Crypt *crpt = NULL); + IoBuf(const char *name, IOMode mode, Crypt *crpt = NULL); virtual ~IoBuf(); uint16 read(void *buf, uint16 len); uint16 read(uint8 *buf); @@ -61,7 +61,7 @@ public: class CFile : public IoBuf { public: static uint16 _maxLineLen; - CFile(const char *name, IOMode mode = kModeRead, CRYPT *crpt = NULL); + CFile(const char *name, IOMode mode = kModeRead, Crypt *crpt = NULL); virtual ~CFile(); void flush(); long mark(); diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 8d2073b66f..2baf1cde1e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -59,21 +59,21 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) void CGEEngine::initCaveValues() { if (_isDemo) { _mini = new byte[16384]; - CAVE_DX = 23; - CAVE_DY = 29; - CAVE_NX = 3; - CAVE_NY = 1; + _caveDx = 23; + _caveDy = 29; + _caveNx = 3; + _caveNy = 1; } else { _mini = new byte[65536]; - CAVE_DX = 9; - CAVE_DY = 10; - CAVE_NX = 8; - CAVE_NY = 3; + _caveDx = 9; + _caveDy = 10; + _caveNx = 8; + _caveNy = 3; } - CAVE_MAX = CAVE_NX * CAVE_NY; + _caveMax = _caveNx * _caveNy; if (_isDemo) { - _maxCaveArr[0] = CAVE_MAX; + _maxCaveArr[0] = _caveMax; _maxCaveArr[1] = -1; _maxCaveArr[2] = -1; _maxCaveArr[3] = -1; @@ -86,14 +86,14 @@ void CGEEngine::initCaveValues() { _maxCaveArr[4] = 24; }; - _heroXY = (Hxy *) malloc (sizeof(Hxy) * CAVE_MAX); - for (int i = 0; i < CAVE_MAX; i++) { + _heroXY = (Hxy *) malloc (sizeof(Hxy) * _caveMax); + for (int i = 0; i < _caveMax; i++) { _heroXY[i]._x = 0; _heroXY[i]._y = 0; } - _barriers = (Bar *) malloc (sizeof(Bar) * (1 + CAVE_MAX)); - for (int i = 0; i < CAVE_MAX + 1; i++) { + _barriers = (Bar *) malloc (sizeof(Bar) * (1 + _caveMax)); + for (int i = 0; i < _caveMax + 1; i++) { _barriers[i]._horz = 0xFF; _barriers[i]._vert = 0xFF; } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 9d2503a5cf..7adc44fac6 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -133,19 +133,19 @@ public: Sprite *_sprK2; Sprite *_sprK3; - uint8 CAVE_DX; - uint8 CAVE_DY; - uint8 CAVE_NX; - uint8 CAVE_NY; - uint16 CAVE_MAX; + uint8 _caveDx; + uint8 _caveDy; + uint8 _caveNx; + uint8 _caveNy; + uint16 _caveMax; Hxy *_heroXY; Bar *_barriers; Common::RandomSource _randomSource; - byte * _mini; - BMP_PTR * _miniShp; - BMP_PTR * _miniShpList; - int _startGameSlot; + byte *_mini; + BitmapPtr *_miniShp; + BitmapPtr *_miniShpList; + int _startGameSlot; virtual Common::Error run(); GUI::Debugger *getDebugger() { @@ -168,7 +168,7 @@ public: bool showTitle(const char *name); void movie(const char *ext); void takeName(); - void inf(const char *txt); + void inf(const char *text); void selectSound(); void dummy() {} void NONE(); @@ -202,7 +202,7 @@ public: void saveMapping(); void saveSound(); void heroCover(int cvr); - void trouble(int seq, int txt); + void trouble(int seq, int text); void offUse(); void tooFar(); void loadHeroXY(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 123501047a..37449fd5dd 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -109,30 +109,30 @@ void CGEEngine::syncHeader(Common::Serializer &s) { s.syncAsUint16LE(_now); s.syncAsUint16LE(_oldLev); s.syncAsUint16LE(_demoText); - for (i = 0; i < 5; ++i) + for (i = 0; i < 5; i++) s.syncAsUint16LE(_game); s.syncAsSint16LE(i); // unused VGA::Mono variable s.syncAsUint16LE(_music); s.syncBytes(_volume, 2); - for (i = 0; i < 4; ++i) + for (i = 0; i < 4; i++) s.syncAsUint16LE(_flag[i]); initCaveValues(); if (s.isLoading()) { //TODO: Fix the memory leak when the game is already running - _heroXY = (Hxy *) malloc (sizeof(Hxy) * CAVE_MAX); - _barriers = (Bar *) malloc (sizeof(Bar) * (1 + CAVE_MAX)); + _heroXY = (Hxy *) malloc (sizeof(Hxy) * _caveMax); + _barriers = (Bar *) malloc (sizeof(Bar) * (1 + _caveMax)); } - for (i = 0; i < CAVE_MAX; ++i) { + for (i = 0; i < _caveMax; i++) { s.syncAsSint16LE(_heroXY[i]._x); s.syncAsUint16LE(_heroXY[i]._y); } - for (i = 0; i < 1 + CAVE_MAX; ++i) { + for (i = 0; i < 1 + _caveMax; i++) { s.syncAsByte(_barriers[i]._horz); s.syncAsByte(_barriers[i]._vert); } - for (i = 0; i < kPocketNX; ++i) + for (i = 0; i < kPocketNX; i++) s.syncAsUint16LE(_pocref[i]); if (s.isSaving()) { @@ -409,15 +409,15 @@ void CGEEngine::heroCover(int cvr) { _snail->addCom(kSnCover, 1, cvr, NULL); } -void CGEEngine::trouble(int seq, int txt) { - debugC(1, kCGEDebugEngine, "CGEEngine::trouble(%d, %d)", seq, txt); +void CGEEngine::trouble(int seq, int text) { + debugC(1, kCGEDebugEngine, "CGEEngine::trouble(%d, %d)", seq, text); _hero->park(); _snail->addCom(kSnWait, -1, -1, _hero); _snail->addCom(kSnSeq, -1, seq, _hero); _snail->addCom(kSnSound, -1, 2, _hero); _snail->addCom(kSnWait, -1, -1, _hero); - _snail->addCom(kSnSay, 1, txt, _hero); + _snail->addCom(kSnSay, 1, text, _hero); } void CGEEngine::offUse() { @@ -444,7 +444,7 @@ void CGEEngine::loadHeroXY() { void CGEEngine::loadMapping() { debugC(1, kCGEDebugEngine, "CGEEngine::loadMapping()"); - if (_now <= CAVE_MAX) { + if (_now <= _caveMax) { INI_FILE cf(progName(".TAB")); if (!cf._error) { memset(Cluster::_map, 0, sizeof(Cluster::_map)); @@ -458,7 +458,7 @@ Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { _flags._kill = true; _flags._bDel = false; - BMP_PTR *MB = new BMP_PTR[2]; + BitmapPtr *MB = new BitmapPtr[2]; MB[0] = new Bitmap("BRICK", true); MB[1] = NULL; setShapeList(MB); @@ -480,7 +480,7 @@ void CGEEngine::setMapBrick(int x, int z) { Square *s = new Square(this); if (s) { static char n[] = "00:00"; - s->gotoxy(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID); + s->gotoxy(x * kMapGridX, kMapTop + z * kMapGridZ); wtom(x, n + 0, 10, 2); wtom(z, n + 3, 10, 2); Cluster::_map[z][x] = 1; @@ -688,8 +688,8 @@ void CGEEngine::switchCave(int cav) { if (!_isDemo) _vga->_spareQ->_show = 0; } - _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, - CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); + _cavLight->gotoxy(CAVE_X + ((_now - 1) % _caveNx) * _caveDx + CAVE_SX, + CAVE_Y + ((_now - 1) / _caveNx) * _caveDy + CAVE_SY); killText(); if (!_startupMode) keyClick(); @@ -837,9 +837,9 @@ void System::touch(uint16 mask, int x, int y) { _infoLine->update(NULL); if (y >= kWorldHeight ) { if (x < kButtonX) { // select cave? - if (y >= CAVE_Y && y < CAVE_Y + _vm->CAVE_NY * _vm->CAVE_DY && - x >= CAVE_X && x < CAVE_X + _vm->CAVE_NX * _vm->CAVE_DX && !_vm->_game) { - cav = ((y - CAVE_Y) / _vm->CAVE_DY) * _vm->CAVE_NX + (x - CAVE_X) / _vm->CAVE_DX + 1; + if (y >= CAVE_Y && y < CAVE_Y + _vm->_caveNy * _vm->_caveDy && + x >= CAVE_X && x < CAVE_X + _vm->_caveNx * _vm->_caveDx && !_vm->_game) { + cav = ((y - CAVE_Y) / _vm->_caveDy) * _vm->_caveNx + (x - CAVE_X) / _vm->_caveDx + 1; if (cav > _vm->_maxCave) cav = 0; } else { @@ -861,7 +861,7 @@ void System::touch(uint16 mask, int x, int y) { _vm->switchCave(cav); if (!_horzLine->_flags._hide) { - if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) { + if (y >= kMapTop && y < kMapTop + kMapHig) { int8 x1, z1; XZ(x, y).split(x1, z1); Cluster::_map[z1][x1] = 1; @@ -869,7 +869,7 @@ void System::touch(uint16 mask, int x, int y) { } } else { if (!_talk && _snail->idle() && _hero - && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_vm->_game) { + && y >= kMapTop && y < kMapTop + kMapHig && !_vm->_game) { _hero->findWay(XZ(x, y)); } } @@ -964,9 +964,9 @@ void CGEEngine::switchMapping() { if (_horzLine->_flags._hide) { int i; - for (i = 0; i < MAP_ZCNT; i++) { + for (i = 0; i < kMapZCnt; i++) { int j; - for (j = 0; j < MAP_XCNT; j++) { + for (j = 0; j < kMapXCnt; j++) { if (Cluster::_map[i][j]) setMapBrick(j, i); } @@ -974,7 +974,7 @@ void CGEEngine::switchMapping() { } else { Sprite *s; for (s = _vga->_showQ->first(); s; s = s->_next) - if (s->_w == MAP_XGRID && s->_h == MAP_ZGRID) + if (s->_w == kMapGridX && s->_h == kMapGridZ) _snail_->addCom(kSnKill, -1, 0, s); } _horzLine->_flags._hide = !_horzLine->_flags._hide; @@ -1526,7 +1526,7 @@ void CGEEngine::runGame() { killMidi(); if (_mini && INI_FILE::exist("MINI.SPR")) { - _miniShp = new BMP_PTR[2]; + _miniShp = new BitmapPtr[2]; _miniShp[0] = _miniShp[1] = NULL; uint8 *ptr = (uint8 *) &*_mini; @@ -1568,7 +1568,7 @@ void CGEEngine::runGame() { _debugLine->_z = 126; _vga->_showQ->insert(_debugLine); - _horzLine->_y = MAP_TOP - (MAP_TOP > 0); + _horzLine->_y = kMapTop - (kMapTop > 0); _horzLine->_z = 126; _vga->_showQ->insert(_horzLine); @@ -1579,8 +1579,8 @@ void CGEEngine::runGame() { _startupMode = 0; _snail->addCom(kSnLevel, -1, _oldLev, &_cavLight); - _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX, - CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); + _cavLight->gotoxy(CAVE_X + ((_now - 1) % _caveNx) * _caveDx + CAVE_SX, + CAVE_Y + ((_now - 1) / _caveNx) * _caveDy + CAVE_SY); caveUp(); _keyboard->setClient(_sys); @@ -1630,11 +1630,11 @@ bool CGEEngine::showTitle(const char *name) { return false; Bitmap::_pal = Vga::_sysPal; - BMP_PTR *LB = new BMP_PTR[2]; + BitmapPtr *LB = new BitmapPtr[2]; LB[0] = new Bitmap(name, true); LB[1] = NULL; Bitmap::_pal = NULL; - bool usr_ok = false; + bool userOk = false; Sprite D(this, LB); D._flags._kill = true; @@ -1675,7 +1675,7 @@ bool CGEEngine::showTitle(const char *name) { if (_mode < 2) { if (_isDemo) { strcpy(_usrFnam, progName(kSvgExt)); - usr_ok = true; + userOk = true; } else { #ifndef EVA // At this point the game originally set the protection variables @@ -1689,7 +1689,7 @@ bool CGEEngine::showTitle(const char *name) { // For ScummVM, skip prompting for name if a savegame in slot 0 already exists if ((_startGameSlot == -1) && savegameExists(0)) { strcpy(_usrFnam, "User"); - usr_ok = true; + userOk = true; } else { for (takeName(); GetText::_ptr;) { mainLoop(); @@ -1697,7 +1697,7 @@ bool CGEEngine::showTitle(const char *name) { return false; } if (_keyboard->last() == Enter && *_usrFnam) - usr_ok = true; + userOk = true; } //Mouse.Off(); _vga->_showQ->clear(); @@ -1705,7 +1705,7 @@ bool CGEEngine::showTitle(const char *name) { #endif } - if (usr_ok && _mode == 0) { + if (userOk && _mode == 0) { if (savegameExists(0)) { // Load the savegame loadGame(0, NULL, true); // only system vars @@ -1728,7 +1728,7 @@ bool CGEEngine::showTitle(const char *name) { if (_isDemo) return true; else - return (_mode == 2 || usr_ok); + return (_mode == 2 || userOk); } void CGEEngine::cge_main() { diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index dc6e65722d..1c2738f62e 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -110,7 +110,7 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) { } // Scan through the ScummVM mapping list - for (int idx = 0; idx < 0x60; ++idx) { + for (int idx = 0; idx < 0x60; idx++) { if (_scummVmCodes[idx] == keycode) { cgeCode = idx; return true; @@ -163,13 +163,13 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) Common::copy(ms, ms + 2, seq); setSeq(seq); - BMP_PTR *MC = new BMP_PTR[3]; + BitmapPtr *MC = new BitmapPtr[3]; MC[0] = new Bitmap("MOUSE", true); MC[1] = new Bitmap("DUMMY", true); MC[2] = NULL; setShapeList(MC); - gotoxy(kScrWidth/2, kScrHeight/2); + gotoxy(kScrWidth / 2, kScrHeight / 2); _z = 127; step(1); } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 1947fc6061..8e141a8be4 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -110,8 +110,8 @@ const char *progName(const char *ext) { return buf; } -char *mergeExt(char *buf, const char *nam, const char *ext) { - strcpy(buf, nam); +char *mergeExt(char *buf, const char *name, const char *ext) { + strcpy(buf, name); char *dot = strrchr(buf, '.'); if (!dot) strcat(buf, ext); @@ -119,8 +119,8 @@ char *mergeExt(char *buf, const char *nam, const char *ext) { return buf; } -char *forceExt(char *buf, const char *nam, const char *ext) { - strcpy(buf, nam); +char *forceExt(char *buf, const char *name, const char *ext) { + strcpy(buf, name); char *dot = strrchr(buf, '.'); if (dot) *dot = '\0'; @@ -204,13 +204,13 @@ char *dwtom(uint32 val, char *str, int radix, int len) { return str; } -IoHand::IoHand(IOMode mode, CRYPT *crpt) - : XFile(mode), _crypt(crpt), _seed(kCryptSeed) { +IoHand::IoHand(IOMode mode, Crypt *crypt) + : XFile(mode), _crypt(crypt), _seed(kCryptSeed) { _file = new Common::File(); } -IoHand::IoHand(const char *name, IOMode mode, CRYPT *crpt) - : XFile(mode), _crypt(crpt), _seed(kCryptSeed) { +IoHand::IoHand(const char *name, IOMode mode, Crypt *crypt) + : XFile(mode), _crypt(crypt), _seed(kCryptSeed) { // TODO: Check if WRI and/or UPD modes are needed, and map to a save file assert(mode == kModeRead); @@ -303,11 +303,11 @@ DataCk *loadWave(XFile *file) { return NULL; } -int takeEnum(const char **tab, const char *txt) { +int takeEnum(const char **tab, const char *text) { const char **e; - if (txt) { + if (text) { for (e = tab; *e; e++) { - if (scumm_stricmp(txt, *e) == 0) { + if (scumm_stricmp(text, *e) == 0) { return e - tab; } } @@ -332,7 +332,7 @@ int new_random(int range) { } DataCk::~DataCk() { - if (!_e && _buf) + if (_buf) free(_buf); } } // End of namespace CGE diff --git a/engines/cge/general.h b/engines/cge/general.h index d55193d85c..57991f2125 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -47,7 +47,7 @@ struct Dac { uint8 _b; }; -typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed); +typedef uint16 Crypt(void *buf, uint16 siz, uint16 seed); template void swap(T &A, T &B) { @@ -92,10 +92,10 @@ class IoHand : public XFile { protected: Common::File *_file; uint16 _seed; - CRYPT *_crypt; + Crypt *_crypt; public: - IoHand(const char *name, IOMode mode = kModeRead, CRYPT crypt = NULL); - IoHand(IOMode mode = kModeRead, CRYPT *crpt = NULL); + IoHand(const char *name, IOMode mode = kModeRead, Crypt crypt = NULL); + IoHand(IOMode mode = kModeRead, Crypt *crypt = NULL); virtual ~IoHand(); static bool exist(const char *name); uint16 read(void *buf, uint16 len); @@ -105,24 +105,21 @@ public: long seek(long pos); }; -CRYPT XCrypt; -CRYPT RCrypt; +Crypt XCrypt; +Crypt RCrypt; uint16 atow(const char *a); uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); char *dwtom(uint32 val, char *str, int radix, int len); -int takeEnum(const char **tab, const char *txt); +int takeEnum(const char **tab, const char *text); uint16 chkSum(void *m, uint16 n); long timer(); -char *mergeExt(char *buf, const char *nam, const char *ext); -char *forceExt(char *buf, const char *nam, const char *ext); -int driveCD(unsigned drv); +char *mergeExt(char *buf, const char *name, const char *ext); +char *forceExt(char *buf, const char *name, const char *ext); // MISSING FUNCTIONS void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)); const char *progName(const char *ext = NULL); -char *mergeExt(char *buf, const char *nam, const char *ext); -char *forceExt(char *buf, const char *nam, const char *ext); unsigned fastRand(); unsigned fastRand(unsigned s); uint16 rCrypt(void *buf, uint16 siz, uint16 seed); @@ -130,7 +127,7 @@ uint16 atow(const char *a); uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); char *dwtom(uint32 val, char * str, int radix, int len); -int takeEnum(const char **tab, const char *txt); +int takeEnum(const char **tab, const char *text); long timer(); int new_random(int range); } // End of namespace CGE diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index fa30b3a9d1..f64f4b2619 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -41,7 +41,7 @@ GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) _ptr = this; _mode = kTBRect; - _ts = new BMP_PTR[2]; + _ts = new BitmapPtr[2]; _ts[0] = box((i + 3) & ~3, 2 * kTextVMargin + 2 * kFontHigh + kTextLineSpace); _ts[1] = NULL; setShapeList(_ts); diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h index d97a4f3dd3..10c05e7cfb 100644 --- a/engines/cge/mixer.h +++ b/engines/cge/mixer.h @@ -40,8 +40,8 @@ namespace CGE { #define kMixName 105 // sprite name class Mixer : public Sprite { - BMP_PTR _mb[2]; - BMP_PTR _lb[kMixMax + 1]; + BitmapPtr _mb[2]; + BitmapPtr _lb[kMixMax + 1]; Sprite *_led[2]; int _fall; void update(); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 2cd38d671f..03cb43f4f1 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -390,7 +390,7 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) { } } -const char *Snail::_comTxt[] = { +const char *Snail::_comText[] = { "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", "SAY", "INF", "TIME", "CAVE", "KILL", "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", @@ -871,10 +871,10 @@ void CGEEngine::snFlash(bool on) { debugC(1, kCGEDebugEngine, "CGEEngine::snFlash(%s)", on ? "true" : "false"); if (on) { - Dac *pal = (Dac *) malloc(sizeof(Dac) * PAL_CNT); + Dac *pal = (Dac *) malloc(sizeof(Dac) * kPalCount); if (pal) { - memcpy(pal, Vga::_sysPal, PAL_SIZ); - for (int i = 0; i < PAL_CNT; i++) { + memcpy(pal, Vga::_sysPal, kPalSize); + for (int i = 0; i < kPalCount; i++) { register int c; c = pal[i]._r << 1; pal[i]._r = (c < 64) ? c : 63; diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 2b488cd5b2..2d12963f2c 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -67,7 +67,7 @@ public: bool _busy; bool _textDelay; uint32 _timerExpiry; - static const char *_comTxt[]; + static const char *_comText[]; bool _talkEnable; Snail(CGEEngine *vm, bool turbo); ~Snail(); diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 4a2df79f24..db44536267 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -73,25 +73,12 @@ uint16 Font::width(const char *text) { return w; } - -/* -void Font::save() { - CFILE f((const char *) _path, WRI); - if (!f._error) { - f.Write(_wid, WID_SIZ); - if (!f._error) - f.Write(_map, _pos[POS_SIZ - 1] + _wid[WID_SIZ - 1]); - } -} -*/ - - -Talk::Talk(CGEEngine *vm, const char *tx, TextBoxStyle mode) +Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode) : Sprite(vm, NULL), _mode(mode), _vm(vm) { _ts = NULL; _flags._syst = true; - update(tx); + update(text); } @@ -101,18 +88,6 @@ Talk::Talk(CGEEngine *vm) _flags._syst = true; } - -/* -Talk::~Talk() { - for (uint16 i = 0; i < ShpCnt; i++) { - if (FP_SEG(_shpList[i]) != _DS) { // small model: always false - delete _shpList[i]; - ShpList[i] = NULL; - } - } -} -*/ - Font *Talk::_font; void Talk::init() { @@ -124,17 +99,18 @@ void Talk::deinit() { } -void Talk::update(const char *tx) { +void Talk::update(const char *text) { uint16 vmarg = (_mode) ? kTextVMargin : 0; uint16 hmarg = (_mode) ? kTextHMargin : 0; - uint16 mw = 0, mh, ln = vmarg; + uint16 mw = 0; + uint16 ln = vmarg; const char *p; uint8 *m; if (!_ts) { uint16 k = 2 * hmarg; - mh = 2 * vmarg + kFontHigh; - for (p = tx; *p; p++) { + uint16 mh = 2 * vmarg + kFontHigh; + for (p = text; *p; p++) { if (*p == '|' || *p == '\n') { mh += kFontHigh + kTextLineSpace; if (k > mw) @@ -146,19 +122,19 @@ void Talk::update(const char *tx) { if (k > mw) mw = k; - _ts = new BMP_PTR[2]; + _ts = new BitmapPtr[2]; _ts[0] = box(mw, mh); _ts[1] = NULL; } m = _ts[0]->_m + ln * mw + hmarg; - while (* tx) { - if (*tx == '|' || *tx == '\n') + while (*text) { + if (*text == '|' || *text == '\n') m = _ts[0]->_m + (ln += kFontHigh + kTextLineSpace) * mw + hmarg; else { - int cw = _font->_wid[(unsigned char)*tx], i; - uint8 *f = _font->_map + _font->_pos[(unsigned char)*tx]; + int cw = _font->_wid[(unsigned char)*text], i; + uint8 *f = _font->_map + _font->_pos[(unsigned char)*text]; for (i = 0; i < cw; i++) { uint8 *pp = m; uint16 n; @@ -172,7 +148,7 @@ void Talk::update(const char *tx) { m++; } } - tx++; + text++; } _ts[0]->code(); setShapeList(_ts); @@ -239,7 +215,7 @@ void Talk::putLine(int line, const char *text) { // clear whole rectangle assert((rsiz % lsiz) == 0); - for (int planeCtr = 0; planeCtr < 4; ++planeCtr, p += psiz) { + for (int planeCtr = 0; planeCtr < 4; planeCtr++, p += psiz) { for (byte *pDest = p; pDest < (p + (rsiz - lsiz)); pDest += lsiz) Common::copy(p - lsiz, p, pDest); } @@ -273,9 +249,9 @@ void Talk::putLine(int line, const char *text) { } -InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldTxt(NULL), _vm(vm) { +InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm) { if (!_ts) { - _ts = new BMP_PTR[2]; + _ts = new BitmapPtr[2]; _ts[1] = NULL; } @@ -284,8 +260,8 @@ InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldTxt(NULL), _vm(vm) { } -void InfoLine::update(const char *tx) { - if (tx != _oldTxt) { +void InfoLine::update(const char *text) { + if (text != _oldText) { uint16 w = _ts[0]->_w; uint16 h = _ts[0]->_h; uint8 *v = (uint8 *) _ts[0]->_v; @@ -306,12 +282,12 @@ void InfoLine::update(const char *tx) { } // paint text line - if (tx) { + if (text) { uint8 *p = v + 2, * q = p + size; - while (*tx) { - uint16 cw = _font->_wid[(unsigned char)*tx]; - uint8 *fp = _font->_map + _font->_pos[(unsigned char)*tx]; + while (*text) { + uint16 cw = _font->_wid[(unsigned char)*text]; + uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text]; for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; @@ -324,10 +300,10 @@ void InfoLine::update(const char *tx) { if (p >= q) p = p - size + 1; } - tx++; + text++; } } - _oldTxt = tx; + _oldText = text; } } diff --git a/engines/cge/talk.h b/engines/cge/talk.h index d9c29261f6..71db57c887 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -66,10 +66,10 @@ public: class Talk : public Sprite { protected: TextBoxStyle _mode; - BMP_PTR *_ts; + BitmapPtr *_ts; Bitmap *box(uint16 w, uint16 h); public: - Talk(CGEEngine *vm, const char *tx, TextBoxStyle mode); + Talk(CGEEngine *vm, const char *text, TextBoxStyle mode); Talk(CGEEngine *vm); //~TALK(); @@ -77,7 +77,7 @@ public: static void init(); static void deinit(); - virtual void update(const char *tx); + virtual void update(const char *text); virtual void update() {} void putLine(int line, const char *text); private: @@ -85,10 +85,10 @@ private: }; class InfoLine : public Talk { - const char *_oldTxt; + const char *_oldText; public: InfoLine(CGEEngine *vm, uint16 wid); - void update(const char *tx); + void update(const char *text); private: CGEEngine *_vm; }; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index f688546810..485ba00ad1 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -40,13 +40,13 @@ Talk *_talk = NULL; Text::Text(CGEEngine *vm, const char *fname, int size) : _vm(vm) { _cache = new Han[size]; - mergeExt(_fileName, fname, SAY_EXT); + mergeExt(_fileName, fname, kSayExt); if (!INI_FILE::exist(_fileName)) error("No talk (%s)\n", _fileName); for (_size = 0; _size < size; _size++) { _cache[_size]._ref = 0; - _cache[_size]._txt = NULL; + _cache[_size]._text = NULL; } } @@ -62,8 +62,8 @@ void Text::clear(int from, int upto) { for (p = _cache, q = p + _size; p < q; p++) { if (p->_ref && p->_ref >= from && p->_ref < upto) { p->_ref = 0; - delete[] p->_txt; - p->_txt = NULL; + delete[] p->_text; + p->_text = NULL; } } } @@ -105,8 +105,8 @@ void Text::preload(int from, int upto) { p = &_cache[find(ref)]; if (p < CacheLim) { - delete[] p->_txt; - p->_txt = NULL; + delete[] p->_text; + p->_text = NULL; } else p = &_cache[find(0)]; if (p >= CacheLim) @@ -114,10 +114,10 @@ void Text::preload(int from, int upto) { s += strlen(s); if (s < line + n) ++s; - if ((p->_txt = new char[strlen(s) + 1]) == NULL) + if ((p->_text = new char[strlen(s) + 1]) == NULL) break; p->_ref = ref; - strcpy(p->_txt, s); + strcpy(p->_text, s); } } } @@ -151,9 +151,9 @@ char *Text::load(int idx, int ref) { if (s < line + n) ++s; p->_ref = ref; - if ((p->_txt = new char[strlen(s) + 1]) == NULL) + if ((p->_text = new char[strlen(s) + 1]) == NULL) return NULL; - return strcpy(p->_txt, s); + return strcpy(p->_text, s); } } return NULL; @@ -163,10 +163,10 @@ char *Text::load(int idx, int ref) { char *Text::getText(int ref) { int i; if ((i = find(ref)) < _size) - return _cache[i]._txt; + return _cache[i]._text; if ((i = find(0)) >= _size) { - clear(SYSTXT_MAX); // clear non-system + clear(kSysTextMax); // clear non-system if ((i = find(0)) >= _size) { clear(); // clear all i = 0; @@ -176,9 +176,9 @@ char *Text::getText(int ref) { } -void Text::say(const char *txt, Sprite *spr) { +void Text::say(const char *text, Sprite *spr) { killText(); - _talk = new Talk(_vm, txt, kTBRound); + _talk = new Talk(_vm, text, kTBRound); if (_talk) { bool east = spr->_flags._east; int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); @@ -217,11 +217,11 @@ void Text::say(const char *txt, Sprite *spr) { } } -void CGEEngine::inf(const char *txt) { - debugC(1, kCGEDebugEngine, "CGEEngine::inf(%s)", txt); +void CGEEngine::inf(const char *text) { + debugC(1, kCGEDebugEngine, "CGEEngine::inf(%s)", text); killText(); - _talk = new Talk(this, txt, kTBRect); + _talk = new Talk(this, text, kTBRect); if (_talk) { _talk->_flags._kill = true; _talk->_flags._bDel = true; diff --git a/engines/cge/text.h b/engines/cge/text.h index 196bfc4edb..6ed5b32b22 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -33,11 +33,9 @@ namespace CGE { -#ifndef SYSTXT_MAX -#define SYSTXT_MAX 1000 -#endif +#define kSysTextMax 1000 -#define SAY_EXT ".SAY" +#define kSayExt ".SAY" #define NOT_VGA_TEXT 90 #define BAD_CHIP_TEXT 91 @@ -54,7 +52,7 @@ namespace CGE { class Text { struct Han { int _ref; - char *_txt; + char *_text; } *_cache; int _size; char _fileName[kPathMax]; @@ -66,7 +64,7 @@ public: void clear(int from = 1, int upto = 0x7FFF); void preload(int from = 1, int upto = 0x7FFF); char *getText(int ref); - void say(const char *txt, Sprite *spr); + void say(const char *text, Sprite *spr); private: CGEEngine *_vm; }; @@ -74,9 +72,9 @@ private: extern Talk *_talk; extern Text *_text; -void say(const char *txt, Sprite *spr); +void say(const char *text, Sprite *spr); void sayTime(Sprite *spr); -void inf(const char *txt); +void inf(const char *text); void killText(); } // End of namespace CGE diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9b30e02e4d..cc715da03c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -211,7 +211,7 @@ Sprite *locate(int ref) { return (spr) ? spr : _vga->_spareQ->locate(ref); } -Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) +Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { @@ -234,7 +234,7 @@ Sprite::~Sprite() { } -BMP_PTR Sprite::shp() { +BitmapPtr Sprite::shp() { register SprExt *e = _ext; if (e) if (e->_seq) { @@ -252,17 +252,17 @@ BMP_PTR Sprite::shp() { } -BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { - BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; +BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { + BitmapPtr *r = (_ext) ? _ext->_shpList : NULL; _shpCnt = 0; _w = 0; _h = 0; if (shpP) { - BMP_PTR *p; + BitmapPtr *p; for (p = shpP; *p; p++) { - BMP_PTR b = (*p); // ->Code(); + BitmapPtr b = (*p); // ->Code(); if (b->_w > _w) _w = b->_w; if (b->_h > _h) @@ -280,7 +280,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { void Sprite::moveShapes(uint8 *buf) { - BMP_PTR *p; + BitmapPtr *p; for (p = _ext->_shpList; *p; p++) { buf += (*p)->moveVmap(buf); } @@ -336,16 +336,16 @@ Snail::Com *Sprite::snList(SnList type) { } -void Sprite::setName(char *n) { +void Sprite::setName(char *name) { if (_ext) { if (_ext->_name) { delete[] _ext->_name; _ext->_name = NULL; } - if (n) { - _ext->_name = new char[strlen(n) + 1]; + if (name) { + _ext->_name = new char[strlen(name) + 1]; assert(_ext->_name != NULL); - strcpy(_ext->_name, n); + strcpy(_ext->_name, name); } } } @@ -358,7 +358,7 @@ Sprite *Sprite::expand() { if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[kLineMax], fname[kPathMax]; - BMP_PTR *shplist = new BMP_PTR[_shpCnt + 1]; + BitmapPtr *shplist = new BitmapPtr[_shpCnt + 1]; Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -419,7 +419,7 @@ Sprite *Sprite::expand() { nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); assert(nea != NULL); Snail::Com *c = &nea[neacnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); @@ -432,7 +432,7 @@ Sprite *Sprite::expand() { tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); assert(tak != NULL); Snail::Com *c = &tak[takcnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); @@ -528,7 +528,7 @@ void Sprite::tick() { void Sprite::makeXlat(uint8 *x) { if (_ext) { - BMP_PTR *b; + BitmapPtr *b; if (_flags._xlat) killXlat(); @@ -541,7 +541,7 @@ void Sprite::makeXlat(uint8 *x) { void Sprite::killXlat() { if (_flags._xlat && _ext) { - BMP_PTR *b; + BitmapPtr *b; uint8 *m = (*_ext->_shpList)->_m; free(m); @@ -616,10 +616,10 @@ void Sprite::hide() { } -BMP_PTR Sprite::ghost() { +BitmapPtr Sprite::ghost() { register SprExt *e = _ext; if (e->_b1) { - BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL); + BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL); assert(bmp != NULL); bmp->_w = e->_b1->_w; bmp->_h = e->_b1->_h; @@ -785,37 +785,35 @@ Graphics::Surface *Vga::_page[4]; Dac *Vga::_sysPal; void Vga::init() { - for (int idx = 0; idx < 4; ++idx) { + for (int idx = 0; idx < 4; idx++) { _page[idx] = new Graphics::Surface(); _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - _sysPal = new Dac[PAL_CNT]; + _sysPal = new Dac[kPalCount]; } void Vga::deinit() { - for (int idx = 0; idx < 4; ++idx) { + for (int idx = 0; idx < 4; idx++) { _page[idx]->free(); delete _page[idx]; } - delete[] _sysPal; } Vga::Vga(int mode) : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), - _msg(NULL), _nam(NULL), _setPal(false), _mono(0) { + _msg(NULL), _name(NULL), _setPal(false), _mono(0) { _oldColors = NULL; _newColors = NULL; _showQ = new Queue(true); _spareQ = new Queue(false); bool std = true; - int i; - for (i = 10; i < 20; i++) { - char *txt = _text->getText(i); - if (txt) { - debugN("%s", txt); + for (int i = 10; i < 20; i++) { + char *text = _text->getText(i); + if (text) { + debugN("%s", text); std = false; } } @@ -826,8 +824,8 @@ Vga::Vga(int mode) setStatAdr(); if (_statAdr != VGAST1_) _mono++; - _oldColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT); - _newColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT); + _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount); + _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount); _oldScreen = SaveScreen(); getColors(_oldColors); sunset(); @@ -853,8 +851,8 @@ Vga::~Vga() { free(_newColors); if (_msg) buffer = Common::String(_msg); - if (_nam) - buffer = buffer + " [" + _nam + "]"; + if (_name) + buffer = buffer + " [" + _name + "]"; debugN("%s", buffer.c_str()); @@ -936,14 +934,14 @@ int Vga::setMode(int mode) { void Vga::getColors(Dac *tab) { - byte palData[PAL_SIZ]; - g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT); + byte palData[kPalSize]; + g_system->getPaletteManager()->grabPalette(palData, 0, kPalCount); palToDac(palData, tab); } void Vga::palToDac(const byte *palData, Dac *tab) { const byte *colP = palData; - for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { + for (int idx = 0; idx < kPalCount; idx++, colP += 3) { tab[idx]._r = *colP >> 2; tab[idx]._g = *(colP + 1) >> 2; tab[idx]._b = *(colP + 2) >> 2; @@ -951,7 +949,7 @@ void Vga::palToDac(const byte *palData, Dac *tab) { } void Vga::dacToPal(const Dac *tab, byte *palData) { - for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { + for (int idx = 0; idx < kPalCount; idx++, palData += 3) { *palData = tab[idx]._r << 2; *(palData + 1) = tab[idx]._g << 2; *(palData + 2) = tab[idx]._b << 2; @@ -960,7 +958,7 @@ void Vga::dacToPal(const Dac *tab, byte *palData) { void Vga::setColors(Dac *tab, int lum) { Dac *palP = tab, *destP = _newColors; - for (int idx = 0; idx < PAL_CNT; ++idx, ++palP, ++destP) { + for (int idx = 0; idx < kPalCount; idx++, palP++, destP++) { destP->_r = (palP->_r * lum) >> 6; destP->_g = (palP->_g * lum) >> 6; destP->_b = (palP->_b * lum) >> 6; @@ -968,7 +966,7 @@ void Vga::setColors(Dac *tab, int lum) { if (_mono) { destP = _newColors; - for (int idx = 0; idx < PAL_CNT; ++idx, ++destP) { + for (int idx = 0; idx < kPalCount; idx++, destP++) { // Form a greyscalce colour from 30% R, 59% G, 11% B uint8 intensity = (((int)destP->_r * 77) + ((int)destP->_g * 151) + ((int)destP->_b * 28)) >> 8; destP->_r = intensity; @@ -982,7 +980,7 @@ void Vga::setColors(Dac *tab, int lum) { void Vga::setColors() { - memset(_newColors, 0, PAL_SIZ); + memset(_newColors, 0, kPalSize); updateColors(); } @@ -1021,7 +1019,7 @@ void Vga::show() { void Vga::updateColors() { - byte palData[PAL_SIZ]; + byte palData[kPalSize]; dacToPal(_newColors, palData); g_system->getPaletteManager()->setPalette(palData, 0, 256); } @@ -1041,7 +1039,7 @@ void Vga::update() { void Vga::clear(uint8 color) { - for (int paneNum = 0; paneNum < 4; ++paneNum) + for (int paneNum = 0; paneNum < 4; paneNum++) _page[paneNum]->fillRect(Common::Rect(0, 0, kScrWidth, kScrHeight), color); } @@ -1062,7 +1060,7 @@ void Bitmap::xShow(int16 x, int16 y) { // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface - for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { + for (int planeCtr = 0; planeCtr < 4; planeCtr++) { byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); for (;;) { @@ -1079,7 +1077,7 @@ void Bitmap::xShow(int16 x, int16 y) { assert(destP < destEndP); if (cmd == 2) - ++srcP; + srcP++; else if (cmd == 3) srcP += count; @@ -1114,7 +1112,7 @@ void Bitmap::show(int16 x, int16 y) { // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface - for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { + for (int planeCtr = 0; planeCtr < 4; planeCtr++) { byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); for (;;) { @@ -1152,7 +1150,7 @@ void Bitmap::show(int16 x, int16 y) { } if (cmd == 2) - ++srcP; + srcP++; } } /* @@ -1184,7 +1182,7 @@ void Bitmap::hide(int16 x, int16 y) { HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *HL = new BMP_PTR[2]; + BitmapPtr *HL = new BitmapPtr[2]; HL[0] = new Bitmap("HLINE", true); HL[1] = NULL; @@ -1193,7 +1191,7 @@ HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *PR = new BMP_PTR[2]; + BitmapPtr *PR = new BitmapPtr[2]; PR[0] = new Bitmap("PRESS", true); PR[1] = NULL; @@ -1202,7 +1200,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *SP = new BMP_PTR[3]; + BitmapPtr *SP = new BitmapPtr[3]; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; @@ -1212,7 +1210,7 @@ Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *LI = new BMP_PTR[5]; + BitmapPtr *LI = new BitmapPtr[5]; LI[0] = new Bitmap("LITE0", true); LI[1] = new Bitmap("LITE1", true); LI[2] = new Bitmap("LITE2", true); diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 15da63efbc..f72d4c693d 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -99,33 +99,32 @@ extern Seq _seq2[]; //extern SEQ * Compass[]; //extern SEQ TurnToS[]; -#define PAL_CNT 256 -#define PAL_SIZ (PAL_CNT * 3) +#define kPalCount 256 +#define kPalSize (kPalCount * 3) + #define VGAATR_ 0x3C0 -#define VGAMIw_ 0x3C0 #define VGASEQ_ 0x3C4 -#define VGAMIr_ 0x3CC #define VGAGRA_ 0x3CE #define VGACRT_ 0x3D4 #define VGAST1_ 0x3DA #define VGAATR (VGAATR_ & 0xFF) -#define VGAMIw (VGAMIw_ & 0xFF) #define VGASEQ (VGASEQ_ & 0xFF) -#define VGAMIr (VGAMIr_ & 0xFF) #define VGAGRA (VGAGRA_ & 0xFF) #define VGACRT (VGACRT_ & 0xFF) -#define VGAST1 (VGAST1_ & 0xFF) - class SprExt { public: - int _x0, _y0; - int _x1, _y1; - BMP_PTR _b0, _b1; - BMP_PTR *_shpList; + int _x0; + int _y0; + int _x1; + int _y1; + BitmapPtr _b0; + BitmapPtr _b1; + BitmapPtr *_shpList; Seq *_seq; char *_name; - Snail::Com *_near, *_take; + Snail::Com *_near; + Snail::Com *_take; SprExt() : _x0(0), _y0(0), _x1(0), _y1(0), @@ -179,15 +178,16 @@ public: inline bool active() { return _ext != NULL; } - Sprite(CGEEngine *vm, BMP_PTR *shp); + + Sprite(CGEEngine *vm, BitmapPtr *shp); virtual ~Sprite(); - BMP_PTR shp(); - BMP_PTR *setShapeList(BMP_PTR *shp); + BitmapPtr shp(); + BitmapPtr *setShapeList(BitmapPtr *shp); void moveShapes(uint8 *buf); Sprite *expand(); Sprite *contract(); Sprite *backShow(bool fast = false); - void setName(char *n); + void setName(char *name); inline char *name() { return (_ext) ? _ext->_name : NULL; } @@ -195,7 +195,7 @@ public: void center(); void show(); void hide(); - BMP_PTR ghost(); + BitmapPtr ghost(); void show(uint16 pg); void makeXlat(uint8 *x); void killXlat(); @@ -243,7 +243,7 @@ class Vga { Dac *_oldColors; Dac *_newColors; const char *_msg; - const char *_nam; + const char *_name; int setMode(int mode); void updateColors(); diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 934bd6299d..e8aa899583 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -48,7 +48,7 @@ MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { p2 -= w; } - _ts = new BMP_PTR[2]; + _ts = new BitmapPtr[2]; _ts[0] = new Bitmap(w, h, p); _ts[1] = NULL; setShapeList(_ts); diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index e2c62513dd..a9eeb6db8e 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -32,7 +32,7 @@ namespace CGE { Walk *_hero; -uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; +uint8 Cluster::_map[kMapZCnt][kMapXCnt]; CGEEngine *Cluster::_vm; void Cluster::init(CGEEngine *vm) { @@ -44,22 +44,22 @@ uint8 &Cluster::cell() { } bool Cluster::isValid() const { - return (_a >= 0) && (_a < MAP_XCNT) && (_b >= 0) && (_b < MAP_ZCNT); + return (_a >= 0) && (_a < kMapXCnt) && (_b >= 0) && (_b < kMapZCnt); } bool Cluster::chkBar() const { - assert(_vm->_now <= _vm->CAVE_MAX); + assert(_vm->_now <= _vm->_caveMax); return (_a == _vm->_barriers[_vm->_now]._horz) && (_b == _vm->_barriers[_vm->_now]._vert); } Cluster XZ(int x, int y) { - if (y < MAP_TOP) - y = MAP_TOP; + if (y < kMapTop) + y = kMapTop; - if (y > MAP_TOP + MAP_HIG - MAP_ZGRID) - y = MAP_TOP + MAP_HIG - MAP_ZGRID; + if (y > kMapTop + kMapHig - kMapGridZ) + y = kMapTop + kMapHig - kMapGridZ; - return Cluster(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID); + return Cluster(x / kMapGridX, (y - kMapTop) / kMapGridZ); } @@ -69,8 +69,8 @@ Cluster XZ(Couple xy) { return XZ(x, y); } -Walk::Walk(CGEEngine *vm, BMP_PTR *shpl) - : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _level(0), _vm(vm) { +Walk::Walk(CGEEngine *vm, BitmapPtr *shpl) + : Sprite(vm, shpl), _dir(kDirNone), _tracePtr(-1), _level(0), _vm(vm) { } @@ -80,7 +80,7 @@ void Walk::tick() { _here = XZ(_x + _w / 2, _y + _h); - if (Dir != NO_DIR) { + if (_dir != kDirNone) { Sprite *spr; _sys->funTouch(); for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { @@ -104,14 +104,14 @@ void Walk::tick() { } else { signed char dx, dz; (_trace[_tracePtr] - _here).split(dx, dz); - DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN); + Dir d = (dx) ? ((dx > 0) ? kDirEast : kDirWest) : ((dz > 0) ? kDirSouth : kDirNorth); turn(d); } } step(); - if ((Dir == WW && _x <= 0) || - (Dir == EE && _x + _w >= kScrWidth) || - (Dir == SS && _y + _w >= kWorldHeight - 2)) + if ((_dir == kDirWest && _x <= 0) || + (_dir == kDirEast && _x + _w >= kScrWidth) || + (_dir == kDirSouth && _y + _w >= kWorldHeight - 2)) park(); else { signed char x; // dummy var @@ -130,7 +130,7 @@ int Walk::distance(Sprite *spr) { if (dx < 0) dx = 0; - dx /= MAP_XGRID; + dx /= kMapGridX; dz = spr->_z - _z; if (dz < 0) dz = - dz; @@ -143,22 +143,22 @@ int Walk::distance(Sprite *spr) { } -void Walk::turn(DIR d) { - DIR dir = (Dir == NO_DIR) ? SS : Dir; - if (d != Dir) { +void Walk::turn(Dir d) { + Dir dir = (_dir == kDirNone) ? kDirSouth : _dir; + if (d != _dir) { step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d)); - Dir = d; + _dir = d; } } void Walk::park() { if (_time == 0) - ++_time; + _time++; - if (Dir != NO_DIR) { - step(9 + 4 * Dir + Dir); - Dir = NO_DIR; + if (_dir != kDirNone) { + step(9 + 4 * _dir + _dir); + _dir = kDirNone; _tracePtr = -1; } } @@ -166,7 +166,7 @@ void Walk::park() { void Walk::findWay(Cluster c) { if (c != _here) { - for (_findLevel = 1; _findLevel <= MAX_FIND_LEVEL; _findLevel++) { + for (_findLevel = 1; _findLevel <= kMaxFindLevel; _findLevel++) { signed char x, z; _here.split(x, z); _target = Couple(x, z); @@ -175,7 +175,7 @@ void Walk::findWay(Cluster c) { if (find1Way(Cluster(x, z))) break; } - _tracePtr = (_findLevel > MAX_FIND_LEVEL) ? -1 : (_findLevel - 1); + _tracePtr = (_findLevel > kMaxFindLevel) ? -1 : (_findLevel - 1); if (_tracePtr < 0) noWay(); _time = 1; @@ -191,8 +191,8 @@ void Walk::findWay(Sprite *spr) { x += spr->_w + _w / 2 - kWalkSide; else x -= _w / 2 - kWalkSide; - findWay(Cluster((x / MAP_XGRID), - ((z < MAP_ZCNT - kDistMax) ? (z + 1) + findWay(Cluster((x / kMapGridX), + ((z < kMapZCnt - kDistMax) ? (z + 1) : (z - 1)))); } } @@ -250,7 +250,7 @@ bool Walk::find1Way(Cluster c) { // Loop through each direction - for (int i = 0; i < tabLen; ++i) { + for (int i = 0; i < tabLen; i++) { // Reset to starting position c = start; diff --git a/engines/cge/walk.h b/engines/cge/walk.h index 15ea9ee0ce..115cb4924a 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -34,13 +34,15 @@ namespace CGE { -#define MAP_XCNT 40 -#define MAP_ZCNT 20 -#define MAP_TOP 80 -#define MAP_HIG 80 -#define MAP_XGRID (kScrWidth / MAP_XCNT) -#define MAP_ZGRID (MAP_HIG / MAP_ZCNT) -#define MAX_FIND_LEVEL 3 +#define kMapXCnt 40 +#define kMapZCnt 20 +#define kMapTop 80 +#define kMapHig 80 +#define kMapGridX (kScrWidth / kMapXCnt) +#define kMapGridZ (kMapHig / kMapZCnt) +#define kMaxFindLevel 3 + +enum Dir { kDirNone = -1, kDirNorth, kDirEast, kDirSouth, kDirWest }; class Couple { protected: @@ -83,7 +85,7 @@ public: class Cluster : public Couple { public: - static uint8 _map[MAP_ZCNT][MAP_XCNT]; + static uint8 _map[kMapZCnt][kMapXCnt]; static CGEEngine *_vm; static void init(CGEEngine *vm); @@ -106,15 +108,15 @@ public: int _level; int _findLevel; Couple _target; - Cluster _trace[MAX_FIND_LEVEL]; + Cluster _trace[kMaxFindLevel]; - enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; - Walk(CGEEngine *vm, BMP_PTR *shpl); + Dir _dir; + Walk(CGEEngine *vm, BitmapPtr *shpl); void tick(); void findWay(Cluster c); void findWay(Sprite *spr); int distance(Sprite *spr); - void turn(DIR d); + void turn(Dir d); void park(); bool lower(Sprite *spr); void reach(Sprite *spr, int mode = -1); diff --git a/engines/cge/wav.h b/engines/cge/wav.h index 739e102959..bd9fc96b0a 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -41,20 +41,20 @@ typedef char FourCC[4]; // Four-character code class ChunkId { // Chunk type identifier union { - FourCC _tx; + FourCC _text; uint32 _id; }; protected: static XFile *ckFile; public: - ChunkId(FourCC t) { - memcpy(_tx, t, sizeof(_tx)); + ChunkId(FourCC text) { + memcpy(_text, text, sizeof(_text)); } ChunkId(uint32 d) { _id = d; } ChunkId(XFile *xf) { - (ckFile = xf)->read(_tx, sizeof(_tx)); + (ckFile = xf)->read(_text, sizeof(_text)); } bool operator !=(ChunkId &X) { return _id != X._id; @@ -116,7 +116,7 @@ public: class DataCk : public CkHea { - bool _e; + bool _ef; uint8 *_buf; public: DataCk(CkHea &hea); -- cgit v1.2.3 From f898da53a48ff9d3dbb5f23ca3aa58ff37181edd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Jul 2011 09:38:08 +0200 Subject: CGE: Improve keyboard behavior for non-US layouts --- engines/cge/events.cpp | 11 ++++++++--- engines/cge/events.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 1c2738f62e..e2aaaa587d 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -99,11 +99,16 @@ Sprite *Keyboard::setClient(Sprite *spr) { return spr; } -bool Keyboard::getKey(uint16 keycode, int &cgeCode) { +bool Keyboard::getKey(Common::Event &event, int &cgeCode) { + Common::KeyCode keycode = event.kbd.keycode; if ((keycode == Common::KEYCODE_LCTRL) || (keycode == Common::KEYCODE_RCTRL)) { cgeCode = 29; return true; } + if ((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT)) { + cgeCode = 56; + return true; + } if (keycode == Common::KEYCODE_KP_ENTER) { cgeCode = 28; return true; @@ -111,7 +116,7 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) { // Scan through the ScummVM mapping list for (int idx = 0; idx < 0x60; idx++) { - if (_scummVmCodes[idx] == keycode) { + if (_scummVmCodes[idx] == event.kbd.ascii) { cgeCode = idx; return true; } @@ -122,7 +127,7 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) { void Keyboard::newKeyboard(Common::Event &event) { int keycode; - if (!getKey(event.kbd.keycode, keycode)) + if (!getKey(event, keycode)) return; if (event.type == Common::EVENT_KEYUP) { diff --git a/engines/cge/events.h b/engines/cge/events.h index 671878f69a..2d85574bd7 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -47,7 +47,7 @@ namespace CGE { class Keyboard { private: - bool getKey(uint16 keycode, int &cgeCode); + bool getKey(Common::Event &event, int &cgeCode); public: static const uint16 _code[0x60]; static const uint16 _scummVmCodes[0x60]; -- cgit v1.2.3 From c053762c6398c7d818d5c7f319877c4b1e712070 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Jul 2011 19:56:14 +0200 Subject: CGE: Replace magic values by defines, rename some defines --- engines/cge/cge_main.cpp | 12 ++++++------ engines/cge/events.cpp | 4 ++-- engines/cge/events.h | 9 ++------- engines/cge/gettext.cpp | 2 +- engines/cge/snail.cpp | 2 +- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 37449fd5dd..302a25a3d5 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -737,13 +737,13 @@ void System::touch(uint16 mask, int x, int y) { pp0 = pp; switch (x) { case Del: - if (_keyboard->_key[ALT] && _keyboard->_key[CTRL]) + if (_keyboard->_key[kKeyAlt] && _keyboard->_key[kKeyCtrl]) _vm->AltCtrlDel(); else _vm->killSprite(); break; case 'F': - if (_keyboard->_key[ALT]) { + if (_keyboard->_key[kKeyAlt]) { Sprite *m = _vga->_showQ->locate(17001); if (m) { m->step(1); @@ -761,7 +761,7 @@ void System::touch(uint16 mask, int x, int y) { _vm->nextStep(); break; case '`': - if (_keyboard->_key[ALT]) + if (_keyboard->_key[kKeyAlt]) _vm->saveMapping(); else _vm->switchMapping(); @@ -791,7 +791,7 @@ void System::touch(uint16 mask, int x, int y) { _sys->_funDel = 1; break; case 'X': - if (_keyboard->_key[ALT]) + if (_keyboard->_key[kKeyAlt]) _finis = true; break; case '0': @@ -799,7 +799,7 @@ void System::touch(uint16 mask, int x, int y) { case '2': case '3': case '4': - if (_keyboard->_key[ALT]) { + if (_keyboard->_key[kKeyAlt]) { _snail->addCom(kSnLevel, -1, x - '0', NULL); break; } @@ -917,7 +917,7 @@ void CGEEngine::switchColorMode() { void CGEEngine::switchMusic() { debugC(1, kCGEDebugEngine, "CGEEngine::switchMusic()"); - if (_keyboard->_key[ALT]) { + if (_keyboard->_key[kKeyAlt]) { if (Vmenu::_addr) _snail_->addCom(kSnKill, -1, 0, Vmenu::_addr); else { diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index e2aaaa587d..119390944e 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -102,11 +102,11 @@ Sprite *Keyboard::setClient(Sprite *spr) { bool Keyboard::getKey(Common::Event &event, int &cgeCode) { Common::KeyCode keycode = event.kbd.keycode; if ((keycode == Common::KEYCODE_LCTRL) || (keycode == Common::KEYCODE_RCTRL)) { - cgeCode = 29; + cgeCode = kKeyCtrl; return true; } if ((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT)) { - cgeCode = 56; + cgeCode = kKeyAlt; return true; } if (keycode == Common::KEYCODE_KP_ENTER) { diff --git a/engines/cge/events.h b/engines/cge/events.h index 2d85574bd7..3b4ff2092f 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -38,12 +38,8 @@ namespace CGE { /*----------------- KEYBOARD interface -----------------*/ -#define KEYBD_INT 9 -#define LSHIFT 42 -#define RSHIFT 54 -#define CTRL 29 -#define ALT 56 - +#define kKeyCtrl 29 +#define kKeyAlt 56 class Keyboard { private: @@ -79,7 +75,6 @@ public: #define ATTN 0x20 // 0x40 #define KEYB 0x80 - extern Talk *_talk; struct CGEEvent { diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index f64f4b2619..a2408bc792 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -103,7 +103,7 @@ void GetText::touch(uint16 mask, int x, int y) { if (_oldKeybClient) _oldKeybClient->touch(mask, x, y); } else { - if (_keyboard->_key[ALT]) { + if (_keyboard->_key[kKeyAlt]) { p = strchr(bezo, x); if (p) x = ogon[p - bezo]; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 03cb43f4f1..e188f76650 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -153,7 +153,7 @@ void CGEEngine::snGame(Sprite *spr, int num) { _sprK2->step(new_random(6)); _sprK3->step(new_random(6)); ///-------------------- - if (spr->_ref == 1 && _keyboard->_key[ALT]) { + if (spr->_ref == 1 && _keyboard->_key[kKeyAlt]) { _sprK1->step(5); _sprK2->step(5); _sprK3->step(5); -- cgit v1.2.3 From 88f6cc9b234432b068a6bd7e18ed92696dc95176 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Aug 2011 09:53:15 +0200 Subject: CGE: Clean eventManager --- engines/cge/cge_main.cpp | 2 +- engines/cge/events.cpp | 90 +++++++++++++++++++++++++----------------------- engines/cge/events.h | 20 ++++++----- engines/cge/snail.cpp | 2 +- 4 files changed, 59 insertions(+), 55 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 302a25a3d5..1198946a41 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1696,7 +1696,7 @@ bool CGEEngine::showTitle(const char *name) { if (_eventManager->_quitFlag) return false; } - if (_keyboard->last() == Enter && *_usrFnam) + if (_keyboard->lastKey() == Enter && *_usrFnam) userOk = true; } //Mouse.Off(); diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 119390944e..113b64cee8 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -33,10 +33,6 @@ namespace CGE { -CGEEvent Evt[EVT_MAX]; - -uint16 EvtHead = 0, EvtTail = 0; - /*----------------- KEYBOARD interface -----------------*/ const uint16 Keyboard::_code[0x60] = { @@ -85,8 +81,7 @@ const uint16 Keyboard::_scummVmCodes[0x60] = { 0 }; -Keyboard::Keyboard() { - _client = NULL; +Keyboard::Keyboard() : _client(NULL) { Common::set_to(&_key[0], &_key[0x60], false); _current = 0; } @@ -139,15 +134,20 @@ void Keyboard::newKeyboard(Common::Event &event) { _current = Keyboard::_code[keycode]; if (_client) { - CGEEvent &evt = Evt[EvtHead]; - EvtHead = (EvtHead + 1) % EVT_MAX; + CGEEvent &evt = _eventManager->getNextEvent(); evt._x = _current; // Keycode - evt._msk = KEYB; // Event mask - evt._ptr = _client; // Sprite pointer + evt._mask = KEYB; // Event mask + evt._spritePtr = _client; // Sprite pointer } } } +uint16 Keyboard::lastKey() { + uint16 cur = _current; + _current = 0; + return cur; +} + /*----------------- MOUSE interface -----------------*/ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) { @@ -185,11 +185,6 @@ Mouse::~Mouse() { } -//void Mouse::setFun() -//{ -//} - - void Mouse::on() { if (_seqPtr && _exist) { _active = true; @@ -216,30 +211,29 @@ void Mouse::newMouse(Common::Event &event) { if (!_active) return; - CGEEvent &evt = Evt[EvtHead]; - EvtHead = (EvtHead + 1) % EVT_MAX; + CGEEvent &evt = _eventManager->getNextEvent(); evt._x = event.mouse.x; evt._y = event.mouse.y; - evt._ptr = spriteAt(evt._x, evt._y); + evt._spritePtr = spriteAt(evt._x, evt._y); switch (event.type) { case Common::EVENT_MOUSEMOVE: - evt._msk = ROLL; + evt._mask = ROLL; break; case Common::EVENT_LBUTTONDOWN: - evt._msk = L_DN; + evt._mask = L_DN; _buttons |= 1; break; case Common::EVENT_LBUTTONUP: - evt._msk = L_UP; + evt._mask = L_UP; _buttons &= ~1; break; case Common::EVENT_RBUTTONDOWN: - evt._msk = R_DN; + evt._mask = R_DN; _buttons |= 2; break; case Common::EVENT_RBUTTONUP: - evt._msk = R_UP; + evt._mask = R_UP; _buttons &= ~2; break; default: @@ -251,6 +245,8 @@ void Mouse::newMouse(Common::Event &event) { EventManager::EventManager() { _quitFlag = false; + _eventQueueHead = 0; + _eventQueueTail = 0; } void EventManager::poll() { @@ -282,27 +278,27 @@ void EventManager::poll() { } void EventManager::handleEvents() { - while (EvtTail != EvtHead) { - CGEEvent e = Evt[EvtTail]; - if (e._msk) { - if (_mouse->_hold && e._ptr != _mouse->_hold) - _mouse->_hold->touch(e._msk | ATTN, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y); + while (_eventQueueTail != _eventQueueHead) { + CGEEvent e = _eventQueue[_eventQueueTail]; + if (e._mask) { + if (_mouse->_hold && e._spritePtr != _mouse->_hold) + _mouse->_hold->touch(e._mask | ATTN, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y); // update mouse cursor position - if (e._msk & ROLL) + if (e._mask & ROLL) _mouse->gotoxy(e._x, e._y); // activate current touched SPRITE - if (e._ptr) { - if (e._msk & KEYB) - e._ptr->touch(e._msk, e._x, e._y); + if (e._spritePtr) { + if (e._mask & KEYB) + e._spritePtr->touch(e._mask, e._x, e._y); else - e._ptr->touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y); + e._spritePtr->touch(e._mask, e._x - e._spritePtr->_x, e._y - e._spritePtr->_y); } else if (_sys) - _sys->touch(e._msk, e._x, e._y); + _sys->touch(e._mask, e._x, e._y); - if (e._msk & L_DN) { - _mouse->_hold = e._ptr; + if (e._mask & L_DN) { + _mouse->_hold = e._spritePtr; if (_mouse->_hold) { _mouse->_hold->_flags._hold = true; @@ -313,7 +309,7 @@ void EventManager::handleEvents() { } } - if (e._msk & L_UP) { + if (e._mask & L_UP) { if (_mouse->_hold) { _mouse->_hold->_flags._hold = false; _mouse->_hold = NULL; @@ -322,10 +318,10 @@ void EventManager::handleEvents() { ///Touched = e.Ptr; // discard Text if button released - if (e._msk & (L_UP | R_UP)) + if (e._mask & (L_UP | R_UP)) killText(); } - EvtTail = (EvtTail + 1) % EVT_MAX; + _eventQueueTail = (_eventQueueTail + 1) % EVT_MAX; } if (_mouse->_hold) { if (_mouse->_hold->_flags._drag) @@ -333,14 +329,20 @@ void EventManager::handleEvents() { } } -void EventManager::clrEvt(Sprite *spr) { +void EventManager::clearEvent(Sprite *spr) { if (spr) { uint16 e; - for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) - if (Evt[e]._ptr == spr) - Evt[e]._msk = 0; + for (e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % EVT_MAX) + if (_eventQueue[e]._spritePtr == spr) + _eventQueue[e]._mask = 0; } else - EvtTail = EvtHead; + _eventQueueTail = _eventQueueHead; } +CGEEvent &EventManager::getNextEvent() { + CGEEvent &evt = _eventQueue[_eventQueueHead]; + _eventQueueHead = (_eventQueueHead + 1) % EVT_MAX; + + return evt; +} } // End of namespace CGE diff --git a/engines/cge/events.h b/engines/cge/events.h index 3b4ff2092f..b213caed3c 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -44,20 +44,16 @@ namespace CGE { class Keyboard { private: bool getKey(Common::Event &event, int &cgeCode); + uint16 _current; public: static const uint16 _code[0x60]; static const uint16 _scummVmCodes[0x60]; - uint16 _current; Sprite *_client; bool _key[0x60]; void newKeyboard(Common::Event &event); - uint16 last() { - uint16 cur = _current; - _current = 0; - return cur; - } + uint16 lastKey(); Sprite *setClient(Sprite *spr); Keyboard(); @@ -78,10 +74,10 @@ public: extern Talk *_talk; struct CGEEvent { - uint16 _msk; + uint16 _mask; uint16 _x; uint16 _y; - Sprite *_ptr; + Sprite *_spritePtr; }; @@ -109,13 +105,19 @@ private: class EventManager { private: Common::Event _event; + CGEEvent _eventQueue[EVT_MAX]; + uint16 _eventQueueHead; + uint16 _eventQueueTail; + void handleEvents(); public: bool _quitFlag; EventManager(); void poll(); - static void clrEvt(Sprite *spr = NULL); + void clearEvent(Sprite *spr); + + CGEEvent &getNextEvent(); }; } // End of namespace CGE diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index e188f76650..aece48a933 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -771,7 +771,7 @@ void CGEEngine::snKill(Sprite *spr) { Sprite *nx = spr->_next; hide1(spr); _vga->_showQ->remove(spr); - EventManager::clrEvt(spr); + _eventManager->clearEvent(spr); if (spr->_flags._kill) delete spr; else { -- cgit v1.2.3 From 6f92cdd0d0e124653c4164c7ab0f91e5b910f6bc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 2 Aug 2011 21:47:56 +0200 Subject: CGE: Rename some more defines --- engines/cge/bitmap.cpp | 4 +- engines/cge/cge.h | 6 +- engines/cge/cge_main.cpp | 152 ++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 19 ++++-- engines/cge/detection.cpp | 12 ++-- engines/cge/events.cpp | 30 ++++----- engines/cge/events.h | 22 ++++--- engines/cge/game.cpp | 10 +-- engines/cge/general.cpp | 2 +- engines/cge/general.h | 2 +- engines/cge/gettext.cpp | 2 +- engines/cge/jbw.h | 1 - engines/cge/mixer.cpp | 4 +- engines/cge/snail.cpp | 21 ++----- engines/cge/text.cpp | 12 ++-- engines/cge/text.h | 15 ++--- engines/cge/vmenu.cpp | 2 +- 17 files changed, 150 insertions(+), 166 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index ddde3bbd21..63f7c0dadf 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -63,11 +63,11 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { #endif { #if (BMP_MODE) - ForceExt(pat, fname, ".BMP"); + forceExt(pat, fname, ".BMP"); PIC_FILE file(pat); if (file._error == 0) { if (loadBMP(&file)) { - Code(); + code(); if (rem) { free(_m); _m = NULL; diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 7adc44fac6..54ea9e37f6 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -40,7 +40,8 @@ namespace CGE { class Console; class Sprite; -#define CGE_SAVEGAME_VERSION 1 +#define kSavegameVersion 1 +#define kSavegameStrSize 11 #define kPocketX 174 #define kPocketY 176 #define kPocketDX 18 @@ -75,8 +76,7 @@ struct SavegameHeader { int totalFrames; }; -extern const char *SAVEGAME_STR; -#define SAVEGAME_STR_SIZE 11 +extern const char *savegameStr; struct Bar { uint8 _horz; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 1198946a41..cbba280ff8 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -54,13 +54,7 @@ namespace CGE { -#define STACK_SIZ 2048 -#define SVGCHKSUM (1956 + _now + _oldLev + _game + _music + _demoText) - -#define SVG0NAME ("{{INIT}}" kSvgExt) -#define SVG0FILE INI_FILE - -uint16 _stklen = (STACK_SIZ * 2); +uint16 _stklen = (kStackSize * 2); Vga *_vga; System *_sys; @@ -90,8 +84,7 @@ Sound *_sound; // 1.01 - 17VII95 - default savegame with sound ON // coditionals EVA for 2-month evaluation version -const char *SAVEGAME_STR = "SCUMMVM_CGE"; -#define SAVEGAME_STR_SIZE 11 +const char *savegameStr = "SCUMMVM_CGE"; //-------------------------------------------------------------------------- @@ -137,13 +130,13 @@ void CGEEngine::syncHeader(Common::Serializer &s) { if (s.isSaving()) { // Write checksum - int checksum = SVGCHKSUM; + int checksum = kSavegameCheckSum; s.syncAsUint16LE(checksum); } else { // Read checksum and validate it uint16 checksum; s.syncAsUint16LE(checksum); - if (checksum != SVGCHKSUM) + if (checksum != kSavegameCheckSum) error("%s", _text->getText(kBadSVG)); } } @@ -156,7 +149,7 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { if (slotNumber == -1) { // Loading the data for the initial game state - SVG0FILE file = SVG0FILE(SVG0NAME); + kSavegame0File file = kSavegame0File(kSavegame0Name); int size = file.size(); byte *dataBuffer = (byte *)malloc(size); file.read(dataBuffer, size); @@ -175,10 +168,10 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { } // Check to see if it's a ScummVM savegame or not - char buffer[SAVEGAME_STR_SIZE + 1]; - readStream->read(buffer, SAVEGAME_STR_SIZE + 1); + char buffer[kSavegameStrSize + 1]; + readStream->read(buffer, kSavegameStrSize + 1); - if (strncmp(buffer, SAVEGAME_STR, SAVEGAME_STR_SIZE + 1) != 0) { + if (strncmp(buffer, savegameStr, kSavegameStrSize + 1) != 0) { // It's not, so rewind back to the start readStream->seek(0); @@ -269,7 +262,7 @@ void CGEEngine::saveGame(int slotNumber, const Common::String &desc) { // Write out the ScummVM savegame header SavegameHeader header; header.saveName = desc; - header.version = CGE_SAVEGAME_VERSION; + header.version = kSavegameVersion; writeSavegameHeader(saveFile, header); // Write out the data of the savegame @@ -282,9 +275,9 @@ void CGEEngine::saveGame(int slotNumber, const Common::String &desc) { void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header) { // Write out a savegame header - out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1); + out->write(savegameStr, kSavegameStrSize + 1); - out->writeByte(CGE_SAVEGAME_VERSION); + out->writeByte(kSavegameVersion); // Write savegame name out->write(header.saveName.c_str(), header.saveName.size() + 1); @@ -376,7 +369,7 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade // Get the savegame version header.version = in->readByte(); - if (header.version > CGE_SAVEGAME_VERSION) + if (header.version > kSavegameVersion) return false; // Read in the string @@ -423,7 +416,7 @@ void CGEEngine::trouble(int seq, int text) { void CGEEngine::offUse() { debugC(1, kCGEDebugEngine, "CGEEngine::offUse()"); - trouble(kSeqOffUse, kOffUse + new_random(_offUseCount)); + trouble(kSeqOffUse, kOffUse + newRandom(_offUseCount)); } void CGEEngine::tooFar() { @@ -467,7 +460,7 @@ Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { void Square::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); - if (mask & L_UP) { + if (mask & kMouseLeftUp) { XZ(_x + x, _y + y).cell() = 0; _snail_->addCom(kSnKill, -1, 0, this); } @@ -688,8 +681,8 @@ void CGEEngine::switchCave(int cav) { if (!_isDemo) _vga->_spareQ->_show = 0; } - _cavLight->gotoxy(CAVE_X + ((_now - 1) % _caveNx) * _caveDx + CAVE_SX, - CAVE_Y + ((_now - 1) / _caveNx) * _caveDy + CAVE_SY); + _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX, + kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY); killText(); if (!_startupMode) keyClick(); @@ -716,7 +709,7 @@ void System::setPal() { } void System::funTouch() { - uint16 n = (PAIN) ? kHeroFun1 : kHeroFun0; + uint16 n = (_vm->_flag[0]) ? kHeroFun1 : kHeroFun0; // PAIN flag if (_talk == NULL || n > _funDel) _funDel = n; } @@ -726,7 +719,7 @@ void System::touch(uint16 mask, int x, int y) { funTouch(); - if (mask & KEYB) { + if (mask & kEventKeyb) { int pp0; _vm->keyClick(); killText(); @@ -837,15 +830,15 @@ void System::touch(uint16 mask, int x, int y) { _infoLine->update(NULL); if (y >= kWorldHeight ) { if (x < kButtonX) { // select cave? - if (y >= CAVE_Y && y < CAVE_Y + _vm->_caveNy * _vm->_caveDy && - x >= CAVE_X && x < CAVE_X + _vm->_caveNx * _vm->_caveDx && !_vm->_game) { - cav = ((y - CAVE_Y) / _vm->_caveDy) * _vm->_caveNx + (x - CAVE_X) / _vm->_caveDx + 1; + if (y >= kCaveY && y < kCaveY + _vm->_caveNy * _vm->_caveDy && + x >= kCaveX && x < kCaveX + _vm->_caveNx * _vm->_caveDx && !_vm->_game) { + cav = ((y - kCaveY) / _vm->_caveDy) * _vm->_caveNx + (x - kCaveX) / _vm->_caveDx + 1; if (cav > _vm->_maxCave) cav = 0; } else { cav = 0; } - } else if (mask & L_UP) { + } else if (mask & kMouseLeftUp) { if (y >= kPocketY && y < kPocketY + kPocketNY * kPocketDY && x >= kPocketX && x < kPocketX + kPocketNX * kPocketDX) { int n = ((y - kPocketY) / kPocketDY) * kPocketNX + (x - kPocketX) / kPocketDX; @@ -856,7 +849,7 @@ void System::touch(uint16 mask, int x, int y) { _vm->postMiniStep(cav - 1); - if (mask & L_UP) { + if (mask & kMouseLeftUp) { if (cav && _snail->idle() && _hero->_tracePtr < 0) _vm->switchCave(cav); @@ -883,10 +876,10 @@ void System::tick() { if (--_funDel == 0) { killText(); if (_snail->idle()) { - if (PAIN) + if (_vm->_flag[0]) // Pain flag _vm->heroCover(9); else { // CHECKME: Before, was: if (Startup::_core >= CORE_MID) { - int n = new_random(100); + int n = newRandom(100); if (n > 96) _vm->heroCover(6 + (_hero->_x + _hero->_w / 2 < kScrWidth / 2)); else { @@ -1043,42 +1036,42 @@ void CGEEngine::saveMapping() { } } + +void CGEEngine::sayDebug() { // 1111111111222222222233333333334444444444555555555566666666667777777777 // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 -static char DebugText[] = " X=000 Y=000 S=00:00 000:000:000 000:000 00"; - -#define ABSX (DebugText + 3) -#define ABSY (DebugText + 9) -#define SP_N (DebugText + 15) -#define SP_S (DebugText + 18) -#define SP_X (DebugText + 21) -#define SP_Y (DebugText + 25) -#define SP_Z (DebugText + 29) -#define SP_W (DebugText + 33) -#define SP_H (DebugText + 37) -#define SP_F (DebugText + 41) + static char DebugText[] = " X=000 Y=000 S=00:00 000:000:000 000:000 00"; + + char *absX = DebugText + 3; + char *absY = DebugText + 9; + char *spN = DebugText + 15; + char *spS = DebugText + 18; + char *spX = DebugText + 21; + char *spY = DebugText + 25; + char *spZ = DebugText + 29; + char *spW = DebugText + 33; + char *spH = DebugText + 37; + char *spF = DebugText + 41; -void CGEEngine::sayDebug() { if (!_debugLine->_flags._hide) { - dwtom(_mouse->_x, ABSX, 10, 3); - dwtom(_mouse->_y, ABSY, 10, 3); + dwtom(_mouse->_x, absX, 10, 3); + dwtom(_mouse->_y, absY, 10, 3); // sprite queue size uint16 n = 0; - Sprite *spr; - for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { + for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) { n++; if (spr == _sprite) { - dwtom(n, SP_N, 10, 2); - dwtom(_sprite->_x, SP_X, 10, 3); - dwtom(_sprite->_y, SP_Y, 10, 3); - dwtom(_sprite->_z, SP_Z, 10, 3); - dwtom(_sprite->_w, SP_W, 10, 3); - dwtom(_sprite->_h, SP_H, 10, 3); - dwtom(*(uint16 *)(&_sprite->_flags), SP_F, 16, 2); + dwtom(n, spN, 10, 2); + dwtom(_sprite->_x, spX, 10, 3); + dwtom(_sprite->_y, spY, 10, 3); + dwtom(_sprite->_z, spZ, 10, 3); + dwtom(_sprite->_w, spW, 10, 3); + dwtom(_sprite->_h, spH, 10, 3); + dwtom(*(uint16 *)(&_sprite->_flags), spF, 16, 2); } } - dwtom(n, SP_S, 10, 2); + dwtom(n, spS, 10, 2); _debugLine->update(DebugText); } } @@ -1092,20 +1085,20 @@ void CGEEngine::switchDebug() { void CGEEngine::optionTouch(int opt, uint16 mask) { switch (opt) { case 1 : - if (mask & L_UP) + if (mask & kMouseLeftUp) switchColorMode(); break; case 2 : - if (mask & L_UP) + if (mask & kMouseLeftUp) switchMusic(); - else if (mask & R_UP) + else if (mask & kMouseRightUp) if (!Mixer::_appear) { Mixer::_appear = true; new Mixer(this, kButtonX, kButtonY); } break; case 3 : - if (mask & L_UP) + if (mask & kMouseLeftUp) quit(); break; } @@ -1115,9 +1108,9 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { #pragma argsused void Sprite::touch(uint16 mask, int x, int y) { _sys->funTouch(); - if ((mask & ATTN) == 0) { + if ((mask & kEventAttn) == 0) { _infoLine->update(name()); - if (mask & (R_DN | L_DN)) + if (mask & (kMouseRightDown | kMouseLeftDown)) _sprite = this; if (_ref / 10 == 12) { _vm->optionTouch(_ref % 10, mask); @@ -1125,11 +1118,11 @@ void Sprite::touch(uint16 mask, int x, int y) { } if (_flags._syst) return; // cannot access system sprites - if (_vm->_game) if (mask & L_UP) { - mask &= ~L_UP; - mask |= R_UP; + if (_vm->_game) if (mask & kMouseLeftUp) { + mask &= ~kMouseLeftUp; + mask |= kMouseRightUp; } - if ((mask & R_UP) && _snail->idle()) { + if ((mask & kMouseRightUp) && _snail->idle()) { Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL; if (ps) { if (_flags._kept || _hero->distance(this) < kDistMax) { @@ -1142,7 +1135,7 @@ void Sprite::touch(uint16 mask, int x, int y) { _vm->tooFar(); } else { if (_flags._kept) - mask |= L_UP; + mask |= kMouseLeftUp; else { if (_hero->distance(this) < kDistMax) { /// @@ -1169,7 +1162,7 @@ void Sprite::touch(uint16 mask, int x, int y) { } } } - if ((mask & L_UP) && _snail->idle()) { + if ((mask & kMouseLeftUp) && _snail->idle()) { if (_flags._kept) { int n; for (n = 0; n < kPocketNX; n++) { @@ -1398,9 +1391,6 @@ void CGEEngine::loadScript(const char *fname) { error("Bad INI line %d [%s]", lcnt, fname); } -#define GAME_FRAME_DELAY (1000 / 50) -#define GAME_TICK_DELAY (1000 / 62) - void CGEEngine::mainLoop() { sayDebug(); @@ -1431,11 +1421,11 @@ void CGEEngine::mainLoop() { void CGEEngine::handleFrame() { // Game frame delay uint32 millis = g_system->getMillis(); - while (!_eventManager->_quitFlag && (millis < (_lastFrame + GAME_FRAME_DELAY))) { + while (!_eventManager->_quitFlag && (millis < (_lastFrame + kGameFrameDelay))) { // Handle any pending events _eventManager->poll(); - if (millis >= (_lastTick + GAME_TICK_DELAY)) { + if (millis >= (_lastTick + kGameTickDelay)) { // Dispatch the tick to any active objects tick(); _lastTick = millis; @@ -1447,7 +1437,7 @@ void CGEEngine::handleFrame() { } _lastFrame = millis; - if (millis >= (_lastTick + GAME_TICK_DELAY)) { + if (millis >= (_lastTick + kGameTickDelay)) { // Dispatch the tick to any active objects tick(); _lastTick = millis; @@ -1579,8 +1569,8 @@ void CGEEngine::runGame() { _startupMode = 0; _snail->addCom(kSnLevel, -1, _oldLev, &_cavLight); - _cavLight->gotoxy(CAVE_X + ((_now - 1) % _caveNx) * _caveDx + CAVE_SX, - CAVE_Y + ((_now - 1) / _caveNx) * _caveDy + CAVE_SY); + _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX, + kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY); caveUp(); _keyboard->setClient(_sys); @@ -1643,7 +1633,7 @@ bool CGEEngine::showTitle(const char *name) { D.show(2); if (_mode == 2) { - inf(SVG0NAME); + inf(kSavegame0Name); _talk->show(2); } @@ -1732,15 +1722,15 @@ bool CGEEngine::showTitle(const char *name) { } void CGEEngine::cge_main() { - uint16 intStack[STACK_SIZ / 2]; + uint16 intStack[kStackSize / 2]; _intStackPtr = intStack; memset(_barriers, 0xFF, sizeof(_barriers)); if (!_mouse->_exist) - error("%s", _text->getText(NO_MOUSE_TEXT)); + error("%s", _text->getText(kTextNoMouse)); - if (!SVG0FILE::exist(SVG0NAME)) + if (!kSavegame0File::exist(kSavegame0Name)) _mode = 2; _debugLine->_flags._hide = true; diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index e3d8d40846..293943d358 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -34,13 +34,11 @@ #include "cge/sound.h" namespace CGE { -#define CAVE_X 4 -#define CAVE_Y 166 -#define CAVE_SX 0 -#define CAVE_SY 0 - -#define PAIN (_vm->_flag[0]) +#define kCaveX 4 +#define kCaveY 166 +#define kCaveSX 0 +#define kCaveSY 0 #define kInfoX 177 #define kInfoY 164 #define kInfoW 140 @@ -85,6 +83,15 @@ namespace CGE { #define kScrWidth 320 #define kScrHeight 200 #define kWorldHeight (kScrHeight - kPanHeight) +#define kStackSize 2048 +#define kSavegameCheckSum (1956 + _now + _oldLev + _game + _music + _demoText) +#define kSavegame0Name ("{{INIT}}" kSvgExt) +#define kSavegame0File INI_FILE +#define kSavegameStrSize 11 +#define kGameFrameDelay (1000 / 50) +#define kGameTickDelay (1000 / 62) + + class System : public Sprite { int _lum; diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index 24fd3d2043..3455052730 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -154,10 +154,10 @@ SaveStateList CGEMetaEngine::listSaves(const char *target) const { CGE::SavegameHeader header; // Check to see if it's a ScummVM savegame or not - char buffer[SAVEGAME_STR_SIZE + 1]; - file->read(buffer, SAVEGAME_STR_SIZE + 1); + char buffer[kSavegameStrSize + 1]; + file->read(buffer, kSavegameStrSize + 1); - if (!strncmp(buffer, CGE::SAVEGAME_STR, SAVEGAME_STR_SIZE + 1)) { + if (!strncmp(buffer, CGE::savegameStr, kSavegameStrSize + 1)) { // Valid savegame if (CGE::CGEEngine::readSavegameHeader(file, header)) { saveList.push_back(SaveStateDescriptor(slotNum, header.saveName)); @@ -184,10 +184,10 @@ SaveStateDescriptor CGEMetaEngine::querySaveMetaInfos(const char *target, int sl CGE::SavegameHeader header; // Check to see if it's a ScummVM savegame or not - char buffer[SAVEGAME_STR_SIZE + 1]; - f->read(buffer, SAVEGAME_STR_SIZE + 1); + char buffer[kSavegameStrSize + 1]; + f->read(buffer, kSavegameStrSize + 1); - bool hasHeader = !strncmp(buffer, CGE::SAVEGAME_STR, SAVEGAME_STR_SIZE + 1) && + bool hasHeader = !strncmp(buffer, CGE::savegameStr, kSavegameStrSize + 1) && CGE::CGEEngine::readSavegameHeader(f, header); delete f; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 113b64cee8..50544255a8 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -136,7 +136,7 @@ void Keyboard::newKeyboard(Common::Event &event) { if (_client) { CGEEvent &evt = _eventManager->getNextEvent(); evt._x = _current; // Keycode - evt._mask = KEYB; // Event mask + evt._mask = kEventKeyb; // Event mask evt._spritePtr = _client; // Sprite pointer } } @@ -218,22 +218,22 @@ void Mouse::newMouse(Common::Event &event) { switch (event.type) { case Common::EVENT_MOUSEMOVE: - evt._mask = ROLL; + evt._mask = kMouseRoll; break; case Common::EVENT_LBUTTONDOWN: - evt._mask = L_DN; + evt._mask = kMouseLeftDown; _buttons |= 1; break; case Common::EVENT_LBUTTONUP: - evt._mask = L_UP; + evt._mask = kMouseLeftUp; _buttons &= ~1; break; case Common::EVENT_RBUTTONDOWN: - evt._mask = R_DN; + evt._mask = kMouseRightDown; _buttons |= 2; break; case Common::EVENT_RBUTTONUP: - evt._mask = R_UP; + evt._mask = kMouseRightUp; _buttons &= ~2; break; default: @@ -282,22 +282,22 @@ void EventManager::handleEvents() { CGEEvent e = _eventQueue[_eventQueueTail]; if (e._mask) { if (_mouse->_hold && e._spritePtr != _mouse->_hold) - _mouse->_hold->touch(e._mask | ATTN, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y); + _mouse->_hold->touch(e._mask | kEventAttn, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y); // update mouse cursor position - if (e._mask & ROLL) + if (e._mask & kMouseRoll) _mouse->gotoxy(e._x, e._y); // activate current touched SPRITE if (e._spritePtr) { - if (e._mask & KEYB) + if (e._mask & kEventKeyb) e._spritePtr->touch(e._mask, e._x, e._y); else e._spritePtr->touch(e._mask, e._x - e._spritePtr->_x, e._y - e._spritePtr->_y); } else if (_sys) _sys->touch(e._mask, e._x, e._y); - if (e._mask & L_DN) { + if (e._mask & kMouseLeftDown) { _mouse->_hold = e._spritePtr; if (_mouse->_hold) { _mouse->_hold->_flags._hold = true; @@ -309,7 +309,7 @@ void EventManager::handleEvents() { } } - if (e._mask & L_UP) { + if (e._mask & kMouseLeftUp) { if (_mouse->_hold) { _mouse->_hold->_flags._hold = false; _mouse->_hold = NULL; @@ -318,10 +318,10 @@ void EventManager::handleEvents() { ///Touched = e.Ptr; // discard Text if button released - if (e._mask & (L_UP | R_UP)) + if (e._mask & (kMouseLeftUp | kMouseRightUp)) killText(); } - _eventQueueTail = (_eventQueueTail + 1) % EVT_MAX; + _eventQueueTail = (_eventQueueTail + 1) % kEventMax; } if (_mouse->_hold) { if (_mouse->_hold->_flags._drag) @@ -332,7 +332,7 @@ void EventManager::handleEvents() { void EventManager::clearEvent(Sprite *spr) { if (spr) { uint16 e; - for (e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % EVT_MAX) + for (e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % kEventMax) if (_eventQueue[e]._spritePtr == spr) _eventQueue[e]._mask = 0; } else @@ -341,7 +341,7 @@ void EventManager::clearEvent(Sprite *spr) { CGEEvent &EventManager::getNextEvent() { CGEEvent &evt = _eventQueue[_eventQueueHead]; - _eventQueueHead = (_eventQueueHead + 1) % EVT_MAX; + _eventQueueHead = (_eventQueueHead + 1) % kEventMax; return evt; } diff --git a/engines/cge/events.h b/engines/cge/events.h index b213caed3c..124597c329 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -40,6 +40,17 @@ namespace CGE { #define kKeyCtrl 29 #define kKeyAlt 56 +#define kEventMax 256 + +enum EventMask { + kMouseRoll = 1 << 0, + kMouseLeftDown = 1 << 1, + kMouseLeftUp = 1 << 2, + kMouseRightDown = 1 << 3, + kMouseRightUp = 1 << 4, + kEventAttn = 1 << 5, + kEventKeyb = 1 << 7 +}; class Keyboard { private: @@ -62,15 +73,6 @@ public: /*----------------- MOUSE interface -----------------*/ -#define EVT_MAX 256 -#define ROLL 0x01 -#define L_DN 0x02 -#define L_UP 0x04 -#define R_DN 0x08 -#define R_UP 0x10 -#define ATTN 0x20 // 0x40 -#define KEYB 0x80 - extern Talk *_talk; struct CGEEvent { @@ -105,7 +107,7 @@ private: class EventManager { private: Common::Event _event; - CGEEvent _eventQueue[EVT_MAX]; + CGEEvent _eventQueue[kEventMax]; uint16 _eventQueueHead; uint16 _eventQueueTail; diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 4107580691..e64e4af38a 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -50,16 +50,16 @@ int Fly::_l = 20, Fly::Fly(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), _tx(0), _ty(0), _vm(vm) { - step(new_random(2)); - gotoxy(_l + new_random(_r - _l - _w), _t + new_random(_b - _t - _h)); + step(newRandom(2)); + gotoxy(_l + newRandom(_r - _l - _w), _t + newRandom(_b - _t - _h)); } void Fly::tick() { step(); if (!_flags._kept) { - if (new_random(10) < 1) { - _tx = new_random(3) - 1; - _ty = new_random(3) - 1; + if (newRandom(10) < 1) { + _tx = newRandom(3) - 1; + _ty = newRandom(3) - 1; } if (_x + _tx < _l || _x + _tx + _w > _r) _tx = -_tx; diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 8e141a8be4..b9c10a7029 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -327,7 +327,7 @@ long timer() { return 0; } -int new_random(int range) { +int newRandom(int range) { return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } diff --git a/engines/cge/general.h b/engines/cge/general.h index 57991f2125..fe34606108 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -129,7 +129,7 @@ char *wtom(uint16 val, char *str, int radix, int len); char *dwtom(uint32 val, char * str, int radix, int len); int takeEnum(const char **tab, const char *text); long timer(); -int new_random(int range); +int newRandom(int range); } // End of namespace CGE #endif diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index a2408bc792..d96e494402 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -77,7 +77,7 @@ void GetText::touch(uint16 mask, int x, int y) { static char bezo[] = "ACELNOSXZ"; char *p; - if (mask & KEYB) { + if (mask & kEventKeyb) { _vm->keyClick(); switch (x) { case Enter : diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 4540c1d8e5..128a92f594 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -33,7 +33,6 @@ namespace CGE { // Defines found in cge.mak -#define VOL #define INI_FILE VFile // Or is it CFile? #define PIC_FILE VFile #define BMP_MODE 0 diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index decc516ae3..ba24f832c3 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -107,7 +107,7 @@ Mixer::~Mixer() { void Mixer::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); - if (mask & L_UP) { + if (mask & kMouseLeftUp) { warning("STUB: Mixer::touch(): Digital Volume"); /* uint8 *vol = (&_sndDrvInfo.Vol2._d) + (x < _w / 2); if (y < kMixButtonHigh) { @@ -129,7 +129,7 @@ void Mixer::tick() { if (spriteAt(x, y) == this) { _fall = kMixFall; if (_flags._hold) - touch(L_UP, x - _x, y - _y); + touch(kMouseLeftUp, x - _x, y - _y); } else { if (_fall) _fall--; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index aece48a933..2d4c28c0ab 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -36,15 +36,6 @@ namespace CGE { -extern Sprite *_pocLight; - -//------------------------------------------------------------------------- -// SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL, -// NULL, NULL, NULL, NULL, }; -// int _pocPtr = 0; -//------------------------------------------------------------------------- -extern Sprite *_pocket[]; - void CGEEngine::snGame(Sprite *spr, int num) { debugC(1, kCGEDebugEngine, "CGEEngine::snGame(spr, %d)", num); @@ -67,11 +58,11 @@ void CGEEngine::snGame(Sprite *spr, int num) { } if (_game) { // continue game - int i = new_random(3), hand = (dup[0]->_shpCnt == 6); + int i = newRandom(3), hand = (dup[0]->_shpCnt == 6); Stage++; if (hand && Stage > kDressed) ++hand; - if (i >= 0 || (dup[i] == spr && new_random(3) == 0)) { + if (i >= 0 || (dup[i] == spr && newRandom(3) == 0)) { _snail->addCom(kSnSeq, -1, 3, dup[0]); // yes _snail->addCom(kSnSeq, -1, 3, dup[1]); // yes _snail->addCom(kSnSeq, -1, 3, dup[2]); // yes @@ -149,9 +140,9 @@ void CGEEngine::snGame(Sprite *spr, int num) { _snail->addCom(kSnGame, 20002, 2, NULL); _game = true; } else { // cont - _sprK1->step(new_random(6)); - _sprK2->step(new_random(6)); - _sprK3->step(new_random(6)); + _sprK1->step(newRandom(6)); + _sprK2->step(newRandom(6)); + _sprK3->step(newRandom(6)); ///-------------------- if (spr->_ref == 1 && _keyboard->_key[kKeyAlt]) { _sprK1->step(5); @@ -179,7 +170,7 @@ void CGEEngine::snGame(Sprite *spr, int num) { _game = false; return; } else - _sprK3->step(new_random(5)); + _sprK3->step(newRandom(5)); } if (_gameCase2Cpt < 100) { switch (_gameCase2Cpt) { diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 485ba00ad1..699bd5bcc1 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -199,18 +199,18 @@ void Text::say(const char *text, Sprite *spr) { _talk->_flags._kill = true; _talk->_flags._bDel = true; - _talk->setName(_text->getText(SAY_NAME)); + _talk->setName(_text->getText(kSayName)); _talk->gotoxy(x - (_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _talk->_h + 1); _talk->_z = 125; - _talk->_ref = SAY_REF; + _talk->_ref = kSayRef; spike->gotoxy(x, _talk->_y + _talk->_h - 1); spike->_z = 126; spike->_flags._slav = true; spike->_flags._kill = true; - spike->setName(_text->getText(SAY_NAME)); + spike->setName(_text->getText(kSayName)); spike->step(east); - spike->_ref = SAY_REF; + spike->_ref = kSayRef; _vga->_showQ->insert(_talk, _vga->_showQ->last()); _vga->_showQ->insert(spike, _vga->_showQ->last()); @@ -225,11 +225,11 @@ void CGEEngine::inf(const char *text) { if (_talk) { _talk->_flags._kill = true; _talk->_flags._bDel = true; - _talk->setName(_text->getText(INF_NAME)); + _talk->setName(_text->getText(kInfName)); _talk->center(); _talk->gotoxy(_talk->_x, _talk->_y - 20); _talk->_z = 126; - _talk->_ref = INF_REF; + _talk->_ref = kInfRef; _vga->_showQ->insert(_talk, _vga->_showQ->last()); } } diff --git a/engines/cge/text.h b/engines/cge/text.h index 6ed5b32b22..bb905ac655 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -37,16 +37,11 @@ namespace CGE { #define kSayExt ".SAY" -#define NOT_VGA_TEXT 90 -#define BAD_CHIP_TEXT 91 -#define BAD_DOS_TEXT 92 -#define NO_CORE_TEXT 93 -#define BAD_MIPS_TEXT 94 -#define NO_MOUSE_TEXT 95 -#define INF_NAME 101 -#define SAY_NAME 102 -#define INF_REF 301 -#define SAY_REF 302 +#define kTextNoMouse 95 +#define kInfName 101 +#define kSayName 102 +#define kInfRef 301 +#define kSayRef 302 class Text { diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index e8aa899583..48b27d9727 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -136,7 +136,7 @@ void Vmenu::touch(uint16 mask, int x, int y) { _bar->gotoxy(_x + kTextHMargin - kMenuBarHM, _y + kTextVMargin + n * h - kMenuBarVM); - if (ok && (mask & L_UP)) { + if (ok && (mask & kMouseLeftUp)) { _items = 0; _snail_->addCom(kSnKill, -1, 0, this); _recent = n; -- cgit v1.2.3 From 7ea1f74759c2b1a5e9d497a6bc3175a414ac94a1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Aug 2011 16:31:32 +0200 Subject: CGE: Fix display of info text at the beginning of the game --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index cc715da03c..8889c59b8d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -813,7 +813,7 @@ Vga::Vga(int mode) for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { - debugN("%s", text); + debugN("%s\n", text); std = false; } } -- cgit v1.2.3 From d229c92879048bc1e48892231783a4788f452490 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 5 Aug 2011 21:09:03 +1000 Subject: CGE: Built an English version game archive This combines the base game resources with the files of cge_work\dusa and work\ins\usa. This makes both action descriptions and hotspots appear in English, although the introduction credits still appear in Polish. I don't know if this was the case for the original 'official' English release; but I consider it a minor issue. --- engines/cge/detection.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index 24fd3d2043..fbe3bc6076 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -75,6 +75,17 @@ static const ADGameDescription gameDescriptions[] = { }, Common::PL_POL, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE }, + // English ScummVM version + { + "soltys", "", + { + {"vol.cat", 0, "bfea076fee47b8d64fdf213e56c60911", 50176}, + {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8427396}, + AD_LISTEND + }, + Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + }, + AD_TABLE_END_MARKER }; -- cgit v1.2.3 From b7a548f3c75e80573b31dd7fdec39bd6569af662 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 5 Aug 2011 21:23:41 +1000 Subject: CGE: Fixed compiler warning of shadowed variable --- engines/cge/cge_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 123501047a..05beaae58d 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -318,8 +318,8 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt if (s.isSaving()) { for (i = 0; i < kPocketNX; i++) { - register Sprite *s = _pocket[i]; - _pocref[i] = (s) ? s->_ref : -1; + register Sprite *spr = _pocket[i]; + _pocref[i] = (spr) ? spr->_ref : -1; } warning("STUB: CGEEngine::syncGame Digital and Midi volume"); -- cgit v1.2.3 From 3ce71737b590ed1306f836c6fb751c2d2654a431 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 5 Aug 2011 21:54:21 +1000 Subject: CGE: Fix mismatched memory free. --- engines/cge/bitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index c02c66df8b..6689998deb 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -187,7 +187,7 @@ uint16 Bitmap::moveVmap(uint8 *buf) { uint16 vsiz = (uint8 *)_b - (uint8 *)_v; uint16 siz = vsiz + _h * sizeof(HideDesc); memcpy(buf, _v, siz); - free(_v); + delete[] _v; _b = (HideDesc *)((_v = buf) + vsiz); return siz; } -- cgit v1.2.3 From c1294b772f3f459976dacb1c06f45425cc94853b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 5 Aug 2011 22:51:32 +1000 Subject: CGE: Added an assert to test out of bounds sprite shape access The English version seems to expect a different number of shapes for some sprites, so it will need further work to determine how best to handle the differences. --- engines/cge/vga13h.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9b30e02e4d..62b902b19c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -382,6 +382,7 @@ Sprite *Sprite::expand() { if (len == 0 || *line == '.') continue; + assert(shpcnt <= _shpCnt); switch (takeEnum(Comd, strtok(line, " =\t"))) { case 0 : { // Name setName(strtok(NULL, "")); -- cgit v1.2.3 From 388dadd56f0b0f35e0b617d1a8ce9ab47a0c14fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 13:12:22 +1000 Subject: CGE: Changed sprite shape list loading to exceed size specified by _shpCnt This fixes the problem that was happening with the new English archive, which had a bigger shape list for one of the items in the first scene. --- engines/cge/vga13h.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index de28794f3f..f34211c360 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -25,6 +25,7 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ +#include "common/array.h" #include "common/rect.h" #include "graphics/palette.h" #include "cge/general.h" @@ -358,7 +359,9 @@ Sprite *Sprite::expand() { if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[kLineMax], fname[kPathMax]; - BitmapPtr *shplist = new BitmapPtr[_shpCnt + 1]; + + Common::Array shplist; + for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -382,13 +385,18 @@ Sprite *Sprite::expand() { if (len == 0 || *line == '.') continue; - assert(shpcnt <= _shpCnt); switch (takeEnum(Comd, strtok(line, " =\t"))) { case 0 : { // Name setName(strtok(NULL, "")); break; } case 1 : { // Phase + // In case the shape index gets too high, increase the array size + while ((shpcnt + 1) >= (int)shplist.size()) { + shplist.push_back(NULL); + ++_shpCnt; + } + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"), true); break; } @@ -456,7 +464,12 @@ Sprite *Sprite::expand() { } else setSeq(getConstantSeq(_shpCnt == 1)); - setShapeList(shplist); + // Set the shape list + BitmapPtr *shapeList = new BitmapPtr[shplist.size()]; + for (uint i = 0; i < shplist.size(); ++i) + shapeList[i] = shplist[i]; + + setShapeList(shapeList); if (nea) nea[neacnt - 1]._ptr = _ext->_near = nea; -- cgit v1.2.3 From 0cb8b15cdf3eafbfea33ab68c6f3d43e42f11e80 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 13:30:36 +1000 Subject: CGE: Fixed warning of shadowed variable --- engines/cge/vga13h.cpp | 8 ++++---- engines/cge/vga13h.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f34211c360..d2ba9b1b99 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -337,16 +337,16 @@ Snail::Com *Sprite::snList(SnList type) { } -void Sprite::setName(char *name) { +void Sprite::setName(char *newName) { if (_ext) { if (_ext->_name) { delete[] _ext->_name; _ext->_name = NULL; } - if (name) { - _ext->_name = new char[strlen(name) + 1]; + if (newName) { + _ext->_name = new char[strlen(newName) + 1]; assert(_ext->_name != NULL); - strcpy(_ext->_name, name); + strcpy(_ext->_name, newName); } } } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index f72d4c693d..db75b48692 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -187,7 +187,7 @@ public: Sprite *expand(); Sprite *contract(); Sprite *backShow(bool fast = false); - void setName(char *name); + void setName(char *newName); inline char *name() { return (_ext) ? _ext->_name : NULL; } -- cgit v1.2.3 From 33c42264868573ed7a47f66075f75d60d2233b39 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 13:34:33 +1000 Subject: CGE: Fix another shadowed variable warning --- engines/cge/cge_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index d9d32b7f39..71089c5ea9 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -311,8 +311,8 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt if (s.isSaving()) { for (i = 0; i < kPocketNX; i++) { - register Sprite *spr = _pocket[i]; - _pocref[i] = (spr) ? spr->_ref : -1; + register Sprite *pocSpr = _pocket[i]; + _pocref[i] = (pocSpr) ? pocSpr->_ref : -1; } warning("STUB: CGEEngine::syncGame Digital and Midi volume"); -- cgit v1.2.3 From 63d49d3e1a460e848915ee54ca85812e1129aaf8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 13:46:44 +1000 Subject: CGE: Fix uninitialised value Valgrind warnings when saving sprite data --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d2ba9b1b99..4ad4e83ad6 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -647,7 +647,7 @@ BitmapPtr Sprite::ghost() { } void Sprite::sync(Common::Serializer &s) { - uint16 unused; + uint16 unused = 0; s.syncAsUint16LE(unused); s.syncAsUint16LE(unused); // _ext -- cgit v1.2.3 From f5d38d82d0c805f6c6d2d58999791cc69f29a024 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 14:01:00 +1000 Subject: CGE: Fix mismatched delete in Bitmap::_v --- engines/cge/bitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index b53cac4e90..60b6cc90fa 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -141,7 +141,7 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), if (v0) { uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); uint16 siz = vsiz + _h * sizeof(HideDesc); - uint8 *v1 = (uint8 *) malloc(sizeof(uint8) * siz); + uint8 *v1 = new uint8[siz]; assert(v1 != NULL); memcpy(v1, v0, siz); _b = (HideDesc *)((_v = v1) + vsiz); -- cgit v1.2.3 From c961597988ab0e9d9ed7dff5b317d620bcc84153 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 15:29:49 +1000 Subject: CGE: Fixed non-portability in loading _heroXY array --- engines/cge/cge_main.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 71089c5ea9..41bb68417c 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -26,6 +26,7 @@ */ #include "common/scummsys.h" +#include "common/endian.h" #include "common/memstream.h" #include "common/savefile.h" #include "common/serializer.h" @@ -110,11 +111,12 @@ void CGEEngine::syncHeader(Common::Serializer &s) { for (i = 0; i < 4; i++) s.syncAsUint16LE(_flag[i]); - initCaveValues(); if (s.isLoading()) { - //TODO: Fix the memory leak when the game is already running - _heroXY = (Hxy *) malloc (sizeof(Hxy) * _caveMax); - _barriers = (Bar *) malloc (sizeof(Bar) * (1 + _caveMax)); + // Reinitialise cave values + free(_heroXY); + free(_barriers); + + initCaveValues(); } for (i = 0; i < _caveMax; i++) { @@ -429,9 +431,18 @@ void CGEEngine::loadHeroXY() { debugC(1, kCGEDebugEngine, "CGEEngine::loadHeroXY()"); INI_FILE cf(progName(".HXY")); + uint16 x, y; + memset(_heroXY, 0, sizeof(_heroXY)); - if (!cf._error) - cf.read((uint8 *)(&_heroXY),sizeof(*(&_heroXY))); + if (!cf._error) { + for (int i = 0; i < _caveMax; ++i) { + cf.read((byte *)&x, 2); + cf.read((byte *)&y, 2); + + _heroXY[i]._x = (int16)FROM_LE_16(x); + _heroXY[i]._y = (int16)FROM_LE_16(y); + } + } } void CGEEngine::loadMapping() { -- cgit v1.2.3 From fc05b8cf1b489933d28e35d949f2de62cc0d8c6a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 16:08:47 +1000 Subject: CGE: Fix memory leak with savegame thumbnails --- engines/cge/cge_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 41bb68417c..3d1c451862 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -293,6 +293,7 @@ void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &he Graphics::Surface *s = _vga->_page[0]; ::createThumbnail(thumb, (const byte *)s->pixels, kScrWidth, kScrHeight, thumbPalette); Graphics::saveThumbnail(*out, *thumb); + thumb->free(); delete thumb; // Write out the save date/time -- cgit v1.2.3 From 9f8eb5a74086881f2818256b01fb6fb946c6420a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 16:55:39 +1000 Subject: CGE: Re-added an explicit check in Sprite destructor against _sprite variable The trouble is that the _sprite variable can currently be pointing to any registered sprite, and should only be freed in the destructor if it hasn't already been freed. Currently, this is best done by keeping track of whether the pointed to sprite has been already freed or not. --- engines/cge/vga13h.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 4ad4e83ad6..b1858c0cbe 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -231,6 +231,9 @@ Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) Sprite::~Sprite() { + if (_sprite == this) + _sprite = NULL; + contract(); } -- cgit v1.2.3 From 1f6c27480d67593cdd786ef25762eee249f74d36 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 17:22:04 +1000 Subject: CGE: Fix memory leak with _sprite global sprite --- engines/cge/cge.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 2baf1cde1e..c06e65491d 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -131,6 +131,7 @@ void CGEEngine::setup() { _pocket[i]->_flags._kill = false; } _sprite = new Sprite(this, NULL); + _sprite->_flags._kill = false; _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, kInfoW); _cavLight = new CavLight(this); @@ -190,7 +191,7 @@ CGEEngine::~CGEEngine() { // Delete engine objects delete _vga; delete _sys; - //delete _sprite; Sprite is destroyed by the queue it's added to + delete _sprite; delete _miniCave; delete _shadow; delete _horzLine; -- cgit v1.2.3 From 5aba6b5a0c5876792290fac806695fee9fecd743 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 18:23:53 +1000 Subject: CGE: Removed redundant _sprite creation in engine setup --- engines/cge/cge.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index c06e65491d..603352d8a0 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -110,6 +110,7 @@ void CGEEngine::setup() { _miniCave = NULL; _miniShp = NULL; _miniShpList = NULL; + _sprite = NULL; // Create debugger console _console = new CGEConsole(this); @@ -130,8 +131,6 @@ void CGEEngine::setup() { _pocket[i] = new Sprite(this, NULL); _pocket[i]->_flags._kill = false; } - _sprite = new Sprite(this, NULL); - _sprite->_flags._kill = false; _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, kInfoW); _cavLight = new CavLight(this); -- cgit v1.2.3 From db61f65b41530b01d2aa2ae6f31496bee669585d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 19:23:01 +1000 Subject: CGE: Fix uninitialised warning on event polling --- engines/cge/events.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 50544255a8..916de839eb 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -247,6 +247,7 @@ EventManager::EventManager() { _quitFlag = false; _eventQueueHead = 0; _eventQueueTail = 0; + memset(&_event, 0, sizeof(Common::Event)); } void EventManager::poll() { -- cgit v1.2.3 From 46e1f03585ffd841eba3a2f5570bd0559cb833bd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 20:03:42 +1000 Subject: CGE: Fixed up freeing of caveValues data --- engines/cge/cge.cpp | 10 +++++++--- engines/cge/cge.h | 1 + engines/cge/cge_main.cpp | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 603352d8a0..2a4ea6bea2 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -99,6 +99,12 @@ void CGEEngine::initCaveValues() { } } +void CGEEngine::freeCaveValues() { + delete[] _mini; + free(_heroXY); + free(_barriers); +} + void CGEEngine::setup() { debugC(1, kCGEDebugEngine, "CGEEngine::setup()"); @@ -209,10 +215,8 @@ CGEEngine::~CGEEngine() { delete _snail; delete _snail_; delete _hero; - delete[] _mini; - free(_heroXY); - free(_barriers); + freeCaveValues(); } Common::Error CGEEngine::run() { diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 54ea9e37f6..54bbadfef7 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -219,6 +219,7 @@ public: void postMiniStep(int stp); void showBak(int ref); void initCaveValues(); + void freeCaveValues(); void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 3d1c451862..b17f40b863 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -113,9 +113,7 @@ void CGEEngine::syncHeader(Common::Serializer &s) { if (s.isLoading()) { // Reinitialise cave values - free(_heroXY); - free(_barriers); - + freeCaveValues(); initCaveValues(); } -- cgit v1.2.3 From 1208e7e5af5d5cf74c615f6b5e7f40800100d146 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 21:03:24 +1000 Subject: CGE: Removed the _mini data block originally used to hold inventory shapes in high memory --- engines/cge/cge.cpp | 5 ++--- engines/cge/cge.h | 1 - engines/cge/cge_main.cpp | 22 +++++++++------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 2a4ea6bea2..b38b6d392f 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -58,13 +58,11 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) void CGEEngine::initCaveValues() { if (_isDemo) { - _mini = new byte[16384]; _caveDx = 23; _caveDy = 29; _caveNx = 3; _caveNy = 1; } else { - _mini = new byte[65536]; _caveDx = 9; _caveDy = 10; _caveNx = 8; @@ -100,7 +98,6 @@ void CGEEngine::initCaveValues() { } void CGEEngine::freeCaveValues() { - delete[] _mini; free(_heroXY); free(_barriers); } @@ -216,6 +213,8 @@ CGEEngine::~CGEEngine() { delete _snail_; delete _hero; + delete[] _miniShpList; + freeCaveValues(); } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 54bbadfef7..23509bbf49 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -142,7 +142,6 @@ public: Bar *_barriers; Common::RandomSource _randomSource; - byte *_mini; BitmapPtr *_miniShp; BitmapPtr *_miniShpList; int _startGameSlot; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index b17f40b863..6b6f4ff971 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1525,22 +1525,18 @@ void CGEEngine::runGame() { if (!_music) killMidi(); - if (_mini && INI_FILE::exist("MINI.SPR")) { + if (INI_FILE::exist("MINI.SPR")) { _miniShp = new BitmapPtr[2]; _miniShp[0] = _miniShp[1] = NULL; - uint8 *ptr = (uint8 *) &*_mini; - if (ptr != NULL) { - loadSprite("MINI", -1, 0, kMiniX, kMiniY); - expandSprite(_miniCave = _sprite); // NULL is ok - if (_miniCave) { - _miniCave->_flags._kill = false; - _miniCave->_flags._hide = true; - _miniCave->moveShapes(ptr); - _miniShp[0] = new Bitmap(*_miniCave->shp()); - _miniShpList = _miniCave->setShapeList(_miniShp); - postMiniStep(-1); - } + loadSprite("MINI", -1, 0, kMiniX, kMiniY); + expandSprite(_miniCave = _sprite); // NULL is ok + if (_miniCave) { + _miniCave->_flags._kill = false; + _miniCave->_flags._hide = true; + _miniShp[0] = new Bitmap(*_miniCave->shp()); + _miniShpList = _miniCave->setShapeList(_miniShp); + postMiniStep(-1); } } -- cgit v1.2.3 From 04e09e530a3bff231022ebf1c50ae5b70fc1c4a7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 22:14:23 +1000 Subject: CGE: Fix memory leaks in pocket list --- engines/cge/cge.cpp | 10 ++++------ engines/cge/cge_main.cpp | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index b38b6d392f..0d63b32d09 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -130,10 +130,8 @@ void CGEEngine::setup() { _vga = new Vga(M13H); _sys = new System(this); _pocLight = new PocLight(this); - for (int i = 0; i < kPocketNX; i++) { - _pocket[i] = new Sprite(this, NULL); - _pocket[i]->_flags._kill = false; - } + for (int i = 0; i < kPocketNX; i++) + _pocket[i] = NULL; _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, kInfoW); _cavLight = new CavLight(this); @@ -207,12 +205,12 @@ CGEEngine::~CGEEngine() { delete _eventManager; delete _fx; delete _sound; - for (int i = 0; i < kPocketNX; i++) - delete _pocket[i]; delete _snail; delete _snail_; delete _hero; + for (int i = 0; _miniShpList[i]; ++i) + delete _miniShpList[i]; delete[] _miniShpList; freeCaveValues(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6b6f4ff971..fd45dd797f 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -356,7 +356,6 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt for (i = 0; i < kPocketNX; i++) { register int r = _pocref[i]; - delete _pocket[i]; _pocket[i] = (r < 0) ? NULL : _vga->_spareQ->locate(r); } } -- cgit v1.2.3 From cbb828b337979e4dae4d5f1560ca4debe94079c4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 7 Aug 2011 11:34:03 +0200 Subject: CGE: Fix a couple of warnings reported by cppcheck --- engines/cge/cfile.h | 8 +++----- engines/cge/cge_main.cpp | 2 +- engines/cge/detection.cpp | 2 +- engines/cge/vol.cpp | 2 +- engines/cge/walk.cpp | 2 +- engines/cge/walk.h | 3 +-- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 6ed3b5e750..f5d784073b 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -41,13 +41,11 @@ protected: uint16 _ptr; uint16 _lim; long _bufMark; - uint16 _seed; - Crypt *_crypt; virtual void readBuf(); virtual void writeBuf(); public: - IoBuf(IOMode mode, Crypt *crpt = NULL); - IoBuf(const char *name, IOMode mode, Crypt *crpt = NULL); + IoBuf(IOMode mode, Crypt *crpt); + IoBuf(const char *name, IOMode mode, Crypt *crpt); virtual ~IoBuf(); uint16 read(void *buf, uint16 len); uint16 read(uint8 *buf); @@ -61,7 +59,7 @@ public: class CFile : public IoBuf { public: static uint16 _maxLineLen; - CFile(const char *name, IOMode mode = kModeRead, Crypt *crpt = NULL); + CFile(const char *name, IOMode mode, Crypt *crpt); virtual ~CFile(); void flush(); long mark(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index fd45dd797f..d709b65c1d 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -91,7 +91,7 @@ const char *savegameStr = "SCUMMVM_CGE"; static bool _finis = false; int _offUseCount; -uint16 *_intStackPtr = false; +uint16 *_intStackPtr = NULL; extern Dac _stdPal[58]; diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index 7eb147d697..e944f2e9b7 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -154,7 +154,7 @@ SaveStateList CGEMetaEngine::listSaves(const char *target) const { SaveStateList saveList; int slotNum = 0; - for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); filename++) { + for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { // Obtain the last 3 digits of the filename, since they correspond to the save slot slotNum = atoi(filename->c_str() + filename->size() - 3); diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 9074a8f061..b3cc49495a 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -71,7 +71,7 @@ void VFile::deinit() { } VFile::VFile(const char *name, IOMode mode) - : IoBuf(mode) { + : IoBuf(mode, NULL) { debugC(3, kCGEDebugFile, "VFile::VFile(%s, %d)", name, mode); if (mode == kModeRead) { diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index a9eeb6db8e..a418bfb178 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -70,7 +70,7 @@ Cluster XZ(Couple xy) { } Walk::Walk(CGEEngine *vm, BitmapPtr *shpl) - : Sprite(vm, shpl), _dir(kDirNone), _tracePtr(-1), _level(0), _vm(vm) { + : Sprite(vm, shpl), _dir(kDirNone), _tracePtr(-1), _level(0), _target(-1, -1), _vm(vm) { } diff --git a/engines/cge/walk.h b/engines/cge/walk.h index 115cb4924a..8327c901b6 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -49,7 +49,6 @@ protected: signed char _a; signed char _b; public: - Couple() { } Couple(const signed char a, const signed char b) : _a(a), _b(b) { } Couple operator + (Couple c) { return Couple(_a + c._a, _b + c._b); @@ -91,8 +90,8 @@ public: static void init(CGEEngine *vm); public: uint8 &cell(); - Cluster() : Couple() { } Cluster(int a, int b) : Couple(a, b) { } + Cluster() : Couple (-1, -1) { } bool chkBar() const; bool isValid() const; -- cgit v1.2.3 From de40ab5e0a24de6139be41f58399b83545a0928d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 7 Aug 2011 11:36:49 +0200 Subject: CGE: Remove JBW flag (useless) --- engines/cge/cge.cpp | 1 - engines/cge/cge.h | 1 - engines/cge/cge_main.cpp | 18 ------------------ 3 files changed, 20 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 0d63b32d09..6fc23969c2 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -51,7 +51,6 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) _startupMode = 1; _demoText = kDemo; _oldLev = 0; - _jbw = false; _pocPtr = 0; } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 23509bbf49..d681eb43e3 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -111,7 +111,6 @@ public: int _startupMode; int _demoText; int _oldLev; - bool _jbw; int _pocPtr; bool _music; int _pocref[kPocketNX]; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index d709b65c1d..6fed0b73ce 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -724,19 +724,15 @@ void System::funTouch() { } void System::touch(uint16 mask, int x, int y) { - static int pp = 0; - funTouch(); if (mask & kEventKeyb) { - int pp0; _vm->keyClick(); killText(); if (_vm->_startupMode == 1) { _snail->addCom(kSnClear, -1, 0, NULL); return; } - pp0 = pp; switch (x) { case Del: if (_keyboard->_key[kKeyAlt] && _keyboard->_key[kKeyCtrl]) @@ -817,21 +813,7 @@ void System::touch(uint16 mask, int x, int y) { if (_snail->idle() && !_hero->_flags._hide) _vm->startCountDown(); break; - case 'J': - if (pp == 0) - pp++; - break; - case 'B': - if (pp == 1) - pp++; - break; - case 'W': - if (pp == 2) - _vm->_jbw = !_vm->_jbw; - break; } - if (pp == pp0) - pp = 0; } else { if (_vm->_startupMode) return; -- cgit v1.2.3 From 7ae8f8ce69ba27b4ee2c1b42dcb624d59edcdfe0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Aug 2011 18:38:06 +1000 Subject: CGE: Decrease delay amounts to give better precision for frame execution --- engines/cge/cge_main.cpp | 2 +- engines/cge/vga13h.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6fed0b73ce..71acd2a522 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1423,7 +1423,7 @@ void CGEEngine::handleFrame() { } // Slight delay - g_system->delayMillis(10); + g_system->delayMillis(5); millis = g_system->getMillis(); } _lastFrame = millis; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index b1858c0cbe..7c11653c4e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -897,7 +897,7 @@ void Vga::setStatAdr() { void Vga::waitVR(bool on) { // Since some of the game parts rely on using vertical sync as a delay mechanism, // we're introducing a short delay to simulate it - g_system->delayMillis(10); + g_system->delayMillis(5); } -- cgit v1.2.3 From 621fa62e8b21535fc2b6e82d0686f1ae06b7ec7a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Aug 2011 19:02:13 +1000 Subject: CGE: Save the game if the game is quit via closing the window --- engines/cge/cge_main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 71acd2a522..4d3b3b251e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1568,6 +1568,10 @@ void CGEEngine::runGame() { mainLoop(); } + // If finishing game due to closing ScummVM window, explicitly save the game + if (!_finis) + qGame(); + _keyboard->setClient(NULL); _snail->addCom(kSnClear, -1, 0, NULL); _snail_->addCom(kSnClear, -1, 0, NULL); -- cgit v1.2.3 From 8cad6821bd1c045b65878e02cfd666a39d1e8ed1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Aug 2011 19:33:08 +1000 Subject: CGE: Fixes for saving games --- engines/cge/cge_main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4d3b3b251e..5e7e3d9ac4 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -239,7 +239,16 @@ Common::Error CGEEngine::loadGameState(int slot) { } Common::Error CGEEngine::saveGameState(int slot, const Common::String &desc) { + caveDown(); + _oldLev = _lev; + saveSound(); + + // Write out the user's progress saveGame(slot, desc); + + // Reload the scene + caveUp(); + return Common::kNoError; } -- cgit v1.2.3 From 0c33687de29c23e7750855ca7885dfad933f869b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Aug 2011 20:41:39 +1000 Subject: CGE: Further fixes to savegames. --- engines/cge/cge.h | 1 + engines/cge/cge_main.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index d681eb43e3..55c97d0644 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -156,6 +156,7 @@ public: void quit(); void resetQSwitch(); void optionTouch(int opt, uint16 mask); + void resetGame(); bool loadGame(int slotNumber, SavegameHeader *header = NULL, bool tiny = false); void setMapBrick(int x, int z); void switchMapping(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 5e7e3d9ac4..0ce514c6bb 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -192,6 +192,7 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { } // Delete the thumbnail + saveHeader.thumbnail->free(); delete saveHeader.thumbnail; // If we're loading the auto-save slot, load the name @@ -229,15 +230,19 @@ Common::String CGEEngine::generateSaveName(int slot) { Common::Error CGEEngine::loadGameState(int slot) { // Clear current game activity caveDown(); + resetGame(); // Load the game - loadGame(slot, NULL, true); - caveUp(); loadGame(slot, NULL); + caveUp(); return Common::kNoError; } +void CGEEngine::resetGame() { + _vga->_spareQ->clear(); +} + Common::Error CGEEngine::saveGameState(int slot, const Common::String &desc) { caveDown(); _oldLev = _lev; @@ -1578,7 +1583,7 @@ void CGEEngine::runGame() { } // If finishing game due to closing ScummVM window, explicitly save the game - if (!_finis) + if (!_finis && canSaveGameStateCurrently()) qGame(); _keyboard->setClient(NULL); -- cgit v1.2.3 From f1f1d8bde084b44756480c7b724f356562ca02b1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 12 Aug 2011 19:48:51 +1000 Subject: CGE: Implemented sound effects --- engines/cge/general.cpp | 20 ++++++++++---------- engines/cge/snddrv.h | 6 ------ engines/cge/sound.cpp | 18 +++++++++++++++++- engines/cge/sound.h | 9 +++++++++ engines/cge/wav.h | 13 ++++++++----- 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index b9c10a7029..67068a9673 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -282,14 +282,6 @@ void sndSetVolume() { warning("STUB: SNDSetVolume"); } -void sndDigiStart(SmpInfo *PSmpInfo) { - warning("STUB: SNDDigitStart"); -} - -void sndDigiStop(SmpInfo *PSmpInfo) { - warning("STUB: SNDDigiStop"); -} - void sndMidiStart(uint8 *MIDFile) { warning("STUB: SNDMIDIStart"); } @@ -299,8 +291,10 @@ void sndMidiStop() { } DataCk *loadWave(XFile *file) { - warning("STUB: LoadWave"); - return NULL; + byte *data = (byte *)malloc(file->size()); + file->read(data, file->size()); + + return new DataCk(data, file->size()); } int takeEnum(const char **tab, const char *text) { @@ -331,9 +325,15 @@ int newRandom(int range) { return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } +DataCk::DataCk(byte *buf, int size) { + _buf = buf; + _ckSize = size; +} + DataCk::~DataCk() { if (_buf) free(_buf); } + } // End of namespace CGE diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 07c4ccd0dd..44ccf47f94 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -73,12 +73,6 @@ void sndDone(); // Set Volume void sndSetVolume(); -// Start Digi -void sndDigiStart(SmpInfo *PSmpInfo); - -// Stop Digi -void sndDigiStop(SmpInfo *PSmpInfo); - // Start MIDI File void sndMidiStart(uint8 *MIDFile); diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 56db1a6482..2cb24df5ba 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -31,11 +31,13 @@ #include "cge/cfile.h" #include "cge/vol.h" #include "cge/cge_main.h" - +#include "common/memstream.h" +#include "audio/decoders/raw.h" namespace CGE { Sound::Sound(CGEEngine *vm) : _vm(vm) { + _audioStream = NULL; open(); } @@ -68,11 +70,25 @@ void Sound::play(DataCk *wav, int pan, int cnt) { } } +void Sound::sndDigiStart(SmpInfo *PSmpInfo) { + // Create an audio stream wrapper for sound + Common::MemoryReadStream *stream = new Common::MemoryReadStream(PSmpInfo->_saddr, + PSmpInfo->_slen, DisposeAfterUse::NO); + _audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); + + // Start the new sound + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _audioStream); +} void Sound::stop() { sndDigiStop(&_smpinf); } +void Sound::sndDigiStop(SmpInfo *PSmpInfo) { + if (_vm->_mixer->isSoundHandleActive(_soundHandle)) + _vm->_mixer->stopHandle(_soundHandle); + _audioStream = NULL; +} Fx::Fx(int size) : _current(NULL) { _cache = new Han[size]; diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 292cb30e76..67b16fc888 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -31,6 +31,10 @@ #include "cge/wav.h" #include "cge/snddrv.h" #include "cge/cge.h" +#include "audio/audiostream.h" +#include "audio/decoders/wave.h" +#include "audio/fmopl.h" +#include "audio/mixer.h" namespace CGE { @@ -45,6 +49,11 @@ public: void stop(); private: CGEEngine *_vm; + Audio::SoundHandle _soundHandle; + Audio::RewindableAudioStream *_audioStream; + + void sndDigiStart(SmpInfo *PSmpInfo); + void sndDigiStop(SmpInfo *PSmpInfo); }; diff --git a/engines/cge/wav.h b/engines/cge/wav.h index bd9fc96b0a..824f40f96f 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -115,16 +115,19 @@ public: }; -class DataCk : public CkHea { +class DataCk { bool _ef; - uint8 *_buf; + byte *_buf; + int _ckSize; public: - DataCk(CkHea &hea); - DataCk(int first, int last); + DataCk(byte *buf, int size); ~DataCk(); - inline uint8 *addr() { + inline const byte *addr() { return _buf; } + inline int size() { + return _ckSize; + } }; -- cgit v1.2.3 From b76c0af2f4fe9cafeafdde70867e159e076b2752 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 12 Aug 2011 21:33:45 +1000 Subject: CGE: Work on implementing MIDI music playback. Music playback is now sort of working, but it seems like only a beat track of the MIDI is getting played --- engines/cge/cge.cpp | 11 ++++-- engines/cge/cge.h | 2 + engines/cge/cge_main.cpp | 12 +++--- engines/cge/general.cpp | 16 -------- engines/cge/snddrv.h | 16 -------- engines/cge/sound.cpp | 99 ++++++++++++++++++++++++++++++------------------ engines/cge/sound.h | 28 ++++++++++++-- 7 files changed, 102 insertions(+), 82 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 6fc23969c2..cfd941017e 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -165,7 +165,7 @@ void CGEEngine::setup() { _flag[i] = false; _mode = 0; - _soundOk = 0; + _soundOk = 1; _sprTv = NULL; _gameCase2Cpt = 0; @@ -186,6 +186,7 @@ CGEEngine::~CGEEngine() { DebugMan.clearAllDebugChannels(); delete _console; + _midiPlayer.killMidi(); // Delete engine objects delete _vga; @@ -208,9 +209,11 @@ CGEEngine::~CGEEngine() { delete _snail_; delete _hero; - for (int i = 0; _miniShpList[i]; ++i) - delete _miniShpList[i]; - delete[] _miniShpList; + if (_miniShpList) { + for (int i = 0; _miniShpList[i]; ++i) + delete _miniShpList[i]; + delete[] _miniShpList; + } freeCaveValues(); } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 55c97d0644..bd347c6e26 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -34,6 +34,7 @@ #include "engines/advancedDetector.h" #include "cge/console.h" #include "cge/bitmap.h" +#include "cge/sound.h" namespace CGE { @@ -141,6 +142,7 @@ public: Bar *_barriers; Common::RandomSource _randomSource; + MusicPlayer _midiPlayer; BitmapPtr *_miniShp; BitmapPtr *_miniShpList; int _startGameSlot; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 0ce514c6bb..1dd6e49650 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -591,7 +591,7 @@ void CGEEngine::caveUp() { int BakRef = 1000 * _now; if (_music) - loadMidi(_now); + _midiPlayer.loadMidi(_now); showBak(BakRef); loadMapping(); @@ -927,9 +927,9 @@ void CGEEngine::switchMusic() { keyClick(); } if (_music) - loadMidi(_now); + _midiPlayer.loadMidi(_now); else - killMidi(); + _midiPlayer.killMidi(); } void CGEEngine::startCountDown() { @@ -1518,7 +1518,7 @@ void CGEEngine::runGame() { _sprite->step(_music); _snail_->addCom(kSnSeq, -1, _music, _sprite); if (!_music) - killMidi(); + _midiPlayer.killMidi(); if (INI_FILE::exist("MINI.SPR")) { _miniShp = new BitmapPtr[2]; @@ -1664,7 +1664,7 @@ bool CGEEngine::showTitle(const char *name) { _vga->copyPage(0, 2); _soundOk = 2; if (_music) - loadMidi(0); + _midiPlayer.loadMidi(0); } if (_mode < 2) { @@ -1742,7 +1742,7 @@ void CGEEngine::cge_main() { _horzLine->_flags._hide = true; if (_music && _soundOk) - loadMidi(0); + _midiPlayer.loadMidi(0); if (_startGameSlot != -1) { // Starting up a savegame from the launcher diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 67068a9673..4d79dbeddc 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -270,26 +270,10 @@ bool IoHand::exist(const char *name) { return f.exists(name); } -void sndInit() { - warning("STUB: SNDInit"); -} - -void sndDone() { - // FIXME: STUB: SNDDone -} - void sndSetVolume() { warning("STUB: SNDSetVolume"); } -void sndMidiStart(uint8 *MIDFile) { - warning("STUB: SNDMIDIStart"); -} - -void sndMidiStop() { - // FIXME: STUB: sndMIDIStop -} - DataCk *loadWave(XFile *file) { byte *data = (byte *)malloc(file->size()); file->read(data, file->size()); diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 44ccf47f94..0678971d0c 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -64,25 +64,9 @@ extern uint16 _midiEndFlag; // ****************************************************** // * Driver Code * // ****************************************************** -// Init Digi Device -void sndInit(); - -// Close Digi Device -void sndDone(); - // Set Volume void sndSetVolume(); -// Start MIDI File -void sndMidiStart(uint8 *MIDFile); - -// Stop MIDI File -void sndMidiStop(); - -// Play MIDI File (to be called while interrupting) -// WARNING: Uses ALL registers! -void sndMidiPlay(); - } // End of namespace CGE #endif diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 2cb24df5ba..aa42df57bf 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -48,13 +48,11 @@ Sound::~Sound() { void Sound::close() { - killMidi(); - sndDone(); + _vm->_midiPlayer.killMidi(); } void Sound::open() { - sndInit(); play((*_fx)[30000], 8); } @@ -180,40 +178,6 @@ DataCk *Fx::operator [](int ref) { return _current; } - -static uint8 *midi = NULL; - - -void killMidi() { - sndMidiStop(); - if (midi) { - delete[] midi; - midi = NULL; - } -} - - -void loadMidi(int ref) { - static char fn[] = "00.MID"; - wtom(ref, fn, 10, 2); - if (INI_FILE::exist(fn)) { - killMidi(); - INI_FILE mid = fn; - if (mid._error == 0) { - uint16 siz = (uint16) mid.size(); - midi = new uint8[siz]; - if (midi) { - mid.read(midi, siz); - if (mid._error) - killMidi(); - else - sndMidiStart(midi); - } - } - } -} - - void *Patch(int pat) { void *p = NULL; static char fn[] = "PATCH000.SND"; @@ -234,4 +198,65 @@ void *Patch(int pat) { return p; } +MusicPlayer::MusicPlayer() { + MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); + _driver = MidiDriver::createMidi(dev); + _driver->open(); + _midiParser = NULL; + _data = NULL; +} + +MusicPlayer::~MusicPlayer() { + killMidi(); + _driver->close(); + delete _driver; +} + +void MusicPlayer::killMidi() { + if (_midiParser) { + // Stop MIDI playback + _midiParser->unloadMusic(); + _driver->setTimerCallback(NULL, NULL); + _driver->close(); + delete _midiParser; + delete _data; + + // Reset playback objects + _data = NULL; + _midiParser = NULL; + } +} + +void MusicPlayer::loadMidi(int ref) { + // Work out the filename and check the given MIDI file exists + Common::String filename = Common::String::format("%.2d.MID", ref); + if (!INI_FILE::exist(filename.c_str())) + return; + + // Stop any currently playing MIDI file + killMidi(); + + // Read in the data for the file + INI_FILE mid(filename.c_str()); + _dataSize = mid.size(); + _data = (byte *)malloc(_dataSize); + mid.read(_data, _dataSize); + + // Start playing the music + sndMidiStart(); +} + +void MusicPlayer::sndMidiStart() { + _midiParser = MidiParser::createParser_SMF(); + + if (_midiParser->loadMusic(_data, _dataSize)) { + _midiParser->setTrack(0); + _midiParser->setMidiDriver(_driver); + _midiParser->setTimerRate(_driver->getBaseTempo()); + + _midiParser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); + _driver->setTimerCallback(_midiParser, MidiParser::timerCallback); + } +} + } // End of namespace CGE diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 67b16fc888..9f7d20957e 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -30,14 +30,19 @@ #include "cge/wav.h" #include "cge/snddrv.h" -#include "cge/cge.h" #include "audio/audiostream.h" #include "audio/decoders/wave.h" #include "audio/fmopl.h" +#include "audio/mididrv.h" +#include "audio/midiparser.h" +#include "audio/midiplayer.h" #include "audio/mixer.h" +#include "common/memstream.h" namespace CGE { +class CGEEngine; + class Sound { public: SmpInfo _smpinf; @@ -74,8 +79,25 @@ public: DataCk *operator[](int ref); }; -void loadMidi(int ref); -void killMidi(); +class MusicPlayer { +private: + MidiDriver *_driver; + MidiParser *_midiParser; + byte *_data; + int _dataSize; + + // Start MIDI File + void sndMidiStart(); + + // Stop MIDI File + void sndMidiStop(); +public: + MusicPlayer(); + ~MusicPlayer(); + + void loadMidi(int ref); + void killMidi(); +}; } // End of namespace CGE -- cgit v1.2.3 From 91fdecbf68cf9eb1bd1f4105cefd1fa20351d31e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 12 Aug 2011 23:10:30 +1000 Subject: CGE: Properly implemented MIDI music playback --- engines/cge/sound.cpp | 78 ++++++++++++++++++++++++++++++++++++--------------- engines/cge/sound.h | 8 ++++-- 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index aa42df57bf..8e60d851a4 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -31,6 +31,7 @@ #include "cge/cfile.h" #include "cge/vol.h" #include "cge/cge_main.h" +#include "common/config-manager.h" #include "common/memstream.h" #include "audio/decoders/raw.h" @@ -199,31 +200,36 @@ void *Patch(int pat) { } MusicPlayer::MusicPlayer() { - MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); - _driver = MidiDriver::createMidi(dev); - _driver->open(); - _midiParser = NULL; _data = NULL; + _isGM = false; + + MidiPlayer::createDriver(); + + int ret = _driver->open(); + if (ret == 0) { + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); + + // TODO: Load cmf.ins with the instrument table. It seems that an + // interface for such an operation is supported for AdLib. Maybe for + // this card, setting instruments is necessary. + + _driver->setTimerCallback(this, &timerCallback); + } } MusicPlayer::~MusicPlayer() { killMidi(); - _driver->close(); - delete _driver; } void MusicPlayer::killMidi() { - if (_midiParser) { - // Stop MIDI playback - _midiParser->unloadMusic(); - _driver->setTimerCallback(NULL, NULL); - _driver->close(); - delete _midiParser; - delete _data; + Audio::MidiPlayer::stop(); - // Reset playback objects + if (_data != NULL) { + delete _data; _data = NULL; - _midiParser = NULL; } } @@ -247,16 +253,42 @@ void MusicPlayer::loadMidi(int ref) { } void MusicPlayer::sndMidiStart() { - _midiParser = MidiParser::createParser_SMF(); + _isGM = true; + + MidiParser *parser = MidiParser::createParser_SMF(); + if (parser->loadMusic(_data, _dataSize)) { + parser->setTrack(0); + parser->setMidiDriver(this); + parser->setTimerRate(_driver->getBaseTempo()); + parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); + + _parser = parser; - if (_midiParser->loadMusic(_data, _dataSize)) { - _midiParser->setTrack(0); - _midiParser->setMidiDriver(_driver); - _midiParser->setTimerRate(_driver->getBaseTempo()); + syncVolume(); + + _isPlaying = true; + } +} + +void MusicPlayer::send(uint32 b) { + if ((b & 0xF0) == 0xC0 && !_isGM && !_nativeMT32) { + b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8; + } + + Audio::MidiPlayer::send(b); +} + +void MusicPlayer::sendToChannel(byte channel, uint32 b) { + if (!_channelsTable[channel]) { + _channelsTable[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel(); + // If a new channel is allocated during the playback, make sure + // its volume is correctly initialized. + if (_channelsTable[channel]) + _channelsTable[channel]->volume(_channelsVolume[channel] * _masterVolume / 255); + } - _midiParser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); - _driver->setTimerCallback(_midiParser, MidiParser::timerCallback); - } + if (_channelsTable[channel]) + _channelsTable[channel]->send(b); } } // End of namespace CGE diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 9f7d20957e..33c4e95d35 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -79,12 +79,11 @@ public: DataCk *operator[](int ref); }; -class MusicPlayer { +class MusicPlayer: public Audio::MidiPlayer { private: - MidiDriver *_driver; - MidiParser *_midiParser; byte *_data; int _dataSize; + bool _isGM; // Start MIDI File void sndMidiStart(); @@ -97,6 +96,9 @@ public: void loadMidi(int ref); void killMidi(); + + virtual void send(uint32 b); + virtual void sendToChannel(byte channel, uint32 b); }; } // End of namespace CGE -- cgit v1.2.3 From 6af5fffd3607d5ffcbb26a7a18316949b7e1ddb8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 12 Aug 2011 19:11:17 +0200 Subject: CGE: Cleanup: remove useless classes --- engines/cge/cge_main.h | 1 - engines/cge/general.cpp | 1 - engines/cge/sound.h | 18 +++++- engines/cge/walk.h | 1 - engines/cge/wav.h | 144 ------------------------------------------------ 5 files changed, 17 insertions(+), 148 deletions(-) delete mode 100644 engines/cge/wav.h diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 293943d358..1c85816c3e 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -28,7 +28,6 @@ #ifndef __CGE_CGE__ #define __CGE_CGE__ -#include "cge/wav.h" #include "cge/vga13h.h" #include "cge/events.h" #include "cge/sound.h" diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 4d79dbeddc..ddfb982d58 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -28,7 +28,6 @@ #include "cge/cge.h" #include "cge/general.h" #include "cge/snddrv.h" -#include "cge/wav.h" namespace CGE { diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 33c4e95d35..01b11487d0 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -28,7 +28,7 @@ #ifndef __CGE_SOUND__ #define __CGE_SOUND__ -#include "cge/wav.h" +#include "cge/general.h" #include "cge/snddrv.h" #include "audio/audiostream.h" #include "audio/decoders/wave.h" @@ -43,6 +43,22 @@ namespace CGE { class CGEEngine; +class DataCk { + byte *_buf; + int _ckSize; +public: + DataCk(byte *buf, int size); + ~DataCk(); + inline const byte *addr() { + return _buf; + } + inline int size() { + return _ckSize; + } +}; + +DataCk *loadWave(XFile *file); + class Sound { public: SmpInfo _smpinf; diff --git a/engines/cge/walk.h b/engines/cge/walk.h index 8327c901b6..c1d387f0b5 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -28,7 +28,6 @@ #ifndef __CGE_WALK__ #define __CGE_WALK__ -#include "cge/wav.h" #include "cge/vga13h.h" #include "cge/events.h" diff --git a/engines/cge/wav.h b/engines/cge/wav.h deleted file mode 100644 index 824f40f96f..0000000000 --- a/engines/cge/wav.h +++ /dev/null @@ -1,144 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_WAV__ -#define __CGE_WAV__ - -#include "cge/general.h" - -namespace CGE { - -#define WAVE_FORMAT_PCM 0x0001 -#define IBM_FORMAT_MULAW 0x0101 -#define IBM_FORMAT_ALAW 0x0102 -#define IBM_FORMAT_ADPCM 0x0103 - -typedef char FourCC[4]; // Four-character code - -class ChunkId { // Chunk type identifier - union { - FourCC _text; - uint32 _id; - }; -protected: - static XFile *ckFile; -public: - ChunkId(FourCC text) { - memcpy(_text, text, sizeof(_text)); - } - ChunkId(uint32 d) { - _id = d; - } - ChunkId(XFile *xf) { - (ckFile = xf)->read(_text, sizeof(_text)); - } - bool operator !=(ChunkId &X) { - return _id != X._id; - } - bool operator ==(ChunkId &X) { - return _id == X._id; - } - const char *name(); -}; - - -class CkHea : public ChunkId { -protected: - uint32 _ckSize; // Chunk size field (size of ckData) -public: - CkHea(XFile *xf) : ChunkId(xf) { - XRead(xf, &_ckSize); - } - CkHea(char id[]) : ChunkId(id), _ckSize(0) { } - void skip(); - uint32 size() { - return _ckSize; - } -}; - - -class FmtCk : public CkHea { - struct Wav { - uint16 _wFormatTag; // Format category - uint16 _wChannels; // Number of channels - uint32 _dwSamplesPerSec; // Sampling rate - uint32 _dwAvgBytesPerSec; // For buffer estimation - uint16 _wBlockAlign; // Data block size - } _wav; - - union { - struct { - uint16 _wBitsPerSample; // Sample size - } _pcm; - }; -public: - FmtCk(CkHea &hea); - inline uint16 channels() { - return _wav._wChannels; - } - inline uint32 smplRate() { - return _wav._dwSamplesPerSec; - } - inline uint32 byteRate() { - return _wav._dwAvgBytesPerSec; - } - inline uint16 blckSize() { - return _wav._wBlockAlign; - } - inline uint16 smplSize() { - return _pcm._wBitsPerSample; - } -}; - - -class DataCk { - bool _ef; - byte *_buf; - int _ckSize; -public: - DataCk(byte *buf, int size); - ~DataCk(); - inline const byte *addr() { - return _buf; - } - inline int size() { - return _ckSize; - } -}; - - -extern ChunkId _riff; -extern ChunkId _wave; -extern ChunkId _fmt; -extern ChunkId _data; - - -DataCk *loadWave(XFile *file); - -} // End of namespace CGE - -#endif -- cgit v1.2.3 From 161a39e9fe0bfdbb1d96a6bb4c88b83d3f073ad0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Aug 2011 11:04:10 +1000 Subject: CGE: Got rid of stub warnings for things that don't need to be implemented in ScummVM --- engines/cge/vga13h.cpp | 137 ++----------------------------------------------- 1 file changed, 5 insertions(+), 132 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 7c11653c4e..51be2ed1e8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -100,92 +100,13 @@ static void Video() { uint16 *SaveScreen() { - /* - uint16 cxy, cur, siz, * scr = NULL, * sav; - - // horizontal size of text mode screen - asm mov ah,0x0F // get current video mode - Video(); // BIOS video service - asm xchg ah,al // answer in ah - asm push ax // preserve width - - // vertical size of text mode screen - asm mov dl,24 // last row on std screen - asm xor bx,bx // valid request in BH - asm mov ax,0x1130 // get EGA's last row # - Video(); // BIOS video service - asm inc dl // # of rows = last+1 - - // compute screen size in words - asm pop ax // restore width - asm mul dl // width * height - - siz = _AX; - - asm mov ax,0x40 // system data segment - asm mov es,ax - asm mov ax,0B000H // Mono - asm cmp byte ptr es:[0x49],0x07 - asm je sto - asm mov ax,0B800H // Color - sto: // store screen address - asm mov word ptr scr+2,ax - - _AH = 0x0F; Video(); // active page - - // take cursor shape - _AH = 0x03; Video(); // get cursor size - cur = _CX; - - // take cursor position - _DH = 0; - _AH = 0x03; Video(); // get cursor - cxy = _DX; - - sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor - if (sav) - { - sav[0] = siz; - sav[1] = cur; - sav[2] = cxy; - memcpy(sav+3, scr, siz * 2); - } - return sav; - */ - warning("STUB: SaveScreen"); + // In ScummVM, we don't need to worry about saving the original screen mode return 0; } void RestoreScreen(uint16 * &sav) { - /* - uint16 * scr = NULL; - - asm mov ax,0x40 // system data segment - asm mov es,ax - asm mov ax,0B000H // Mono - asm cmp byte ptr es:[0x49],0x07 - asm je sto - asm mov ax,0B800H // Color - sto: // store screen address - asm mov word ptr scr+2,ax - - memcpy(scr, sav+3, sav[0] * 2); - - _AH = 0x0F; Video(); // active page - - // set cursor shape - _CX = sav[1]; - _AH = 0x01; Video(); // set cursor size - - // set cursor position - _DX = sav[2]; - _AH = 0x02; Video(); // set cursor - - free(sav); - sav = NULL; - */ - warning("STUB: RestoreScreen"); + // In ScummVM, we don't need to restore the original text screen when the game exits } @@ -830,7 +751,7 @@ Vga::Vga(int mode) for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { - debugN("%s\n", text); + debugN(1, "%s\n", text); std = false; } } @@ -879,17 +800,7 @@ Vga::~Vga() { void Vga::setStatAdr() { - /* - asm mov dx,VGAMIr_ - asm in al,dx - asm test al,1 // CGA addressing mode flag - asm mov ax,VGAST1_ // CGA addressing - asm jnz set_mode_adr - asm xor al,0x60 // MDA addressing - set_mode_adr: - StatAdr = _AX; - */ - warning("STUB: VGA::setStatADR"); + // No implementation needed for ScummVM } @@ -902,45 +813,7 @@ void Vga::waitVR(bool on) { void Vga::setup(VgaRegBlk *vrb) { - /* - waitVR(); // *--LOOK!--* resets VGAATR logic - asm cld - asm mov si, vrb // take address of parameter table - asm mov dh,0x03 // higher byte of I/O address is always 3 - - s: - asm lodsw // take lower byte of I/O address and index - asm or ah,ah // 0 = end of table - asm jz xit // no more: exit - asm or al,al // indexed register? - asm js single // 7th bit set means single register - asm mov dl,ah // complete I/O address - asm out dx,al // put index into control register - asm inc dx // data register is next to control - asm in al,dx // take old data - - write: - asm mov cl,al // preserve old data - asm lodsw // take 2 masks from table - asm xor al,0xFF // invert mask bits - asm and al,cl // clear bits with "clr" mask - asm or al,ah // set bits with "set" mask - asm cmp dl,0xC1 // special case? - asm jne std2 // no: standard job, otherwise... - asm dec dx // data out reg shares address with index - std2: - asm out dx,al // write new value to register - asm jmp s - - single: // read address in al, write address in ah - asm mov dl,al // complete I/O read address - asm in al,dx // take old data - asm mov dl,ah // complete I/O write address - asm jmp write // continue standard routine - - xit: - */ - warning("STUB: VGA::setup"); + // No direct VGA setup required, since ScummVM provides it's own graphics interface } -- cgit v1.2.3 From ef7a17a64a9d3781108ccdf2c7338b02bf3b3aa6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Aug 2011 16:44:48 +1000 Subject: CGE: Fix for HLINE not being available for demo The HorizLine class is really only used for on-screen debugging information anyway, so it's not a problem. --- engines/cge/cge.cpp | 6 +++++- engines/cge/cge.h | 1 + engines/cge/cge_main.cpp | 18 +++++++++++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index cfd941017e..936aeea75a 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -131,7 +131,7 @@ void CGEEngine::setup() { _pocLight = new PocLight(this); for (int i = 0; i < kPocketNX; i++) _pocket[i] = NULL; - _horzLine = new HorizLine(this); + _horzLine = isDemo() ? NULL : new HorizLine(this); _infoLine = new InfoLine(this, kInfoW); _cavLight = new CavLight(this); _debugLine = new InfoLine(this, kScrWidth); @@ -247,4 +247,8 @@ bool CGEEngine::canSaveGameStateCurrently() { return (_startupMode == 0) && _mouse->_active; } +bool CGEEngine::isDemo() const { + return _gameDescription->flags & ADGF_DEMO; +} + } // End of namespace CGE diff --git a/engines/cge/cge.h b/engines/cge/cge.h index bd347c6e26..8aff3334a0 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -104,6 +104,7 @@ public: virtual bool hasFeature(EngineFeature f) const; virtual bool canLoadGameStateCurrently(); virtual bool canSaveGameStateCurrently(); + bool isDemo() const; virtual Common::Error loadGameState(int slot); virtual Common::Error saveGameState(int slot, const Common::String &desc); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 1dd6e49650..24cdaf5e92 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -651,7 +651,7 @@ void CGEEngine::caveDown() { debugC(1, kCGEDebugEngine, "CGEEngine::caveDown()"); Sprite *spr; - if (!_horzLine->_flags._hide) + if (_horzLine && !_horzLine->_flags._hide) switchMapping(); for (spr = _vga->_showQ->first(); spr;) { @@ -858,7 +858,7 @@ void System::touch(uint16 mask, int x, int y) { if (cav && _snail->idle() && _hero->_tracePtr < 0) _vm->switchCave(cav); - if (!_horzLine->_flags._hide) { + if (_horzLine && !_horzLine->_flags._hide) { if (y >= kMapTop && y < kMapTop + kMapHig) { int8 x1, z1; XZ(x, y).split(x1, z1); @@ -958,9 +958,10 @@ void CGEEngine::takeName() { } void CGEEngine::switchMapping() { + assert(_horzLine); debugC(1, kCGEDebugEngine, "CGEEngine::switchMapping()"); - if (_horzLine->_flags._hide) { + if (_horzLine && _horzLine->_flags._hide) { int i; for (i = 0; i < kMapZCnt; i++) { int j; @@ -1559,9 +1560,11 @@ void CGEEngine::runGame() { _debugLine->_z = 126; _vga->_showQ->insert(_debugLine); - _horzLine->_y = kMapTop - (kMapTop > 0); - _horzLine->_z = 126; - _vga->_showQ->insert(_horzLine); + if (_horzLine) { + _horzLine->_y = kMapTop - (kMapTop > 0); + _horzLine->_z = 126; + _vga->_showQ->insert(_horzLine); + } _mouse->_busy = _vga->_spareQ->locate(kBusyRef); if (_mouse->_busy) @@ -1739,7 +1742,8 @@ void CGEEngine::cge_main() { _mode = 2; _debugLine->_flags._hide = true; - _horzLine->_flags._hide = true; + if (_horzLine) + _horzLine->_flags._hide = true; if (_music && _soundOk) _midiPlayer.loadMidi(0); -- cgit v1.2.3 From 58229750ccf6ede03332aec6b8c888fdca2917a0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 13 Aug 2011 09:16:15 +0200 Subject: CGE: silent valgrind warnings --- engines/cge/bitmap.cpp | 2 +- engines/cge/sound.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 60b6cc90fa..df68491bd5 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -165,7 +165,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { _h = bmp._h; _m = NULL; _map = 0; - free(_v); + delete[] _v; if (v0 == NULL) _v = NULL; else { diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 8e60d851a4..a3895958f0 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -228,7 +228,7 @@ void MusicPlayer::killMidi() { Audio::MidiPlayer::stop(); if (_data != NULL) { - delete _data; + free(_data); _data = NULL; } } -- cgit v1.2.3 From b02e34cade624362bee157dab364094c1710e548 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 13 Aug 2011 09:33:39 +0200 Subject: CGE: Implement sayTime() --- engines/cge/snail.cpp | 2 +- engines/cge/text.cpp | 16 ++++++---------- engines/cge/text.h | 4 +--- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 2d4c28c0ab..6a5556ca58 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -995,7 +995,7 @@ void Snail::runCom() { if (spr && _talkEnable) { if (spr == _hero && spr->seqTest(-1)) spr->step(kSeqHTalk); - sayTime(spr); + _text->sayTime(spr); } break; case kSnCave: diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 699bd5bcc1..0e77bb8955 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -234,16 +234,12 @@ void CGEEngine::inf(const char *text) { } } -void sayTime(Sprite *spr) { - /* - static char t[] = "00:00"; - struct time ti; - gettime(&ti); - wtom(ti.ti_hour, t+0, 10, 2); - wtom(ti.ti_min, t+3, 10, 2); - Say((*t == '0') ? (t+1) : t, spr); - */ - warning("STUB: sayTime"); +void Text::sayTime(Sprite *spr) { + TimeDate curTime; + char t[6]; + _vm->_system->getTimeAndDate(curTime); + sprintf(t, "%d:%02d", curTime.tm_hour, curTime.tm_min); + say(t, spr); } void killText() { diff --git a/engines/cge/text.h b/engines/cge/text.h index bb905ac655..d6845f4361 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -60,6 +60,7 @@ public: void preload(int from = 1, int upto = 0x7FFF); char *getText(int ref); void say(const char *text, Sprite *spr); + void sayTime(Sprite *spr); private: CGEEngine *_vm; }; @@ -67,9 +68,6 @@ private: extern Talk *_talk; extern Text *_text; -void say(const char *text, Sprite *spr); -void sayTime(Sprite *spr); -void inf(const char *text); void killText(); } // End of namespace CGE -- cgit v1.2.3 From 177da650dde785abbee7ed446e71115839082517 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Aug 2011 18:06:09 +1000 Subject: CGE: Fix loading of vol.cat file to be endian safe --- engines/cge/btfile.cpp | 41 +++++++++++++++++++++++++++++++++++------ engines/cge/btfile.h | 16 ++++++++-------- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 1f987340b7..7ecfa94e9b 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -31,6 +31,7 @@ #include "cge/cge.h" #include "common/debug.h" #include "common/debug-channels.h" +#include "common/memstream.h" namespace CGE { @@ -61,8 +62,8 @@ void BtFile::putPage(int lev, bool hard) { debugC(1, kCGEDebugFile, "BtFile::putPage(%d, %s)", lev, hard ? "true" : "false"); if (hard || _buff[lev]._updt) { - seek(_buff[lev]._pgNo * sizeof(BtPage)); - write((uint8 *) _buff[lev]._page, sizeof(BtPage)); + seek(_buff[lev]._pgNo * kBtSize); + write((uint8 *) _buff[lev]._page, kBtSize); _buff[lev]._updt = false; } } @@ -72,17 +73,25 @@ BtPage *BtFile::getPage(int lev, uint16 pgn) { debugC(1, kCGEDebugFile, "BtFile::getPage(%d, %d)", lev, pgn); if (_buff[lev]._pgNo != pgn) { - int32 pos = pgn * sizeof(BtPage); + int32 pos = pgn * kBtSize; putPage(lev, false); _buff[lev]._pgNo = pgn; if (size() > pos) { - seek((uint32) pgn * sizeof(BtPage)); - read((uint8 *) _buff[lev]._page, sizeof(BtPage)); + seek((uint32) pgn * kBtSize); + + // Read in the page + byte buffer[kBtSize]; + int bytesRead = read(buffer, kBtSize); + + // Unpack it into the page structure + Common::MemoryReadStream stream(buffer, bytesRead, DisposeAfterUse::NO); + _buff[lev]._page->read(stream); + _buff[lev]._updt = false; } else { + memset(&_buff[lev]._page, 0, kBtSize); _buff[lev]._page->_hea._count = 0; _buff[lev]._page->_hea._down = kBtValNone; - memset(_buff[lev]._page->_data, '\0', sizeof(_buff[lev]._page->_data)); _buff[lev]._updt = true; } _buff[lev]._indx = -1; @@ -152,4 +161,24 @@ void BtFile::make(BtKeypack *keypack, uint16 count) { } } +void BtPage::read(Common::ReadStream &s) { + _hea._count = s.readUint16LE(); + _hea._down = s.readUint16LE(); + + if (_hea._down == kBtValNone) { + // Leaf list + for (int i = 0; i < kBtLeafCount; ++i) { + s.read(_lea[i]._key, kBtKeySize); + _lea[i]._mark = s.readUint32LE(); + _lea[i]._size = s.readUint16LE(); + } + } else { + // Root index + for (int i = 0; i < kBtInnerCount; ++i) { + s.read(_inn[i]._key, kBtKeySize); + _inn[i]._down = s.readUint16LE(); + } + } +} + } // End of namespace CGE diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 6b7155d43d..26b008bea6 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -29,18 +29,19 @@ #define __CGE_BTFILE__ #include "cge/general.h" +#include "common/stream.h" namespace CGE { #define kBtSize 1024 #define kBtKeySize 13 #define kBtLevel 2 +#define kBtInnerCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 2 /*sizeof(Inner) */)) +#define kBtLeafCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 4 + 2 /*sizeof(BtKeypack) */)) #define kBtValNone 0xFFFF #define kBtValRoot 0 -#include "common/pack-start.h" // START STRUCT PACKING - struct BtKeypack { char _key[kBtKeySize]; uint32 _mark; @@ -61,16 +62,15 @@ struct BtPage { Hea _hea; union { // dummy filler to make proper size of union - uint8 _data[kBtSize - sizeof(Hea)]; + uint8 _data[kBtSize - 4 /*sizeof(Hea) */]; // inner version of data: key + word-sized page link - Inner _inn[(kBtSize - sizeof(Hea)) / sizeof(Inner)]; + Inner _inn[kBtInnerCount]; // leaf version of data: key + all user data - BtKeypack _lea[(kBtSize - sizeof(Hea)) / sizeof(BtKeypack)]; + BtKeypack _lea[kBtLeafCount]; }; -}; - -#include "common/pack-end.h" // END STRUCT PACKING + void read(Common::ReadStream &s); +}; class BtFile : public IoHand { struct { -- cgit v1.2.3 From 1d3f1830c890f2f4f2fbb8fcf4db90dfe1bacdde Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 13 Aug 2011 10:09:45 +0200 Subject: CGE: Remove useless functions related to data file creation (unused) --- engines/cge/btfile.cpp | 26 -------------------------- engines/cge/btfile.h | 1 - engines/cge/general.cpp | 16 ---------------- engines/cge/general.h | 8 -------- engines/cge/vol.cpp | 17 +---------------- engines/cge/vol.h | 11 +---------- 6 files changed, 2 insertions(+), 77 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 7ecfa94e9b..053f264b35 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -135,32 +135,6 @@ int keycomp(const void *k1, const void *k2) { return scumm_strnicmp((const char *) k1, (const char*) k2, kBtKeySize); } - -void BtFile::make(BtKeypack *keypack, uint16 count) { - debugC(1, kCGEDebugFile, "BtFile::make(keypack, %d)", count); - -#if kBtLevel != 2 -#error This tiny BTREE implementation works with exactly 2 levels! -#endif - _fqsort(keypack, count, sizeof(*keypack), keycomp); - uint16 n = 0; - BtPage *Root = getPage(0, n++); - BtPage *Leaf = getPage(1, n); - Root->_hea._down = n; - putPage(0, true); - while (count--) { - if (Leaf->_hea._count >= ArrayCount(Leaf->_lea)) { - putPage(1, true); // save filled page - Leaf = getPage(1, ++n); // take empty page - memcpy(Root->_inn[Root->_hea._count]._key, keypack->_key, kBtKeySize); - Root->_inn[Root->_hea._count++]._down = n; - _buff[0]._updt = true; - } - Leaf->_lea[Leaf->_hea._count++] = *(keypack++); - _buff[1]._updt = true; - } -} - void BtPage::read(Common::ReadStream &s) { _hea._count = s.readUint16LE(); _hea._down = s.readUint16LE(); diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 26b008bea6..7cfdc263e7 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -87,7 +87,6 @@ public: virtual ~BtFile(); BtKeypack *find(const char *key); BtKeypack *next(); - void make(BtKeypack *keypack, uint16 count); }; } // End of namespace CGE diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index ddfb982d58..6d7b1daf88 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -92,10 +92,6 @@ Dac _stdPal[] = {// R G B { 255, 255, 255}, // 255 }; -void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)) { - warning("STUB: _fqsort"); -} - const char *progName(const char *ext) { static char buf[kMaxFile]; strcpy(buf, "CGE"); @@ -292,18 +288,6 @@ int takeEnum(const char **tab, const char *text) { return -1; } -long timer() { -/* - asm mov ax,0x40 - asm mov es,ax - asm mov cx,es:[0x6C] - asm mov dx,es:[0x6E] - return ((long) _DX << 16) | _CX; -*/ - warning("STUB: timer"); - return 0; -} - int newRandom(int range) { return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } diff --git a/engines/cge/general.h b/engines/cge/general.h index fe34606108..90cba269cd 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -113,22 +113,14 @@ char *wtom(uint16 val, char *str, int radix, int len); char *dwtom(uint32 val, char *str, int radix, int len); int takeEnum(const char **tab, const char *text); uint16 chkSum(void *m, uint16 n); -long timer(); char *mergeExt(char *buf, const char *name, const char *ext); char *forceExt(char *buf, const char *name, const char *ext); // MISSING FUNCTIONS -void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *)); const char *progName(const char *ext = NULL); unsigned fastRand(); unsigned fastRand(unsigned s); uint16 rCrypt(void *buf, uint16 siz, uint16 seed); -uint16 atow(const char *a); -uint16 xtow(const char *x); -char *wtom(uint16 val, char *str, int radix, int len); -char *dwtom(uint32 val, char * str, int radix, int len); -int takeEnum(const char **tab, const char *text); -long timer(); int newRandom(int range); } // End of namespace CGE diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index b3cc49495a..44cad5e832 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -40,13 +40,7 @@ VFile *VFile::_recent = NULL; /*-----------------------------------------------------------------------*/ -Dat::Dat(): -#ifdef VOL_UPD - _file(DAT_NAME, UPD, CRP) -#else - _file(DAT_NAME, kModeRead, CRP) -#endif -{ +Dat::Dat(): _file(DAT_NAME, kModeRead, CRP) { debugC(1, kCGEDebugFile, "Dat::Dat()"); } @@ -56,12 +50,7 @@ void VFile::init() { debugC(1, kCGEDebugFile, "VFile::init()"); _dat = new Dat(); -#ifdef VOL_UPD - _cat = new BtFile(CAT_NAME, UPD, CRP); -#else _cat = new BtFile(CAT_NAME, kModeRead, CRP); -#endif - _recent = NULL; } @@ -82,10 +71,6 @@ VFile::VFile(const char *name, IOMode mode) _error = 1; _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size; } -#ifdef VOL_UPD - else - Make(name); -#endif } diff --git a/engines/cge/vol.h b/engines/cge/vol.h index f64e7eec54..f9d9382eac 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -36,16 +36,9 @@ namespace CGE { #define CAT_NAME "VOL.CAT" #define DAT_NAME "VOL.DAT" -#define CRP XCrypt - +#define CRP XCrypt #define XMASK 0xA5 - -#ifdef VOL_UPD -#define VOLBASE IOHAND -#else #define VOLBASE CFile -#endif - class Dat { friend class VFile; @@ -58,7 +51,6 @@ public: bool read(long org, uint16 len, uint8 *buf); }; - class VFile : public IoBuf { private: static Dat *_dat; @@ -70,7 +62,6 @@ private: void readBuf(); void writeBuf() { } - void make(const char *fspec); public: VFile(const char *name, IOMode mode = kModeRead); ~VFile(); -- cgit v1.2.3 From 9a94a239b8b9099ebfb8b4061ca68a0a7b1174b7 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 17 Aug 2011 10:12:37 +0200 Subject: CGE: Fix gcc shadowed member warning. --- engines/cge/general.cpp | 4 ++-- engines/cge/sound.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 6d7b1daf88..112de730ec 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -292,9 +292,9 @@ int newRandom(int range) { return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } -DataCk::DataCk(byte *buf, int size) { +DataCk::DataCk(byte *buf, int bufSize) { _buf = buf; - _ckSize = size; + _ckSize = bufSize; } DataCk::~DataCk() { diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 01b11487d0..e6bc2dedde 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -47,7 +47,7 @@ class DataCk { byte *_buf; int _ckSize; public: - DataCk(byte *buf, int size); + DataCk(byte *buf, int bufSize); ~DataCk(); inline const byte *addr() { return _buf; -- cgit v1.2.3 From a9f002897ea344d8851d66a9a3fa27dd3d457fa7 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 17 Aug 2011 10:50:26 +0200 Subject: CGE: Preserve const in cast. --- engines/cge/snddrv.h | 2 +- engines/cge/sound.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 0678971d0c..7af214365f 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -45,7 +45,7 @@ namespace CGE { // sample info struct SmpInfo { - uint8 *_saddr; // address + const uint8 *_saddr; // address uint16 _slen; // length uint16 _span; // left/right pan (0-15) int _sflag; // flag diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index a3895958f0..8a199c7ee2 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -61,7 +61,7 @@ void Sound::open() { void Sound::play(DataCk *wav, int pan, int cnt) { if (wav) { stop(); - _smpinf._saddr = (uint8 *) &*(wav->addr()); + _smpinf._saddr = &*(wav->addr()); _smpinf._slen = (uint16)wav->size(); _smpinf._span = pan; _smpinf._sflag = cnt; -- cgit v1.2.3 From 23689cac23fcbe205f28434ddbb4a686feda4dea Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 17 Aug 2011 10:55:49 +0200 Subject: CGE: Remove unused Rgb/Trgb/mkRgb. --- engines/cge/vga13h.cpp | 10 ---------- engines/cge/vga13h.h | 15 --------------- 2 files changed, 25 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 51be2ed1e8..9b063f0c02 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -118,16 +118,6 @@ Dac mkDac(uint8 r, uint8 g, uint8 b) { return x; } - -Rgb mkRgb(uint8 r, uint8 g, uint8 b) { - static Trgb x; - x._dac._r = r; - x._dac._g = g; - x._dac._b = b; - return x._rgb; -} - - Sprite *locate(int ref) { Sprite *spr = _vga->_showQ->locate(ref); return (spr) ? spr : _vga->_spareQ->locate(ref); diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index db75b48692..d43e590084 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -65,20 +65,6 @@ namespace CGE { #define SPR_EXT ".SPR" -struct Rgb { - uint16 _r : 2; - uint16 _R : 6; - uint16 _g : 2; - uint16 _G : 6; - uint16 _b : 2; - uint16 _B : 6; -}; - -typedef union { - Dac _dac; - Rgb _rgb; -} Trgb; - struct VgaRegBlk { uint8 _idx; uint8 _adr; @@ -299,7 +285,6 @@ public: Dac mkDac(uint8 r, uint8 g, uint8 b); -Rgb mkRgb(uint8 r, uint8 g, uint8 b); template -- cgit v1.2.3 From 85a0fa03ad72be9942decc84b87a6c91c71e5652 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 18 Aug 2011 00:33:54 +0200 Subject: CGE: Remove unused _intStackPtr. --- engines/cge/cge_main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 24cdaf5e92..a154a3d141 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -91,7 +91,6 @@ const char *savegameStr = "SCUMMVM_CGE"; static bool _finis = false; int _offUseCount; -uint16 *_intStackPtr = NULL; extern Dac _stdPal[58]; @@ -1730,9 +1729,6 @@ bool CGEEngine::showTitle(const char *name) { } void CGEEngine::cge_main() { - uint16 intStack[kStackSize / 2]; - _intStackPtr = intStack; - memset(_barriers, 0xFF, sizeof(_barriers)); if (!_mouse->_exist) -- cgit v1.2.3 From 40ea6d788bfabb9d692377fa0baf87b3e5824e0c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 19 Aug 2011 07:25:58 +0200 Subject: CGE: Suppress some dead code --- engines/cge/sound.cpp | 20 -------------------- engines/cge/vga13h.cpp | 24 +----------------------- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 8a199c7ee2..b22548c16d 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -179,26 +179,6 @@ DataCk *Fx::operator [](int ref) { return _current; } -void *Patch(int pat) { - void *p = NULL; - static char fn[] = "PATCH000.SND"; - - wtom(pat, fn + 5, 10, 3); - INI_FILE snd = fn; - if (!snd._error) { - uint16 siz = (uint16) snd.size(); - p = (uint8 *) malloc(siz); - if (p) { - snd.read(p, siz); - if (snd._error) { - free(p); - p = NULL; - } - } - } - return p; -} - MusicPlayer::MusicPlayer() { _data = NULL; _isGM = false; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9b063f0c02..ad2415caaf 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -77,28 +77,6 @@ Seq *getConstantSeq(bool seqFlag) { extern "C" void SNDMIDIPlay(); -/* -static void Video() { - static uint16 SP_S; - - asm push bx - asm push bp - asm push si - asm push di - asm push es - asm xor bx,bx // video page #0 - SP_S = _SP; - asm int VIDEO - _SP = SP_S; - asm pop es - asm pop di - asm pop si - asm pop bp - asm pop bx -} -*/ - - uint16 *SaveScreen() { // In ScummVM, we don't need to worry about saving the original screen mode return 0; @@ -125,7 +103,7 @@ Sprite *locate(int ref) { Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), - _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), + _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; -- cgit v1.2.3 From 0d730b85e3e05829ba5ce3fbcdbf2886a9a28a94 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Aug 2011 19:49:05 +1000 Subject: CGE: Changed the Sprite bit-flags into a union, to fix savegame endian issues --- engines/cge/cge_main.cpp | 86 ++++++++++++++++++++++++------------------------ engines/cge/events.cpp | 10 +++--- engines/cge/game.cpp | 2 +- engines/cge/gettext.cpp | 4 +-- engines/cge/mixer.cpp | 16 ++++----- engines/cge/snail.cpp | 52 ++++++++++++++--------------- engines/cge/talk.cpp | 4 +-- engines/cge/text.cpp | 14 ++++---- engines/cge/vga13h.cpp | 28 ++++++++-------- engines/cge/vga13h.h | 22 ++++++++----- engines/cge/vmenu.cpp | 12 +++---- engines/cge/walk.cpp | 14 ++++---- 12 files changed, 134 insertions(+), 130 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index a154a3d141..213ad7abec 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -470,8 +470,8 @@ void CGEEngine::loadMapping() { } Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { - _flags._kill = true; - _flags._bDel = false; + _flags.flags._kill = true; + _flags.flags._bDel = false; BitmapPtr *MB = new BitmapPtr[2]; MB[0] = new Bitmap("BRICK", true); @@ -528,7 +528,7 @@ void CGEEngine::quit() { { NULL, &CGEEngine::dummy } }; - if (_snail->idle() && !_hero->_flags._hide) { + if (_snail->idle() && !_hero->_flags.flags._hide) { if (Vmenu::_addr) { _snail_->addCom(kSnKill, -1, 0, Vmenu::_addr); resetQSwitch(); @@ -553,13 +553,13 @@ void CGEEngine::miniStep(int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::miniStep(%d)", stp); if (stp < 0) - _miniCave->_flags._hide = true; + _miniCave->_flags.flags._hide = true; else { *_miniShp[0] = *_miniShpList[stp]; if (_fx->_current) &*(_fx->_current->addr()); - _miniCave->_flags._hide = false; + _miniCave->_flags.flags._hide = false; } } @@ -600,7 +600,7 @@ void CGEEngine::caveUp() { Sprite *n = spr->_next; if (spr->_cave == _now || spr->_cave == 0) if (spr->_ref != BakRef) { - if (spr->_flags._back) + if (spr->_flags.flags._back) spr->backShow(); else expandSprite(spr); @@ -618,7 +618,7 @@ void CGEEngine::caveUp() { // following 2 lines trims Hero's Z position! _hero->tick(); _hero->_time = 1; - _hero->_flags._hide = false; + _hero->_flags.flags._hide = false; } if (!_dark) @@ -650,7 +650,7 @@ void CGEEngine::caveDown() { debugC(1, kCGEDebugEngine, "CGEEngine::caveDown()"); Sprite *spr; - if (_horzLine && !_horzLine->_flags._hide) + if (_horzLine && !_horzLine->_flags.flags._hide) switchMapping(); for (spr = _vga->_showQ->first(); spr;) { @@ -823,7 +823,7 @@ void System::touch(uint16 mask, int x, int y) { _sprite->step(x - '0'); break; case F10 : - if (_snail->idle() && !_hero->_flags._hide) + if (_snail->idle() && !_hero->_flags.flags._hide) _vm->startCountDown(); break; } @@ -857,7 +857,7 @@ void System::touch(uint16 mask, int x, int y) { if (cav && _snail->idle() && _hero->_tracePtr < 0) _vm->switchCave(cav); - if (_horzLine && !_horzLine->_flags._hide) { + if (_horzLine && !_horzLine->_flags.flags._hide) { if (y >= kMapTop && y < kMapTop + kMapHig) { int8 x1, z1; XZ(x, y).split(x1, z1); @@ -960,7 +960,7 @@ void CGEEngine::switchMapping() { assert(_horzLine); debugC(1, kCGEDebugEngine, "CGEEngine::switchMapping()"); - if (_horzLine && _horzLine->_flags._hide) { + if (_horzLine && _horzLine->_flags.flags._hide) { int i; for (i = 0; i < kMapZCnt; i++) { int j; @@ -975,14 +975,14 @@ void CGEEngine::switchMapping() { if (s->_w == kMapGridX && s->_h == kMapGridZ) _snail_->addCom(kSnKill, -1, 0, s); } - _horzLine->_flags._hide = !_horzLine->_flags._hide; + _horzLine->_flags.flags._hide = !_horzLine->_flags.flags._hide; } void CGEEngine::killSprite() { debugC(1, kCGEDebugEngine, "CGEEngine::killSprite()"); - _sprite->_flags._kill = true; - _sprite->_flags._bDel = true; + _sprite->_flags.flags._kill = true; + _sprite->_flags.flags._bDel = true; _snail_->addCom(kSnKill, -1, 0, _sprite); _sprite = NULL; } @@ -1007,7 +1007,7 @@ void CGEEngine::pullSprite() { if (spr) { spr = spr->_next; if (spr) - ok = (!spr->_flags._slav); + ok = (!spr->_flags.flags._slav); } if (ok) { _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); @@ -1058,7 +1058,7 @@ void CGEEngine::sayDebug() { char *spH = DebugText + 37; char *spF = DebugText + 41; - if (!_debugLine->_flags._hide) { + if (!_debugLine->_flags.flags._hide) { dwtom(_mouse->_x, absX, 10, 3); dwtom(_mouse->_y, absY, 10, 3); @@ -1083,7 +1083,7 @@ void CGEEngine::sayDebug() { void CGEEngine::switchDebug() { - _debugLine->_flags._hide = !_debugLine->_flags._hide; + _debugLine->_flags.flags._hide = !_debugLine->_flags.flags._hide; } @@ -1121,7 +1121,7 @@ void Sprite::touch(uint16 mask, int x, int y) { _vm->optionTouch(_ref % 10, mask); return; } - if (_flags._syst) + if (_flags.flags._syst) return; // cannot access system sprites if (_vm->_game) if (mask & kMouseLeftUp) { mask &= ~kMouseLeftUp; @@ -1130,7 +1130,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if ((mask & kMouseRightUp) && _snail->idle()) { Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL; if (ps) { - if (_flags._kept || _hero->distance(this) < kDistMax) { + if (_flags.flags._kept || _hero->distance(this) < kDistMax) { if (works(ps)) { _vm->feedSnail(ps, kTake); } else @@ -1139,18 +1139,18 @@ void Sprite::touch(uint16 mask, int x, int y) { } else _vm->tooFar(); } else { - if (_flags._kept) + if (_flags.flags._kept) mask |= kMouseLeftUp; else { if (_hero->distance(this) < kDistMax) { /// - if (_flags._port) { + if (_flags.flags._port) { if (_vm->findPocket(NULL) < 0) _vm->pocFul(); else { _snail->addCom(kSnReach, -1, -1, this); _snail->addCom(kSnKeep, -1, -1, this); - _flags._port = false; + _flags.flags._port = false; } } else { if (_takePtr != NO_PTR) { @@ -1168,7 +1168,7 @@ void Sprite::touch(uint16 mask, int x, int y) { } } if ((mask & kMouseLeftUp) && _snail->idle()) { - if (_flags._kept) { + if (_flags.flags._kept) { int n; for (n = 0; n < kPocketNX; n++) { if (_pocket[n] == this) { @@ -1319,11 +1319,11 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int _sprite->_ref = ref; _sprite->_cave = cav; _sprite->_z = pos; - _sprite->_flags._east = east; - _sprite->_flags._port = port; - _sprite->_flags._tran = tran; - _sprite->_flags._kill = true; - _sprite->_flags._bDel = true; + _sprite->_flags.flags._east = east; + _sprite->_flags.flags._port = port; + _sprite->_flags.flags._tran = tran; + _sprite->_flags.flags._kill = true; + _sprite->_flags.flags._bDel = true; // Extract the filename, without the extension strcpy(_sprite->_file, fname); @@ -1390,7 +1390,7 @@ void CGEEngine::loadScript(const char *fname) { _sprite = NULL; loadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); if (_sprite && BkG) - _sprite->_flags._back = true; + _sprite->_flags.flags._back = true; } if (! ok) error("Bad INI line %d [%s]", lcnt, fname); @@ -1452,7 +1452,7 @@ void CGEEngine::handleFrame() { void CGEEngine::tick() { for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (spr->_time) { - if (!spr->_flags._hide) { + if (!spr->_flags.flags._hide) { if (--spr->_time == 0) spr->tick(); } @@ -1483,9 +1483,9 @@ void CGEEngine::runGame() { _text->preload(100, 1000); loadHeroXY(); - _cavLight->_flags._tran = true; + _cavLight->_flags.flags._tran = true; _vga->_showQ->append(_cavLight); - _cavLight->_flags._hide = true; + _cavLight->_flags.flags._hide = true; const Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, @@ -1500,7 +1500,7 @@ void CGEEngine::runGame() { Common::copy(pocSeq, pocSeq + 7, seq); _pocLight->setSeq(seq); - _pocLight->_flags._tran = true; + _pocLight->_flags.flags._tran = true; _pocLight->_time = 1; _pocLight->_z = 120; _vga->_showQ->append(_pocLight); @@ -1527,8 +1527,8 @@ void CGEEngine::runGame() { loadSprite("MINI", -1, 0, kMiniX, kMiniY); expandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { - _miniCave->_flags._kill = false; - _miniCave->_flags._hide = true; + _miniCave->_flags.flags._kill = false; + _miniCave->_flags.flags._hide = true; _miniShp[0] = new Bitmap(*_miniCave->shp()); _miniShpList = _miniCave->setShapeList(_miniShp); postMiniStep(-1); @@ -1543,16 +1543,16 @@ void CGEEngine::runGame() { delete _shadow; if ((_shadow = _sprite) != NULL) { _shadow->_ref = 2; - _shadow->_flags._tran = true; - _shadow->_flags._kill = false; - _hero->_flags._shad = true; + _shadow->_flags.flags._tran = true; + _shadow->_flags.flags._kill = false; + _hero->_flags.flags._shad = true; _vga->_showQ->insert(_vga->_spareQ->remove(_shadow), _hero); } } } _infoLine->gotoxy(kInfoX, kInfoY); - _infoLine->_flags._tran = true; + _infoLine->_flags.flags._tran = true; _infoLine->update(NULL); _vga->_showQ->insert(_infoLine); @@ -1634,8 +1634,8 @@ bool CGEEngine::showTitle(const char *name) { bool userOk = false; Sprite D(this, LB); - D._flags._kill = true; - D._flags._bDel = true; + D._flags.flags._kill = true; + D._flags.flags._bDel = true; D.center(); D.show(2); @@ -1737,9 +1737,9 @@ void CGEEngine::cge_main() { if (!kSavegame0File::exist(kSavegame0Name)) _mode = 2; - _debugLine->_flags._hide = true; + _debugLine->_flags.flags._hide = true; if (_horzLine) - _horzLine->_flags._hide = true; + _horzLine->_flags.flags._hide = true; if (_music && _soundOk) _midiPlayer.loadMidi(0); diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 916de839eb..7235bf19c1 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -158,7 +158,7 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) _buttons = 0; _busy = NULL; _active = false; - _flags._kill = false; + _flags.flags._kill = false; const Seq ms[] = { { 0, 0, 0, 0, 1 }, @@ -301,9 +301,9 @@ void EventManager::handleEvents() { if (e._mask & kMouseLeftDown) { _mouse->_hold = e._spritePtr; if (_mouse->_hold) { - _mouse->_hold->_flags._hold = true; + _mouse->_hold->_flags.flags._hold = true; - if (_mouse->_hold->_flags._drag) { + if (_mouse->_hold->_flags.flags._drag) { _mouse->_hx = e._x - _mouse->_hold->_x; _mouse->_hy = e._y - _mouse->_hold->_y; } @@ -312,7 +312,7 @@ void EventManager::handleEvents() { if (e._mask & kMouseLeftUp) { if (_mouse->_hold) { - _mouse->_hold->_flags._hold = false; + _mouse->_hold->_flags.flags._hold = false; _mouse->_hold = NULL; } } @@ -325,7 +325,7 @@ void EventManager::handleEvents() { _eventQueueTail = (_eventQueueTail + 1) % kEventMax; } if (_mouse->_hold) { - if (_mouse->_hold->_flags._drag) + if (_mouse->_hold->_flags.flags._drag) _mouse->_hold->gotoxy(_mouse->_x - _mouse->_hx, _mouse->_y - _mouse->_hy); } } diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index e64e4af38a..0b9c6e2a40 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -56,7 +56,7 @@ Fly::Fly(CGEEngine *vm, Bitmap **shpl) void Fly::tick() { step(); - if (!_flags._kept) { + if (!_flags.flags._kept) { if (newRandom(10) < 1) { _tx = newRandom(3) - 1; _ty = newRandom(3) - 1; diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index d96e494402..34e8643668 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -46,8 +46,8 @@ GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) _ts[1] = NULL; setShapeList(_ts); - _flags._bDel = true; - _flags._kill = true; + _flags.flags._bDel = true; + _flags.flags._kill = true; memcpy(_buff, text, _len); _buff[_len] = ' '; _buff[_len + 1] = '\0'; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index ba24f832c3..513c6f683f 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -45,9 +45,9 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ _mb[1] = NULL; setShapeList(_mb); setName(_text->getText(kMixName)); - _flags._syst = true; - _flags._kill = true; - _flags._bDel = true; + _flags.flags._syst = true; + _flags.flags._kill = true; + _flags.flags._bDel = true; gotoxy(x, y); _z = kMixZ; @@ -73,13 +73,13 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ spr->setSeq(seq); spr->gotoxy(x + 2 + 12 * i, y + 8); - spr->_flags._tran = true; - spr->_flags._kill = true; - spr->_flags._bDel = false; + spr->_flags.flags._tran = true; + spr->_flags.flags._kill = true; + spr->_flags.flags._bDel = false; spr->_z = kMixZ; _led[i] = spr; } - _led[ArrayCount(_led) - 1]->_flags._bDel = true; + _led[ArrayCount(_led) - 1]->_flags.flags._bDel = true; _vga->_showQ->insert(this); for (i = 0; i < ArrayCount(_led); i++) @@ -128,7 +128,7 @@ void Mixer::tick() { int y = _mouse->_y; if (spriteAt(x, y) == this) { _fall = kMixFall; - if (_flags._hold) + if (_flags.flags._hold) touch(kMouseLeftUp, x - _x, y - _y); } else { if (_fall) diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 6a5556ca58..750d44f45c 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -493,7 +493,7 @@ void CGEEngine::snZTrim(Sprite *spr) { if (spr) if (spr->active()) { Sprite *s; - s = (spr->_flags._shad) ? spr->_prev : NULL; + s = (spr->_flags.flags._shad) ? spr->_prev : NULL; _vga->_showQ->insert(_vga->_showQ->remove(spr)); if (s) { s->_z = spr->_z; @@ -506,9 +506,9 @@ void CGEEngine::snHide(Sprite *spr, int val) { debugC(1, kCGEDebugEngine, "CGEEngine::snHide(spr, %d)", val); if (spr) { - spr->_flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags._hide); - if (spr->_flags._shad) - spr->_prev->_flags._hide = spr->_flags._hide; + spr->_flags.flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags.flags._hide); + if (spr->_flags.flags._shad) + spr->_prev->_flags.flags._hide = spr->_flags.flags._hide; } } @@ -554,18 +554,18 @@ void CGEEngine::snSend(Sprite *spr, int val) { spr->_cave = val; if (val1 != was1) { if (was1) { - if (spr->_flags._kept) { + if (spr->_flags.flags._kept) { int n = findPocket(spr); if (n >= 0) _pocket[n] = NULL; } hide1(spr); contractSprite(spr); - spr->_flags._slav = false; + spr->_flags.flags._slav = false; } else { if (spr->_ref % 1000 == 0) Bitmap::_pal = Vga::_sysPal; - if (spr->_flags._back) + if (spr->_flags.flags._back) spr->backShow(true); else expandSprite(spr); @@ -589,12 +589,12 @@ void CGEEngine::snSwap(Sprite *spr, int xref) { swap(spr->_x, xspr->_x); swap(spr->_y, xspr->_y); swap(spr->_z, xspr->_z); - if (spr->_flags._kept) { + if (spr->_flags.flags._kept) { int n = findPocket(spr); if (n >= 0) _pocket[n] = xspr; - xspr->_flags._kept = true; - xspr->_flags._port = false; + xspr->_flags.flags._kept = true; + xspr->_flags.flags._port = false; } if (xwas1 != was1) { if (was1) { @@ -617,14 +617,14 @@ void CGEEngine::snCover(Sprite *spr, int xref) { Sprite *xspr = locate(xref); if (spr && xspr) { - spr->_flags._hide = true; + spr->_flags.flags._hide = true; xspr->_z = spr->_z; xspr->_cave = spr->_cave; xspr->gotoxy(spr->_x, spr->_y); expandSprite(xspr); - if ((xspr->_flags._shad = spr->_flags._shad) == 1) { + if ((xspr->_flags.flags._shad = spr->_flags.flags._shad) == 1) { _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr); - spr->_flags._shad = false; + spr->_flags.flags._shad = false; } feedSnail(xspr, kNear); } @@ -635,12 +635,12 @@ void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) { debugC(1, kCGEDebugEngine, "CGEEngine::snUncover(spr, xspr)"); if (spr && xspr) { - spr->_flags._hide = false; + spr->_flags.flags._hide = false; spr->_cave = xspr->_cave; spr->gotoxy(xspr->_x, xspr->_y); - if ((spr->_flags._shad = xspr->_flags._shad) == 1) { + if ((spr->_flags.flags._shad = xspr->_flags.flags._shad) == 1) { _vga->_showQ->insert(_vga->_showQ->remove(xspr->_prev), spr); - xspr->_flags._shad = false; + xspr->_flags.flags._shad = false; } spr->_z = xspr->_z; snSend(xspr, -1); @@ -728,7 +728,7 @@ void CGEEngine::snSlave(Sprite *spr, int ref) { if (spr && slv) { if (spr->active()) { snSend(slv, spr->_cave); - slv->_flags._slav = true; + slv->_flags.flags._slav = true; slv->_z = spr->_z; _vga->_showQ->insert(_vga->_showQ->remove(slv), spr->_next); } @@ -740,21 +740,21 @@ void CGEEngine::snTrans(Sprite *spr, int trans) { debugC(1, kCGEDebugEngine, "CGEEngine::snTrans(spr, %d)", trans); if (spr) - spr->_flags._tran = (trans < 0) ? !spr->_flags._tran : (trans != 0); + spr->_flags.flags._tran = (trans < 0) ? !spr->_flags.flags._tran : (trans != 0); } void CGEEngine::snPort(Sprite *spr, int port) { debugC(1, kCGEDebugEngine, "CGEEngine::snPort(spr, %d)", port); if (spr) - spr->_flags._port = (port < 0) ? !spr->_flags._port : (port != 0); + spr->_flags.flags._port = (port < 0) ? !spr->_flags.flags._port : (port != 0); } void CGEEngine::snKill(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::snKill(spr)"); if (spr) { - if (spr->_flags._kept) { + if (spr->_flags.flags._kept) { int n = findPocket(spr); if (n >= 0) _pocket[n] = NULL; @@ -763,14 +763,14 @@ void CGEEngine::snKill(Sprite *spr) { hide1(spr); _vga->_showQ->remove(spr); _eventManager->clearEvent(spr); - if (spr->_flags._kill) + if (spr->_flags.flags._kill) delete spr; else { spr->_cave = -1; _vga->_spareQ->append(spr); } if (nx) { - if (nx->_flags._slav) + if (nx->_flags.flags._slav) snKill(nx); } } @@ -791,11 +791,11 @@ void CGEEngine::snKeep(Sprite *spr, int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::snKeep(spr, %d)", stp); selectPocket(-1); - if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) { + if (spr && ! spr->_flags.flags._kept && _pocket[_pocPtr] == NULL) { snSound(spr, 3, 1); _pocket[_pocPtr] = spr; spr->_cave = 0; - spr->_flags._kept = true; + spr->_flags.flags._kept = true; spr->gotoxy(kPocketX + kPocketDX * _pocPtr + kPocketDX / 2 - spr->_w / 2, kPocketY + kPocketDY / 2 - spr->_h / 2); if (stp >= 0) @@ -812,7 +812,7 @@ void CGEEngine::snGive(Sprite *spr, int stp) { if (p >= 0) { _pocket[p] = NULL; spr->_cave = _now; - spr->_flags._kept = false; + spr->_flags.flags._kept = false; if (stp >= 0) spr->step(stp); } @@ -843,7 +843,7 @@ void CGEEngine::snLevel(Sprite *spr, int lev) { } _maxCave = _maxCaveArr[_lev]; if (spr) - spr->_flags._hide = false; + spr->_flags.flags._hide = false; } diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index db44536267..0f38bb0892 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -77,7 +77,7 @@ Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode) : Sprite(vm, NULL), _mode(mode), _vm(vm) { _ts = NULL; - _flags._syst = true; + _flags.flags._syst = true; update(text); } @@ -85,7 +85,7 @@ Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode) Talk::Talk(CGEEngine *vm) : Sprite(vm, NULL), _mode(kTBPure), _vm(vm) { _ts = NULL; - _flags._syst = true; + _flags.flags._syst = true; } Font *Talk::_font; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 0e77bb8955..c3bdbea706 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -180,7 +180,7 @@ void Text::say(const char *text, Sprite *spr) { killText(); _talk = new Talk(_vm, text, kTBRound); if (_talk) { - bool east = spr->_flags._east; + bool east = spr->_flags.flags._east; int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); int y = spr->_y + 2; Sprite *spike = new Spike(_vm); @@ -197,8 +197,8 @@ void Text::say(const char *text, Sprite *spr) { if (spr->_ref == 1) x += ((east) ? -10 : 10); // Hero - _talk->_flags._kill = true; - _talk->_flags._bDel = true; + _talk->_flags.flags._kill = true; + _talk->_flags.flags._bDel = true; _talk->setName(_text->getText(kSayName)); _talk->gotoxy(x - (_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _talk->_h + 1); _talk->_z = 125; @@ -206,8 +206,8 @@ void Text::say(const char *text, Sprite *spr) { spike->gotoxy(x, _talk->_y + _talk->_h - 1); spike->_z = 126; - spike->_flags._slav = true; - spike->_flags._kill = true; + spike->_flags.flags._slav = true; + spike->_flags.flags._kill = true; spike->setName(_text->getText(kSayName)); spike->step(east); spike->_ref = kSayRef; @@ -223,8 +223,8 @@ void CGEEngine::inf(const char *text) { killText(); _talk = new Talk(this, text, kTBRect); if (_talk) { - _talk->_flags._kill = true; - _talk->_flags._bDel = true; + _talk->_flags.flags._kill = true; + _talk->_flags.flags._bDel = true; _talk->setName(_text->getText(kInfName)); _talk->center(); _talk->gotoxy(_talk->_x, _talk->_y - 20); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ad2415caaf..6c41292712 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -164,7 +164,7 @@ BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { } expand(); _ext->_shpList = shpP; - _flags._bDel = true; + _flags.flags._bDel = true; if (!_ext->_seq) setSeq(getConstantSeq(_shpCnt < 2)); } @@ -382,7 +382,7 @@ Sprite *Sprite::contract() { if (e) { if (e->_name) delete[] e->_name; - if (_flags._bDel && e->_shpList) { + if (_flags.flags._bDel && e->_shpList) { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; @@ -436,24 +436,24 @@ void Sprite::makeXlat(uint8 *x) { if (_ext) { BitmapPtr *b; - if (_flags._xlat) + if (_flags.flags._xlat) killXlat(); for (b = _ext->_shpList; *b; b++) (*b)->_m = x; - _flags._xlat = true; + _flags.flags._xlat = true; } } void Sprite::killXlat() { - if (_flags._xlat && _ext) { + if (_flags.flags._xlat && _ext) { BitmapPtr *b; uint8 *m = (*_ext->_shpList)->_m; free(m); for (b = _ext->_shpList; *b; b++) (*b)->_m = NULL; - _flags._xlat = false; + _flags.flags._xlat = false; } } @@ -475,9 +475,9 @@ void Sprite::gotoxy(int x, int y) { _y = y; } if (_next) - if (_next->_flags._slav) + if (_next->_flags.flags._slav) _next->gotoxy(_next->_x - xo + _x, _next->_y - yo + _y); - if (_flags._shad) + if (_flags.flags._shad) _prev->gotoxy(_prev->_x - xo + _x, _prev->_y - yo + _y); } @@ -498,8 +498,8 @@ void Sprite::show() { e->_y1 = _y; e->_b1 = shp(); // asm sti // ...done! - if (!_flags._hide) { - if (_flags._xlat) + if (!_flags.flags._hide) { + if (_flags.flags._xlat) e->_b1->xShow(e->_x1, e->_y1); else e->_b1->show(e->_x1, e->_y1); @@ -545,7 +545,7 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); // _ext s.syncAsUint16LE(_ref); s.syncAsByte(_cave); - s.syncBytes((byte *)&_flags, 2); + s.syncAsUint16LE(_flags.flagsWord); s.syncAsUint16LE(_x); s.syncAsUint16LE(_y); s.syncAsByte(_z); @@ -567,7 +567,7 @@ Sprite *spriteAt(int x, int y) { Sprite *spr = NULL, * tail = _vga->_showQ->last(); if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { - if (! spr->_flags._hide && ! spr->_flags._tran) { + if (! spr->_flags.flags._hide && ! spr->_flags.flags._tran) { if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) break; } @@ -589,7 +589,7 @@ Queue::~Queue() { void Queue::clear() { while (_head) { Sprite *s = remove(_head); - if (s->_flags._kill) + if (s->_flags.flags._kill) delete s; } } @@ -1077,7 +1077,7 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(LI); - _flags._kill = false; + _flags.flags._kill = false; } } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index d43e590084..9ac1bb3c63 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -120,14 +120,8 @@ public: {} }; - -class Sprite { -protected: - SprExt *_ext; -public: - int _ref; - signed char _cave; - struct Flags { +union Flags { + struct FlagsBits { uint16 _hide : 1; // general visibility switch uint16 _near : 1; // Near action lock uint16 _drag : 1; // sprite is moveable @@ -144,7 +138,17 @@ public: uint16 _back : 1; // 'send to background' request uint16 _bDel : 1; // delete bitmaps in ~SPRITE uint16 _tran : 1; // transparent (untouchable) - } _flags; + } flags; + uint16 flagsWord; +}; + +class Sprite { +protected: + SprExt *_ext; +public: + int _ref; + signed char _cave; + Flags _flags; int _x; int _y; signed char _z; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 48b27d9727..fc7ef2fe00 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -53,10 +53,10 @@ MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { _ts[1] = NULL; setShapeList(_ts); - _flags._slav = true; - _flags._tran = true; - _flags._kill = true; - _flags._bDel = true; + _flags.flags._slav = true; + _flags.flags._tran = true; + _flags.flags._kill = true; + _flags.flags._bDel = true; } @@ -98,8 +98,8 @@ Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) _items = 0; for (cp = list; cp->_text; cp++) _items++; - _flags._bDel = true; - _flags._kill = true; + _flags.flags._bDel = true; + _flags.flags._kill = true; if (x < 0 || y < 0) center(); else diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index a418bfb178..36fecdd22b 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -75,7 +75,7 @@ Walk::Walk(CGEEngine *vm, BitmapPtr *shpl) void Walk::tick() { - if (_flags._hide) + if (_flags.flags._hide) return; _here = XZ(_x + _w / 2, _y + _h); @@ -85,17 +85,17 @@ void Walk::tick() { _sys->funTouch(); for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (distance(spr) < 2) { - if (!spr->_flags._near) { + if (!spr->_flags.flags._near) { _vm->feedSnail(spr, kNear); - spr->_flags._near = true; + spr->_flags.flags._near = true; } } else { - spr->_flags._near = false; + spr->_flags.flags._near = false; } } } - if (_flags._hold || _tracePtr < 0) + if (_flags.flags._hold || _tracePtr < 0) park(); else { if (_here == _trace[_tracePtr]) { @@ -187,7 +187,7 @@ void Walk::findWay(Sprite *spr) { if (spr && spr != this) { int x = spr->_x; int z = spr->_z; - if (spr->_flags._east) + if (spr->_flags.flags._east) x += spr->_w + _w / 2 - kWalkSide; else x -= _w / 2 - kWalkSide; @@ -207,7 +207,7 @@ void Walk::reach(Sprite *spr, int mode) { if (spr) { _hero->findWay(spr); if (mode < 0) { - mode = spr->_flags._east; + mode = spr->_flags.flags._east; if (lower(spr)) mode += 2; } -- cgit v1.2.3 From 372d488b3bc01f6dce06dde83d4818a010695c70 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Aug 2011 20:36:43 +1000 Subject: CGE: Revert previous commit of flags synchronisation --- engines/cge/cge_main.cpp | 96 +++++++++++++++++++++++++----------------------- engines/cge/events.cpp | 10 ++--- engines/cge/game.cpp | 2 +- engines/cge/gettext.cpp | 4 +- engines/cge/mixer.cpp | 16 ++++---- engines/cge/snail.cpp | 52 +++++++++++++------------- engines/cge/talk.cpp | 4 +- engines/cge/text.cpp | 14 +++---- engines/cge/vga13h.cpp | 28 +++++++------- engines/cge/vga13h.h | 21 ++++------- engines/cge/vmenu.cpp | 12 +++--- engines/cge/walk.cpp | 14 +++---- engines/cge/walk.h | 2 +- 13 files changed, 137 insertions(+), 138 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 213ad7abec..5b98b0a4e8 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -462,16 +462,20 @@ void CGEEngine::loadMapping() { if (_now <= _caveMax) { INI_FILE cf(progName(".TAB")); if (!cf._error) { - memset(Cluster::_map, 0, sizeof(Cluster::_map)); - cf.seek((_now - 1) * sizeof(Cluster::_map)); - cf.read((uint8 *) Cluster::_map, sizeof(Cluster::_map)); + // Move to the data for the given room + cf.seek((_now - 1) * kMapArrSize); + + // Read in the data + for (int z = 0; z < kMapZCnt; ++z) { + cf.read(&Cluster::_map[z][0], kMapXCnt); + } } } } Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { - _flags.flags._kill = true; - _flags.flags._bDel = false; + _flags._kill = true; + _flags._bDel = false; BitmapPtr *MB = new BitmapPtr[2]; MB[0] = new Bitmap("BRICK", true); @@ -528,7 +532,7 @@ void CGEEngine::quit() { { NULL, &CGEEngine::dummy } }; - if (_snail->idle() && !_hero->_flags.flags._hide) { + if (_snail->idle() && !_hero->_flags._hide) { if (Vmenu::_addr) { _snail_->addCom(kSnKill, -1, 0, Vmenu::_addr); resetQSwitch(); @@ -553,13 +557,13 @@ void CGEEngine::miniStep(int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::miniStep(%d)", stp); if (stp < 0) - _miniCave->_flags.flags._hide = true; + _miniCave->_flags._hide = true; else { *_miniShp[0] = *_miniShpList[stp]; if (_fx->_current) &*(_fx->_current->addr()); - _miniCave->_flags.flags._hide = false; + _miniCave->_flags._hide = false; } } @@ -600,7 +604,7 @@ void CGEEngine::caveUp() { Sprite *n = spr->_next; if (spr->_cave == _now || spr->_cave == 0) if (spr->_ref != BakRef) { - if (spr->_flags.flags._back) + if (spr->_flags._back) spr->backShow(); else expandSprite(spr); @@ -618,7 +622,7 @@ void CGEEngine::caveUp() { // following 2 lines trims Hero's Z position! _hero->tick(); _hero->_time = 1; - _hero->_flags.flags._hide = false; + _hero->_flags._hide = false; } if (!_dark) @@ -650,7 +654,7 @@ void CGEEngine::caveDown() { debugC(1, kCGEDebugEngine, "CGEEngine::caveDown()"); Sprite *spr; - if (_horzLine && !_horzLine->_flags.flags._hide) + if (_horzLine && !_horzLine->_flags._hide) switchMapping(); for (spr = _vga->_showQ->first(); spr;) { @@ -823,7 +827,7 @@ void System::touch(uint16 mask, int x, int y) { _sprite->step(x - '0'); break; case F10 : - if (_snail->idle() && !_hero->_flags.flags._hide) + if (_snail->idle() && !_hero->_flags._hide) _vm->startCountDown(); break; } @@ -857,7 +861,7 @@ void System::touch(uint16 mask, int x, int y) { if (cav && _snail->idle() && _hero->_tracePtr < 0) _vm->switchCave(cav); - if (_horzLine && !_horzLine->_flags.flags._hide) { + if (_horzLine && !_horzLine->_flags._hide) { if (y >= kMapTop && y < kMapTop + kMapHig) { int8 x1, z1; XZ(x, y).split(x1, z1); @@ -960,7 +964,7 @@ void CGEEngine::switchMapping() { assert(_horzLine); debugC(1, kCGEDebugEngine, "CGEEngine::switchMapping()"); - if (_horzLine && _horzLine->_flags.flags._hide) { + if (_horzLine && _horzLine->_flags._hide) { int i; for (i = 0; i < kMapZCnt; i++) { int j; @@ -975,14 +979,14 @@ void CGEEngine::switchMapping() { if (s->_w == kMapGridX && s->_h == kMapGridZ) _snail_->addCom(kSnKill, -1, 0, s); } - _horzLine->_flags.flags._hide = !_horzLine->_flags.flags._hide; + _horzLine->_flags._hide = !_horzLine->_flags._hide; } void CGEEngine::killSprite() { debugC(1, kCGEDebugEngine, "CGEEngine::killSprite()"); - _sprite->_flags.flags._kill = true; - _sprite->_flags.flags._bDel = true; + _sprite->_flags._kill = true; + _sprite->_flags._bDel = true; _snail_->addCom(kSnKill, -1, 0, _sprite); _sprite = NULL; } @@ -1007,7 +1011,7 @@ void CGEEngine::pullSprite() { if (spr) { spr = spr->_next; if (spr) - ok = (!spr->_flags.flags._slav); + ok = (!spr->_flags._slav); } if (ok) { _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); @@ -1058,7 +1062,7 @@ void CGEEngine::sayDebug() { char *spH = DebugText + 37; char *spF = DebugText + 41; - if (!_debugLine->_flags.flags._hide) { + if (!_debugLine->_flags._hide) { dwtom(_mouse->_x, absX, 10, 3); dwtom(_mouse->_y, absY, 10, 3); @@ -1083,7 +1087,7 @@ void CGEEngine::sayDebug() { void CGEEngine::switchDebug() { - _debugLine->_flags.flags._hide = !_debugLine->_flags.flags._hide; + _debugLine->_flags._hide = !_debugLine->_flags._hide; } @@ -1121,7 +1125,7 @@ void Sprite::touch(uint16 mask, int x, int y) { _vm->optionTouch(_ref % 10, mask); return; } - if (_flags.flags._syst) + if (_flags._syst) return; // cannot access system sprites if (_vm->_game) if (mask & kMouseLeftUp) { mask &= ~kMouseLeftUp; @@ -1130,7 +1134,7 @@ void Sprite::touch(uint16 mask, int x, int y) { if ((mask & kMouseRightUp) && _snail->idle()) { Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL; if (ps) { - if (_flags.flags._kept || _hero->distance(this) < kDistMax) { + if (_flags._kept || _hero->distance(this) < kDistMax) { if (works(ps)) { _vm->feedSnail(ps, kTake); } else @@ -1139,18 +1143,18 @@ void Sprite::touch(uint16 mask, int x, int y) { } else _vm->tooFar(); } else { - if (_flags.flags._kept) + if (_flags._kept) mask |= kMouseLeftUp; else { if (_hero->distance(this) < kDistMax) { /// - if (_flags.flags._port) { + if (_flags._port) { if (_vm->findPocket(NULL) < 0) _vm->pocFul(); else { _snail->addCom(kSnReach, -1, -1, this); _snail->addCom(kSnKeep, -1, -1, this); - _flags.flags._port = false; + _flags._port = false; } } else { if (_takePtr != NO_PTR) { @@ -1168,7 +1172,7 @@ void Sprite::touch(uint16 mask, int x, int y) { } } if ((mask & kMouseLeftUp) && _snail->idle()) { - if (_flags.flags._kept) { + if (_flags._kept) { int n; for (n = 0; n < kPocketNX; n++) { if (_pocket[n] == this) { @@ -1319,11 +1323,11 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int _sprite->_ref = ref; _sprite->_cave = cav; _sprite->_z = pos; - _sprite->_flags.flags._east = east; - _sprite->_flags.flags._port = port; - _sprite->_flags.flags._tran = tran; - _sprite->_flags.flags._kill = true; - _sprite->_flags.flags._bDel = true; + _sprite->_flags._east = east; + _sprite->_flags._port = port; + _sprite->_flags._tran = tran; + _sprite->_flags._kill = true; + _sprite->_flags._bDel = true; // Extract the filename, without the extension strcpy(_sprite->_file, fname); @@ -1390,7 +1394,7 @@ void CGEEngine::loadScript(const char *fname) { _sprite = NULL; loadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); if (_sprite && BkG) - _sprite->_flags.flags._back = true; + _sprite->_flags._back = true; } if (! ok) error("Bad INI line %d [%s]", lcnt, fname); @@ -1452,7 +1456,7 @@ void CGEEngine::handleFrame() { void CGEEngine::tick() { for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (spr->_time) { - if (!spr->_flags.flags._hide) { + if (!spr->_flags._hide) { if (--spr->_time == 0) spr->tick(); } @@ -1483,9 +1487,9 @@ void CGEEngine::runGame() { _text->preload(100, 1000); loadHeroXY(); - _cavLight->_flags.flags._tran = true; + _cavLight->_flags._tran = true; _vga->_showQ->append(_cavLight); - _cavLight->_flags.flags._hide = true; + _cavLight->_flags._hide = true; const Seq pocSeq[] = { { 0, 0, 0, 0, 20 }, @@ -1500,7 +1504,7 @@ void CGEEngine::runGame() { Common::copy(pocSeq, pocSeq + 7, seq); _pocLight->setSeq(seq); - _pocLight->_flags.flags._tran = true; + _pocLight->_flags._tran = true; _pocLight->_time = 1; _pocLight->_z = 120; _vga->_showQ->append(_pocLight); @@ -1527,8 +1531,8 @@ void CGEEngine::runGame() { loadSprite("MINI", -1, 0, kMiniX, kMiniY); expandSprite(_miniCave = _sprite); // NULL is ok if (_miniCave) { - _miniCave->_flags.flags._kill = false; - _miniCave->_flags.flags._hide = true; + _miniCave->_flags._kill = false; + _miniCave->_flags._hide = true; _miniShp[0] = new Bitmap(*_miniCave->shp()); _miniShpList = _miniCave->setShapeList(_miniShp); postMiniStep(-1); @@ -1543,16 +1547,16 @@ void CGEEngine::runGame() { delete _shadow; if ((_shadow = _sprite) != NULL) { _shadow->_ref = 2; - _shadow->_flags.flags._tran = true; - _shadow->_flags.flags._kill = false; - _hero->_flags.flags._shad = true; + _shadow->_flags._tran = true; + _shadow->_flags._kill = false; + _hero->_flags._shad = true; _vga->_showQ->insert(_vga->_spareQ->remove(_shadow), _hero); } } } _infoLine->gotoxy(kInfoX, kInfoY); - _infoLine->_flags.flags._tran = true; + _infoLine->_flags._tran = true; _infoLine->update(NULL); _vga->_showQ->insert(_infoLine); @@ -1634,8 +1638,8 @@ bool CGEEngine::showTitle(const char *name) { bool userOk = false; Sprite D(this, LB); - D._flags.flags._kill = true; - D._flags.flags._bDel = true; + D._flags._kill = true; + D._flags._bDel = true; D.center(); D.show(2); @@ -1737,9 +1741,9 @@ void CGEEngine::cge_main() { if (!kSavegame0File::exist(kSavegame0Name)) _mode = 2; - _debugLine->_flags.flags._hide = true; + _debugLine->_flags._hide = true; if (_horzLine) - _horzLine->_flags.flags._hide = true; + _horzLine->_flags._hide = true; if (_music && _soundOk) _midiPlayer.loadMidi(0); diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 7235bf19c1..916de839eb 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -158,7 +158,7 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) _buttons = 0; _busy = NULL; _active = false; - _flags.flags._kill = false; + _flags._kill = false; const Seq ms[] = { { 0, 0, 0, 0, 1 }, @@ -301,9 +301,9 @@ void EventManager::handleEvents() { if (e._mask & kMouseLeftDown) { _mouse->_hold = e._spritePtr; if (_mouse->_hold) { - _mouse->_hold->_flags.flags._hold = true; + _mouse->_hold->_flags._hold = true; - if (_mouse->_hold->_flags.flags._drag) { + if (_mouse->_hold->_flags._drag) { _mouse->_hx = e._x - _mouse->_hold->_x; _mouse->_hy = e._y - _mouse->_hold->_y; } @@ -312,7 +312,7 @@ void EventManager::handleEvents() { if (e._mask & kMouseLeftUp) { if (_mouse->_hold) { - _mouse->_hold->_flags.flags._hold = false; + _mouse->_hold->_flags._hold = false; _mouse->_hold = NULL; } } @@ -325,7 +325,7 @@ void EventManager::handleEvents() { _eventQueueTail = (_eventQueueTail + 1) % kEventMax; } if (_mouse->_hold) { - if (_mouse->_hold->_flags.flags._drag) + if (_mouse->_hold->_flags._drag) _mouse->_hold->gotoxy(_mouse->_x - _mouse->_hx, _mouse->_y - _mouse->_hy); } } diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 0b9c6e2a40..e64e4af38a 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -56,7 +56,7 @@ Fly::Fly(CGEEngine *vm, Bitmap **shpl) void Fly::tick() { step(); - if (!_flags.flags._kept) { + if (!_flags._kept) { if (newRandom(10) < 1) { _tx = newRandom(3) - 1; _ty = newRandom(3) - 1; diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 34e8643668..d96e494402 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -46,8 +46,8 @@ GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) _ts[1] = NULL; setShapeList(_ts); - _flags.flags._bDel = true; - _flags.flags._kill = true; + _flags._bDel = true; + _flags._kill = true; memcpy(_buff, text, _len); _buff[_len] = ' '; _buff[_len + 1] = '\0'; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 513c6f683f..ba24f832c3 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -45,9 +45,9 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ _mb[1] = NULL; setShapeList(_mb); setName(_text->getText(kMixName)); - _flags.flags._syst = true; - _flags.flags._kill = true; - _flags.flags._bDel = true; + _flags._syst = true; + _flags._kill = true; + _flags._bDel = true; gotoxy(x, y); _z = kMixZ; @@ -73,13 +73,13 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ spr->setSeq(seq); spr->gotoxy(x + 2 + 12 * i, y + 8); - spr->_flags.flags._tran = true; - spr->_flags.flags._kill = true; - spr->_flags.flags._bDel = false; + spr->_flags._tran = true; + spr->_flags._kill = true; + spr->_flags._bDel = false; spr->_z = kMixZ; _led[i] = spr; } - _led[ArrayCount(_led) - 1]->_flags.flags._bDel = true; + _led[ArrayCount(_led) - 1]->_flags._bDel = true; _vga->_showQ->insert(this); for (i = 0; i < ArrayCount(_led); i++) @@ -128,7 +128,7 @@ void Mixer::tick() { int y = _mouse->_y; if (spriteAt(x, y) == this) { _fall = kMixFall; - if (_flags.flags._hold) + if (_flags._hold) touch(kMouseLeftUp, x - _x, y - _y); } else { if (_fall) diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 750d44f45c..6a5556ca58 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -493,7 +493,7 @@ void CGEEngine::snZTrim(Sprite *spr) { if (spr) if (spr->active()) { Sprite *s; - s = (spr->_flags.flags._shad) ? spr->_prev : NULL; + s = (spr->_flags._shad) ? spr->_prev : NULL; _vga->_showQ->insert(_vga->_showQ->remove(spr)); if (s) { s->_z = spr->_z; @@ -506,9 +506,9 @@ void CGEEngine::snHide(Sprite *spr, int val) { debugC(1, kCGEDebugEngine, "CGEEngine::snHide(spr, %d)", val); if (spr) { - spr->_flags.flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags.flags._hide); - if (spr->_flags.flags._shad) - spr->_prev->_flags.flags._hide = spr->_flags.flags._hide; + spr->_flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags._hide); + if (spr->_flags._shad) + spr->_prev->_flags._hide = spr->_flags._hide; } } @@ -554,18 +554,18 @@ void CGEEngine::snSend(Sprite *spr, int val) { spr->_cave = val; if (val1 != was1) { if (was1) { - if (spr->_flags.flags._kept) { + if (spr->_flags._kept) { int n = findPocket(spr); if (n >= 0) _pocket[n] = NULL; } hide1(spr); contractSprite(spr); - spr->_flags.flags._slav = false; + spr->_flags._slav = false; } else { if (spr->_ref % 1000 == 0) Bitmap::_pal = Vga::_sysPal; - if (spr->_flags.flags._back) + if (spr->_flags._back) spr->backShow(true); else expandSprite(spr); @@ -589,12 +589,12 @@ void CGEEngine::snSwap(Sprite *spr, int xref) { swap(spr->_x, xspr->_x); swap(spr->_y, xspr->_y); swap(spr->_z, xspr->_z); - if (spr->_flags.flags._kept) { + if (spr->_flags._kept) { int n = findPocket(spr); if (n >= 0) _pocket[n] = xspr; - xspr->_flags.flags._kept = true; - xspr->_flags.flags._port = false; + xspr->_flags._kept = true; + xspr->_flags._port = false; } if (xwas1 != was1) { if (was1) { @@ -617,14 +617,14 @@ void CGEEngine::snCover(Sprite *spr, int xref) { Sprite *xspr = locate(xref); if (spr && xspr) { - spr->_flags.flags._hide = true; + spr->_flags._hide = true; xspr->_z = spr->_z; xspr->_cave = spr->_cave; xspr->gotoxy(spr->_x, spr->_y); expandSprite(xspr); - if ((xspr->_flags.flags._shad = spr->_flags.flags._shad) == 1) { + if ((xspr->_flags._shad = spr->_flags._shad) == 1) { _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr); - spr->_flags.flags._shad = false; + spr->_flags._shad = false; } feedSnail(xspr, kNear); } @@ -635,12 +635,12 @@ void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) { debugC(1, kCGEDebugEngine, "CGEEngine::snUncover(spr, xspr)"); if (spr && xspr) { - spr->_flags.flags._hide = false; + spr->_flags._hide = false; spr->_cave = xspr->_cave; spr->gotoxy(xspr->_x, xspr->_y); - if ((spr->_flags.flags._shad = xspr->_flags.flags._shad) == 1) { + if ((spr->_flags._shad = xspr->_flags._shad) == 1) { _vga->_showQ->insert(_vga->_showQ->remove(xspr->_prev), spr); - xspr->_flags.flags._shad = false; + xspr->_flags._shad = false; } spr->_z = xspr->_z; snSend(xspr, -1); @@ -728,7 +728,7 @@ void CGEEngine::snSlave(Sprite *spr, int ref) { if (spr && slv) { if (spr->active()) { snSend(slv, spr->_cave); - slv->_flags.flags._slav = true; + slv->_flags._slav = true; slv->_z = spr->_z; _vga->_showQ->insert(_vga->_showQ->remove(slv), spr->_next); } @@ -740,21 +740,21 @@ void CGEEngine::snTrans(Sprite *spr, int trans) { debugC(1, kCGEDebugEngine, "CGEEngine::snTrans(spr, %d)", trans); if (spr) - spr->_flags.flags._tran = (trans < 0) ? !spr->_flags.flags._tran : (trans != 0); + spr->_flags._tran = (trans < 0) ? !spr->_flags._tran : (trans != 0); } void CGEEngine::snPort(Sprite *spr, int port) { debugC(1, kCGEDebugEngine, "CGEEngine::snPort(spr, %d)", port); if (spr) - spr->_flags.flags._port = (port < 0) ? !spr->_flags.flags._port : (port != 0); + spr->_flags._port = (port < 0) ? !spr->_flags._port : (port != 0); } void CGEEngine::snKill(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::snKill(spr)"); if (spr) { - if (spr->_flags.flags._kept) { + if (spr->_flags._kept) { int n = findPocket(spr); if (n >= 0) _pocket[n] = NULL; @@ -763,14 +763,14 @@ void CGEEngine::snKill(Sprite *spr) { hide1(spr); _vga->_showQ->remove(spr); _eventManager->clearEvent(spr); - if (spr->_flags.flags._kill) + if (spr->_flags._kill) delete spr; else { spr->_cave = -1; _vga->_spareQ->append(spr); } if (nx) { - if (nx->_flags.flags._slav) + if (nx->_flags._slav) snKill(nx); } } @@ -791,11 +791,11 @@ void CGEEngine::snKeep(Sprite *spr, int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::snKeep(spr, %d)", stp); selectPocket(-1); - if (spr && ! spr->_flags.flags._kept && _pocket[_pocPtr] == NULL) { + if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) { snSound(spr, 3, 1); _pocket[_pocPtr] = spr; spr->_cave = 0; - spr->_flags.flags._kept = true; + spr->_flags._kept = true; spr->gotoxy(kPocketX + kPocketDX * _pocPtr + kPocketDX / 2 - spr->_w / 2, kPocketY + kPocketDY / 2 - spr->_h / 2); if (stp >= 0) @@ -812,7 +812,7 @@ void CGEEngine::snGive(Sprite *spr, int stp) { if (p >= 0) { _pocket[p] = NULL; spr->_cave = _now; - spr->_flags.flags._kept = false; + spr->_flags._kept = false; if (stp >= 0) spr->step(stp); } @@ -843,7 +843,7 @@ void CGEEngine::snLevel(Sprite *spr, int lev) { } _maxCave = _maxCaveArr[_lev]; if (spr) - spr->_flags.flags._hide = false; + spr->_flags._hide = false; } diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 0f38bb0892..db44536267 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -77,7 +77,7 @@ Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode) : Sprite(vm, NULL), _mode(mode), _vm(vm) { _ts = NULL; - _flags.flags._syst = true; + _flags._syst = true; update(text); } @@ -85,7 +85,7 @@ Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode) Talk::Talk(CGEEngine *vm) : Sprite(vm, NULL), _mode(kTBPure), _vm(vm) { _ts = NULL; - _flags.flags._syst = true; + _flags._syst = true; } Font *Talk::_font; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index c3bdbea706..0e77bb8955 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -180,7 +180,7 @@ void Text::say(const char *text, Sprite *spr) { killText(); _talk = new Talk(_vm, text, kTBRound); if (_talk) { - bool east = spr->_flags.flags._east; + bool east = spr->_flags._east; int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); int y = spr->_y + 2; Sprite *spike = new Spike(_vm); @@ -197,8 +197,8 @@ void Text::say(const char *text, Sprite *spr) { if (spr->_ref == 1) x += ((east) ? -10 : 10); // Hero - _talk->_flags.flags._kill = true; - _talk->_flags.flags._bDel = true; + _talk->_flags._kill = true; + _talk->_flags._bDel = true; _talk->setName(_text->getText(kSayName)); _talk->gotoxy(x - (_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _talk->_h + 1); _talk->_z = 125; @@ -206,8 +206,8 @@ void Text::say(const char *text, Sprite *spr) { spike->gotoxy(x, _talk->_y + _talk->_h - 1); spike->_z = 126; - spike->_flags.flags._slav = true; - spike->_flags.flags._kill = true; + spike->_flags._slav = true; + spike->_flags._kill = true; spike->setName(_text->getText(kSayName)); spike->step(east); spike->_ref = kSayRef; @@ -223,8 +223,8 @@ void CGEEngine::inf(const char *text) { killText(); _talk = new Talk(this, text, kTBRect); if (_talk) { - _talk->_flags.flags._kill = true; - _talk->_flags.flags._bDel = true; + _talk->_flags._kill = true; + _talk->_flags._bDel = true; _talk->setName(_text->getText(kInfName)); _talk->center(); _talk->gotoxy(_talk->_x, _talk->_y - 20); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6c41292712..ad2415caaf 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -164,7 +164,7 @@ BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { } expand(); _ext->_shpList = shpP; - _flags.flags._bDel = true; + _flags._bDel = true; if (!_ext->_seq) setSeq(getConstantSeq(_shpCnt < 2)); } @@ -382,7 +382,7 @@ Sprite *Sprite::contract() { if (e) { if (e->_name) delete[] e->_name; - if (_flags.flags._bDel && e->_shpList) { + if (_flags._bDel && e->_shpList) { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; @@ -436,24 +436,24 @@ void Sprite::makeXlat(uint8 *x) { if (_ext) { BitmapPtr *b; - if (_flags.flags._xlat) + if (_flags._xlat) killXlat(); for (b = _ext->_shpList; *b; b++) (*b)->_m = x; - _flags.flags._xlat = true; + _flags._xlat = true; } } void Sprite::killXlat() { - if (_flags.flags._xlat && _ext) { + if (_flags._xlat && _ext) { BitmapPtr *b; uint8 *m = (*_ext->_shpList)->_m; free(m); for (b = _ext->_shpList; *b; b++) (*b)->_m = NULL; - _flags.flags._xlat = false; + _flags._xlat = false; } } @@ -475,9 +475,9 @@ void Sprite::gotoxy(int x, int y) { _y = y; } if (_next) - if (_next->_flags.flags._slav) + if (_next->_flags._slav) _next->gotoxy(_next->_x - xo + _x, _next->_y - yo + _y); - if (_flags.flags._shad) + if (_flags._shad) _prev->gotoxy(_prev->_x - xo + _x, _prev->_y - yo + _y); } @@ -498,8 +498,8 @@ void Sprite::show() { e->_y1 = _y; e->_b1 = shp(); // asm sti // ...done! - if (!_flags.flags._hide) { - if (_flags.flags._xlat) + if (!_flags._hide) { + if (_flags._xlat) e->_b1->xShow(e->_x1, e->_y1); else e->_b1->show(e->_x1, e->_y1); @@ -545,7 +545,7 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); // _ext s.syncAsUint16LE(_ref); s.syncAsByte(_cave); - s.syncAsUint16LE(_flags.flagsWord); + s.syncBytes((byte *)&_flags, 2); s.syncAsUint16LE(_x); s.syncAsUint16LE(_y); s.syncAsByte(_z); @@ -567,7 +567,7 @@ Sprite *spriteAt(int x, int y) { Sprite *spr = NULL, * tail = _vga->_showQ->last(); if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { - if (! spr->_flags.flags._hide && ! spr->_flags.flags._tran) { + if (! spr->_flags._hide && ! spr->_flags._tran) { if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) break; } @@ -589,7 +589,7 @@ Queue::~Queue() { void Queue::clear() { while (_head) { Sprite *s = remove(_head); - if (s->_flags.flags._kill) + if (s->_flags._kill) delete s; } } @@ -1077,7 +1077,7 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(LI); - _flags.flags._kill = false; + _flags._kill = false; } } // End of namespace CGE diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 9ac1bb3c63..1d41a068ff 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -120,8 +120,13 @@ public: {} }; -union Flags { - struct FlagsBits { +class Sprite { +protected: + SprExt *_ext; +public: + int _ref; + signed char _cave; + struct Flags { uint16 _hide : 1; // general visibility switch uint16 _near : 1; // Near action lock uint16 _drag : 1; // sprite is moveable @@ -138,17 +143,7 @@ union Flags { uint16 _back : 1; // 'send to background' request uint16 _bDel : 1; // delete bitmaps in ~SPRITE uint16 _tran : 1; // transparent (untouchable) - } flags; - uint16 flagsWord; -}; - -class Sprite { -protected: - SprExt *_ext; -public: - int _ref; - signed char _cave; - Flags _flags; + } _flags; int _x; int _y; signed char _z; diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index fc7ef2fe00..48b27d9727 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -53,10 +53,10 @@ MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { _ts[1] = NULL; setShapeList(_ts); - _flags.flags._slav = true; - _flags.flags._tran = true; - _flags.flags._kill = true; - _flags.flags._bDel = true; + _flags._slav = true; + _flags._tran = true; + _flags._kill = true; + _flags._bDel = true; } @@ -98,8 +98,8 @@ Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) _items = 0; for (cp = list; cp->_text; cp++) _items++; - _flags.flags._bDel = true; - _flags.flags._kill = true; + _flags._bDel = true; + _flags._kill = true; if (x < 0 || y < 0) center(); else diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index 36fecdd22b..a418bfb178 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -75,7 +75,7 @@ Walk::Walk(CGEEngine *vm, BitmapPtr *shpl) void Walk::tick() { - if (_flags.flags._hide) + if (_flags._hide) return; _here = XZ(_x + _w / 2, _y + _h); @@ -85,17 +85,17 @@ void Walk::tick() { _sys->funTouch(); for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (distance(spr) < 2) { - if (!spr->_flags.flags._near) { + if (!spr->_flags._near) { _vm->feedSnail(spr, kNear); - spr->_flags.flags._near = true; + spr->_flags._near = true; } } else { - spr->_flags.flags._near = false; + spr->_flags._near = false; } } } - if (_flags.flags._hold || _tracePtr < 0) + if (_flags._hold || _tracePtr < 0) park(); else { if (_here == _trace[_tracePtr]) { @@ -187,7 +187,7 @@ void Walk::findWay(Sprite *spr) { if (spr && spr != this) { int x = spr->_x; int z = spr->_z; - if (spr->_flags.flags._east) + if (spr->_flags._east) x += spr->_w + _w / 2 - kWalkSide; else x -= _w / 2 - kWalkSide; @@ -207,7 +207,7 @@ void Walk::reach(Sprite *spr, int mode) { if (spr) { _hero->findWay(spr); if (mode < 0) { - mode = spr->_flags.flags._east; + mode = spr->_flags._east; if (lower(spr)) mode += 2; } diff --git a/engines/cge/walk.h b/engines/cge/walk.h index c1d387f0b5..271663e51d 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -35,6 +35,7 @@ namespace CGE { #define kMapXCnt 40 #define kMapZCnt 20 +#define kMapArrSize (kMapZCnt * kMapXCnt) #define kMapTop 80 #define kMapHig 80 #define kMapGridX (kScrWidth / kMapXCnt) @@ -93,7 +94,6 @@ public: Cluster() : Couple (-1, -1) { } bool chkBar() const; bool isValid() const; - }; -- cgit v1.2.3 From 2b0cec1cd7b87fe971f2adc44da20e03e71991dc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Aug 2011 21:15:59 +1000 Subject: CGE: Fix problem with being able to walk into protected areas --- engines/cge/walk.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index a418bfb178..7bce9e29e6 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -49,7 +49,8 @@ bool Cluster::isValid() const { bool Cluster::chkBar() const { assert(_vm->_now <= _vm->_caveMax); - return (_a == _vm->_barriers[_vm->_now]._horz) && (_b == _vm->_barriers[_vm->_now]._vert); + return (_a < 0) || (_b < 0) || (_a >= _vm->_barriers[_vm->_now]._horz) || + (_b >= _vm->_barriers[_vm->_now]._vert); } Cluster XZ(int x, int y) { -- cgit v1.2.3 From 2178d64cbe795ab839ecac3bdbb4d7dd0bf647bd Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 14:54:34 +0200 Subject: CGE: Endian-swap the contents of block descriptions. --- engines/cge/bitmap.cpp | 18 +++++++++--------- engines/cge/talk.cpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index df68491bd5..ddab57eec8 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -106,16 +106,16 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) // + room for wash table assert(v != NULL); - *(uint16 *) v = kBmpCPY | dsiz; // data chunk hader + *(uint16 *) v = TO_LE_16(kBmpCPY | dsiz); // data chunk hader memset(v + 2, fill, dsiz); // data bytes - *(uint16 *)(v + lsiz - 2) = kBmpSKP | ((kScrWidth / 4) - dsiz); // gap + *(uint16 *)(v + lsiz - 2) = TO_LE_16(kBmpSKP | ((kScrWidth / 4) - dsiz)); // gap // Replicate lines byte *destP; for (destP = v + lsiz; destP < (v + psiz); destP += lsiz) Common::copy(v, v + lsiz, destP); - *(uint16 *)(v + psiz - 2) = kBmpEOI; // plane trailer uint16 + *(uint16 *)(v + psiz - 2) = TO_LE_16(kBmpEOI); // plane trailer uint16 // Repliccate planes for (destP = v + psiz; destP < (v + 4 * psiz); destP += psiz) @@ -239,7 +239,7 @@ BitmapPtr Bitmap::code() { if ((pix == kPixelTransp) != skip || cnt >= 0x3FF0) { // end of block cnt |= (skip) ? kBmpSKP : kBmpCPY; if (_v) - *cp = cnt; // store block description uint16 + *cp = TO_LE_16(cnt); // store block description uint16 cp = (uint16 *) im; im += 2; @@ -261,7 +261,7 @@ BitmapPtr Bitmap::code() { } else { cnt |= kBmpCPY; if (_v) - *cp = cnt; + *cp = TO_LE_16(cnt); cp = (uint16 *) im; im += 2; @@ -273,13 +273,13 @@ BitmapPtr Bitmap::code() { if (cnt && ! skip) { cnt |= kBmpCPY; if (_v) - *cp = cnt; + *cp = TO_LE_16(cnt); cp = (uint16 *) im; im += 2; } if (_v) - *cp = kBmpEOI; + *cp = TO_LE_16(kBmpEOI); cp = (uint16 *) im; im += 2; } @@ -326,7 +326,7 @@ bool Bitmap::solidAt(int16 x, int16 y) { while (r) { uint16 w, t; - w = *(uint16 *) m; + w = READ_LE_UINT16(m); m += 2; t = w & 0xC000; w &= 0x3FFF; @@ -347,7 +347,7 @@ bool Bitmap::solidAt(int16 x, int16 y) { while (true) { uint16 w, t; - w = *(uint16 *) m; + w = READ_LE_UINT16(m); m += 2; t = w & 0xC000; w &= 0x3FFF; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index db44536267..88949dbfc0 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -276,7 +276,7 @@ void InfoLine::update(const char *text) { for (pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) { Common::copy(v, v + lsiz, pDest); } - *(uint16 *)(v + psiz - 2) = kBmpEOI; // plane trailer uint16 + *(uint16 *)(v + psiz - 2) = TO_LE_16(kBmpEOI); // plane trailer uint16 for (pDest = v + psiz; pDest < (v + 4 * psiz); pDest += psiz) { Common::copy(v, v + psiz, pDest); } -- cgit v1.2.3 From 43a41f5380228c62959374750667dadd175ea5ad Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 14:55:44 +0200 Subject: CGE: Endian-swap VBM headers on load if needed. --- engines/cge/bitmap.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index ddab57eec8..e497828788 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -407,15 +407,19 @@ bool Bitmap::loadVBM(XFile *f) { uint16 p = 0, n = 0; if (f->_error == 0) f->read((uint8 *)&p, sizeof(p)); + p = FROM_LE_16(p); if (f->_error == 0) f->read((uint8 *)&n, sizeof(n)); + n = FROM_LE_16(n); if (f->_error == 0) f->read((uint8 *)&_w, sizeof(_w)); + _w = FROM_LE_16(_w); if (f->_error == 0) f->read((uint8 *)&_h, sizeof(_h)); + _h = FROM_LE_16(_h); if (f->_error == 0) { if (p) { -- cgit v1.2.3 From 4e4062806b1b1d80e98f7935e911249a458eadc8 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 15:55:27 +0200 Subject: CGE: Portability fix for syncing sprite flags. --- engines/cge/vga13h.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ad2415caaf..7e4daeb898 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -545,7 +545,48 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); // _ext s.syncAsUint16LE(_ref); s.syncAsByte(_cave); - s.syncBytes((byte *)&_flags, 2); + + // bitfield in-memory storage is unpredictable, so to avoid + // any issues, pack/unpack everything manually + uint16 flags = 0; + if (s.isLoading()) { + s.syncAsUint16LE(flags); + _flags._hide = flags & 0x0001 ? true : false; + _flags._near = flags & 0x0002 ? true : false; + _flags._drag = flags & 0x0004 ? true : false; + _flags._hold = flags & 0x0008 ? true : false; + _flags._____ = flags & 0x0010 ? true : false; + _flags._slav = flags & 0x0020 ? true : false; + _flags._syst = flags & 0x0040 ? true : false; + _flags._kill = flags & 0x0080 ? true : false; + _flags._xlat = flags & 0x0100 ? true : false; + _flags._port = flags & 0x0200 ? true : false; + _flags._kept = flags & 0x0400 ? true : false; + _flags._east = flags & 0x0800 ? true : false; + _flags._shad = flags & 0x1000 ? true : false; + _flags._back = flags & 0x2000 ? true : false; + _flags._bDel = flags & 0x4000 ? true : false; + _flags._tran = flags & 0x8000 ? true : false; + } else { + flags = (flags << 1) | _flags._tran; + flags = (flags << 1) | _flags._bDel; + flags = (flags << 1) | _flags._back; + flags = (flags << 1) | _flags._shad; + flags = (flags << 1) | _flags._east; + flags = (flags << 1) | _flags._kept; + flags = (flags << 1) | _flags._port; + flags = (flags << 1) | _flags._xlat; + flags = (flags << 1) | _flags._kill; + flags = (flags << 1) | _flags._syst; + flags = (flags << 1) | _flags._slav; + flags = (flags << 1) | _flags._____; + flags = (flags << 1) | _flags._hold; + flags = (flags << 1) | _flags._drag; + flags = (flags << 1) | _flags._near; + flags = (flags << 1) | _flags._hide; + s.syncAsUint16LE(flags); + } + s.syncAsUint16LE(_x); s.syncAsUint16LE(_y); s.syncAsByte(_z); -- cgit v1.2.3 From 65cd0689c7f23dde33b7c8c5328b5dd3b21c7171 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 15:56:03 +0200 Subject: CGE: Remove (empty) ems.cpp. --- engines/cge/ems.cpp | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 engines/cge/ems.cpp diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp deleted file mode 100644 index f545822a6b..0000000000 --- a/engines/cge/ems.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/general.h" - -namespace CGE { -} // End of namespace CGE -- cgit v1.2.3 From f0889d3f5492a71293d789b5ffb9752c90c9b6f8 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 16:01:51 +0200 Subject: CGE: Remove unused snSelect function, and broken config.cpp. --- engines/cge/cge.h | 1 - engines/cge/cge_main.cpp | 1 - engines/cge/config.cpp | 47 ----------------------------------------------- engines/cge/config.h | 35 ----------------------------------- engines/cge/module.mk | 1 - engines/cge/snail.cpp | 2 +- 6 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 engines/cge/config.cpp delete mode 100644 engines/cge/config.h diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 8aff3334a0..1c5e680901 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -243,7 +243,6 @@ public: void snRelZ(Sprite *spr, int z); void snRNNext(Sprite *spr, int p); void snRTNext(Sprite *spr, int p); - void snSelect(); void snSend(Sprite *spr, int val); void snRelX(Sprite *spr, int x); void snRelY(Sprite *spr, int y); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 5b98b0a4e8..39e65370e8 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -36,7 +36,6 @@ #include "graphics/thumbnail.h" #include "cge/general.h" #include "cge/sound.h" -#include "cge/config.h" #include "cge/vga13h.h" #include "cge/snail.h" #include "cge/text.h" diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp deleted file mode 100644 index b1cc5769d8..0000000000 --- a/engines/cge/config.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/config.h" -#include "cge/sound.h" -#include "cge/vmenu.h" -#include "cge/text.h" -#include "cge/cge_main.h" - -namespace CGE { - -static Choice *_cho; -static int _hlp; - -void CGEEngine::snSelect() { - debugC(1, kCGEDebugEngine, "CGEEngine::snSelect()"); - - inf(_text->getText(_hlp)); - _talk->gotoxy(_talk->_x, kFontHigh / 2); - (new Vmenu(this, _cho, kScrWidth / 2, _talk->_y + _talk->_h + kTextVMargin + kFontHigh))->setName(_text->getText(kMenu)); -} - -} // End of namespace CGE diff --git a/engines/cge/config.h b/engines/cge/config.h deleted file mode 100644 index 5ea677b97d..0000000000 --- a/engines/cge/config.h +++ /dev/null @@ -1,35 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_CONFIG__ -#define __CGE_CONFIG__ - -namespace CGE { - #define kMenu 56 -} // End of namespace CGE - -#endif diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 8829883e26..3ea061419b 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -6,7 +6,6 @@ MODULE_OBJS := \ cfile.o \ cge.o \ cge_main.o \ - config.o \ console.o \ detection.o \ events.o \ diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 6a5556ca58..ea8e480b35 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -1141,7 +1141,7 @@ void Snail::runCom() { warning("TODO: Select sound card"); break; case kSnSelect: - _vm->snSelect(); + warning("TODO: Sound card selection"); break; case kSndSetVolume: sndSetVolume(); -- cgit v1.2.3 From 4e156b24635c3cb44d46dde7a01f97fb2fe4a552 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 16:04:10 +0200 Subject: CGE: Mass re-style/cleanup. --- engines/cge/bitmap.cpp | 68 +++++----- engines/cge/cfile.cpp | 18 +-- engines/cge/cge_main.cpp | 319 +++++++++++++++++++++++------------------------ engines/cge/events.cpp | 6 +- engines/cge/events.h | 1 - engines/cge/game.cpp | 22 ++-- engines/cge/game.h | 9 +- engines/cge/general.cpp | 32 ++--- engines/cge/gettext.cpp | 14 +-- engines/cge/mixer.cpp | 17 +-- engines/cge/talk.cpp | 200 ++++++++++++++--------------- engines/cge/text.cpp | 184 ++++++++++++++------------- engines/cge/vmenu.cpp | 72 +++++------ engines/cge/vol.cpp | 3 - engines/cge/walk.cpp | 66 +++++----- engines/cge/walk.h | 1 - 16 files changed, 494 insertions(+), 538 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index e497828788..0829600902 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -81,14 +81,12 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { } } - Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL), _map(0) { debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%d, %d, map)", w, h); if (map) code(); } - // following routine creates filled rectangle // immediately as VGA video chunks, in near memory as fast as possible, // especially for text line real time display @@ -134,21 +132,20 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) _b = b; } - Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), _map(0) { debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(bmp)"); uint8 *v0 = bmp._v; - if (v0) { - uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); - uint16 siz = vsiz + _h * sizeof(HideDesc); - uint8 *v1 = new uint8[siz]; - assert(v1 != NULL); - memcpy(v1, v0, siz); - _b = (HideDesc *)((_v = v1) + vsiz); - } + if (!v0) + return; + + uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0); + uint16 siz = vsiz + _h * sizeof(HideDesc); + uint8 *v1 = new uint8[siz]; + assert(v1 != NULL); + memcpy(v1, v0, siz); + _b = (HideDesc *)((_v = v1) + vsiz); } - Bitmap::~Bitmap() { debugC(6, kCGEDebugBitmap, "Bitmap::~Bitmap()"); @@ -156,7 +153,6 @@ Bitmap::~Bitmap() { delete[] _v; } - Bitmap &Bitmap::operator = (const Bitmap &bmp) { debugC(1, kCGEDebugBitmap, "&Bitmap::operator ="); @@ -166,9 +162,10 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { _m = NULL; _map = 0; delete[] _v; - if (v0 == NULL) + + if (v0 == NULL) { _v = NULL; - else { + } else { uint16 vsiz = (uint8 *)bmp._b - (uint8 *)v0; uint16 siz = vsiz + _h * sizeof(HideDesc); uint8 *v1 = (uint8 *) malloc(sizeof(uint8) * siz); @@ -179,21 +176,19 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) { return *this; } - uint16 Bitmap::moveVmap(uint8 *buf) { debugC(1, kCGEDebugBitmap, "Bitmap::moveVmap(buf)"); - if (_v) { - uint16 vsiz = (uint8 *)_b - (uint8 *)_v; - uint16 siz = vsiz + _h * sizeof(HideDesc); - memcpy(buf, _v, siz); - delete[] _v; - _b = (HideDesc *)((_v = buf) + vsiz); - return siz; - } - return 0; -} + if (!_v) + return 0; + uint16 vsiz = (uint8 *)_b - (uint8 *)_v; + uint16 siz = vsiz + _h * sizeof(HideDesc); + memcpy(buf, _v, siz); + delete[] _v; + _b = (HideDesc *)((_v = buf) + vsiz); + return siz; +} BitmapPtr Bitmap::code() { debugC(1, kCGEDebugBitmap, "Bitmap::code()"); @@ -201,7 +196,7 @@ BitmapPtr Bitmap::code() { if (!_m) return false; - uint16 i, cnt; + uint16 cnt; if (_v) { // old X-map exists, so remove it delete[] _v; @@ -214,7 +209,7 @@ BitmapPtr Bitmap::code() { int bpl; if (_v) { // 2nd pass - fill the hide table - for (i = 0; i < _h; i++) { + for (uint16 i = 0; i < _h; i++) { _b[i]._skip = 0xFFFF; _b[i]._hide = 0x0000; } @@ -225,7 +220,7 @@ BitmapPtr Bitmap::code() { uint16 j; cnt = 0; - for (i = 0; i < _h; i++) { // once per each line + for (uint16 i = 0; i < _h; i++) { // once per each line uint8 pix; for (j = bpl; j < _w; j += 4) { pix = bm[j]; @@ -293,7 +288,7 @@ BitmapPtr Bitmap::code() { _b = (HideDesc *)(_v + sizV); } cnt = 0; - for (i = 0; i < _h; i++) { + for (uint16 i = 0; i < _h; i++) { if (_b[i]._skip == 0xFFFF) { // whole line is skipped _b[i]._skip = (cnt + kScrWidth) >> 2; cnt = 0; @@ -309,19 +304,16 @@ BitmapPtr Bitmap::code() { return this; } - bool Bitmap::solidAt(int16 x, int16 y) { debugC(6, kCGEDebugBitmap, "Bitmap::solidAt(%d, %d)", x, y); - uint8 *m; - uint16 r, n, n0; - if ((x >= _w) || (y >= _h)) return false; - m = _v; - r = static_cast(x) % 4; - n0 = (kScrWidth * y + x) / 4, n = 0; + uint8 *m = _v; + uint16 r = static_cast(x) % 4; + uint16 n0 = (kScrWidth * y + x) / 4; + uint16 n = 0; while (r) { uint16 w, t; @@ -372,7 +364,6 @@ bool Bitmap::solidAt(int16 x, int16 y) { } } - bool Bitmap::saveVBM(XFile *f) { debugC(1, kCGEDebugBitmap, "Bitmap::saveVBM(f)"); @@ -400,7 +391,6 @@ bool Bitmap::saveVBM(XFile *f) { return (f->_error == 0); } - bool Bitmap::loadVBM(XFile *f) { debugC(5, kCGEDebugBitmap, "Bitmap::loadVBM(f)"); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index c6144f624b..c5c2c2c19c 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -44,7 +44,6 @@ IoBuf::IoBuf(IOMode mode, Crypt *crypt) assert(_buff != NULL); } - IoBuf::IoBuf(const char *name, IOMode mode, Crypt *crypt) : IoHand(name, mode, crypt), _bufMark(0), @@ -64,7 +63,6 @@ IoBuf::~IoBuf() { free(_buff); } - void IoBuf::readBuf() { debugC(4, kCGEDebugFile, "IoBuf::readBuf()"); @@ -73,7 +71,6 @@ void IoBuf::readBuf() { _ptr = 0; } - void IoBuf::writeBuf() { debugC(4, kCGEDebugFile, "IoBuf::writeBuf()"); @@ -84,7 +81,6 @@ void IoBuf::writeBuf() { } } - uint16 IoBuf::read(void *buf, uint16 len) { debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len); @@ -107,7 +103,6 @@ uint16 IoBuf::read(void *buf, uint16 len) { return total; } - uint16 IoBuf::read(uint8 *buf) { debugC(3, kCGEDebugFile, "IoBuf::read(buf)"); @@ -154,7 +149,6 @@ uint16 IoBuf::read(uint8 *buf) { return total; } - uint16 IoBuf::write(void *buf, uint16 len) { debugC(1, kCGEDebugFile, "IoBuf::write(buf, %d)", len); @@ -175,7 +169,6 @@ uint16 IoBuf::write(void *buf, uint16 len) { return tot; } - uint16 IoBuf::write(uint8 *buf) { debugC(1, kCGEDebugFile, "IoBuf::write(buf)"); @@ -195,7 +188,6 @@ uint16 IoBuf::write(uint8 *buf) { return len; } - int IoBuf::read() { debugC(1, kCGEDebugFile, "IoBuf::read()"); @@ -207,7 +199,6 @@ int IoBuf::read() { return _buff[_ptr++]; } - void IoBuf::write(uint8 b) { debugC(1, kCGEDebugFile, "IoBuf::write(%d)", b); @@ -216,20 +207,16 @@ void IoBuf::write(uint8 b) { _buff[_lim++] = b; } - -uint16 CFile::_maxLineLen = kLineMaxSize; - +uint16 CFile::_maxLineLen = kLineMaxSize; CFile::CFile(const char *name, IOMode mode, Crypt *crypt) : IoBuf(name, mode, crypt) { debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crypt)", name, mode); } - CFile::~CFile() { } - void CFile::flush() { debugC(1, kCGEDebugFile, "CFile::flush()"); @@ -246,14 +233,12 @@ void CFile::flush() { warning("FIXME: CFILE::Flush"); } - long CFile::mark() { debugC(5, kCGEDebugFile, "CFile::mark()"); return _bufMark + ((_mode != kModeRead) ? _lim : _ptr); } - long CFile::seek(long pos) { debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos); @@ -271,7 +256,6 @@ long CFile::seek(long pos) { } } - void CFile::append(CFile &f) { debugC(1, kCGEDebugFile, "CFile::append(f)"); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 39e65370e8..91de45e447 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -88,8 +88,8 @@ const char *savegameStr = "SCUMMVM_CGE"; //-------------------------------------------------------------------------- -static bool _finis = false; -int _offUseCount; +static bool _finis = false; +int _offUseCount; extern Dac _stdPal[58]; @@ -255,7 +255,6 @@ Common::Error CGEEngine::saveGameState(int slot, const Common::String &desc) { return Common::kNoError; } - void CGEEngine::saveSound() { warning("STUB: CGEEngine::saveSound"); /* Convert to saving any such needed data in ScummVM configuration file @@ -317,13 +316,10 @@ void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &he } void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny) { - Sprite *spr; - int i; - Common::Serializer s(readStream, writeStream); if (s.isSaving()) { - for (i = 0; i < kPocketNX; i++) { + for (int i = 0; i < kPocketNX; i++) { register Sprite *pocSpr = _pocket[i]; _pocref[i] = (pocSpr) ? pocSpr->_ref : -1; } @@ -340,7 +336,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt if (s.isSaving()) { // Loop through saving the sprite data - for (spr = _vga->_spareQ->first(); spr; spr = spr->_next) { + for (Sprite *spr = _vga->_spareQ->first(); spr; spr = spr->_next) { if ((spr->_ref >= 1000) && !s.err()) spr->sync(s); } @@ -359,14 +355,14 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt S.sync(s); S._prev = S._next = NULL; - spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL) + Sprite *spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL) : new Sprite(this, NULL); assert(spr != NULL); *spr = S; _vga->_spareQ->append(spr); } - for (i = 0; i < kPocketNX; i++) { + for (int i = 0; i < kPocketNX; i++) { register int r = _pocref[i]; _pocket[i] = (r < 0) ? NULL : _vga->_spareQ->locate(r); } @@ -482,7 +478,6 @@ Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { setShapeList(MB); } - void Square::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); if (mask & kMouseLeftUp) { @@ -491,7 +486,6 @@ void Square::touch(uint16 mask, int x, int y) { } } - void CGEEngine::setMapBrick(int x, int z) { debugC(1, kCGEDebugEngine, "CGEEngine::setMapBrick(%d, %d)", x, z); @@ -513,7 +507,6 @@ void CGEEngine::keyClick() { _snail_->addCom(kSnSound, -1, 5, NULL); } - void CGEEngine::resetQSwitch() { debugC(1, kCGEDebugEngine, "CGEEngine::resetQSwitch()"); @@ -521,7 +514,6 @@ void CGEEngine::resetQSwitch() { keyClick(); } - void CGEEngine::quit() { debugC(1, kCGEDebugEngine, "CGEEngine::quit()"); @@ -545,7 +537,6 @@ void CGEEngine::quit() { } } - void CGEEngine::AltCtrlDel() { debugC(1, kCGEDebugEngine, "CGEEngine::AltCtrlDel()"); @@ -577,21 +568,22 @@ void CGEEngine::showBak(int ref) { debugC(1, kCGEDebugEngine, "CGEEngine::showBack(%d)", ref); Sprite *spr = _vga->_spareQ->locate(ref); - if (spr) { - Bitmap::_pal = Vga::_sysPal; - spr->expand(); - Bitmap::_pal = NULL; - spr->show(2); - _vga->copyPage(1, 2); - _sys->setPal(); - spr->contract(); - } + if (!spr) + return; + + Bitmap::_pal = Vga::_sysPal; + spr->expand(); + Bitmap::_pal = NULL; + spr->show(2); + _vga->copyPage(1, 2); + _sys->setPal(); + spr->contract(); } void CGEEngine::caveUp() { debugC(1, kCGEDebugEngine, "CGEEngine::caveUp()"); - int BakRef = 1000 * _now; + const int BakRef = 1000 * _now; if (_music) _midiPlayer.loadMidi(_now); @@ -652,11 +644,10 @@ void CGEEngine::caveUp() { void CGEEngine::caveDown() { debugC(1, kCGEDebugEngine, "CGEEngine::caveDown()"); - Sprite *spr; if (_horzLine && !_horzLine->_flags._hide) switchMapping(); - for (spr = _vga->_showQ->first(); spr;) { + for (Sprite *spr = _vga->_showQ->first(); spr;) { Sprite *n = spr->_next; if (spr->_ref >= 1000 /*&& spr->_cave*/) { if (spr->_ref % 1000 == 999) @@ -689,31 +680,31 @@ void CGEEngine::qGame() { _finis = true; } - void CGEEngine::switchCave(int cav) { debugC(1, kCGEDebugEngine, "CGEEngine::switchCave(%d)", cav); - if (cav != _now) { - if (cav < 0) { - _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint - _snail->addCom2(kSnExec, -1, 0, kQGame); // switch cave - } else { - _now = cav; - _mouse->off(); - if (_hero) { - _hero->park(); - _hero->step(0); - if (!_isDemo) - _vga->_spareQ->_show = 0; - } - _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX, - kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY); - killText(); - if (!_startupMode) - keyClick(); - _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint - _snail->addCom2(kSnExec, 0, 0, kXCave); // switch cave + if (cav == _now) + return; + + if (cav < 0) { + _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint + _snail->addCom2(kSnExec, -1, 0, kQGame); // switch cave + } else { + _now = cav; + _mouse->off(); + if (_hero) { + _hero->park(); + _hero->step(0); + if (!_isDemo) + _vga->_spareQ->_show = 0; } + _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX, + kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY); + killText(); + if (!_startupMode) + keyClick(); + _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint + _snail->addCom2(kSnExec, 0, 0, kXCave); // switch cave } } @@ -724,9 +715,8 @@ System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { } void System::setPal() { - uint i; Dac *p = Vga::_sysPal + 256 - ArrayCount(_stdPal); - for (i = 0; i < ArrayCount(_stdPal); i++) { + for (uint i = 0; i < ArrayCount(_stdPal); i++) { p[i]._r = _stdPal[i]._r >> 2; p[i]._g = _stdPal[i]._g >> 2; p[i]._b = _stdPal[i]._b >> 2; @@ -918,9 +908,9 @@ void CGEEngine::switchMusic() { debugC(1, kCGEDebugEngine, "CGEEngine::switchMusic()"); if (_keyboard->_key[kKeyAlt]) { - if (Vmenu::_addr) + if (Vmenu::_addr) { _snail_->addCom(kSnKill, -1, 0, Vmenu::_addr); - else { + } else { _snail_->addCom(kSnSeq, 122, (_music = false), NULL); _snail->addCom2(kSnExec, -1, 0, kSelectSound); } @@ -944,9 +934,9 @@ void CGEEngine::startCountDown() { void CGEEngine::takeName() { debugC(1, kCGEDebugEngine, "CGEEngine::takeName()"); - if (GetText::_ptr) + if (GetText::_ptr) { _snail_->addCom(kSnKill, -1, 0, GetText::_ptr); - else { + } else { memset(_usrFnam, 0, 15); GetText *tn = new GetText(this, _text->getText(kGetNamePrompt), _usrFnam, 8); if (tn) { @@ -964,17 +954,14 @@ void CGEEngine::switchMapping() { debugC(1, kCGEDebugEngine, "CGEEngine::switchMapping()"); if (_horzLine && _horzLine->_flags._hide) { - int i; - for (i = 0; i < kMapZCnt; i++) { - int j; - for (j = 0; j < kMapXCnt; j++) { + for (int i = 0; i < kMapZCnt; i++) { + for (int j = 0; j < kMapXCnt; j++) { if (Cluster::_map[i][j]) setMapBrick(j, i); } } } else { - Sprite *s; - for (s = _vga->_showQ->first(); s; s = s->_next) + for (Sprite *s = _vga->_showQ->first(); s; s = s->_next) if (s->_w == kMapGridX && s->_h == kMapGridZ) _snail_->addCom(kSnKill, -1, 0, s); } @@ -1084,104 +1071,109 @@ void CGEEngine::sayDebug() { } } - void CGEEngine::switchDebug() { _debugLine->_flags._hide = !_debugLine->_flags._hide; } - void CGEEngine::optionTouch(int opt, uint16 mask) { switch (opt) { - case 1 : + case 1: if (mask & kMouseLeftUp) switchColorMode(); break; - case 2 : - if (mask & kMouseLeftUp) + case 2: + if (mask & kMouseLeftUp) { switchMusic(); - else if (mask & kMouseRightUp) + } else if (mask & kMouseRightUp) if (!Mixer::_appear) { Mixer::_appear = true; new Mixer(this, kButtonX, kButtonY); } break; - case 3 : + case 3: if (mask & kMouseLeftUp) quit(); break; } } - #pragma argsused void Sprite::touch(uint16 mask, int x, int y) { _sys->funTouch(); - if ((mask & kEventAttn) == 0) { - _infoLine->update(name()); - if (mask & (kMouseRightDown | kMouseLeftDown)) - _sprite = this; - if (_ref / 10 == 12) { - _vm->optionTouch(_ref % 10, mask); - return; + + if ((mask & kEventAttn) != 0) + return; + + _infoLine->update(name()); + + if (mask & (kMouseRightDown | kMouseLeftDown)) + _sprite = this; + + if (_ref / 10 == 12) { + _vm->optionTouch(_ref % 10, mask); + return; + } + + if (_flags._syst) + return; // cannot access system sprites + + if (_vm->_game) + if (mask & kMouseLeftUp) { + mask &= ~kMouseLeftUp; + mask |= kMouseRightUp; } - if (_flags._syst) - return; // cannot access system sprites - if (_vm->_game) if (mask & kMouseLeftUp) { - mask &= ~kMouseLeftUp; - mask |= kMouseRightUp; - } - if ((mask & kMouseRightUp) && _snail->idle()) { - Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL; - if (ps) { - if (_flags._kept || _hero->distance(this) < kDistMax) { - if (works(ps)) { - _vm->feedSnail(ps, kTake); - } else - _vm->offUse(); - _vm->selectPocket(-1); + + if ((mask & kMouseRightUp) && _snail->idle()) { + Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL; + if (ps) { + if (_flags._kept || _hero->distance(this) < kDistMax) { + if (works(ps)) { + _vm->feedSnail(ps, kTake); } else - _vm->tooFar(); + _vm->offUse(); + _vm->selectPocket(-1); + } else + _vm->tooFar(); + } else { + if (_flags._kept) { + mask |= kMouseLeftUp; } else { - if (_flags._kept) - mask |= kMouseLeftUp; - else { - if (_hero->distance(this) < kDistMax) { - /// - if (_flags._port) { - if (_vm->findPocket(NULL) < 0) - _vm->pocFul(); - else { - _snail->addCom(kSnReach, -1, -1, this); - _snail->addCom(kSnKeep, -1, -1, this); - _flags._port = false; - } - } else { - if (_takePtr != NO_PTR) { - if (snList(kTake)[_takePtr]._com == kSnNext) - _vm->offUse(); - else - _vm->feedSnail(this, kTake); - } else - _vm->offUse(); + if (_hero->distance(this) < kDistMax) { + /// + if (_flags._port) { + if (_vm->findPocket(NULL) < 0) + _vm->pocFul(); + else { + _snail->addCom(kSnReach, -1, -1, this); + _snail->addCom(kSnKeep, -1, -1, this); + _flags._port = false; } - }/// - else - _vm->tooFar(); - } + } else { + if (_takePtr != NO_PTR) { + if (snList(kTake)[_takePtr]._com == kSnNext) + _vm->offUse(); + else + _vm->feedSnail(this, kTake); + } else + _vm->offUse(); + } + }/// + else + _vm->tooFar(); } } - if ((mask & kMouseLeftUp) && _snail->idle()) { - if (_flags._kept) { - int n; - for (n = 0; n < kPocketNX; n++) { - if (_pocket[n] == this) { - _vm->selectPocket(n); - break; - } + } + + if ((mask & kMouseLeftUp) && _snail->idle()) { + if (_flags._kept) { + for (int n = 0; n < kPocketNX; n++) { + if (_pocket[n] == this) { + _vm->selectPocket(n); + break; } - } else - _snail->addCom(kSnWalk, -1, -1, this); // Hero->FindWay(this); - } + } + } else + _snail->addCom(kSnWalk, -1, -1, this); // Hero->FindWay(this); } } @@ -1196,7 +1188,6 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int static const char *Type[] = { "DEAD", "AUTO", "WALK", "NEWTON", "LISSAJOUS", "FLY", NULL }; - char line[kLineMax]; int shpcnt = 0; int type = 0; // DEAD @@ -1204,14 +1195,16 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int bool port = false; bool tran = false; int i, lcnt = 0; - uint16 len; + char line[kLineMax]; mergeExt(line, fname, SPR_EXT); + if (INI_FILE::exist(line)) { // sprite description file exist INI_FILE sprf(line); if (sprf._error) error("Bad SPR [%s]", line); + uint16 len; while ((len = sprf.read((uint8 *)line)) != 0) { lcnt++; if (len && line[len - 1] == '\n') @@ -1252,15 +1245,16 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int // make sprite of choosen type switch (type) { - case 1 : { // AUTO + case 1: + // AUTO _sprite = new Sprite(this, NULL); if (_sprite) { _sprite->gotoxy(col, row); //Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$ } break; - } - case 2 : { // WALK + case 2: + { // WALK Walk *w = new Walk(this, NULL); if (w && ref == 1) { w->gotoxy(col, row); @@ -1270,7 +1264,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int } _sprite = w; break; - } + } /* case 3 : // NEWTON NEWTON * n = new NEWTON(NULL); @@ -1286,7 +1280,8 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int _sprite = n; break; */ - case 4 : { // LISSAJOUS + case 4: + // LISSAJOUS error("Bad type [%s]", fname); /* LISSAJOUS * l = new LISSAJOUS(NULL); @@ -1304,20 +1299,21 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int _sprite = l; */ break; - } - case 5 : { // FLY + case 5: + { // FLY Fly *f = new Fly(this, NULL); _sprite = f; //////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$ break; - } - default: { // DEAD + } + default: + // DEAD _sprite = new Sprite(this, NULL); if (_sprite) _sprite->gotoxy(col, row); break; } - } + if (_sprite) { _sprite->_ref = ref; _sprite->_cave = cav; @@ -1339,19 +1335,16 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int } } - void CGEEngine::loadScript(const char *fname) { - char line[kLineMax]; - char *SpN; - int SpI, SpA, SpX, SpY, SpZ; - bool BkG = false; INI_FILE scrf(fname); - int lcnt = 0; - bool ok = true; if (scrf._error) return; + bool ok = true; + int lcnt = 0; + + char line[kLineMax]; while (scrf.read((uint8 *)line) != 0) { char *p; @@ -1360,33 +1353,41 @@ void CGEEngine::loadScript(const char *fname) { continue; ok = false; // not OK if break + // sprite ident number if ((p = strtok(line, " \t\n")) == NULL) break; - SpI = atoi(p); + int SpI = atoi(p); + // sprite file name + char *SpN; if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) break; + // sprite cave if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - SpA = atoi(p); + int SpA = atoi(p); + // sprite column if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - SpX = atoi(p); + int SpX = atoi(p); + // sprite row if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - SpY = atoi(p); + int SpY = atoi(p); + // sprite Z pos if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - SpZ = atoi(p); + int SpZ = atoi(p); + // sprite life if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; - BkG = atoi(p) == 0; + bool BkG = atoi(p) == 0; ok = true; // no break: OK @@ -1395,7 +1396,8 @@ void CGEEngine::loadScript(const char *fname) { if (_sprite && BkG) _sprite->_flags._back = true; } - if (! ok) + + if (!ok) error("Bad INI line %d [%s]", lcnt, fname); } @@ -1469,15 +1471,14 @@ void CGEEngine::loadUser() { // user .SVG file found - load it from slot 0 loadGame(0, NULL); } else if (_mode == 1) { - // Load either initial game state savegame or launcher specified savegame - loadGame(_startGameSlot, NULL); + // Load either initial game state savegame or launcher specified savegame + loadGame(_startGameSlot, NULL); } else { - error("Creating setup savegames not supported"); + error("Creating setup savegames not supported"); } loadScript(progName(kIn0Ext)); } - void CGEEngine::runGame() { if (_eventManager->_quitFlag) return; @@ -1601,7 +1602,6 @@ void CGEEngine::runGame() { _shadow = NULL; } - void CGEEngine::movie(const char *ext) { if (_eventManager->_quitFlag) return; @@ -1624,7 +1624,6 @@ void CGEEngine::movie(const char *ext) { } } - bool CGEEngine::showTitle(const char *name) { if (_eventManager->_quitFlag) return false; @@ -1634,7 +1633,6 @@ bool CGEEngine::showTitle(const char *name) { LB[0] = new Bitmap(name, true); LB[1] = NULL; Bitmap::_pal = NULL; - bool userOk = false; Sprite D(this, LB); D._flags._kill = true; @@ -1672,6 +1670,7 @@ bool CGEEngine::showTitle(const char *name) { _midiPlayer.loadMidi(0); } + bool userOk = false; if (_mode < 2) { if (_isDemo) { strcpy(_usrFnam, progName(kSvgExt)); diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 916de839eb..342a0a8cb1 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -184,7 +184,6 @@ Mouse::~Mouse() { off(); } - void Mouse::on() { if (_seqPtr && _exist) { _active = true; @@ -194,7 +193,6 @@ void Mouse::on() { } } - void Mouse::off() { if (_seqPtr == 0) { if (_exist) { @@ -332,8 +330,7 @@ void EventManager::handleEvents() { void EventManager::clearEvent(Sprite *spr) { if (spr) { - uint16 e; - for (e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % kEventMax) + for (uint16 e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % kEventMax) if (_eventQueue[e]._spritePtr == spr) _eventQueue[e]._mask = 0; } else @@ -346,4 +343,5 @@ CGEEvent &EventManager::getNextEvent() { return evt; } + } // End of namespace CGE diff --git a/engines/cge/events.h b/engines/cge/events.h index 124597c329..9df09fdba5 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -82,7 +82,6 @@ struct CGEEvent { Sprite *_spritePtr; }; - class Mouse : public Sprite { public: Sprite *_hold; diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index e64e4af38a..0c4f5971bc 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -43,7 +43,7 @@ uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b) { return x; } -int Fly::_l = 20, +const int Fly::_l = 20, Fly::_t = 40, Fly::_r = 110, Fly::_b = 100; @@ -56,17 +56,17 @@ Fly::Fly(CGEEngine *vm, Bitmap **shpl) void Fly::tick() { step(); - if (!_flags._kept) { - if (newRandom(10) < 1) { - _tx = newRandom(3) - 1; - _ty = newRandom(3) - 1; - } - if (_x + _tx < _l || _x + _tx + _w > _r) - _tx = -_tx; - if (_y + _ty < _t || _y + _ty + _h > _b) - _ty = -_ty; - gotoxy(_x + _tx, _y + _ty); + if (_flags._kept) + return; + if (newRandom(10) < 1) { + _tx = newRandom(3) - 1; + _ty = newRandom(3) - 1; } + if (_x + _tx < _l || _x + _tx + _w > _r) + _tx = -_tx; + if (_y + _ty < _t || _y + _ty + _h > _b) + _ty = -_ty; + gotoxy(_x + _tx, _y + _ty); } } // End of namespace CGE diff --git a/engines/cge/game.h b/engines/cge/game.h index 078f3880ea..bb4f3655a2 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -32,14 +32,13 @@ namespace CGE { - uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b); class Fly : public Sprite { - static int _l; - static int _t; - static int _r; - static int _b; + static const int _l; + static const int _t; + static const int _r; + static const int _b; public: int _tx, _ty; Fly(CGEEngine *vm, Bitmap **shpl); diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 112de730ec..25ed7d6ff2 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -124,7 +124,7 @@ char *forceExt(char *buf, const char *name, const char *ext) { return buf; } -static unsigned Seed = 0xA5; +static unsigned Seed = 0xA5; unsigned fastRand() { return Seed = 257 * Seed + 817; @@ -157,22 +157,25 @@ uint16 XCrypt(void *buf, uint16 siz, uint16 seed) { } uint16 atow(const char *a) { + if (!a) + return 0; + uint16 w = 0; - if (a) - while (IsDigit(*a)) - w = (10 * w) + (*(a++) & 0xF); + while (IsDigit(*a)) + w = (10 * w) + (*(a++) & 0xF); return w; } uint16 xtow(const char *x) { + if (!x) + return 0; + uint16 w = 0; - if (x) { - while (IsHxDig(*x)) { - register uint16 d = *(x++); - if (d > '9') - d -= 'A' - ('9' + 1); - w = (w << 4) | (d & 0xF); - } + while (IsHxDig(*x)) { + register uint16 d = *(x++); + if (d > '9') + d -= 'A' - ('9' + 1); + w = (w << 4) | (d & 0xF); } return w; } @@ -261,8 +264,7 @@ long IoHand::size() { } bool IoHand::exist(const char *name) { - Common::File f; - return f.exists(name); + return Common::File::exists(name); } void sndSetVolume() { @@ -298,8 +300,8 @@ DataCk::DataCk(byte *buf, int bufSize) { } DataCk::~DataCk() { - if (_buf) - free(_buf); + if (_buf) + free(_buf); } } // End of namespace CGE diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index d96e494402..46dacbe1de 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -33,15 +33,14 @@ namespace CGE { GetText *GetText::_ptr = NULL; - GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) : Talk(vm), _text(text), _size(min(size, kGetTextMax)), _len(min(_size, strlen(text))), _cntr(kGetTextBlink), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { - int i = 2 * kTextHMargin + _font->width(info); _ptr = this; _mode = kTBRect; _ts = new BitmapPtr[2]; + const int i = 2 * kTextHMargin + _font->width(info); _ts[0] = box((i + 3) & ~3, 2 * kTextVMargin + 2 * kFontHigh + kTextLineSpace); _ts[1] = NULL; setShapeList(_ts); @@ -55,13 +54,11 @@ GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) tick(); } - GetText::~GetText() { _keyboard->setClient(_oldKeybClient); _ptr = NULL; } - void GetText::tick() { if (++_cntr >= kGetTextBlink) { _buff[_len] ^= (' ' ^ '_'); @@ -71,7 +68,6 @@ void GetText::tick() { _time = kGetTextTime; } - void GetText::touch(uint16 mask, int x, int y) { static char ogon[] = "•œ¥£˜ ¡"; static char bezo[] = "ACELNOSXZ"; @@ -80,7 +76,7 @@ void GetText::touch(uint16 mask, int x, int y) { if (mask & kEventKeyb) { _vm->keyClick(); switch (x) { - case Enter : + case Enter: _buff[_len] = '\0'; strcpy(_text, _buff); for (p = _text; *p; p++) { @@ -88,17 +84,17 @@ void GetText::touch(uint16 mask, int x, int y) { if (q) *p = bezo[q - ogon]; } - case Esc : + case Esc: _snail_->addCom(kSnKill, -1, 0, this); break; - case BSp : + case BSp: if (_len) { _len--; _buff[_len] = _buff[_len + 1]; _buff[_len + 1] = _buff[_len + 2]; } break; - default : + default: if (x < 'A' || x > 'Z') { if (_oldKeybClient) _oldKeybClient->touch(mask, x, y); diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index ba24f832c3..8390647cec 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -38,7 +38,6 @@ extern Mouse *Mouse; bool Mixer::_appear = false; - Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _vm(vm) { _appear = true; _mb[0] = new Bitmap("VOLUME", true); @@ -53,19 +52,18 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ // slaves - uint i; Seq ls[kMixMax]; - for (i = 0; i < kMixMax; i++) { + for (uint i = 0; i < kMixMax; i++) { static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); _lb[i] = new Bitmap(fn, true); ls[i]._now = ls[i]._next = i; ls[i]._dx = ls[i]._dy = ls[i]._dly = 0; } - _lb[i] = NULL; + _lb[kMixMax] = NULL; - for (i = 0; i < ArrayCount(_led); i++) { + for (uint i = 0; i < ArrayCount(_led); i++) { register Sprite *spr = new Sprite(_vm, _lb); Seq *seq = (Seq *)malloc(kMixMax * sizeof(Seq)); @@ -82,7 +80,7 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ _led[ArrayCount(_led) - 1]->_flags._bDel = true; _vga->_showQ->insert(this); - for (i = 0; i < ArrayCount(_led); i++) + for (uint i = 0; i < ArrayCount(_led); i++) _vga->_showQ->insert(_led[i]); //--- reset balance @@ -102,7 +100,6 @@ Mixer::~Mixer() { _appear = false; } - #pragma argsused void Mixer::touch(uint16 mask, int x, int y) { Sprite::touch(mask, x, y); @@ -122,7 +119,6 @@ void Mixer::touch(uint16 mask, int x, int y) { } } - void Mixer::tick() { int x = _mouse->_x; int y = _mouse->_y; @@ -131,9 +127,9 @@ void Mixer::tick() { if (_flags._hold) touch(kMouseLeftUp, x - _x, y - _y); } else { - if (_fall) + if (_fall) { _fall--; - else { + } else { for (uint i = 0; i < ArrayCount(_led); i++) _snail_->addCom(kSnKill, -1, 0, _led[i]); _snail_->addCom(kSnKill, -1, 0, this); @@ -142,7 +138,6 @@ void Mixer::tick() { _time = kMixDelay; } - void Mixer::update() { warning("STUB: Mixer::Update"); /* diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 88949dbfc0..4bcd5cb715 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -32,50 +32,51 @@ #include "cge/events.h" namespace CGE { + Font::Font(const char *name) { - _map = (uint8 *) malloc(sizeof(uint8) * kMapSize); - _pos = (uint16 *) malloc(sizeof(uint16) * kPosSize); - _wid = (uint8 *) malloc(sizeof(uint8) * kWidSize); + _map = (uint8 *)malloc(kMapSize); + _pos = (uint16 *)malloc(kPosSize * sizeof(uint16)); + _wid = (uint8 *)malloc(kWidSize); + assert((_map != NULL) && (_pos != NULL) && (_wid != NULL)); mergeExt(_path, name, kFontExt); load(); } - Font::~Font() { free(_map); free(_pos); free(_wid); } - void Font::load() { INI_FILE f(_path); - if (!f._error) { - f.read(_wid, kWidSize); - if (!f._error) { - uint16 i, p = 0; - for (i = 0; i < kPosSize; i++) { - _pos[i] = p; - p += _wid[i]; - } - f.read(_map, p); - } + if (f._error) + return; + + f.read(_wid, kWidSize); + if (f._error) + return; + + uint16 p = 0; + for (uint16 i = 0; i < kPosSize; i++) { + _pos[i] = p; + p += _wid[i]; } + f.read(_map, p); } - uint16 Font::width(const char *text) { uint16 w = 0; - if (text) - while (* text) - w += _wid[(unsigned char)*(text++)]; + if (!text) + return 0; + while (*text) + w += _wid[(unsigned char)*(text++)]; return w; } Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode) : Sprite(vm, NULL), _mode(mode), _vm(vm) { - _ts = NULL; _flags._syst = true; update(text); @@ -98,19 +99,17 @@ void Talk::deinit() { delete _font; } - void Talk::update(const char *text) { - uint16 vmarg = (_mode) ? kTextVMargin : 0; - uint16 hmarg = (_mode) ? kTextHMargin : 0; + const uint16 vmarg = (_mode) ? kTextVMargin : 0; + const uint16 hmarg = (_mode) ? kTextHMargin : 0; uint16 mw = 0; uint16 ln = vmarg; - const char *p; uint8 *m; if (!_ts) { uint16 k = 2 * hmarg; uint16 mh = 2 * vmarg + kFontHigh; - for (p = text; *p; p++) { + for (const char *p = text; *p; p++) { if (*p == '|' || *p == '\n') { mh += kFontHigh + kTextLineSpace; if (k > mw) @@ -130,15 +129,15 @@ void Talk::update(const char *text) { m = _ts[0]->_m + ln * mw + hmarg; while (*text) { - if (*text == '|' || *text == '\n') + if (*text == '|' || *text == '\n') { m = _ts[0]->_m + (ln += kFontHigh + kTextLineSpace) * mw + hmarg; - else { - int cw = _font->_wid[(unsigned char)*text], i; + } else { + int cw = _font->_wid[(unsigned char)*text]; uint8 *f = _font->_map + _font->_pos[(unsigned char)*text]; - for (i = 0; i < cw; i++) { + for (int i = 0; i < cw; i++) { uint8 *pp = m; uint16 n; - register uint16 b = *(f++); + uint16 b = *(f++); for (n = 0; n < kFontHigh; n++) { if (b & 1) *pp = kTextColFG; @@ -155,21 +154,18 @@ void Talk::update(const char *text) { } Bitmap *Talk::box(uint16 w, uint16 h) { - uint8 *b, * p, * q; - uint16 r = (_mode == kTBRound) ? kTextRoundCorner : 0; - if (w < 8) w = 8; if (h < 8) h = 8; uint16 n = w * h; - b = (uint8 *) malloc(sizeof(uint8) * n); + uint8 *b = (uint8 *)malloc(n); assert(b != NULL); memset(b, kTextColBG, n); if (_mode) { - p = b; - q = b + n - w; + uint8 *p = b; + uint8 *q = b + n - w; memset(p, LGRAY, w); memset(q, DGRAY, w); while (p < q) { @@ -178,6 +174,7 @@ Bitmap *Talk::box(uint16 w, uint16 h) { *p = LGRAY; } p = b; + const uint16 r = (_mode == kTBRound) ? kTextRoundCorner : 0; for (int i = 0; i < r; i++) { int j; for (j = 0; j < r - i; j++) { @@ -197,13 +194,12 @@ Bitmap *Talk::box(uint16 w, uint16 h) { return new Bitmap(w, h, b); } - void Talk::putLine(int line, const char *text) { -// Note: (TS[0].W % 4) have to be 0 + // Note: (_ts[0]._w % 4) must be 0 uint16 w = _ts[0]->_w; uint16 h = _ts[0]->_h; - uint8 *v = _ts[0]->_v, * p; - uint16 dsiz = w >> 2; // data size (1 plane line size) + uint8 *v = _ts[0]->_v; + uint16 dsiz = w >> 2; // data size (1 plane line size) uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap uint16 psiz = h * lsiz; // - last gap, but + plane trailer uint16 size = 4 * psiz; // whole map size @@ -211,7 +207,7 @@ void Talk::putLine(int line, const char *text) { // set desired line pointer v += (kTextVMargin + (kFontHigh + kTextLineSpace) * line) * lsiz; - p = v; // assume blanked line above text + uint8 *p = v; // assume blanked line above text // clear whole rectangle assert((rsiz % lsiz) == 0); @@ -221,34 +217,32 @@ void Talk::putLine(int line, const char *text) { } // paint text line - if (text) { - uint8 *q; - p = v + 2 + kTextHMargin / 4 + (kTextHMargin % 4) * psiz; - q = v + size; - - while (* text) { - uint16 cw = _font->_wid[(unsigned char)*text], i; - uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text]; + if (!text) + return; + p = v + 2 + (kTextHMargin / 4) + (kTextHMargin % 4) * psiz; + uint8 *q = v + size; - for (i = 0; i < cw; i++) { - register uint16 b = fp[i]; - uint16 n; - for (n = 0; n < kFontHigh; n++) { - if (b & 1) - *p = kTextColFG; - b >>= 1; - p += lsiz; - } - p = p - rsiz + psiz; - if (p >= q) - p = p - size + 1; + while (*text) { + uint16 cw = _font->_wid[(unsigned char)*text], i; + uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text]; + + for (i = 0; i < cw; i++) { + uint16 b = fp[i]; + uint16 n; + for (n = 0; n < kFontHigh; n++) { + if (b & 1) + *p = kTextColFG; + b >>= 1; + p += lsiz; } - text++; + p = p - rsiz + psiz; + if (p >= q) + p = p - size + 1; } + text++; } } - InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm) { if (!_ts) { _ts = new BitmapPtr[2]; @@ -259,52 +253,52 @@ InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm) setShapeList(_ts); } - void InfoLine::update(const char *text) { - if (text != _oldText) { - uint16 w = _ts[0]->_w; - uint16 h = _ts[0]->_h; - uint8 *v = (uint8 *) _ts[0]->_v; - uint16 dsiz = w >> 2; // data size (1 plane line size) - uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap - uint16 psiz = h * lsiz; // - last gape, but + plane trailer - uint16 size = 4 * psiz; // whole map size - - // clear whole rectangle - byte *pDest; - memset(v + 2, kTextColBG, dsiz); // data bytes - for (pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) { - Common::copy(v, v + lsiz, pDest); - } - *(uint16 *)(v + psiz - 2) = TO_LE_16(kBmpEOI); // plane trailer uint16 - for (pDest = v + psiz; pDest < (v + 4 * psiz); pDest += psiz) { - Common::copy(v, v + psiz, pDest); - } + if (text == _oldText) + return; + + uint16 w = _ts[0]->_w; + uint16 h = _ts[0]->_h; + uint8 *v = (uint8 *)_ts[0]->_v; + uint16 dsiz = w >> 2; // data size (1 plane line size) + uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap + uint16 psiz = h * lsiz; // - last gape, but + plane trailer + uint16 size = 4 * psiz; // whole map size + + // clear whole rectangle + memset(v + 2, kTextColBG, dsiz); // data bytes + for (byte *pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) { + Common::copy(v, v + lsiz, pDest); + } + *(uint16 *)(v + psiz - 2) = TO_LE_16(kBmpEOI); // plane trailer uint16 + for (byte *pDest = v + psiz; pDest < (v + 4 * psiz); pDest += psiz) { + Common::copy(v, v + psiz, pDest); + } - // paint text line - if (text) { - uint8 *p = v + 2, * q = p + size; - - while (*text) { - uint16 cw = _font->_wid[(unsigned char)*text]; - uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text]; - - for (uint16 i = 0; i < cw; i++) { - register uint16 b = fp[i]; - for (uint16 n = 0; n < kFontHigh; n++) { - if (b & 1) - *p = kTextColFG; - b >>= 1; - p += lsiz; - } - if (p >= q) - p = p - size + 1; + // paint text line + if (text) { + uint8 *p = v + 2, * q = p + size; + + while (*text) { + uint16 cw = _font->_wid[(unsigned char)*text]; + uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text]; + + for (uint16 i = 0; i < cw; i++) { + uint16 b = fp[i]; + for (uint16 n = 0; n < kFontHigh; n++) { + if (b & 1) + *p = kTextColFG; + b >>= 1; + p += lsiz; } - text++; + if (p >= q) + p = p - size + 1; } + text++; } - _oldText = text; } + + _oldText = text; } } // End of namespace CGE diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 0e77bb8955..7e58762afa 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -50,16 +50,13 @@ Text::Text(CGEEngine *vm, const char *fname, int size) : _vm(vm) { } } - Text::~Text() { clear(); delete[] _cache; } - void Text::clear(int from, int upto) { - Han *p, * q; - for (p = _cache, q = p + _size; p < q; p++) { + for (Han *p = _cache, *q = p + _size; p < q; p++) { if (p->_ref && p->_ref >= from && p->_ref < upto) { p->_ref = 0; delete[] p->_text; @@ -68,11 +65,9 @@ void Text::clear(int from, int upto) { } } - int Text::find(int ref) { - Han *p, * q; int i = 0; - for (p = _cache, q = p + _size; p < q; p++) { + for (Han *p = _cache, *q = p + _size; p < q; p++) { if (p->_ref == ref) break; else @@ -91,31 +86,34 @@ void Text::preload(int from, int upto) { while ((n = tf.read((uint8 *)line)) != 0) { char *s; - int ref; if (line[n - 1] == '\n') - line[-- n] = '\0'; + line[--n] = '\0'; + if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; - if (! IsDigit(*s)) + if (!IsDigit(*s)) continue; - ref = atoi(s); + + int ref = atoi(s); if (ref && ref >= from && ref < upto) { - Han *p; + Han *p = &_cache[find(ref)]; - p = &_cache[find(ref)]; if (p < CacheLim) { delete[] p->_text; p->_text = NULL; } else p = &_cache[find(0)]; + if (p >= CacheLim) break; + s += strlen(s); if (s < line + n) ++s; if ((p->_text = new char[strlen(s) + 1]) == NULL) break; + p->_ref = ref; strcpy(p->_text, s); } @@ -126,35 +124,39 @@ void Text::preload(int from, int upto) { char *Text::load(int idx, int ref) { INI_FILE tf = _fileName; - if (!tf._error) { - Han *p = &_cache[idx]; - char line[kLineMax + 1]; - int n; + if (tf._error) + return NULL; + + char line[kLineMax + 1]; + int n; + + while ((n = tf.read((uint8 *)line)) != 0) { + char *s; + + if (line[n - 1] == '\n') + line[-- n] = '\0'; + if ((s = strtok(line, " =,;/\t\n")) == NULL) + continue; + if (!IsDigit(*s)) + continue; + + int r = atoi(s); + if (r < ref) + continue; + if (r > ref) + break; - while ((n = tf.read((uint8 *)line)) != 0) { - char *s; + // (r == ref) + s += strlen(s); + if (s < line + n) + ++s; - if (line[n - 1] == '\n') - line[-- n] = '\0'; - if ((s = strtok(line, " =,;/\t\n")) == NULL) - continue; - if (! IsDigit(*s)) - continue; + Han *p = &_cache[idx]; + p->_ref = ref; - int r = atoi(s); - if (r < ref) - continue; - if (r > ref) - break; - // (r == ref) - s += strlen(s); - if (s < line + n) - ++s; - p->_ref = ref; - if ((p->_text = new char[strlen(s) + 1]) == NULL) - return NULL; - return strcpy(p->_text, s); - } + if ((p->_text = new char[strlen(s) + 1]) == NULL) + return NULL; + return strcpy(p->_text, s); } return NULL; } @@ -179,42 +181,43 @@ char *Text::getText(int ref) { void Text::say(const char *text, Sprite *spr) { killText(); _talk = new Talk(_vm, text, kTBRound); - if (_talk) { - bool east = spr->_flags._east; - int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); - int y = spr->_y + 2; - Sprite *spike = new Spike(_vm); - uint16 sw = spike->_w; - - if (east) { - if (x + sw + kTextRoundCorner + 5 >= kScrWidth) - east = false; - } else { - if (x <= 5 + kTextRoundCorner + sw) - east = true; - } - x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2 - sw); - if (spr->_ref == 1) - x += ((east) ? -10 : 10); // Hero - - _talk->_flags._kill = true; - _talk->_flags._bDel = true; - _talk->setName(_text->getText(kSayName)); - _talk->gotoxy(x - (_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _talk->_h + 1); - _talk->_z = 125; - _talk->_ref = kSayRef; - - spike->gotoxy(x, _talk->_y + _talk->_h - 1); - spike->_z = 126; - spike->_flags._slav = true; - spike->_flags._kill = true; - spike->setName(_text->getText(kSayName)); - spike->step(east); - spike->_ref = kSayRef; - - _vga->_showQ->insert(_talk, _vga->_showQ->last()); - _vga->_showQ->insert(spike, _vga->_showQ->last()); + if (!_talk) + return; + + bool east = spr->_flags._east; + int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2); + int y = spr->_y + 2; + Sprite *spike = new Spike(_vm); + uint16 sw = spike->_w; + + if (east) { + if (x + sw + kTextRoundCorner + 5 >= kScrWidth) + east = false; + } else { + if (x <= 5 + kTextRoundCorner + sw) + east = true; } + x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2 - sw); + if (spr->_ref == 1) + x += ((east) ? -10 : 10); // Hero + + _talk->_flags._kill = true; + _talk->_flags._bDel = true; + _talk->setName(_text->getText(kSayName)); + _talk->gotoxy(x - (_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _talk->_h + 1); + _talk->_z = 125; + _talk->_ref = kSayRef; + + spike->gotoxy(x, _talk->_y + _talk->_h - 1); + spike->_z = 126; + spike->_flags._slav = true; + spike->_flags._kill = true; + spike->setName(_text->getText(kSayName)); + spike->step(east); + spike->_ref = kSayRef; + + _vga->_showQ->insert(_talk, _vga->_showQ->last()); + _vga->_showQ->insert(spike, _vga->_showQ->last()); } void CGEEngine::inf(const char *text) { @@ -222,31 +225,34 @@ void CGEEngine::inf(const char *text) { killText(); _talk = new Talk(this, text, kTBRect); - if (_talk) { - _talk->_flags._kill = true; - _talk->_flags._bDel = true; - _talk->setName(_text->getText(kInfName)); - _talk->center(); - _talk->gotoxy(_talk->_x, _talk->_y - 20); - _talk->_z = 126; - _talk->_ref = kInfRef; - _vga->_showQ->insert(_talk, _vga->_showQ->last()); - } + if (!_talk) + return; + + _talk->_flags._kill = true; + _talk->_flags._bDel = true; + _talk->setName(_text->getText(kInfName)); + _talk->center(); + _talk->gotoxy(_talk->_x, _talk->_y - 20); + _talk->_z = 126; + _talk->_ref = kInfRef; + _vga->_showQ->insert(_talk, _vga->_showQ->last()); } void Text::sayTime(Sprite *spr) { TimeDate curTime; - char t[6]; _vm->_system->getTimeAndDate(curTime); + + char t[6]; sprintf(t, "%d:%02d", curTime.tm_hour, curTime.tm_min); say(t, spr); } void killText() { - if (_talk) { - _snail_->addCom(kSnKill, -1, 0, _talk); - _talk = NULL; - } + if (!_talk) + return; + + _snail_->addCom(kSnKill, -1, 0, _talk); + _talk = NULL; } } // End of namespace CGE diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 48b27d9727..c8a21160bf 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -59,9 +59,7 @@ MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) { _flags._bDel = true; } - -static char *vmgt; - +static char *g_vmgt; char *VMGather(Choice *list) { Choice *cp; @@ -71,30 +69,28 @@ char *VMGather(Choice *list) { len += strlen(cp->_text); h++; } - vmgt = new char[len + h]; - if (vmgt) { - *vmgt = '\0'; + g_vmgt = new char[len + h]; + if (g_vmgt) { + *g_vmgt = '\0'; for (cp = list; cp->_text; cp++) { - if (*vmgt) - strcat(vmgt, "|"); - strcat(vmgt, cp->_text); + if (*g_vmgt) + strcat(g_vmgt, "|"); + strcat(g_vmgt, cp->_text); h++; } } - return vmgt; + return g_vmgt; } - Vmenu *Vmenu::_addr = NULL; -int Vmenu::_recent = -1; - +int Vmenu::_recent = -1; Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) : Talk(vm, VMGather(list), kTBRect), _menu(list), _bar(NULL), _vm(vm) { Choice *cp; _addr = this; - delete[] vmgt; + delete[] g_vmgt; _items = 0; for (cp = list; cp->_text; cp++) _items++; @@ -110,7 +106,6 @@ Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) _vga->_showQ->insert(_bar, _vga->_showQ->last()); } - Vmenu::~Vmenu() { _addr = NULL; } @@ -118,31 +113,32 @@ Vmenu::~Vmenu() { #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) void Vmenu::touch(uint16 mask, int x, int y) { - if (_items) { - Sprite::touch(mask, x, y); - - y -= kTextVMargin - 1; - int n = 0; - bool ok = false; - uint16 h = kFontHigh + kTextLineSpace; - - if (y >= 0) { - n = y / h; - if (n < _items) - ok = (x >= kTextHMargin && x < _w - kTextHMargin/* && y % h < FONT_HIG*/); - else - n = _items - 1; - } + if (!_items) + return; + + Sprite::touch(mask, x, y); + + y -= kTextVMargin - 1; + int n = 0; + bool ok = false; + uint16 h = kFontHigh + kTextLineSpace; + + if (y >= 0) { + n = y / h; + if (n < _items) + ok = (x >= kTextHMargin && x < _w - kTextHMargin/* && y % h < FONT_HIG*/); + else + n = _items - 1; + } - _bar->gotoxy(_x + kTextHMargin - kMenuBarHM, _y + kTextVMargin + n * h - kMenuBarVM); + _bar->gotoxy(_x + kTextHMargin - kMenuBarHM, _y + kTextVMargin + n * h - kMenuBarVM); - if (ok && (mask & kMouseLeftUp)) { - _items = 0; - _snail_->addCom(kSnKill, -1, 0, this); - _recent = n; - assert(_menu[n].Proc); - CALL_MEMBER_FN(*_vm, _menu[n].Proc)(); - } + if (ok && (mask & kMouseLeftUp)) { + _items = 0; + _snail_->addCom(kSnKill, -1, 0, this); + _recent = n; + assert(_menu[n].Proc); + CALL_MEMBER_FN(*_vm, _menu[n].Proc)(); } } diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 44cad5e832..51dbe4f856 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -73,20 +73,17 @@ VFile::VFile(const char *name, IOMode mode) } } - VFile::~VFile() { if (_recent == this) _recent = NULL; } - bool VFile::exist(const char *name) { debugC(1, kCGEDebugFile, "VFile::exist(%s)", name); return scumm_stricmp(_cat->find(name)->_key, name) == 0; } - void VFile::readBuf() { debugC(3, kCGEDebugFile, "VFile::readBuf()"); diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index 7bce9e29e6..89d7f6308b 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -96,9 +96,9 @@ void Walk::tick() { } } - if (_flags._hold || _tracePtr < 0) + if (_flags._hold || _tracePtr < 0) { park(); - else { + } else { if (_here == _trace[_tracePtr]) { if (--_tracePtr < 0) park(); @@ -112,9 +112,9 @@ void Walk::tick() { step(); if ((_dir == kDirWest && _x <= 0) || (_dir == kDirEast && _x + _w >= kScrWidth) || - (_dir == kDirSouth && _y + _w >= kWorldHeight - 2)) + (_dir == kDirSouth && _y + _w >= kWorldHeight - 2)) { park(); - else { + } else { signed char x; // dummy var _here.split(x, _z); // take current Z position _snail_->addCom(kSnZTrim, -1, 0, this); // update Hero's pos in show queue @@ -123,8 +123,7 @@ void Walk::tick() { int Walk::distance(Sprite *spr) { - int dx, dz; - dx = spr->_x - (_x + _w - kWalkSide); + int dx = spr->_x - (_x + _w - kWalkSide); if (dx < 0) dx = (_x + kWalkSide) - (spr->_x + spr->_w); @@ -132,7 +131,7 @@ int Walk::distance(Sprite *spr) { dx = 0; dx /= kMapGridX; - dz = spr->_z - _z; + int dz = spr->_z - _z; if (dz < 0) dz = - dz; @@ -166,36 +165,39 @@ void Walk::park() { void Walk::findWay(Cluster c) { - if (c != _here) { - for (_findLevel = 1; _findLevel <= kMaxFindLevel; _findLevel++) { - signed char x, z; - _here.split(x, z); - _target = Couple(x, z); - c.split(x, z); - - if (find1Way(Cluster(x, z))) - break; - } - _tracePtr = (_findLevel > kMaxFindLevel) ? -1 : (_findLevel - 1); - if (_tracePtr < 0) - noWay(); - _time = 1; + if (c == _here) + return; + + for (_findLevel = 1; _findLevel <= kMaxFindLevel; _findLevel++) { + signed char x, z; + _here.split(x, z); + _target = Couple(x, z); + c.split(x, z); + + if (find1Way(Cluster(x, z))) + break; } + _tracePtr = (_findLevel > kMaxFindLevel) ? -1 : (_findLevel - 1); + if (_tracePtr < 0) + noWay(); + _time = 1; } void Walk::findWay(Sprite *spr) { - if (spr && spr != this) { - int x = spr->_x; - int z = spr->_z; - if (spr->_flags._east) - x += spr->_w + _w / 2 - kWalkSide; - else - x -= _w / 2 - kWalkSide; - findWay(Cluster((x / kMapGridX), - ((z < kMapZCnt - kDistMax) ? (z + 1) - : (z - 1)))); - } + if (!spr || spr == this) + return; + + int x = spr->_x; + int z = spr->_z; + if (spr->_flags._east) + x += spr->_w + _w / 2 - kWalkSide; + else + x -= _w / 2 - kWalkSide; + + findWay(Cluster((x / kMapGridX), + ((z < kMapZCnt - kDistMax) ? (z + 1) + : (z - 1)))); } diff --git a/engines/cge/walk.h b/engines/cge/walk.h index 271663e51d..e924976927 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -96,7 +96,6 @@ public: bool isValid() const; }; - class Walk : public Sprite { private: CGEEngine *_vm; -- cgit v1.2.3 From df122cec1779659365f4f3bddb67b6b635620822 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 19 Aug 2011 18:32:46 +0200 Subject: CGE: fix some warnings reported by cppcheck --- engines/cge/cge_main.h | 1 - engines/cge/events.cpp | 1 + engines/cge/walk.cpp | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 1c85816c3e..1c5f818217 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -93,7 +93,6 @@ namespace CGE { class System : public Sprite { - int _lum; public: int _funDel; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 916de839eb..ea2515ef2e 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -247,6 +247,7 @@ EventManager::EventManager() { _quitFlag = false; _eventQueueHead = 0; _eventQueueTail = 0; + memset(&_eventQueue, 0, kEventMax * sizeof(CGEEvent)); memset(&_event, 0, sizeof(Common::Event)); } diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index 7bce9e29e6..a024599203 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -71,7 +71,7 @@ Cluster XZ(Couple xy) { } Walk::Walk(CGEEngine *vm, BitmapPtr *shpl) - : Sprite(vm, shpl), _dir(kDirNone), _tracePtr(-1), _level(0), _target(-1, -1), _vm(vm) { + : Sprite(vm, shpl), _dir(kDirNone), _tracePtr(-1), _level(0), _target(-1, -1), _findLevel(-1), _vm(vm) { } -- cgit v1.2.3 From 8ff904c6b576eda37930b020e39855c1fd261b2f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 19 Aug 2011 19:48:49 +0200 Subject: CGE: clean up bitmap class. Suppress useless methods, functions, defines... --- engines/cge/bitmap.cpp | 116 ++--------------------------------------------- engines/cge/bitmap.h | 5 +- engines/cge/cge_main.cpp | 4 +- engines/cge/events.cpp | 4 +- engines/cge/jbw.h | 1 - engines/cge/mixer.cpp | 4 +- engines/cge/vga13h.cpp | 20 ++++---- 7 files changed, 22 insertions(+), 132 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index e497828788..b7e9eec2fc 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -48,36 +48,18 @@ void Bitmap::deinit() { } #pragma argsused -Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) { - debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%s, %s)", fname, rem ? "true" : "false"); +Bitmap::Bitmap(const char *fname) : _m(NULL), _v(NULL), _map(0) { + debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%s)", fname); char pat[kMaxPath]; forceExt(pat, fname, ".VBM"); -#if (BMP_MODE < 2) - if (rem && PIC_FILE::exist(pat)) { + if (PIC_FILE::exist(pat)) { PIC_FILE file(pat); if ((file._error == 0) && (!loadVBM(&file))) error("Bad VBM [%s]", fname); - } else -#endif - { -#if (BMP_MODE) - forceExt(pat, fname, ".BMP"); - PIC_FILE file(pat); - if (file._error == 0) { - if (loadBMP(&file)) { - code(); - if (rem) { - free(_m); - _m = NULL; - } - } else - error("Bad BMP [%s]", fname); - } -#else + } else { error("Bad VBM [%s]", fname); -#endif } } @@ -88,7 +70,6 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL) code(); } - // following routine creates filled rectangle // immediately as VGA video chunks, in near memory as fast as possible, // especially for text line real time display @@ -117,7 +98,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) *(uint16 *)(v + psiz - 2) = TO_LE_16(kBmpEOI); // plane trailer uint16 - // Repliccate planes + // Replicate planes for (destP = v + psiz; destP < (v + 4 * psiz); destP += psiz) Common::copy(v, v + psiz, destP); @@ -134,7 +115,6 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill) _b = b; } - Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), _map(0) { debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(bmp)"); uint8 *v0 = bmp._v; @@ -372,35 +352,6 @@ bool Bitmap::solidAt(int16 x, int16 y) { } } - -bool Bitmap::saveVBM(XFile *f) { - debugC(1, kCGEDebugBitmap, "Bitmap::saveVBM(f)"); - - uint16 p = (_pal != NULL), - n = ((uint16)(((uint8 *)_b) - _v)) + _h * sizeof(HideDesc); - if (f->_error == 0) - f->write((uint8 *)&p, sizeof(p)); - - if (f->_error == 0) - f->write((uint8 *)&n, sizeof(n)); - - if (f->_error == 0) - f->write((uint8 *)&_w, sizeof(_w)); - - if (f->_error == 0) - f->write((uint8 *)&_h, sizeof(_h)); - - if (f->_error == 0) - if (p) - f->write((uint8 *)_pal, 256 * 3); - - if (f->_error == 0) - f->write(_v, n); - - return (f->_error == 0); -} - - bool Bitmap::loadVBM(XFile *f) { debugC(5, kCGEDebugBitmap, "Bitmap::loadVBM(f)"); @@ -448,61 +399,4 @@ bool Bitmap::loadVBM(XFile *f) { return (f->_error == 0); } -bool Bitmap::loadBMP(XFile *f) { - debugC(1, kCGEDebugBitmap, "Bitmap::loadBMP(f)"); - - struct { - char BM[2]; - union { int16 len; int32 len_; }; - union { int16 _06; int32 _06_; }; - union { int16 hdr; int32 hdr_; }; - union { int16 _0E; int32 _0E_; }; - union { int16 wid; int32 wid_; }; - union { int16 hig; int32 hig_; }; - union { int16 _1A; int32 _1A_; }; - union { int16 _1E; int32 _1E_; }; - union { int16 _22; int32 _22_; }; - union { int16 _26; int32 _26_; }; - union { int16 _2A; int32 _2A_; }; - union { int16 _2E; int32 _2E_; }; - union { int16 _32; int32 _32_; }; - } hea; - - Bgr4 bpal[256]; - - f->read((byte *)&hea, sizeof(hea)); - if (f->_error == 0) { - if (hea.hdr == 0x436L) { - int16 i = (hea.hdr - sizeof(hea)) / sizeof(Bgr4); - f->read((byte *)&bpal, sizeof(bpal)); - if (f->_error == 0) { - if (_pal) { - for (i = 0; i < 256; i++) { - _pal[i]._r = bpal[i]._R; - _pal[i]._g = bpal[i]._G; - _pal[i]._b = bpal[i]._B; - } - _pal = NULL; - } - _h = hea.hig; - _w = hea.wid; - if ((_m = (byte *) malloc(sizeof(byte) * (_h * _w))) != NULL) { - int16 r = (4 - (hea.wid & 3)) % 4; - byte buf[3]; - for (i = _h - 1; i >= 0; i--) { - f->read(_m + (_w * i), _w); - if (r && f->_error == 0) - f->read(buf, r); - if (f->_error) - break; - } - if (i < 0) - return true; - } - } - } - } - return false; -} - } // End of namespace CGE diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 30e11d08ec..7604cb8081 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -60,7 +60,6 @@ struct HideDesc { #include "common/pack-end.h" class Bitmap { - bool loadBMP(XFile *f); bool loadVBM(XFile *f); public: static Dac *_pal; @@ -71,7 +70,7 @@ public: int32 _map; HideDesc *_b; - Bitmap(const char *fname, bool rem); + Bitmap(const char *fname); Bitmap(uint16 w, uint16 h, uint8 *map); Bitmap(uint16 w, uint16 h, uint8 fill); Bitmap(const Bitmap &bmp); @@ -79,14 +78,12 @@ public: static void init(); static void deinit(); - Bitmap *flipH(); Bitmap *code(); Bitmap &operator = (const Bitmap &bmp); void hide(int16 x, int16 y); void show(int16 x, int16 y); void xShow(int16 x, int16 y); bool solidAt(int16 x, int16 y); - bool saveVBM(XFile *f); uint16 moveVmap(uint8 *buf); }; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 5b98b0a4e8..e64fc382ee 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -478,7 +478,7 @@ Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { _flags._bDel = false; BitmapPtr *MB = new BitmapPtr[2]; - MB[0] = new Bitmap("BRICK", true); + MB[0] = new Bitmap("BRICK"); MB[1] = NULL; setShapeList(MB); } @@ -1632,7 +1632,7 @@ bool CGEEngine::showTitle(const char *name) { Bitmap::_pal = Vga::_sysPal; BitmapPtr *LB = new BitmapPtr[2]; - LB[0] = new Bitmap(name, true); + LB[0] = new Bitmap(name); LB[1] = NULL; Bitmap::_pal = NULL; bool userOk = false; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index ea2515ef2e..f414bd048a 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -169,8 +169,8 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) setSeq(seq); BitmapPtr *MC = new BitmapPtr[3]; - MC[0] = new Bitmap("MOUSE", true); - MC[1] = new Bitmap("DUMMY", true); + MC[0] = new Bitmap("MOUSE"); + MC[1] = new Bitmap("DUMMY"); MC[2] = NULL; setShapeList(MC); diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 128a92f594..0ba8a1956b 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -35,7 +35,6 @@ namespace CGE { // Defines found in cge.mak #define INI_FILE VFile // Or is it CFile? #define PIC_FILE VFile -#define BMP_MODE 0 // #define kMaxFile 128 diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index ba24f832c3..7a07f99c6e 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -41,7 +41,7 @@ bool Mixer::_appear = false; Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _vm(vm) { _appear = true; - _mb[0] = new Bitmap("VOLUME", true); + _mb[0] = new Bitmap("VOLUME"); _mb[1] = NULL; setShapeList(_mb); setName(_text->getText(kMixName)); @@ -59,7 +59,7 @@ Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _ for (i = 0; i < kMixMax; i++) { static char fn[] = "V00"; wtom(i, fn + 1, 10, 2); - _lb[i] = new Bitmap(fn, true); + _lb[i] = new Bitmap(fn); ls[i]._now = ls[i]._next = i; ls[i]._dx = ls[i]._dy = ls[i]._dly = 0; } diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ad2415caaf..d963622b13 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -289,7 +289,7 @@ Sprite *Sprite::expand() { ++_shpCnt; } - shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"), true); + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); break; } case 2 : { // Seq @@ -344,7 +344,7 @@ Sprite *Sprite::expand() { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(_file, true); + shplist[shpcnt++] = new Bitmap(_file); } shplist[shpcnt] = NULL; if (seq) { @@ -1041,7 +1041,7 @@ void Bitmap::hide(int16 x, int16 y) { HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *HL = new BitmapPtr[2]; - HL[0] = new Bitmap("HLINE", true); + HL[0] = new Bitmap("HLINE"); HL[1] = NULL; setShapeList(HL); @@ -1050,7 +1050,7 @@ HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *PR = new BitmapPtr[2]; - PR[0] = new Bitmap("PRESS", true); + PR[0] = new Bitmap("PRESS"); PR[1] = NULL; setShapeList(PR); @@ -1059,8 +1059,8 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *SP = new BitmapPtr[3]; - SP[0] = new Bitmap("SPK_L", true); - SP[1] = new Bitmap("SPK_R", true); + SP[0] = new Bitmap("SPK_L"); + SP[1] = new Bitmap("SPK_R"); SP[2] = NULL; setShapeList(SP); @@ -1069,10 +1069,10 @@ Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *LI = new BitmapPtr[5]; - LI[0] = new Bitmap("LITE0", true); - LI[1] = new Bitmap("LITE1", true); - LI[2] = new Bitmap("LITE2", true); - LI[3] = new Bitmap("LITE3", true); + LI[0] = new Bitmap("LITE0"); + LI[1] = new Bitmap("LITE1"); + LI[2] = new Bitmap("LITE2"); + LI[3] = new Bitmap("LITE3"); LI[4] = NULL; setShapeList(LI); -- cgit v1.2.3 From 01b4ac72190bdfb3cd637890c5c0a88bc16163ac Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 23:54:24 +0200 Subject: CGE: More cleanup. --- engines/cge/vga13h.cpp | 485 ++++++++++++++++++++++--------------------------- engines/cge/vga13h.h | 6 +- 2 files changed, 222 insertions(+), 269 deletions(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 80060bfd74..feaa005643 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -38,7 +38,7 @@ namespace CGE { -static VgaRegBlk VideoMode[] = { +static VgaRegBlk VideoMode[] = { { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 @@ -55,7 +55,7 @@ static VgaRegBlk VideoMode[] = { { 0x00, 0x00, 0x00, 0x00 } }; -bool SpeedTest = false; +bool SpeedTest = false; Seq *getConstantSeq(bool seqFlag) { const Seq seq1[] = { { 0, 0, 0, 0, 0 } }; @@ -74,20 +74,17 @@ Seq *getConstantSeq(bool seqFlag) { return seq; } - -extern "C" void SNDMIDIPlay(); +extern "C" void SNDMIDIPlay(); uint16 *SaveScreen() { // In ScummVM, we don't need to worry about saving the original screen mode return 0; } - void RestoreScreen(uint16 * &sav) { // In ScummVM, we don't need to restore the original text screen when the game exits } - Dac mkDac(uint8 r, uint8 g, uint8 b) { static Dac x; x._r = r; @@ -118,7 +115,6 @@ Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) setShapeList(shpP); } - Sprite::~Sprite() { if (_sprite == this) _sprite = NULL; @@ -126,25 +122,22 @@ Sprite::~Sprite() { contract(); } - BitmapPtr Sprite::shp() { - register SprExt *e = _ext; - if (e) - if (e->_seq) { - int i = e->_seq[_seqPtr]._now; - if (i >= _shpCnt) { - //char s[256]; - //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", - // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); - //VGA::Exit(s, File); - error("Invalid PHASE in SPRITE::Shp() %s", _file); - } - return e->_shpList[i]; - } - return NULL; + SprExt *e = _ext; + if (!e || !e->_seq) + return NULL; + + int i = e->_seq[_seqPtr]._now; + if (i >= _shpCnt) { + //char s[256]; + //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", + // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); + //VGA::Exit(s, File); + error("Invalid PHASE in SPRITE::Shp() %s", _file); + } + return e->_shpList[i]; } - BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { BitmapPtr *r = (_ext) ? _ext->_shpList : NULL; @@ -171,7 +164,6 @@ BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { return r; } - void Sprite::moveShapes(uint8 *buf) { BitmapPtr *p; for (p = _ext->_shpList; *p; p++) { @@ -179,22 +171,21 @@ void Sprite::moveShapes(uint8 *buf) { } } - bool Sprite::works(Sprite *spr) { - if (spr) - if (spr->_ext) { - Snail::Com *c = spr->_ext->_take; - if (c != NULL) { - c += spr->_takePtr; - if (c->_ref == _ref) - if (c->_com != kSnLabel || (c->_val == 0 || c->_val == _vm->_now)) - return true; - } - } + if (!spr || !spr->_ext) + return false; + + Snail::Com *c = spr->_ext->_take; + if (c != NULL) { + c += spr->_takePtr; + if (c->_ref == _ref) + if (c->_com != kSnLabel || (c->_val == 0 || c->_val == _vm->_now)) + return true; + } + return false; } - Seq *Sprite::setSeq(Seq *seq) { if (_ext) { free(_ext->_seq); @@ -202,7 +193,8 @@ Seq *Sprite::setSeq(Seq *seq) { } expand(); - register Seq *s = _ext->_seq; + + Seq *s = _ext->_seq; _ext->_seq = seq; if (_seqPtr == NO_SEQ) step(0); @@ -211,7 +203,6 @@ Seq *Sprite::setSeq(Seq *seq) { return s; } - bool Sprite::seqTest(int n) { if (n >= 0) return (_seqPtr == n); @@ -220,186 +211,189 @@ bool Sprite::seqTest(int n) { return true; } - Snail::Com *Sprite::snList(SnList type) { - register SprExt *e = _ext; + SprExt *e = _ext; if (e) return (type == kNear) ? e->_near : e->_take; return NULL; } - void Sprite::setName(char *newName) { - if (_ext) { - if (_ext->_name) { - delete[] _ext->_name; - _ext->_name = NULL; - } - if (newName) { - _ext->_name = new char[strlen(newName) + 1]; - assert(_ext->_name != NULL); - strcpy(_ext->_name, newName); - } + if (!_ext) + return; + + if (_ext->_name) { + delete[] _ext->_name; + _ext->_name = NULL; + } + if (newName) { + _ext->_name = new char[strlen(newName) + 1]; + assert(_ext->_name != NULL); + strcpy(_ext->_name, newName); } } - Sprite *Sprite::expand() { - if (!_ext) { - _ext = new SprExt; - assert(_ext != NULL); - if (*_file) { - static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; - char line[kLineMax], fname[kPathMax]; - - Common::Array shplist; - for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); - Seq *seq = NULL; - int shpcnt = 0, - seqcnt = 0, - neacnt = 0, - takcnt = 0, - maxnow = 0, - maxnxt = 0; - - Snail::Com *nea = NULL; - Snail::Com *tak = NULL; - mergeExt(fname, _file, SPR_EXT); - if (INI_FILE::exist(fname)) { // sprite description file exist - INI_FILE sprf(fname); - if (!(sprf._error==0)) - error("Bad SPR [%s]", fname); - int len = 0, lcnt = 0; - while ((len = sprf.read((uint8 *)line)) != 0) { - lcnt++; - if (len && line[len - 1] == '\n') - line[--len] = '\0'; - if (len == 0 || *line == '.') - continue; - - switch (takeEnum(Comd, strtok(line, " =\t"))) { - case 0 : { // Name - setName(strtok(NULL, "")); - break; - } - case 1 : { // Phase - // In case the shape index gets too high, increase the array size - while ((shpcnt + 1) >= (int)shplist.size()) { - shplist.push_back(NULL); - ++_shpCnt; - } - - shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); - break; - } - case 2 : { // Seq - seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); - assert(seq != NULL); - Seq *s = &seq[seqcnt++]; - s->_now = atoi(strtok(NULL, " \t,;/")); - if (s->_now > maxnow) - maxnow = s->_now; - s->_next = atoi(strtok(NULL, " \t,;/")); - switch (s->_next) { - case 0xFF : - s->_next = seqcnt; - break; - case 0xFE : - s->_next = seqcnt - 1; - break; - } - if (s->_next > maxnxt) - maxnxt = s->_next; - s->_dx = atoi(strtok(NULL, " \t,;/")); - s->_dy = atoi(strtok(NULL, " \t,;/")); - s->_dly = atoi(strtok(NULL, " \t,;/")); - break; - } - case 3 : { // Near - if (_nearPtr != NO_PTR) { - nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - assert(nea != NULL); - Snail::Com *c = &nea[neacnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) - error("Bad NEAR in %d [%s]", lcnt, fname); - c->_ref = atoi(strtok(NULL, " \t,;/")); - c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - } - } + if (_ext) + return this; + + _ext = new SprExt; + assert(_ext != NULL); + if (!*_file) + return this; + + static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; + char line[kLineMax], fname[kPathMax]; + + Common::Array shplist; + for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); + Seq *seq = NULL; + int shpcnt = 0, + seqcnt = 0, + neacnt = 0, + takcnt = 0, + maxnow = 0, + maxnxt = 0; + + Snail::Com *nea = NULL; + Snail::Com *tak = NULL; + mergeExt(fname, _file, SPR_EXT); + if (INI_FILE::exist(fname)) { // sprite description file exist + INI_FILE sprf(fname); + if (!(sprf._error==0)) + error("Bad SPR [%s]", fname); + int len = 0, lcnt = 0; + while ((len = sprf.read((uint8 *)line)) != 0) { + lcnt++; + if (len && line[len - 1] == '\n') + line[--len] = '\0'; + if (len == 0 || *line == '.') + continue; + + Snail::Com *c; + switch (takeEnum(Comd, strtok(line, " =\t"))) { + case 0: + // Name + setName(strtok(NULL, "")); + break; + case 1: + // Phase + // In case the shape index gets too high, increase the array size + while ((shpcnt + 1) >= (int)shplist.size()) { + shplist.push_back(NULL); + ++_shpCnt; + } + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); + break; + case 2: + // Seq + seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + assert(seq != NULL); + Seq *s; + s = &seq[seqcnt++]; + s->_now = atoi(strtok(NULL, " \t,;/")); + if (s->_now > maxnow) + maxnow = s->_now; + s->_next = atoi(strtok(NULL, " \t,;/")); + switch (s->_next) { + case 0xFF: + s->_next = seqcnt; + break; + case 0xFE: + s->_next = seqcnt - 1; break; - case 4 : { // Take - if (_takePtr != NO_PTR) { - tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - assert(tak != NULL); - Snail::Com *c = &tak[takcnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) - error("Bad NEAR in %d [%s]", lcnt, fname); - c->_ref = atoi(strtok(NULL, " \t,;/")); - c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - } - break; - } - } } - } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(_file); + if (s->_next > maxnxt) + maxnxt = s->_next; + s->_dx = atoi(strtok(NULL, " \t,;/")); + s->_dy = atoi(strtok(NULL, " \t,;/")); + s->_dly = atoi(strtok(NULL, " \t,;/")); + break; + case 3: + // Near + if (_nearPtr == NO_PTR) + break; + nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); + assert(nea != NULL); + c = &nea[neacnt++]; + if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) + error("Bad NEAR in %d [%s]", lcnt, fname); + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; + break; + case 4: + // Take + if (_takePtr == NO_PTR) + break; + tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); + assert(tak != NULL); + c = &tak[takcnt++]; + if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) + error("Bad NEAR in %d [%s]", lcnt, fname); + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; + break; } - shplist[shpcnt] = NULL; - if (seq) { - if (maxnow >= shpcnt) - error("Bad PHASE in SEQ [%s]", fname); - if (maxnxt >= seqcnt) - error("Bad JUMP in SEQ [%s]", fname); - setSeq(seq); - } else - setSeq(getConstantSeq(_shpCnt == 1)); - - // Set the shape list - BitmapPtr *shapeList = new BitmapPtr[shplist.size()]; - for (uint i = 0; i < shplist.size(); ++i) - shapeList[i] = shplist[i]; - - setShapeList(shapeList); - - if (nea) - nea[neacnt - 1]._ptr = _ext->_near = nea; - else - _nearPtr = NO_PTR; - if (tak) - tak[takcnt - 1]._ptr = _ext->_take = tak; - else - _takePtr = NO_PTR; } + } else { + // no sprite description: try to read immediately from .BMP + shplist[shpcnt++] = new Bitmap(_file); } + + shplist[shpcnt] = NULL; + if (seq) { + if (maxnow >= shpcnt) + error("Bad PHASE in SEQ [%s]", fname); + if (maxnxt >= seqcnt) + error("Bad JUMP in SEQ [%s]", fname); + setSeq(seq); + } else + setSeq(getConstantSeq(_shpCnt == 1)); + + // Set the shape list + BitmapPtr *shapeList = new BitmapPtr[shplist.size()]; + for (uint i = 0; i < shplist.size(); ++i) + shapeList[i] = shplist[i]; + + setShapeList(shapeList); + + if (nea) + nea[neacnt - 1]._ptr = _ext->_near = nea; + else + _nearPtr = NO_PTR; + if (tak) + tak[takcnt - 1]._ptr = _ext->_take = tak; + else + _takePtr = NO_PTR; + return this; } - Sprite *Sprite::contract() { - register SprExt *e = _ext; - if (e) { - if (e->_name) - delete[] e->_name; - if (_flags._bDel && e->_shpList) { - int i; - for (i = 0; e->_shpList[i]; i++) - delete e->_shpList[i]; - delete[] e->_shpList; - } + SprExt *e = _ext; + if (!e) + return this; + + if (e->_name) + delete[] e->_name; + if (_flags._bDel && e->_shpList) { + for (int i = 0; e->_shpList[i]; i++) + delete e->_shpList[i]; + delete[] e->_shpList; + } - free(e->_seq); - free(e->_near); - free(e->_take); + free(e->_seq); + free(e->_near); + free(e->_take); + + delete e; + _ext = NULL; - delete e; - _ext = NULL; - } return this; } - Sprite *Sprite::backShow(bool fast) { expand(); show(2); @@ -410,7 +404,6 @@ Sprite *Sprite::backShow(bool fast) { return this; } - void Sprite::step(int nr) { if (nr >= 0) _seqPtr = nr; @@ -426,37 +419,32 @@ void Sprite::step(int nr) { } } - void Sprite::tick() { step(); } - void Sprite::makeXlat(uint8 *x) { - if (_ext) { - BitmapPtr *b; + if (!_ext) + return; - if (_flags._xlat) - killXlat(); - for (b = _ext->_shpList; *b; b++) - (*b)->_m = x; - _flags._xlat = true; - } + if (_flags._xlat) + killXlat(); + for (BitmapPtr *b = _ext->_shpList; *b; b++) + (*b)->_m = x; + _flags._xlat = true; } - void Sprite::killXlat() { - if (_flags._xlat && _ext) { - BitmapPtr *b; - uint8 *m = (*_ext->_shpList)->_m; - free(m); - - for (b = _ext->_shpList; *b; b++) - (*b)->_m = NULL; - _flags._xlat = false; - } -} + if (!_flags._xlat || !_ext) + return; + + uint8 *m = (*_ext->_shpList)->_m; + free(m); + for (BitmapPtr *b = _ext->_shpList; *b; b++) + (*b)->_m = NULL; + _flags._xlat = false; +} void Sprite::gotoxy(int x, int y) { int xo = _x, yo = _y; @@ -481,14 +469,12 @@ void Sprite::gotoxy(int x, int y) { _prev->gotoxy(_prev->_x - xo + _x, _prev->_y - yo + _y); } - void Sprite::center() { gotoxy((kScrWidth - _w) / 2, (kScrHeight - _h) / 2); } - void Sprite::show() { - register SprExt *e; + SprExt *e; // asm cli // critic section... e = _ext; e->_x0 = e->_x1; @@ -506,7 +492,6 @@ void Sprite::show() { } } - void Sprite::show(uint16 pg) { Graphics::Surface *a = Vga::_page[1]; Vga::_page[1] = Vga::_page[pg & 3]; @@ -514,28 +499,26 @@ void Sprite::show(uint16 pg) { Vga::_page[1] = a; } - void Sprite::hide() { - register SprExt *e = _ext; + SprExt *e = _ext; if (e->_b0) e->_b0->hide(e->_x0, e->_y0); } - BitmapPtr Sprite::ghost() { - register SprExt *e = _ext; - if (e->_b1) { - BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL); - assert(bmp != NULL); - bmp->_w = e->_b1->_w; - bmp->_h = e->_b1->_h; - bmp->_b = new HideDesc[bmp->_h]; - assert(bmp->_b != NULL); - bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); - bmp->_map = (e->_y1 << 16) + e->_x1; - return bmp; - } - return NULL; + SprExt *e = _ext; + if (!e->_b1) + return NULL; + + BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL); + assert(bmp != NULL); + bmp->_w = e->_b1->_w; + bmp->_h = e->_b1->_h; + bmp->_b = new HideDesc[bmp->_h]; + assert(bmp->_b != NULL); + bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); + bmp->_map = (e->_y1 << 16) + e->_x1; + return bmp; } void Sprite::sync(Common::Serializer &s) { @@ -617,16 +600,13 @@ Sprite *spriteAt(int x, int y) { return spr; } - Queue::Queue(bool show) : _head(NULL), _tail(NULL), _show(show) { } - Queue::~Queue() { clear(); } - void Queue::clear() { while (_head) { Sprite *s = remove(_head); @@ -635,7 +615,6 @@ void Queue::clear() { } } - void Queue::forAll(void (*fun)(Sprite *)) { Sprite *s = _head; while (s) { @@ -645,7 +624,6 @@ void Queue::forAll(void (*fun)(Sprite *)) { } } - void Queue::append(Sprite *spr) { if (_tail) { spr->_prev = _tail; @@ -659,7 +637,6 @@ void Queue::append(Sprite *spr) { spr->contract(); } - void Queue::insert(Sprite *spr, Sprite *nxt) { if (nxt == _head) { spr->_next = _head; @@ -681,7 +658,6 @@ void Queue::insert(Sprite *spr, Sprite *nxt) { spr->contract(); } - void Queue::insert(Sprite *spr) { Sprite *s; for (s = _head; s; s = s->_next) @@ -716,17 +692,14 @@ Sprite *Queue::remove(Sprite *spr) { return spr; } - Sprite *Queue::locate(int ref) { - Sprite *spr; - for (spr = _head; spr; spr = spr->_next) { + for (Sprite *spr = _head; spr; spr = spr->_next) { if (spr->_ref == ref) return spr; } return NULL; } - //extern const char Copr[]; Graphics::Surface *Vga::_page[4]; Dac *Vga::_sysPal; @@ -782,7 +755,6 @@ Vga::Vga(int mode) clear(0); } - Vga::~Vga() { _mono = 0; @@ -807,12 +779,10 @@ Vga::~Vga() { delete _spareQ; } - void Vga::setStatAdr() { // No implementation needed for ScummVM } - #pragma argsused void Vga::waitVR(bool on) { // Since some of the game parts rely on using vertical sync as a delay mechanism, @@ -820,18 +790,15 @@ void Vga::waitVR(bool on) { g_system->delayMillis(5); } - void Vga::setup(VgaRegBlk *vrb) { // No direct VGA setup required, since ScummVM provides it's own graphics interface } - int Vga::setMode(int mode) { // ScummVM provides it's own vieo services return 0; } - void Vga::getColors(Dac *tab) { byte palData[kPalSize]; g_system->getPaletteManager()->grabPalette(palData, 0, kPalCount); @@ -877,13 +844,11 @@ void Vga::setColors(Dac *tab, int lum) { _setPal = true; } - void Vga::setColors() { memset(_newColors, 0, kPalSize); updateColors(); } - void Vga::sunrise(Dac *tab) { for (int i = 0; i <= 64; i += FADE_STEP) { setColors(tab, i); @@ -892,7 +857,6 @@ void Vga::sunrise(Dac *tab) { } } - void Vga::sunset() { Dac tab[256]; getColors(tab); @@ -903,27 +867,22 @@ void Vga::sunset() { } } - void Vga::show() { - Sprite *spr = _showQ->first(); - - for (spr = _showQ->first(); spr; spr = spr->_next) + for (Sprite *spr = _showQ->first(); spr; spr = spr->_next) spr->show(); update(); - for (spr = _showQ->first(); spr; spr = spr->_next) + for (Sprite *spr = _showQ->first(); spr; spr = spr->_next) spr->hide(); _frmCnt++; } - void Vga::updateColors() { byte palData[kPalSize]; dacToPal(_newColors, palData); g_system->getPaletteManager()->setPalette(palData, 0, 256); } - void Vga::update() { SWAP(Vga::_page[0], Vga::_page[1]); @@ -936,13 +895,11 @@ void Vga::update() { g_system->updateScreen(); } - void Vga::clear(uint8 color) { for (int paneNum = 0; paneNum < 4; paneNum++) _page[paneNum]->fillRect(Common::Rect(0, 0, kScrWidth, kScrHeight), color); } - void Vga::copyPage(uint16 d, uint16 s) { _page[d]->copyFrom(*_page[s]); } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 1d41a068ff..8576752d07 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -194,7 +194,6 @@ private: CGEEngine *_vm; }; - class Queue { Sprite *_head; Sprite *_tail; @@ -219,7 +218,6 @@ public: void clear(); }; - class Vga { uint16 _oldMode; uint16 *_oldScreen; @@ -282,10 +280,8 @@ public: PocLight(CGEEngine *vm); }; - Dac mkDac(uint8 r, uint8 g, uint8 b); - template uint8 closest(CBLK *pal, CBLK x) { #define f(col, lum) ((((uint16)(col)) << 8) / lum) @@ -316,7 +312,7 @@ uint8 closest(CBLK *pal, CBLK x) { } uint16 *saveScreen(); -void restoreScreen(uint16 * &sav); +void restoreScreen(uint16 * &sav); Sprite *spriteAt(int x, int y); Sprite *locate(int ref); -- cgit v1.2.3 From 749cd3b1159d132a2dc58afdf1817b1cee41f634 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 20 Aug 2011 00:03:44 +0200 Subject: CGE: Another fix for the pathfinding --- engines/cge/walk.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index 914f6db669..ccbb0e5532 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -47,12 +47,6 @@ bool Cluster::isValid() const { return (_a >= 0) && (_a < kMapXCnt) && (_b >= 0) && (_b < kMapZCnt); } -bool Cluster::chkBar() const { - assert(_vm->_now <= _vm->_caveMax); - return (_a < 0) || (_b < 0) || (_a >= _vm->_barriers[_vm->_now]._horz) || - (_b >= _vm->_barriers[_vm->_now]._vert); -} - Cluster XZ(int x, int y) { if (y < kMapTop) y = kMapTop; @@ -230,6 +224,11 @@ void Walk::noWay() { _vm->trouble(kSeqNoWay, kNoWay); } +bool Cluster::chkBar() const { + assert(_vm->_now <= _vm->_caveMax); + return (_a == _vm->_barriers[_vm->_now]._horz) || (_b == _vm->_barriers[_vm->_now]._vert); +} + bool Walk::find1Way(Cluster c) { Cluster start = c; const Cluster tab[4] = { Cluster(-1, 0), Cluster(1, 0), Cluster(0, -1), Cluster(0, 1)}; @@ -251,7 +250,6 @@ bool Walk::find1Way(Cluster c) { // Location is occupied return false; - // Loop through each direction for (int i = 0; i < tabLen; i++) { // Reset to starting position -- cgit v1.2.3 From c1807138fbb9dca4ff2d59f8c5ed39385716c6a0 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 20 Aug 2011 00:11:30 +0200 Subject: CGE: Cleanup of snail.cpp. --- engines/cge/snail.cpp | 1025 ++++++++++++++++++++++++------------------------- engines/cge/snail.h | 1 - 2 files changed, 508 insertions(+), 518 deletions(-) diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index ea8e480b35..ef766b9a4e 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -40,7 +40,7 @@ void CGEEngine::snGame(Sprite *spr, int num) { debugC(1, kCGEDebugEngine, "CGEEngine::snGame(spr, %d)", num); switch (num) { - case 1 : { + case 1: { static Sprite *dup[3] = { NULL, NULL, NULL }; int buref = 0; int Stage = 0; @@ -125,10 +125,9 @@ void CGEEngine::snGame(Sprite *spr, int num) { _snail->addCom(kSnSay, buref, 16008, NULL); // zgadnij! _game = true; } - } - break; - //-------------------------------------------------------------------- - case 2 : { + } + break; + case 2: if (_sprTv == NULL) { _sprTv = _vga->_showQ->locate(20700); _sprK1 = _vga->_showQ->locate(20701); @@ -139,105 +138,108 @@ void CGEEngine::snGame(Sprite *spr, int num) { if (!_game) { // init _snail->addCom(kSnGame, 20002, 2, NULL); _game = true; - } else { // cont - _sprK1->step(newRandom(6)); - _sprK2->step(newRandom(6)); - _sprK3->step(newRandom(6)); - ///-------------------- - if (spr->_ref == 1 && _keyboard->_key[kKeyAlt]) { - _sprK1->step(5); - _sprK2->step(5); - _sprK3->step(5); - } - ///-------------------- - _snail->addCom(kSnSetZ, 20700, 0, NULL); - bool hit = (_sprK1->_seqPtr + _sprK2->_seqPtr + _sprK3->_seqPtr == 15); - if (hit) { - if (spr->_ref == 1) { - _snail->addCom(kSnSay, 1, 20003, NULL); // hura! - _snail->addCom(kSnSeq, 20011, 2, NULL); // kamera won - _snail->addCom(kSnSend, 20701, -1, NULL); // k1 won - _snail->addCom(kSnSend, 20702, -1, NULL); // k2 won - _snail->addCom(kSnSend, 20703, -1, NULL); // k3 won - _snail->addCom(kSnSend, 20700, -1, NULL); // tv won - _snail->addCom(kSnKeep, 20007, 0, NULL); // do kieszeni - _snail->addCom(kSnSend, 20006, 20, NULL); // bilon - _snail->addCom(kSnSound, 20006, 20002, NULL); // bilon! - _snail->addCom(kSnSay, 20002, 20004, NULL); - _snail->addCom(kSnSend, 20010, 20, NULL); // papier - _snail->addCom(kSnSound, 20010, 20003, NULL); // papier! - _snail->addCom(kSnSay, 20001, 20005, NULL); - _game = false; - return; - } else - _sprK3->step(newRandom(5)); - } - if (_gameCase2Cpt < 100) { - switch (_gameCase2Cpt) { - case 15 : - _snail->addCom(kSnSay, 20003, 20021, NULL); - break; - case 30 : - case 45 : - case 60 : - case 75 : - _snail->addCom(kSnSay, 20003, 20022, NULL); - break; - } - _gameCase2Cpt++; - } - switch (spr->_ref) { - case 1 : - _snail->addCom(kSnSay, 20001, 20011, NULL); // zapro - _snail->addCom(kSnSeq, 20001, 1, NULL); // rzu - _snail->addCom(kSnWait, 20001, 1, NULL); // czekaj - _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k - _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k - _snail->addCom(kSnWait, 20001, 16, NULL); // czekaj - _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† - _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ - _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech - _snail->addCom(kSnWait, 20007, -1, NULL); // koniec - _snail->addCom(kSnGame, 20001, 2, NULL); // again! - break; - case 20001: - _snail->addCom(kSnSay, 20002, 20012, NULL); // zapro - _snail->addCom(kSnSeq, 20002, 1, NULL); // rzu - _snail->addCom(kSnWait, 20002, 3, NULL); // czekaj - _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k - _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k - _snail->addCom(kSnWait, 20002, 10, NULL); // czekaj - _snail->addCom(kSnSeq, 20007, 2, NULL); // lec† - _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ - _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech - _snail->addCom(kSnWait, 20007, -1, NULL); // koniec - _snail->addCom(kSnGame, 20002, 2, NULL); // again! + break; + } + + // cont + _sprK1->step(newRandom(6)); + _sprK2->step(newRandom(6)); + _sprK3->step(newRandom(6)); + + if (spr->_ref == 1 && _keyboard->_key[kKeyAlt]) { + _sprK1->step(5); + _sprK2->step(5); + _sprK3->step(5); + } + + _snail->addCom(kSnSetZ, 20700, 0, NULL); + bool hit = (_sprK1->_seqPtr + _sprK2->_seqPtr + _sprK3->_seqPtr == 15); + if (hit) { + if (spr->_ref == 1) { + _snail->addCom(kSnSay, 1, 20003, NULL); // hura! + _snail->addCom(kSnSeq, 20011, 2, NULL); // kamera won + _snail->addCom(kSnSend, 20701, -1, NULL); // k1 won + _snail->addCom(kSnSend, 20702, -1, NULL); // k2 won + _snail->addCom(kSnSend, 20703, -1, NULL); // k3 won + _snail->addCom(kSnSend, 20700, -1, NULL); // tv won + _snail->addCom(kSnKeep, 20007, 0, NULL); // do kieszeni + _snail->addCom(kSnSend, 20006, 20, NULL); // bilon + _snail->addCom(kSnSound, 20006, 20002, NULL); // bilon! + _snail->addCom(kSnSay, 20002, 20004, NULL); + _snail->addCom(kSnSend, 20010, 20, NULL); // papier + _snail->addCom(kSnSound, 20010, 20003, NULL); // papier! + _snail->addCom(kSnSay, 20001, 20005, NULL); + _game = false; + return; + } else + _sprK3->step(newRandom(5)); + } + + if (_gameCase2Cpt < 100) { + switch (_gameCase2Cpt) { + case 15: + _snail->addCom(kSnSay, 20003, 20021, NULL); break; - case 20002: - _snail->addCom(kSnSay, 20002, 20010, NULL); // zapro - _snail->addCom(kSnWalk, 20005, -1, NULL); // do stol - _snail->addCom(kSnWait, 1, -1, NULL); // stoi - _snail->addCom(kSnCover, 1, 20101, NULL); // grasol - _snail->addCom(kSnSeq, 20101, 1, NULL); // rzu - _snail->addCom(kSnWait, 20101, 5, NULL); // czekaj - _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k - _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k - _snail->addCom(kSnWait, 20101, 15, NULL); // czekaj - _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† - _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ - _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech - _snail->addCom(kSnWait, 20101, -1, NULL); // koniec - _snail->addCom(kSnUncover, 1, 20101, NULL); // SDS - _snail->addCom(kSnGame, 1, 2, NULL); // again! + case 30: + case 45: + case 60: + case 75: + _snail->addCom(kSnSay, 20003, 20022, NULL); break; } + _gameCase2Cpt++; + } + + switch (spr->_ref) { + case 1: + _snail->addCom(kSnSay, 20001, 20011, NULL); // zapro + _snail->addCom(kSnSeq, 20001, 1, NULL); // rzu + _snail->addCom(kSnWait, 20001, 1, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20001, 16, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech + _snail->addCom(kSnWait, 20007, -1, NULL); // koniec + _snail->addCom(kSnGame, 20001, 2, NULL); // again! + break; + + case 20001: + _snail->addCom(kSnSay, 20002, 20012, NULL); // zapro + _snail->addCom(kSnSeq, 20002, 1, NULL); // rzu + _snail->addCom(kSnWait, 20002, 3, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20002, 10, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 2, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech + _snail->addCom(kSnWait, 20007, -1, NULL); // koniec + _snail->addCom(kSnGame, 20002, 2, NULL); // again! + break; + + case 20002: + _snail->addCom(kSnSay, 20002, 20010, NULL); // zapro + _snail->addCom(kSnWalk, 20005, -1, NULL); // do stol + _snail->addCom(kSnWait, 1, -1, NULL); // stoi + _snail->addCom(kSnCover, 1, 20101, NULL); // grasol + _snail->addCom(kSnSeq, 20101, 1, NULL); // rzu + _snail->addCom(kSnWait, 20101, 5, NULL); // czekaj + _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k + _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k + _snail->addCom(kSnWait, 20101, 15, NULL); // czekaj + _snail->addCom(kSnSeq, 20007, 1, NULL); // lec† + _snail->addCom(kSnHide, 20007, 0, NULL); // poka§ + _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech + _snail->addCom(kSnWait, 20101, -1, NULL); // koniec + _snail->addCom(kSnUncover, 1, 20101, NULL); // SDS + _snail->addCom(kSnGame, 1, 2, NULL); // again! + break; } - } - break; } } - void CGEEngine::expandSprite(Sprite *spr) { debugC(5, kCGEDebugEngine, "CGEEngine::expandSprite(spr)"); @@ -245,7 +247,6 @@ void CGEEngine::expandSprite(Sprite *spr) { _vga->_showQ->insert(_vga->_spareQ->remove(spr)); } - void CGEEngine::contractSprite(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::contractSprite(spr)"); @@ -257,12 +258,11 @@ int CGEEngine::findPocket(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::findPocket(spr)"); for (int i = 0; i < kPocketNX; i++) - if (_pocket[i] == spr) - return i; + if (_pocket[i] == spr) + return i; return -1; } - void CGEEngine::selectPocket(int n) { debugC(1, kCGEDebugEngine, "CGEEngine::selectPocket(%d)", n); @@ -309,76 +309,77 @@ void CGEEngine::snGhost(Bitmap *bmp) { void CGEEngine::feedSnail(Sprite *spr, SnList snq) { debugC(1, kCGEDebugEngine, "CGEEngine::feedSnail(spr, snq)"); - if (spr) - if (spr->active()) { - uint8 ptr = (snq == kTake) ? spr->_takePtr : spr->_nearPtr; - - if (ptr != NO_PTR) { - Snail::Com *comtab = spr->snList(snq); - Snail::Com *c = comtab + ptr; - - if (findPocket(NULL) < 0) { // no empty pockets? - Snail::Com *p; - for (p = c; p->_com != kSnNext; p++) { // find KEEP command - if (p->_com == kSnKeep) { - pocFul(); - return; - } - if (p->_ptr) - break; - } - } - while (true) { - if (c->_com == kSnTalk) { - if ((_snail->_talkEnable = (c->_val != 0)) == false) - killText(); - } - if (c->_com == kSnNext) { - Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); - if (s) { - uint8 *idx = (snq == kTake) ? &s->_takePtr : &s->_nearPtr; - if (*idx != NO_PTR) { - int v; - switch (c->_val) { - case -1 : - v = c - comtab + 1; - break; - case -2 : - v = c - comtab; - break; - case -3 : - v = -1; - break; - default : - v = c->_val; - break; - } - if (v >= 0) - *idx = v; - } - } - if (s == spr) - break; - } - if (c->_com == kSnIf) { - Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); - if (s) { // sprite extsts - if (! s->seqTest(-1)) - c = comtab + c->_val; // not parked - else - ++c; - } else - ++c; - } else { - _snail->addCom(c->_com, c->_ref, c->_val, spr); - if (c->_ptr) - break; - else - c++; + if (!spr || !spr->active()) + return; + + uint8 ptr = (snq == kTake) ? spr->_takePtr : spr->_nearPtr; + + if (ptr == NO_PTR) + return; + + Snail::Com *comtab = spr->snList(snq); + Snail::Com *c = comtab + ptr; + + if (findPocket(NULL) < 0) { // no empty pockets? + Snail::Com *p; + for (p = c; p->_com != kSnNext; p++) { // find KEEP command + if (p->_com == kSnKeep) { + pocFul(); + return; + } + if (p->_ptr) + break; + } + } + while (true) { + if (c->_com == kSnTalk) { + if ((_snail->_talkEnable = (c->_val != 0)) == false) + killText(); + } + if (c->_com == kSnNext) { + Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); + if (s) { + uint8 *idx = (snq == kTake) ? &s->_takePtr : &s->_nearPtr; + if (*idx != NO_PTR) { + int v; + switch (c->_val) { + case -1 : + v = c - comtab + 1; + break; + case -2 : + v = c - comtab; + break; + case -3 : + v = -1; + break; + default : + v = c->_val; + break; } + if (v >= 0) + *idx = v; } } + if (s == spr) + break; + } + if (c->_com == kSnIf) { + Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); + if (s) { // sprite extsts + if (! s->seqTest(-1)) + c = comtab + c->_val; // not parked + else + ++c; + } else + ++c; + } else { + _snail->addCom(c->_com, c->_ref, c->_val, spr); + if (c->_ptr) + break; + else + c++; } + } } const char *Snail::_comText[] = { @@ -395,7 +396,6 @@ const char *Snail::_comText[] = { "MOUSE", "SOUND", "COUNT", NULL }; - Snail::Snail(CGEEngine *vm, bool turbo) : _turbo(turbo), _busy(false), _textDelay(false), _timerExpiry(0), _talkEnable(true), @@ -490,16 +490,15 @@ void CGEEngine::snRTNext(Sprite *spr, int p) { void CGEEngine::snZTrim(Sprite *spr) { debugC(4, kCGEDebugEngine, "CGEEngine::snZTrim(spr)"); - if (spr) - if (spr->active()) { - Sprite *s; - s = (spr->_flags._shad) ? spr->_prev : NULL; - _vga->_showQ->insert(_vga->_showQ->remove(spr)); - if (s) { - s->_z = spr->_z; - _vga->_showQ->insert(_vga->_showQ->remove(s), spr); - } - } + if (!spr || !spr->active()) + return; + + Sprite *s = (spr->_flags._shad) ? spr->_prev : NULL; + _vga->_showQ->insert(_vga->_showQ->remove(spr)); + if (s) { + s->_z = spr->_z; + _vga->_showQ->insert(_vga->_showQ->remove(s), spr); + } } void CGEEngine::snHide(Sprite *spr, int val) { @@ -547,30 +546,31 @@ void CGEEngine::snRSeq(Sprite *spr, int val) { void CGEEngine::snSend(Sprite *spr, int val) { debugC(1, kCGEDebugEngine, "CGEEngine::snSend(spr, %d)", val); - if (spr) { - int was = spr->_cave; - bool was1 = (was == 0 || was == _now); - bool val1 = (val == 0 || val == _now); - spr->_cave = val; - if (val1 != was1) { - if (was1) { - if (spr->_flags._kept) { - int n = findPocket(spr); - if (n >= 0) - _pocket[n] = NULL; - } - hide1(spr); - contractSprite(spr); - spr->_flags._slav = false; - } else { - if (spr->_ref % 1000 == 0) - Bitmap::_pal = Vga::_sysPal; - if (spr->_flags._back) - spr->backShow(true); - else - expandSprite(spr); - Bitmap::_pal = NULL; + if (!spr) + return; + + int was = spr->_cave; + bool was1 = (was == 0 || was == _now); + bool val1 = (val == 0 || val == _now); + spr->_cave = val; + if (val1 != was1) { + if (was1) { + if (spr->_flags._kept) { + int n = findPocket(spr); + if (n >= 0) + _pocket[n] = NULL; } + hide1(spr); + contractSprite(spr); + spr->_flags._slav = false; + } else { + if (spr->_ref % 1000 == 0) + Bitmap::_pal = Vga::_sysPal; + if (spr->_flags._back) + spr->backShow(true); + else + expandSprite(spr); + Bitmap::_pal = NULL; } } } @@ -579,77 +579,77 @@ void CGEEngine::snSwap(Sprite *spr, int xref) { debugC(1, kCGEDebugEngine, "CGEEngine::snSwap(spr, %d)", xref); Sprite *xspr = locate(xref); - if (spr && xspr) { - int was = spr->_cave; - int xwas = xspr->_cave; - bool was1 = (was == 0 || was == _now); - bool xwas1 = (xwas == 0 || xwas == _now); - - swap(spr->_cave, xspr->_cave); - swap(spr->_x, xspr->_x); - swap(spr->_y, xspr->_y); - swap(spr->_z, xspr->_z); - if (spr->_flags._kept) { - int n = findPocket(spr); - if (n >= 0) - _pocket[n] = xspr; - xspr->_flags._kept = true; - xspr->_flags._port = false; - } - if (xwas1 != was1) { - if (was1) { - hide1(spr); - contractSprite(spr); - } else - expandSprite(spr); - if (xwas1) { - hide1(xspr); - contractSprite(xspr); - } else - expandSprite(xspr); - } + if (!spr || !xspr) + return; + + int was = spr->_cave; + int xwas = xspr->_cave; + bool was1 = (was == 0 || was == _now); + bool xwas1 = (xwas == 0 || xwas == _now); + + swap(spr->_cave, xspr->_cave); + swap(spr->_x, xspr->_x); + swap(spr->_y, xspr->_y); + swap(spr->_z, xspr->_z); + if (spr->_flags._kept) { + int n = findPocket(spr); + if (n >= 0) + _pocket[n] = xspr; + xspr->_flags._kept = true; + xspr->_flags._port = false; + } + if (xwas1 != was1) { + if (was1) { + hide1(spr); + contractSprite(spr); + } else + expandSprite(spr); + if (xwas1) { + hide1(xspr); + contractSprite(xspr); + } else + expandSprite(xspr); } } - void CGEEngine::snCover(Sprite *spr, int xref) { debugC(1, kCGEDebugEngine, "CGEEngine::snCover(spr, %d)", xref); Sprite *xspr = locate(xref); - if (spr && xspr) { - spr->_flags._hide = true; - xspr->_z = spr->_z; - xspr->_cave = spr->_cave; - xspr->gotoxy(spr->_x, spr->_y); - expandSprite(xspr); - if ((xspr->_flags._shad = spr->_flags._shad) == 1) { - _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr); - spr->_flags._shad = false; - } - feedSnail(xspr, kNear); + if (!spr || !xspr) + return; + + spr->_flags._hide = true; + xspr->_z = spr->_z; + xspr->_cave = spr->_cave; + xspr->gotoxy(spr->_x, spr->_y); + expandSprite(xspr); + if ((xspr->_flags._shad = spr->_flags._shad) == 1) { + _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr); + spr->_flags._shad = false; } + feedSnail(xspr, kNear); } - void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) { debugC(1, kCGEDebugEngine, "CGEEngine::snUncover(spr, xspr)"); - if (spr && xspr) { - spr->_flags._hide = false; - spr->_cave = xspr->_cave; - spr->gotoxy(xspr->_x, xspr->_y); - if ((spr->_flags._shad = xspr->_flags._shad) == 1) { - _vga->_showQ->insert(_vga->_showQ->remove(xspr->_prev), spr); - xspr->_flags._shad = false; - } - spr->_z = xspr->_z; - snSend(xspr, -1); - if (spr->_time == 0) - spr->_time++; + if (!spr || !xspr) + return; + + spr->_flags._hide = false; + spr->_cave = xspr->_cave; + spr->gotoxy(xspr->_x, xspr->_y); + if ((spr->_flags._shad = xspr->_flags._shad) == 1) { + _vga->_showQ->insert(_vga->_showQ->remove(xspr->_prev), spr); + xspr->_flags._shad = false; } + spr->_z = xspr->_z; + snSend(xspr, -1); + if (spr->_time == 0) + spr->_time++; } - void CGEEngine::snSetX0(int cav, int x0) { debugC(1, kCGEDebugEngine, "CGEEngine::snSetX0(%d, %d)", cav, x0); @@ -683,7 +683,6 @@ void CGEEngine::snRelY(Sprite *spr, int y) { spr->gotoxy(spr->_x, _hero->_y + y); } - void CGEEngine::snRelZ(Sprite *spr, int z) { debugC(1, kCGEDebugEngine, "CGEEngine::snRelZ(spr, %d)", z); @@ -693,7 +692,6 @@ void CGEEngine::snRelZ(Sprite *spr, int z) { } } - void CGEEngine::snSetX(Sprite *spr, int x) { debugC(1, kCGEDebugEngine, "CGEEngine::snSetX(spr, %d)", x); @@ -701,7 +699,6 @@ void CGEEngine::snSetX(Sprite *spr, int x) { spr->gotoxy(x, spr->_y); } - void CGEEngine::snSetY(Sprite *spr, int y) { debugC(1, kCGEDebugEngine, "CGEEngine::snSetY(spr, %d)", y); @@ -709,7 +706,6 @@ void CGEEngine::snSetY(Sprite *spr, int y) { spr->gotoxy(spr->_x, y); } - void CGEEngine::snSetZ(Sprite *spr, int z) { debugC(1, kCGEDebugEngine, "CGEEngine::snSetZ(spr, %d)", z); @@ -720,7 +716,6 @@ void CGEEngine::snSetZ(Sprite *spr, int z) { } } - void CGEEngine::snSlave(Sprite *spr, int ref) { debugC(1, kCGEDebugEngine, "CGEEngine::snSlave(spr, %d)", ref); @@ -735,7 +730,6 @@ void CGEEngine::snSlave(Sprite *spr, int ref) { } } - void CGEEngine::snTrans(Sprite *spr, int trans) { debugC(1, kCGEDebugEngine, "CGEEngine::snTrans(spr, %d)", trans); @@ -753,30 +747,30 @@ void CGEEngine::snPort(Sprite *spr, int port) { void CGEEngine::snKill(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::snKill(spr)"); - if (spr) { - if (spr->_flags._kept) { - int n = findPocket(spr); - if (n >= 0) - _pocket[n] = NULL; - } - Sprite *nx = spr->_next; - hide1(spr); - _vga->_showQ->remove(spr); - _eventManager->clearEvent(spr); - if (spr->_flags._kill) - delete spr; - else { - spr->_cave = -1; - _vga->_spareQ->append(spr); - } - if (nx) { - if (nx->_flags._slav) - snKill(nx); - } + if (!spr) + return; + + if (spr->_flags._kept) { + int n = findPocket(spr); + if (n >= 0) + _pocket[n] = NULL; + } + Sprite *nx = spr->_next; + hide1(spr); + _vga->_showQ->remove(spr); + _eventManager->clearEvent(spr); + if (spr->_flags._kill) { + delete spr; + } else { + spr->_cave = -1; + _vga->_spareQ->append(spr); + } + if (nx) { + if (nx->_flags._slav) + snKill(nx); } } - void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { debugC(1, kCGEDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt); @@ -786,7 +780,6 @@ void CGEEngine::snSound(Sprite *spr, int wav, int cnt) { _sound->play((*_fx)[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt); } - void CGEEngine::snKeep(Sprite *spr, int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::snKeep(spr, %d)", stp); @@ -846,7 +839,6 @@ void CGEEngine::snLevel(Sprite *spr, int lev) { spr->_flags._hide = false; } - void CGEEngine::snFlag(int indx, bool v) { _flag[indx] = v; } @@ -881,7 +873,6 @@ void CGEEngine::snFlash(bool on) { _dark = false; } - void CGEEngine::snLight(bool in) { debugC(1, kCGEDebugEngine, "CGEEngine::snLight(%s)", in ? "true" : "false"); @@ -889,7 +880,7 @@ void CGEEngine::snLight(bool in) { _vga->sunrise(Vga::_sysPal); else _vga->sunset(); - _dark = ! in; + _dark = !in; } void CGEEngine::snBarrier(int cav, int bar, bool horz) { @@ -925,254 +916,254 @@ void CGEEngine::snMouse(bool on) { _mouse->off(); } - void Snail::runCom() { static int count = 1; - if (!_busy) { - _busy = true; - uint8 tmpHead = _head; - while (_tail != tmpHead) { - Com *snc = &_snList[_tail]; - - if (!_turbo) { // only for the slower one - if (_timerExpiry) { - // Delay in progress - if (_timerExpiry > g_system->getMillis()) - // Delay not yet ended - break; - // Delay is finished - _timerExpiry = 0; - } else { - if (_textDelay) { - killText(); - _textDelay = false; - } - } - if (_talk && snc->_com != kSnPause) + if (_busy) + return; + + _busy = true; + uint8 tmpHead = _head; + while (_tail != tmpHead) { + Com *snc = &_snList[_tail]; + + if (!_turbo) { // only for the slower one + if (_timerExpiry) { + // Delay in progress + if (_timerExpiry > g_system->getMillis()) + // Delay not yet ended break; - } - Sprite *spr = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr)); - switch (snc->_com) { - case kSnLabel: - break; - case kSnPause : - _timerExpiry = g_system->getMillis() + snc->_val * kSnailFrameDelay; - if (_talk) - _textDelay = true; - break; - case kSnWait: - if (spr) { - if (spr->seqTest(snc->_val) && - (snc->_val >= 0 || spr != _hero || _hero->_tracePtr < 0)) { - _timerExpiry = g_system->getMillis() + spr->_time * kSnailFrameDelay; - } else - goto xit; - } - break; - case kSnLevel: - _vm->snLevel(spr, snc->_val); - break; - case kSnHide: - _vm->snHide(spr, snc->_val); - break; - case kSnSay: - if (spr && _talkEnable) { - if (spr == _hero && spr->seqTest(-1)) - spr->step(kSeqHTalk); - _text->say(_text->getText(snc->_val), spr); - _sys->_funDel = kHeroFun0; - } - break; - case kSnInf: - if (_talkEnable) { - _vm->inf(_text->getText(snc->_val)); - _sys->_funDel = kHeroFun0; - } - break; - case kSnTime: - if (spr && _talkEnable) { - if (spr == _hero && spr->seqTest(-1)) - spr->step(kSeqHTalk); - _text->sayTime(spr); + // Delay is finished + _timerExpiry = 0; + } else { + if (_textDelay) { + killText(); + _textDelay = false; } + } + if (_talk && snc->_com != kSnPause) break; - case kSnCave: - _vm->switchCave(snc->_val); - break; - case kSnKill: - _vm->snKill(spr); - break; - case kSnSeq: - _vm->snSeq(spr, snc->_val); - break; - case kSnRSeq: - _vm->snRSeq(spr, snc->_val); - break; - case kSnSend: - _vm->snSend(spr, snc->_val); - break; - case kSnSwap: - _vm->snSwap(spr, snc->_val); - break; - case kSnCover: - _vm->snCover(spr, snc->_val); - break; - case kSnUncover: - _vm->snUncover(spr, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); - break; - case kSnKeep: - _vm->snKeep(spr, snc->_val); - break; - case kSnGive: - _vm->snGive(spr, snc->_val); - break; - case kSnGame: - _vm->snGame(spr, snc->_val); - break; - case kSnSetX0: - _vm->snSetX0(snc->_ref, snc->_val); - break; - case kSnSetY0: - _vm->snSetY0(snc->_ref, snc->_val); - break; - case kSnSetXY: - _vm->snSetXY(spr, snc->_val); - break; - case kSnRelX: - _vm->snRelX(spr, snc->_val); - break; - case kSnRelY: - _vm->snRelY(spr, snc->_val); - break; - case kSnRelZ: - _vm->snRelZ(spr, snc->_val); - break; - case kSnSetX: - _vm->snSetX(spr, snc->_val); - break; - case kSnSetY: - _vm->snSetY(spr, snc->_val); - break; - case kSnSetZ: - _vm->snSetZ(spr, snc->_val); - break; - case kSnSlave: - _vm->snSlave(spr, snc->_val); - break; - case kSnTrans: - _vm->snTrans(spr, snc->_val); - break; - case kSnPort: - _vm->snPort(spr, snc->_val); - break; - case kSnNext: - case kSnIf: - case kSnTalk: - break; - case kSnMouse: - _vm->snMouse(snc->_val != 0); - break; - case kSnNNext: - _vm->snNNext(spr, snc->_val); - break; - case kSnTNext: - _vm->snTNext(spr, snc->_val); - break; - case kSnRNNext: - _vm->snRNNext(spr, snc->_val); - break; - case kSnRTNext: - _vm->snRTNext(spr, snc->_val); - break; - case kSnRMNear: - _vm->snRmNear(spr); - break; - case kSnRmTake: - _vm->snRmTake(spr); - break; - case kSnFlag: - _vm->snFlag(snc->_ref & 3, snc->_val != 0); - break; - case kSnSetRef: - _vm->snSetRef(spr, snc->_val); - break; - case kSnBackPt: - _vm->snBackPt(spr, snc->_val); - break; - case kSnFlash: - _vm->snFlash(snc->_val != 0); - break; - case kSnLight: - _vm->snLight(snc->_val != 0); - break; - case kSnSetHBarrier: - _vm->snBarrier(snc->_ref, snc->_val, true); - break; - case kSnSetVBarrier: - _vm->snBarrier(snc->_ref, snc->_val, false); - break; - case kSnWalk: - _vm->snWalk(spr, snc->_ref, snc->_val); - break; - case kSnReach: - _vm->snReach(spr, snc->_val); - break; - case kSnSound: - _vm->snSound(spr, snc->_val, count); - count = 1; - break; - case kSnCount: - count = snc->_val; + } + + Sprite *spr = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr)); + switch (snc->_com) { + case kSnLabel: + break; + case kSnPause : + _timerExpiry = g_system->getMillis() + snc->_val * kSnailFrameDelay; + if (_talk) + _textDelay = true; + break; + case kSnWait: + if (spr) { + if (spr->seqTest(snc->_val) && + (snc->_val >= 0 || spr != _hero || _hero->_tracePtr < 0)) { + _timerExpiry = g_system->getMillis() + spr->_time * kSnailFrameDelay; + } else + goto xit; + } + break; + case kSnLevel: + _vm->snLevel(spr, snc->_val); + break; + case kSnHide: + _vm->snHide(spr, snc->_val); + break; + case kSnSay: + if (spr && _talkEnable) { + if (spr == _hero && spr->seqTest(-1)) + spr->step(kSeqHTalk); + _text->say(_text->getText(snc->_val), spr); + _sys->_funDel = kHeroFun0; + } + break; + case kSnInf: + if (_talkEnable) { + _vm->inf(_text->getText(snc->_val)); + _sys->_funDel = kHeroFun0; + } + break; + case kSnTime: + if (spr && _talkEnable) { + if (spr == _hero && spr->seqTest(-1)) + spr->step(kSeqHTalk); + _text->sayTime(spr); + } + break; + case kSnCave: + _vm->switchCave(snc->_val); + break; + case kSnKill: + _vm->snKill(spr); + break; + case kSnSeq: + _vm->snSeq(spr, snc->_val); + break; + case kSnRSeq: + _vm->snRSeq(spr, snc->_val); + break; + case kSnSend: + _vm->snSend(spr, snc->_val); + break; + case kSnSwap: + _vm->snSwap(spr, snc->_val); + break; + case kSnCover: + _vm->snCover(spr, snc->_val); + break; + case kSnUncover: + _vm->snUncover(spr, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); + break; + case kSnKeep: + _vm->snKeep(spr, snc->_val); + break; + case kSnGive: + _vm->snGive(spr, snc->_val); + break; + case kSnGame: + _vm->snGame(spr, snc->_val); + break; + case kSnSetX0: + _vm->snSetX0(snc->_ref, snc->_val); + break; + case kSnSetY0: + _vm->snSetY0(snc->_ref, snc->_val); + break; + case kSnSetXY: + _vm->snSetXY(spr, snc->_val); + break; + case kSnRelX: + _vm->snRelX(spr, snc->_val); + break; + case kSnRelY: + _vm->snRelY(spr, snc->_val); + break; + case kSnRelZ: + _vm->snRelZ(spr, snc->_val); + break; + case kSnSetX: + _vm->snSetX(spr, snc->_val); + break; + case kSnSetY: + _vm->snSetY(spr, snc->_val); + break; + case kSnSetZ: + _vm->snSetZ(spr, snc->_val); + break; + case kSnSlave: + _vm->snSlave(spr, snc->_val); + break; + case kSnTrans: + _vm->snTrans(spr, snc->_val); + break; + case kSnPort: + _vm->snPort(spr, snc->_val); + break; + case kSnNext: + case kSnIf: + case kSnTalk: + break; + case kSnMouse: + _vm->snMouse(snc->_val != 0); + break; + case kSnNNext: + _vm->snNNext(spr, snc->_val); + break; + case kSnTNext: + _vm->snTNext(spr, snc->_val); + break; + case kSnRNNext: + _vm->snRNNext(spr, snc->_val); + break; + case kSnRTNext: + _vm->snRTNext(spr, snc->_val); + break; + case kSnRMNear: + _vm->snRmNear(spr); + break; + case kSnRmTake: + _vm->snRmTake(spr); + break; + case kSnFlag: + _vm->snFlag(snc->_ref & 3, snc->_val != 0); + break; + case kSnSetRef: + _vm->snSetRef(spr, snc->_val); + break; + case kSnBackPt: + _vm->snBackPt(spr, snc->_val); + break; + case kSnFlash: + _vm->snFlash(snc->_val != 0); + break; + case kSnLight: + _vm->snLight(snc->_val != 0); + break; + case kSnSetHBarrier: + _vm->snBarrier(snc->_ref, snc->_val, true); + break; + case kSnSetVBarrier: + _vm->snBarrier(snc->_ref, snc->_val, false); + break; + case kSnWalk: + _vm->snWalk(spr, snc->_ref, snc->_val); + break; + case kSnReach: + _vm->snReach(spr, snc->_val); + break; + case kSnSound: + _vm->snSound(spr, snc->_val, count); + count = 1; + break; + case kSnCount: + count = snc->_val; + break; + case kSnExec: + switch (snc->_cbType) { + case kQGame: + _vm->qGame(); break; - case kSnExec: - switch (snc->_cbType) { - case kQGame: - _vm->qGame(); - break; - case kMiniStep: - _vm->miniStep(snc->_val); - break; - case kXCave: - _vm->xCave(); - break; - case kSelectSound: - warning("TODO: Select sound card"); - break; - case kSnSelect: - warning("TODO: Sound card selection"); - break; - case kSndSetVolume: - sndSetVolume(); - break; - default: - error("Unknown Callback Type in SNEXEC"); - } + case kMiniStep: + _vm->miniStep(snc->_val); break; - case kSnStep: - spr->step(); + case kXCave: + _vm->xCave(); break; - case kSnZTrim: - _vm->snZTrim(spr); + case kSelectSound: + warning("TODO: Select sound card"); break; - case kSnGhost: - _vm->snGhost((Bitmap *) snc->_ptr); + case kSnSelect: + warning("TODO: Sound card selection"); break; - default : - warning("Unhandled snc->_com in SNMouse(bool)"); + case kSndSetVolume: + sndSetVolume(); break; + default: + error("Unknown Callback Type in SNEXEC"); } - _tail++; - if (!_turbo) - break; + break; + case kSnStep: + spr->step(); + break; + case kSnZTrim: + _vm->snZTrim(spr); + break; + case kSnGhost: + _vm->snGhost((Bitmap *) snc->_ptr); + break; + default: + warning("Unhandled snc->_com in SNMouse(bool)"); + break; } -xit: - _busy = false; + _tail++; + if (!_turbo) + break; } +xit: + _busy = false; } - bool Snail::idle() { return (_head == _tail); } diff --git a/engines/cge/snail.h b/engines/cge/snail.h index 2d12963f2c..e478ad95ff 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -80,7 +80,6 @@ private: CGEEngine *_vm; }; - } // End of namespace CGE #endif -- cgit v1.2.3 From e4a37322a6678aa3874d96ce131bebbccbdd7a44 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 20 Aug 2011 00:23:45 +0200 Subject: CGE: More misc cleanup. --- engines/cge/btfile.cpp | 4 --- engines/cge/events.cpp | 1 - engines/cge/sound.cpp | 19 ++---------- engines/cge/text.cpp | 78 ++++++++++++++++++++++++-------------------------- engines/cge/walk.cpp | 19 ++++-------- 5 files changed, 47 insertions(+), 74 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 053f264b35..a4d16010e5 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -48,7 +48,6 @@ BtFile::BtFile(const char *name, IOMode mode, Crypt *crpt) } } - BtFile::~BtFile() { debugC(1, kCGEDebugFile, "BtFile::~BtFile()"); for (int i = 0; i < kBtLevel; i++) { @@ -57,7 +56,6 @@ BtFile::~BtFile() { } } - void BtFile::putPage(int lev, bool hard) { debugC(1, kCGEDebugFile, "BtFile::putPage(%d, %s)", lev, hard ? "true" : "false"); @@ -68,7 +66,6 @@ void BtFile::putPage(int lev, bool hard) { } } - BtPage *BtFile::getPage(int lev, uint16 pgn) { debugC(1, kCGEDebugFile, "BtFile::getPage(%d, %d)", lev, pgn); @@ -130,7 +127,6 @@ BtKeypack *BtFile::find(const char *key) { return NULL; } - int keycomp(const void *k1, const void *k2) { return scumm_strnicmp((const char *) k1, (const char*) k2, kBtKeySize); } diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 6e23b4e613..5af5a9ee3f 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -179,7 +179,6 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0) step(1); } - Mouse::~Mouse() { off(); } diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index b22548c16d..432bca75b5 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -42,22 +42,18 @@ Sound::Sound(CGEEngine *vm) : _vm(vm) { open(); } - Sound::~Sound() { close(); } - void Sound::close() { _vm->_midiPlayer.killMidi(); } - void Sound::open() { play((*_fx)[30000], 8); } - void Sound::play(DataCk *wav, int pan, int cnt) { if (wav) { stop(); @@ -97,16 +93,13 @@ Fx::Fx(int size) : _current(NULL) { } } - Fx::~Fx() { clear(); delete[] _cache; } - void Fx::clear() { - Han *p, * q; - for (p = _cache, q = p + _size; p < q; p++) { + for (Han *p = _cache, *q = p + _size; p < q; p++) { if (p->_ref) { p->_ref = 0; delete p->_wav; @@ -116,11 +109,9 @@ void Fx::clear() { _current = NULL; } - int Fx::find(int ref) { - Han *p, * q; int i = 0; - for (p = _cache, q = p + _size; p < q; p++) { + for (Han *p = _cache, *q = p + _size; p < q; p++) { if (p->_ref == ref) break; else @@ -129,12 +120,10 @@ int Fx::find(int ref) { return i; } - void Fx::preload(int ref0) { Han *cacheLim = _cache + _size; - int ref; - for (ref = ref0; ref < ref0 + 10; ref++) { + for (int ref = ref0; ref < ref0 + 10; ref++) { static char fname[] = "FX00000.WAV"; wtom(ref, fname + 2, 10, 5); INI_FILE file = INI_FILE(fname); @@ -149,7 +138,6 @@ void Fx::preload(int ref0) { } } - DataCk *Fx::load(int idx, int ref) { static char fname[] = "FX00000.WAV"; wtom(ref, fname + 2, 10, 5); @@ -164,7 +152,6 @@ DataCk *Fx::load(int idx, int ref) { return wav; } - DataCk *Fx::operator [](int ref) { int i; if ((i = find(ref)) < _size) diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 7e58762afa..0e6fc40920 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -79,44 +79,44 @@ int Text::find(int ref) { void Text::preload(int from, int upto) { INI_FILE tf = _fileName; - if (!tf._error) { - Han *CacheLim = _cache + _size; - char line[kLineMax + 1]; - int n; - - while ((n = tf.read((uint8 *)line)) != 0) { - char *s; - - if (line[n - 1] == '\n') - line[--n] = '\0'; - - if ((s = strtok(line, " =,;/\t\n")) == NULL) - continue; - if (!IsDigit(*s)) - continue; - - int ref = atoi(s); - if (ref && ref >= from && ref < upto) { - Han *p = &_cache[find(ref)]; - - if (p < CacheLim) { - delete[] p->_text; - p->_text = NULL; - } else - p = &_cache[find(0)]; - - if (p >= CacheLim) - break; - - s += strlen(s); - if (s < line + n) - ++s; - if ((p->_text = new char[strlen(s) + 1]) == NULL) - break; - - p->_ref = ref; - strcpy(p->_text, s); - } + if (tf._error) + return; + + Han *CacheLim = _cache + _size; + char line[kLineMax + 1]; + int n; + + while ((n = tf.read((uint8 *)line)) != 0) { + if (line[n - 1] == '\n') + line[--n] = '\0'; + + char *s; + if ((s = strtok(line, " =,;/\t\n")) == NULL) + continue; + if (!IsDigit(*s)) + continue; + + int ref = atoi(s); + if (ref && ref >= from && ref < upto) { + Han *p = &_cache[find(ref)]; + + if (p < CacheLim) { + delete[] p->_text; + p->_text = NULL; + } else + p = &_cache[find(0)]; + + if (p >= CacheLim) + break; + + s += strlen(s); + if (s < line + n) + ++s; + if ((p->_text = new char[strlen(s) + 1]) == NULL) + break; + + p->_ref = ref; + strcpy(p->_text, s); } } } @@ -161,7 +161,6 @@ char *Text::load(int idx, int ref) { return NULL; } - char *Text::getText(int ref) { int i; if ((i = find(ref)) < _size) @@ -177,7 +176,6 @@ char *Text::getText(int ref) { return load(i, ref); } - void Text::say(const char *text, Sprite *spr) { killText(); _talk = new Talk(_vm, text, kTBRound); diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index ccbb0e5532..95cc92afd4 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -57,7 +57,6 @@ Cluster XZ(int x, int y) { return Cluster(x / kMapGridX, (y - kMapTop) / kMapGridZ); } - Cluster XZ(Couple xy) { signed char x, y; xy.split(x, y); @@ -68,7 +67,6 @@ Walk::Walk(CGEEngine *vm, BitmapPtr *shpl) : Sprite(vm, shpl), _dir(kDirNone), _tracePtr(-1), _level(0), _target(-1, -1), _findLevel(-1), _vm(vm) { } - void Walk::tick() { if (_flags._hide) return; @@ -76,9 +74,8 @@ void Walk::tick() { _here = XZ(_x + _w / 2, _y + _h); if (_dir != kDirNone) { - Sprite *spr; _sys->funTouch(); - for (spr = _vga->_showQ->first(); spr; spr = spr->_next) { + for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (distance(spr) < 2) { if (!spr->_flags._near) { _vm->feedSnail(spr, kNear); @@ -103,8 +100,10 @@ void Walk::tick() { turn(d); } } + step(); - if ((_dir == kDirWest && _x <= 0) || + + if ((_dir == kDirWest && _x <= 0) || (_dir == kDirEast && _x + _w >= kScrWidth) || (_dir == kDirSouth && _y + _w >= kWorldHeight - 2)) { park(); @@ -115,7 +114,6 @@ void Walk::tick() { } } - int Walk::distance(Sprite *spr) { int dx = spr->_x - (_x + _w - kWalkSide); if (dx < 0) @@ -136,7 +134,6 @@ int Walk::distance(Sprite *spr) { return dz - 1; } - void Walk::turn(Dir d) { Dir dir = (_dir == kDirNone) ? kDirSouth : _dir; if (d != _dir) { @@ -145,7 +142,6 @@ void Walk::turn(Dir d) { } } - void Walk::park() { if (_time == 0) _time++; @@ -157,7 +153,6 @@ void Walk::park() { } } - void Walk::findWay(Cluster c) { if (c == _here) return; @@ -171,13 +166,13 @@ void Walk::findWay(Cluster c) { if (find1Way(Cluster(x, z))) break; } + _tracePtr = (_findLevel > kMaxFindLevel) ? -1 : (_findLevel - 1); if (_tracePtr < 0) noWay(); _time = 1; } - void Walk::findWay(Sprite *spr) { if (!spr || spr == this) return; @@ -194,12 +189,10 @@ void Walk::findWay(Sprite *spr) { : (z - 1)))); } - bool Walk::lower(Sprite *spr) { return (spr->_y > _y + (_h * 3) / 5); } - void Walk::reach(Sprite *spr, int mode) { if (spr) { _hero->findWay(spr); @@ -230,7 +223,6 @@ bool Cluster::chkBar() const { } bool Walk::find1Way(Cluster c) { - Cluster start = c; const Cluster tab[4] = { Cluster(-1, 0), Cluster(1, 0), Cluster(0, -1), Cluster(0, 1)}; const int tabLen = 4; @@ -251,6 +243,7 @@ bool Walk::find1Way(Cluster c) { return false; // Loop through each direction + Cluster start = c; for (int i = 0; i < tabLen; i++) { // Reset to starting position c = start; -- cgit v1.2.3 From e916f9ce8c284a429798ea2dc74fd0b6fc1b09ab Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 20 Aug 2011 00:40:44 +0200 Subject: CGE: Another few formatting tweaks. --- engines/cge/bitmap.cpp | 2 +- engines/cge/cge_main.cpp | 11 +++-------- engines/cge/snddrv.h | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 1de10e2bfd..f9eae101ce 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -223,7 +223,7 @@ BitmapPtr Bitmap::code() { skip = (pix == kPixelTransp); cnt = 0; } - if (! skip) { + if (!skip) { if (_v) *im = pix; im++; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 99cb5d487f..fb92f93e01 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -369,7 +369,6 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt } } debugC(1, kCGEDebugEngine, "CGEEngine::saveSound()"); - } bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header) { @@ -401,7 +400,6 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade header.saveMinutes = in->readSint16LE(); return true; - } void CGEEngine::heroCover(int cvr) { @@ -546,9 +544,9 @@ void CGEEngine::AltCtrlDel() { void CGEEngine::miniStep(int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::miniStep(%d)", stp); - if (stp < 0) + if (stp < 0) { _miniCave->_flags._hide = true; - else { + } else { *_miniShp[0] = *_miniShpList[stp]; if (_fx->_current) &*(_fx->_current->addr()); @@ -640,7 +638,6 @@ void CGEEngine::caveUp() { _mouse->on(); } - void CGEEngine::caveDown() { debugC(1, kCGEDebugEngine, "CGEEngine::caveDown()"); @@ -656,6 +653,7 @@ void CGEEngine::caveDown() { } spr = n; } + _text->clear(1000); } @@ -867,7 +865,6 @@ void System::touch(uint16 mask, int x, int y) { } } - void System::tick() { if (!_vm->_startupMode) if (--_funDel == 0) { @@ -1031,7 +1028,6 @@ void CGEEngine::saveMapping() { } } - void CGEEngine::sayDebug() { // 1111111111222222222233333333334444444444555555555566666666667777777777 // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 @@ -1177,7 +1173,6 @@ void Sprite::touch(uint16 mask, int x, int y) { } } - void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) { static const char *Comd[] = { "Name", "Type", "Phase", "East", "Left", "Right", "Top", "Bottom", diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 7af214365f..9e937d1cbf 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -45,7 +45,7 @@ namespace CGE { // sample info struct SmpInfo { - const uint8 *_saddr; // address + const uint8 *_saddr; // address uint16 _slen; // length uint16 _span; // left/right pan (0-15) int _sflag; // flag -- cgit v1.2.3 From 81ae309d5f8617615305ef1c6ce280e7cc380d2a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 20 Aug 2011 01:32:20 +0200 Subject: CGE: Suppress some debug code present in the original --- engines/cge/cge.h | 6 -- engines/cge/cge_main.cpp | 178 ++--------------------------------------------- engines/cge/cge_main.h | 1 - engines/cge/walk.cpp | 2 +- 4 files changed, 7 insertions(+), 180 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 1c5e680901..fbb096df07 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -201,7 +201,6 @@ public: void pocFul(); void hide1(Sprite *spr); void loadMapping(); - void saveMapping(); void saveSound(); void heroCover(int cvr); void trouble(int seq, int text); @@ -211,13 +210,8 @@ public: void keyClick(); void switchColorMode(); void killSprite(); - void pushSprite(); - void pullSprite(); - void sayDebug(); - void nextStep(); void switchDebug(); void miniStep(int stp); - void AltCtrlDel(); void postMiniStep(int stp); void showBak(int ref); void initCaveValues(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index fb92f93e01..56033c9c9f 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -535,12 +535,6 @@ void CGEEngine::quit() { } } -void CGEEngine::AltCtrlDel() { - debugC(1, kCGEDebugEngine, "CGEEngine::AltCtrlDel()"); - - _snail_->addCom(kSnSay, -1, kAltCtrlDel, _hero); -} - void CGEEngine::miniStep(int stp) { debugC(1, kCGEDebugEngine, "CGEEngine::miniStep(%d)", stp); @@ -738,12 +732,6 @@ void System::touch(uint16 mask, int x, int y) { return; } switch (x) { - case Del: - if (_keyboard->_key[kKeyAlt] && _keyboard->_key[kKeyCtrl]) - _vm->AltCtrlDel(); - else - _vm->killSprite(); - break; case 'F': if (_keyboard->_key[kKeyAlt]) { Sprite *m = _vga->_showQ->locate(17001); @@ -753,45 +741,6 @@ void System::touch(uint16 mask, int x, int y) { } } break; - case PgUp: - _vm->pushSprite(); - break; - case PgDn: - _vm->pullSprite(); - break; - case '+': - _vm->nextStep(); - break; - case '`': - if (_keyboard->_key[kKeyAlt]) - _vm->saveMapping(); - else - _vm->switchMapping(); - break; - case F1: - _vm->switchDebug(); - break; - case F3: - _hero->step(kTSeq + 4); - break; - case F4: - _hero->step(kTSeq + 5); - break; - case F5: - _hero->step(kTSeq + 0); - break; - case F6: - _hero->step(kTSeq + 1); - break; - case F7: - _hero->step(kTSeq + 2); - break; - case F8: - _hero->step(kTSeq + 3); - break; - case F9: - _sys->_funDel = 1; - break; case 'X': if (_keyboard->_key[kKeyAlt]) _finis = true; @@ -805,18 +754,6 @@ void System::touch(uint16 mask, int x, int y) { _snail->addCom(kSnLevel, -1, x - '0', NULL); break; } - case '5': - case '6': - case '7': - case '8': - case '9': - if (_sprite) - _sprite->step(x - '0'); - break; - case F10 : - if (_snail->idle() && !_hero->_flags._hide) - _vm->startCountDown(); - break; } } else { if (_vm->_startupMode) @@ -876,16 +813,12 @@ void System::tick() { int n = newRandom(100); if (n > 96) _vm->heroCover(6 + (_hero->_x + _hero->_w / 2 < kScrWidth / 2)); - else { - if (n > 90) - _vm->heroCover(5); - else { - if (n > 60) - _vm->heroCover(4); - else - _vm->heroCover(3); - } - } + else if (n > 90) + _vm->heroCover(5); + else if (n > 60) + _vm->heroCover(4); + else + _vm->heroCover(3); } } funTouch(); @@ -974,103 +907,6 @@ void CGEEngine::killSprite() { _sprite = NULL; } -void CGEEngine::pushSprite() { - debugC(1, kCGEDebugEngine, "CGEEngine::pushSprite()"); - - Sprite *spr = _sprite->_prev; - if (spr) { - _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); - while (_sprite->_z > _sprite->_next->_z) - _sprite->_z--; - } else - _snail_->addCom(kSnSound, -1, 2, NULL); -} - -void CGEEngine::pullSprite() { - debugC(1, kCGEDebugEngine, "CGEEngine::pullSprite()"); - - bool ok = false; - Sprite *spr = _sprite->_next; - if (spr) { - spr = spr->_next; - if (spr) - ok = (!spr->_flags._slav); - } - if (ok) { - _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); - if (_sprite->_prev) - while (_sprite->_z < _sprite->_prev->_z) - _sprite->_z++; - } else - _snail_->addCom(kSnSound, -1, 2, NULL); -} - -void CGEEngine::nextStep() { - debugC(1, kCGEDebugEngine, "CGEEngine::nextStep()"); - - _snail_->addCom(kSnStep, 0, 0, _sprite); -} - -void CGEEngine::saveMapping() { - debugC(1, kCGEDebugEngine, "CGEEngine::saveMapping()"); - - IoHand cfTab(progName(".TAB"), kModeUpdate); - if (!cfTab._error) { - cfTab.seek((_now - 1) * sizeof(Cluster::_map)); - cfTab.write((uint8 *) Cluster::_map, sizeof(Cluster::_map)); - } - - IoHand cfHxy(progName(".HXY"), kModeWrite); - if (!cfHxy._error) { - _heroXY[_now - 1]._x = _hero->_x; - _heroXY[_now - 1]._y = _hero->_y; - cfHxy.write((uint8 *) _heroXY, sizeof(_heroXY)); - } -} - -void CGEEngine::sayDebug() { -// 1111111111222222222233333333334444444444555555555566666666667777777777 -// 01234567890123456789012345678901234567890123456789012345678901234567890123456789 - static char DebugText[] = " X=000 Y=000 S=00:00 000:000:000 000:000 00"; - - char *absX = DebugText + 3; - char *absY = DebugText + 9; - char *spN = DebugText + 15; - char *spS = DebugText + 18; - char *spX = DebugText + 21; - char *spY = DebugText + 25; - char *spZ = DebugText + 29; - char *spW = DebugText + 33; - char *spH = DebugText + 37; - char *spF = DebugText + 41; - - if (!_debugLine->_flags._hide) { - dwtom(_mouse->_x, absX, 10, 3); - dwtom(_mouse->_y, absY, 10, 3); - - // sprite queue size - uint16 n = 0; - for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) { - n++; - if (spr == _sprite) { - dwtom(n, spN, 10, 2); - dwtom(_sprite->_x, spX, 10, 3); - dwtom(_sprite->_y, spY, 10, 3); - dwtom(_sprite->_z, spZ, 10, 3); - dwtom(_sprite->_w, spW, 10, 3); - dwtom(_sprite->_h, spH, 10, 3); - dwtom(*(uint16 *)(&_sprite->_flags), spF, 16, 2); - } - } - dwtom(n, spS, 10, 2); - _debugLine->update(DebugText); - } -} - -void CGEEngine::switchDebug() { - _debugLine->_flags._hide = !_debugLine->_flags._hide; -} - void CGEEngine::optionTouch(int opt, uint16 mask) { switch (opt) { case 1: @@ -1397,8 +1233,6 @@ void CGEEngine::loadScript(const char *fname) { } void CGEEngine::mainLoop() { - sayDebug(); - if (_isDemo) { // static uint32 tc = 0; if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ _talk == NULL && _snail->idle()) { diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index 1c5f818217..ad1e4e258f 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -77,7 +77,6 @@ namespace CGE { #define kNoWay 671 #define kTooFar 681 #define kPocketFull 691 -#define kAltCtrlDel 777 #define kPanHeight 40 #define kScrWidth 320 #define kScrHeight 200 diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index 95cc92afd4..252e068d80 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -206,7 +206,7 @@ void Walk::reach(Sprite *spr, int mode) { _snail->insCom(kSnPause, -1, 64, NULL); _snail->insCom(kSnSeq, -1, kTSeq + mode, this); if (spr) { - _snail->insCom(kSnWait, -1, -1, _hero); /////--------$$$$$$$ + _snail->insCom(kSnWait, -1, -1, _hero); /////--------$$$$$$$ //SNINSERT(SNWALK, -1, -1, spr); } // sequence is not finished, -- cgit v1.2.3 From f408456d14b12152727be31fe00f61b028f18c3b Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 20 Aug 2011 16:41:10 -0400 Subject: COMMON: Add wrapper for inflating headerless zlib data --- common/zlib.cpp | 29 +++++++++++++++++++++++++++++ common/zlib.h | 9 +++++++++ 2 files changed, 38 insertions(+) diff --git a/common/zlib.cpp b/common/zlib.cpp index 86c618830e..70133fea30 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -49,6 +49,35 @@ bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long return Z_OK == ::uncompress(dst, dstLen, src, srcLen); } +bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen) { + if (!dst || !dstLen || !src || !srcLen) + return false; + + // Initialize zlib + z_stream stream; + stream.next_in = const_cast(src); + stream.avail_in = srcLen; + stream.next_out = dst; + stream.avail_out = dstLen; + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; + stream.opaque = Z_NULL; + + // Negative MAX_WBITS tells zlib there's no zlib header + int err = inflateInit2(&stream, -MAX_WBITS); + if (err != Z_OK) + return false; + + err = inflate(&stream, Z_SYNC_FLUSH); + if (err != Z_OK && err != Z_STREAM_END) { + inflateEnd(&stream); + return false; + } + + inflateEnd(&stream); + return true; +} + /** * A simple wrapper class which can be used to wrap around an arbitrary * other SeekableReadStream and will then provide on-the-fly decompression support. diff --git a/common/zlib.h b/common/zlib.h index 1925034310..7af7df0da8 100644 --- a/common/zlib.h +++ b/common/zlib.h @@ -41,6 +41,15 @@ class WriteStream; */ bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long srcLen); +/** + * Wrapper around zlib's inflate functions. This function will call the + * necessary inflate functions to uncompress data compressed with deflate + * but *not* with the standard zlib header. + * + * @return true on success (Z_OK or Z_STREAM_END), false otherwise + */ +bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen); + #endif /** -- cgit v1.2.3 From f91f0f275660cfa3362036f583619b4ef7d343fd Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 20 Aug 2011 16:42:09 -0400 Subject: AGOS: Add an archive class for handling InstallShield Cabinets --- engines/agos/installshield_cab.cpp | 201 +++++++++++++++++++++++++++++++++++++ engines/agos/installshield_cab.h | 67 +++++++++++++ engines/agos/module.mk | 1 + 3 files changed, 269 insertions(+) create mode 100644 engines/agos/installshield_cab.cpp create mode 100644 engines/agos/installshield_cab.h diff --git a/engines/agos/installshield_cab.cpp b/engines/agos/installshield_cab.cpp new file mode 100644 index 0000000000..a8b5d0fba2 --- /dev/null +++ b/engines/agos/installshield_cab.cpp @@ -0,0 +1,201 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +// The following code is based on unshield +// Original copyright: + +// Copyright (c) 2003 David Eriksson +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include "agos/installshield_cab.h" + +#include "common/debug.h" +#include "common/memstream.h" +#include "common/zlib.h" + +namespace AGOS { + +InstallShieldCabinet::InstallShieldCabinet() : Common::Archive() { + _stream = 0; +} + +InstallShieldCabinet::~InstallShieldCabinet() { + close(); +} + +bool InstallShieldCabinet::open(const Common::String &filename) { + close(); + + _stream = SearchMan.createReadStreamForMember(filename); + + if (!_stream) + return false; + + // Note that we only support a limited subset of cabinet files + // Only single cabinet files and ones without data shared between + // cabinets. + + // Check for the magic uint32 + if (_stream->readUint32LE() != 0x28635349) { + close(); + return false; + } + + uint32 version = _stream->readUint32LE(); + + if (version != 0x01000004) { + warning("Unsupported CAB version %08x", version); + close(); + return false; + } + + /* uint32 volumeInfo = */ _stream->readUint32LE(); + uint32 cabDescriptorOffset = _stream->readUint32LE(); + /* uint32 cabDescriptorSize = */ _stream->readUint32LE(); + + _stream->seek(cabDescriptorOffset); + + _stream->skip(12); + uint32 fileTableOffset = _stream->readUint32LE(); + _stream->skip(4); + uint32 fileTableSize = _stream->readUint32LE(); + uint32 fileTableSize2 = _stream->readUint32LE(); + uint32 directoryCount = _stream->readUint32LE(); + _stream->skip(8); + uint32 fileCount = _stream->readUint32LE(); + + if (fileTableSize != fileTableSize2) + warning("file table sizes do not match"); + + // We're ignoring file groups and components since we + // should not need them. Moving on to the files... + + _stream->seek(cabDescriptorOffset + fileTableOffset); + uint32 fileTableCount = directoryCount + fileCount; + uint32 *fileTableOffsets = new uint32[fileTableCount]; + for (uint32 i = 0; i < fileTableCount; i++) + fileTableOffsets[i] = _stream->readUint32LE(); + + for (uint32 i = directoryCount; i < fileCount + directoryCount; i++) { + _stream->seek(cabDescriptorOffset + fileTableOffset + fileTableOffsets[i]); + uint32 nameOffset = _stream->readUint32LE(); + /* uint32 directoryIndex = */ _stream->readUint32LE(); + + // First read in data needed by us to get at the file data + FileEntry entry; + entry.flags = _stream->readUint16LE(); + entry.uncompressedSize = _stream->readUint32LE(); + entry.compressedSize = _stream->readUint32LE(); + _stream->skip(20); + entry.offset = _stream->readUint32LE(); + + // Then let's get the string + _stream->seek(cabDescriptorOffset + fileTableOffset + nameOffset); + Common::String fileName; + + char c = _stream->readByte(); + while (c) { + fileName += c; + c = _stream->readByte(); + } + + _map[fileName] = entry; + } + + delete[] fileTableOffsets; + + return true; +} + +void InstallShieldCabinet::close() { + delete _stream; _stream = 0; + _map.clear(); +} + +bool InstallShieldCabinet::hasFile(const Common::String &name) { + return _map.contains(name); +} + +int InstallShieldCabinet::listMembers(Common::ArchiveMemberList &list) { + for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++) + list.push_back(getMember(it->_key)); + + return _map.size(); +} + +Common::ArchiveMemberPtr InstallShieldCabinet::getMember(const Common::String &name) { + return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); +} + +Common::SeekableReadStream *InstallShieldCabinet::createReadStreamForMember(const Common::String &name) const { + if (!_stream || !_map.contains(name)) + return 0; + + const FileEntry &entry = _map[name]; + + _stream->seek(entry.offset); + + if (!(entry.flags & 0x04)) { + // Not compressed + return _stream->readStream(entry.uncompressedSize); + } + +#ifdef USE_ZLIB + byte *src = (byte *)malloc(entry.compressedSize); + byte *dst = (byte *)malloc(entry.uncompressedSize); + + _stream->read(src, entry.compressedSize); + + bool result = Common::inflateZlibHeaderless(dst, entry.uncompressedSize, src, entry.compressedSize); + free(src); + + if (!result) { + warning("failed to inflate CAB file '%s'", name.c_str()); + free(dst); + return 0; + } + + return new Common::MemoryReadStream(dst, entry.uncompressedSize, DisposeAfterUse::YES); +#else + warning("zlib required to extract compressed CAB file '%s'", name.c_str()); + return 0; +#endif +} + +} // End of namespace AGOS diff --git a/engines/agos/installshield_cab.h b/engines/agos/installshield_cab.h new file mode 100644 index 0000000000..3fb8e66b03 --- /dev/null +++ b/engines/agos/installshield_cab.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/archive.h" +#include "common/scummsys.h" +#include "common/endian.h" +#include "common/file.h" +#include "common/hash-str.h" +#include "common/hashmap.h" +#include "common/str.h" + +#ifndef AGOS_INSTALLSHIELD_CAB_H +#define AGOS_INSTALLSHIELD_CAB_H + +namespace AGOS { + +class InstallShieldCabinet : public Common::Archive { +public: + InstallShieldCabinet(); + ~InstallShieldCabinet(); + + bool open(const Common::String &filename); + void close(); + bool isOpen() const { return _stream != 0; } + + // Common::Archive API implementation + bool hasFile(const Common::String &name); + int listMembers(Common::ArchiveMemberList &list); + Common::ArchiveMemberPtr getMember(const Common::String &name); + Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; + +private: + struct FileEntry { + uint32 uncompressedSize; + uint32 compressedSize; + uint32 offset; + uint16 flags; + }; + + Common::SeekableReadStream *_stream; + + typedef Common::HashMap FileMap; + FileMap _map; +}; + +} // End of namespace AGOS + +#endif diff --git a/engines/agos/module.mk b/engines/agos/module.mk index 7069d8005b..7ae5e17bf2 100644 --- a/engines/agos/module.mk +++ b/engines/agos/module.mk @@ -51,6 +51,7 @@ ifdef ENABLE_AGOS2 MODULE_OBJS += \ animation.o \ feeble.o \ + installshield_cab.o \ oracle.o \ script_dp.o \ script_ff.o \ -- cgit v1.2.3 From 62035d06bb0f7be05074921c901aa2cd61a53a39 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Aug 2011 01:28:07 +0200 Subject: CGE: Remove a useless pragma, and any code related to writing data --- engines/cge/bitmap.cpp | 1 - engines/cge/btfile.cpp | 42 ++++++-------------- engines/cge/btfile.h | 2 - engines/cge/cfile.cpp | 100 +----------------------------------------------- engines/cge/cfile.h | 6 --- engines/cge/general.cpp | 17 -------- engines/cge/general.h | 2 - engines/cge/vol.h | 4 -- 8 files changed, 14 insertions(+), 160 deletions(-) diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index f9eae101ce..50bec4ed57 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -47,7 +47,6 @@ void Bitmap::init() { void Bitmap::deinit() { } -#pragma argsused Bitmap::Bitmap(const char *fname) : _m(NULL), _v(NULL), _map(0) { debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%s)", fname); diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index a4d16010e5..449bd6aaad 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -43,27 +43,14 @@ BtFile::BtFile(const char *name, IOMode mode, Crypt *crpt) _buff[i]._page = new BtPage; _buff[i]._pgNo = kBtValNone; _buff[i]._indx = -1; - _buff[i]._updt = false; assert(_buff[i]._page != NULL); } } BtFile::~BtFile() { debugC(1, kCGEDebugFile, "BtFile::~BtFile()"); - for (int i = 0; i < kBtLevel; i++) { - putPage(i, false); + for (int i = 0; i < kBtLevel; i++) delete _buff[i]._page; - } -} - -void BtFile::putPage(int lev, bool hard) { - debugC(1, kCGEDebugFile, "BtFile::putPage(%d, %s)", lev, hard ? "true" : "false"); - - if (hard || _buff[lev]._updt) { - seek(_buff[lev]._pgNo * kBtSize); - write((uint8 *) _buff[lev]._page, kBtSize); - _buff[lev]._updt = false; - } } BtPage *BtFile::getPage(int lev, uint16 pgn) { @@ -71,26 +58,21 @@ BtPage *BtFile::getPage(int lev, uint16 pgn) { if (_buff[lev]._pgNo != pgn) { int32 pos = pgn * kBtSize; - putPage(lev, false); _buff[lev]._pgNo = pgn; - if (size() > pos) { - seek((uint32) pgn * kBtSize); + assert(size() > pos); + // In the original, there was a check verifying if the + // purpose was to write a new file. This should only be + // to create a new file, thus it was removed. + seek((uint32) pgn * kBtSize); - // Read in the page - byte buffer[kBtSize]; - int bytesRead = read(buffer, kBtSize); + // Read in the page + byte buffer[kBtSize]; + int bytesRead = read(buffer, kBtSize); - // Unpack it into the page structure - Common::MemoryReadStream stream(buffer, bytesRead, DisposeAfterUse::NO); - _buff[lev]._page->read(stream); + // Unpack it into the page structure + Common::MemoryReadStream stream(buffer, bytesRead, DisposeAfterUse::NO); + _buff[lev]._page->read(stream); - _buff[lev]._updt = false; - } else { - memset(&_buff[lev]._page, 0, kBtSize); - _buff[lev]._page->_hea._count = 0; - _buff[lev]._page->_hea._down = kBtValNone; - _buff[lev]._updt = true; - } _buff[lev]._indx = -1; } return _buff[lev]._page; diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 7cfdc263e7..1095324116 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -77,10 +77,8 @@ class BtFile : public IoHand { BtPage *_page; uint16 _pgNo; int _indx; - bool _updt; } _buff[kBtLevel]; - void putPage(int lev, bool hard); BtPage *getPage(int lev, uint16 pgn); public: BtFile(const char *name, IOMode mode, Crypt *crpt); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index c5c2c2c19c..f20ab16353 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -57,9 +57,6 @@ IoBuf::IoBuf(const char *name, IOMode mode, Crypt *crypt) IoBuf::~IoBuf() { debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()"); - - if (_mode != kModeRead) - writeBuf(); free(_buff); } @@ -71,16 +68,6 @@ void IoBuf::readBuf() { _ptr = 0; } -void IoBuf::writeBuf() { - debugC(4, kCGEDebugFile, "IoBuf::writeBuf()"); - - if (_lim) { - IoHand::write(_buff, _lim); - _bufMark = IoHand::mark(); - _lim = 0; - } -} - uint16 IoBuf::read(void *buf, uint16 len) { debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len); @@ -149,45 +136,6 @@ uint16 IoBuf::read(uint8 *buf) { return total; } -uint16 IoBuf::write(void *buf, uint16 len) { - debugC(1, kCGEDebugFile, "IoBuf::write(buf, %d)", len); - - uint16 tot = 0; - while (len) { - uint16 n = kBufferSize - _lim; - if (n > len) - n = len; - if (n) { - memcpy(_buff + _lim, buf, n); - _lim += n; - len -= n; - buf = (uint8 *)buf + n; - tot += n; - } else - writeBuf(); - } - return tot; -} - -uint16 IoBuf::write(uint8 *buf) { - debugC(1, kCGEDebugFile, "IoBuf::write(buf)"); - - uint16 len = 0; - if (buf) { - len = strlen((const char *) buf); - if (len) - if (buf[len - 1] == '\n') - --len; - len = write(buf, len); - if (len) { - static char EOL[] = "\r\n"; - uint16 n = write(EOL, sizeof(EOL) - 1); - len += n; - } - } - return len; -} - int IoBuf::read() { debugC(1, kCGEDebugFile, "IoBuf::read()"); @@ -199,14 +147,6 @@ int IoBuf::read() { return _buff[_ptr++]; } -void IoBuf::write(uint8 b) { - debugC(1, kCGEDebugFile, "IoBuf::write(%d)", b); - - if (_lim >= kBufferSize) - writeBuf(); - _buff[_lim++] = b; -} - uint16 CFile::_maxLineLen = kLineMaxSize; CFile::CFile(const char *name, IOMode mode, Crypt *crypt) @@ -217,22 +157,6 @@ CFile::CFile(const char *name, IOMode mode, Crypt *crypt) CFile::~CFile() { } -void CFile::flush() { - debugC(1, kCGEDebugFile, "CFile::flush()"); - - if (_mode != kModeRead) - writeBuf(); - else - _lim = 0; - - /* - _BX = Handle; - _AH = 0x68; // Flush buffer - asm int 0x21 - */ - warning("FIXME: CFILE::Flush"); -} - long CFile::mark() { debugC(5, kCGEDebugFile, "CFile::mark()"); @@ -243,33 +167,13 @@ long CFile::seek(long pos) { debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos); if (pos >= _bufMark && pos < _bufMark + _lim) { - ((_mode == kModeRead) ? _ptr : _lim) = (uint16)(pos - _bufMark); + _ptr = (uint16)(pos - _bufMark); return pos; } else { - if (_mode != kModeRead) - writeBuf(); - else - _lim = 0; - + _lim = 0; _ptr = 0; return _bufMark = IoHand::seek(pos); } } -void CFile::append(CFile &f) { - debugC(1, kCGEDebugFile, "CFile::append(f)"); - - seek(size()); - if (f._error == 0) { - while (true) { - if ((_lim = f.IoHand::read(_buff, kBufferSize)) == kBufferSize) - writeBuf(); - else - break; - if ((_error = f._error) != 0) - break; - } - } -} - } // End of namespace CGE diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index f5d784073b..39260d2673 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -42,7 +42,6 @@ protected: uint16 _lim; long _bufMark; virtual void readBuf(); - virtual void writeBuf(); public: IoBuf(IOMode mode, Crypt *crpt); IoBuf(const char *name, IOMode mode, Crypt *crpt); @@ -50,9 +49,6 @@ public: uint16 read(void *buf, uint16 len); uint16 read(uint8 *buf); int read(); - uint16 write(void *buf, uint16 len); - uint16 write(uint8 *buf); - void write(uint8 b); }; @@ -61,10 +57,8 @@ public: static uint16 _maxLineLen; CFile(const char *name, IOMode mode, Crypt *crpt); virtual ~CFile(); - void flush(); long mark(); long seek(long pos); - void append(CFile &f); }; } // End of namespace CGE diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 25ed7d6ff2..798749c2bf 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -233,23 +233,6 @@ uint16 IoHand::read(void *buf, uint16 len) { return bytesRead; } -uint16 IoHand::write(void *buf, uint16 len) { - warning("IOHAND::Write not supported"); - return 0; -/* - if (len) { - if (Mode == kModeRead || Handle < 0) - return 0; - if (Crypt) - Seed = Crypt(buf, len, Seed); - Error = _dos_write(Handle, buf, len, &len); - if (Crypt) - Seed = Crypt(buf, len, Seed); //------$$$$$$$ - } - return len; -*/ -} - long IoHand::mark() { return _file->pos(); } diff --git a/engines/cge/general.h b/engines/cge/general.h index 90cba269cd..75a3f3da93 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -75,7 +75,6 @@ public: XFile(IOMode mode) : _mode(mode), _error(0) { } virtual ~XFile() { } virtual uint16 read(void *buf, uint16 len) = 0; - virtual uint16 write(void *buf, uint16 len) = 0; virtual long mark() = 0; virtual long size() = 0; virtual long seek(long pos) = 0; @@ -99,7 +98,6 @@ public: virtual ~IoHand(); static bool exist(const char *name); uint16 read(void *buf, uint16 len); - uint16 write(void *buf, uint16 len); long mark(); long size(); long seek(long pos); diff --git a/engines/cge/vol.h b/engines/cge/vol.h index f9d9382eac..d85faa4f4a 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -45,9 +45,6 @@ class Dat { VOLBASE _file; public: Dat(); - - bool append(uint8 *buf, uint16 len); - bool write(CFile &f); bool read(long org, uint16 len, uint8 *buf); }; @@ -61,7 +58,6 @@ private: long _endMark; void readBuf(); - void writeBuf() { } public: VFile(const char *name, IOMode mode = kModeRead); ~VFile(); -- cgit v1.2.3 From 8de4d8c402bf8a2ae97fa4ffcd96b1c071dc8bbb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Aug 2011 01:41:03 +0200 Subject: CGE: Get rid of IOMode since it's always 'read' --- engines/cge/btfile.cpp | 6 +++--- engines/cge/btfile.h | 2 +- engines/cge/cfile.cpp | 20 ++++++++++---------- engines/cge/cfile.h | 6 +++--- engines/cge/general.cpp | 13 +++++-------- engines/cge/general.h | 10 +++------- engines/cge/vol.cpp | 26 ++++++++++++-------------- engines/cge/vol.h | 2 +- 8 files changed, 38 insertions(+), 47 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 449bd6aaad..fd49cd2b12 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -35,9 +35,9 @@ namespace CGE { -BtFile::BtFile(const char *name, IOMode mode, Crypt *crpt) - : IoHand(name, mode, crpt) { - debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode); +BtFile::BtFile(const char *name, Crypt *crpt) + : IoHand(name, crpt) { + debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, crpt)", name); for (int i = 0; i < kBtLevel; i++) { _buff[i]._page = new BtPage; diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 1095324116..19b10c3eed 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -81,7 +81,7 @@ class BtFile : public IoHand { BtPage *getPage(int lev, uint16 pgn); public: - BtFile(const char *name, IOMode mode, Crypt *crpt); + BtFile(const char *name, Crypt *crpt); virtual ~BtFile(); BtKeypack *find(const char *key); BtKeypack *next(); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index f20ab16353..652fecae9a 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -33,23 +33,23 @@ namespace CGE { -IoBuf::IoBuf(IOMode mode, Crypt *crypt) - : IoHand(mode, crypt), +IoBuf::IoBuf(Crypt *crypt) + : IoHand(crypt), _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crypt)", mode); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(crypt)"); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); assert(_buff != NULL); } -IoBuf::IoBuf(const char *name, IOMode mode, Crypt *crypt) - : IoHand(name, mode, crypt), +IoBuf::IoBuf(const char *name, Crypt *crypt) + : IoHand(name, crypt), _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crypt)", name, mode); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crypt)", name); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); assert(_buff != NULL); @@ -149,9 +149,9 @@ int IoBuf::read() { uint16 CFile::_maxLineLen = kLineMaxSize; -CFile::CFile(const char *name, IOMode mode, Crypt *crypt) - : IoBuf(name, mode, crypt) { - debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crypt)", name, mode); +CFile::CFile(const char *name, Crypt *crypt) + : IoBuf(name, crypt) { + debugC(1, kCGEDebugFile, "CFile::CFile(%s, crypt)", name); } CFile::~CFile() { @@ -160,7 +160,7 @@ CFile::~CFile() { long CFile::mark() { debugC(5, kCGEDebugFile, "CFile::mark()"); - return _bufMark + ((_mode != kModeRead) ? _lim : _ptr); + return _bufMark + _ptr; } long CFile::seek(long pos) { diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 39260d2673..f7b45d8ade 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -43,8 +43,8 @@ protected: long _bufMark; virtual void readBuf(); public: - IoBuf(IOMode mode, Crypt *crpt); - IoBuf(const char *name, IOMode mode, Crypt *crpt); + IoBuf(Crypt *crpt); + IoBuf(const char *name, Crypt *crpt); virtual ~IoBuf(); uint16 read(void *buf, uint16 len); uint16 read(uint8 *buf); @@ -55,7 +55,7 @@ public: class CFile : public IoBuf { public: static uint16 _maxLineLen; - CFile(const char *name, IOMode mode, Crypt *crpt); + CFile(const char *name, Crypt *crpt); virtual ~CFile(); long mark(); long seek(long pos); diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 798749c2bf..a3258e9415 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -202,16 +202,13 @@ char *dwtom(uint32 val, char *str, int radix, int len) { return str; } -IoHand::IoHand(IOMode mode, Crypt *crypt) - : XFile(mode), _crypt(crypt), _seed(kCryptSeed) { +IoHand::IoHand(Crypt *crypt) + : XFile(), _crypt(crypt), _seed(kCryptSeed) { _file = new Common::File(); } -IoHand::IoHand(const char *name, IOMode mode, Crypt *crypt) - : XFile(mode), _crypt(crypt), _seed(kCryptSeed) { - // TODO: Check if WRI and/or UPD modes are needed, and map to a save file - assert(mode == kModeRead); - +IoHand::IoHand(const char *name, Crypt *crypt) + : XFile(), _crypt(crypt), _seed(kCryptSeed) { _file = new Common::File(); _file->open(name); } @@ -222,7 +219,7 @@ IoHand::~IoHand() { } uint16 IoHand::read(void *buf, uint16 len) { - if (_mode == kModeWrite || !_file->isOpen()) + if (!_file->isOpen()) return 0; uint16 bytesRead = _file->read(buf, len); diff --git a/engines/cge/general.h b/engines/cge/general.h index 75a3f3da93..37f492a538 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -39,8 +39,6 @@ namespace CGE { #define kCryptSeed 0xA5 -enum IOMode { kModeRead, kModeWrite, kModeUpdate }; - struct Dac { uint8 _r; uint8 _g; @@ -68,11 +66,9 @@ T min(T A, T B) { class XFile { public: - IOMode _mode; uint16 _error; - XFile() : _mode(kModeRead), _error(0) { } - XFile(IOMode mode) : _mode(mode), _error(0) { } + XFile() : _error(0) { } virtual ~XFile() { } virtual uint16 read(void *buf, uint16 len) = 0; virtual long mark() = 0; @@ -93,8 +89,8 @@ protected: uint16 _seed; Crypt *_crypt; public: - IoHand(const char *name, IOMode mode = kModeRead, Crypt crypt = NULL); - IoHand(IOMode mode = kModeRead, Crypt *crypt = NULL); + IoHand(const char *name, Crypt crypt = NULL); + IoHand(Crypt *crypt = NULL); virtual ~IoHand(); static bool exist(const char *name); uint16 read(void *buf, uint16 len); diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 51dbe4f856..ff0a979b1d 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -40,7 +40,7 @@ VFile *VFile::_recent = NULL; /*-----------------------------------------------------------------------*/ -Dat::Dat(): _file(DAT_NAME, kModeRead, CRP) { +Dat::Dat(): _file(DAT_NAME, CRP) { debugC(1, kCGEDebugFile, "Dat::Dat()"); } @@ -50,7 +50,7 @@ void VFile::init() { debugC(1, kCGEDebugFile, "VFile::init()"); _dat = new Dat(); - _cat = new BtFile(CAT_NAME, kModeRead, CRP); + _cat = new BtFile(CAT_NAME, CRP); _recent = NULL; } @@ -59,18 +59,16 @@ void VFile::deinit() { delete _cat; } -VFile::VFile(const char *name, IOMode mode) - : IoBuf(mode, NULL) { - debugC(3, kCGEDebugFile, "VFile::VFile(%s, %d)", name, mode); - - if (mode == kModeRead) { - if (_dat->_file._error || _cat->_error) - error("Bad volume data"); - BtKeypack *kp = _cat->find(name); - if (scumm_stricmp(kp->_key, name) != 0) - _error = 1; - _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size; - } +VFile::VFile(const char *name) + : IoBuf(NULL) { + debugC(3, kCGEDebugFile, "VFile::VFile(%s)", name); + + if (_dat->_file._error || _cat->_error) + error("Bad volume data"); + BtKeypack *kp = _cat->find(name); + if (scumm_stricmp(kp->_key, name) != 0) + _error = 1; + _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size; } VFile::~VFile() { diff --git a/engines/cge/vol.h b/engines/cge/vol.h index d85faa4f4a..d7184ba064 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -59,7 +59,7 @@ private: void readBuf(); public: - VFile(const char *name, IOMode mode = kModeRead); + VFile(const char *name); ~VFile(); static void init(); -- cgit v1.2.3 From e69c7a3ac4e3a764b0ace52ea580a877eb7f72da Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Aug 2011 09:51:49 +0200 Subject: CGE: Remove mixer --- engines/cge/cge_main.cpp | 16 +---- engines/cge/mixer.cpp | 150 ----------------------------------------------- engines/cge/mixer.h | 60 ------------------- engines/cge/module.mk | 1 - 4 files changed, 3 insertions(+), 224 deletions(-) delete mode 100644 engines/cge/mixer.cpp delete mode 100644 engines/cge/mixer.h diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 56033c9c9f..759f942c29 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -46,7 +46,6 @@ #include "cge/talk.h" #include "cge/vmenu.h" #include "cge/gettext.h" -#include "cge/mixer.h" #include "cge/cge_main.h" #include "cge/cge.h" #include "cge/walk.h" @@ -257,12 +256,6 @@ Common::Error CGEEngine::saveGameState(int slot, const Common::String &desc) { void CGEEngine::saveSound() { warning("STUB: CGEEngine::saveSound"); - /* Convert to saving any such needed data in ScummVM configuration file - - CFile cfg(usrPath(progName(CFG_EXT)), WRI); - if (!cfg._error) - cfg.write(&_sndDrvInfo, sizeof(_sndDrvInfo) - sizeof(_sndDrvInfo.Vol2)); - */ } void CGEEngine::saveGame(int slotNumber, const Common::String &desc) { @@ -914,13 +907,10 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { switchColorMode(); break; case 2: - if (mask & kMouseLeftUp) { + if (mask & kMouseLeftUp) switchMusic(); - } else if (mask & kMouseRightUp) - if (!Mixer::_appear) { - Mixer::_appear = true; - new Mixer(this, kButtonX, kButtonY); - } + else if (mask & kMouseRightUp) + warning("TODO: Use ScummVM sound dialog"); break; case 3: if (mask & kMouseLeftUp) diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp deleted file mode 100644 index c483653ec2..0000000000 --- a/engines/cge/mixer.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/mixer.h" -#include "cge/text.h" -#include "cge/snail.h" -#include "cge/events.h" -#include "cge/snddrv.h" -#include "cge/cge_main.h" - -namespace CGE { - -extern Mouse *Mouse; - -bool Mixer::_appear = false; - -Mixer::Mixer(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), _fall(kMixFall), _vm(vm) { - _appear = true; - _mb[0] = new Bitmap("VOLUME"); - _mb[1] = NULL; - setShapeList(_mb); - setName(_text->getText(kMixName)); - _flags._syst = true; - _flags._kill = true; - _flags._bDel = true; - gotoxy(x, y); - _z = kMixZ; - - // slaves - - Seq ls[kMixMax]; - - for (uint i = 0; i < kMixMax; i++) { - static char fn[] = "V00"; - wtom(i, fn + 1, 10, 2); - _lb[i] = new Bitmap(fn); - ls[i]._now = ls[i]._next = i; - ls[i]._dx = ls[i]._dy = ls[i]._dly = 0; - } - _lb[kMixMax] = NULL; - - for (uint i = 0; i < ArrayCount(_led); i++) { - register Sprite *spr = new Sprite(_vm, _lb); - - Seq *seq = (Seq *)malloc(kMixMax * sizeof(Seq)); - Common::copy(ls, ls + kMixMax, seq); - spr->setSeq(seq); - - spr->gotoxy(x + 2 + 12 * i, y + 8); - spr->_flags._tran = true; - spr->_flags._kill = true; - spr->_flags._bDel = false; - spr->_z = kMixZ; - _led[i] = spr; - } - _led[ArrayCount(_led) - 1]->_flags._bDel = true; - - _vga->_showQ->insert(this); - for (uint i = 0; i < ArrayCount(_led); i++) - _vga->_showQ->insert(_led[i]); - - //--- reset balance - warning("STUB: MIXER::MIXER() reset balance of digital and midi volumes"); -/* i = (_sndDrvInfo.Vol4._ml + _sndDrvInfo.Vol4._mr) / 2; - _sndDrvInfo.Vol4._ml = i; - _sndDrvInfo.Vol4._mr = i; - i = (_sndDrvInfo.Vol4._dl + _sndDrvInfo.Vol4._dr) / 2; - _sndDrvInfo.Vol4._dl = i; - _sndDrvInfo.Vol4._dr = i; -*/ - update(); - _time = kMixDelay; -} - -Mixer::~Mixer() { - _appear = false; -} - -#pragma argsused -void Mixer::touch(uint16 mask, int x, int y) { - Sprite::touch(mask, x, y); - - if (mask & kMouseLeftUp) { - warning("STUB: Mixer::touch(): Digital Volume"); -/* uint8 *vol = (&_sndDrvInfo.Vol2._d) + (x < _w / 2); - if (y < kMixButtonHigh) { - if (*vol < 0xFF) - *vol += 0x11; - } else if (y >= _h - kMixButtonHigh) { - if (*vol > 0x00) - *vol -= 0x11; - } - update(); -*/ - } -} - -void Mixer::tick() { - int x = _mouse->_x; - int y = _mouse->_y; - if (spriteAt(x, y) == this) { - _fall = kMixFall; - if (_flags._hold) - touch(kMouseLeftUp, x - _x, y - _y); - } else { - if (_fall) { - _fall--; - } else { - for (uint i = 0; i < ArrayCount(_led); i++) - _snail_->addCom(kSnKill, -1, 0, _led[i]); - _snail_->addCom(kSnKill, -1, 0, this); - } - } - _time = kMixDelay; -} - -void Mixer::update() { - warning("STUB: Mixer::Update"); -/* - _led[0]->step(_sndDrvInfo.Vol4._ml); - _led[1]->step(_sndDrvInfo.Vol4._dl); -*/ - _snail_->addCom2(kSnExec, -1, 0, kSndSetVolume); -} - -} // End of namespace CGE diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h deleted file mode 100644 index 10c05e7cfb..0000000000 --- a/engines/cge/mixer.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_MIXER__ -#define __CGE_MIXER__ - -#include "cge/vga13h.h" - -namespace CGE { - -#define kMixMax 16 // count of Leds -#define kMixZ 64 // mixer Z position -#define kMixDelay 12 // 6/s -#define kMixFall 6 // in MIX_DELAY units -#define kMixButtonHigh 6 // mixer button high -#define kMixName 105 // sprite name - -class Mixer : public Sprite { - BitmapPtr _mb[2]; - BitmapPtr _lb[kMixMax + 1]; - Sprite *_led[2]; - int _fall; - void update(); -public: - static bool _appear; - Mixer(CGEEngine *vm, int x, int y); - ~Mixer(); - void touch(uint16 mask, int x, int y); - void tick(); -private: - CGEEngine *_vm; -}; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 3ea061419b..e71de2d9e4 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -12,7 +12,6 @@ MODULE_OBJS := \ game.o \ general.o \ gettext.o \ - mixer.o \ snail.o \ sound.o \ talk.o \ -- cgit v1.2.3 From bb591b5415bcf63f554c14d5be9d74bba9e5b6cc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Aug 2011 11:15:28 +0200 Subject: CGE: Some clean up in Vga class --- engines/cge/cge.cpp | 2 +- engines/cge/cge_main.cpp | 19 ++++++------ engines/cge/snail.cpp | 16 +++++----- engines/cge/talk.cpp | 16 +++++----- engines/cge/talk.h | 4 +-- engines/cge/vga13h.cpp | 81 ++++++++++-------------------------------------- engines/cge/vga13h.h | 81 ++++++++++-------------------------------------- engines/cge/vmenu.h | 4 +-- 8 files changed, 65 insertions(+), 158 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 936aeea75a..584512b69a 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -126,7 +126,7 @@ void CGEEngine::setup() { // Initialise engine objects _text = new Text(this, progName(), 128); - _vga = new Vga(M13H); + _vga = new Vga(); _sys = new System(this); _pocLight = new PocLight(this); for (int i = 0; i < kPocketNX; i++) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 759f942c29..e9ea9bd428 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -961,27 +961,27 @@ void Sprite::touch(uint16 mask, int x, int y) { mask |= kMouseLeftUp; } else { if (_hero->distance(this) < kDistMax) { - /// if (_flags._port) { - if (_vm->findPocket(NULL) < 0) + if (_vm->findPocket(NULL) < 0) { _vm->pocFul(); - else { + } else { _snail->addCom(kSnReach, -1, -1, this); _snail->addCom(kSnKeep, -1, -1, this); _flags._port = false; } } else { - if (_takePtr != NO_PTR) { + if (_takePtr != kNoPtr) { if (snList(kTake)[_takePtr]._com == kSnNext) _vm->offUse(); else _vm->feedSnail(this, kTake); - } else + } else { _vm->offUse(); + } } - }/// - else + } else { _vm->tooFar(); + } } } } @@ -994,8 +994,9 @@ void Sprite::touch(uint16 mask, int x, int y) { break; } } - } else + } else { _snail->addCom(kSnWalk, -1, -1, this); // Hero->FindWay(this); + } } } @@ -1018,7 +1019,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int int i, lcnt = 0; char line[kLineMax]; - mergeExt(line, fname, SPR_EXT); + mergeExt(line, fname, kSprExt); if (INI_FILE::exist(line)) { // sprite description file exist INI_FILE sprf(line); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index ef766b9a4e..756c2675aa 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -314,7 +314,7 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) { uint8 ptr = (snq == kTake) ? spr->_takePtr : spr->_nearPtr; - if (ptr == NO_PTR) + if (ptr == kNoPtr) return; Snail::Com *comtab = spr->snList(snq); @@ -340,7 +340,7 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) { Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref); if (s) { uint8 *idx = (snq == kTake) ? &s->_takePtr : &s->_nearPtr; - if (*idx != NO_PTR) { + if (*idx != kNoPtr) { int v; switch (c->_val) { case -1 : @@ -458,7 +458,7 @@ void CGEEngine::snNNext(Sprite *spr, int p) { debugC(1, kCGEDebugEngine, "CGEEngine::snNNext(spr, %d)", p); if (spr) - if (spr->_nearPtr != NO_PTR) + if (spr->_nearPtr != kNoPtr) spr->_nearPtr = p; } @@ -466,7 +466,7 @@ void CGEEngine::snTNext(Sprite *spr, int p) { debugC(1, kCGEDebugEngine, "CGEEngine::snTNext(spr, %d)", p); if (spr) - if (spr->_takePtr != NO_PTR) + if (spr->_takePtr != kNoPtr) spr->_takePtr = p; } @@ -474,7 +474,7 @@ void CGEEngine::snRNNext(Sprite *spr, int p) { debugC(1, kCGEDebugEngine, "CGEEngine::snRNNext(spr, %d)", p); if (spr) - if (spr->_nearPtr != NO_PTR) + if (spr->_nearPtr != kNoPtr) spr->_nearPtr += p; } @@ -483,7 +483,7 @@ void CGEEngine::snRTNext(Sprite *spr, int p) { debugC(1, kCGEDebugEngine, "CGEEngine::snRTNext(spr, %d)", p); if (spr) - if (spr->_takePtr != NO_PTR) + if (spr->_takePtr != kNoPtr) spr->_takePtr += p; } @@ -515,14 +515,14 @@ void CGEEngine::snRmNear(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::snRmNear(spr)"); if (spr) - spr->_nearPtr = NO_PTR; + spr->_nearPtr = kNoPtr; } void CGEEngine::snRmTake(Sprite *spr) { debugC(1, kCGEDebugEngine, "CGEEngine::snRmTake(spr)"); if (spr) - spr->_takePtr = NO_PTR; + spr->_takePtr = kNoPtr; } void CGEEngine::snSeq(Sprite *spr, int val) { diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 4bcd5cb715..812fa1d9dc 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -166,12 +166,12 @@ Bitmap *Talk::box(uint16 w, uint16 h) { if (_mode) { uint8 *p = b; uint8 *q = b + n - w; - memset(p, LGRAY, w); - memset(q, DGRAY, w); + memset(p, kVgaColLightGray, w); + memset(q, kVgaColDarkGray, w); while (p < q) { p += w; - *(p - 1) = DGRAY; - *p = LGRAY; + *(p - 1) = kVgaColDarkGray; + *p = kVgaColLightGray; } p = b; const uint16 r = (_mode == kTBRound) ? kTextRoundCorner : 0; @@ -183,10 +183,10 @@ Bitmap *Talk::box(uint16 w, uint16 h) { q[j] = kPixelTransp; q[w - j - 1] = kPixelTransp; } - p[j] = LGRAY; - p[w - j - 1] = DGRAY; - q[j] = LGRAY; - q[w - j - 1] = DGRAY; + p[j] = kVgaColLightGray; + p[w - j - 1] = kVgaColDarkGray; + q[j] = kVgaColLightGray; + q[w - j - 1] = kVgaColDarkGray; p += w; q -= w; } diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 71db57c887..9a999e5e8e 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -34,8 +34,8 @@ namespace CGE { -#define kTextColFG DARK // foreground color -#define kTextColBG GRAY // background color +#define kTextColFG kVgaColDark // foreground color +#define kTextColBG kVgaColGray // background color #define kTextHMargin (6&~1) // EVEN horizontal margins! #define kTextVMargin 5 // vertical margins #define kTextLineSpace 2 // line spacing diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index feaa005643..8213a1bcf3 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -38,25 +38,6 @@ namespace CGE { -static VgaRegBlk VideoMode[] = { - { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode - { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 - { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 - { 0x06, VGAGRA, 0x02, 0x00 }, // misc - { 0x14, VGACRT, 0x40, 0x00 }, // underline - { 0x13, VGACRT, 0xFF, 0x28 }, // screen width - { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control - { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end - { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line - { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode -// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end -// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb -// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr - { 0x00, 0x00, 0x00, 0x00 } -}; - -bool SpeedTest = false; - Seq *getConstantSeq(bool seqFlag) { const Seq seq1[] = { { 0, 0, 0, 0, 0 } }; const Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; @@ -76,15 +57,6 @@ Seq *getConstantSeq(bool seqFlag) { extern "C" void SNDMIDIPlay(); -uint16 *SaveScreen() { - // In ScummVM, we don't need to worry about saving the original screen mode - return 0; -} - -void RestoreScreen(uint16 * &sav) { - // In ScummVM, we don't need to restore the original text screen when the game exits -} - Dac mkDac(uint8 r, uint8 g, uint8 b) { static Dac x; x._r = r; @@ -100,7 +72,7 @@ Sprite *locate(int ref) { Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), - _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), + _next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; @@ -196,7 +168,7 @@ Seq *Sprite::setSeq(Seq *seq) { Seq *s = _ext->_seq; _ext->_seq = seq; - if (_seqPtr == NO_SEQ) + if (_seqPtr == kNoSeq) step(0); else if (_time == 0) step(_seqPtr); @@ -246,7 +218,9 @@ Sprite *Sprite::expand() { char line[kLineMax], fname[kPathMax]; Common::Array shplist; - for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); + for (int i = 0; i < _shpCnt + 1; ++i) + shplist.push_back(NULL); + Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -257,7 +231,7 @@ Sprite *Sprite::expand() { Snail::Com *nea = NULL; Snail::Com *tak = NULL; - mergeExt(fname, _file, SPR_EXT); + mergeExt(fname, _file, kSprExt); if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); if (!(sprf._error==0)) @@ -311,7 +285,7 @@ Sprite *Sprite::expand() { break; case 3: // Near - if (_nearPtr == NO_PTR) + if (_nearPtr == kNoPtr) break; nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); assert(nea != NULL); @@ -324,7 +298,7 @@ Sprite *Sprite::expand() { break; case 4: // Take - if (_takePtr == NO_PTR) + if (_takePtr == kNoPtr) break; tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); assert(tak != NULL); @@ -362,11 +336,11 @@ Sprite *Sprite::expand() { if (nea) nea[neacnt - 1]._ptr = _ext->_near = nea; else - _nearPtr = NO_PTR; + _nearPtr = kNoPtr; if (tak) tak[takcnt - 1]._ptr = _ext->_take = tak; else - _takePtr = NO_PTR; + _takePtr = kNoPtr; return this; } @@ -721,9 +695,8 @@ void Vga::deinit() { delete[] _sysPal; } -Vga::Vga(int mode) - : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), - _msg(NULL), _name(NULL), _setPal(false), _mono(0) { +Vga::Vga() + : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { _oldColors = NULL; _newColors = NULL; _showQ = new Queue(true); @@ -741,17 +714,11 @@ Vga::Vga(int mode) // warning(Copr); warning("TODO: Fix Copr"); - setStatAdr(); - if (_statAdr != VGAST1_) - _mono++; _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount); _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount); - _oldScreen = SaveScreen(); getColors(_oldColors); sunset(); - _oldMode = setMode(mode); setColors(); - setup(VideoMode); clear(0); } @@ -779,26 +746,12 @@ Vga::~Vga() { delete _spareQ; } -void Vga::setStatAdr() { - // No implementation needed for ScummVM -} - -#pragma argsused -void Vga::waitVR(bool on) { +void Vga::waitVR() { // Since some of the game parts rely on using vertical sync as a delay mechanism, // we're introducing a short delay to simulate it g_system->delayMillis(5); } -void Vga::setup(VgaRegBlk *vrb) { - // No direct VGA setup required, since ScummVM provides it's own graphics interface -} - -int Vga::setMode(int mode) { - // ScummVM provides it's own vieo services - return 0; -} - void Vga::getColors(Dac *tab) { byte palData[kPalSize]; g_system->getPaletteManager()->grabPalette(palData, 0, kPalCount); @@ -850,9 +803,9 @@ void Vga::setColors() { } void Vga::sunrise(Dac *tab) { - for (int i = 0; i <= 64; i += FADE_STEP) { + for (int i = 0; i <= 64; i += kFadeStep) { setColors(tab, i); - waitVR(true); + waitVR(); updateColors(); } } @@ -860,9 +813,9 @@ void Vga::sunrise(Dac *tab) { void Vga::sunset() { Dac tab[256]; getColors(tab); - for (int i = 64; i >= 0; i -= FADE_STEP) { + for (int i = 64; i >= 0; i -= kFadeStep) { setColors(tab, i); - waitVR(true); + waitVR(); updateColors(); } } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 8576752d07..9649201021 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -37,40 +37,18 @@ namespace CGE { -#define FADE_STEP 2 -#define TMR_DIV ((0x8000/TMR_RATE)*2) -#define NREP 9 -#define FREP 24 - -#define TMR_RATE1 16 -#define TMR_RATE2 4 -#define TMR_RATE (TMR_RATE1 * TMR_RATE2) - -#define MAX_NAME 20 -#define VIDEO 0x10 - -#define NO_CLEAR 0x80 -#define TEXT_MODE 0x03 -#define M13H 0x13 - -#define LIGHT 0xFF -#define DARK 207 -#define DGRAY 225 /*219*/ -#define GRAY 231 -#define LGRAY 237 -#define kPixelTransp 0xFE - -#define NO_SEQ (-1) -#define NO_PTR ((uint8)-1) - -#define SPR_EXT ".SPR" - -struct VgaRegBlk { - uint8 _idx; - uint8 _adr; - uint8 _clr; - uint8 _set; -}; +#define kFadeStep 2 +#define kVgaColDark 207 +#define kVgaColDarkGray 225 /*219*/ +#define kVgaColGray 231 +#define kVgaColLightGray 237 +#define kPixelTransp 0xFE +#define kNoSeq (-1) +#define kNoPtr ((uint8)-1) +#define kSprExt ".SPR" +#define kPalCount 256 +#define kPalSize (kPalCount * 3) + struct Seq { uint8 _now; @@ -82,21 +60,6 @@ struct Seq { extern Seq _seq1[]; extern Seq _seq2[]; -//extern SEQ * Compass[]; -//extern SEQ TurnToS[]; - -#define kPalCount 256 -#define kPalSize (kPalCount * 3) - -#define VGAATR_ 0x3C0 -#define VGASEQ_ 0x3C4 -#define VGAGRA_ 0x3CE -#define VGACRT_ 0x3D4 -#define VGAST1_ 0x3DA -#define VGAATR (VGAATR_ & 0xFF) -#define VGASEQ (VGASEQ_ & 0xFF) -#define VGAGRA (VGAGRA_ & 0xFF) -#define VGACRT (VGACRT_ & 0xFF) class SprExt { public: @@ -219,20 +182,15 @@ public: }; class Vga { - uint16 _oldMode; - uint16 *_oldScreen; - uint16 _statAdr; bool _setPal; Dac *_oldColors; Dac *_newColors; const char *_msg; const char *_name; - int setMode(int mode); void updateColors(); void setColors(); - void setStatAdr(); - void waitVR(bool on); + void waitVR(); public: uint32 _frmCnt; Queue *_showQ; @@ -241,12 +199,11 @@ public: static Graphics::Surface *_page[4]; static Dac *_sysPal; - Vga(int mode); + Vga(); ~Vga(); static void init(); static void deinit(); - void setup(VgaRegBlk *vrb); void getColors(Dac *tab); void setColors(Dac *tab, int lum); void clear(uint8 color); @@ -288,12 +245,12 @@ uint8 closest(CBLK *pal, CBLK x) { uint16 i, dif = 0xFFFF, found = 0; uint16 L = x._r + x._g + x._b; if (!L) - ++L; + L++; uint16 R = f(x._r, L), G = f(x._g, L), B = f(x._b, L); for (i = 0; i < 256; i++) { uint16 l = pal[i]._r + pal[i]._g + pal[i]._b; - if (! l) - ++l; + if (!l) + l++; int r = f(pal[i]._r, l), g = f(pal[i]._g, l), b = f(pal[i]._b, l); uint16 D = ((r > R) ? (r - R) : (R - r)) + ((g > G) ? (g - G) : (G - g)) + @@ -311,13 +268,9 @@ uint8 closest(CBLK *pal, CBLK x) { #undef f } -uint16 *saveScreen(); -void restoreScreen(uint16 * &sav); Sprite *spriteAt(int x, int y); Sprite *locate(int ref); -extern bool _speedTest; - } // End of namespace CGE #endif diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 93979b5895..0ddcfdb91d 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -34,8 +34,8 @@ namespace CGE { #define kMenuBarVM 1 #define kMenuBarHM 3 -#define kMenuBarLT LGRAY -#define kMenuBarRB DGRAY +#define kMenuBarLT kVgaColLightGray +#define kMenuBarRB kVgaColDarkGray struct Choice { -- cgit v1.2.3 From c6e89df3d940747a85d447f172e2323c800f5eaf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 22 Aug 2011 19:59:09 +0200 Subject: CGE: Fix error reported by fuzzie --- engines/cge/cfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 652fecae9a..23881cf89a 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -49,7 +49,7 @@ IoBuf::IoBuf(const char *name, Crypt *crypt) _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crypt)", name); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, crypt)", name); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); assert(_buff != NULL); -- cgit v1.2.3 From 8b388b6829885bbeb223991626f6b457115dabeb Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 22 Aug 2011 20:17:49 +0200 Subject: CGE: Fix compilation after thumbnail changes. --- engines/cge/cge_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index e9ea9bd428..0309f9f724 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -378,8 +378,8 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade while ((ch = (char)in->readByte()) != '\0') header.saveName += ch; // Get the thumbnail - header.thumbnail = new Graphics::Surface(); - if (!Graphics::loadThumbnail(*in, *header.thumbnail)) { + header.thumbnail = Graphics::loadThumbnail(*in); + if (!header.thumbnail) { delete header.thumbnail; header.thumbnail = NULL; return false; -- cgit v1.2.3 From 4ea4172cbad466738836f7be8ebdcad4eabd0bb9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 26 Aug 2011 05:51:08 +0200 Subject: SCUMM: Implement proper Indy4 Amiga palette handling. This should fix incorrect text colors in some scenes. --- engines/scumm/charset.cpp | 26 ++- engines/scumm/charset.h | 3 + engines/scumm/costume.cpp | 12 +- engines/scumm/cursor.cpp | 5 + engines/scumm/gfx.cpp | 30 ++++ engines/scumm/palette.cpp | 409 ++++++++++++++++++++++++++++++++++++--------- engines/scumm/room.cpp | 7 +- engines/scumm/saveload.cpp | 7 + engines/scumm/scumm.cpp | 6 + engines/scumm/scumm.h | 11 ++ 10 files changed, 427 insertions(+), 89 deletions(-) diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 8558da397e..f7b98e2451 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -767,6 +767,13 @@ void CharsetRendererClassic::printChar(int chr, bool ignoreCharsetMask) { _textScreenID = vs->number; } + // We need to know the virtual screen we draw on for Indy 4 Amiga, since + // it selects the palette map according to this. We furthermore can not + // use _textScreenID here, since that will cause inventory graphics + // glitches. + if (_vm->_game.platform == Common::kPlatformAmiga && _vm->_game.id == GID_INDY4) + _drawScreen = vs->number; + printCharIntern(is2byte, _charPtr, _origWidth, _origHeight, _width, _height, vs, ignoreCharsetMask); _left += _origWidth; @@ -917,12 +924,27 @@ void CharsetRendererClassic::drawBitsN(const Graphics::Surface &s, byte *dst, co numbits = 8; byte *cmap = _vm->_charsetColorMap; + // Indy4 Amiga always uses the room or verb palette map to match colors to + // the currently setup palette, thus we need to select it over here too. + // Done like the original interpreter. + byte *amigaMap = 0; + if (_vm->_game.platform == Common::kPlatformAmiga && _vm->_game.id == GID_INDY4) { + if (_drawScreen == kVerbVirtScreen) + amigaMap = _vm->_verbPalette; + else + amigaMap = _vm->_roomPalette; + } + for (y = 0; y < height && y + drawTop < s.h; y++) { for (x = 0; x < width; x++) { color = (bits >> (8 - bpp)) & 0xFF; - if (color && y + drawTop >= 0) - *dst = cmap[color]; + if (color && y + drawTop >= 0) { + if (amigaMap) + *dst = amigaMap[cmap[color]]; + else + *dst = cmap[color]; + } dst++; bits <<= bpp; numbits -= bpp; diff --git a/engines/scumm/charset.h b/engines/scumm/charset.h index b23ec996f5..fabb82b389 100644 --- a/engines/scumm/charset.h +++ b/engines/scumm/charset.h @@ -119,6 +119,9 @@ protected: int _offsX, _offsY; const byte *_charPtr; + // On which virtual screen will be drawn right now + VirtScreenNumber _drawScreen; + public: CharsetRendererClassic(ScummEngine *vm) : CharsetRendererCommon(vm) {} diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 4ca4988605..eb3cc3262c 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -545,6 +545,13 @@ void ClassicCostumeRenderer::proc3_ami(Codec1 &v1) { oldXpos = v1.x; oldScaleIndexX = _scaleIndexX; + // Indy4 Amiga always uses the room map to match colors to the currently + // setup palette in the actor code in the original, thus we need to do this + // mapping over here too. + byte *amigaMap = 0; + if (_vm->_game.platform == Common::kPlatformAmiga && _vm->_game.id == GID_INDY4) + amigaMap = _vm->_roomPalette; + do { len = *src++; color = len >> v1.shr; @@ -556,7 +563,10 @@ void ClassicCostumeRenderer::proc3_ami(Codec1 &v1) { masked = (y < 0 || y >= _out.h) || (v1.x < 0 || v1.x >= _out.w) || (v1.mask_ptr && (mask[0] & maskbit)); if (color && !masked) { - *dst = _palette[color]; + if (amigaMap) + *dst = amigaMap[_palette[color]]; + else + *dst = _palette[color]; } if (_scaleX == 255 || v1.scaletable[_scaleIndexX] < _scaleX) { diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 6739282c9d..1c79ac7a5a 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -610,6 +610,11 @@ void ScummEngine_v5::setBuiltinCursor(int idx) { WRITE_UINT16(_grabbedCursor + i * 2, 0xFF); } else { color = default_cursor_colors[idx]; + // Indy4 Amiga always uses the room or verb palette map to match colors to + // the currently setup palette, thus we need to select it over here too. + // This is guesswork! + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) + color = _roomPalette[color]; memset(_grabbedCursor, 0xFF, sizeof(_grabbedCursor)); } diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 8a32b963cd..a22aa1802f 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -1025,6 +1025,16 @@ void ScummEngine::restoreBackground(Common::Rect rect, byte backColor) { if (rect.left > vs->w) return; + // Indy4 Amiga always uses the room or verb palette map to match colors to + // the currently setup palette, thus we need to select it over here too. + // Done like the original interpreter. + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + if (vs->number == kVerbVirtScreen) + backColor = _verbPalette[backColor]; + else + backColor = _roomPalette[backColor]; + } + // Convert 'rect' to local (virtual screen) coordinates rect.top -= vs->topline; rect.bottom -= vs->topline; @@ -1235,6 +1245,16 @@ void ScummEngine::drawBox(int x, int y, int x2, int y2, int color) { if ((vs = findVirtScreen(y)) == NULL) return; + // Indy4 Amiga always uses the room or verb palette map to match colors to + // the currently setup palette, thus we need to select it over here too. + // Done like the original interpreter. + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + if (vs->number == kVerbVirtScreen) + color = _verbPalette[color]; + else + color = _roomPalette[color]; + } + if (x > x2) SWAP(x, x2); @@ -1872,6 +1892,16 @@ bool Gdi::drawStrip(byte *dstPtr, VirtScreen *vs, int x, int y, const int width, } assertRange(0, offset, smapLen-1, "screen strip"); + // Indy4 Amiga always uses the room or verb palette map to match colors to + // the currently setup palette, thus we need to select it over here too. + // Done like the original interpreter. + if (_vm->_game.platform == Common::kPlatformAmiga && _vm->_game.id == GID_INDY4) { + if (vs->number == kVerbVirtScreen) + _roomPalette = _vm->_verbPalette; + else + _roomPalette = _vm->_roomPalette; + } + return decompressBitmap(dstPtr, vs->pitch, smap_ptr + offset, height); } diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 30096000ce..930b287f00 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -372,6 +372,121 @@ void ScummEngine::setPaletteFromPtr(const byte *ptr, int numcolor) { setDirtyColors(firstIndex, numcolor - 1); } +void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) { + memcpy(_currentPalette, ptr, 768); + + for (int i = 0; i < 32; ++i) { + _shadowPalette[i] = i; + _colorUsedByCycle[i] = 0; + } + + _amigaFirstUsedColor = 80; + for (; _amigaFirstUsedColor < 256; ++_amigaFirstUsedColor) { + if (ptr[_amigaFirstUsedColor * 3 + 0] <= 251 + || ptr[_amigaFirstUsedColor * 3 + 1] <= 251 + || ptr[_amigaFirstUsedColor * 3 + 2] <= 251) + break; + } + + for (int i = 0; i < 64; ++i) { + _amigaPalette[i * 3 + 0] = _currentPalette[(i + 16) * 3 + 0] >> 4; + _amigaPalette[i * 3 + 1] = _currentPalette[(i + 16) * 3 + 1] >> 4; + _amigaPalette[i * 3 + 2] = _currentPalette[(i + 16) * 3 + 2] >> 4; + } + + for (int i = 0; i < 256; ++i) { + if (i < 16 || i >= _amigaFirstUsedColor) { + mapRoomPalette(i); + mapVerbPalette(i); + } else { + int idx = (i - 16) & 31; + if (idx != 17) { + _roomPalette[i] = idx; + _verbPalette[i] = idx + 32; + } else { + _roomPalette[i] = 0; + _verbPalette[i] = 32; + } + } + } + + setDirtyColors(0, 255); +} + +void ScummEngine::mapRoomPalette(int idx) { + if (idx >= 16 && idx < 48 && idx != 33) + _roomPalette[idx] = idx - 16; + else + _roomPalette[idx] = remapRoomPaletteColor(_currentPalette[idx * 3 + 0] >> 4, + _currentPalette[idx * 3 + 1] >> 4, + _currentPalette[idx * 3 + 2] >> 4); +} + +static const uint8 amigaWeightTable[16] = { + 0, 1, 4, 9, 16, 25, 36, 49, + 64, 81, 100, 121, 144, 169, 196, 225 +}; + +int ScummEngine::remapRoomPaletteColor(int r, int g, int b) { + int idx = 0; + uint16 minValue = 0xFFFF; + + const byte *pal = _amigaPalette; + const byte *cycle = _colorUsedByCycle; + + for (int i = 0; i < 32; ++i) { + if (!*cycle++ && i != 17) { + int rD = ABS(*pal++ - r); + int gD = ABS(*pal++ - g); + int bD = ABS(*pal++ - b); + + const uint16 weight = amigaWeightTable[rD] + amigaWeightTable[gD] + amigaWeightTable[bD]; + if (weight < minValue) { + minValue = weight; + idx = i; + } + } else { + pal += 3; + } + } + + return idx; +} + +void ScummEngine::mapVerbPalette(int idx) { + if (idx >= 48 && idx < 80 && idx != 65) + _verbPalette[idx] = idx - 16; + else + _verbPalette[idx] = remapVerbPaletteColor(_currentPalette[idx * 3 + 0] >> 4, + _currentPalette[idx * 3 + 1] >> 4, + _currentPalette[idx * 3 + 2] >> 4) + 32; +} + +int ScummEngine::remapVerbPaletteColor(int r, int g, int b) { + int idx = 0; + uint16 minValue = 0xFFFF; + + const byte *pal = _amigaPalette + 32 * 3; + + for (int i = 0; i < 32; ++i) { + if (i != 17) { + int rD = ABS(*pal++ - r); + int gD = ABS(*pal++ - g); + int bD = ABS(*pal++ - b); + + const uint16 weight = amigaWeightTable[rD] + amigaWeightTable[gD] + amigaWeightTable[bD]; + if (weight < minValue) { + minValue = weight; + idx = i; + } + } else { + pal += 3; + } + } + + return idx; +} + void ScummEngine::setDirtyColors(int min, int max) { if (_palDirtyMin > min) _palDirtyMin = min; @@ -419,11 +534,26 @@ void ScummEngine::initCycl(const byte *ptr) { cycl->start = *ptr++; cycl->end = *ptr++; + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + cycl->start = CLIP(cycl->start - 16, 0, 31); + cycl->end = CLIP(cycl->end - 16, 0, 31); + } + for (int i = cycl->start; i <= cycl->end; ++i) { _colorUsedByCycle[i] = 1; } } } + + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + for (int i = 0; i < 256; ++i) { + if (i >= 16 && i < _amigaFirstUsedColor) + continue; + + if (_colorUsedByCycle[_roomPalette[i]]) + mapRoomPalette(i); + } + } } void ScummEngine::stopCycle(int i) { @@ -432,11 +562,23 @@ void ScummEngine::stopCycle(int i) { assertRange(0, i, 16, "stopCycle: cycle"); if (i != 0) { _colorCycle[i - 1].delay = 0; + cycl = &_colorCycle[i - 1]; + for (int j = cycl->start; j <= cycl->end && j < 32; ++j) { + _shadowPalette[j] = j; + _colorUsedByCycle[j] = 0; + } return; } - for (i = 0, cycl = _colorCycle; i < 16; i++, cycl++) + for (i = 0, cycl = _colorCycle; i < 16; i++, cycl++) { cycl->delay = 0; + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + for (int j = cycl->start; j <= cycl->end && j < 32; ++j) { + _shadowPalette[j] = j; + _colorUsedByCycle[j] = 0; + } + } + } } /** @@ -512,14 +654,18 @@ void ScummEngine::cyclePalette() { setDirtyColors(cycl->start, cycl->end); moveMemInPalRes(cycl->start, cycl->end, cycl->flags & 2); - doCyclePalette(_currentPalette, cycl->start, cycl->end, 3, !(cycl->flags & 2)); + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + doCyclePalette(_shadowPalette, cycl->start, cycl->end, 1, !(cycl->flags & 2)); + } else { + doCyclePalette(_currentPalette, cycl->start, cycl->end, 3, !(cycl->flags & 2)); - if (_shadowPalette) { - if (_game.version >= 7) { - for (j = 0; j < NUM_SHADOW_PALETTE; j++) + if (_shadowPalette) { + if (_game.version >= 7) { + for (j = 0; j < NUM_SHADOW_PALETTE; j++) doCycleIndirectPalette(_shadowPalette + j * 256, cycl->start, cycl->end, !(cycl->flags & 2)); - } else { - doCycleIndirectPalette(_shadowPalette, cycl->start, cycl->end, !(cycl->flags & 2)); + } else { + doCycleIndirectPalette(_shadowPalette, cycl->start, cycl->end, !(cycl->flags & 2)); + } } } } @@ -733,62 +879,104 @@ void ScummEngine::setShadowPalette(int redScale, int greenScale, int blueScale, } void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) { - int max; - if (_game.version >= 5 && _game.version <= 6 && _game.heversion <= 60) { - max = 252; - } else { - max = 255; - } + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + startColor = CLIP(startColor, 0, 255); - if (startColor <= endColor) { - const byte *cptr; - const byte *palptr; - int color, idx, j; + //bool remappedVerbColors = false; + bool remappedRoomColors = false; + bool cycleFlag = (blueScale <= 250 && greenScale <= 250 && redScale <= 250); + + const byte *palptr = getPalettePtr(_curPalIndex, _roomResource) + startColor * 3; + + for (int i = startColor; i <= endColor; ++i) { + if (i >= 16 && i <= 48) { + if (cycleFlag) + _colorUsedByCycle[i - 16] &= ~2; + else + _colorUsedByCycle[i - 16] |= 2; + } + + _currentPalette[i * 3 + 0] = (*palptr++ * redScale) >> 8; + _currentPalette[i * 3 + 1] = (*palptr++ * greenScale) >> 8; + _currentPalette[i * 3 + 2] = (*palptr++ * blueScale) >> 8; + } + + for (int i = startColor; i <= endColor; ++i) { + if (i >= 16 && i < 48 && i != 33) { + remappedRoomColors = true; + _amigaPalette[(i - 16) * 3 + 0] = _currentPalette[i * 3 + 0] >> 4; + _amigaPalette[(i - 16) * 3 + 1] = _currentPalette[i * 3 + 1] >> 4; + _amigaPalette[(i - 16) * 3 + 2] = _currentPalette[i * 3 + 2] >> 4; + } else if (i >= 48 && i < 80 && i != 65) { + //remappedVerbColors = true; + _amigaPalette[(i - 16) * 3 + 0] = _currentPalette[i * 3 + 0] >> 4; + _amigaPalette[(i - 16) * 3 + 1] = _currentPalette[i * 3 + 1] >> 4; + _amigaPalette[(i - 16) * 3 + 2] = _currentPalette[i * 3 + 2] >> 4; + } + } + + for (int i = 0; i < 256; ++i) { + if (i >= 16 && i <= _amigaFirstUsedColor) + continue; + + bool inRange = (startColor <= i && i <= endColor); + int idx = _roomPalette[i] + 16; + bool mappedInRange = (startColor <= idx && idx <= endColor); + + if (inRange == mappedInRange || (remappedRoomColors && cycleFlag)) + mapRoomPalette(i); + } - if (_game.heversion >= 90 || _game.version == 8) { - palptr = _darkenPalette; + setDirtyColors(startColor, endColor); + } else { + int max; + if (_game.version >= 5 && _game.version <= 6 && _game.heversion <= 60) { + max = 252; } else { - palptr = getPalettePtr(_curPalIndex, _roomResource); + max = 255; } - for (j = startColor; j <= endColor; j++) { - idx = (_game.heversion == 70) ? _HEV7ActorPalette[j] : j; - cptr = palptr + idx * 3; - if (_game.heversion == 70) - setDirtyColors(idx, idx); + if (startColor <= endColor) { + const byte *cptr; + const byte *palptr; + int color, idx, j; - // Original FOA Amiga version skips these colors - // Fixes bug #1206994: "FOA AMIGA: Black cursor and text in Dig Site" - if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { - if (j < 16) { - cptr += 3; - continue; - } + if (_game.heversion >= 90 || _game.version == 8) { + palptr = _darkenPalette; + } else { + palptr = getPalettePtr(_curPalIndex, _roomResource); } - - color = *cptr++; - color = color * redScale / 0xFF; - if (color > max) - color = max; - _currentPalette[idx * 3 + 0] = color; - - color = *cptr++; - color = color * greenScale / 0xFF; - if (color > max) - color = max; - _currentPalette[idx * 3 + 1] = color; - - color = *cptr++; - color = color * blueScale / 0xFF; - if (color > max) - color = max; - _currentPalette[idx * 3 + 2] = color; - - if (_game.features & GF_16BIT_COLOR) - _16BitPalette[idx] = get16BitColor(_currentPalette[idx * 3 + 0], _currentPalette[idx * 3 + 1], _currentPalette[idx * 3 + 2]); + for (j = startColor; j <= endColor; j++) { + idx = (_game.heversion == 70) ? _HEV7ActorPalette[j] : j; + cptr = palptr + idx * 3; + + if (_game.heversion == 70) + setDirtyColors(idx, idx); + + color = *cptr++; + color = color * redScale / 0xFF; + if (color > max) + color = max; + _currentPalette[idx * 3 + 0] = color; + + color = *cptr++; + color = color * greenScale / 0xFF; + if (color > max) + color = max; + _currentPalette[idx * 3 + 1] = color; + + color = *cptr++; + color = color * blueScale / 0xFF; + if (color > max) + color = max; + _currentPalette[idx * 3 + 2] = color; + + if (_game.features & GF_16BIT_COLOR) + _16BitPalette[idx] = get16BitColor(_currentPalette[idx * 3 + 0], _currentPalette[idx * 3 + 1], _currentPalette[idx * 3 + 2]); + } + if (_game.heversion != 70) + setDirtyColors(startColor, endColor); } - if (_game.heversion != 70) - setDirtyColors(startColor, endColor); } } @@ -1007,6 +1195,37 @@ void ScummEngine::setPalColor(int idx, int r, int g, int b) { _darkenPalette[idx * 3 + 2] = b; } + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + if (idx < 16 || idx > _amigaFirstUsedColor) { + mapRoomPalette(idx); + mapVerbPalette(idx); + } else if (idx >= 16 && idx < 48 && idx != 33) { + _amigaPalette[(idx - 16) * 3 + 0] = _currentPalette[idx * 3 + 0] >> 4; + _amigaPalette[(idx - 16) * 3 + 1] = _currentPalette[idx * 3 + 1] >> 4; + _amigaPalette[(idx - 16) * 3 + 2] = _currentPalette[idx * 3 + 2] >> 4; + + for (int i = 0; i < 256; ++i) { + if (i >= 16 && i <= _amigaFirstUsedColor) + continue; + + if (idx - 16 == _roomPalette[i]) + mapRoomPalette(i); + } + } else if (idx >= 48 && idx < 80 && idx != 65) { + _amigaPalette[(idx - 16) * 3 + 0] = _currentPalette[idx * 3 + 0] >> 4; + _amigaPalette[(idx - 16) * 3 + 1] = _currentPalette[idx * 3 + 1] >> 4; + _amigaPalette[(idx - 16) * 3 + 2] = _currentPalette[idx * 3 + 2] >> 4; + + for (int i = 0; i < 256; ++i) { + if (i >= 16 && i <= _amigaFirstUsedColor) + continue; + + if (idx - 16 == _verbPalette[i]) + mapVerbPalette(i); + } + } + } + if (_game.features & GF_16BIT_COLOR) _16BitPalette[idx] = get16BitColor(r, g, b); @@ -1026,6 +1245,8 @@ void ScummEngine::setCurrentPalette(int palindex) { towns_setPaletteFromPtr(pals); #endif #endif + } else if (_game.id == GID_INDY4 && _game.platform == Common::kPlatformAmiga) { + setAmigaPaletteFromPtr(pals); } else { setPaletteFromPtr(pals); } @@ -1081,42 +1302,64 @@ void ScummEngine::updatePalette() { if (_palDirtyMax == -1) return; - bool noir_mode = (_game.id == GID_SAMNMAX && readVar(0x8000)); - int first = _palDirtyMin; - int num = _palDirtyMax - first + 1; - int i; - byte palette_colors[3 * 256]; byte *p = palette_colors; + int first; + int num; - for (i = _palDirtyMin; i <= _palDirtyMax; i++) { - byte *data; + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + // Indy4 Amiga has a special palette handling scheme + first = 0; + num = 64; - if (_game.features & GF_SMALL_HEADER && _game.version > 2) - data = _currentPalette + _shadowPalette[i] * 3; - else - data = _currentPalette + i * 3; + for (int i = 0; i < 64; ++i) { + byte *data; - // Sam & Max film noir mode. Convert the colors to grayscale - // before uploading them to the backend. + if (i < 32) + data = _amigaPalette + _shadowPalette[i] * 3; + else + data = _amigaPalette + i * 3; - if (noir_mode) { - int r, g, b; - byte brightness; + *p++ = data[0] * 255 / 15; + *p++ = data[1] * 255 / 15; + *p++ = data[2] * 255 / 15; + } + } else { + bool noir_mode = (_game.id == GID_SAMNMAX && readVar(0x8000)); + int i; - r = data[0]; - g = data[1]; - b = data[2]; + first = _palDirtyMin; + num = _palDirtyMax - first + 1; - brightness = (byte)((0.299 * r + 0.587 * g + 0.114 * b) + 0.5); + for (i = _palDirtyMin; i <= _palDirtyMax; i++) { + byte *data; - *p++ = brightness; - *p++ = brightness; - *p++ = brightness; - } else { - *p++ = data[0]; - *p++ = data[1]; - *p++ = data[2]; + if (_game.features & GF_SMALL_HEADER && _game.version > 2) + data = _currentPalette + _shadowPalette[i] * 3; + else + data = _currentPalette + i * 3; + + // Sam & Max film noir mode. Convert the colors to grayscale + // before uploading them to the backend. + + if (noir_mode) { + int r, g, b; + byte brightness; + + r = data[0]; + g = data[1]; + b = data[2]; + + brightness = (byte)((0.299 * r + 0.587 * g + 0.114 * b) + 0.5); + + *p++ = brightness; + *p++ = brightness; + *p++ = brightness; + } else { + *p++ = data[0]; + *p++ = data[1]; + *p++ = data[2]; + } } } @@ -1127,7 +1370,7 @@ void ScummEngine::updatePalette() { #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE if (_game.platform == Common::kPlatformFMTowns) { p = palette_colors; - for (i = first; i < first + num; ++i) { + for (int i = first; i < first + num; ++i) { _16BitPalette[i] = get16BitColor(p[0], p[1], p[2]); p += 3; } diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp index 8962a0e971..63cbef8944 100644 --- a/engines/scumm/room.cpp +++ b/engines/scumm/room.cpp @@ -552,6 +552,10 @@ void ScummEngine::resetRoomSubBlocks() { } } + // We need to setup the current palette before initCycl for Indy4 Amiga. + if (_PALS_offs || _CLUT_offs) + setCurrentPalette(0); + // Color cycling // HE 7.0 games load resources but don't use them. if (_game.version >= 4 && _game.heversion <= 62) { @@ -570,9 +574,6 @@ void ScummEngine::resetRoomSubBlocks() { } } #endif - - if (_PALS_offs || _CLUT_offs) - setCurrentPalette(0); } diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index 870ec8cdf7..27fa7bc27b 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -1348,6 +1348,13 @@ void ScummEngine::saveOrLoad(Serializer *s) { memset(_colorUsedByCycle, 0, sizeof(_colorUsedByCycle)); } + // We need to restore the internal state of the Amiga palette for Indy4 + // Amiga. + // TODO: We should rather store the state in the savefile and only do this + // for old savegames. + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) + setAmigaPaletteFromPtr(_currentPalette); + // // Save/load more global object state // diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 3b83019275..81f6af453c 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -290,6 +290,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) #endif _shadowPalette = NULL; _shadowPaletteSize = 0; + _verbPalette = NULL; memset(_currentPalette, 0, sizeof(_currentPalette)); memset(_darkenPalette, 0, sizeof(_darkenPalette)); memset(_HEV7ActorPalette, 0, sizeof(_HEV7ActorPalette)); @@ -610,6 +611,7 @@ ScummEngine::~ScummEngine() { _textSurface.free(); free(_shadowPalette); + free(_verbPalette); free(_palManipPalette); free(_palManipIntermediatePal); @@ -1408,6 +1410,10 @@ void ScummEngine::resetScumm() { _16BitPalette = (uint16 *)calloc(512, sizeof(uint16)); #endif + // Indy4 Amiga needs another palette map for the verb area. + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4 && !_verbPalette) + _verbPalette = (uint8 *)calloc(256, 1); + #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE if (_game.platform == Common::kPlatformFMTowns) { delete _townsScreen; diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 04a175e732..8ffa893f33 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -970,6 +970,7 @@ protected: void setCurrentPalette(int pal); void setRoomPalette(int pal, int room); void setPCEPaletteFromPtr(const byte *ptr); + void setAmigaPaletteFromPtr(const byte *ptr); virtual void setPaletteFromPtr(const byte *ptr, int numcolor = -1); virtual void setPalColor(int index, int r, int g, int b); @@ -1065,6 +1066,9 @@ public: uint16 _hePaletteSlot; uint16 *_16BitPalette; + // Indy4 Amiga specific + byte *_verbPalette; + protected: int _shadowPaletteSize; byte _currentPalette[3 * 256]; @@ -1085,6 +1089,13 @@ protected: bool _enable_gs; bool _copyProtection; + uint16 _amigaFirstUsedColor; + byte _amigaPalette[3 * 64]; + void mapRoomPalette(int idx); + int remapRoomPaletteColor(int r, int g, int b); + void mapVerbPalette(int idx); + int remapVerbPaletteColor(int r, int g, int b); + public: uint16 _extraBoxFlags[65]; -- cgit v1.2.3 From 618d01c41c9e8507408b117dfa63750975fec68b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 26 Aug 2011 06:34:59 +0200 Subject: SCUMM: Fix some range checks in Indy4 Amiga palette code. --- engines/scumm/palette.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 930b287f00..c00a117751 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -889,7 +889,7 @@ void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int const byte *palptr = getPalettePtr(_curPalIndex, _roomResource) + startColor * 3; for (int i = startColor; i <= endColor; ++i) { - if (i >= 16 && i <= 48) { + if (i >= 16 && i < 48) { if (cycleFlag) _colorUsedByCycle[i - 16] &= ~2; else @@ -916,7 +916,7 @@ void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int } for (int i = 0; i < 256; ++i) { - if (i >= 16 && i <= _amigaFirstUsedColor) + if (i >= 16 && i < _amigaFirstUsedColor) continue; bool inRange = (startColor <= i && i <= endColor); @@ -1196,7 +1196,7 @@ void ScummEngine::setPalColor(int idx, int r, int g, int b) { } if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { - if (idx < 16 || idx > _amigaFirstUsedColor) { + if (idx < 16 || idx >= _amigaFirstUsedColor) { mapRoomPalette(idx); mapVerbPalette(idx); } else if (idx >= 16 && idx < 48 && idx != 33) { @@ -1205,7 +1205,7 @@ void ScummEngine::setPalColor(int idx, int r, int g, int b) { _amigaPalette[(idx - 16) * 3 + 2] = _currentPalette[idx * 3 + 2] >> 4; for (int i = 0; i < 256; ++i) { - if (i >= 16 && i <= _amigaFirstUsedColor) + if (i >= 16 && i < _amigaFirstUsedColor) continue; if (idx - 16 == _roomPalette[i]) @@ -1217,7 +1217,7 @@ void ScummEngine::setPalColor(int idx, int r, int g, int b) { _amigaPalette[(idx - 16) * 3 + 2] = _currentPalette[idx * 3 + 2] >> 4; for (int i = 0; i < 256; ++i) { - if (i >= 16 && i <= _amigaFirstUsedColor) + if (i >= 16 && i < _amigaFirstUsedColor) continue; if (idx - 16 == _verbPalette[i]) -- cgit v1.2.3 From cef09b345b73042a6459f6e7e21b3adc7ca875b2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 26 Aug 2011 06:49:00 +0200 Subject: SCUMM: Fix bug in Indy4 Amiga's implementation of darkenPalette. --- engines/scumm/palette.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index c00a117751..216708f098 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -884,7 +884,7 @@ void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int //bool remappedVerbColors = false; bool remappedRoomColors = false; - bool cycleFlag = (blueScale <= 250 && greenScale <= 250 && redScale <= 250); + bool cycleFlag = (blueScale >= 250 && greenScale >= 250 && redScale >= 250); const byte *palptr = getPalettePtr(_curPalIndex, _roomResource) + startColor * 3; @@ -923,7 +923,7 @@ void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int int idx = _roomPalette[i] + 16; bool mappedInRange = (startColor <= idx && idx <= endColor); - if (inRange == mappedInRange || (remappedRoomColors && cycleFlag)) + if (inRange != mappedInRange || (remappedRoomColors && cycleFlag)) mapRoomPalette(i); } -- cgit v1.2.3 From e791f904ed1e3090ca176f8b42e784602d18df08 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 26 Aug 2011 18:27:21 +0200 Subject: SCUMM: Fix Indy4 Amiga cursor. The original did not use the room nor verb palette map for the cursor, but seems to use a custom palette. I now just changed the cursor to use the colors from the DOS version of Indy4. This is rather guesswork, but the original did always show a flashing color in those colors instead of based on the screen colors. --- engines/scumm/cursor.cpp | 16 ++++++++++------ engines/scumm/palette.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 1c79ac7a5a..36f06a4889 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -609,12 +609,16 @@ void ScummEngine_v5::setBuiltinCursor(int idx) { for (i = 0; i < 1024; i++) WRITE_UINT16(_grabbedCursor + i * 2, 0xFF); } else { - color = default_cursor_colors[idx]; - // Indy4 Amiga always uses the room or verb palette map to match colors to - // the currently setup palette, thus we need to select it over here too. - // This is guesswork! - if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) - color = _roomPalette[color]; + // Indy4 Amiga uses its own color set for the cursor image. + // This is patchwork code to make the cursor flash in correct colors. + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + static const uint8 indy4AmigaColors[4] = { + 252, 252, 253, 254 + }; + color = indy4AmigaColors[idx]; + } else { + color = default_cursor_colors[idx]; + } memset(_grabbedCursor, 0xFF, sizeof(_grabbedCursor)); } diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 216708f098..75db90842d 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -1324,6 +1324,16 @@ void ScummEngine::updatePalette() { *p++ = data[1] * 255 / 15; *p++ = data[2] * 255 / 15; } + + // Setup colors for the mouse cursor + // Color values taken from Indy4 DOS + static const uint8 mouseCursorPalette[] = { + 255, 255, 255, + 171, 171, 171, + 87, 87, 87 + }; + + _system->getPaletteManager()->setPalette(mouseCursorPalette, 252, 3); } else { bool noir_mode = (_game.id == GID_SAMNMAX && readVar(0x8000)); int i; -- cgit v1.2.3 From b4a17c702db5ff0af20ee72dca677c6eeccd4621 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 26 Aug 2011 18:35:13 +0200 Subject: SCUMM: Add some comments to our Indy4 Amiga verb palette handling. We handle the verb palette map a bit different, since we use one 64 color palette instead of two 32 color palettes for different screen areas. --- engines/scumm/palette.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 75db90842d..4d53b2ec74 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -400,6 +400,10 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) { mapVerbPalette(i); } else { int idx = (i - 16) & 31; + // We adjust our verb palette map from [0, 31] to [32, 63], since unlike + // the original we set up the verb palette at colors [32, 63]. + // The original instead used two different palettes for the verb virtual + // screen and all the rest. if (idx != 17) { _roomPalette[i] = idx; _verbPalette[i] = idx + 32; @@ -454,6 +458,10 @@ int ScummEngine::remapRoomPaletteColor(int r, int g, int b) { } void ScummEngine::mapVerbPalette(int idx) { + // We adjust our verb palette map from [0, 31] to [32, 63], since unlike + // the original we set up the verb palette at colors [32, 63]. + // The original instead used two different palettes for the verb virtual + // screen and all the rest. if (idx >= 48 && idx < 80 && idx != 65) _verbPalette[idx] = idx - 16; else @@ -1220,6 +1228,8 @@ void ScummEngine::setPalColor(int idx, int r, int g, int b) { if (i >= 16 && i < _amigaFirstUsedColor) continue; + // We do - 16 instead of - 48 like the original, since our + // verb palette map is using [32, 63] instead of [0, 31]. if (idx - 16 == _verbPalette[i]) mapVerbPalette(i); } -- cgit v1.2.3 From ffc09f86478a413ab92d49be327f7f84814ab268 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 26 Aug 2011 18:36:44 +0200 Subject: SCUMM: Mark some more ScummEngine members Indy4 Amiga specific. --- engines/scumm/scumm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 8ffa893f33..0af8264a58 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -1089,6 +1089,7 @@ protected: bool _enable_gs; bool _copyProtection; + // Indy4 Amiga specific uint16 _amigaFirstUsedColor; byte _amigaPalette[3 * 64]; void mapRoomPalette(int idx); -- cgit v1.2.3 From f77fc07b6b1e0137cf5ef46c8530ec8b696eefe3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 26 Aug 2011 18:43:28 +0200 Subject: SCUMM: Save Indy4 Amiga specific palettes like the original did. For older saves I added a warning and a fallback which tries to setup everything correctly. This might cause some issues, but should hopefully be just fine. --- engines/scumm/saveload.cpp | 22 ++++++++++++++++------ engines/scumm/saveload.h | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index 27fa7bc27b..e0eba99cce 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -1322,6 +1322,9 @@ void ScummEngine::saveOrLoad(Serializer *s) { if (_shadowPaletteSize) { s->saveLoadArrayOf(_shadowPalette, _shadowPaletteSize, 1, sleByte); // _roomPalette didn't show up until V21 save games + // Note that we also save the room palette for Indy4 Amiga, since it + // is used as palette map there too, but we do so slightly a bit + // further down to group it with the other special palettes needed. if (s->getVersion() >= VER(21) && _game.version < 5) s->saveLoadArrayOf(_roomPalette, sizeof(_roomPalette), 1, sleByte); } @@ -1348,12 +1351,19 @@ void ScummEngine::saveOrLoad(Serializer *s) { memset(_colorUsedByCycle, 0, sizeof(_colorUsedByCycle)); } - // We need to restore the internal state of the Amiga palette for Indy4 - // Amiga. - // TODO: We should rather store the state in the savefile and only do this - // for old savegames. - if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) - setAmigaPaletteFromPtr(_currentPalette); + // Indy4 Amiga specific palette tables were not saved before V85 + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + if (s->getVersion() >= 85) { + s->saveLoadArrayOf(_roomPalette, 256, 1, sleByte); + s->saveLoadArrayOf(_verbPalette, 256, 1, sleByte); + s->saveLoadArrayOf(_amigaPalette, 3 * 64, 1, sleByte); + } else { + warning("Save with old Indiana Jones 4 Amiga palette handling detected"); + // We need to restore the internal state of the Amiga palette for Indy4 + // Amiga. This might lead to graphics glitches! + setAmigaPaletteFromPtr(_currentPalette); + } + } // // Save/load more global object state diff --git a/engines/scumm/saveload.h b/engines/scumm/saveload.h index 776f40e12b..792a31d067 100644 --- a/engines/scumm/saveload.h +++ b/engines/scumm/saveload.h @@ -47,7 +47,7 @@ namespace Scumm { * only saves/loads those which are valid for the version of the savegame * which is being loaded/saved currently. */ -#define CURRENT_VER 84 +#define CURRENT_VER 85 /** * An auxillary macro, used to specify savegame versions. We use this instead -- cgit v1.2.3 From bb2f63d285c705f592adb06720776cf51d108af8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 26 Aug 2011 23:32:05 +0200 Subject: CGE: Remove useless function --- engines/cge/btfile.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index fd49cd2b12..ca02e1e43d 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -109,10 +109,6 @@ BtKeypack *BtFile::find(const char *key) { return NULL; } -int keycomp(const void *k1, const void *k2) { - return scumm_strnicmp((const char *) k1, (const char*) k2, kBtKeySize); -} - void BtPage::read(Common::ReadStream &s) { _hea._count = s.readUint16LE(); _hea._down = s.readUint16LE(); -- cgit v1.2.3 From 71440760307dfb99e6194929fb0c8d3bf1a0df10 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 09:05:32 +0200 Subject: CGE: Move IO classes to a separated source file --- engines/cge/bitmap.cpp | 7 +- engines/cge/bitmap.h | 3 +- engines/cge/btfile.cpp | 132 --------------- engines/cge/btfile.h | 92 ---------- engines/cge/cfile.cpp | 179 -------------------- engines/cge/cfile.h | 66 -------- engines/cge/cge.cpp | 1 - engines/cge/cge_main.cpp | 18 +- engines/cge/cge_main.h | 2 +- engines/cge/fileio.cpp | 427 +++++++++++++++++++++++++++++++++++++++++++++++ engines/cge/fileio.h | 180 ++++++++++++++++++++ engines/cge/general.cpp | 77 --------- engines/cge/general.h | 40 ----- engines/cge/jbw.h | 5 - engines/cge/module.mk | 4 +- engines/cge/sound.cpp | 10 +- engines/cge/sound.h | 2 +- engines/cge/talk.cpp | 4 +- engines/cge/text.cpp | 7 +- engines/cge/vga13h.cpp | 5 +- engines/cge/vol.cpp | 120 ------------- engines/cge/vol.h | 77 --------- 22 files changed, 633 insertions(+), 825 deletions(-) delete mode 100644 engines/cge/btfile.cpp delete mode 100644 engines/cge/btfile.h delete mode 100644 engines/cge/cfile.cpp delete mode 100644 engines/cge/cfile.h create mode 100644 engines/cge/fileio.cpp create mode 100644 engines/cge/fileio.h delete mode 100644 engines/cge/vol.cpp delete mode 100644 engines/cge/vol.h diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 50bec4ed57..02265f09bc 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -26,10 +26,7 @@ */ #include "cge/bitmap.h" -#include "cge/cfile.h" #include "cge/jbw.h" -#include "cge/vol.h" -#include "cge/cfile.h" #include "cge/vga13h.h" #include "cge/cge_main.h" #include "common/system.h" @@ -53,8 +50,8 @@ Bitmap::Bitmap(const char *fname) : _m(NULL), _v(NULL), _map(0) { char pat[kMaxPath]; forceExt(pat, fname, ".VBM"); - if (PIC_FILE::exist(pat)) { - PIC_FILE file(pat); + if (VFile::exist(pat)) { + VFile file(pat); if ((file._error == 0) && (!loadVBM(&file))) error("Bad VBM [%s]", fname); } else { diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 7604cb8081..8896d13bb4 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -28,7 +28,8 @@ #ifndef __CGE_BITMAP__ #define __CGE_BITMAP__ -#include "cge/general.h" +#include "cge/fileio.h" +//#include "cge/general.h" namespace CGE { diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp deleted file mode 100644 index ca02e1e43d..0000000000 --- a/engines/cge/btfile.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/btfile.h" -#include "common/system.h" -#include "common/str.h" -#include "cge/cge.h" -#include "common/debug.h" -#include "common/debug-channels.h" -#include "common/memstream.h" - -namespace CGE { - -BtFile::BtFile(const char *name, Crypt *crpt) - : IoHand(name, crpt) { - debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, crpt)", name); - - for (int i = 0; i < kBtLevel; i++) { - _buff[i]._page = new BtPage; - _buff[i]._pgNo = kBtValNone; - _buff[i]._indx = -1; - assert(_buff[i]._page != NULL); - } -} - -BtFile::~BtFile() { - debugC(1, kCGEDebugFile, "BtFile::~BtFile()"); - for (int i = 0; i < kBtLevel; i++) - delete _buff[i]._page; -} - -BtPage *BtFile::getPage(int lev, uint16 pgn) { - debugC(1, kCGEDebugFile, "BtFile::getPage(%d, %d)", lev, pgn); - - if (_buff[lev]._pgNo != pgn) { - int32 pos = pgn * kBtSize; - _buff[lev]._pgNo = pgn; - assert(size() > pos); - // In the original, there was a check verifying if the - // purpose was to write a new file. This should only be - // to create a new file, thus it was removed. - seek((uint32) pgn * kBtSize); - - // Read in the page - byte buffer[kBtSize]; - int bytesRead = read(buffer, kBtSize); - - // Unpack it into the page structure - Common::MemoryReadStream stream(buffer, bytesRead, DisposeAfterUse::NO); - _buff[lev]._page->read(stream); - - _buff[lev]._indx = -1; - } - return _buff[lev]._page; -} - -BtKeypack *BtFile::find(const char *key) { - debugC(1, kCGEDebugFile, "BtFile::find(%s)", key); - - int lev = 0; - uint16 nxt = kBtValRoot; - while (!_error) { - BtPage *pg = getPage(lev, nxt); - // search - if (pg->_hea._down != kBtValNone) { - int i; - for (i = 0; i < pg->_hea._count; i++) { - // Does this work, or does it have to compare the entire buffer? - if (scumm_strnicmp((const char *)key, (const char*)pg->_inn[i]._key, kBtKeySize) < 0) - break; - } - nxt = (i) ? pg->_inn[i - 1]._down : pg->_hea._down; - _buff[lev]._indx = i - 1; - lev++; - } else { - int i; - for (i = 0; i < pg->_hea._count - 1; i++) { - if (scumm_stricmp((const char *)key, (const char *)pg->_lea[i]._key) <= 0) - break; - } - _buff[lev]._indx = i; - return &pg->_lea[i]; - } - } - return NULL; -} - -void BtPage::read(Common::ReadStream &s) { - _hea._count = s.readUint16LE(); - _hea._down = s.readUint16LE(); - - if (_hea._down == kBtValNone) { - // Leaf list - for (int i = 0; i < kBtLeafCount; ++i) { - s.read(_lea[i]._key, kBtKeySize); - _lea[i]._mark = s.readUint32LE(); - _lea[i]._size = s.readUint16LE(); - } - } else { - // Root index - for (int i = 0; i < kBtInnerCount; ++i) { - s.read(_inn[i]._key, kBtKeySize); - _inn[i]._down = s.readUint16LE(); - } - } -} - -} // End of namespace CGE diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h deleted file mode 100644 index 19b10c3eed..0000000000 --- a/engines/cge/btfile.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_BTFILE__ -#define __CGE_BTFILE__ - -#include "cge/general.h" -#include "common/stream.h" - -namespace CGE { - -#define kBtSize 1024 -#define kBtKeySize 13 -#define kBtLevel 2 -#define kBtInnerCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 2 /*sizeof(Inner) */)) -#define kBtLeafCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 4 + 2 /*sizeof(BtKeypack) */)) - -#define kBtValNone 0xFFFF -#define kBtValRoot 0 - -struct BtKeypack { - char _key[kBtKeySize]; - uint32 _mark; - uint16 _size; -}; - -struct Inner { - uint8 _key[kBtKeySize]; - uint16 _down; -}; - -struct Hea { - uint16 _count; - uint16 _down; -}; - -struct BtPage { - Hea _hea; - union { - // dummy filler to make proper size of union - uint8 _data[kBtSize - 4 /*sizeof(Hea) */]; - // inner version of data: key + word-sized page link - Inner _inn[kBtInnerCount]; - // leaf version of data: key + all user data - BtKeypack _lea[kBtLeafCount]; - }; - - void read(Common::ReadStream &s); -}; - -class BtFile : public IoHand { - struct { - BtPage *_page; - uint16 _pgNo; - int _indx; - } _buff[kBtLevel]; - - BtPage *getPage(int lev, uint16 pgn); -public: - BtFile(const char *name, Crypt *crpt); - virtual ~BtFile(); - BtKeypack *find(const char *key); - BtKeypack *next(); -}; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp deleted file mode 100644 index 23881cf89a..0000000000 --- a/engines/cge/cfile.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/cfile.h" -#include "common/system.h" -#include "cge/cge.h" -#include "common/debug.h" -#include "common/debug-channels.h" - -namespace CGE { - -IoBuf::IoBuf(Crypt *crypt) - : IoHand(crypt), - _bufMark(0), - _ptr(0), - _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(crypt)"); - - _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); - assert(_buff != NULL); -} - -IoBuf::IoBuf(const char *name, Crypt *crypt) - : IoHand(name, crypt), - _bufMark(0), - _ptr(0), - _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, crypt)", name); - - _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); - assert(_buff != NULL); -} - -IoBuf::~IoBuf() { - debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()"); - free(_buff); -} - -void IoBuf::readBuf() { - debugC(4, kCGEDebugFile, "IoBuf::readBuf()"); - - _bufMark = IoHand::mark(); - _lim = IoHand::read(_buff, kBufferSize); - _ptr = 0; -} - -uint16 IoBuf::read(void *buf, uint16 len) { - debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len); - - uint16 total = 0; - while (len) { - if (_ptr >= _lim) - readBuf(); - uint16 n = _lim - _ptr; - if (n) { - if (len < n) - n = len; - memcpy(buf, _buff + _ptr, n); - buf = (uint8 *)buf + n; - len -= n; - total += n; - _ptr += n; - } else - break; - } - return total; -} - -uint16 IoBuf::read(uint8 *buf) { - debugC(3, kCGEDebugFile, "IoBuf::read(buf)"); - - uint16 total = 0; - - while (total < kLineMaxSize - 2) { - if (_ptr >= _lim) - readBuf(); - uint8 *p = _buff + _ptr; - uint16 n = _lim - _ptr; - if (n) { - if (total + n >= kLineMaxSize - 2) - n = kLineMaxSize - 2 - total; - uint8 *eol = (uint8 *) memchr(p, '\r', n); - if (eol) - n = (uint16)(eol - p); - uint8 *eof = (uint8 *) memchr(p, '\32', n); - if (eof) { // end-of-file - n = (uint16)(eof - p); - _ptr = (uint16)(eof - _buff); - } - if (n) - memcpy(buf, p, n); - buf += n; - total += n; - if (eof) - break; - _ptr += n; - if (eol) { - _ptr++; - *(buf++) = '\n'; - total++; - if (_ptr >= _lim) - readBuf(); - if (_ptr < _lim) - if (_buff[_ptr] == '\n') - ++_ptr; - break; - } - } else - break; - } - *buf = '\0'; - return total; -} - -int IoBuf::read() { - debugC(1, kCGEDebugFile, "IoBuf::read()"); - - if (_ptr >= _lim) { - readBuf(); - if (_lim == 0) - return -1; - } - return _buff[_ptr++]; -} - -uint16 CFile::_maxLineLen = kLineMaxSize; - -CFile::CFile(const char *name, Crypt *crypt) - : IoBuf(name, crypt) { - debugC(1, kCGEDebugFile, "CFile::CFile(%s, crypt)", name); -} - -CFile::~CFile() { -} - -long CFile::mark() { - debugC(5, kCGEDebugFile, "CFile::mark()"); - - return _bufMark + _ptr; -} - -long CFile::seek(long pos) { - debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos); - - if (pos >= _bufMark && pos < _bufMark + _lim) { - _ptr = (uint16)(pos - _bufMark); - return pos; - } else { - _lim = 0; - _ptr = 0; - return _bufMark = IoHand::seek(pos); - } -} - -} // End of namespace CGE diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h deleted file mode 100644 index f7b45d8ade..0000000000 --- a/engines/cge/cfile.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_CFILE__ -#define __CGE_CFILE__ - -#include "cge/general.h" - -namespace CGE { - -#define kLineMaxSize 512 -#define kBufferSize 2048 - -class IoBuf : public IoHand { -protected: - uint8 *_buff; - uint16 _ptr; - uint16 _lim; - long _bufMark; - virtual void readBuf(); -public: - IoBuf(Crypt *crpt); - IoBuf(const char *name, Crypt *crpt); - virtual ~IoBuf(); - uint16 read(void *buf, uint16 len); - uint16 read(uint8 *buf); - int read(); -}; - - -class CFile : public IoBuf { -public: - static uint16 _maxLineLen; - CFile(const char *name, Crypt *crpt); - virtual ~CFile(); - long mark(); - long seek(long pos); -}; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 584512b69a..0dbc1c8696 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -34,7 +34,6 @@ #include "cge/cge_main.h" #include "cge/talk.h" #include "cge/text.h" -#include "cge/vol.h" #include "cge/walk.h" namespace CGE { diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 0309f9f724..cf3e5223b4 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -41,8 +41,6 @@ #include "cge/text.h" #include "cge/game.h" #include "cge/events.h" -#include "cge/cfile.h" -#include "cge/vol.h" #include "cge/talk.h" #include "cge/vmenu.h" #include "cge/gettext.h" @@ -427,7 +425,7 @@ void CGEEngine::tooFar() { void CGEEngine::loadHeroXY() { debugC(1, kCGEDebugEngine, "CGEEngine::loadHeroXY()"); - INI_FILE cf(progName(".HXY")); + VFile cf(progName(".HXY")); uint16 x, y; memset(_heroXY, 0, sizeof(_heroXY)); @@ -446,7 +444,7 @@ void CGEEngine::loadMapping() { debugC(1, kCGEDebugEngine, "CGEEngine::loadMapping()"); if (_now <= _caveMax) { - INI_FILE cf(progName(".TAB")); + VFile cf(progName(".TAB")); if (!cf._error) { // Move to the data for the given room cf.seek((_now - 1) * kMapArrSize); @@ -1021,8 +1019,8 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int char line[kLineMax]; mergeExt(line, fname, kSprExt); - if (INI_FILE::exist(line)) { // sprite description file exist - INI_FILE sprf(line); + if (VFile::exist(line)) { // sprite description file exist + VFile sprf(line); if (sprf._error) error("Bad SPR [%s]", line); @@ -1158,7 +1156,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int } void CGEEngine::loadScript(const char *fname) { - INI_FILE scrf(fname); + VFile scrf(fname); if (scrf._error) return; @@ -1344,7 +1342,7 @@ void CGEEngine::runGame() { if (!_music) _midiPlayer.killMidi(); - if (INI_FILE::exist("MINI.SPR")) { + if (VFile::exist("MINI.SPR")) { _miniShp = new BitmapPtr[2]; _miniShp[0] = _miniShp[1] = NULL; @@ -1362,7 +1360,7 @@ void CGEEngine::runGame() { if (_hero) { expandSprite(_hero); _hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y); - if (INI_FILE::exist("00SHADOW.SPR")) { + if (VFile::exist("00SHADOW.SPR")) { loadSprite("00SHADOW", -1, 0, _hero->_x + 14, _hero->_y + 51); delete _shadow; if ((_shadow = _sprite) != NULL) { @@ -1427,7 +1425,7 @@ void CGEEngine::movie(const char *ext) { return; const char *fn = progName(ext); - if (INI_FILE::exist(fn)) { + if (VFile::exist(fn)) { loadScript(fn); expandSprite(_vga->_spareQ->locate(999)); feedSnail(_vga->_showQ->locate(999), kTake); diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index ad1e4e258f..cce3122235 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -84,7 +84,7 @@ namespace CGE { #define kStackSize 2048 #define kSavegameCheckSum (1956 + _now + _oldLev + _game + _music + _demoText) #define kSavegame0Name ("{{INIT}}" kSvgExt) -#define kSavegame0File INI_FILE +#define kSavegame0File VFile #define kSavegameStrSize 11 #define kGameFrameDelay (1000 / 50) #define kGameTickDelay (1000 / 62) diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp new file mode 100644 index 0000000000..b2761f33be --- /dev/null +++ b/engines/cge/fileio.cpp @@ -0,0 +1,427 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "common/system.h" +#include "common/str.h" +#include "common/debug.h" +#include "common/debug-channels.h" +#include "common/memstream.h" +#include "cge/cge.h" +#include "cge/fileio.h" + +namespace CGE { + +Dat *VFile::_dat = NULL; +BtFile *VFile::_cat = NULL; +VFile *VFile::_recent = NULL; + +uint16 XCrypt(void *buf, uint16 siz, uint16 seed) { + byte *b = static_cast(buf); + + for (uint16 i = 0; i < siz; i++) + *b++ ^= seed; + + return seed; +} + +/*----------------------------------------------------------------------- + * IOHand + *-----------------------------------------------------------------------*/ +IoHand::IoHand(Crypt *crypt) : XFile(), _crypt(crypt), _seed(kCryptSeed) { + _file = new Common::File(); +} + +IoHand::IoHand(const char *name, Crypt *crypt) + : XFile(), _crypt(crypt), _seed(kCryptSeed) { + _file = new Common::File(); + _file->open(name); +} + +IoHand::~IoHand() { + _file->close(); + delete _file; +} + +uint16 IoHand::read(void *buf, uint16 len) { + if (!_file->isOpen()) + return 0; + + uint16 bytesRead = _file->read(buf, len); + if (!bytesRead) + error("Read %s - %d bytes", _file->getName(), len); + if (_crypt) + _seed = _crypt(buf, len, kCryptSeed); + return bytesRead; +} + +long IoHand::mark() { + return _file->pos(); +} + +long IoHand::seek(long pos) { + _file->seek(pos, SEEK_SET); + return _file->pos(); +} + +long IoHand::size() { + return _file->size(); +} + +bool IoHand::exist(const char *name) { + return Common::File::exists(name); +} + +/*----------------------------------------------------------------------- + * IoBuf + *-----------------------------------------------------------------------*/ +IoBuf::IoBuf(Crypt *crypt) + : IoHand(crypt), + _bufMark(0), + _ptr(0), + _lim(0) { + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(crypt)"); + + _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); + assert(_buff != NULL); +} + +IoBuf::IoBuf(const char *name, Crypt *crypt) + : IoHand(name, crypt), + _bufMark(0), + _ptr(0), + _lim(0) { + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, crypt)", name); + + _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); + assert(_buff != NULL); +} + +IoBuf::~IoBuf() { + debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()"); + free(_buff); +} + +void IoBuf::readBuf() { + debugC(4, kCGEDebugFile, "IoBuf::readBuf()"); + + _bufMark = IoHand::mark(); + _lim = IoHand::read(_buff, kBufferSize); + _ptr = 0; +} + +uint16 IoBuf::read(void *buf, uint16 len) { + debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len); + + uint16 total = 0; + while (len) { + if (_ptr >= _lim) + readBuf(); + uint16 n = _lim - _ptr; + if (n) { + if (len < n) + n = len; + memcpy(buf, _buff + _ptr, n); + buf = (uint8 *)buf + n; + len -= n; + total += n; + _ptr += n; + } else + break; + } + return total; +} + +uint16 IoBuf::read(uint8 *buf) { + debugC(3, kCGEDebugFile, "IoBuf::read(buf)"); + + uint16 total = 0; + + while (total < kLineMaxSize - 2) { + if (_ptr >= _lim) + readBuf(); + uint8 *p = _buff + _ptr; + uint16 n = _lim - _ptr; + if (n) { + if (total + n >= kLineMaxSize - 2) + n = kLineMaxSize - 2 - total; + uint8 *eol = (uint8 *) memchr(p, '\r', n); + if (eol) + n = (uint16)(eol - p); + uint8 *eof = (uint8 *) memchr(p, '\32', n); + if (eof) { // end-of-file + n = (uint16)(eof - p); + _ptr = (uint16)(eof - _buff); + } + if (n) + memcpy(buf, p, n); + buf += n; + total += n; + if (eof) + break; + _ptr += n; + if (eol) { + _ptr++; + *(buf++) = '\n'; + total++; + if (_ptr >= _lim) + readBuf(); + if (_ptr < _lim) + if (_buff[_ptr] == '\n') + ++_ptr; + break; + } + } else + break; + } + *buf = '\0'; + return total; +} + +int IoBuf::read() { + debugC(1, kCGEDebugFile, "IoBuf::read()"); + + if (_ptr >= _lim) { + readBuf(); + if (_lim == 0) + return -1; + } + return _buff[_ptr++]; +} + +/*----------------------------------------------------------------------- + * CFile + *-----------------------------------------------------------------------*/ +uint16 CFile::_maxLineLen = kLineMaxSize; + +CFile::CFile(const char *name, Crypt *crypt) + : IoBuf(name, crypt) { + debugC(1, kCGEDebugFile, "CFile::CFile(%s, crypt)", name); +} + +CFile::~CFile() { +} + +long CFile::mark() { + debugC(5, kCGEDebugFile, "CFile::mark()"); + + return _bufMark + _ptr; +} + +long CFile::seek(long pos) { + debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos); + + if (pos >= _bufMark && pos < _bufMark + _lim) { + _ptr = (uint16)(pos - _bufMark); + return pos; + } else { + _lim = 0; + _ptr = 0; + return _bufMark = IoHand::seek(pos); + } +} + +/*----------------------------------------------------------------------- + * BtPage + *-----------------------------------------------------------------------*/ +void BtPage::read(Common::ReadStream &s) { + _hea._count = s.readUint16LE(); + _hea._down = s.readUint16LE(); + + if (_hea._down == kBtValNone) { + // Leaf list + for (int i = 0; i < kBtLeafCount; ++i) { + s.read(_lea[i]._key, kBtKeySize); + _lea[i]._mark = s.readUint32LE(); + _lea[i]._size = s.readUint16LE(); + } + } else { + // Root index + for (int i = 0; i < kBtInnerCount; ++i) { + s.read(_inn[i]._key, kBtKeySize); + _inn[i]._down = s.readUint16LE(); + } + } +} + +/*----------------------------------------------------------------------- + * BtFile + *-----------------------------------------------------------------------*/ +BtFile::BtFile(const char *name, Crypt *crpt) + : IoHand(name, crpt) { + debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, crpt)", name); + + for (int i = 0; i < kBtLevel; i++) { + _buff[i]._page = new BtPage; + _buff[i]._pgNo = kBtValNone; + _buff[i]._indx = -1; + assert(_buff[i]._page != NULL); + } +} + +BtFile::~BtFile() { + debugC(1, kCGEDebugFile, "BtFile::~BtFile()"); + for (int i = 0; i < kBtLevel; i++) + delete _buff[i]._page; +} + +BtPage *BtFile::getPage(int lev, uint16 pgn) { + debugC(1, kCGEDebugFile, "BtFile::getPage(%d, %d)", lev, pgn); + + if (_buff[lev]._pgNo != pgn) { + int32 pos = pgn * kBtSize; + _buff[lev]._pgNo = pgn; + assert(size() > pos); + // In the original, there was a check verifying if the + // purpose was to write a new file. This should only be + // to create a new file, thus it was removed. + seek((uint32) pgn * kBtSize); + + // Read in the page + byte buffer[kBtSize]; + int bytesRead = read(buffer, kBtSize); + + // Unpack it into the page structure + Common::MemoryReadStream stream(buffer, bytesRead, DisposeAfterUse::NO); + _buff[lev]._page->read(stream); + + _buff[lev]._indx = -1; + } + return _buff[lev]._page; +} + +BtKeypack *BtFile::find(const char *key) { + debugC(1, kCGEDebugFile, "BtFile::find(%s)", key); + + int lev = 0; + uint16 nxt = kBtValRoot; + while (!_error) { + BtPage *pg = getPage(lev, nxt); + // search + if (pg->_hea._down != kBtValNone) { + int i; + for (i = 0; i < pg->_hea._count; i++) { + // Does this work, or does it have to compare the entire buffer? + if (scumm_strnicmp((const char *)key, (const char*)pg->_inn[i]._key, kBtKeySize) < 0) + break; + } + nxt = (i) ? pg->_inn[i - 1]._down : pg->_hea._down; + _buff[lev]._indx = i - 1; + lev++; + } else { + int i; + for (i = 0; i < pg->_hea._count - 1; i++) { + if (scumm_stricmp((const char *)key, (const char *)pg->_lea[i]._key) <= 0) + break; + } + _buff[lev]._indx = i; + return &pg->_lea[i]; + } + } + return NULL; +} + +/*----------------------------------------------------------------------- + * Dat + *-----------------------------------------------------------------------*/ +Dat::Dat(): _file(kDatName, XCrypt) { + debugC(1, kCGEDebugFile, "Dat::Dat()"); +} + +/*----------------------------------------------------------------------- + * VFile + *-----------------------------------------------------------------------*/ +void VFile::init() { + debugC(1, kCGEDebugFile, "VFile::init()"); + + _dat = new Dat(); + _cat = new BtFile(kCatName, XCrypt); + _recent = NULL; +} + +void VFile::deinit() { + delete _dat; + delete _cat; +} + +VFile::VFile(const char *name) : IoBuf(NULL) { + debugC(3, kCGEDebugFile, "VFile::VFile(%s)", name); + + if (_dat->_file._error || _cat->_error) + error("Bad volume data"); + BtKeypack *kp = _cat->find(name); + if (scumm_stricmp(kp->_key, name) != 0) + _error = 1; + _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size; +} + +VFile::~VFile() { + if (_recent == this) + _recent = NULL; +} + +bool VFile::exist(const char *name) { + debugC(1, kCGEDebugFile, "VFile::exist(%s)", name); + + return scumm_stricmp(_cat->find(name)->_key, name) == 0; +} + +void VFile::readBuf() { + debugC(3, kCGEDebugFile, "VFile::readBuf()"); + + if (_recent != this) { + _dat->_file.seek(_bufMark + _lim); + _recent = this; + } + _bufMark = _dat->_file.mark(); + long n = _endMark - _bufMark; + if (n > kBufferSize) + n = kBufferSize; + _lim = _dat->_file.read(_buff, (uint16) n); + _ptr = 0; +} + +long VFile::mark() { + debugC(5, kCGEDebugFile, "VFile::mark()"); + + return (_bufMark + _ptr) - _begMark; +} + +long VFile::size() { + debugC(1, kCGEDebugFile, "VFile::size()"); + + return _endMark - _begMark; +} + +long VFile::seek(long pos) { + debugC(1, kCGEDebugFile, "VFile::seek(%ld)", pos); + + _recent = NULL; + _lim = 0; + return (_bufMark = _begMark + pos); +} + +} // End of namespace CGE diff --git a/engines/cge/fileio.h b/engines/cge/fileio.h new file mode 100644 index 0000000000..a8577207bd --- /dev/null +++ b/engines/cge/fileio.h @@ -0,0 +1,180 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#ifndef __CGE_BTFILE__ +#define __CGE_BTFILE__ + +#include "cge/general.h" +#include "common/stream.h" + +namespace CGE { + +#define kBtSize 1024 +#define kBtKeySize 13 +#define kBtLevel 2 +#define kBtInnerCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 2 /*sizeof(Inner) */)) +#define kBtLeafCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 4 + 2 /*sizeof(BtKeypack) */)) +#define kBtValNone 0xFFFF +#define kBtValRoot 0 +#define kLineMaxSize 512 +#define kBufferSize 2048 +#define kCatName "VOL.CAT" +#define kDatName "VOL.DAT" + +struct BtKeypack { + char _key[kBtKeySize]; + uint32 _mark; + uint16 _size; +}; + +struct Inner { + uint8 _key[kBtKeySize]; + uint16 _down; +}; + +struct Hea { + uint16 _count; + uint16 _down; +}; + +class XFile { +public: + uint16 _error; + + XFile() : _error(0) { } + virtual ~XFile() { } + virtual uint16 read(void *buf, uint16 len) = 0; + virtual long mark() = 0; + virtual long size() = 0; + virtual long seek(long pos) = 0; +}; + +class IoHand : public XFile { +protected: + Common::File *_file; + uint16 _seed; + Crypt *_crypt; +public: + IoHand(const char *name, Crypt crypt); + IoHand(Crypt *crypt); + virtual ~IoHand(); + static bool exist(const char *name); + uint16 read(void *buf, uint16 len); + long mark(); + long size(); + long seek(long pos); +}; + +class IoBuf : public IoHand { +protected: + uint8 *_buff; + uint16 _ptr; + uint16 _lim; + long _bufMark; + virtual void readBuf(); +public: + IoBuf(Crypt *crpt); + IoBuf(const char *name, Crypt *crpt); + virtual ~IoBuf(); + uint16 read(void *buf, uint16 len); + uint16 read(uint8 *buf); + int read(); +}; + + +class CFile : public IoBuf { +public: + static uint16 _maxLineLen; + CFile(const char *name, Crypt *crpt); + virtual ~CFile(); + long mark(); + long seek(long pos); +}; + +struct BtPage { + Hea _hea; + union { + // dummy filler to make proper size of union + uint8 _data[kBtSize - 4 /*sizeof(Hea) */]; + // inner version of data: key + word-sized page link + Inner _inn[kBtInnerCount]; + // leaf version of data: key + all user data + BtKeypack _lea[kBtLeafCount]; + }; + + void read(Common::ReadStream &s); +}; + +class BtFile : public IoHand { + struct { + BtPage *_page; + uint16 _pgNo; + int _indx; + } _buff[kBtLevel]; + + BtPage *getPage(int lev, uint16 pgn); +public: + BtFile(const char *name, Crypt *crpt); + virtual ~BtFile(); + BtKeypack *find(const char *key); + BtKeypack *next(); +}; + +class Dat { + friend class VFile; + CFile _file; +public: + Dat(); + bool read(long org, uint16 len, uint8 *buf); +}; + +class VFile : public IoBuf { +private: + static Dat *_dat; + static BtFile *_cat; + static VFile *_recent; + + long _begMark; + long _endMark; + + void readBuf(); +public: + VFile(const char *name); + ~VFile(); + + static void init(); + static void deinit(); + static bool exist(const char *name); + static const char *next(); + long mark(); + long size(); + long seek(long pos); +}; + +} // End of namespace CGE + +#endif diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index a3258e9415..68db71e918 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -124,38 +124,6 @@ char *forceExt(char *buf, const char *name, const char *ext) { return buf; } -static unsigned Seed = 0xA5; - -unsigned fastRand() { - return Seed = 257 * Seed + 817; -} -unsigned fastRand(unsigned s) { - return Seed = 257 * s + 817; -} - -uint16 RCrypt(void *buf, uint16 siz, uint16 seed) { - if (buf && siz) { - byte *b = static_cast(buf); - byte *q = b + (siz - 1); - seed = fastRand(seed); - *b++ ^= seed; - while (buf < q) - *b++ ^= fastRand(); - if (buf == q) - *b ^= (seed = fastRand()); - } - return seed; -} - -uint16 XCrypt(void *buf, uint16 siz, uint16 seed) { - byte *b = static_cast(buf); - - for (uint16 i = 0; i < siz; i++) - *b++ ^= seed; - - return seed; -} - uint16 atow(const char *a) { if (!a) return 0; @@ -202,51 +170,6 @@ char *dwtom(uint32 val, char *str, int radix, int len) { return str; } -IoHand::IoHand(Crypt *crypt) - : XFile(), _crypt(crypt), _seed(kCryptSeed) { - _file = new Common::File(); -} - -IoHand::IoHand(const char *name, Crypt *crypt) - : XFile(), _crypt(crypt), _seed(kCryptSeed) { - _file = new Common::File(); - _file->open(name); -} - -IoHand::~IoHand() { - _file->close(); - delete _file; -} - -uint16 IoHand::read(void *buf, uint16 len) { - if (!_file->isOpen()) - return 0; - - uint16 bytesRead = _file->read(buf, len); - if (!bytesRead) - error("Read %s - %d bytes", _file->getName(), len); - if (_crypt) - _seed = _crypt(buf, len, Seed); - return bytesRead; -} - -long IoHand::mark() { - return _file->pos(); -} - -long IoHand::seek(long pos) { - _file->seek(pos, SEEK_SET); - return _file->pos(); -} - -long IoHand::size() { - return _file->size(); -} - -bool IoHand::exist(const char *name) { - return Common::File::exists(name); -} - void sndSetVolume() { warning("STUB: SNDSetVolume"); } diff --git a/engines/cge/general.h b/engines/cge/general.h index 37f492a538..fbb5fc4c45 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -64,43 +64,6 @@ T min(T A, T B) { return (A < B) ? A : B; } -class XFile { -public: - uint16 _error; - - XFile() : _error(0) { } - virtual ~XFile() { } - virtual uint16 read(void *buf, uint16 len) = 0; - virtual long mark() = 0; - virtual long size() = 0; - virtual long seek(long pos) = 0; -}; - - -template -inline uint16 XRead(XFile *xf, T *t) { - return xf->read((uint8 *) t, sizeof(*t)); -} - - -class IoHand : public XFile { -protected: - Common::File *_file; - uint16 _seed; - Crypt *_crypt; -public: - IoHand(const char *name, Crypt crypt = NULL); - IoHand(Crypt *crypt = NULL); - virtual ~IoHand(); - static bool exist(const char *name); - uint16 read(void *buf, uint16 len); - long mark(); - long size(); - long seek(long pos); -}; - -Crypt XCrypt; -Crypt RCrypt; uint16 atow(const char *a); uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); @@ -112,9 +75,6 @@ char *forceExt(char *buf, const char *name, const char *ext); // MISSING FUNCTIONS const char *progName(const char *ext = NULL); -unsigned fastRand(); -unsigned fastRand(unsigned s); -uint16 rCrypt(void *buf, uint16 siz, uint16 seed); int newRandom(int range); } // End of namespace CGE diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h index 0ba8a1956b..490c79803a 100644 --- a/engines/cge/jbw.h +++ b/engines/cge/jbw.h @@ -32,11 +32,6 @@ namespace CGE { -// Defines found in cge.mak -#define INI_FILE VFile // Or is it CFile? -#define PIC_FILE VFile -// - #define kMaxFile 128 #define IsDigit(c) ((c) >= '0' && (c) <= '9') diff --git a/engines/cge/module.mk b/engines/cge/module.mk index e71de2d9e4..6d34cdfd14 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -2,13 +2,12 @@ MODULE := engines/cge MODULE_OBJS := \ bitmap.o \ - btfile.o \ - cfile.o \ cge.o \ cge_main.o \ console.o \ detection.o \ events.o \ + fileio.o \ game.o \ general.o \ gettext.o \ @@ -18,7 +17,6 @@ MODULE_OBJS := \ text.o \ vga13h.o \ vmenu.o \ - vol.o \ walk.o MODULE_DIRS += \ diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 432bca75b5..daef3fa429 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -28,8 +28,6 @@ #include "cge/general.h" #include "cge/sound.h" #include "cge/text.h" -#include "cge/cfile.h" -#include "cge/vol.h" #include "cge/cge_main.h" #include "common/config-manager.h" #include "common/memstream.h" @@ -126,7 +124,7 @@ void Fx::preload(int ref0) { for (int ref = ref0; ref < ref0 + 10; ref++) { static char fname[] = "FX00000.WAV"; wtom(ref, fname + 2, 10, 5); - INI_FILE file = INI_FILE(fname); + VFile file = VFile(fname); DataCk *wav = loadWave(&file); if (wav) { Han *p = &_cache[find(0)]; @@ -142,7 +140,7 @@ DataCk *Fx::load(int idx, int ref) { static char fname[] = "FX00000.WAV"; wtom(ref, fname + 2, 10, 5); - INI_FILE file = INI_FILE(fname); + VFile file = VFile(fname); DataCk *wav = loadWave(&file); if (wav) { Han *p = &_cache[idx]; @@ -203,14 +201,14 @@ void MusicPlayer::killMidi() { void MusicPlayer::loadMidi(int ref) { // Work out the filename and check the given MIDI file exists Common::String filename = Common::String::format("%.2d.MID", ref); - if (!INI_FILE::exist(filename.c_str())) + if (!VFile::exist(filename.c_str())) return; // Stop any currently playing MIDI file killMidi(); // Read in the data for the file - INI_FILE mid(filename.c_str()); + VFile mid(filename.c_str()); _dataSize = mid.size(); _data = (byte *)malloc(_dataSize); mid.read(_data, _dataSize); diff --git a/engines/cge/sound.h b/engines/cge/sound.h index e6bc2dedde..53f57a19b0 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -28,7 +28,7 @@ #ifndef __CGE_SOUND__ #define __CGE_SOUND__ -#include "cge/general.h" +#include "cge/fileio.h" #include "cge/snddrv.h" #include "audio/audiostream.h" #include "audio/decoders/wave.h" diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 812fa1d9dc..5e8aa1b869 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -27,7 +27,6 @@ #include "cge/general.h" #include "cge/talk.h" -#include "cge/vol.h" #include "cge/game.h" #include "cge/events.h" @@ -50,7 +49,7 @@ Font::~Font() { } void Font::load() { - INI_FILE f(_path); + VFile f(_path); if (f._error) return; @@ -61,6 +60,7 @@ void Font::load() { uint16 p = 0; for (uint16 i = 0; i < kPosSize; i++) { _pos[i] = p; + warning("Fonts 0x%X 0x%X", i, p); p += _wid[i]; } f.read(_map, p); diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 0e6fc40920..973aadd23a 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -28,7 +28,6 @@ #include "cge/general.h" #include "cge/text.h" #include "cge/talk.h" -#include "cge/vol.h" #include "cge/game.h" #include "cge/snail.h" #include "cge/cge_main.h" @@ -41,7 +40,7 @@ Talk *_talk = NULL; Text::Text(CGEEngine *vm, const char *fname, int size) : _vm(vm) { _cache = new Han[size]; mergeExt(_fileName, fname, kSayExt); - if (!INI_FILE::exist(_fileName)) + if (!VFile::exist(_fileName)) error("No talk (%s)\n", _fileName); for (_size = 0; _size < size; _size++) { @@ -78,7 +77,7 @@ int Text::find(int ref) { void Text::preload(int from, int upto) { - INI_FILE tf = _fileName; + VFile tf = _fileName; if (tf._error) return; @@ -123,7 +122,7 @@ void Text::preload(int from, int upto) { char *Text::load(int idx, int ref) { - INI_FILE tf = _fileName; + VFile tf = _fileName; if (tf._error) return NULL; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 8213a1bcf3..317cb415f8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -31,7 +31,6 @@ #include "cge/general.h" #include "cge/vga13h.h" #include "cge/bitmap.h" -#include "cge/vol.h" #include "cge/text.h" #include "cge/cge_main.h" #include "cge/cge.h" @@ -232,8 +231,8 @@ Sprite *Sprite::expand() { Snail::Com *nea = NULL; Snail::Com *tak = NULL; mergeExt(fname, _file, kSprExt); - if (INI_FILE::exist(fname)) { // sprite description file exist - INI_FILE sprf(fname); + if (VFile::exist(fname)) { // sprite description file exist + VFile sprf(fname); if (!(sprf._error==0)) error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp deleted file mode 100644 index ff0a979b1d..0000000000 --- a/engines/cge/vol.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/vol.h" -#include "common/system.h" -#include "common/str.h" -#include "cge/cge.h" -#include "common/debug.h" -#include "common/debug-channels.h" - -namespace CGE { - -Dat *VFile::_dat = NULL; -BtFile *VFile::_cat = NULL; -VFile *VFile::_recent = NULL; - -/*-----------------------------------------------------------------------*/ - -Dat::Dat(): _file(DAT_NAME, CRP) { - debugC(1, kCGEDebugFile, "Dat::Dat()"); -} - -/*-----------------------------------------------------------------------*/ - -void VFile::init() { - debugC(1, kCGEDebugFile, "VFile::init()"); - - _dat = new Dat(); - _cat = new BtFile(CAT_NAME, CRP); - _recent = NULL; -} - -void VFile::deinit() { - delete _dat; - delete _cat; -} - -VFile::VFile(const char *name) - : IoBuf(NULL) { - debugC(3, kCGEDebugFile, "VFile::VFile(%s)", name); - - if (_dat->_file._error || _cat->_error) - error("Bad volume data"); - BtKeypack *kp = _cat->find(name); - if (scumm_stricmp(kp->_key, name) != 0) - _error = 1; - _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size; -} - -VFile::~VFile() { - if (_recent == this) - _recent = NULL; -} - -bool VFile::exist(const char *name) { - debugC(1, kCGEDebugFile, "VFile::exist(%s)", name); - - return scumm_stricmp(_cat->find(name)->_key, name) == 0; -} - -void VFile::readBuf() { - debugC(3, kCGEDebugFile, "VFile::readBuf()"); - - if (_recent != this) { - _dat->_file.seek(_bufMark + _lim); - _recent = this; - } - _bufMark = _dat->_file.mark(); - long n = _endMark - _bufMark; - if (n > kBufferSize) - n = kBufferSize; - _lim = _dat->_file.read(_buff, (uint16) n); - _ptr = 0; -} - -long VFile::mark() { - debugC(5, kCGEDebugFile, "VFile::mark()"); - - return (_bufMark + _ptr) - _begMark; -} - -long VFile::size() { - debugC(1, kCGEDebugFile, "VFile::size()"); - - return _endMark - _begMark; -} - -long VFile::seek(long pos) { - debugC(1, kCGEDebugFile, "VFile::seel(%ld)", pos); - - _recent = NULL; - _lim = 0; - return (_bufMark = _begMark + pos); -} - -} // End of namespace CGE diff --git a/engines/cge/vol.h b/engines/cge/vol.h deleted file mode 100644 index d7184ba064..0000000000 --- a/engines/cge/vol.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_VOL__ -#define __CGE_VOL__ - -#include "cge/btfile.h" -#include "cge/cfile.h" - -namespace CGE { - -#define CAT_NAME "VOL.CAT" -#define DAT_NAME "VOL.DAT" - -#define CRP XCrypt -#define XMASK 0xA5 -#define VOLBASE CFile - -class Dat { - friend class VFile; - VOLBASE _file; -public: - Dat(); - bool read(long org, uint16 len, uint8 *buf); -}; - -class VFile : public IoBuf { -private: - static Dat *_dat; - static BtFile *_cat; - static VFile *_recent; - - long _begMark; - long _endMark; - - void readBuf(); -public: - VFile(const char *name); - ~VFile(); - - static void init(); - static void deinit(); - static bool exist(const char *name); - static const char *next(); - long mark(); - long size(); - long seek(long pos); -}; - - -} // End of namespace CGE - -#endif -- cgit v1.2.3 From a8ad211c3663130c151b7a5cad8f9fc550226449 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 09:39:35 +0200 Subject: CGE: Merge talk.cpp and gettext.cpp --- engines/cge/cge_main.cpp | 1 - engines/cge/fileio.h | 4 +- engines/cge/gettext.cpp | 119 ----------------------------------------------- engines/cge/gettext.h | 61 ------------------------ engines/cge/module.mk | 1 - engines/cge/talk.cpp | 85 +++++++++++++++++++++++++++++++++ engines/cge/talk.h | 29 ++++++++++-- 7 files changed, 112 insertions(+), 188 deletions(-) delete mode 100644 engines/cge/gettext.cpp delete mode 100644 engines/cge/gettext.h diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index cf3e5223b4..2d83dce040 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -43,7 +43,6 @@ #include "cge/events.h" #include "cge/talk.h" #include "cge/vmenu.h" -#include "cge/gettext.h" #include "cge/cge_main.h" #include "cge/cge.h" #include "cge/walk.h" diff --git a/engines/cge/fileio.h b/engines/cge/fileio.h index a8577207bd..7cb5ce07e0 100644 --- a/engines/cge/fileio.h +++ b/engines/cge/fileio.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_BTFILE__ -#define __CGE_BTFILE__ +#ifndef __CGE_FILEIO__ +#define __CGE_FILEIO__ #include "cge/general.h" #include "common/stream.h" diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp deleted file mode 100644 index 46dacbe1de..0000000000 --- a/engines/cge/gettext.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#include "cge/gettext.h" -#include "cge/events.h" -#include "cge/cge_main.h" - -namespace CGE { - -GetText *GetText::_ptr = NULL; - -GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) - : Talk(vm), _text(text), _size(min(size, kGetTextMax)), _len(min(_size, strlen(text))), - _cntr(kGetTextBlink), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { - _ptr = this; - _mode = kTBRect; - - _ts = new BitmapPtr[2]; - const int i = 2 * kTextHMargin + _font->width(info); - _ts[0] = box((i + 3) & ~3, 2 * kTextVMargin + 2 * kFontHigh + kTextLineSpace); - _ts[1] = NULL; - setShapeList(_ts); - - _flags._bDel = true; - _flags._kill = true; - memcpy(_buff, text, _len); - _buff[_len] = ' '; - _buff[_len + 1] = '\0'; - putLine(0, info); - tick(); -} - -GetText::~GetText() { - _keyboard->setClient(_oldKeybClient); - _ptr = NULL; -} - -void GetText::tick() { - if (++_cntr >= kGetTextBlink) { - _buff[_len] ^= (' ' ^ '_'); - _cntr = 0; - } - putLine(1, _buff); - _time = kGetTextTime; -} - -void GetText::touch(uint16 mask, int x, int y) { - static char ogon[] = "•œ¥£˜ ¡"; - static char bezo[] = "ACELNOSXZ"; - char *p; - - if (mask & kEventKeyb) { - _vm->keyClick(); - switch (x) { - case Enter: - _buff[_len] = '\0'; - strcpy(_text, _buff); - for (p = _text; *p; p++) { - char *q = strchr(ogon, *p); - if (q) - *p = bezo[q - ogon]; - } - case Esc: - _snail_->addCom(kSnKill, -1, 0, this); - break; - case BSp: - if (_len) { - _len--; - _buff[_len] = _buff[_len + 1]; - _buff[_len + 1] = _buff[_len + 2]; - } - break; - default: - if (x < 'A' || x > 'Z') { - if (_oldKeybClient) - _oldKeybClient->touch(mask, x, y); - } else { - if (_keyboard->_key[kKeyAlt]) { - p = strchr(bezo, x); - if (p) - x = ogon[p - bezo]; - } - if (_len < _size && 2 * kTextHMargin + _font->width(_buff) + _font->_wid[x] <= _w) { - _buff[_len + 2] = _buff[_len + 1]; - _buff[_len + 1] = _buff[_len]; - _buff[_len++] = x; - } - } - break; - } - } else - Sprite::touch(mask, x, y); -} - -} // End of namespace CGE diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h deleted file mode 100644 index 6afa9ccfec..0000000000 --- a/engines/cge/gettext.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_GETTEXT__ -#define __CGE_GETTEXT__ - -#include "cge/general.h" -#include "cge/talk.h" - -namespace CGE { - -#define kGetTextMax 24 -#define kGetTextBlink 6 -#define kGetTextTime 6 - -class GetText : public Talk { - char _buff[kGetTextMax + 2]; - char *_text; - uint16 _size; - uint16 _len; - uint16 _cntr; - Sprite *_oldKeybClient; - -public: - static GetText *_ptr; - GetText(CGEEngine *vm, const char *info, char *text, int size); - ~GetText(); - void touch(uint16 mask, int x, int y); - void tick(); - -private: - CGEEngine *_vm; -}; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/module.mk b/engines/cge/module.mk index 6d34cdfd14..62b319e190 100644 --- a/engines/cge/module.mk +++ b/engines/cge/module.mk @@ -10,7 +10,6 @@ MODULE_OBJS := \ fileio.o \ game.o \ general.o \ - gettext.o \ snail.o \ sound.o \ talk.o \ diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 5e8aa1b869..58c68339bb 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -29,6 +29,7 @@ #include "cge/talk.h" #include "cge/game.h" #include "cge/events.h" +#include "cge/cge_main.h" namespace CGE { @@ -301,4 +302,88 @@ void InfoLine::update(const char *text) { _oldText = text; } +GetText *GetText::_ptr = NULL; + +GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) + : Talk(vm), _text(text), _size(min(size, kGetTextMax)), _len(min(_size, strlen(text))), + _cntr(kGetTextBlink), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { + _ptr = this; + _mode = kTBRect; + + _ts = new BitmapPtr[2]; + const int i = 2 * kTextHMargin + _font->width(info); + _ts[0] = box((i + 3) & ~3, 2 * kTextVMargin + 2 * kFontHigh + kTextLineSpace); + _ts[1] = NULL; + setShapeList(_ts); + + _flags._bDel = true; + _flags._kill = true; + memcpy(_buff, text, _len); + _buff[_len] = ' '; + _buff[_len + 1] = '\0'; + putLine(0, info); + tick(); +} + +GetText::~GetText() { + _keyboard->setClient(_oldKeybClient); + _ptr = NULL; +} + +void GetText::tick() { + if (++_cntr >= kGetTextBlink) { + _buff[_len] ^= (' ' ^ '_'); + _cntr = 0; + } + putLine(1, _buff); + _time = kGetTextTime; +} + +void GetText::touch(uint16 mask, int x, int y) { + static char ogon[] = "•œ¥£˜ ¡"; + static char bezo[] = "ACELNOSXZ"; + char *p; + + if (mask & kEventKeyb) { + _vm->keyClick(); + switch (x) { + case Enter: + _buff[_len] = '\0'; + strcpy(_text, _buff); + for (p = _text; *p; p++) { + char *q = strchr(ogon, *p); + if (q) + *p = bezo[q - ogon]; + } + case Esc: + _snail_->addCom(kSnKill, -1, 0, this); + break; + case BSp: + if (_len) { + _len--; + _buff[_len] = _buff[_len + 1]; + _buff[_len + 1] = _buff[_len + 2]; + } + break; + default: + if (x < 'A' || x > 'Z') { + if (_oldKeybClient) + _oldKeybClient->touch(mask, x, y); + } else { + if (_keyboard->_key[kKeyAlt]) { + p = strchr(bezo, x); + if (p) + x = ogon[p - bezo]; + } + if (_len < _size && 2 * kTextHMargin + _font->width(_buff) + _font->_wid[x] <= _w) { + _buff[_len + 2] = _buff[_len + 1]; + _buff[_len + 1] = _buff[_len]; + _buff[_len++] = x; + } + } + break; + } + } else + Sprite::touch(mask, x, y); +} } // End of namespace CGE diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 9a999e5e8e..5bb4aa2052 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -28,9 +28,9 @@ #ifndef __CGE_TALK__ #define __CGE_TALK__ -#include "cge/vga13h.h" #include "cge/general.h" #include "cge/jbw.h" +#include "cge/vga13h.h" namespace CGE { @@ -43,10 +43,12 @@ namespace CGE { #define kWidSize 256 #define kPosSize 256 #define kMapSize (256*8) - -#define kFontHigh 8 -#define kFontExt ".CFT" +#define kFontHigh 8 +#define kFontExt ".CFT" #define kPathMax 128 +#define kGetTextMax 24 +#define kGetTextBlink 6 +#define kGetTextTime 6 enum TextBoxStyle { kTBPure, kTBRect, kTBRound }; @@ -93,6 +95,25 @@ private: CGEEngine *_vm; }; +class GetText : public Talk { + char _buff[kGetTextMax + 2]; + char *_text; + uint16 _size; + uint16 _len; + uint16 _cntr; + Sprite *_oldKeybClient; + +public: + static GetText *_ptr; + GetText(CGEEngine *vm, const char *info, char *text, int size); + ~GetText(); + void touch(uint16 mask, int x, int y); + void tick(); + +private: + CGEEngine *_vm; +}; + } // End of namespace CGE #endif -- cgit v1.2.3 From 4d059c0e62f6d1c2a78963a55e86d74a89373a56 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 14:05:04 +0200 Subject: CGE: Remove user first name input, used originally for savegame names --- engines/cge/cge.h | 2 -- engines/cge/cge_main.cpp | 60 ++++++++---------------------------------------- 2 files changed, 9 insertions(+), 53 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index fbb096df07..f4260dc31a 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -124,7 +124,6 @@ public: bool _game; int _now; int _lev; - char _usrFnam[15]; int _mode; int _soundOk; int _gameCase2Cpt; @@ -169,7 +168,6 @@ public: void runGame(); bool showTitle(const char *name); void movie(const char *ext); - void takeName(); void inf(const char *text); void selectSound(); void dummy() {} diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 2d83dce040..5df7ab193e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -188,10 +188,6 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { // Delete the thumbnail saveHeader.thumbnail->free(); delete saveHeader.thumbnail; - - // If we're loading the auto-save slot, load the name - if (slotNumber == 0) - strncpy(_usrFnam, saveHeader.saveName.c_str(), 8); } // Get in the savegame @@ -656,7 +652,7 @@ void CGEEngine::qGame() { saveSound(); // Write out the user's progress - saveGame(0, _usrFnam); + saveGame(0, ""); _vga->sunset(); _finis = true; @@ -851,24 +847,6 @@ void CGEEngine::startCountDown() { switchCave(-1); } -void CGEEngine::takeName() { - debugC(1, kCGEDebugEngine, "CGEEngine::takeName()"); - - if (GetText::_ptr) { - _snail_->addCom(kSnKill, -1, 0, GetText::_ptr); - } else { - memset(_usrFnam, 0, 15); - GetText *tn = new GetText(this, _text->getText(kGetNamePrompt), _usrFnam, 8); - if (tn) { - tn->setName(_text->getText(kGetNameTitle)); - tn->center(); - tn->gotoxy(tn->_x, tn->_y - 10); - tn->_z = 126; - _vga->_showQ->insert(tn); - } - } -} - void CGEEngine::switchMapping() { assert(_horzLine); debugC(1, kCGEDebugEngine, "CGEEngine::switchMapping()"); @@ -1487,41 +1465,23 @@ bool CGEEngine::showTitle(const char *name) { _midiPlayer.loadMidi(0); } - bool userOk = false; if (_mode < 2) { - if (_isDemo) { - strcpy(_usrFnam, progName(kSvgExt)); - userOk = true; - } else { -#ifndef EVA + if (!_isDemo) { // At this point the game originally set the protection variables // used by the copy protection check movie("X00"); // paylist _vga->copyPage(1, 2); _vga->copyPage(0, 1); _vga->_showQ->append(_mouse); - //Mouse.On(); - - // For ScummVM, skip prompting for name if a savegame in slot 0 already exists - if ((_startGameSlot == -1) && savegameExists(0)) { - strcpy(_usrFnam, "User"); - userOk = true; - } else { - for (takeName(); GetText::_ptr;) { - mainLoop(); - if (_eventManager->_quitFlag) - return false; - } - if (_keyboard->lastKey() == Enter && *_usrFnam) - userOk = true; - } - //Mouse.Off(); + // In the original game, the user had to enter his name + // As it was only used to name savegames, it has been removed _vga->_showQ->clear(); _vga->copyPage(0, 2); -#endif } - if (userOk && _mode == 0) { + if (_mode == 0) { +// The auto-load of savegame #0 is currently disabled +#if 0 if (savegameExists(0)) { // Load the savegame loadGame(0, NULL, true); // only system vars @@ -1532,6 +1492,7 @@ bool CGEEngine::showTitle(const char *name) { _flag[3] = false; } } else +#endif _mode++; } } @@ -1541,10 +1502,7 @@ bool CGEEngine::showTitle(const char *name) { _vga->copyPage(0, 2); - if (_isDemo) - return true; - else - return (_mode == 2 || userOk); + return true; } void CGEEngine::cge_main() { -- cgit v1.2.3 From fedd3108719405eb5de52206a8337de4c9cd875d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 14:08:39 +0200 Subject: CGE: Remove GetText class, which was used to enter the username --- engines/cge/talk.cpp | 84 ---------------------------------------------------- engines/cge/talk.h | 22 -------------- 2 files changed, 106 deletions(-) diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 58c68339bb..9a4cd7caf5 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -302,88 +302,4 @@ void InfoLine::update(const char *text) { _oldText = text; } -GetText *GetText::_ptr = NULL; - -GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) - : Talk(vm), _text(text), _size(min(size, kGetTextMax)), _len(min(_size, strlen(text))), - _cntr(kGetTextBlink), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { - _ptr = this; - _mode = kTBRect; - - _ts = new BitmapPtr[2]; - const int i = 2 * kTextHMargin + _font->width(info); - _ts[0] = box((i + 3) & ~3, 2 * kTextVMargin + 2 * kFontHigh + kTextLineSpace); - _ts[1] = NULL; - setShapeList(_ts); - - _flags._bDel = true; - _flags._kill = true; - memcpy(_buff, text, _len); - _buff[_len] = ' '; - _buff[_len + 1] = '\0'; - putLine(0, info); - tick(); -} - -GetText::~GetText() { - _keyboard->setClient(_oldKeybClient); - _ptr = NULL; -} - -void GetText::tick() { - if (++_cntr >= kGetTextBlink) { - _buff[_len] ^= (' ' ^ '_'); - _cntr = 0; - } - putLine(1, _buff); - _time = kGetTextTime; -} - -void GetText::touch(uint16 mask, int x, int y) { - static char ogon[] = "•œ¥£˜ ¡"; - static char bezo[] = "ACELNOSXZ"; - char *p; - - if (mask & kEventKeyb) { - _vm->keyClick(); - switch (x) { - case Enter: - _buff[_len] = '\0'; - strcpy(_text, _buff); - for (p = _text; *p; p++) { - char *q = strchr(ogon, *p); - if (q) - *p = bezo[q - ogon]; - } - case Esc: - _snail_->addCom(kSnKill, -1, 0, this); - break; - case BSp: - if (_len) { - _len--; - _buff[_len] = _buff[_len + 1]; - _buff[_len + 1] = _buff[_len + 2]; - } - break; - default: - if (x < 'A' || x > 'Z') { - if (_oldKeybClient) - _oldKeybClient->touch(mask, x, y); - } else { - if (_keyboard->_key[kKeyAlt]) { - p = strchr(bezo, x); - if (p) - x = ogon[p - bezo]; - } - if (_len < _size && 2 * kTextHMargin + _font->width(_buff) + _font->_wid[x] <= _w) { - _buff[_len + 2] = _buff[_len + 1]; - _buff[_len + 1] = _buff[_len]; - _buff[_len++] = x; - } - } - break; - } - } else - Sprite::touch(mask, x, y); -} } // End of namespace CGE diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 5bb4aa2052..2c546f3427 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -46,9 +46,6 @@ namespace CGE { #define kFontHigh 8 #define kFontExt ".CFT" #define kPathMax 128 -#define kGetTextMax 24 -#define kGetTextBlink 6 -#define kGetTextTime 6 enum TextBoxStyle { kTBPure, kTBRect, kTBRound }; @@ -95,25 +92,6 @@ private: CGEEngine *_vm; }; -class GetText : public Talk { - char _buff[kGetTextMax + 2]; - char *_text; - uint16 _size; - uint16 _len; - uint16 _cntr; - Sprite *_oldKeybClient; - -public: - static GetText *_ptr; - GetText(CGEEngine *vm, const char *info, char *text, int size); - ~GetText(); - void touch(uint16 mask, int x, int y); - void tick(); - -private: - CGEEngine *_vm; -}; - } // End of namespace CGE #endif -- cgit v1.2.3 From 5346ac18b7e33a603aa2743fa57f430d96cdbc33 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 28 Aug 2011 00:40:55 +1000 Subject: AGOS: Integrate InstallShield support. --- engines/agos/agos.cpp | 51 ++++++++++++++- engines/agos/agos.h | 31 +++++++-- engines/agos/animation.cpp | 10 ++- engines/agos/detection.cpp | 31 +++++++++ engines/agos/detection_tables.h | 126 +++++++++++++++++++++++++++++++++++++ engines/agos/feeble.cpp | 3 + engines/agos/installshield_cab.cpp | 126 +++++++++++++++++++++---------------- engines/agos/installshield_cab.h | 40 +++--------- engines/agos/intern.h | 6 +- engines/agos/res.cpp | 111 ++++++++++++++++++-------------- engines/agos/res_snd.cpp | 24 +++---- engines/agos/saveload.cpp | 8 +-- engines/agos/subroutine.cpp | 22 +++---- 13 files changed, 417 insertions(+), 172 deletions(-) diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 300cd28ee4..a7964603a2 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -41,18 +41,51 @@ namespace AGOS { static const GameSpecificSettings simon1_settings = { + "", // base_filename + "", // restore_filename + "", // tbl_filename "EFFECTS", // effects_filename "SIMON", // speech_filename }; static const GameSpecificSettings simon2_settings = { + "", // base_filename + "", // restore_filename + "", // tbl_filename "", // effects_filename "SIMON2", // speech_filename }; -static const GameSpecificSettings puzzlepack_settings = { +static const GameSpecificSettings dimp_settings = { + "Gdimp", // base_filename + "", // restore_filename + "", // tbl_filename "", // effects_filename - "MUSIC", // speech_filename + "MUSIC", // speech_filename +}; + +static const GameSpecificSettings jumble_settings = { + "Gjumble", // base_filename + "", // restore_filename + "", // tbl_filename + "", // effects_filename + "MUSIC", // speech_filename +}; + +static const GameSpecificSettings puzzle_settings = { + "Gpuzzle", // base_filename + "", // restore_filename + "", // tbl_filename + "", // effects_filename + "MUSIC", // speech_filename +}; + +static const GameSpecificSettings swampy_settings = { + "Gswampy", // base_filename + "", // restore_filename + "", // tbl_filename + "", // effects_filename + "MUSIC", // speech_filename }; #ifdef ENABLE_AGOS2 @@ -678,7 +711,15 @@ static const uint16 initialVideoWindows_PN[20] = { #ifdef ENABLE_AGOS2 void AGOSEngine_PuzzlePack::setupGame() { - gss = &puzzlepack_settings; + if (getGameId() == GID_DIMP) { + gss = &dimp_settings; + } else if (getGameId() == GID_JUMBLE) { + gss = &jumble_settings; + } else if (getGameId() == GID_PUZZLE) { + gss = &puzzle_settings; + } else if (getGameId() == GID_SWAMPY) { + gss = &swampy_settings; + } _numVideoOpcodes = 85; _vgaMemSize = 7500000; _itemMemSize = 20000; @@ -963,6 +1004,10 @@ void AGOSEngine::pause() { } Common::Error AGOSEngine::go() { +#ifdef ENABLE_AGOS2 + loadArchives(); +#endif + loadGamePcFile(); addTimeEvent(0, 1); diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 820bc0260b..ec979abc20 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -25,6 +25,7 @@ #include "engines/engine.h" +#include "common/archive.h" #include "common/array.h" #include "common/error.h" #include "common/keyboard.h" @@ -186,6 +187,22 @@ class Debugger; # define _OPCODE(ver, x) { &ver::x, "" } #endif +class ArchiveMan : public Common::SearchSet { +public: + ArchiveMan(); + + void enableFallback(bool val) { _fallBack = val; } + +#ifdef ENABLE_AGOS2 + void registerArchive(const Common::String &filename, int priority); +#endif + + Common::SeekableReadStream *open(const Common::String &filename); + +private: + bool _fallBack; +}; + class AGOSEngine : public Engine { protected: friend class Debugger; @@ -599,6 +616,8 @@ public: AGOSEngine(OSystem *system, const AGOSGameDescription *gd); virtual ~AGOSEngine(); + ArchiveMan _archives; + byte *_curSfxFile; uint32 _curSfxFileSize; uint16 _sampleEnd, _sampleWait; @@ -608,6 +627,10 @@ protected: virtual uint16 readUint16Wrapper(const void *src); virtual uint32 readUint32Wrapper(const void *src); +#ifdef ENABLE_AGOS2 + void loadArchives(); +#endif + int allocGamePcVars(Common::SeekableReadStream *in); void createPlayer(); void allocateStringTable(int num); @@ -792,14 +815,14 @@ protected: void loadTextIntoMem(uint16 stringId); uint loadTextFile(const char *filename, byte *dst); - Common::File *openTablesFile(const char *filename); - void closeTablesFile(Common::File *in); + Common::SeekableReadStream *openTablesFile(const char *filename); + void closeTablesFile(Common::SeekableReadStream *in); uint loadTextFile_simon1(const char *filename, byte *dst); - Common::File *openTablesFile_simon1(const char *filename); + Common::SeekableReadStream *openTablesFile_simon1(const char *filename); uint loadTextFile_gme(const char *filename, byte *dst); - Common::File *openTablesFile_gme(const char *filename); + Common::SeekableReadStream *openTablesFile_gme(const char *filename); void invokeTimeEvent(TimeEvent *te); bool kickoffTimeEvents(); diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index d9a585bd05..b05623525f 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -251,8 +251,11 @@ bool MoviePlayerDXA::load() { } Common::String videoName = Common::String::format("%s.dxa", baseName); - if (!loadFile(videoName)) + Common::SeekableReadStream *videoStream = _vm->_archives.open(videoName); + if (!videoStream) error("Failed to load video file %s", videoName.c_str()); + if (!loadStream(videoStream)) + error("Failed to load video stream from file %s", videoName.c_str()); debug(0, "Playing video %s", videoName.c_str()); @@ -412,8 +415,11 @@ MoviePlayerSMK::MoviePlayerSMK(AGOSEngine_Feeble *vm, const char *name) bool MoviePlayerSMK::load() { Common::String videoName = Common::String::format("%s.smk", baseName); - if (!loadFile(videoName)) + Common::SeekableReadStream *videoStream = _vm->_archives.open(videoName); + if (!videoStream) error("Failed to load video file %s", videoName.c_str()); + if (!loadStream(videoStream)) + error("Failed to load video stream from file %s", videoName.c_str()); debug(0, "Playing video %s", videoName.c_str()); diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp index 2be888b92a..a14b660817 100644 --- a/engines/agos/detection.cpp +++ b/engines/agos/detection.cpp @@ -240,6 +240,22 @@ Common::Platform AGOSEngine::getPlatform() const { } const char *AGOSEngine::getFileName(int type) const { + // Required if the InstallShield cab is been used + if (getGameType() == GType_PP) { + if (type == GAME_BASEFILE) + return gss->base_filename; + } + + // Required if the InstallShield cab is been used + if (getGameType() == GType_FF && getPlatform() == Common::kPlatformWindows) { + if (type == GAME_BASEFILE) + return gss->base_filename; + if (type == GAME_RESTFILE) + return gss->restore_filename; + if (type == GAME_TBLFILE) + return gss->tbl_filename; + } + for (int i = 0; _gameDescription->desc.filesDescriptions[i].fileType; i++) { if (_gameDescription->desc.filesDescriptions[i].fileType == type) return _gameDescription->desc.filesDescriptions[i].fileName; @@ -247,4 +263,19 @@ const char *AGOSEngine::getFileName(int type) const { return NULL; } +#ifdef ENABLE_AGOS2 +void AGOSEngine::loadArchives() { + const ADGameFileDescription *ag; + + if (getFeatures() & GF_PACKED) { + for (ag = _gameDescription->desc.filesDescriptions; ag->fileName; ag++) { + if (!_archives.hasArchive(ag->fileName)) + _archives.registerArchive(ag->fileName, ag->fileType); + } + } + + _archives.enableFallback(true); +} +#endif + } // End of namespace AGOS diff --git a/engines/agos/detection_tables.h b/engines/agos/detection_tables.h index d9f321d98e..a7a384a496 100644 --- a/engines/agos/detection_tables.h +++ b/engines/agos/detection_tables.h @@ -2519,6 +2519,27 @@ static const AGOSGameDescription gameDescriptions[] = { GF_OLD_BUNDLE | GF_ZLIBCOMP | GF_TALKIE }, + // The Feeble Files - English Windows 2CD (with InstallShield cab) + { + { + "feeble", + "2CD", + + { + { "data1.cab", 0, "600db08891e7a21badc8215e604cd88f", 28845430}, + { NULL, 0, NULL, 0} + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO_NOSUBTITLES | GUIO_NOMUSIC + }, + + GType_FF, + GID_FEEBLEFILES, + GF_OLD_BUNDLE | GF_TALKIE | GF_PACKED + }, + // The Feeble Files - English Windows 2CD { { @@ -2565,6 +2586,27 @@ static const AGOSGameDescription gameDescriptions[] = { GF_OLD_BUNDLE | GF_TALKIE }, + // The Feeble Files - English Windows 4CD (with InstallShield cab) + { + { + "feeble", + "4CD", + + { + { "data1.cab", 0, "65804cbc9036ac4b1275d97e0de3be2f", 28943062}, + { NULL, 0, NULL, 0} + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO_NOSUBTITLES | GUIO_NOMUSIC + }, + + GType_FF, + GID_FEEBLEFILES, + GF_OLD_BUNDLE | GF_TALKIE | GF_PACKED + }, + // The Feeble Files - English Windows 4CD { { @@ -2703,6 +2745,27 @@ static const AGOSGameDescription gameDescriptions[] = { GF_OLD_BUNDLE | GF_TALKIE }, + // Simon the Sorcerer's Puzzle Pack - Demon in my Pocket (with InstallShield cab) + { + { + "dimp", + "CD", + + { + { "data1.cab", 0, "36dd86c1d872cea81ac1de7753dd684a", 40394693}, + { NULL, 0, NULL, 0} + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO_NOSUBTITLES | GUIO_NOMUSIC + }, + + GType_PP, + GID_DIMP, + GF_OLD_BUNDLE | GF_TALKIE | GF_PACKED + }, + // Simon the Sorcerer's Puzzle Pack - Demon in my Pocket { { @@ -2724,6 +2787,27 @@ static const AGOSGameDescription gameDescriptions[] = { GF_OLD_BUNDLE | GF_TALKIE }, + // Simon the Sorcerer's Puzzle Pack - Jumble (with InstallShield cab) + { + { + "jumble", + "CD", + + { + { "data1.cab", 0, "36dd86c1d872cea81ac1de7753dd684a", 40394693}, + { NULL, 0, NULL, 0} + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO_NOSUBTITLES + }, + + GType_PP, + GID_JUMBLE, + GF_OLD_BUNDLE | GF_TALKIE | GF_PACKED + }, + // Simon the Sorcerer's Puzzle Pack - Jumble { { @@ -2745,6 +2829,27 @@ static const AGOSGameDescription gameDescriptions[] = { GF_OLD_BUNDLE | GF_TALKIE }, + // Simon the Sorcerer's Puzzle Pack - NoPatience (with InstallShield cab) + { + { + "puzzle", + "CD", + + { + { "data1.cab", 0, "36dd86c1d872cea81ac1de7753dd684a", 40394693}, + { NULL, 0, NULL, 0} + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO_NOSUBTITLES + }, + + GType_PP, + GID_PUZZLE, + GF_OLD_BUNDLE | GF_TALKIE | GF_PACKED + }, + // Simon the Sorcerer's Puzzle Pack - NoPatience { { @@ -2766,6 +2871,27 @@ static const AGOSGameDescription gameDescriptions[] = { GF_OLD_BUNDLE | GF_TALKIE }, + // Simon the Sorcerer's Puzzle Pack - Swampy Adventures - English (with InstallShield cab) + { + { + "swampy", + "CD", + + { + { "data1.cab", 0, "36dd86c1d872cea81ac1de7753dd684a", 40394693}, + { NULL, 0, NULL, 0} + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO_NOSUBTITLES + }, + + GType_PP, + GID_SWAMPY, + GF_OLD_BUNDLE | GF_TALKIE | GF_PACKED + }, + // Simon the Sorcerer's Puzzle Pack - Swampy Adventures - English { { diff --git a/engines/agos/feeble.cpp b/engines/agos/feeble.cpp index 4c82b7e19d..e9a91e3b76 100644 --- a/engines/agos/feeble.cpp +++ b/engines/agos/feeble.cpp @@ -45,6 +45,9 @@ AGOSEngine_Feeble::~AGOSEngine_Feeble() { } static const GameSpecificSettings feeblefiles_settings = { + "game22", // base_filename + "save.999", // restore_filename + "tbllist", // tbl_filename "", // effects_filename "VOICES", // speech_filename }; diff --git a/engines/agos/installshield_cab.cpp b/engines/agos/installshield_cab.cpp index a8b5d0fba2..f7b49a64c5 100644 --- a/engines/agos/installshield_cab.cpp +++ b/engines/agos/installshield_cab.cpp @@ -46,59 +46,80 @@ #include "agos/installshield_cab.h" #include "common/debug.h" +#include "common/file.h" #include "common/memstream.h" #include "common/zlib.h" namespace AGOS { -InstallShieldCabinet::InstallShieldCabinet() : Common::Archive() { - _stream = 0; -} +class InstallShieldCabinet : public Common::Archive { + Common::String _installShieldFilename; + +public: + InstallShieldCabinet(const Common::String &filename); + ~InstallShieldCabinet(); + + // Common::Archive API implementation + bool hasFile(const Common::String &name); + int listMembers(Common::ArchiveMemberList &list); + Common::ArchiveMemberPtr getMember(const Common::String &name); + Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; + +private: + struct FileEntry { + uint32 uncompressedSize; + uint32 compressedSize; + uint32 offset; + uint16 flags; + }; + + typedef Common::HashMap FileMap; + FileMap _map; +}; InstallShieldCabinet::~InstallShieldCabinet() { - close(); + _map.clear(); } -bool InstallShieldCabinet::open(const Common::String &filename) { - close(); +InstallShieldCabinet::InstallShieldCabinet(const Common::String &filename) : _installShieldFilename(filename) { + Common::File installShieldFile; - _stream = SearchMan.createReadStreamForMember(filename); - - if (!_stream) - return false; + if (!installShieldFile.open(_installShieldFilename)) { + warning("InstallShieldCabinet::InstallShieldCabinet(): Could not find the archive file %s", _installShieldFilename.c_str()); + return; + } // Note that we only support a limited subset of cabinet files // Only single cabinet files and ones without data shared between // cabinets. // Check for the magic uint32 - if (_stream->readUint32LE() != 0x28635349) { - close(); - return false; + if (installShieldFile.readUint32LE() != 0x28635349) { + warning("InstallShieldCabinet::InstallShieldCabinet(): Magic ID doesn't match"); + return; } - uint32 version = _stream->readUint32LE(); + uint32 version = installShieldFile.readUint32LE(); if (version != 0x01000004) { warning("Unsupported CAB version %08x", version); - close(); - return false; + return; } - /* uint32 volumeInfo = */ _stream->readUint32LE(); - uint32 cabDescriptorOffset = _stream->readUint32LE(); - /* uint32 cabDescriptorSize = */ _stream->readUint32LE(); + /* uint32 volumeInfo = */ installShieldFile.readUint32LE(); + uint32 cabDescriptorOffset = installShieldFile.readUint32LE(); + /* uint32 cabDescriptorSize = */ installShieldFile.readUint32LE(); - _stream->seek(cabDescriptorOffset); + installShieldFile.seek(cabDescriptorOffset); - _stream->skip(12); - uint32 fileTableOffset = _stream->readUint32LE(); - _stream->skip(4); - uint32 fileTableSize = _stream->readUint32LE(); - uint32 fileTableSize2 = _stream->readUint32LE(); - uint32 directoryCount = _stream->readUint32LE(); - _stream->skip(8); - uint32 fileCount = _stream->readUint32LE(); + installShieldFile.skip(12); + uint32 fileTableOffset = installShieldFile.readUint32LE(); + installShieldFile.skip(4); + uint32 fileTableSize = installShieldFile.readUint32LE(); + uint32 fileTableSize2 = installShieldFile.readUint32LE(); + uint32 directoryCount = installShieldFile.readUint32LE(); + installShieldFile.skip(8); + uint32 fileCount = installShieldFile.readUint32LE(); if (fileTableSize != fileTableSize2) warning("file table sizes do not match"); @@ -106,49 +127,42 @@ bool InstallShieldCabinet::open(const Common::String &filename) { // We're ignoring file groups and components since we // should not need them. Moving on to the files... - _stream->seek(cabDescriptorOffset + fileTableOffset); + installShieldFile.seek(cabDescriptorOffset + fileTableOffset); uint32 fileTableCount = directoryCount + fileCount; uint32 *fileTableOffsets = new uint32[fileTableCount]; for (uint32 i = 0; i < fileTableCount; i++) - fileTableOffsets[i] = _stream->readUint32LE(); + fileTableOffsets[i] = installShieldFile.readUint32LE(); for (uint32 i = directoryCount; i < fileCount + directoryCount; i++) { - _stream->seek(cabDescriptorOffset + fileTableOffset + fileTableOffsets[i]); - uint32 nameOffset = _stream->readUint32LE(); - /* uint32 directoryIndex = */ _stream->readUint32LE(); + installShieldFile.seek(cabDescriptorOffset + fileTableOffset + fileTableOffsets[i]); + uint32 nameOffset = installShieldFile.readUint32LE(); + /* uint32 directoryIndex = */ installShieldFile.readUint32LE(); // First read in data needed by us to get at the file data FileEntry entry; - entry.flags = _stream->readUint16LE(); - entry.uncompressedSize = _stream->readUint32LE(); - entry.compressedSize = _stream->readUint32LE(); - _stream->skip(20); - entry.offset = _stream->readUint32LE(); + entry.flags = installShieldFile.readUint16LE(); + entry.uncompressedSize = installShieldFile.readUint32LE(); + entry.compressedSize = installShieldFile.readUint32LE(); + installShieldFile.skip(20); + entry.offset = installShieldFile.readUint32LE(); // Then let's get the string - _stream->seek(cabDescriptorOffset + fileTableOffset + nameOffset); + installShieldFile.seek(cabDescriptorOffset + fileTableOffset + nameOffset); Common::String fileName; - char c = _stream->readByte(); + char c = installShieldFile.readByte(); while (c) { fileName += c; - c = _stream->readByte(); + c = installShieldFile.readByte(); } - _map[fileName] = entry; } delete[] fileTableOffsets; - - return true; -} - -void InstallShieldCabinet::close() { - delete _stream; _stream = 0; - _map.clear(); } bool InstallShieldCabinet::hasFile(const Common::String &name) { + warning("hasFile: Filename %s", name.c_str()); return _map.contains(name); } @@ -164,23 +178,25 @@ Common::ArchiveMemberPtr InstallShieldCabinet::getMember(const Common::String &n } Common::SeekableReadStream *InstallShieldCabinet::createReadStreamForMember(const Common::String &name) const { - if (!_stream || !_map.contains(name)) + if (!_map.contains(name)) return 0; const FileEntry &entry = _map[name]; - _stream->seek(entry.offset); + Common::File archiveFile; + archiveFile.open(_installShieldFilename); + archiveFile.seek(entry.offset); if (!(entry.flags & 0x04)) { // Not compressed - return _stream->readStream(entry.uncompressedSize); + return archiveFile.readStream(entry.uncompressedSize); } #ifdef USE_ZLIB byte *src = (byte *)malloc(entry.compressedSize); byte *dst = (byte *)malloc(entry.uncompressedSize); - _stream->read(src, entry.compressedSize); + archiveFile.read(src, entry.compressedSize); bool result = Common::inflateZlibHeaderless(dst, entry.uncompressedSize, src, entry.compressedSize); free(src); @@ -198,4 +214,8 @@ Common::SeekableReadStream *InstallShieldCabinet::createReadStreamForMember(cons #endif } +Common::Archive *makeInstallShieldArchive(const Common::String &name) { + return new InstallShieldCabinet(name); +} + } // End of namespace AGOS diff --git a/engines/agos/installshield_cab.h b/engines/agos/installshield_cab.h index 3fb8e66b03..f7e8bed277 100644 --- a/engines/agos/installshield_cab.h +++ b/engines/agos/installshield_cab.h @@ -21,11 +21,6 @@ */ #include "common/archive.h" -#include "common/scummsys.h" -#include "common/endian.h" -#include "common/file.h" -#include "common/hash-str.h" -#include "common/hashmap.h" #include "common/str.h" #ifndef AGOS_INSTALLSHIELD_CAB_H @@ -33,34 +28,13 @@ namespace AGOS { -class InstallShieldCabinet : public Common::Archive { -public: - InstallShieldCabinet(); - ~InstallShieldCabinet(); - - bool open(const Common::String &filename); - void close(); - bool isOpen() const { return _stream != 0; } - - // Common::Archive API implementation - bool hasFile(const Common::String &name); - int listMembers(Common::ArchiveMemberList &list); - Common::ArchiveMemberPtr getMember(const Common::String &name); - Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; - -private: - struct FileEntry { - uint32 uncompressedSize; - uint32 compressedSize; - uint32 offset; - uint16 flags; - }; - - Common::SeekableReadStream *_stream; - - typedef Common::HashMap FileMap; - FileMap _map; -}; +/** + * This factory method creates an Archive instance corresponding to the content + * of the InstallShield compressed file with the given name. + * + * May return 0 in case of a failure. + */ +Common::Archive *makeInstallShieldArchive(const Common::String &name); } // End of namespace AGOS diff --git a/engines/agos/intern.h b/engines/agos/intern.h index 18f56be4a4..773b9c15bd 100644 --- a/engines/agos/intern.h +++ b/engines/agos/intern.h @@ -193,6 +193,9 @@ struct TimeEvent { }; struct GameSpecificSettings { + const char *base_filename; + const char *restore_filename; + const char *tbl_filename; const char *effects_filename; const char *speech_filename; }; @@ -251,7 +254,8 @@ enum GameFeatures { GF_32COLOR = 1 << 5, GF_EGA = 1 << 6, GF_PLANAR = 1 << 7, - GF_DEMO = 1 << 8 + GF_DEMO = 1 << 8, + GF_PACKED = 1 << 9 }; enum GameFileTypes { diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index a71d4d8150..fe7bcd62a9 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -31,11 +31,30 @@ #include "agos/agos.h" #include "agos/intern.h" #include "agos/sound.h" +#include "agos/installshield_cab.h" #include "common/zlib.h" namespace AGOS { +ArchiveMan::ArchiveMan() { + _fallBack = false; +} + +#ifdef ENABLE_AGOS2 +void ArchiveMan::registerArchive(const Common::String &filename, int priority) { + add(filename, makeInstallShieldArchive(filename), priority); +} +#endif + +Common::SeekableReadStream *ArchiveMan::open(const Common::String &filename) { + if (_fallBack && SearchMan.hasFile(filename)) { + return SearchMan.createReadStreamForMember(filename); + } + + return createReadStreamForMember(filename); +} + #ifdef ENABLE_AGOS2 uint16 AGOSEngine_Feeble::to16Wrapper(uint value) { return TO_LE_16(value); @@ -150,21 +169,21 @@ int AGOSEngine::allocGamePcVars(Common::SeekableReadStream *in) { } void AGOSEngine_PN::loadGamePcFile() { - Common::File in; + Common::SeekableReadStream *in; if (getFileName(GAME_BASEFILE) != NULL) { // Read dataBase - in.open(getFileName(GAME_BASEFILE)); - if (in.isOpen() == false) { + in = _archives.open(getFileName(GAME_BASEFILE)); + if (!in) { error("loadGamePcFile: Can't load database file '%s'", getFileName(GAME_BASEFILE)); } - _dataBaseSize = in.size(); + _dataBaseSize = in->size(); _dataBase = (byte *)malloc(_dataBaseSize); if (_dataBase == NULL) error("loadGamePcFile: Out of memory for dataBase"); - in.read(_dataBase, _dataBaseSize); - in.close(); + in->read(_dataBase, _dataBaseSize); + delete in; if (_dataBase[31] != 0) error("Later version of system requested"); @@ -172,17 +191,17 @@ void AGOSEngine_PN::loadGamePcFile() { if (getFileName(GAME_TEXTFILE) != NULL) { // Read textBase - in.open(getFileName(GAME_TEXTFILE)); - if (in.isOpen() == false) { + in = _archives.open(getFileName(GAME_TEXTFILE)); + if (!in) { error("loadGamePcFile: Can't load textbase file '%s'", getFileName(GAME_TEXTFILE)); } - _textBaseSize = in.size(); + _textBaseSize = in->size(); _textBase = (byte *)malloc(_textBaseSize); if (_textBase == NULL) error("loadGamePcFile: Out of memory for textBase"); - in.read(_textBase, _textBaseSize); - in.close(); + in->read(_textBase, _textBaseSize); + delete in; if (_textBase[getlong(30L)] != 128) error("Unknown compression format"); @@ -190,20 +209,20 @@ void AGOSEngine_PN::loadGamePcFile() { } void AGOSEngine::loadGamePcFile() { - Common::File in; + Common::SeekableReadStream *in; int fileSize; if (getFileName(GAME_BASEFILE) != NULL) { /* Read main gamexx file */ - in.open(getFileName(GAME_BASEFILE)); - if (in.isOpen() == false) { + in = _archives.open(getFileName(GAME_BASEFILE)); + if (!in) { error("loadGamePcFile: Can't load gamexx file '%s'", getFileName(GAME_BASEFILE)); } if (getFeatures() & GF_CRUNCHED_GAMEPC) { - uint srcSize = in.size(); + uint srcSize = in->size(); byte *srcBuf = (byte *)malloc(srcSize); - in.read(srcBuf, srcSize); + in->read(srcBuf, srcSize); uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); byte *dstBuf = (byte *)malloc(dstSize); @@ -214,25 +233,25 @@ void AGOSEngine::loadGamePcFile() { readGamePcFile(&stream); free(dstBuf); } else { - readGamePcFile(&in); + readGamePcFile(in); } - in.close(); + delete in; } if (getFileName(GAME_TBLFILE) != NULL) { /* Read list of TABLE resources */ - in.open(getFileName(GAME_TBLFILE)); - if (in.isOpen() == false) { + in = _archives.open(getFileName(GAME_TBLFILE)); + if (!in) { error("loadGamePcFile: Can't load table resources file '%s'", getFileName(GAME_TBLFILE)); } - fileSize = in.size(); + fileSize = in->size(); _tblList = (byte *)malloc(fileSize); if (_tblList == NULL) error("loadGamePcFile: Out of memory for strip table list"); - in.read(_tblList, fileSize); - in.close(); + in->read(_tblList, fileSize); + delete in; /* Remember the current state */ _subroutineListOrg = _subroutineList; @@ -242,71 +261,71 @@ void AGOSEngine::loadGamePcFile() { if (getFileName(GAME_STRFILE) != NULL) { /* Read list of TEXT resources */ - in.open(getFileName(GAME_STRFILE)); - if (in.isOpen() == false) + in = _archives.open(getFileName(GAME_STRFILE)); + if (!in) error("loadGamePcFile: Can't load text resources file '%s'", getFileName(GAME_STRFILE)); - fileSize = in.size(); + fileSize = in->size(); _strippedTxtMem = (byte *)malloc(fileSize); if (_strippedTxtMem == NULL) error("loadGamePcFile: Out of memory for strip text list"); - in.read(_strippedTxtMem, fileSize); - in.close(); + in->read(_strippedTxtMem, fileSize); + delete in; } if (getFileName(GAME_STATFILE) != NULL) { /* Read list of ROOM STATE resources */ - in.open(getFileName(GAME_STATFILE)); - if (in.isOpen() == false) { + in = _archives.open(getFileName(GAME_STATFILE)); + if (!in) { error("loadGamePcFile: Can't load state resources file '%s'", getFileName(GAME_STATFILE)); } - _numRoomStates = in.size() / 8; + _numRoomStates = in->size() / 8; _roomStates = (RoomState *)calloc(_numRoomStates, sizeof(RoomState)); if (_roomStates == NULL) error("loadGamePcFile: Out of memory for room state list"); for (uint s = 0; s < _numRoomStates; s++) { - uint16 num = in.readUint16BE() - (_itemArrayInited - 2); + uint16 num = in->readUint16BE() - (_itemArrayInited - 2); - _roomStates[num].state = in.readUint16BE(); - _roomStates[num].classFlags = in.readUint16BE(); - _roomStates[num].roomExitStates = in.readUint16BE(); + _roomStates[num].state = in->readUint16BE(); + _roomStates[num].classFlags = in->readUint16BE(); + _roomStates[num].roomExitStates = in->readUint16BE(); } - in.close(); + delete in; } if (getFileName(GAME_RMSLFILE) != NULL) { /* Read list of ROOM ITEMS resources */ - in.open(getFileName(GAME_RMSLFILE)); - if (in.isOpen() == false) { + in = _archives.open(getFileName(GAME_RMSLFILE)); + if (!in) { error("loadGamePcFile: Can't load room resources file '%s'", getFileName(GAME_RMSLFILE)); } - fileSize = in.size(); + fileSize = in->size(); _roomsList = (byte *)malloc(fileSize); if (_roomsList == NULL) error("loadGamePcFile: Out of memory for room items list"); - in.read(_roomsList, fileSize); - in.close(); + in->read(_roomsList, fileSize); + delete in; } if (getFileName(GAME_XTBLFILE) != NULL) { /* Read list of XTABLE resources */ - in.open(getFileName(GAME_XTBLFILE)); - if (in.isOpen() == false) { + in = _archives.open(getFileName(GAME_XTBLFILE)); + if (!in) { error("loadGamePcFile: Can't load xtable resources file '%s'", getFileName(GAME_XTBLFILE)); } - fileSize = in.size(); + fileSize = in->size(); _xtblList = (byte *)malloc(fileSize); if (_xtblList == NULL) error("loadGamePcFile: Out of memory for strip xtable list"); - in.read(_xtblList, fileSize); - in.close(); + in->read(_xtblList, fileSize); + delete in; /* Remember the current state */ _xsubroutineListOrg = _subroutineList; diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp index 9a04ce2d26..1d4e2d1060 100644 --- a/engines/agos/res_snd.cpp +++ b/engines/agos/res_snd.cpp @@ -450,17 +450,17 @@ static const char *dimpSoundList[32] = { void AGOSEngine::loadSoundFile(const char* filename) { - Common::File in; + Common::SeekableReadStream *in; - in.open(filename); - if (in.isOpen() == false) + in = _archives.open(filename); + if (!in) error("loadSound: Can't load %s", filename); - uint32 dstSize = in.size(); + uint32 dstSize = in->size(); byte *dst = (byte *)malloc(dstSize); - if (in.read(dst, dstSize) != dstSize) + if (in->read(dst, dstSize) != dstSize) error("loadSound: Read failed"); - in.close(); + delete in; _sound->playSfxData(dst, 0, 0, 0); } @@ -469,21 +469,21 @@ void AGOSEngine::loadSound(uint16 sound, int16 pan, int16 vol, uint16 type) { byte *dst; if (getGameId() == GID_DIMP) { - Common::File in; + Common::SeekableReadStream *in; char filename[15]; assert(sound >= 1 && sound <= 32); sprintf(filename, "%s.wav", dimpSoundList[sound - 1]); - in.open(filename); - if (in.isOpen() == false) + in = _archives.open(filename); + if (!in) error("loadSound: Can't load %s", filename); - uint32 dstSize = in.size(); + uint32 dstSize = in->size(); dst = (byte *)malloc(dstSize); - if (in.read(dst, dstSize) != dstSize) + if (in->read(dst, dstSize) != dstSize) error("loadSound: Read failed"); - in.close(); + delete in; } else if (getFeatures() & GF_ZLIBCOMP) { char filename[15]; diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index 10830db002..6779eabdbf 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -1019,9 +1019,7 @@ bool AGOSEngine::loadGame(const char *filename, bool restartMode) { if (restartMode) { // Load restart state - Common::File *file = new Common::File(); - file->open(filename); - f = file; + f = _archives.open(filename); } else { f = _saveFileMan->openForLoading(filename); } @@ -1195,9 +1193,7 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) { if (restartMode) { // Load restart state - Common::File *file = new Common::File(); - file->open(filename); - f = file; + f = _archives.open(filename); } else { f = _saveFileMan->openForLoading(filename); } diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp index bd9abb16b5..10c1c1aaf9 100644 --- a/engines/agos/subroutine.cpp +++ b/engines/agos/subroutine.cpp @@ -258,22 +258,21 @@ void AGOSEngine::endCutscene() { _runScriptReturn1 = true; } -Common::File *AGOSEngine::openTablesFile(const char *filename) { +Common::SeekableReadStream *AGOSEngine::openTablesFile(const char *filename) { if (getFeatures() & GF_OLD_BUNDLE) return openTablesFile_simon1(filename); else return openTablesFile_gme(filename); } -Common::File *AGOSEngine::openTablesFile_simon1(const char *filename) { - Common::File *fo = new Common::File(); - fo->open(filename); - if (fo->isOpen() == false) +Common::SeekableReadStream *AGOSEngine::openTablesFile_simon1(const char *filename) { + Common::SeekableReadStream *in = _archives.open(filename); + if (!in) error("openTablesFile: Can't open '%s'", filename); - return fo; + return in; } -Common::File *AGOSEngine::openTablesFile_gme(const char *filename) { +Common::SeekableReadStream *AGOSEngine::openTablesFile_gme(const char *filename) { uint res; uint32 offs; @@ -287,7 +286,7 @@ Common::File *AGOSEngine::openTablesFile_gme(const char *filename) { bool AGOSEngine::loadTablesIntoMem(uint16 subrId) { byte *p; uint16 min_num, max_num, file_num; - Common::File *in; + Common::SeekableReadStream *in; char filename[30]; if (_tblList == NULL) @@ -336,7 +335,7 @@ bool AGOSEngine::loadTablesIntoMem(uint16 subrId) { bool AGOSEngine_Waxworks::loadTablesIntoMem(uint16 subrId) { byte *p; uint min_num, max_num; - Common::File *in; + Common::SeekableReadStream *in; p = _tblList; if (p == NULL) @@ -403,7 +402,7 @@ bool AGOSEngine::loadXTablesIntoMem(uint16 subrId) { int i; uint min_num, max_num; char filename[30]; - Common::File *in; + Common::SeekableReadStream *in; p = _xtblList; if (p == NULL) @@ -453,9 +452,8 @@ bool AGOSEngine::loadXTablesIntoMem(uint16 subrId) { return 0; } -void AGOSEngine::closeTablesFile(Common::File *in) { +void AGOSEngine::closeTablesFile(Common::SeekableReadStream *in) { if (getFeatures() & GF_OLD_BUNDLE) { - in->close(); delete in; } } -- cgit v1.2.3 From 3ca0b304cf29f12d5fb3cadccb18689306d33ff8 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Mon, 15 Aug 2011 08:52:11 +0200 Subject: MOHAWK: Implement fading for Myst Demo --- engines/mohawk/graphics.cpp | 42 ++++++++++++++++++++++++++++++++-- engines/mohawk/graphics.h | 1 + engines/mohawk/myst_stacks/demo.cpp | 9 +++++--- engines/mohawk/myst_stacks/preview.cpp | 10 +++++--- engines/mohawk/myst_stacks/slides.cpp | 2 +- 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index 35c9d478d8..c4326d175f 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -672,12 +672,50 @@ void MystGraphics::simulatePreviousDrawDelay(const Common::Rect &dest) { _nextAllowedDrawTime = time + _constantDrawDelay + dest.height() * dest.width() / _proportionalDrawDelay; } +void MystGraphics::copyBackBufferToScreenWithSaturation(int16 saturation) { + Graphics::Surface *screen = _vm->_system->lockScreen(); + + for (uint16 y = 0; y < _viewport.height(); y++) + for (uint16 x = 0; x < _viewport.width(); x++) { + uint32 color; + uint8 r, g, b; + + if (_pixelFormat.bytesPerPixel == 2) + color = *(const uint16 *)_backBuffer->getBasePtr(x, y); + else + color = *(const uint32 *)_backBuffer->getBasePtr(x, y); + + _pixelFormat.colorToRGB(color, r, g, b); + + r = CLIP((int16)r - saturation, 0, 255); + g = CLIP((int16)g - saturation, 0, 255); + b = CLIP((int16)b - saturation, 0, 255); + + color = _pixelFormat.RGBToColor(r, g, b); + + if (_pixelFormat.bytesPerPixel == 2) { + uint16 *dst = (uint16 *)screen->getBasePtr(x, y); + *dst = color; + } else { + uint32 *dst = (uint32 *)screen->getBasePtr(x, y); + *dst = color; + } + } + + _vm->_system->unlockScreen(); + _vm->_system->updateScreen(); +} + void MystGraphics::fadeToBlack() { - // TODO: Implement + for (int16 i = 0; i < 256; i += 32) { + copyBackBufferToScreenWithSaturation(i); + } } void MystGraphics::fadeFromBlack() { - // TODO: Implement + for (int16 i = 256; i >= 0; i -= 32) { + copyBackBufferToScreenWithSaturation(i); + } } #endif // ENABLE_MYST diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h index 96357bbff1..463608a2aa 100644 --- a/engines/mohawk/graphics.h +++ b/engines/mohawk/graphics.h @@ -136,6 +136,7 @@ protected: MohawkSurface *decodeImage(uint16 id); MohawkEngine *getVM() { return (MohawkEngine *)_vm; } void simulatePreviousDrawDelay(const Common::Rect &dest); + void copyBackBufferToScreenWithSaturation(int16 saturation); private: MohawkEngine_Myst *_vm; diff --git a/engines/mohawk/myst_stacks/demo.cpp b/engines/mohawk/myst_stacks/demo.cpp index c9e806655e..fbad7dc384 100644 --- a/engines/mohawk/myst_stacks/demo.cpp +++ b/engines/mohawk/myst_stacks/demo.cpp @@ -84,7 +84,10 @@ void Demo::o_stopIntro(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Demo::o_fadeFromBlack(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Fade from black", op); - _vm->_gfx->fadeFromBlack(); + + // FIXME: This glitches when enabled. The backbuffer is drawn to screen, + // and then the fading occurs, causing the background to appear for one frame. + // _vm->_gfx->fadeFromBlack(); } void Demo::o_fadeToBlack(uint16 op, uint16 var, uint16 argc, uint16 *argv) { @@ -101,14 +104,14 @@ void Demo::returnToMenu_run() { switch (_returnToMenuStep){ case 0: _vm->_gfx->fadeToBlack(); - _vm->changeToCard(2003, true); + _vm->changeToCard(2003, false); _vm->_gfx->fadeFromBlack(); _returnToMenuStep++; break; case 1: _vm->_gfx->fadeToBlack(); - _vm->changeToCard(2001, true); + _vm->changeToCard(2001, false); _vm->_gfx->fadeFromBlack(); _vm->_cursor->showCursor(); diff --git a/engines/mohawk/myst_stacks/preview.cpp b/engines/mohawk/myst_stacks/preview.cpp index 1b72c85d96..31e22bb8c5 100644 --- a/engines/mohawk/myst_stacks/preview.cpp +++ b/engines/mohawk/myst_stacks/preview.cpp @@ -85,7 +85,10 @@ void Preview::o_fadeToBlack(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Preview::o_fadeFromBlack(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Fade from black", op); - _vm->_gfx->fadeFromBlack(); + + // FIXME: This glitches when enabled. The backbuffer is drawn to screen, + // and then the fading occurs, causing the background to appear for one frame. + // _vm->_gfx->fadeFromBlack(); } void Preview::o_stayHere(uint16 op, uint16 var, uint16 argc, uint16 *argv) { @@ -99,6 +102,7 @@ void Preview::o_stayHere(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Preview::o_speechStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Speech stop", op); + _vm->_sound->stopSound(3001); _speechRunning = false; _globals.currentAge = 2; } @@ -143,7 +147,7 @@ void Preview::speech_run() { case 2: // Go to Myst if (_currentCue >= 2) { _vm->_gfx->fadeToBlack(); - _vm->changeToCard(3002, true); + _vm->changeToCard(3002, false); _vm->_gfx->fadeFromBlack(); _speechStep++; @@ -186,7 +190,7 @@ void Preview::speech_run() { break; _vm->_gfx->fadeToBlack(); - _vm->changeToCard(3005, true); + _vm->changeToCard(3005, false); _vm->_gfx->fadeFromBlack(); _speechNextTime = time + 1000; _speechStep++; diff --git a/engines/mohawk/myst_stacks/slides.cpp b/engines/mohawk/myst_stacks/slides.cpp index 943cb90071..794793e49c 100644 --- a/engines/mohawk/myst_stacks/slides.cpp +++ b/engines/mohawk/myst_stacks/slides.cpp @@ -63,7 +63,7 @@ void Slides::runPersistentScripts() { // Used on Cards... if (_vm->_system->getMillis() > _nextCardTime) { _vm->_gfx->fadeToBlack(); - _vm->changeToCard(_nextCardID, true); + _vm->changeToCard(_nextCardID, false); _vm->_gfx->fadeFromBlack(); } } -- cgit v1.2.3 From 01ddc5e140862b0cfaa28b697218d1903294fcd5 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 20 Aug 2011 12:51:11 +0200 Subject: NEWS: Mention the PS3 port --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index c132abff60..016c6379e8 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,9 @@ For a more comprehensive changelog of the latest experimental code, see: - Added support for Blue's Birthday Adventure - Added support for Ringworld: Revenge Of The Patriarch + New Ports: + - Added PlayStation 3 port. + AGI: - Implemented sound support for the DOS version of Winnie the Pooh in the Hundred Acre Wood. -- cgit v1.2.3 From 2d8457fceb775bbbe5b49ea6038fac7aedb1a052 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Fri, 26 Aug 2011 20:42:31 +0200 Subject: MOHAWK: Implement channelwood var getter 31 (patch from P. Monnerat) --- engines/mohawk/myst_stacks/channelwood.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp index 0dd69a673a..9ca47cc92a 100644 --- a/engines/mohawk/myst_stacks/channelwood.cpp +++ b/engines/mohawk/myst_stacks/channelwood.cpp @@ -159,6 +159,16 @@ uint16 Channelwood::getVar(uint16 var) { return ((_state.waterValveStates & 0xe2) == 0x80) ? 1 : 0; case 30: // Door State return _doorOpened; + case 31: // Water flowing in pipe fork ? + // 0 -> keep sound. + // 1 -> not flowing. + // 2 --> flowing. + if ((_state.waterValveStates & 0xe2) == 0x82) // From left. + return 2; + if ((_state.waterValveStates & 0xf4) == 0xa0) // From right. + return 1; + + return 0; case 32: // Sound - Water Flowing in Pipe to Book Room Elevator return ((_state.waterValveStates & 0xf8) == 0xb0 && _state.pipeState) ? 1 : 0; case 33: // Channelwood Lower Walkway to Upper Walkway Spiral Stair Upper Door State -- cgit v1.2.3 From e0030a2aab4d78426e4250615b2c40b872f9bbb1 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Fri, 26 Aug 2011 20:43:31 +0200 Subject: MOHAWK: Fix incorrect cursor in D'ni (patch from P. Monnerat) --- engines/mohawk/myst_stacks/dni.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/mohawk/myst_stacks/dni.cpp b/engines/mohawk/myst_stacks/dni.cpp index cf28945c71..2ced265f02 100644 --- a/engines/mohawk/myst_stacks/dni.cpp +++ b/engines/mohawk/myst_stacks/dni.cpp @@ -106,7 +106,7 @@ void Dni::o_handPage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { if (_globals.ending == 1 && _vm->_video->getElapsedTime(atrus) > (uint)Audio::Timestamp(0, 6801, 600).msecs()) { _globals.ending = 2; _globals.heldPage = 0; - _vm->_cursor->setCursor(kDefaultMystCursor); + _vm->setMainCursor(kDefaultMystCursor); // Play movie end (atrus leaving) _vm->_video->setVideoBounds(atrus, Audio::Timestamp(0, 14813, 600), Audio::Timestamp(0xFFFFFFFF)); -- cgit v1.2.3 From ac53915d01e69b90fc6bf64dbce2606c9d4044fd Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Fri, 26 Aug 2011 20:49:36 +0200 Subject: MOHAWK: Stop the engine sound when Myst's generator voltage goes down to zero (patch from P. Monnerat) --- engines/mohawk/myst_stacks/myst.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index 66492d1200..b67b333a85 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -1350,8 +1350,10 @@ void Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint16 argc, uint16 * if (_state.generatorVoltage) _vm->_sound->replaceSoundMyst(8297); - else + else { _vm->_sound->replaceSoundMyst(9297); + _vm->_sound->stopBackgroundMyst(); + } } else { if (_generatorVoltage) _vm->_sound->replaceSoundMyst(6297); -- cgit v1.2.3 From cd45d63e064c5f45e911256de75c3efef156337d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 27 Aug 2011 17:41:12 +0200 Subject: SCUMM: Added some comments about special colors in Indy4 Amiga. --- engines/scumm/palette.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 4d53b2ec74..9977436dc6 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -382,6 +382,9 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) { _amigaFirstUsedColor = 80; for (; _amigaFirstUsedColor < 256; ++_amigaFirstUsedColor) { + // We look for the first used color here. If all color components are + // >= 252 the color seems to be unused. Check remapPaletteColor for + // the same behavior. if (ptr[_amigaFirstUsedColor * 3 + 0] <= 251 || ptr[_amigaFirstUsedColor * 3 + 1] <= 251 || ptr[_amigaFirstUsedColor * 3 + 2] <= 251) @@ -408,6 +411,10 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) { _roomPalette[i] = idx; _verbPalette[i] = idx + 32; } else { + // In all my tests it seems the colors 0 and 32 in + // _amigaPalette are in fact black. Thus 17 is probably black. + // For the room map the color 17 is 33 (17+16), for the verb + // map it is 65 (17+32). _roomPalette[i] = 0; _verbPalette[i] = 32; } @@ -418,6 +425,8 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) { } void ScummEngine::mapRoomPalette(int idx) { + // For Color 33 (which is in fact 17+16) see the special case in + // setAmigaPaletteFromPtr. if (idx >= 16 && idx < 48 && idx != 33) _roomPalette[idx] = idx - 16; else @@ -462,6 +471,8 @@ void ScummEngine::mapVerbPalette(int idx) { // the original we set up the verb palette at colors [32, 63]. // The original instead used two different palettes for the verb virtual // screen and all the rest. + // For Color 65 (which is in fact 17+32) see the special case in + // setAmigaPaletteFromPtr. if (idx >= 48 && idx < 80 && idx != 65) _verbPalette[idx] = idx - 16; else @@ -910,6 +921,8 @@ void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int } for (int i = startColor; i <= endColor; ++i) { + // Colors 33 (17+16) and 65 (17+32) will never get changed. For + // more information about these check setAmigaPaletteFromPtr. if (i >= 16 && i < 48 && i != 33) { remappedRoomColors = true; _amigaPalette[(i - 16) * 3 + 0] = _currentPalette[i * 3 + 0] >> 4; @@ -1204,6 +1217,8 @@ void ScummEngine::setPalColor(int idx, int r, int g, int b) { } if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + // Colors 33 (17+16) and 65 (17+32) will never get changed. For + // more information about these check setAmigaPaletteFromPtr. if (idx < 16 || idx >= _amigaFirstUsedColor) { mapRoomPalette(idx); mapVerbPalette(idx); -- cgit v1.2.3 From bc0e65baacedc5daebc55f0c16a83b5c1810ab88 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 18:01:06 +0200 Subject: CGE: remove jbw.h, some clean up --- engines/cge/bitmap.cpp | 1 - engines/cge/cge_main.cpp | 10 ++---- engines/cge/events.h | 30 +++++++++++++++- engines/cge/general.cpp | 2 +- engines/cge/general.h | 5 ++- engines/cge/jbw.h | 89 ------------------------------------------------ engines/cge/snail.h | 1 - engines/cge/talk.h | 1 - engines/cge/text.h | 5 +-- 9 files changed, 38 insertions(+), 106 deletions(-) delete mode 100644 engines/cge/jbw.h diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 02265f09bc..87bf49047f 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -26,7 +26,6 @@ */ #include "cge/bitmap.h" -#include "cge/jbw.h" #include "cge/vga13h.h" #include "cge/cge_main.h" #include "common/system.h" diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 5df7ab193e..8ac07b9f11 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -310,9 +310,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt _pocref[i] = (pocSpr) ? pocSpr->_ref : -1; } - warning("STUB: CGEEngine::syncGame Digital and Midi volume"); -// _volume[0] = _sndDrvInfo.Vol2._d; -// _volume[1] = _sndDrvInfo.Vol2._m; + // Skip Digital and Midi volumes, useless under ScummVM _volume[0] = 0; _volume[1] = 0; } @@ -329,9 +327,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt } else { // Loading game if (_soundOk == 1 && _mode == 0) { -// _sndDrvInfo.Vol2._d = _volume[0]; -// _sndDrvInfo.Vol2._m = _volume[1]; - warning("STUB: CGEEngine::syncGame Digital and Midi volume"); + // Skip Digital and Midi volumes, useless under ScummVM sndSetVolume(); } @@ -652,7 +648,7 @@ void CGEEngine::qGame() { saveSound(); // Write out the user's progress - saveGame(0, ""); + saveGame(0, Common::String("Automatic Savegame")); _vga->sunset(); _finis = true; diff --git a/engines/cge/events.h b/engines/cge/events.h index 9df09fdba5..9b7de9efd4 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -31,7 +31,6 @@ #include "common/events.h" #include "cge/game.h" #include "cge/talk.h" -#include "cge/jbw.h" #include "cge/vga13h.h" namespace CGE { @@ -52,6 +51,35 @@ enum EventMask { kEventKeyb = 1 << 7 }; +enum Keys { + NoKey = 0, CtrlA, CtrlB, CtrlC, CtrlD, CtrlE, CtrlF, CtrlG, CtrlH, + CtrlI, CtrlJ, CtrlK, CtrlL, CtrlM, CtrlN, CtrlO, CtrlP, + CtrlQ, CtrlR, CtrlS, CtrlT, CtrlU, CtrlV, CtrlW, CtrlX, + CtrlY, CtrlZ, + BSp = 8, Tab, + Enter = 13, + Eof = 26, Esc, + AltQ = 256 + 16, AltW, AltE, AltR, AltT, AltY, AltU, AltI, AltO, AltP, + AltA = 256 + 30, AltS, AltD, AltF, AltG, AltH, AltJ, AltK, AltL, + AltZ = 256 + 44, AltX, AltC, AltV, AltB, AltN, AltM, + F11 = 256 + 87, F12, + F1 = 256 + 59, F2, F3, F4, F5, F6, F7, F8, F9, F10, + ShiftTab = 256 + 15, + ShiftF1 = 256 + 84, ShiftF2, ShiftF3, ShiftF4, ShiftF5, + ShiftF6, ShiftF7, ShiftF8, ShiftF9, ShiftF10, + CtrlF1 = 256 + 94, CtrlF2, CtrlF3, CtrlF4, CtrlF5, + CtrlF6, CtrlF7, CtrlF8, CtrlF9, CtrlF10, + AltF1 = 256 + 104, AltF2, AltF3, AltF4, AltF5, + AltF6, AltF7, AltF8, AltF9, AltF10, + Home = 256 + 71, Up, PgUp, + Left = 256 + 75, Ctr, Right, + End = 256 + 79, Down, PgDn, Ins, Del, + CtrlLeft = 256 + 115, CtrlRight, CtrlEnd, CtrlPgDn, CtrlHome, + CtrlPgUp = 256 + 132, + MouseLeft = 512 + 1, MouseRight, + TwiceLeft = 512 + 256 + 1, TwiceRight +}; + class Keyboard { private: bool getKey(Common::Event &event, int &cgeCode); diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 68db71e918..c20da2466c 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -171,7 +171,7 @@ char *dwtom(uint32 val, char *str, int radix, int len) { } void sndSetVolume() { - warning("STUB: SNDSetVolume"); + // USeless for ScummVM } DataCk *loadWave(XFile *file) { diff --git a/engines/cge/general.h b/engines/cge/general.h index fbb5fc4c45..6a0bc13675 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -33,11 +33,14 @@ #include "common/random.h" #include "common/textconsole.h" #include "common/str.h" -#include "cge/jbw.h" namespace CGE { #define kCryptSeed 0xA5 +#define kMaxFile 128 +#define IsDigit(c) ((c) >= '0' && (c) <= '9') +#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) +#define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) struct Dac { uint8 _r; diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h deleted file mode 100644 index 490c79803a..0000000000 --- a/engines/cge/jbw.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Soltys source code - * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef __CGE_JBW__ -#define __CGE_JBW__ - -#include "common/scummsys.h" - -namespace CGE { - -#define kMaxFile 128 - -#define IsDigit(c) ((c) >= '0' && (c) <= '9') -#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) -#define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) - -enum Keys { - NoKey = 0, CtrlA, CtrlB, CtrlC, CtrlD, CtrlE, CtrlF, CtrlG, CtrlH, - CtrlI, CtrlJ, CtrlK, CtrlL, CtrlM, CtrlN, CtrlO, CtrlP, - CtrlQ, CtrlR, CtrlS, CtrlT, CtrlU, CtrlV, CtrlW, CtrlX, - CtrlY, CtrlZ, - BSp = 8, - Tab = 9, - Enter = 13, - Eof = 26, - Esc = 27, - AltQ = 256 + 16, AltW, AltE, AltR, AltT, AltY, AltU, AltI, AltO, AltP, - AltA = 256 + 30, AltS, AltD, AltF, AltG, AltH, AltJ, AltK, AltL, - AltZ = 256 + 44, AltX, AltC, AltV, AltB, AltN, AltM, - F11 = 256 + 87, F12, - F1 = 256 + 59, F2, F3, F4, F5, F6, F7, F8, F9, F10, - ShiftTab = 256 + 15, - ShiftF1 = 256 + 84, ShiftF2, ShiftF3, ShiftF4, ShiftF5, - ShiftF6, ShiftF7, ShiftF8, ShiftF9, ShiftF10, - CtrlF1 = 256 + 94, CtrlF2, CtrlF3, CtrlF4, CtrlF5, - CtrlF6, CtrlF7, CtrlF8, CtrlF9, CtrlF10, - AltF1 = 256 + 104, AltF2, AltF3, AltF4, AltF5, - AltF6, AltF7, AltF8, AltF9, AltF10, - Home = 256 + 71, - Up, - PgUp, - Left = 256 + 75, - Ctr, - Right, - End = 256 + 79, - Down, - PgDn, - Ins, - Del, - CtrlLeft = 256 + 115, - CtrlRight, - CtrlEnd, - CtrlPgDn, - CtrlHome, - CtrlPgUp = 256 + 132, - - MouseLeft = 512 + 1, - MouseRight, - TwiceLeft = 512 + 256 + 1, - TwiceRight -}; - -} // End of namespace CGE - -#endif diff --git a/engines/cge/snail.h b/engines/cge/snail.h index e478ad95ff..c2290da911 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -28,7 +28,6 @@ #ifndef __CGE_SNAIL__ #define __CGE_SNAIL__ -#include "cge/jbw.h" #include "cge/cge.h" namespace CGE { diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 2c546f3427..3591fc6fcc 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -29,7 +29,6 @@ #define __CGE_TALK__ #include "cge/general.h" -#include "cge/jbw.h" #include "cge/vga13h.h" namespace CGE { diff --git a/engines/cge/text.h b/engines/cge/text.h index d6845f4361..d4607f8f3c 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -29,14 +29,11 @@ #define __CGE_TEXT__ #include "cge/talk.h" -#include "cge/jbw.h" namespace CGE { -#define kSysTextMax 1000 - #define kSayExt ".SAY" - +#define kSysTextMax 1000 #define kTextNoMouse 95 #define kInfName 101 #define kSayName 102 -- cgit v1.2.3 From ad244d464cbae3fdef27caf948f33b8f7884bad9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 18:14:50 +0200 Subject: CGE: Set slot #0 as write protected as it's an automatic savegame --- engines/cge/detection.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index e944f2e9b7..383eb3933a 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -215,6 +215,11 @@ SaveStateDescriptor CGEMetaEngine::querySaveMetaInfos(const char *target, int sl desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay); desc.setSaveTime(header.saveHour, header.saveMinutes); + // Slot 0 is used for the 'automatic save on exit' save in Soltys, thus + // we prevent it from being deleted or overwritten by accident. + desc.setDeletableFlag(slot != 0); + desc.setWriteProtectedFlag(slot == 0); + return desc; } } -- cgit v1.2.3 From 4cb6c739a4cf75a0e072197845a54620db0b10b8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 19:09:13 +0200 Subject: CGE: Change a couple of static members to non static in Vga class --- engines/cge/cge.cpp | 2 -- engines/cge/cge_main.cpp | 16 ++++++------- engines/cge/snail.cpp | 8 +++---- engines/cge/vga13h.cpp | 59 +++++++++++++++++------------------------------- engines/cge/vga13h.h | 6 ++--- 5 files changed, 35 insertions(+), 56 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 0dbc1c8696..f471b63866 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -117,7 +117,6 @@ void CGEEngine::setup() { _console = new CGEConsole(this); // Initialise classes that have static members - Vga::init(); VFile::init(); Bitmap::init(); Talk::init(); @@ -178,7 +177,6 @@ CGEEngine::~CGEEngine() { Talk::deinit(); Bitmap::deinit(); VFile::deinit(); - Vga::deinit(); Cluster::init(this); // Remove all of our debug levels here diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 8ac07b9f11..a784b10c1d 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -545,7 +545,7 @@ void CGEEngine::showBak(int ref) { if (!spr) return; - Bitmap::_pal = Vga::_sysPal; + Bitmap::_pal = _vga->_sysPal; spr->expand(); Bitmap::_pal = NULL; spr->show(2); @@ -600,7 +600,7 @@ void CGEEngine::caveUp() { if (_shadow) { _vga->_showQ->remove(_shadow); - _shadow->makeXlat(glass(Vga::_sysPal, 204, 204, 204)); + _shadow->makeXlat(glass(_vga->_sysPal, 204, 204, 204)); _vga->_showQ->insert(_shadow, _hero); _shadow->_z = _hero->_z; } @@ -608,7 +608,7 @@ void CGEEngine::caveUp() { _vga->show(); _vga->copyPage(1, 0); _vga->show(); - _vga->sunrise(Vga::_sysPal); + _vga->sunrise(_vga->_sysPal); _dark = false; if (!_startupMode) _mouse->on(); @@ -689,7 +689,7 @@ System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { } void System::setPal() { - Dac *p = Vga::_sysPal + 256 - ArrayCount(_stdPal); + Dac *p = _vga->_sysPal + 256 - ArrayCount(_stdPal); for (uint i = 0; i < ArrayCount(_stdPal); i++) { p[i]._r = _stdPal[i]._r >> 2; p[i]._g = _stdPal[i]._g >> 2; @@ -813,7 +813,7 @@ void CGEEngine::switchColorMode() { _snail_->addCom(kSnSeq, 121, _vga->_mono = !_vga->_mono, NULL); keyClick(); - _vga->setColors(Vga::_sysPal, 64); + _vga->setColors(_vga->_sysPal, 64); } void CGEEngine::switchMusic() { @@ -1419,7 +1419,7 @@ bool CGEEngine::showTitle(const char *name) { if (_eventManager->_quitFlag) return false; - Bitmap::_pal = Vga::_sysPal; + Bitmap::_pal = _vga->_sysPal; BitmapPtr *LB = new BitmapPtr[2]; LB[0] = new Bitmap(name); LB[1] = NULL; @@ -1440,7 +1440,7 @@ bool CGEEngine::showTitle(const char *name) { _vga->copyPage(1, 2); _vga->copyPage(0, 1); selectPocket(-1); - _vga->sunrise(Vga::_sysPal); + _vga->sunrise(_vga->_sysPal); if (_mode < 2 && !_soundOk) { _vga->copyPage(1, 2); @@ -1481,7 +1481,7 @@ bool CGEEngine::showTitle(const char *name) { if (savegameExists(0)) { // Load the savegame loadGame(0, NULL, true); // only system vars - _vga->setColors(Vga::_sysPal, 64); + _vga->setColors(_vga->_sysPal, 64); _vga->update(); if (_flag[3]) { //flag FINIS _mode++; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 756c2675aa..7893b9d539 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -565,7 +565,7 @@ void CGEEngine::snSend(Sprite *spr, int val) { spr->_flags._slav = false; } else { if (spr->_ref % 1000 == 0) - Bitmap::_pal = Vga::_sysPal; + Bitmap::_pal = _vga->_sysPal; if (spr->_flags._back) spr->backShow(true); else @@ -856,7 +856,7 @@ void CGEEngine::snFlash(bool on) { if (on) { Dac *pal = (Dac *) malloc(sizeof(Dac) * kPalCount); if (pal) { - memcpy(pal, Vga::_sysPal, kPalSize); + memcpy(pal, _vga->_sysPal, kPalSize); for (int i = 0; i < kPalCount; i++) { register int c; c = pal[i]._r << 1; @@ -869,7 +869,7 @@ void CGEEngine::snFlash(bool on) { _vga->setColors(pal, 64); } } else - _vga->setColors(Vga::_sysPal, 64); + _vga->setColors(_vga->_sysPal, 64); _dark = false; } @@ -877,7 +877,7 @@ void CGEEngine::snLight(bool in) { debugC(1, kCGEDebugEngine, "CGEEngine::snLight(%s)", in ? "true" : "false"); if (in) - _vga->sunrise(Vga::_sysPal); + _vga->sunrise(_vga->_sysPal); else _vga->sunset(); _dark = !in; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 317cb415f8..d510b98f45 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -448,7 +448,6 @@ void Sprite::center() { void Sprite::show() { SprExt *e; -// asm cli // critic section... e = _ext; e->_x0 = e->_x1; e->_y0 = e->_y1; @@ -456,7 +455,6 @@ void Sprite::show() { e->_x1 = _x; e->_y1 = _y; e->_b1 = shp(); -// asm sti // ...done! if (!_flags._hide) { if (_flags._xlat) e->_b1->xShow(e->_x1, e->_y1); @@ -466,10 +464,10 @@ void Sprite::show() { } void Sprite::show(uint16 pg) { - Graphics::Surface *a = Vga::_page[1]; - Vga::_page[1] = Vga::_page[pg & 3]; + Graphics::Surface *a = _vga->_page[1]; + _vga->_page[1] = _vga->_page[pg & 3]; shp()->show(_x, _y); - Vga::_page[1] = a; + _vga->_page[1] = a; } void Sprite::hide() { @@ -673,45 +671,24 @@ Sprite *Queue::locate(int ref) { return NULL; } -//extern const char Copr[]; -Graphics::Surface *Vga::_page[4]; -Dac *Vga::_sysPal; +Vga::Vga() : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { + _oldColors = NULL; + _newColors = NULL; + _showQ = new Queue(true); + _spareQ = new Queue(false); + _sysPal = new Dac[kPalCount]; -void Vga::init() { for (int idx = 0; idx < 4; idx++) { _page[idx] = new Graphics::Surface(); _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - _sysPal = new Dac[kPalCount]; -} - -void Vga::deinit() { - for (int idx = 0; idx < 4; idx++) { - _page[idx]->free(); - delete _page[idx]; - } - delete[] _sysPal; -} - -Vga::Vga() - : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { - _oldColors = NULL; - _newColors = NULL; - _showQ = new Queue(true); - _spareQ = new Queue(false); - - bool std = true; for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { debugN(1, "%s\n", text); - std = false; } } - if (std) -// warning(Copr); - warning("TODO: Fix Copr"); _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount); _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount); @@ -743,6 +720,12 @@ Vga::~Vga() { delete _showQ; delete _spareQ; + delete[] _sysPal; + + for (int idx = 0; idx < 4; idx++) { + _page[idx]->free(); + delete _page[idx]; + } } void Vga::waitVR() { @@ -862,14 +845,14 @@ void Bitmap::xShow(int16 x, int16 y) { debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); + byte *destEndP = (byte *)_vga->_page[1]->pixels + (kScrWidth * kScrHeight); byte *lookupTable = _m; // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; planeCtr++) { - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -915,13 +898,13 @@ void Bitmap::show(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); + byte *destEndP = (byte *)_vga->_page[1]->pixels + (kScrWidth * kScrHeight); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; planeCtr++) { - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -979,8 +962,8 @@ void Bitmap::hide(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::hide(%d, %d)", x, y); for (int yp = y; yp < y + _h; yp++) { - const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); + const byte *srcP = (const byte *)_vga->_page[2]->getBasePtr(x, yp); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x, yp); Common::copy(srcP, srcP + _w, destP); } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 9649201021..e917e86a32 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -196,13 +196,11 @@ public: Queue *_showQ; Queue *_spareQ; int _mono; - static Graphics::Surface *_page[4]; - static Dac *_sysPal; + Graphics::Surface *_page[4]; + Dac *_sysPal; Vga(); ~Vga(); - static void init(); - static void deinit(); void getColors(Dac *tab); void setColors(Dac *tab, int lum); -- cgit v1.2.3 From 003c16920c1790152e64250b38613f36e39ec719 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 27 Aug 2011 19:57:45 +0200 Subject: SCUMM: Also save first used color beyond 80 in Indy4 Amiga palette. --- engines/scumm/palette.cpp | 23 +++++++++++++---------- engines/scumm/saveload.cpp | 9 +++++++++ engines/scumm/saveload.h | 2 +- engines/scumm/scumm.h | 1 + 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 9977436dc6..7a6be90f68 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -380,16 +380,7 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) { _colorUsedByCycle[i] = 0; } - _amigaFirstUsedColor = 80; - for (; _amigaFirstUsedColor < 256; ++_amigaFirstUsedColor) { - // We look for the first used color here. If all color components are - // >= 252 the color seems to be unused. Check remapPaletteColor for - // the same behavior. - if (ptr[_amigaFirstUsedColor * 3 + 0] <= 251 - || ptr[_amigaFirstUsedColor * 3 + 1] <= 251 - || ptr[_amigaFirstUsedColor * 3 + 2] <= 251) - break; - } + amigaPaletteFindFirstUsedColor(); for (int i = 0; i < 64; ++i) { _amigaPalette[i * 3 + 0] = _currentPalette[(i + 16) * 3 + 0] >> 4; @@ -424,6 +415,18 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) { setDirtyColors(0, 255); } +void ScummEngine::amigaPaletteFindFirstUsedColor() { + for (_amigaFirstUsedColor = 80; _amigaFirstUsedColor < 256; ++_amigaFirstUsedColor) { + // We look for the first used color here. If all color components are + // >= 252 the color seems to be unused. Check remapPaletteColor for + // the same behavior. + if (_currentPalette[_amigaFirstUsedColor * 3 + 0] <= 251 + || _currentPalette[_amigaFirstUsedColor * 3 + 1] <= 251 + || _currentPalette[_amigaFirstUsedColor * 3 + 2] <= 251) + break; + } +} + void ScummEngine::mapRoomPalette(int idx) { // For Color 33 (which is in fact 17+16) see the special case in // setAmigaPaletteFromPtr. diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index e0eba99cce..db151c2457 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -1357,6 +1357,15 @@ void ScummEngine::saveOrLoad(Serializer *s) { s->saveLoadArrayOf(_roomPalette, 256, 1, sleByte); s->saveLoadArrayOf(_verbPalette, 256, 1, sleByte); s->saveLoadArrayOf(_amigaPalette, 3 * 64, 1, sleByte); + + // Starting from version 86 we also save the first used color in + // the palette beyond the verb palette. For old versions we just + // look for it again, which hopefully won't cause any troubles. + if (s->getVersion() >= 86) { + s->saveLoadArrayOf(&_amigaFirstUsedColor, 1, 2, sleUint16); + } else { + amigaPaletteFindFirstUsedColor(); + } } else { warning("Save with old Indiana Jones 4 Amiga palette handling detected"); // We need to restore the internal state of the Amiga palette for Indy4 diff --git a/engines/scumm/saveload.h b/engines/scumm/saveload.h index 792a31d067..16c225d20e 100644 --- a/engines/scumm/saveload.h +++ b/engines/scumm/saveload.h @@ -47,7 +47,7 @@ namespace Scumm { * only saves/loads those which are valid for the version of the savegame * which is being loaded/saved currently. */ -#define CURRENT_VER 85 +#define CURRENT_VER 86 /** * An auxillary macro, used to specify savegame versions. We use this instead diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 0af8264a58..d9237b2b30 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -1092,6 +1092,7 @@ protected: // Indy4 Amiga specific uint16 _amigaFirstUsedColor; byte _amigaPalette[3 * 64]; + void amigaPaletteFindFirstUsedColor(); void mapRoomPalette(int idx); int remapRoomPaletteColor(int r, int g, int b); void mapVerbPalette(int idx); -- cgit v1.2.3 From d0e64ce4a3a30d3db6194f15320dac981a0c7a16 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 27 Aug 2011 19:58:36 +0200 Subject: SCUMM: Properly prefix player_towns.h include with scumm/. --- engines/scumm/saveload.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index db151c2457..3ab13df032 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -30,7 +30,7 @@ #include "scumm/charset.h" #include "scumm/imuse_digi/dimuse.h" #include "scumm/imuse/imuse.h" -#include "player_towns.h" +#include "scumm/player_towns.h" #include "scumm/he/intern_he.h" #include "scumm/object.h" #include "scumm/resource.h" -- cgit v1.2.3 From 20a8f7b364601b137cb6af7450eaf86cbe3a48d9 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 27 Aug 2011 11:35:31 -0400 Subject: NEWS: Mention AGOS now supports InstallShield cabinets --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 016c6379e8..91a3c85e7d 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,10 @@ For a more comprehensive changelog of the latest experimental code, see: AGI: - Implemented sound support for the DOS version of Winnie the Pooh in the Hundred Acre Wood. + AGOS: + - Implemented support for loading data directly from InstallShield + cabinets in The Feeble Files and Simon the Sorcerer's Puzzle Pack. + SCUMM: - Implemented PC Speaker support for SCUMM v5 games. - Fixed priority bug in iMuse. As a result the AdLib music should sound -- cgit v1.2.3 From dc9cca5f46c513da929561b7bee2f78909881626 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 23:54:18 +0200 Subject: CGE: Fix level when restoring a game --- engines/cge/cge_main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index a784b10c1d..f09b374b8a 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -224,6 +224,8 @@ Common::Error CGEEngine::loadGameState(int slot) { // Load the game loadGame(slot, NULL); + _lev = _oldLev; + _snail->addCom(kSnLevel, -1, _oldLev, &_cavLight); caveUp(); return Common::kNoError; @@ -331,7 +333,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt sndSetVolume(); } - if (! tiny) { // load sprites & pocket + if (!tiny) { // load sprites & pocket while (readStream->pos() < readStream->size()) { Sprite S(this, NULL); S.sync(s); @@ -350,7 +352,6 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt } } } - debugC(1, kCGEDebugEngine, "CGEEngine::saveSound()"); } bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header) { @@ -364,7 +365,8 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade // Read in the string header.saveName.clear(); char ch; - while ((ch = (char)in->readByte()) != '\0') header.saveName += ch; + while ((ch = (char)in->readByte()) != '\0') + header.saveName += ch; // Get the thumbnail header.thumbnail = Graphics::loadThumbnail(*in); -- cgit v1.2.3 From 12b6851276d8249ad499c54f25d0dd8e84998384 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 28 Aug 2011 00:35:00 +0200 Subject: CGE: Fix glitch in previous commit --- engines/cge/cge_main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index f09b374b8a..6aa3052399 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -224,7 +224,6 @@ Common::Error CGEEngine::loadGameState(int slot) { // Load the game loadGame(slot, NULL); - _lev = _oldLev; _snail->addCom(kSnLevel, -1, _oldLev, &_cavLight); caveUp(); -- cgit v1.2.3 From 4e83a49b0fe42de37827ecffe5a65e492e76ea06 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 27 Aug 2011 23:43:28 +0100 Subject: AGI: Fix bug #3398171: AGI: SQ1/SQ2: problem entering name Was introduced during refactoring to SCI-like opcode handling. Also restored original comments about opcode parameter differences between AGI versions. --- engines/agi/opcodes.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/agi/opcodes.cpp b/engines/agi/opcodes.cpp index c2cecefc52..d1baab93e1 100644 --- a/engines/agi/opcodes.cpp +++ b/engines/agi/opcodes.cpp @@ -288,7 +288,7 @@ AgiInstruction insV2[] = { { "status.line.on", "", &cmdStatusLineOn }, { "status.line.off", "", &cmdStatusLineOff }, { "set.string", "ns", &cmdSetString }, - { "get.string", "ns", &cmdGetString }, + { "get.string", "nsnnn", &cmdGetString }, { "word.to.string", "nn", &cmdWordToString }, { "parse", "n", &cmdParse }, { "get.num", "nv", &cmdGetNum }, @@ -307,7 +307,7 @@ AgiInstruction insV2[] = { { "program.control", "", &cmdProgramControl }, { "player.control", "", &cmdPlayerControl }, { "obj.status.v", "v", &cmdObjStatusF }, - { "quit", "n", &cmdQuit }, + { "quit", "n", &cmdQuit }, // 0 args for AGI version 2.089 { "show.mem", "", &cmdShowMem }, { "pause", "", &cmdPause }, { "echo.line", "", &cmdEchoLine }, @@ -324,16 +324,16 @@ AgiInstruction insV2[] = { { "reposition.to.v", "nvv", &cmdRepositionToF }, { "trace.on", "", &cmdTraceOn }, { "trace.info", "nnn", &cmdTraceInfo }, - { "print.at", "snnn", &cmdPrintAt }, + { "print.at", "snnn", &cmdPrintAt }, // 3 args for AGI versions before 2.440 { "print.at.v", "vnnn", &cmdPrintAtV }, { "discard.view.v", "v", &cmdDiscardView}, { "clear.text.rect", "nnnnn", &cmdClearTextRect }, { "set.upper.left", "nn", &cmdSetUpperLeft }, { "set.menu", "s", &cmdSetMenu }, - { "set.menu.member", "sn", &cmdSetMenuItem }, + { "set.menu.item", "sn", &cmdSetMenuItem }, { "submit.menu", "", &cmdSubmitMenu }, - { "enable.member", "n", &cmdEnableItem }, - { "disable.member", "n", &cmdDisableItem }, + { "enable.item", "n", &cmdEnableItem }, + { "disable.item", "n", &cmdDisableItem }, { "menu.input", "", &cmdMenuInput }, { "show.obj.v", "v", &cmdShowObjV }, { "open.dialogue", "", &cmdOpenDialogue }, @@ -349,12 +349,12 @@ AgiInstruction insV2[] = { { "hold.key", "", &cmdHoldKey }, { "set.pri.base", "n", &cmdSetPriBase }, { "discard.sound", "n", &cmdDiscardSound }, - { "hide.mouse", "", &cmdHideMouse }, + { "hide.mouse", "", &cmdHideMouse }, // 1 arg for AGI version 3.002.086 { "allow.menu", "n", &cmdAllowMenu }, { "show.mouse", "", &cmdShowMouse }, { "fence.mouse", "nnnn", &cmdFenceMouse }, { "mouse.posn", "vv", &cmdMousePosn }, - { "release.key", "", &cmdReleaseKey }, + { "release.key", "", &cmdReleaseKey }, // 2 args for at least the Amiga GR (v2.05 1989-03-09) using AGI 2.316 { "adj.ego.move.to.xy", "", &cmdAdjEgoMoveToXY } }; -- cgit v1.2.3 From a14a9bb9a22d356a04bbacc3880d36a7ec1a9c57 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 28 Aug 2011 00:48:53 +0200 Subject: CGE: Fix ending animation - Game is now completable --- engines/cge/cge_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 6aa3052399..8763cb9967 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1375,7 +1375,7 @@ void CGEEngine::runGame() { _keyboard->setClient(_sys); // main loop while (!_finis && !_eventManager->_quitFlag) { - if (_finis) + if (_flag[3]) _snail->addCom2(kSnExec, -1, 0, kQGame); mainLoop(); } -- cgit v1.2.3 From b3457144ed6a4002ea8b51ac93ba14047950c262 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 28 Aug 2011 10:40:23 +1000 Subject: SCUMM: Add basic support for setOffHeap resource flag in HE90+ games. --- engines/scumm/he/intern_he.h | 1 + engines/scumm/he/resource_he.cpp | 34 ++++++++++++++++++++++++++++++++++ engines/scumm/he/script_v90he.cpp | 2 +- engines/scumm/resource.cpp | 29 +++++++++++++++++++++++++++-- engines/scumm/resource.h | 9 +++++++-- 5 files changed, 70 insertions(+), 5 deletions(-) diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index f4df6571fa..cdc5faa084 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -458,6 +458,7 @@ protected: virtual void saveOrLoad(Serializer *s); virtual void readMAXS(int blockSize); + void setResourceOffHeap(int typeId, int resId, int val); virtual void processActors(); diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp index 39240e347f..42748d08ed 100644 --- a/engines/scumm/he/resource_he.cpp +++ b/engines/scumm/he/resource_he.cpp @@ -386,6 +386,40 @@ int ScummEngine_v72he::getSoundResourceSize(ResId id) { return size; } +void ScummEngine_v90he::setResourceOffHeap(int typeId, int resId, int val) { + debug(0, "setResourceOffHeap: type %d resId %d toggle %d", typeId, resId, val); + ResType type; + + switch (typeId) { + case 1: + type = rtRoom; + break; + case 2: + type = rtScript; + break; + case 3: + type = rtCostume; + break; + case 4: + type = rtSound; + break; + case 6: + type = rtCharset; + break; + case 19: + type = rtImage; + break; + default: + error("setResourceOffHeap: default case %d", typeId); + } + + if (val == 1) { + _res->setOffHeap(type, resId); + } else { + _res->setOnHeap(type, resId); + } +} + #endif } // End of namespace Scumm diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp index 66a0a34d16..877f8b239d 100644 --- a/engines/scumm/he/script_v90he.cpp +++ b/engines/scumm/he/script_v90he.cpp @@ -2358,7 +2358,7 @@ void ScummEngine_v90he::o90_kernelSetFunctions() { _wiz->_rectOverrideEnabled = false; break; case 714: - debug(5, "o90_kernelSetFunctions: case 714: type %d resId %d unk1 %d", args[1], args[2], args[3]); + setResourceOffHeap(args[1], args[2], args[3]); break; case 1492: // Remote start script function diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index 10301da3e3..8c34ed3626 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -47,7 +47,8 @@ enum { RF_USAGE = 0x7F, RF_USAGE_MAX = RF_USAGE, - RS_MODIFIED = 0x10 + RS_MODIFIED = 0x10, + RF_OFFHEAP = 0x40 }; @@ -938,6 +939,18 @@ void ResourceManager::unlock(ResType type, ResId idx) { _types[type][idx].unlock(); } +void ResourceManager::setOffHeap(ResType type, ResId idx) { + if (!validateResource("setOffHeap", type, idx)) + return; + _types[type][idx].setOffHeap(); +} + +void ResourceManager::setOnHeap(ResType type, ResId idx) { + if (!validateResource("setOnHeap", type, idx)) + return; + _types[type][idx].setOnHeap(); +} + bool ResourceManager::isLocked(ResType type, ResId idx) const { if (!validateResource("isLocked", type, idx)) return false; @@ -956,6 +969,18 @@ bool ResourceManager::Resource::isLocked() const { return (_flags & RF_LOCK) != 0; } +void ResourceManager::Resource::setOffHeap() { + _flags |= RF_OFFHEAP; +} + +void ResourceManager::Resource::setOnHeap() { + _flags &= ~RF_OFFHEAP; +} + +bool ResourceManager::Resource::isOffHeap() const { + return (_flags & RF_OFFHEAP) != 0; +} + bool ScummEngine::isResourceInUse(ResType type, ResId idx) const { if (!_res->validateResource("isResourceInUse", type, idx)) return false; @@ -1035,7 +1060,7 @@ void ResourceManager::expireResources(uint32 size) { while (idx-- > 0) { Resource &tmp = _types[type][idx]; byte counter = tmp.getResourceCounter(); - if (!tmp.isLocked() && counter >= best_counter && tmp._address && !_vm->isResourceInUse(type, idx)) { + if (!tmp.isLocked() && counter >= best_counter && tmp._address && !_vm->isResourceInUse(type, idx) && !tmp.isOffHeap()) { best_counter = counter; best_type = type; best_res = idx; diff --git a/engines/scumm/resource.h b/engines/scumm/resource.h index 2e8960717f..ddecca43a2 100644 --- a/engines/scumm/resource.h +++ b/engines/scumm/resource.h @@ -134,12 +134,15 @@ public: inline void setResourceCounter(byte counter); inline byte getResourceCounter() const; + // HE specific void lock(); void unlock(); bool isLocked() const; - void setModified(); bool isModified() const; + void setOffHeap(); + void setOnHeap(); + bool isOffHeap() const; }; /** @@ -188,12 +191,14 @@ public: bool isResourceLoaded(ResType type, ResId idx) const; + // HE Specific void lock(ResType type, ResId idx); void unlock(ResType type, ResId idx); bool isLocked(ResType type, ResId idx) const; - void setModified(ResType type, ResId idx); bool isModified(ResType type, ResId idx) const; + void setOffHeap(ResType type, ResId idx); + void setOnHeap(ResType type, ResId idx); /** * This method increments the _expireCounter, and if it overflows (which happens -- cgit v1.2.3 From fb41b96e96e450f11bfe4860b440052b83410e83 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 28 Aug 2011 11:39:05 +1000 Subject: SCUMM: setOffHeap uses resource status in HE90+ games. --- engines/scumm/resource.cpp | 52 +++++++++++++++++++++++----------------------- engines/scumm/resource.h | 6 ++++-- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index 8c34ed3626..f445a44ded 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -939,18 +939,6 @@ void ResourceManager::unlock(ResType type, ResId idx) { _types[type][idx].unlock(); } -void ResourceManager::setOffHeap(ResType type, ResId idx) { - if (!validateResource("setOffHeap", type, idx)) - return; - _types[type][idx].setOffHeap(); -} - -void ResourceManager::setOnHeap(ResType type, ResId idx) { - if (!validateResource("setOnHeap", type, idx)) - return; - _types[type][idx].setOnHeap(); -} - bool ResourceManager::isLocked(ResType type, ResId idx) const { if (!validateResource("isLocked", type, idx)) return false; @@ -969,18 +957,6 @@ bool ResourceManager::Resource::isLocked() const { return (_flags & RF_LOCK) != 0; } -void ResourceManager::Resource::setOffHeap() { - _flags |= RF_OFFHEAP; -} - -void ResourceManager::Resource::setOnHeap() { - _flags &= ~RF_OFFHEAP; -} - -bool ResourceManager::Resource::isOffHeap() const { - return (_flags & RF_OFFHEAP) != 0; -} - bool ScummEngine::isResourceInUse(ResType type, ResId idx) const { if (!_res->validateResource("isResourceInUse", type, idx)) return false; @@ -1018,18 +994,42 @@ void ResourceManager::setModified(ResType type, ResId idx) { _types[type][idx].setModified(); } +void ResourceManager::setOffHeap(ResType type, ResId idx) { + if (!validateResource("setOffHeap", type, idx)) + return; + _types[type][idx].setOffHeap(); +} + +void ResourceManager::setOnHeap(ResType type, ResId idx) { + if (!validateResource("setOnHeap", type, idx)) + return; + _types[type][idx].setOnHeap(); +} + bool ResourceManager::isModified(ResType type, ResId idx) const { if (!validateResource("isModified", type, idx)) return false; return _types[type][idx].isModified(); } +bool ResourceManager::Resource::isModified() const { + return (_status & RS_MODIFIED) != 0; +} + +bool ResourceManager::Resource::isOffHeap() const { + return (_status & RF_OFFHEAP) != 0; +} + void ResourceManager::Resource::setModified() { _status |= RS_MODIFIED; } -bool ResourceManager::Resource::isModified() const { - return (_status & RS_MODIFIED) != 0; +void ResourceManager::Resource::setOffHeap() { + _status |= RF_OFFHEAP; +} + +void ResourceManager::Resource::setOnHeap() { + _status &= ~RF_OFFHEAP; } void ResourceManager::expireResources(uint32 size) { diff --git a/engines/scumm/resource.h b/engines/scumm/resource.h index ddecca43a2..aa7f809b76 100644 --- a/engines/scumm/resource.h +++ b/engines/scumm/resource.h @@ -134,10 +134,11 @@ public: inline void setResourceCounter(byte counter); inline byte getResourceCounter() const; - // HE specific void lock(); void unlock(); bool isLocked() const; + + // HE specific void setModified(); bool isModified() const; void setOffHeap(); @@ -191,10 +192,11 @@ public: bool isResourceLoaded(ResType type, ResId idx) const; - // HE Specific void lock(ResType type, ResId idx); void unlock(ResType type, ResId idx); bool isLocked(ResType type, ResId idx) const; + + // HE Specific void setModified(ResType type, ResId idx); bool isModified(ResType type, ResId idx) const; void setOffHeap(ResType type, ResId idx); -- cgit v1.2.3 From 039805ad3bb1b87afe3d32d8b625afaebb1e9f2f Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 28 Aug 2011 16:40:03 +1000 Subject: AGOS: Fix regression when starting Personal Nightmare, or disabling AGOS2. --- engines/agos/detection.cpp | 2 -- engines/agos/res.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp index a14b660817..861aa08851 100644 --- a/engines/agos/detection.cpp +++ b/engines/agos/detection.cpp @@ -273,8 +273,6 @@ void AGOSEngine::loadArchives() { _archives.registerArchive(ag->fileName, ag->fileType); } } - - _archives.enableFallback(true); } #endif diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index fe7bcd62a9..0baae11e89 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -38,7 +38,7 @@ namespace AGOS { ArchiveMan::ArchiveMan() { - _fallBack = false; + _fallBack = true; } #ifdef ENABLE_AGOS2 -- cgit v1.2.3 From 2798c65d756e82db8eb4a58ca3db526215557333 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 28 Aug 2011 14:06:57 +0300 Subject: SCI: Fixed bug #3297883 - "SCI: LB1 (Amiga) - Intro stuck" --- engines/sci/sound/midiparser_sci.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp index f48a68dc66..ad7ba7ca36 100644 --- a/engines/sci/sound/midiparser_sci.cpp +++ b/engines/sci/sound/midiparser_sci.cpp @@ -480,11 +480,18 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) { info.basic.param2 = 0; if (info.channel() == 0xF) {// SCI special case if (info.basic.param1 != kSetSignalLoop) { - // at least in kq5/french&mac the first scene in the intro has a song that sets signal to 4 immediately - // on tick 0. Signal isn't set at that point by sierra sci and it would cause the castle daventry text to - // get immediately removed, so we currently filter it. - // Sierra SCI ignores them as well at that time - if ((_position._play_tick) || (info.delta)) { + // At least in kq5/french&mac the first scene in the intro has + // a song that sets signal to 4 immediately on tick 0. Signal + // isn't set at that point by sierra sci and it would cause the + // castle daventry text to get immediately removed, so we + // currently filter it. Sierra SCI ignores them as well at that + // time. However, this filtering should only be performed for + // SCI1 and newer games. Signalling is done differently in SCI0 + // though, so ignoring these signals in SCI0 games will result + // in glitches (e.g. the intro of LB1 Amiga gets stuck - bug + // #3297883). Refer to MusicEntry::setSignal() in sound/music.cpp. + if (_soundVersion <= SCI_VERSION_0_LATE || + _position._play_tick || info.delta) { _signalSet = true; _signalToSet = info.basic.param1; } -- cgit v1.2.3 From 722a9459fe65c6d129cdaf2bbe38b41195cc844f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Aug 2011 22:53:20 +1000 Subject: TSAGE: Added lots of original source names from debugger, further work on first game scene --- engines/tsage/blue_force/blueforce_logic.cpp | 13 ++++-- engines/tsage/blue_force/blueforce_scenes0.cpp | 36 ++++++++------- engines/tsage/blue_force/blueforce_scenes1.cpp | 4 +- engines/tsage/blue_force/blueforce_scenes3.cpp | 29 +++++++----- engines/tsage/blue_force/blueforce_ui.cpp | 26 +++++++---- engines/tsage/blue_force/blueforce_ui.h | 3 +- engines/tsage/core.cpp | 39 +++++++++++++--- engines/tsage/globals.cpp | 17 ++----- engines/tsage/globals.h | 63 ++++++++++++++++++++++---- 9 files changed, 156 insertions(+), 74 deletions(-) diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 60bbddbabc..9c7d66aadf 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -422,7 +422,7 @@ SceneExt::SceneExt(): Scene() { void SceneExt::postInit(SceneObjectList *OwnerList) { Scene::postInit(OwnerList); - if (BF_GLOBALS._v4CEA2) { + if (BF_GLOBALS._dayNumber) { // Blank out the bottom portion of the screen BF_GLOBALS._interfaceY = BF_INTERFACE_Y; @@ -441,7 +441,7 @@ void SceneExt::dispatch() { _timerList.dispatch(); if (_field37A) { - if ((--_field37A == 0) && BF_GLOBALS._v4CEA2) { + if ((--_field37A == 0) && BF_GLOBALS._dayNumber) { if (BF_GLOBALS._v4E238 && (BF_GLOBALS._v4CF9E == 1)) { warning("sub_1B052"); } @@ -494,8 +494,11 @@ void SceneHandlerExt::postInit(SceneObjectList *OwnerList) { SceneHandler::postInit(OwnerList); // Load the low end palette data - GLOBALS._scenePalette.loadPalette(2); - GLOBALS._scenePalette.refresh(); + BF_GLOBALS._scenePalette.loadPalette(2); + BF_GLOBALS._scenePalette.refresh(); + + // Setup the user interface + BF_GLOBALS._uiElements.setup(Common::Point(0, BF_INTERFACE_Y - 2)); } void SceneHandlerExt::process(Event &event) { @@ -548,8 +551,8 @@ void VisualSpeaker::proc12(Action *action) { } void VisualSpeaker::setText(const Common::String &msg) { - BF_GLOBALS._events.waitForPress(); _objectList.draw(); + BF_GLOBALS._sceneObjects->draw(); _sceneText._color1 = _color1; _sceneText._color2 = _color2; diff --git a/engines/tsage/blue_force/blueforce_scenes0.cpp b/engines/tsage/blue_force/blueforce_scenes0.cpp index f1b714ec6c..f33312494a 100644 --- a/engines/tsage/blue_force/blueforce_scenes0.cpp +++ b/engines/tsage/blue_force/blueforce_scenes0.cpp @@ -263,29 +263,31 @@ void Scene50::Tooltip::highlight(bool btnDown) { update(); if (btnDown) { - if ((BF_GLOBALS._bikiniHutState == 14) && BF_GLOBALS.getFlag(98)) + if ((BF_GLOBALS._bookmark == bCalledToDrunkStop) && BF_GLOBALS.getFlag(beenToJRDay2)) scene->_sceneNumber = 600; - else if (BF_GLOBALS._bikiniHutState == 5) + else if (BF_GLOBALS._bookmark == bBookedGreen) scene->_sceneNumber = 410; else { - BF_GLOBALS._v4CEF4 = _newSceneNumber; + BF_GLOBALS._driveToScene = _newSceneNumber; - switch (BF_GLOBALS._v4CEF2) { + switch (BF_GLOBALS._driveFromScene) { case 330: case 340: case 342: BF_GLOBALS._player.disableControl(); - if (_locationId != BF_GLOBALS._mapLocationId) { + BF_GLOBALS._mapLocationId = _locationId; + + if (BF_GLOBALS._driveToScene == 330) { scene->_sceneNumber = 330; } else { - scene->_sceneNumber = (BF_GLOBALS._v4CEA2 != 1) || (BF_GLOBALS._bikiniHutState < 1) || - (BF_GLOBALS._bikiniHutState >= 2) ? 342 : 340; + scene->_sceneNumber = (BF_GLOBALS._dayNumber != 1) || (BF_GLOBALS._bookmark < bStartOfGame) || + (BF_GLOBALS._bookmark >= bCalledToDomesticViolence) ? 342 : 340; } break; case 410: case 551: - if (BF_GLOBALS.getFlag((BF_GLOBALS._v4CEF2 == 410) ? 41 : 40)) { + if (BF_GLOBALS.getFlag((BF_GLOBALS._driveFromScene == 410) ? fSearchedTruck : didDrunk)) { BF_GLOBALS._mapLocationId = _locationId; BF_GLOBALS._player.disableControl(); scene->_sceneNumber = _newSceneNumber; @@ -298,7 +300,7 @@ void Scene50::Tooltip::highlight(bool btnDown) { case 300: if (_locationId == 1) { - BF_GLOBALS._v4CEF4 = 300; + BF_GLOBALS._driveToScene = 300; _newSceneNumber = 300; } // Deliberate fall through to default @@ -354,7 +356,7 @@ void Scene50::postInit(SceneObjectList *OwnerList) { _location5.set(Rect(383, 57, 402, 70), 380, CITY_HALL_JAIL, 32); _location7.set(Rect(128, 32, 143, 42), 800, JAMISON_RYAN, 128); _location9.set(Rect(349, 125, 359, 132), - (BF_GLOBALS._bikiniHutState == 13) || (BF_GLOBALS._bikiniHutState == 14) ? 551 : 550, + (BF_GLOBALS._bookmark == bInspectionDone) || (BF_GLOBALS._bookmark == bCalledToDrunkStop) ? 551 : 550, BIKINI_HUT, 16); _item.setBounds(Rect(0, 0, SCREEN_WIDTH * 2, SCREEN_HEIGHT)); @@ -424,7 +426,7 @@ void Scene50::remove() { void Scene50::signal() { if (_sceneMode == 1) { // Destination selected - if ((BF_GLOBALS._v4CEF2 == 551) && (_sceneNumber != BF_GLOBALS._v4CEF2)) { + if ((BF_GLOBALS._driveFromScene == 551) && (_sceneNumber != BF_GLOBALS._driveFromScene)) { BF_GLOBALS.setFlag(109); BF_GLOBALS.setFlag(115); BF_GLOBALS.setFlag(121); @@ -432,20 +434,20 @@ void Scene50::signal() { BF_GLOBALS.setFlag(133); } - if ((BF_GLOBALS._v4CEF2 == 410) && (_sceneNumber != BF_GLOBALS._v4CEF2)) { + if ((BF_GLOBALS._driveFromScene == 410) && (_sceneNumber != BF_GLOBALS._driveFromScene)) { BF_GLOBALS.setFlag(125); } - if ((BF_GLOBALS._v4CEF2 == 340) && (_sceneNumber != BF_GLOBALS._v4CEF2)) { + if ((BF_GLOBALS._driveFromScene == 340) && (_sceneNumber != BF_GLOBALS._driveFromScene)) { BF_GLOBALS.setFlag(123); } - if ((BF_GLOBALS._v4CEF2 == 380) && (_sceneNumber != BF_GLOBALS._v4CEF2)) { - if (BF_GLOBALS._bikiniHutState >= 4) + if ((BF_GLOBALS._driveFromScene == 380) && (_sceneNumber != BF_GLOBALS._driveFromScene)) { + if (BF_GLOBALS._bookmark >= bLauraToParamedics) BF_GLOBALS.setFlag(129); - if (BF_GLOBALS._bikiniHutState >= 6) + if (BF_GLOBALS._bookmark >= bStoppedFrankie) BF_GLOBALS.setFlag(131); - if (BF_GLOBALS._bikiniHutState == 3) { + if (BF_GLOBALS._bookmark == bArrestedGreen) { BF_GLOBALS._v4CEA8 = 19; _sceneNumber = 666; } diff --git a/engines/tsage/blue_force/blueforce_scenes1.cpp b/engines/tsage/blue_force/blueforce_scenes1.cpp index 650b63c24b..7cccb0d284 100644 --- a/engines/tsage/blue_force/blueforce_scenes1.cpp +++ b/engines/tsage/blue_force/blueforce_scenes1.cpp @@ -176,7 +176,7 @@ void Scene100::postInit(SceneObjectList *OwnerList) { _globals->_player.disableControl(); _index = 109; - if (BF_GLOBALS._v4CEA2 < 6) { + if (BF_GLOBALS._dayNumber < 6) { // Title loadScene(100); BF_GLOBALS._sound1.play(2); @@ -191,7 +191,7 @@ void Scene100::postInit(SceneObjectList *OwnerList) { void Scene100::signal() { ++_sceneMode; - if (BF_GLOBALS._v4CEA2 < 6) { + if (BF_GLOBALS._dayNumber < 6) { BF_GLOBALS._scenePalette.clearListeners(); BF_GLOBALS._scenePalette.loadPalette(100); BF_GLOBALS._sceneManager.changeScene(_index); diff --git a/engines/tsage/blue_force/blueforce_scenes3.cpp b/engines/tsage/blue_force/blueforce_scenes3.cpp index e49037abf9..42c5c5dcde 100644 --- a/engines/tsage/blue_force/blueforce_scenes3.cpp +++ b/engines/tsage/blue_force/blueforce_scenes3.cpp @@ -48,7 +48,7 @@ void Scene300::Object::startMover(CursorType action) { void Scene300::Object17::startMover(CursorType action) { if ((action != CURSOR_USE) || !BF_GLOBALS.getFlag(3)) { NamedObject::startMover(action); - } else if ((BF_GLOBALS._v4CEA2 != 2) || (BF_GLOBALS._bikiniHutState >= 12)) { + } else if ((BF_GLOBALS._dayNumber != 2) || (BF_GLOBALS._bookmark >= bEndDayOne)) { Scene300 *scene = (Scene300 *)BF_GLOBALS._sceneManager._scene; setAction(&scene->_action4); } else { @@ -249,10 +249,12 @@ void Scene300::postInit(SceneObjectList *OwnerList) { BF_GLOBALS._player._moveDiff = Common::Point(3, 1); BF_GLOBALS._player.disableControl(); + _object8.postInit(); + _object8.setVisage(301); _object8.setStrip(2); _object8.setPosition(Common::Point(300, 77)); - if ((BF_GLOBALS._v4CEA2 != 2) || (BF_GLOBALS._bikiniHutState < 12)) { + if ((BF_GLOBALS._dayNumber != 2) || (BF_GLOBALS._bookmark < bEndDayOne)) { _object17.postInit(); _object17.setVisage(301); _object17.setStrip(1); @@ -280,13 +282,14 @@ void Scene300::postInit(SceneObjectList *OwnerList) { //***DEBUG*** BF_GLOBALS.setFlag(2); -BF_GLOBALS._sceneManager._previousScene = 190; +BF_GLOBALS._sceneManager._previousScene = 315; // 190; BF_GLOBALS._player.setVisage(190); +BF_GLOBALS._player.setStrip(1); switch (BF_GLOBALS._sceneManager._previousScene) { case 50: case 60: - BF_GLOBALS.clearFlag(2); + BF_GLOBALS.clearFlag(onBike); if (BF_GLOBALS.getFlag(3)) { BF_GLOBALS._player.disableControl(); _sceneMode = 318; @@ -304,7 +307,7 @@ BF_GLOBALS._player.setVisage(190); BF_GLOBALS._player.setPosition(Common::Point(175, 50)); ADD_PLAYER_MOVER_THIS(BF_GLOBALS._player, 123, 71); - if ((BF_GLOBALS._v4CEA2 == 2) && (BF_GLOBALS._bikiniHutState < 12)) + if ((BF_GLOBALS._dayNumber == 2) && (BF_GLOBALS._bookmark < bEndDayOne)) setup(); } else if (!BF_GLOBALS.getFlag(3)) { BF_GLOBALS._player.disableControl(); @@ -318,8 +321,8 @@ BF_GLOBALS._player.setVisage(190); break; case 315: BF_GLOBALS._player.setPosition(Common::Point(305, 66)); - if ((BF_GLOBALS._v4CEA2 != 2) || (BF_GLOBALS._bikiniHutState >= 12)) { - BF_GLOBALS._player.setVisage(BF_GLOBALS.getFlag(3) ? 1304 : 303); + if ((BF_GLOBALS._dayNumber != 2) || (BF_GLOBALS._bookmark >= bEndDayOne)) { + BF_GLOBALS._player.setVisage(BF_GLOBALS.getFlag(onDuty) ? 1304 : 303); BF_GLOBALS._player.disableControl(); _sceneMode = 0; setAction(&_sequenceManager1, this, 306, &BF_GLOBALS._player, &_object8, NULL); @@ -344,10 +347,10 @@ void Scene300::signal() { switch (_sceneMode) { case 300: BF_GLOBALS._sound1.fadeSound(33); - BF_GLOBALS.clearFlag(2); + BF_GLOBALS.clearFlag(onBike); _sceneMode = 0; - if ((BF_GLOBALS._v4CEA2 != 1) || (BF_GLOBALS._bikiniHutState != 0)) { + if ((BF_GLOBALS._dayNumber != 1) || (BF_GLOBALS._bookmark != bNone)) { signal(); } else { _stripManager.start(3005, this); @@ -373,7 +376,7 @@ void Scene300::signal() { setAction(&_sequenceManager1, this, 303, &_object13, &_object1, NULL); break; case 305: - if ((BF_GLOBALS._v4CEA2 == 4) || (BF_GLOBALS._v4CEA2 == 5)) { + if ((BF_GLOBALS._dayNumber == 4) || (BF_GLOBALS._dayNumber == 5)) { _sceneMode = 0; setAction(&_action3); } else { @@ -407,7 +410,7 @@ void Scene300::signal() { BF_GLOBALS._sceneManager.changeScene(60); break; case 318: - BF_GLOBALS.clearFlag(2); + BF_GLOBALS.clearFlag(onBike); _sceneMode = 0; signal(); break; @@ -442,7 +445,7 @@ void Scene300::signal() { _object13.setAction(&_sequenceManager2, NULL, 313, &_object13, &_object17, NULL); _object14.setAction(&_sequenceManager3, this, 314, &_object14, &_object18, NULL); - BF_GLOBALS._bikiniHutState = 12; + BF_GLOBALS._bookmark = bEndDayOne; BF_GLOBALS._sound1.changeSound(33); break; case 2307: @@ -504,6 +507,8 @@ void Scene300::signal() { } void Scene300::process(Event &event) { + SceneExt::process(event); + if ((BF_GLOBALS._player._field8E != 0) && !_eventHandler && (event.mousePos.y < (BF_INTERFACE_Y - 1))) { Visage visage; diff --git a/engines/tsage/blue_force/blueforce_ui.cpp b/engines/tsage/blue_force/blueforce_ui.cpp index e27c744486..b455541dd4 100644 --- a/engines/tsage/blue_force/blueforce_ui.cpp +++ b/engines/tsage/blue_force/blueforce_ui.cpp @@ -83,13 +83,13 @@ void UIQuestion::setEnabled(bool flag) { void UIScore::postInit(SceneObjectList *OwnerList) { int xp = 266; - _digit3.setup(1, 6, 1, 266, 180, 255); + _digit3.setup(1, 6, 1, xp, 180, 255); xp += 7; - _digit2.setup(1, 6, 1, 266, 180, 255); + _digit2.setup(1, 6, 1, xp, 180, 255); xp += 7; - _digit1.setup(1, 6, 1, 266, 180, 255); + _digit1.setup(1, 6, 1, xp, 180, 255); xp += 7; - _digit0.setup(1, 6, 1, 266, 180, 255); + _digit0.setup(1, 6, 1, xp, 180, 255); } void UIScore::draw() { @@ -169,6 +169,11 @@ void UICollection::hide() { _visible = false; } +void UICollection::show() { + _visible = true; + draw(); +} + void UICollection::erase() { if (_clearScreen) { Rect tempRect(0, BF_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT); @@ -216,7 +221,7 @@ void UIElements::setup(const Common::Point &pt) { _slotStart = 0; _itemList.clear(); _scoreValue = 0; - _field820 = 1; + _active = true; UICollection::setup(pt); hide(); @@ -224,6 +229,7 @@ void UIElements::setup(const Common::Point &pt) { add(&_object1); // Set up the inventory slots + int xp = 0; for (int idx = 0; idx < 4; ++idx) { UIElement *item = NULL; switch (idx) { @@ -241,14 +247,16 @@ void UIElements::setup(const Common::Point &pt) { break; } - item->setup(9, 1, idx, idx * 63 + 2, 4, 255); + xp = idx * 63 + 2; + item->setup(9, 1, idx, xp, 4, 255); add(item); } // Setup bottom-right hand buttons - int xp = 62; + xp += 62; _question.setup(1, 4, 7, xp, 16, 255); _question.setEnabled(false); + add(&_question); xp += 21; _scrollLeft.setup(1, 4, 1, xp, 16, 255); @@ -275,7 +283,7 @@ void UIElements::add(UIElement *obj) { assert(_objList.size() < 12); _objList.push_back(obj); - obj->setPosition(Common::Point(_bounds.left + obj->_bounds.left, _bounds.top + obj->_bounds.top)); + obj->setPosition(Common::Point(_bounds.left + obj->_position.x, _bounds.top + obj->_position.y)); GfxSurface s = obj->getFrame(); s.draw(obj->_position); } @@ -326,7 +334,7 @@ void UIElements::updateInventory() { } } - if (_field820) + if (_active) draw(); } diff --git a/engines/tsage/blue_force/blueforce_ui.h b/engines/tsage/blue_force/blueforce_ui.h index 15e7a760d9..809701f83e 100644 --- a/engines/tsage/blue_force/blueforce_ui.h +++ b/engines/tsage/blue_force/blueforce_ui.h @@ -102,6 +102,7 @@ public: UICollection(); void setup(const Common::Point &pt); void hide(); + void show(); void resetClear(); void draw(); }; @@ -119,7 +120,7 @@ public: UIInventoryScroll _scrollLeft, _scrollRight; ASound _sound; int _itemCount, _slotStart, _scoreValue; - bool _field820; + bool _active; Common::Array _itemList; virtual void postInit(SceneObjectList *OwnerList = NULL) { error("Wrong init() called"); } diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 3a489e0024..38fd668fac 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1786,6 +1786,8 @@ SceneObject::SceneObject() : SceneHotspot() { _frameChange = 0; _visage = 0; + _strip = 0; + _frame = 0; } SceneObject::SceneObject(const SceneObject &so) : SceneHotspot() { @@ -2305,10 +2307,6 @@ void SceneObject::removeObject() { _globals->_sceneItems.remove(this); _globals->_sceneObjects->remove(this); - if (_visage) { - _visage = 0; - } - if (_objectWrapper) { _objectWrapper->remove(); _objectWrapper = NULL; @@ -2710,8 +2708,8 @@ void SceneText::synchronize(Serializer &s) { /*--------------------------------------------------------------------------*/ Visage::Visage() { - _resNum = 0; - _rlbNum = 0; + _resNum = -1; + _rlbNum = -1; _data = NULL; } @@ -2738,7 +2736,27 @@ void Visage::setVisage(int resNum, int rlbNum) { _resNum = resNum; _rlbNum = rlbNum; DEALLOCATE(_data); - _data = _resourceManager->getResource(RES_VISAGE, resNum, rlbNum); + + if (_vm->getGameID() == GType_Ringworld) { + // In Ringworld, we immediately get the data + _data = _resourceManager->getResource(RES_VISAGE, resNum, rlbNum); + } else { + // Blue Force has an extra indirection via a visage index file + byte *indexData = _resourceManager->getResource(RES_VISAGE, resNum, 9999); + if (rlbNum == 0) + rlbNum = 1; + + // Get the flags/rlbNum to use + uint32 flags = READ_LE_UINT32(indexData + (rlbNum - 1) * 4 + 2); + + if (flags & 0xC0000000) { + // TODO: See whether rest of flags dword is needed + rlbNum = (int)(flags & 0xff); + } + + _data = _resourceManager->getResource(RES_VISAGE, resNum, rlbNum); + } + assert(_data); } } @@ -2787,6 +2805,10 @@ void Player::disableControl() { _canWalk = false; _uiEnabled = false; _globals->_events.setCursor(CURSOR_NONE); + _field8E = 0; + + if ((_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) + BF_GLOBALS._uiElements.hide(); } void Player::enableControl() { @@ -2805,6 +2827,9 @@ void Player::enableControl() { _globals->_events.setCursor(CURSOR_WALK); break; } + + if ((_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) + BF_GLOBALS._uiElements.show(); } void Player::process(Event &event) { diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index 52bd42fc5c..f8b42ec604 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -186,18 +186,17 @@ namespace BlueForce { BlueForceGlobals::BlueForceGlobals(): Globals() { _interfaceY = 0; _v51C44 = 1; - _v4CEA2 = 0; + _dayNumber = 1; _v4CEA4 = 0; _v4CEA8 = 0; - _v4CEF2 = 0; - _v4CEF4 = 0; + _driveFromScene = 0; + _driveToScene = 0; _v4CF9E = 0; _v4E238 = 0; _v501FC = 0; _v51C42 = 0; - _bikiniHutState = 0; + _bookmark = bNone; _mapLocationId = 1; - Common::set_to(_globalFlags, _globalFlags + 12, 0); } void BlueForceGlobals::synchronize(Serializer &s) { @@ -205,14 +204,6 @@ void BlueForceGlobals::synchronize(Serializer &s) { error("Sync variables"); } -bool BlueForceGlobals::getFlag(int v) { - return _globalFlags[v / 8] & (1 << (v % 8)); -} - -void BlueForceGlobals::setFlag(int v) { - _globalFlags[v / 8] |= 1 << (v % 8); -} - } // end of namespace BlueForce } // end of namespace TsAGE diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index f5d4aaa16f..c5324c38cd 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -111,31 +111,78 @@ namespace BlueForce { using namespace TsAGE; +enum Bookmark { + bNone, + bStartOfGame, bCalledToDomesticViolence, bArrestedGreen, bLauraToParamedics, + bBookedGreen, bStoppedFrankie, bBookedFrankie, bBookedFrankieEvidence, + bEndOfWorkDayOne, bTalkedToGrannyAboutSkipsCard, bLyleStoppedBy, bEndDayOne, + bInspectionDone, bCalledToDrunkStop, bArrestedDrunk, bEndDayTwo, + bFlashBackOne, bFlashBackTwo, bFlashBackThree, bDroppedOffLyle, bEndDayThree, + bDoneWithIsland, bDoneAtLyles, bEndDayFour, bInvestigateBoat, bFinishedWGreen, + bAmbushed, bAmbushOver, bEndOfGame +}; + +enum Flag { + JAKE_FILE_COPIED, gunClean, onBike, onDuty, fShowedIdToKate, fLateToMarina, + fCalledBackup, fWithLyle, gunDrawn, fBackupArrived340, fBriefedBackup, + fGotAllSkip340, fToldToLeave340, fBackupIn350, fNetInBoat, fForbesWaiting, + fWithCarter, fTalkedToTony, fMugOnKate, takenWeasel, gotTrailer450, + showEugeneNapkin, showRapEugene, fMgrCallsWeasel, fCarterMetLyle, + fGunLoaded, fLoadedSpare, showEugeneID, fRandomShot350, examinedFile810, + shownLyleCrate1, shownLyleRapsheet, shownLyleDisk, shownLylePO, + fCanDrawGun, fGotAutoWeapon, fGotBulletsFromDash, fShotSuttersDesk, + greenTaken, fLateToDrunkStop, didDrunk, fSearchedTruck, seenFolder, + showMugAround, frankInJail, fTalkedCarterDay3, fDecryptedBluePrints, + fTalkedToDrunkInCar, fToldLyleOfSchedule, fTalkedShooterNoBkup, + fTalkedDriverNoBkup, fDriverOutOfTruck, readGreenRights, readFrankRights, + talkedToHarrisAboutDrunk, unlockBoat, fShootGoon, fBlowUpGoon, + fTalkedToBarry, fTalkedToLarry, fLeftTraceIn920, fLeftTraceIn900, + fBackupAt340, fShotNicoIn910, fGotPointsForTktBook, fGotPointsForMCard, + fShowedBluePrint, fGotPointsForPunch, fGotPointsForBox, fGotPointsForBank, + fGotPointsForCombo, fGotPointsForCoin, fGotPointsForCPU, fGotPointsForBoots, + fGotPointsForCrate, fGotPointsForBlackCord, fGotPointsForGeneratorPlug, + fGotPointsForFuseBoxPlug, fGotPointsForStartGenerator, fGotPointsForLightsOn, + fGotPointsForOpeningDoor, fGotPointsForClosingDoor, fGotPointsForLightsOff, + fGotPointsForGeneratorOff, fGotPointsForCordOnForklift, fGotPointsForCuffingNico, + fGotPointsForCuffingDA, fGotPointsForSearchingNico, fGotPointsForSearchingDA, + fLeftTraceIn910, fBookedGreenEvidence, fGotPointsForCleaningGun, + fGotPointsForMemo, fGotPointsForFBI, fTookTrailerAmmo, fAlertedGreen355, + fGotGreen355fTalkedToGrannyDay3, shownFax, beenToJRDay2, shownLyleCrate1Day1, + fLyleOnIsland, iWasAmbushed, fGangInCar, fArrivedAtGangStop, ticketVW, + f1015Marina, fCan1015Marina, f1015Frankie, fCan1015Frankie, f1015Drunk, + fCan1015Drunk, f1027Marina, fCan1027Marina, f1027Frankie, fCan1027Frankie, + f1027Drunk, fCan1027Drunk, f1035Marina, fCan1035Marina, f1035Frankie, + fCan1035Frankie, f1035Drunk, fCan1035Drunk, f1097Marina, fCan1097Marina, + f1097Frankie, fCan1097Frankie, f1097Drunk, fCan1097Drunk, f1098Marina, + fCan1098Marina, f1098Frankie, fCan1098Frankie, f1098Drunk, fCan1098Drunk, + fCuffedFrankie, fGotPointsForTrapDog, fGotPointsForUnlockGate, + fGotPointsForUnlockWarehouse, fGotPointsForLockWarehouse, fGotPointsForLockGate, + fGotPointsForFreeDog, fGotPointsForWhistleDog, fGivenNapkin, fCan1004Marina, + fCan1004Drunk, fHasLeftDrunk, fHasDrivenFromDrunk, fCrateOpen, fSawGuns, + hookPoints +}; + class BlueForceGlobals: public Globals { public: ASoundExt _sound1, _sound2, _sound3; UIElements _uiElements; - int _v4CEA2; + int _dayNumber; int _v4CEA4; int _v4CEA8; - int _v4CEF2; - int _v4CEF4; + int _driveFromScene; + int _driveToScene; int _v4CF9E; int _v4E238; int _v501FC; int _v51C42; int _v51C44; int _interfaceY; - int _bikiniHutState; + Bookmark _bookmark; int _mapLocationId; - uint8 _globalFlags[12]; BlueForceGlobals(); virtual Common::String getClassName() { return "BFGlobals"; } virtual void synchronize(Serializer &s); - - void setFlag(int v); - bool getFlag(int v); }; } // End of namespace BlueForce -- cgit v1.2.3 From 5b25fc3e25389c8d44b05bb92d514229f595b627 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 27 Aug 2011 01:08:48 +0200 Subject: GOB: Fix language inconsistencies in Geisha --- engines/gob/game.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 7b43e9c4d7..502a440005 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -583,7 +583,11 @@ void Game::playTot(int16 function) { WRITE_VAR(13, _vm->_global->_useMouse); WRITE_VAR(14, _vm->_global->_soundFlags); WRITE_VAR(15, _vm->_global->_fakeVideoMode); - WRITE_VAR(16, _vm->_global->_language); + + if (_vm->getGameType() == kGameTypeGeisha) + WRITE_VAR(57, _vm->_global->_language); + else + WRITE_VAR(16, _vm->_global->_language); // WORKAROUND: Inca2 seems to depend on that variable to be cleared if (_vm->getGameType() == kGameTypeInca2) -- cgit v1.2.3 From 8c69d64678361420fc1e51632cd79b29fb3128f3 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 28 Aug 2011 21:40:09 +0200 Subject: GOB: Fix a potential input box bug --- engines/gob/hotspots.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp index f3647af76e..1a2f4b2769 100644 --- a/engines/gob/hotspots.cpp +++ b/engines/gob/hotspots.cpp @@ -1348,12 +1348,12 @@ void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs, inputs[inputCount].str = 0; if ((type >= kTypeInput2NoLeave) && (type <= kTypeInput3Leave)) { - uint16 length = _vm->_game->_script->readUint16(); + inputs[inputCount].length = _vm->_game->_script->readUint16(); inputs[inputCount].str = (const char *)(_vm->_game->_script->getData() + _vm->_game->_script->pos()); - _vm->_game->_script->skip(length); + _vm->_game->_script->skip(inputs[inputCount].length); } if (left == 0xFFFF) { -- cgit v1.2.3 From fcadd5a56d2ed1b51df9106a7703aa6a50dada8d Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 28 Aug 2011 21:40:45 +0200 Subject: GOB: Fix Geisha's hotspot checks --- engines/gob/hotspots.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp index 1a2f4b2769..96b1efbcf1 100644 --- a/engines/gob/hotspots.cpp +++ b/engines/gob/hotspots.cpp @@ -775,7 +775,8 @@ uint16 Hotspots::check(uint8 handleMouse, int16 delay, uint16 &id, uint16 &index _vm->_draw->blitCursor(); - if ((key != _currentKey) && (_vm->getGameType() != kGameTypeFascination)) + if ((key != _currentKey) && (_vm->getGameType() != kGameTypeFascination) && + (_vm->getGameType() != kGameTypeGeisha)) // If the hotspot changed, leave the old one // Code not present in Fascination executables leave(_currentIndex); -- cgit v1.2.3 From a8d6b92b5a02d582e34d1249d973a9273909db4c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 29 Aug 2011 00:29:22 +0200 Subject: CGE: Little cleanup of the English data file and update the detection --- engines/cge/detection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index 383eb3933a..5e74166222 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -79,8 +79,8 @@ static const ADGameDescription gameDescriptions[] = { { "soltys", "", { - {"vol.cat", 0, "bfea076fee47b8d64fdf213e56c60911", 50176}, - {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8427396}, + {"vol.cat", 0, "bd08969b5f1acea0f92d195f750c17d5", 50176}, + {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8428832}, AD_LISTEND }, Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE -- cgit v1.2.3 From dfe9fc05aabfb6097ef580e5fba42fda8e7cb098 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 28 Aug 2011 23:50:07 +0200 Subject: GOB: Implement saving/loading for Geisha --- engines/gob/gob.cpp | 1 + engines/gob/inter.h | 2 + engines/gob/inter_geisha.cpp | 97 ++++++++++++++-- engines/gob/module.mk | 1 + engines/gob/save/saveload.h | 54 +++++++++ engines/gob/save/saveload_geisha.cpp | 215 +++++++++++++++++++++++++++++++++++ 6 files changed, 359 insertions(+), 11 deletions(-) create mode 100644 engines/gob/save/saveload_geisha.cpp diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 7bb7928406..51a117b7ec 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -422,6 +422,7 @@ bool GobEngine::initGameParts() { _map = new Map_v1(this); _goblin = new Goblin_v1(this); _scenery = new Scenery_v1(this); + _saveLoad = new SaveLoad_Geisha(this, _targetName.c_str()); break; case kGameTypeFascination: diff --git a/engines/gob/inter.h b/engines/gob/inter.h index 84180f407d..764c7bf246 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -348,6 +348,8 @@ protected: void oGeisha_goblinFunc(OpFuncParams ¶ms); void oGeisha_loadSound(OpFuncParams ¶ms); void oGeisha_checkData(OpFuncParams ¶ms); + void oGeisha_readData(OpFuncParams ¶ms); + void oGeisha_writeData(OpFuncParams ¶ms); void oGeisha_gamePenetration(OpGobParams ¶ms); void oGeisha_gameDiving(OpGobParams ¶ms); diff --git a/engines/gob/inter_geisha.cpp b/engines/gob/inter_geisha.cpp index 658f2346f4..e547285f86 100644 --- a/engines/gob/inter_geisha.cpp +++ b/engines/gob/inter_geisha.cpp @@ -21,6 +21,10 @@ */ #include "common/endian.h" +#include "common/str.h" +#include "common/translation.h" + +#include "gui/message.h" #include "gob/gob.h" #include "gob/inter.h" @@ -30,6 +34,7 @@ #include "gob/game.h" #include "gob/draw.h" #include "gob/video.h" +#include "gob/save/saveload.h" #include "gob/sound/sound.h" #include "gob/sound/sounddesc.h" @@ -54,6 +59,8 @@ void Inter_Geisha::setupOpcodesFunc() { OPCODEFUNC(0x25, oGeisha_goblinFunc); OPCODEFUNC(0x3A, oGeisha_loadSound); OPCODEFUNC(0x3F, oGeisha_checkData); + OPCODEFUNC(0x4D, oGeisha_readData); + OPCODEFUNC(0x4E, oGeisha_writeData); OPCODEGOB(0, oGeisha_gamePenetration); OPCODEGOB(1, oGeisha_gameDiving); @@ -114,20 +121,88 @@ int16 Inter_Geisha::loadSound(int16 slot) { } void Inter_Geisha::oGeisha_checkData(OpFuncParams ¶ms) { - const char *file = _vm->_game->_script->evalString(); - int16 varOff = _vm->_game->_script->readVarIndex(); + Common::String file = _vm->_game->_script->evalString(); + int16 varOff = _vm->_game->_script->readVarIndex(); + + file.toLowercase(); + if (file.hasSuffix(".0ot")) + file.setChar('t', file.size() - 3); + + bool exists = false; + + SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file.c_str()); + if (mode == SaveLoad::kSaveModeNone) { + + exists = _vm->_dataIO->hasFile(file); + if (!exists) + warning("File \"%s\" not found", file.c_str()); + + } else if (mode == SaveLoad::kSaveModeSave) + exists = _vm->_saveLoad->getSize(file.c_str()) >= 0; + else if (mode == SaveLoad::kSaveModeExists) + exists = true; + + WRITE_VAR_OFFSET(varOff, exists ? 50 : (uint32)-1); +} + +void Inter_Geisha::oGeisha_readData(OpFuncParams ¶ms) { + const char *file = _vm->_game->_script->evalString(); + + uint16 dataVar = _vm->_game->_script->readVarIndex(); + + debugC(2, kDebugFileIO, "Read from file \"%s\" (%d)", file, dataVar); + + WRITE_VAR(1, 1); + + SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file); + if (mode == SaveLoad::kSaveModeSave) { + + if (!_vm->_saveLoad->load(file, dataVar, 0, 0)) { + + GUI::MessageDialog dialog(_("Failed to load game state from file.")); + dialog.runModal(); + + } else + WRITE_VAR(1, 0); + + return; + + } else if (mode == SaveLoad::kSaveModeIgnore) { + WRITE_VAR(1, 0); + return; + } + + warning("Attempted to read from file \"%s\"", file); +} + +void Inter_Geisha::oGeisha_writeData(OpFuncParams ¶ms) { + const char *file = _vm->_game->_script->evalString(); + + int16 dataVar = _vm->_game->_script->readVarIndex(); + int32 size = _vm->_game->_script->readValExpr(); + + debugC(2, kDebugFileIO, "Write to file \"%s\" (%d, %d bytes)", file, dataVar, size); + + WRITE_VAR(1, 1); + + SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file); + if (mode == SaveLoad::kSaveModeSave) { + + if (!_vm->_saveLoad->save(file, dataVar, size, 0)) { + + GUI::MessageDialog dialog(_("Failed to save game state to file.")); + dialog.runModal(); - Common::String fileName(file); + } else + WRITE_VAR(1, 0); - fileName.toLowercase(); - if (fileName.hasSuffix(".0ot")) - fileName.setChar('t', fileName.size() - 3); + } else if (mode == SaveLoad::kSaveModeIgnore) { + WRITE_VAR(1, 0); + return; + } else if (mode == SaveLoad::kSaveModeNone) + warning("Attempted to write to file \"%s\"", file); - if (!_vm->_dataIO->hasFile(fileName)) { - warning("File \"%s\" not found", fileName.c_str()); - WRITE_VAR_OFFSET(varOff, (uint32) -1); - } else - WRITE_VAR_OFFSET(varOff, 50); // "handle" between 50 and 128 = in archive + WRITE_VAR(1, 0); } void Inter_Geisha::oGeisha_gamePenetration(OpGobParams ¶ms) { diff --git a/engines/gob/module.mk b/engines/gob/module.mk index b85c387734..0300bcc3f0 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -77,6 +77,7 @@ MODULE_OBJS := \ save/saveload_v4.o \ save/saveload_v6.o \ save/saveload_v7.o \ + save/saveload_geisha.o \ save/saveload_fascin.o \ save/saveload_inca2.o \ save/saveload_playtoons.o \ diff --git a/engines/gob/save/saveload.h b/engines/gob/save/saveload.h index 4d51a5b51c..66b3482bac 100644 --- a/engines/gob/save/saveload.h +++ b/engines/gob/save/saveload.h @@ -71,6 +71,60 @@ protected: virtual const char *getDescription(const char *fileName) const; }; +/** Save/Load class for Geisha. */ +class SaveLoad_Geisha : public SaveLoad { +public: + SaveLoad_Geisha(GobEngine *vm, const char *targetName); + virtual ~SaveLoad_Geisha(); + + SaveMode getSaveMode(const char *fileName) const; + +protected: + static const uint32 kSlotCount = 7; + static const uint32 kSlotSize = 44; + + static const uint32 kSaveFileSize = kSlotCount * kSlotSize; + + struct SaveFile { + const char *sourceName; + SaveMode mode; + SaveHandler *handler; + const char *description; + }; + + /** Handles the save slots. */ + class GameHandler : public SaveHandler { + public: + GameHandler(GobEngine *vm, const Common::String &target); + ~GameHandler(); + + int32 getSize(); + bool load(int16 dataVar, int32 size, int32 offset); + bool save(int16 dataVar, int32 size, int32 offset); + + private: + /** Slot file construction. */ + class File : public SlotFileIndexed { + public: + File(GobEngine *vm, const Common::String &base); + ~File(); + + int getSlot(int32 offset) const; + int getSlotRemainder(int32 offset) const; + }; + + File _file; + }; + + static SaveFile _saveFiles[]; + + SaveHandler *getHandler(const char *fileName) const; + const char *getDescription(const char *fileName) const; + + const SaveFile *getSaveFile(const char *fileName) const; + SaveFile *getSaveFile(const char *fileName); +}; + /** Save/Load class for Gobliins 2, Ween: The Prophecy and Bargon Attack. */ class SaveLoad_v2 : public SaveLoad { public: diff --git a/engines/gob/save/saveload_geisha.cpp b/engines/gob/save/saveload_geisha.cpp new file mode 100644 index 0000000000..3414c12dda --- /dev/null +++ b/engines/gob/save/saveload_geisha.cpp @@ -0,0 +1,215 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "gob/save/saveload.h" +#include "gob/save/saveconverter.h" +#include "gob/inter.h" +#include "gob/variables.h" + +namespace Gob { + +SaveLoad_Geisha::SaveFile SaveLoad_Geisha::_saveFiles[] = { + {"save.inf", kSaveModeSave, 0, "savegame"} +}; + + +SaveLoad_Geisha::GameHandler::File::File(GobEngine *vm, const Common::String &base) : + SlotFileIndexed(vm, SaveLoad_Geisha::kSlotCount, base, "s") { + +} + +SaveLoad_Geisha::GameHandler::File::~File() { +} + +int SaveLoad_Geisha::GameHandler::File::getSlot(int32 offset) const { + return 0; +} + +int SaveLoad_Geisha::GameHandler::File::getSlotRemainder(int32 offset) const { + return 0; +} + + +SaveLoad_Geisha::GameHandler::GameHandler(GobEngine *vm, const Common::String &target) : + SaveHandler(vm), _file(vm, target) { + +} + +SaveLoad_Geisha::GameHandler::~GameHandler() { +} + +int32 SaveLoad_Geisha::GameHandler::getSize() { + if (_file.getSlotMax() == 0) + return -1; + + return SaveLoad_Geisha::kSaveFileSize; +} + +bool SaveLoad_Geisha::GameHandler::load(int16 dataVar, int32 size, int32 offset) { + if ((size != 0) || (offset != 0)) { + warning("Invalid loading procedure: %d, %d, %d", dataVar, size, offset); + return false; + } + + memset(_vm->_inter->_variables->getAddressOff8(dataVar), 0, SaveLoad_Geisha::kSaveFileSize); + + for (uint32 slot = 0; slot < SaveLoad_Geisha::kSlotCount; + slot++, dataVar += SaveLoad_Geisha::kSlotSize) { + + if (!_file.exists(slot)) + continue; + + Common::String slotFile = _file.build(slot); + if (slotFile.empty()) + return false; + + SaveReader reader(2, slot, slotFile); + if (!reader.load()) { + warning("Save slot %d contains corrupted save", slot); + continue; + } + + SavePartInfo info(20, (uint32) _vm->getGameType(), 0, + _vm->getEndianness(), _vm->_inter->_variables->getSize()); + SavePartVars vars(_vm, SaveLoad_Geisha::kSlotSize); + + if (!reader.readPart(0, &info) || !reader.readPart(1, &vars)) { + warning("Save slot %d contains corrupted save", slot); + continue; + } + + if (!vars.writeInto(dataVar, 0, SaveLoad_Geisha::kSlotSize)) { + warning("Save slot %d contains corrupted save", slot); + continue; + } + } + + return true; +} + +bool SaveLoad_Geisha::GameHandler::save(int16 dataVar, int32 size, int32 offset) { + if (((uint32)size != SaveLoad_Geisha::kSaveFileSize) || (offset != 0)) { + warning("Invalid saving procedure: %d, %d, %d", dataVar, size, offset); + return false; + } + + for (uint32 slot = 0; slot < SaveLoad_Geisha::kSlotCount; + slot++, dataVar += SaveLoad_Geisha::kSlotSize) { + + const byte *slotData = _vm->_inter->_variables->getAddressOff8(dataVar); + + // Check of the slot's data is empty + bool empty = true; + for (uint32 j = 0; j < SaveLoad_Geisha::kSlotSize; j++) { + if (slotData[j] != 0) { + empty = false; + break; + } + } + + // Don't save empty slots + if (empty) + continue; + + Common::String slotFile = _file.build(slot); + if (slotFile.empty()) + return false; + + SaveWriter writer(2, slot, slotFile); + + SavePartInfo info(20, (uint32) _vm->getGameType(), 0, + _vm->getEndianness(), _vm->_inter->_variables->getSize()); + SavePartVars vars(_vm, SaveLoad_Geisha::kSlotSize); + + info.setDesc(Common::String::format("Geisha, slot %d", slot).c_str()); + if (!vars.readFrom(dataVar, 0, SaveLoad_Geisha::kSlotSize)) + return false; + + if (!writer.writePart(0, &info)) + return false; + if (!writer.writePart(1, &vars)) + return false; + } + + return true; +} + + +SaveLoad_Geisha::SaveLoad_Geisha(GobEngine *vm, const char *targetName) : + SaveLoad(vm) { + + _saveFiles[0].handler = new GameHandler(vm, targetName); +} + +SaveLoad_Geisha::~SaveLoad_Geisha() { + for (int i = 0; i < ARRAYSIZE(_saveFiles); i++) + delete _saveFiles[i].handler; +} + +const SaveLoad_Geisha::SaveFile *SaveLoad_Geisha::getSaveFile(const char *fileName) const { + fileName = stripPath(fileName); + + for (int i = 0; i < ARRAYSIZE(_saveFiles); i++) + if (!scumm_stricmp(fileName, _saveFiles[i].sourceName)) + return &_saveFiles[i]; + + return 0; +} + +SaveLoad_Geisha::SaveFile *SaveLoad_Geisha::getSaveFile(const char *fileName) { + fileName = stripPath(fileName); + + for (int i = 0; i < ARRAYSIZE(_saveFiles); i++) + if (!scumm_stricmp(fileName, _saveFiles[i].sourceName)) + return &_saveFiles[i]; + + return 0; +} + +SaveHandler *SaveLoad_Geisha::getHandler(const char *fileName) const { + const SaveFile *saveFile = getSaveFile(fileName); + + if (saveFile) + return saveFile->handler; + + return 0; +} + +const char *SaveLoad_Geisha::getDescription(const char *fileName) const { + const SaveFile *saveFile = getSaveFile(fileName); + + if (saveFile) + return saveFile->description; + + return 0; +} + +SaveLoad::SaveMode SaveLoad_Geisha::getSaveMode(const char *fileName) const { + const SaveFile *saveFile = getSaveFile(fileName); + + if (saveFile) + return saveFile->mode; + + return kSaveModeNone; +} + +} // End of namespace Gob -- cgit v1.2.3 From 5f4dad1a6dcd86e29f291a8a5d48e8cd085c6bb7 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 29 Aug 2011 09:47:46 +0200 Subject: GOB: Fix the display length of "You can't use that" texts in Geisha --- engines/gob/hotspots.cpp | 30 ++++++++++++++++++++++++++++-- engines/gob/hotspots.h | 4 ++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp index 96b1efbcf1..5e0af847de 100644 --- a/engines/gob/hotspots.cpp +++ b/engines/gob/hotspots.cpp @@ -202,6 +202,8 @@ Hotspots::Hotspots(GobEngine *vm) : _vm(vm) { _currentKey = 0; _currentIndex = 0; _currentId = 0; + _currentX = 0; + _currentY = 0; } Hotspots::~Hotspots() { @@ -385,6 +387,8 @@ void Hotspots::push(uint8 all, bool force) { backup.key = _currentKey; backup.id = _currentId; backup.index = _currentIndex; + backup.x = _currentX; + backup.y = _currentY; backup.hotspots = new Hotspot[size]; @@ -415,6 +419,8 @@ void Hotspots::push(uint8 all, bool force) { _currentKey = 0; _currentId = 0; _currentIndex = 0; + _currentX = 0; + _currentY = 0; _stack.push(backup); } @@ -445,6 +451,8 @@ void Hotspots::pop() { _currentKey = backup.key; _currentId = backup.id; _currentIndex = backup.index; + _currentX = backup.x; + _currentY = backup.y; delete[] backup.hotspots; } @@ -498,6 +506,9 @@ void Hotspots::enter(uint16 index) { (spot.getState() == (kStateFilled | kStateType2))) WRITE_VAR(17, -(spot.id & 0x0FFF)); + _currentX = _vm->_global->_inter_mouseX; + _currentY = _vm->_global->_inter_mouseY; + if (spot.funcEnter != 0) call(spot.funcEnter); } @@ -649,9 +660,22 @@ bool Hotspots::checkHotspotChanged() { // Get the current hotspot key = checkMouse(kTypeMove, id, index); - if (key == _currentKey) - // Nothing changed => nothing to do + uint16 mouseX = _vm->_global->_inter_mouseX; + uint16 mouseY = _vm->_global->_inter_mouseY; + + if (key == _currentKey) { + // Still the same hotspot, just update the mouse position + + _currentX = mouseX; + _currentY = mouseY; return false; + } + + // In Geisha, no move hotspot changes should occur when + // we didn't actually move the mouse + if (_vm->getGameType() == kGameTypeGeisha) + if ((mouseX == _currentX) && (mouseY == _currentY)) + return false; // Leave the old area if (isValid(_currentKey, _currentId,_currentIndex)) @@ -660,6 +684,8 @@ bool Hotspots::checkHotspotChanged() { _currentKey = key; _currentId = id; _currentIndex = index; + _currentX = mouseX; + _currentY = mouseY; // Enter the new one if (isValid(key, id, index)) diff --git a/engines/gob/hotspots.h b/engines/gob/hotspots.h index 8d26ad224e..b348f9cd70 100644 --- a/engines/gob/hotspots.h +++ b/engines/gob/hotspots.h @@ -158,6 +158,8 @@ private: uint32 key; uint32 id; uint32 index; + uint16 x; + uint16 y; }; struct InputDesc { @@ -178,6 +180,8 @@ private: uint16 _currentKey; uint16 _currentIndex; uint16 _currentId; + uint16 _currentX; + uint16 _currentY; /** Add a hotspot, returning the new index. */ uint16 add(const Hotspot &hotspot); -- cgit v1.2.3 From b12fed08356d8cd59de5ae5867bb8f8f9b0c5453 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 29 Aug 2011 11:55:21 +0200 Subject: DREAMWEB: 'printmessage' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 21 --------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 10 ++++++++++ engines/dreamweb/stubs.h | 2 ++ 5 files changed, 14 insertions(+), 23 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 744e285fbf..f2134be215 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -51,6 +51,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'printchar', 'printdirect', 'printslow', + 'printmessage', 'usetimedtext', 'dumptimedtext', 'setuptimedtemp', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 8d3518d5f6..f716d89769 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -15615,26 +15615,6 @@ void DreamGenContext::examineobtext() { commandwithob(); } -void DreamGenContext::printmessage() { - STACK_CHECK; - push(dx); - push(bx); - push(di); - ah = 0; - _add(ax, ax); - bx = ax; - es = data.word(kCommandtext); - ax = es.word(bx); - _add(ax, (66*2)); - si = ax; - di = pop(); - bx = pop(); - dx = pop(); - al = 0; - ah = 0; - printdirect(); -} - void DreamGenContext::printmessage2() { STACK_CHECK; push(dx); @@ -18459,7 +18439,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_walkintoroom: walkintoroom(); break; case addr_afterintroroom: afterintroroom(); break; case addr_examineobtext: examineobtext(); break; - case addr_printmessage: printmessage(); break; case addr_printmessage2: printmessage2(); break; case addr_setwalk: setwalk(); break; case addr_bresenhams: bresenhams(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index fc4deeb488..3ad99d1543 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -105,7 +105,6 @@ public: static const uint16 addr_bresenhams = 0xca50; static const uint16 addr_setwalk = 0xca44; static const uint16 addr_printmessage2 = 0xca30; - static const uint16 addr_printmessage = 0xca2c; static const uint16 addr_examineobtext = 0xca20; static const uint16 addr_afterintroroom = 0xca14; static const uint16 addr_walkintoroom = 0xca10; @@ -2017,7 +2016,7 @@ public: void loadsecondsample(); void transfercontoex(); //void multiput(); - void printmessage(); + //void printmessage(); void businessman(); void switchryanoff(); //void commandwithob(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 9b85cbb9f4..92a2a3d139 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1618,6 +1618,16 @@ void DreamGenContext::animpointer() { data.byte(kPointerframe) = 8; } +void DreamGenContext::printmessage() { + printmessage(di, bx, al, dl, (bool)(dl & 1)); +} + +void DreamGenContext::printmessage(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered) { + uint16 offset = kTextstart + segRef(data.word(kCommandtext)).word(index * 2); + const uint8 *string = segRef(data.word(kCommandtext)).ptr(offset, 0); + printdirect(&string, x, &y, maxWidth, centered); +} + bool DreamGenContext::isCD() { // The original sources has two codepaths depending if the game is 'if cd' or not // This is a hack to guess which version to use with the assumption that if we have a cd version diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 7c8cee4690..bb5568e20d 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -47,6 +47,8 @@ void printchar(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height); void printdirect(); void printdirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered); + void printmessage(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered); + void printmessage(); void usetimedtext(); void dumptimedtext(); void setuptimedtemp(); -- cgit v1.2.3 From a28bffec1cf37517f3dd9d7fda7ad511c921a7db Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Aug 2011 22:01:11 +1000 Subject: TSAGE: Implemented the Blue Force right-click dialog --- engines/tsage/blue_force/blueforce_dialogs.cpp | 201 +++++++++++++++++++++++++ engines/tsage/blue_force/blueforce_dialogs.h | 61 ++++++++ engines/tsage/blue_force/blueforce_logic.cpp | 7 + engines/tsage/blue_force/blueforce_logic.h | 1 + engines/tsage/core.cpp | 13 +- engines/tsage/core.h | 1 + engines/tsage/dialogs.cpp | 180 ---------------------- engines/tsage/dialogs.h | 29 ---- engines/tsage/events.cpp | 25 ++- engines/tsage/graphics.cpp | 23 ++- engines/tsage/module.mk | 2 + engines/tsage/ringworld/ringworld_logic.cpp | 7 + engines/tsage/ringworld/ringworld_logic.h | 1 + engines/tsage/scenes.h | 1 + 14 files changed, 329 insertions(+), 223 deletions(-) create mode 100644 engines/tsage/blue_force/blueforce_dialogs.cpp create mode 100644 engines/tsage/blue_force/blueforce_dialogs.h diff --git a/engines/tsage/blue_force/blueforce_dialogs.cpp b/engines/tsage/blue_force/blueforce_dialogs.cpp new file mode 100644 index 0000000000..ec99df8c3b --- /dev/null +++ b/engines/tsage/blue_force/blueforce_dialogs.cpp @@ -0,0 +1,201 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/translation.h" + +#include "gui/dialog.h" +#include "gui/widget.h" + +#include "tsage/tsage.h" +#include "tsage/core.h" +#include "tsage/dialogs.h" +#include "tsage/staticres.h" +#include "tsage/globals.h" +#include "tsage/blue_force/blueforce_dialogs.h" +#include "tsage/ringworld/ringworld_logic.h" + +namespace TsAGE { + +namespace BlueForce { + +/** + * This dialog implements the right-click dialog + */ +RightClickDialog::RightClickDialog() : GfxDialog() { + // Setup button areas + _rectList1[0] = Rect(7, 50, 41, 67); + _rectList1[1] = Rect(13, 27, 50, 50); + _rectList1[2] = Rect(49, 27, 84, 50); + _rectList1[3] = Rect(56, 50, 90, 67); + _rectList1[4] = Rect(26, 68, 69, 99); + + _rectList3[0] = Rect(12, 49, 27, 64); + _rectList3[1] = Rect(27, 31, 42, 46); + _rectList3[2] = Rect(56, 31, 71, 46); + _rectList3[3] = Rect(72, 50, 87, 65); + _rectList3[4] = Rect(41, 81, 56, 96); + + // Set the palette and change the cursor + GfxSurface cursor = surfaceFromRes(1, 5, 9); + BF_GLOBALS._events.setCursor(cursor); + + setPalette(); + + // Get the dialog image + _surface = surfaceFromRes(1, 1, 1); + + // Set the dialog position + Rect dialogRect; + dialogRect.resize(_surface, 0, 0, 100); + dialogRect.center(_globals->_events._mousePos.x, _globals->_events._mousePos.y); + + // Ensure the dialog will be entirely on-screen + Rect screenRect = _globals->gfxManager()._bounds; + screenRect.collapse(4, 4); + dialogRect.contain(screenRect); + + // Load selected button images + _btnImages.setVisage(1, 2); + + _bounds = dialogRect; + _gfxManager._bounds = _bounds; + + _highlightedAction = -1; + _selectedAction = -1; +} + +RightClickDialog::~RightClickDialog() { +} + +void RightClickDialog::draw() { + // Save the covered background area + _savedArea = Surface_getArea(_globals->_gfxManagerInstance.getSurface(), _bounds); + + // Draw the dialog image + _globals->gfxManager().copyFrom(_surface, _bounds.left, _bounds.top); + + // Pre-process rect lists + for (int idx = 0; idx < 5; ++idx) { + _rectList2[idx] = _rectList1[idx]; + _rectList4[idx] = _rectList3[idx]; + + _rectList2[idx].translate(_bounds.left, _bounds.top); + _rectList4[idx].translate(_bounds.left, _bounds.top); + } +} + +bool RightClickDialog::process(Event &event) { + switch (event.eventType) { + case EVENT_MOUSE_MOVE: { + // Check whether a button is highlighted + int buttonIndex = 0; + while ((buttonIndex < 5) && !_rectList1[buttonIndex].contains(event.mousePos)) + ++buttonIndex; + if (buttonIndex == 5) + buttonIndex = -1; + + // If selection has changed, handle it + if (buttonIndex != _highlightedAction) { + if (_highlightedAction != -1) { + // Another button was previously selected, so restore dialog + _gfxManager.copyFrom(_surface, 0, 0); + } + + if (buttonIndex != -1) { + // Draw newly selected button + GfxSurface btn = _btnImages.getFrame(buttonIndex + 1); + _gfxManager.copyFrom(btn, _rectList3[buttonIndex].left, _rectList3[buttonIndex].top); + } + + _highlightedAction = buttonIndex; + } + + event.handled = true; + return true; + } + + case EVENT_BUTTON_DOWN: + // Specify the selected action + _selectedAction = (_highlightedAction == -1) ? 5 : _highlightedAction; + event.handled = true; + return true; + + default: + break; + } + + return false; +} + +void RightClickDialog::execute() { + // Draw the dialog + draw(); + + // Dialog event handler loop + _gfxManager.activate(); + + while (!_vm->shouldQuit() && (_selectedAction == -1)) { + Event evt; + while (_globals->_events.getEvent(evt, EVENT_MOUSE_MOVE | EVENT_BUTTON_DOWN)) { + evt.mousePos.x -= _bounds.left; + evt.mousePos.y -= _bounds.top; + + process(evt); + } + + g_system->delayMillis(10); + g_system->updateScreen(); + } + + // Execute the specified action + CursorType cursorNum = CURSOR_NONE; + switch (_selectedAction) { + case 0: + // Walk action + cursorNum = BF_GLOBALS._player._canWalk ? CURSOR_WALK : CURSOR_USE; + break; + case 1: + // Use action + cursorNum = CURSOR_USE; + break; + case 2: + // Look action + cursorNum = CURSOR_LOOK; + break; + case 3: + // Talk action + cursorNum = CURSOR_TALK; + break; + case 4: + // Options dialog + break; + } + + if (cursorNum != CURSOR_NONE) + BF_GLOBALS._events.setCursor(cursorNum); + + _gfxManager.deactivate(); +} + +} // End of namespace BlueForce + +} // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_dialogs.h b/engines/tsage/blue_force/blueforce_dialogs.h new file mode 100644 index 0000000000..1ead39a089 --- /dev/null +++ b/engines/tsage/blue_force/blueforce_dialogs.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TSAGE_BLUEFORCE_DIALOGS_H +#define TSAGE_BLUEFORCE_DIALOGS_H + +#include "gui/options.h" +#include "tsage/events.h" +#include "tsage/graphics.h" +#include "common/list.h" +#include "common/rect.h" +#include "common/system.h" + +namespace TsAGE { + +namespace BlueForce { + +class RightClickDialog : public GfxDialog { +private: + GfxSurface _surface; + Visage _btnImages; + Rect _rectList1[5]; + Rect _rectList2[5]; + Rect _rectList3[5]; + Rect _rectList4[5]; + + int _highlightedAction; + int _selectedAction; +public: + RightClickDialog(); + ~RightClickDialog(); + + virtual void draw(); + virtual bool process(Event &event); + void execute(); +}; + +} // End of namespace BlueForce + +} // End of namespace TsAGE + +#endif diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 9c7d66aadf..985a1578ab 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -21,6 +21,7 @@ */ #include "tsage/blue_force/blueforce_logic.h" +#include "tsage/blue_force/blueforce_dialogs.h" #include "tsage/blue_force/blueforce_scenes0.h" #include "tsage/blue_force/blueforce_scenes1.h" #include "tsage/blue_force/blueforce_scenes3.h" @@ -135,6 +136,12 @@ Scene *BlueForceGame::createScene(int sceneNumber) { } } +void BlueForceGame::rightClick() { + RightClickDialog *dlg = new RightClickDialog(); + dlg->execute(); + delete dlg; +} + /*--------------------------------------------------------------------------*/ AObjectArray::AObjectArray(): EventHandler() { diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index d756d85cb3..a3bcf9ea01 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -41,6 +41,7 @@ class BlueForceGame: public Game { public: virtual void start(); virtual Scene *createScene(int sceneNumber); + virtual void rightClick(); }; #define OBJ_ARRAY_SIZE 10 diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 38fd668fac..4842284442 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1244,6 +1244,15 @@ void ScenePalette::setPalette(int index, int count) { g_system->getPaletteManager()->setPalette((const byte *)&_palette[index * 3], index, count); } +/** + * Set a palette entry + */ +void ScenePalette::setEntry(int index, uint r, uint g, uint b) { + _palette[index * 3] = r; + _palette[index * 3 + 1] = g; + _palette[index * 3 + 2] = b; +} + /** * Returns the palette index with the closest matching color to that specified * @param r R component @@ -3616,9 +3625,7 @@ void SceneHandler::process(Event &event) { // Check for displaying right-click dialog if ((event.eventType == EVENT_BUTTON_DOWN) && (event.btnState == BTNSHIFT_RIGHT) && _globals->_player._uiEnabled) { - RightClickDialog *dlg = new RightClickDialog(); - dlg->execute(); - delete dlg; + _globals->_game->rightClick(); event.handled = true; return; diff --git a/engines/tsage/core.h b/engines/tsage/core.h index b1cbf74bd3..9cd28b1e89 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -368,6 +368,7 @@ public: bool loadPalette(int paletteNum); void refresh(); void setPalette(int index, int count); + void setEntry(int index, uint r, uint g, uint b); uint8 indexOf(uint r, uint g, uint b, int threshold = 0xffff); void getPalette(int start = 0, int count = 256); void signalListeners(); diff --git a/engines/tsage/dialogs.cpp b/engines/tsage/dialogs.cpp index ae385b8c15..d5e7b1514d 100644 --- a/engines/tsage/dialogs.cpp +++ b/engines/tsage/dialogs.cpp @@ -109,186 +109,6 @@ ConfigDialog::ConfigDialog() : GUI::OptionsDialog("", "GlobalConfig") { /*--------------------------------------------------------------------------*/ -#define BUTTON_WIDTH 28 -#define BUTTON_HEIGHT 29 - -RightClickButton::RightClickButton(int buttonIndex, int xp, int yp) : GfxButton() { - _buttonIndex = buttonIndex; - this->_bounds.left = xp; - this->_bounds.top = yp; - this->_bounds.setWidth(BUTTON_WIDTH); - this->_bounds.setHeight(BUTTON_HEIGHT); - _savedButton = NULL; -} - -void RightClickButton::highlight() { - if (_savedButton) { - // Button was previously highlighted, so de-highlight by restoring saved area - _globals->gfxManager().copyFrom(*_savedButton, _bounds.left, _bounds.top); - delete _savedButton; - _savedButton = NULL; - } else { - // Highlight button by getting the needed highlighted image resource - _savedButton = Surface_getArea(_globals->gfxManager().getSurface(), _bounds); - - uint size; - byte *imgData = _resourceManager->getSubResource(7, 2, _buttonIndex, &size); - - GfxSurface btnSelected = surfaceFromRes(imgData); - _globals->gfxManager().copyFrom(btnSelected, _bounds.left, _bounds.top); - - DEALLOCATE(imgData); - } -} - -/*--------------------------------------------------------------------------*/ - -/** - * This dialog implements the right-click dialog - */ -RightClickDialog::RightClickDialog() : GfxDialog(), - _walkButton(1, 48, 12), _lookButton(2, 31, 29), _useButton(3, 65, 29), - _talkButton(4, 14, 47), _inventoryButton(5, 48, 47), _optionsButton(6, 83, 47) { - Rect rectArea, dialogRect; - - // Set the palette and change the cursor - _gfxManager.setDialogPalette(); - _globals->_events.setCursor(CURSOR_ARROW); - - // Get the dialog image - _surface = surfaceFromRes(7, 1, 1); - - // Set the dialog position - dialogRect.resize(_surface, 0, 0, 100); - dialogRect.center(_globals->_events._mousePos.x, _globals->_events._mousePos.y); - - // Ensure the dialog will be entirely on-screen - Rect screenRect = _globals->gfxManager()._bounds; - screenRect.collapse(4, 4); - dialogRect.contain(screenRect); - - _bounds = dialogRect; - _gfxManager._bounds = _bounds; - - _highlightedButton = NULL; - _selectedAction = -1; -} - -RightClickDialog::~RightClickDialog() { -} - -RightClickButton *RightClickDialog::findButton(const Common::Point &pt) { - RightClickButton *btnList[] = { &_walkButton, &_lookButton, &_useButton, &_talkButton, &_inventoryButton, &_optionsButton }; - - for (int i = 0; i < 6; ++i) { - btnList[i]->_owner = this; - - if (btnList[i]->_bounds.contains(pt)) - return btnList[i]; - } - - return NULL; -} - -void RightClickDialog::draw() { - // Save the covered background area - _savedArea = Surface_getArea(_globals->_gfxManagerInstance.getSurface(), _bounds); - - // Draw the dialog image - _globals->gfxManager().copyFrom(_surface, _bounds.left, _bounds.top); -} - -bool RightClickDialog::process(Event &event) { - switch (event.eventType) { - case EVENT_MOUSE_MOVE: { - // Check whether a button is highlighted - RightClickButton *btn = findButton(event.mousePos); - - if (btn != _highlightedButton) { - // De-highlight any previously selected button - if (_highlightedButton) { - _highlightedButton->highlight(); - _highlightedButton = NULL; - } - if (btn) { - // Highlight the new button - btn->highlight(); - _highlightedButton = btn; - } - } - event.handled = true; - return true; - } - - case EVENT_BUTTON_DOWN: - // If a button is highlighted, then flag the selected button index - if (_highlightedButton) - _selectedAction = _highlightedButton->_buttonIndex; - else - _selectedAction = _lookButton._buttonIndex; - event.handled = true; - return true; - - default: - break; - } - - return false; -} - -void RightClickDialog::execute() { - // Draw the dialog - draw(); - - // Dialog event handler loop - _gfxManager.activate(); - - while (!_vm->shouldQuit() && (_selectedAction == -1)) { - Event evt; - while (_globals->_events.getEvent(evt, EVENT_MOUSE_MOVE | EVENT_BUTTON_DOWN)) { - evt.mousePos.x -= _bounds.left; - evt.mousePos.y -= _bounds.top; - - process(evt); - } - - g_system->delayMillis(10); - g_system->updateScreen(); - } - - // Execute the specified action - switch (_selectedAction) { - case 1: - // Look action - _globals->_events.setCursor(CURSOR_LOOK); - break; - case 2: - // Walk action - _globals->_events.setCursor(CURSOR_WALK); - break; - case 3: - // Use cursor - _globals->_events.setCursor(CURSOR_USE); - break; - case 4: - // Talk cursor - _globals->_events.setCursor(CURSOR_TALK); - break; - case 5: - // Inventory dialog - InventoryDialog::show(); - break; - case 6: - // Dialog options - OptionsDialog::show(); - break; - } - - _gfxManager.deactivate(); -} - -/*--------------------------------------------------------------------------*/ - void ModalDialog::draw() { // Set the palette for use in the dialog setPalette(); diff --git a/engines/tsage/dialogs.h b/engines/tsage/dialogs.h index 55adb6c813..7355ea1cf9 100644 --- a/engines/tsage/dialogs.h +++ b/engines/tsage/dialogs.h @@ -49,35 +49,6 @@ public: ConfigDialog(); }; -class RightClickButton : public GfxButton { -private: - GfxSurface *_savedButton; -public: - int _buttonIndex; - - RightClickButton(int buttonIndex, int xp, int yp); - ~RightClickButton() { delete _savedButton; } - - virtual void highlight(); -}; - -class RightClickDialog : public GfxDialog { -private: - GfxSurface _surface; - RightClickButton *_highlightedButton; - int _selectedAction; - RightClickButton _walkButton, _lookButton, _useButton, _talkButton, _inventoryButton, _optionsButton; - - RightClickButton *findButton(const Common::Point &pt); -public: - RightClickDialog(); - ~RightClickDialog(); - - virtual void draw(); - virtual bool process(Event &event); - void execute(); -}; - /*--------------------------------------------------------------------------*/ class ModalDialog : public GfxDialog { diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp index a6471dc8ab..72393832c8 100644 --- a/engines/tsage/events.cpp +++ b/engines/tsage/events.cpp @@ -164,19 +164,30 @@ void EventsClass::setCursor(CursorType cursorType) { case CURSOR_LOOK: // Look cursor - cursor = _resourceManager->getSubResource(4, 1, 5, &size); + if (_vm->getGameID() == GType_BlueForce) + cursor = _resourceManager->getSubResource(1, 5, 3, &size); + else + cursor = _resourceManager->getSubResource(4, 1, 5, &size); _currentCursor = CURSOR_LOOK; break; case CURSOR_USE: // Use cursor - cursor = _resourceManager->getSubResource(4, 1, 4, &size); + if (_vm->getGameID() == GType_BlueForce) { + cursor = _resourceManager->getSubResource(1, 5, 2, &size); + } else { + cursor = _resourceManager->getSubResource(4, 1, 4, &size); + } _currentCursor = CURSOR_USE; break; case CURSOR_TALK: // Talk cursor - cursor = _resourceManager->getSubResource(4, 1, 3, &size); + if (_vm->getGameID() == GType_BlueForce) { + cursor = _resourceManager->getSubResource(1, 5, 4, &size); + } else { + cursor = _resourceManager->getSubResource(4, 1, 3, &size); + } _currentCursor = CURSOR_TALK; break; @@ -189,9 +200,13 @@ void EventsClass::setCursor(CursorType cursorType) { case CURSOR_WALK: default: // Walk cursor - cursor = CURSOR_WALK_DATA; + if (_vm->getGameID() == GType_BlueForce) { + cursor = _resourceManager->getSubResource(1, 5, 1, &size); + } else { + cursor = CURSOR_WALK_DATA; + delFlag = false; + } _currentCursor = CURSOR_WALK; - delFlag = false; break; } diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp index 1884bfb4f5..69c9995b93 100644 --- a/engines/tsage/graphics.cpp +++ b/engines/tsage/graphics.cpp @@ -1069,12 +1069,23 @@ GfxButton *GfxDialog::execute(GfxButton *defaultButton) { } void GfxDialog::setPalette() { - _globals->_scenePalette.loadPalette(0); - _globals->_scenePalette.setPalette(0, 1); - _globals->_scenePalette.setPalette(_globals->_scenePalette._colors.foreground, 1); - _globals->_scenePalette.setPalette(_globals->_fontColors.background, 1); - _globals->_scenePalette.setPalette(_globals->_fontColors.foreground, 1); - _globals->_scenePalette.setPalette(255, 1); + if (_vm->getGameID() == GType_BlueForce) { + _globals->_scenePalette.loadPalette(2); + _globals->_scenePalette.setPalette(0, 1); + _globals->_scenePalette.setPalette(_globals->_gfxColors.background, 1); + _globals->_scenePalette.setPalette(_globals->_gfxColors.foreground, 1); + _globals->_scenePalette.setPalette(_globals->_fontColors.background, 1); + _globals->_scenePalette.setPalette(_globals->_fontColors.foreground, 1); + _globals->_scenePalette.setEntry(255, 0xff, 0xff, 0xff); + _globals->_scenePalette.setPalette(255, 1); + } else { + _globals->_scenePalette.loadPalette(0); + _globals->_scenePalette.setPalette(0, 1); + _globals->_scenePalette.setPalette(_globals->_scenePalette._colors.foreground, 1); + _globals->_scenePalette.setPalette(_globals->_fontColors.background, 1); + _globals->_scenePalette.setPalette(_globals->_fontColors.foreground, 1); + _globals->_scenePalette.setPalette(255, 1); + } } /*--------------------------------------------------------------------------*/ diff --git a/engines/tsage/module.mk b/engines/tsage/module.mk index ed6fb296a0..ef715330f1 100644 --- a/engines/tsage/module.mk +++ b/engines/tsage/module.mk @@ -1,6 +1,7 @@ MODULE := engines/tsage MODULE_OBJS := \ + blue_force/blueforce_dialogs.o \ blue_force/blueforce_logic.o \ blue_force/blueforce_scenes0.o \ blue_force/blueforce_scenes1.o \ @@ -16,6 +17,7 @@ MODULE_OBJS := \ graphics.o \ resources.o \ ringworld/ringworld_demo.o \ + ringworld/ringworld_dialogs.o \ ringworld/ringworld_logic.o \ ringworld/ringworld_scenes1.o \ ringworld/ringworld_scenes2.o \ diff --git a/engines/tsage/ringworld/ringworld_logic.cpp b/engines/tsage/ringworld/ringworld_logic.cpp index 2a34e49b39..366076d7aa 100644 --- a/engines/tsage/ringworld/ringworld_logic.cpp +++ b/engines/tsage/ringworld/ringworld_logic.cpp @@ -28,6 +28,7 @@ #include "tsage/tsage.h" #include "tsage/staticres.h" #include "tsage/ringworld/ringworld_demo.h" +#include "tsage/ringworld/ringworld_dialogs.h" #include "tsage/ringworld/ringworld_scenes1.h" #include "tsage/ringworld/ringworld_scenes2.h" #include "tsage/ringworld/ringworld_scenes3.h" @@ -1489,6 +1490,12 @@ void RingworldGame::processEvent(Event &event) { } } +void RingworldGame::rightClick() { + RightClickDialog *dlg = new RightClickDialog(); + dlg->execute(); + delete dlg; +} + } // End of namespace Ringworld } // End of namespace TsAGE diff --git a/engines/tsage/ringworld/ringworld_logic.h b/engines/tsage/ringworld/ringworld_logic.h index 69e5520581..830b28302a 100644 --- a/engines/tsage/ringworld/ringworld_logic.h +++ b/engines/tsage/ringworld/ringworld_logic.h @@ -456,6 +456,7 @@ public: virtual Scene *createScene(int sceneNumber); virtual void processEvent(Event &event); + virtual void rightClick(); }; } // End of namespace Ringworld diff --git a/engines/tsage/scenes.h b/engines/tsage/scenes.h index 7e8c26f912..793013b603 100644 --- a/engines/tsage/scenes.h +++ b/engines/tsage/scenes.h @@ -132,6 +132,7 @@ public: virtual void endGame(int resNum, int lineNum) {} virtual Scene *createScene(int sceneNumber) = 0; virtual void processEvent(Event &event) {} + virtual void rightClick() {} }; } // End of namespace TsAGE -- cgit v1.2.3 From b516e4f440fa853f129c2802733deebfd22566d1 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 29 Aug 2011 14:09:00 +0200 Subject: GOB: Add a workaround for some of Geisha's textboxes Geisha often displays text while it loads a new TOT. Back in the days, this took long enough so that the text could be read. Since this isn't the case anymore, we'll wait for the user to press a key or click the mouse. --- engines/gob/inter.h | 3 +++ engines/gob/inter_geisha.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/engines/gob/inter.h b/engines/gob/inter.h index 764c7bf246..c84cc384ce 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -345,6 +345,7 @@ protected: virtual void setupOpcodesGob(); void oGeisha_loadCursor(OpFuncParams ¶ms); + void oGeisha_loadTot(OpFuncParams ¶ms); void oGeisha_goblinFunc(OpFuncParams ¶ms); void oGeisha_loadSound(OpFuncParams ¶ms); void oGeisha_checkData(OpFuncParams ¶ms); @@ -361,6 +362,8 @@ protected: void oGeisha_caress2(OpGobParams ¶ms); int16 loadSound(int16 slot); + + bool keyPressed(); }; class Inter_v2 : public Inter_v1 { diff --git a/engines/gob/inter_geisha.cpp b/engines/gob/inter_geisha.cpp index e547285f86..6c3e97c2a7 100644 --- a/engines/gob/inter_geisha.cpp +++ b/engines/gob/inter_geisha.cpp @@ -56,6 +56,7 @@ void Inter_Geisha::setupOpcodesFunc() { Inter_v1::setupOpcodesFunc(); OPCODEFUNC(0x03, oGeisha_loadCursor); + OPCODEFUNC(0x12, oGeisha_loadTot); OPCODEFUNC(0x25, oGeisha_goblinFunc); OPCODEFUNC(0x3A, oGeisha_loadSound); OPCODEFUNC(0x3F, oGeisha_checkData); @@ -81,6 +82,62 @@ void Inter_Geisha::oGeisha_loadCursor(OpFuncParams ¶ms) { o1_loadCursor(params); } +bool Inter_Geisha::keyPressed() { + int16 key = _vm->_util->checkKey(); + if (key) + return true; + + int16 x, y; + MouseButtons buttons; + + _vm->_util->getMouseState(&x, &y, &buttons); + return buttons != kMouseButtonsNone; +} + +struct TOTTransition { + const char *to; + const char *from; + int32 offset; +}; + +static const TOTTransition kTOTTransitions[] = { + {"chambre.tot", "photo.tot" , 1801}, + {"mo.tot" , "chambre.tot", 13580}, + {"chambre.tot", "mo.tot" , 564}, + {"hard.tot" , "chambre.tot", 13917}, + {"carte.tot" , "hard.tot" , 17926}, + {"chambre.tot", "carte.tot" , 14609}, + {"chambre.tot", "mo.tot" , 3658}, + {"streap.tot" , "chambre.tot", 14652}, + {"bonsai.tot" , "porte.tot" , 2858}, + {"lit.tot" , "napa.tot" , 3380}, + {"oko.tot" , "chambre.tot", 14146}, + {"chambre.tot", "oko.tot" , 2334} +}; + +void Inter_Geisha::oGeisha_loadTot(OpFuncParams ¶ms) { + o1_loadTot(params); + + // WORKAROUND: Geisha often displays text while it loads a new TOT. + // Back in the days, this took long enough so that the text + // could be read. Since this isn't the case anymore, we'll + // wait for the user to press a key or click the mouse. + bool needWait = false; + + for (int i = 0; i < ARRAYSIZE(kTOTTransitions); i++) + if ((_vm->_game->_script->pos() == kTOTTransitions[i].offset) && + (_vm->_game->_totToLoad == kTOTTransitions[i].to) && + (_vm->_game->_curTotFile == kTOTTransitions[i].from)) { + + needWait = true; + break; + } + + if (needWait) + while (!keyPressed()) + _vm->_util->longDelay(1); +} + void Inter_Geisha::oGeisha_loadSound(OpFuncParams ¶ms) { loadSound(-1); } -- cgit v1.2.3 From 57f00ff1dc920c132bd821ac61fd5261c848493c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Aug 2011 22:14:30 +1000 Subject: TSAGE: Added Ringworld specific dialogs file --- engines/tsage/ringworld/ringworld_dialogs.cpp | 222 ++++++++++++++++++++++++++ engines/tsage/ringworld/ringworld_dialogs.h | 70 ++++++++ 2 files changed, 292 insertions(+) create mode 100644 engines/tsage/ringworld/ringworld_dialogs.cpp create mode 100644 engines/tsage/ringworld/ringworld_dialogs.h diff --git a/engines/tsage/ringworld/ringworld_dialogs.cpp b/engines/tsage/ringworld/ringworld_dialogs.cpp new file mode 100644 index 0000000000..ca4ccbc7c5 --- /dev/null +++ b/engines/tsage/ringworld/ringworld_dialogs.cpp @@ -0,0 +1,222 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/translation.h" + +#include "gui/dialog.h" +#include "gui/widget.h" + +#include "tsage/tsage.h" +#include "tsage/core.h" +#include "tsage/dialogs.h" +#include "tsage/staticres.h" +#include "tsage/globals.h" +#include "tsage/ringworld/ringworld_dialogs.h" +#include "tsage/ringworld/ringworld_logic.h" + +namespace TsAGE { + +namespace Ringworld { + +/*--------------------------------------------------------------------------*/ + +#define BUTTON_WIDTH 28 +#define BUTTON_HEIGHT 29 + +RightClickButton::RightClickButton(int buttonIndex, int xp, int yp) : GfxButton() { + _buttonIndex = buttonIndex; + this->_bounds.left = xp; + this->_bounds.top = yp; + this->_bounds.setWidth(BUTTON_WIDTH); + this->_bounds.setHeight(BUTTON_HEIGHT); + _savedButton = NULL; +} + +void RightClickButton::highlight() { + if (_savedButton) { + // Button was previously highlighted, so de-highlight by restoring saved area + _globals->gfxManager().copyFrom(*_savedButton, _bounds.left, _bounds.top); + delete _savedButton; + _savedButton = NULL; + } else { + // Highlight button by getting the needed highlighted image resource + _savedButton = Surface_getArea(_globals->gfxManager().getSurface(), _bounds); + + uint size; + byte *imgData = _resourceManager->getSubResource(7, 2, _buttonIndex, &size); + + GfxSurface btnSelected = surfaceFromRes(imgData); + _globals->gfxManager().copyFrom(btnSelected, _bounds.left, _bounds.top); + + DEALLOCATE(imgData); + } +} + +/*--------------------------------------------------------------------------*/ + +/** + * This dialog implements the right-click dialog + */ +RightClickDialog::RightClickDialog() : GfxDialog(), + _walkButton(1, 48, 12), _lookButton(2, 31, 29), _useButton(3, 65, 29), + _talkButton(4, 14, 47), _inventoryButton(5, 48, 47), _optionsButton(6, 83, 47) { + Rect rectArea, dialogRect; + + // Set the palette and change the cursor + _gfxManager.setDialogPalette(); + _globals->_events.setCursor(CURSOR_ARROW); + + // Get the dialog image + _surface = surfaceFromRes(7, 1, 1); + + // Set the dialog position + dialogRect.resize(_surface, 0, 0, 100); + dialogRect.center(_globals->_events._mousePos.x, _globals->_events._mousePos.y); + + // Ensure the dialog will be entirely on-screen + Rect screenRect = _globals->gfxManager()._bounds; + screenRect.collapse(4, 4); + dialogRect.contain(screenRect); + + _bounds = dialogRect; + _gfxManager._bounds = _bounds; + + _highlightedButton = NULL; + _selectedAction = -1; +} + +RightClickDialog::~RightClickDialog() { +} + +RightClickButton *RightClickDialog::findButton(const Common::Point &pt) { + RightClickButton *btnList[] = { &_walkButton, &_lookButton, &_useButton, &_talkButton, &_inventoryButton, &_optionsButton }; + + for (int i = 0; i < 6; ++i) { + btnList[i]->_owner = this; + + if (btnList[i]->_bounds.contains(pt)) + return btnList[i]; + } + + return NULL; +} + +void RightClickDialog::draw() { + // Save the covered background area + _savedArea = Surface_getArea(_globals->_gfxManagerInstance.getSurface(), _bounds); + + // Draw the dialog image + _globals->gfxManager().copyFrom(_surface, _bounds.left, _bounds.top); +} + +bool RightClickDialog::process(Event &event) { + switch (event.eventType) { + case EVENT_MOUSE_MOVE: { + // Check whether a button is highlighted + RightClickButton *btn = findButton(event.mousePos); + + if (btn != _highlightedButton) { + // De-highlight any previously selected button + if (_highlightedButton) { + _highlightedButton->highlight(); + _highlightedButton = NULL; + } + if (btn) { + // Highlight the new button + btn->highlight(); + _highlightedButton = btn; + } + } + event.handled = true; + return true; + } + + case EVENT_BUTTON_DOWN: + // If a button is highlighted, then flag the selected button index + if (_highlightedButton) + _selectedAction = _highlightedButton->_buttonIndex; + else + _selectedAction = _lookButton._buttonIndex; + event.handled = true; + return true; + + default: + break; + } + + return false; +} + +void RightClickDialog::execute() { + // Draw the dialog + draw(); + + // Dialog event handler loop + _gfxManager.activate(); + + while (!_vm->shouldQuit() && (_selectedAction == -1)) { + Event evt; + while (_globals->_events.getEvent(evt, EVENT_MOUSE_MOVE | EVENT_BUTTON_DOWN)) { + evt.mousePos.x -= _bounds.left; + evt.mousePos.y -= _bounds.top; + + process(evt); + } + + g_system->delayMillis(10); + g_system->updateScreen(); + } + + // Execute the specified action + switch (_selectedAction) { + case 1: + // Look action + _globals->_events.setCursor(CURSOR_LOOK); + break; + case 2: + // Walk action + _globals->_events.setCursor(CURSOR_WALK); + break; + case 3: + // Use cursor + _globals->_events.setCursor(CURSOR_USE); + break; + case 4: + // Talk cursor + _globals->_events.setCursor(CURSOR_TALK); + break; + case 5: + // Inventory dialog + InventoryDialog::show(); + break; + case 6: + // Dialog options + OptionsDialog::show(); + break; + } + + _gfxManager.deactivate(); +} + +} // End of namespace Ringworld + +} // End of namespace TsAGE diff --git a/engines/tsage/ringworld/ringworld_dialogs.h b/engines/tsage/ringworld/ringworld_dialogs.h new file mode 100644 index 0000000000..11a8f10e70 --- /dev/null +++ b/engines/tsage/ringworld/ringworld_dialogs.h @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TSAGE_RINGWORLD_DIALOGS_H +#define TSAGE_RINGWORLD_DIALOGS_H + +#include "gui/options.h" +#include "tsage/events.h" +#include "tsage/graphics.h" +#include "common/list.h" +#include "common/rect.h" +#include "common/system.h" + +namespace TsAGE { + +namespace Ringworld { + +class RightClickButton : public GfxButton { +private: + GfxSurface *_savedButton; +public: + int _buttonIndex; + + RightClickButton(int buttonIndex, int xp, int yp); + ~RightClickButton() { delete _savedButton; } + + virtual void highlight(); +}; + +class RightClickDialog : public GfxDialog { +private: + GfxSurface _surface; + RightClickButton *_highlightedButton; + int _selectedAction; + RightClickButton _walkButton, _lookButton, _useButton, _talkButton, _inventoryButton, _optionsButton; + + RightClickButton *findButton(const Common::Point &pt); +public: + RightClickDialog(); + ~RightClickDialog(); + + virtual void draw(); + virtual bool process(Event &event); + void execute(); +}; + +} // End of namespace Ringworld + +} // End of namespace TsAGE + +#endif -- cgit v1.2.3 From 3623ae35efd6269c862ab894ef03fbeb7704d765 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 29 Aug 2011 12:38:22 +0200 Subject: DREAMWEB: 'addtopeoplelist' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 19 ------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/sprite.cpp | 8 ++++++++ engines/dreamweb/stubs.h | 1 + 5 files changed, 11 insertions(+), 21 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index f2134be215..641b784526 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -163,6 +163,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'readmouse4', 'waitframes', 'drawflags', + 'addtopeoplelist', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index f716d89769..b7e5ba5917 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2032,24 +2032,6 @@ gottrainframe: showgamereel(); } -void DreamGenContext::addtopeoplelist() { - STACK_CHECK; - push(es); - push(bx); - push(bx); - cl = es.byte(bx+7); - ax = es.word(bx+3); - bx = data.word(kListpos); - es = data.word(kBuffers); - es.word(bx) = ax; - ax = pop(); - es.word(bx+2) = ax; - es.byte(bx+4) = cl; - bx = pop(); - es = pop(); - _add(data.word(kListpos), 5); -} - void DreamGenContext::checkspeed() { STACK_CHECK; _cmp(data.byte(kLastweapon), -1); @@ -17948,7 +17930,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_copper: copper(); break; case addr_sparky: sparky(); break; case addr_train: train(); break; - case addr_addtopeoplelist: addtopeoplelist(); break; case addr_checkspeed: checkspeed(); break; case addr_delsprite: delsprite(); break; case addr_mainman: mainman(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 3ad99d1543..18b982f3e4 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -596,7 +596,6 @@ public: static const uint16 addr_mainman = 0xc138; static const uint16 addr_delsprite = 0xc11c; static const uint16 addr_checkspeed = 0xc110; - static const uint16 addr_addtopeoplelist = 0xc108; static const uint16 addr_train = 0xc104; static const uint16 addr_sparky = 0xc100; static const uint16 addr_copper = 0xc0fc; @@ -1413,7 +1412,7 @@ public: void showdiary(); void purgealocation(); //void updatepeople(); - void addtopeoplelist(); + //void addtopeoplelist(); void hangoncurs(); void sparkydrip(); void compare(); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 17d4ddbbed..95d8321ad1 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -889,5 +889,13 @@ void DreamGenContext::checkone(uint8 x, uint8 y, uint8 *flag, uint8 *flagEx, uin *type = tileData[2]; } +void DreamGenContext::addtopeoplelist() { + People *people = (People *)segRef(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(People)); + people->setW0(es.word(bx+3)); + people->setW2(bx); + people->b4 = es.byte(bx+7); + data.word(kListpos) += sizeof(People); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index bb5568e20d..746855b18d 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -193,4 +193,5 @@ void readmouse4(); uint16 waitframes(); void drawflags(); + void addtopeoplelist(); -- cgit v1.2.3 From 3d85a4974bfd93a69fa51f54b12c0728509450fa Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 29 Aug 2011 14:54:21 +0200 Subject: DREAMWEB: 'showgamereel' gets a ReelRoutine* as parameter --- engines/dreamweb/sprite.cpp | 12 ++++++------ engines/dreamweb/structs.h | 2 ++ engines/dreamweb/stubs.cpp | 4 ++++ engines/dreamweb/stubs.h | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 95d8321ad1..f555daa626 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -549,16 +549,16 @@ void DreamGenContext::showreelframe(Reel *reel) { } void DreamGenContext::showgamereel() { - uint16 reelpointer = es.word(bx+3); + showgamereel((ReelRoutine *)es.ptr(bx, sizeof(ReelRoutine))); +} + +void DreamGenContext::showgamereel(ReelRoutine *routine) { + uint16 reelpointer = routine->reelPointer(); if (reelpointer >= 512) return; data.word(kReelpointer) = reelpointer; - push(es); - push(bx); plotreel(); - bx = pop(); - es = pop(); - es.word(bx+3) = data.word(kReelpointer); + routine->setReelPointer(data.word(kReelpointer)); } const Frame *DreamGenContext::getreelframeax(uint16 frame) { diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 1cb52eccea..804684ad33 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -168,6 +168,8 @@ struct ReelRoutine { uint8 mapY; uint8 b3; uint8 b4; + uint16 reelPointer() const { return READ_LE_UINT16(&b3); } + void setReelPointer(uint16 v) { WRITE_LE_UINT16(&b3, v); } uint8 b5; uint8 b6; uint8 b7; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 92a2a3d139..d56394ea3f 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -935,7 +935,11 @@ void DreamGenContext::plotreel() { showreelframe(reel); ++reel; } + push(es); + push(bx); soundonreels(); + bx = pop(); + es = pop(); } void DreamGenContext::crosshair() { diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 746855b18d..2d5d45a692 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -99,6 +99,7 @@ void findsource(); Frame *findsourceCPP(); void showgamereel(); + void showgamereel(ReelRoutine *routine); void showreelframe(); void showreelframe(Reel *reel); const Frame *getreelframeax(uint16 frame); -- cgit v1.2.3 From 14ac4efa09f1b6b59f60769770a519397c6da3de Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 29 Aug 2011 14:55:57 +0200 Subject: DREAMWEB: 'addpeoplelist' takes a ReelRoutine* param --- engines/dreamweb/sprite.cpp | 12 +++++++++--- engines/dreamweb/structs.h | 8 ++++---- engines/dreamweb/stubs.cpp | 4 ++-- engines/dreamweb/stubs.h | 1 + 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index f555daa626..c2ec27739c 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -890,10 +890,16 @@ void DreamGenContext::checkone(uint8 x, uint8 y, uint8 *flag, uint8 *flagEx, uin } void DreamGenContext::addtopeoplelist() { + addtopeoplelist((ReelRoutine *)es.ptr(bx, sizeof(ReelRoutine))); +} + +void DreamGenContext::addtopeoplelist(ReelRoutine *routine) { + uint16 routinePointer = (const uint8 *)routine - cs.ptr(0, 0); + People *people = (People *)segRef(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(People)); - people->setW0(es.word(bx+3)); - people->setW2(bx); - people->b4 = es.byte(bx+7); + people->setReelPointer(routine->reelPointer()); + people->setRoutinePointer(routinePointer); + people->b4 = routine->b7; data.word(kListpos) += sizeof(People); } diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 804684ad33..6d3deacc6f 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -178,12 +178,12 @@ struct ReelRoutine { struct People { uint8 b0; uint8 b1; - uint16 w0() const { return READ_LE_UINT16(&b0); } - void setW0(uint16 v) { WRITE_LE_UINT16(&b0, v); } + uint16 reelPointer() const { return READ_LE_UINT16(&b0); } + void setReelPointer(uint16 v) { WRITE_LE_UINT16(&b0, v); } uint8 b2; uint8 b3; - uint16 w2() const { return READ_LE_UINT16(&b2); } - void setW2(uint16 v) { WRITE_LE_UINT16(&b2, v); } + uint16 routinePointer() const { return READ_LE_UINT16(&b2); } + void setRoutinePointer(uint16 v) { WRITE_LE_UINT16(&b2, v); } uint8 b4; }; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index d56394ea3f..33f7a414f9 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -985,7 +985,7 @@ bool DreamGenContext::checkifperson(uint8 x, uint8 y) { for (size_t i = 0; i < 12; ++i, ++people) { if (people->b4 == 255) continue; - data.word(kReelpointer) = people->w0(); + data.word(kReelpointer) = people->reelPointer(); Reel *reel = getreelstart(); if (reel->frame() == 0xffff) ++reel; @@ -1002,7 +1002,7 @@ bool DreamGenContext::checkifperson(uint8 x, uint8 y) { continue; if (y >= ymax) continue; - data.word(kPersondata) = people->w2(); + data.word(kPersondata) = people->routinePointer(); obname(people->b4, 5); return true; } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 2d5d45a692..70236aacb1 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -195,4 +195,5 @@ uint16 waitframes(); void drawflags(); void addtopeoplelist(); + void addtopeoplelist(ReelRoutine *routine); -- cgit v1.2.3 From 8004a82f29c7ab6613367e7dde01d3c7af437316 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 29 Aug 2011 10:34:48 -0400 Subject: MOHAWK: Fix using the Mac binary for Riven cursors --- engines/mohawk/cursors.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp index cbd17e0b86..8c72c9875e 100644 --- a/engines/mohawk/cursors.cpp +++ b/engines/mohawk/cursors.cpp @@ -199,12 +199,10 @@ void MacCursorManager::setCursor(uint16 id) { if (!stream) stream = _resFork->getResource(MKTAG('C','U','R','S'), id); - if (stream) { + if (stream) setMacCursor(stream); - delete stream; - } else { + else setDefaultCursor(); - } } LivingBooksCursorManager_v2::LivingBooksCursorManager_v2() { -- cgit v1.2.3 From 5e0c546aa99b789d528da307dac99dc704a0a995 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 29 Aug 2011 22:51:45 +0200 Subject: CGE: Remove code related to demos, and tag demos as unsupported --- engines/cge/cge.cpp | 60 ++++++++++++++++++++--------------------------- engines/cge/cge.h | 5 ++-- engines/cge/cge_main.cpp | 42 +++++++++++---------------------- engines/cge/detection.cpp | 27 ++++++++++----------- 4 files changed, 54 insertions(+), 80 deletions(-) diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index f471b63866..514580bbe3 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -46,7 +46,6 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) DebugMan.addDebugChannel(kCGEDebugFile, "file", "CGE IO debug channel"); DebugMan.addDebugChannel(kCGEDebugEngine, "engine", "CGE Engine debug channel"); - _isDemo = _gameDescription->flags & ADGF_DEMO; _startupMode = 1; _demoText = kDemo; _oldLev = 0; @@ -55,32 +54,17 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) } void CGEEngine::initCaveValues() { - if (_isDemo) { - _caveDx = 23; - _caveDy = 29; - _caveNx = 3; - _caveNy = 1; - } else { - _caveDx = 9; - _caveDy = 10; - _caveNx = 8; - _caveNy = 3; - } + _caveDx = 9; + _caveDy = 10; + _caveNx = 8; + _caveNy = 3; _caveMax = _caveNx * _caveNy; - if (_isDemo) { - _maxCaveArr[0] = _caveMax; - _maxCaveArr[1] = -1; - _maxCaveArr[2] = -1; - _maxCaveArr[3] = -1; - _maxCaveArr[4] = -1; - } else { - _maxCaveArr[0] = 1; - _maxCaveArr[1] = 8; - _maxCaveArr[2] = 16; - _maxCaveArr[3] = 23; - _maxCaveArr[4] = 24; - }; + _maxCaveArr[0] = 1; + _maxCaveArr[1] = 8; + _maxCaveArr[2] = 16; + _maxCaveArr[3] = 23; + _maxCaveArr[4] = 24; _heroXY = (Hxy *) malloc (sizeof(Hxy) * _caveMax); for (int i = 0; i < _caveMax; i++) { @@ -100,7 +84,7 @@ void CGEEngine::freeCaveValues() { free(_barriers); } -void CGEEngine::setup() { +void CGEEngine::init() { debugC(1, kCGEDebugEngine, "CGEEngine::setup()"); // Initialise fields @@ -129,7 +113,7 @@ void CGEEngine::setup() { _pocLight = new PocLight(this); for (int i = 0; i < kPocketNX; i++) _pocket[i] = NULL; - _horzLine = isDemo() ? NULL : new HorizLine(this); + _horzLine = new HorizLine(this); _infoLine = new InfoLine(this, kInfoW); _cavLight = new CavLight(this); _debugLine = new InfoLine(this, kScrWidth); @@ -170,9 +154,7 @@ void CGEEngine::setup() { _startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; } -CGEEngine::~CGEEngine() { - debugC(1, kCGEDebugEngine, "CGEEngine::~CGEEngine()"); - +void CGEEngine::deinit() { // Call classes with static members to clear them up Talk::deinit(); Bitmap::deinit(); @@ -215,17 +197,29 @@ CGEEngine::~CGEEngine() { freeCaveValues(); } +CGEEngine::~CGEEngine() { + debugC(1, kCGEDebugEngine, "CGEEngine::~CGEEngine()"); +} + Common::Error CGEEngine::run() { debugC(1, kCGEDebugEngine, "CGEEngine::run()"); + if (_gameDescription->flags & ADGF_DEMO) { + warning("Demos of Soltys are not supported.\nPlease get a free version on ScummVM download page"); + return Common::kUnsupportedGameidError; + } + // Initialize graphics using following: initGraphics(320, 200, false); // Setup necessary game objects - setup(); + init(); // Run the game cge_main(); + // Remove game objects + deinit(); + return Common::kNoError; } @@ -244,8 +238,4 @@ bool CGEEngine::canSaveGameStateCurrently() { return (_startupMode == 0) && _mouse->_active; } -bool CGEEngine::isDemo() const { - return _gameDescription->flags & ADGF_DEMO; -} - } // End of namespace CGE diff --git a/engines/cge/cge.h b/engines/cge/cge.h index f4260dc31a..98f9ba8bc2 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -104,12 +104,10 @@ public: virtual bool hasFeature(EngineFeature f) const; virtual bool canLoadGameStateCurrently(); virtual bool canSaveGameStateCurrently(); - bool isDemo() const; virtual Common::Error loadGameState(int slot); virtual Common::Error saveGameState(int slot, const Common::String &desc); const ADGameDescription *_gameDescription; - bool _isDemo; int _startupMode; int _demoText; int _oldLev; @@ -262,7 +260,8 @@ protected: private: CGEConsole *_console; - void setup(); + void init(); + void deinit(); }; // Example console class diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 8763cb9967..4b834c9800 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -225,6 +225,8 @@ Common::Error CGEEngine::loadGameState(int slot) { // Load the game loadGame(slot, NULL); _snail->addCom(kSnLevel, -1, _oldLev, &_cavLight); + _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX, + kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY); caveUp(); return Common::kNoError; @@ -670,8 +672,7 @@ void CGEEngine::switchCave(int cav) { if (_hero) { _hero->park(); _hero->step(0); - if (!_isDemo) - _vga->_spareQ->_show = 0; + _vga->_spareQ->_show = 0; } _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX, kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY); @@ -1196,19 +1197,6 @@ void CGEEngine::loadScript(const char *fname) { } void CGEEngine::mainLoop() { - if (_isDemo) { -// static uint32 tc = 0; - if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ _talk == NULL && _snail->idle()) { - if (_text->getText(_demoText)) { - _snail->addCom(kSnSound, -1, 4, NULL); // drumla - _snail->addCom(kSnInf, -1, _demoText, NULL); - _snail->addCom(kSnLabel, -1, -1, NULL); - if (_text->getText(++_demoText) == NULL) - _demoText = kDemo + 1; - } - //FIXME: tc = TimerCount; - } - } _vga->show(); _snail_->runCom(); _snail->runCom(); @@ -1463,18 +1451,16 @@ bool CGEEngine::showTitle(const char *name) { } if (_mode < 2) { - if (!_isDemo) { - // At this point the game originally set the protection variables - // used by the copy protection check - movie("X00"); // paylist - _vga->copyPage(1, 2); - _vga->copyPage(0, 1); - _vga->_showQ->append(_mouse); - // In the original game, the user had to enter his name - // As it was only used to name savegames, it has been removed - _vga->_showQ->clear(); - _vga->copyPage(0, 2); - } + // At this point the game originally set the protection variables + // used by the copy protection check + movie("X00"); // paylist + _vga->copyPage(1, 2); + _vga->copyPage(0, 1); + _vga->_showQ->append(_mouse); + // In the original game, the user had to enter his name + // As it was only used to name savegames, it has been removed + _vga->_showQ->clear(); + _vga->copyPage(0, 2); if (_mode == 0) { // The auto-load of savegame #0 is currently disabled @@ -1531,7 +1517,7 @@ void CGEEngine::cge_main() { movie(kLgoExt); if (showTitle("WELCOME")) { - if ((!_isDemo) && (_mode == 1)) + if (_mode == 1) movie("X02"); // intro runGame(); _startupMode = 2; diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index 5e74166222..c64295db0e 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -57,35 +57,34 @@ static const ADGameDescription gameDescriptions[] = { }, Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE }, + // English ScummVM version { - "soltys", "Soltys Demo", + "soltys", "", { - {"vol.cat", 0, "1e077c8ff58109a187f07ac54b0c873a", 18788}, - {"vol.dat", 0, "75d385a6074c58b69f7730481f256051", 1796710}, + {"vol.cat", 0, "bd08969b5f1acea0f92d195f750c17d5", 50176}, + {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8428832}, AD_LISTEND }, - Common::PL_POL, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE + Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE }, { - "soltys", "Soltys Demo", + "soltys", "Soltys Demo (not supported)", { - {"vol.cat", 0, "f17987487fab1ebddd781d8d02fedecc", 7168}, - {"vol.dat", 0, "c5d9b15863cab61dc125551576dece04", 1075272}, + {"vol.cat", 0, "1e077c8ff58109a187f07ac54b0c873a", 18788}, + {"vol.dat", 0, "75d385a6074c58b69f7730481f256051", 1796710}, AD_LISTEND }, - Common::PL_POL, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE + Common::PL_POL, Common::kPlatformPC, ADGF_DEMO , GUIO_NONE }, - // English ScummVM version { - "soltys", "", + "soltys", "Soltys Demo (not supported)", { - {"vol.cat", 0, "bd08969b5f1acea0f92d195f750c17d5", 50176}, - {"vol.dat", 0, "f9ae2e7f8f7cac91378cdafca43faf1e", 8428832}, + {"vol.cat", 0, "f17987487fab1ebddd781d8d02fedecc", 7168}, + {"vol.dat", 0, "c5d9b15863cab61dc125551576dece04", 1075272}, AD_LISTEND }, - Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + Common::PL_POL, Common::kPlatformPC, ADGF_DEMO , GUIO_NONE }, - AD_TABLE_END_MARKER }; -- cgit v1.2.3 From 951dfa2be973e5234df3fbca4d14e10f0dcd3c9c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 29 Aug 2011 23:10:33 +0200 Subject: CGE: Fix the language of one of the demos --- engines/cge/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp index c64295db0e..abb0cf5efb 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -74,7 +74,7 @@ static const ADGameDescription gameDescriptions[] = { {"vol.dat", 0, "75d385a6074c58b69f7730481f256051", 1796710}, AD_LISTEND }, - Common::PL_POL, Common::kPlatformPC, ADGF_DEMO , GUIO_NONE + Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO , GUIO_NONE }, { "soltys", "Soltys Demo (not supported)", -- cgit v1.2.3 From c79984634474a0bfe564e2043652adf598f4cc73 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 29 Aug 2011 16:31:00 +0200 Subject: DREAMWEB: 'showallex' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/backdrop.cpp | 35 +++++++++++++++ engines/dreamweb/dreamgen.cpp | 89 --------------------------------------- engines/dreamweb/dreamgen.h | 3 +- engines/dreamweb/stubs.h | 1 + 5 files changed, 38 insertions(+), 91 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 641b784526..85a1b4b478 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -143,6 +143,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'placesetobject', 'removesetobject', 'showallfree', + 'showallex', 'adjustlen', 'finishedwalking', 'checkone', diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp index f667e7b73c..cfa4d571e8 100644 --- a/engines/dreamweb/backdrop.cpp +++ b/engines/dreamweb/backdrop.cpp @@ -297,5 +297,40 @@ void DreamGenContext::drawflags() { } } +void DreamGenContext::showallex() { + data.word(kListpos) = kExlist; + memset(segRef(data.word(kBuffers)).ptr(kExlist, 100 * 5), 0xff, 100 * 5); + + data.word(kFrsegment) = data.word(kExtras); + data.word(kDataad) = kExframedata; + data.word(kFramesad) = kExframes; + data.byte(kCurrentex) = 0; + si = kExdata + 2; + for (size_t i = 0; i < 100; ++i, ++data.byte(kCurrentex), si +=16) { + es = data.word(kExtras); + if (es.byte(si) == 0xff) + continue; + if (es.byte(si-2) != data.byte(kReallocation)) + continue; + if (getmapad((const uint8 *)es.ptr(si, 5)) == 0) + continue; + data.word(kCurrentframe) = 3 * data.byte(kCurrentex); + uint8 width, height; + calcfrframe(&width, &height); + uint16 x, y; + finalframe(&x, &y); + if ((width != 0) || (height != 0)) { + showframe((Frame *)segRef(data.word(kFrsegment)).ptr(0, 0), x + data.word(kMapadx), y + data.word(kMapady), data.word(kCurrentframe) & 0xff, 0); + ObjPos *objPos = (ObjPos *)segRef(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(ObjPos)); + objPos->xMin = data.byte(kSavex); + objPos->yMin = data.byte(kSavey); + objPos->xMax = data.byte(kSavesize + 0) + data.byte(kSavex); + objPos->yMax = data.byte(kSavesize + 1) + data.byte(kSavey); + objPos->index = i; + data.word(kListpos) += sizeof(ObjPos); + } + } +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index b7e5ba5917..5b1e30fddb 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -6303,94 +6303,6 @@ void DreamGenContext::drawfloor() { es = pop(); } -void DreamGenContext::showallex() { - STACK_CHECK; - es = data.word(kBuffers); - bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)); - data.word(kListpos) = bx; - di = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)); - cx = 100*5; - al = 255; - _stosb(cx, true); - es = data.word(kExtras); - data.word(kFrsegment) = es; - ax = (0); - data.word(kDataad) = ax; - ax = (0+2080); - data.word(kFramesad) = ax; - data.byte(kCurrentex) = 0; - si = (0+2080+30000)+2; - cx = 0; -exloop: - push(cx); - push(si); - es = data.word(kExtras); - push(si); - ch = 0; - _cmp(es.byte(si), 255); - if (flags.z()) - goto notinroom; - al = es.byte(si-2); - _cmp(al, data.byte(kReallocation)); - if (!flags.z()) - goto notinroom; - getmapad(); -notinroom: - si = pop(); - _cmp(ch, 0); - if (flags.z()) - goto blankex; - al = data.byte(kCurrentex); - ah = 0; - dx = ax; - _add(ax, ax); - _add(ax, dx); - data.word(kCurrentframe) = ax; - push(es); - push(si); - calcfrframe(); - es = data.word(kMapstore); - ds = data.word(kFrsegment); - finalframe(); - si = pop(); - es = pop(); - _cmp(cx, 0); - if (flags.z()) - goto blankex; - ax = data.word(kCurrentframe); - ah = 0; - _add(di, data.word(kMapadx)); - _add(bx, data.word(kMapady)); - showframe(); - si = data.word(kListpos); - es = data.word(kBuffers); - al = data.byte(kSavex); - ah = data.byte(kSavey); - es.word(si) = ax; - cx = ax; - ax = data.word(kSavesize); - _add(al, cl); - _add(ah, ch); - es.word(si+2) = ax; - ax = pop(); - cx = pop(); - push(cx); - push(ax); - es.byte(si+4) = cl; - _add(si, 5); - data.word(kListpos) = si; -blankex: - _inc(data.byte(kCurrentex)); - si = pop(); - cx = pop(); - _add(si, 16); - _inc(cx); - _cmp(cx, 100); - if (flags.z()) - return /* (finex) */; - goto exloop; -} - void DreamGenContext::autolook() { STACK_CHECK; ax = data.word(kMousex); @@ -18078,7 +17990,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_deleteextext: deleteextext(); break; case addr_blockget: blockget(); break; case addr_drawfloor: drawfloor(); break; - case addr_showallex: showallex(); break; case addr_autolook: autolook(); break; case addr_look: look(); break; case addr_dolook: dolook(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 18b982f3e4..cc777f4e82 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -447,7 +447,6 @@ public: static const uint16 addr_dolook = 0xc474; static const uint16 addr_look = 0xc470; static const uint16 addr_autolook = 0xc46c; - static const uint16 addr_showallex = 0xc450; static const uint16 addr_drawfloor = 0xc428; static const uint16 addr_blockget = 0xc424; static const uint16 addr_deleteextext = 0xc420; @@ -1468,7 +1467,7 @@ public: void dumpdiarykeys(); void disablesoundint(); void checkifset(); - void showallex(); + //void showallex(); void openpoolboss(); void buttontwo(); //void usetimedtext(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 70236aacb1..0be9c793cf 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -170,6 +170,7 @@ void removesetobject(); void removesetobject(uint8 index); void showallfree(); + void showallex(); bool finishedwalkingCPP(); void finishedwalking(); void checkone(); -- cgit v1.2.3 From 081bdece0c66aa900935e5bff9ed8f3eb70eb4ec Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 02:18:55 +0200 Subject: DREAMWEB: More reversing of DynObject struct --- engines/dreamweb/backdrop.cpp | 12 ++++++------ engines/dreamweb/structs.h | 10 +++------- engines/dreamweb/stubs.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp index cfa4d571e8..4ffd58936c 100644 --- a/engines/dreamweb/backdrop.cpp +++ b/engines/dreamweb/backdrop.cpp @@ -305,14 +305,14 @@ void DreamGenContext::showallex() { data.word(kDataad) = kExframedata; data.word(kFramesad) = kExframes; data.byte(kCurrentex) = 0; - si = kExdata + 2; - for (size_t i = 0; i < 100; ++i, ++data.byte(kCurrentex), si +=16) { - es = data.word(kExtras); - if (es.byte(si) == 0xff) + DynObject *objects = (DynObject *)segRef(data.word(kExtras)).ptr(kExdata, sizeof(DynObject)); + for (size_t i = 0; i < 100; ++i, ++data.byte(kCurrentex)) { + DynObject *object = objects + i; + if (object->b2[0] == 0xff) continue; - if (es.byte(si-2) != data.byte(kReallocation)) + if (object->currentLocation != data.byte(kReallocation)) continue; - if (getmapad((const uint8 *)es.ptr(si, 5)) == 0) + if (getmapad(object->b2) == 0) continue; data.word(kCurrentframe) = 3 * data.byte(kCurrentex); uint8 width, height; diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 6d3deacc6f..0b99b01be9 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -119,18 +119,14 @@ struct SetObject { }; struct DynObject { - uint8 b0; + uint8 currentLocation; uint8 index; - uint8 b2; - uint8 b3; - uint8 b4; - uint8 b5; - uint8 b6; + uint8 b2[5]; uint8 b7; uint8 b8; uint8 b9; uint8 b10; - uint8 location; + uint8 initialLocation; uint8 id[4]; }; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 33f7a414f9..3c4c228471 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1177,8 +1177,8 @@ void DreamGenContext::dochange(uint8 index, uint8 value, uint8 type) { getsetad(index)->b58[0] = value; } else if (type == 1) { //freeobject DynObject *freeObject = getfreead(index); - if (freeObject->b2 == 0xff) - freeObject->b2 = value; + if (freeObject->b2[0] == 0xff) + freeObject->b2[0] = value; } else { //path bx = kPathdata + (type - 100) * 144 + index * 8; es = data.word(kReels); @@ -1190,10 +1190,10 @@ void DreamGenContext::deletetaken() { const DynObject *extraObjects = (const DynObject *)segRef(data.word(kExtras)).ptr(kExdata, 0); DynObject *freeObjects = (DynObject *)segRef(data.word(kFreedat)).ptr(0, 0); for(size_t i = 0; i < kNumexobjects; ++i) { - uint8 location = extraObjects[i].location; + uint8 location = extraObjects[i].initialLocation; if (location == data.byte(kReallocation)) { uint8 index = extraObjects[i].index; - freeObjects[index].b2 = 254; + freeObjects[index].b2[0] = 254; } } } -- cgit v1.2.3 From 7624083cdcb80c044bd34391a4d536e12bb2320d Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 02:26:28 +0200 Subject: DREAMWEB: 'getexpos' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 19 ------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 11 +++++++++++ engines/dreamweb/stubs.h | 2 ++ 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 85a1b4b478..b76edfe351 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -165,6 +165,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'waitframes', 'drawflags', 'addtopeoplelist', + 'getexpos', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 5b1e30fddb..d2a9651267 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -6026,24 +6026,6 @@ moretext: goto moretext; } -void DreamGenContext::getexpos() { - STACK_CHECK; - es = data.word(kExtras); - al = 0; - di = (0+2080+30000); -tryanotherex: - _cmp(es.byte(di+2), 255); - if (flags.z()) - goto foundnewex; - _add(di, 16); - _inc(al); - _cmp(al, (114)); - if (!flags.z()) - goto tryanotherex; -foundnewex: - data.byte(kExpos) = al; -} - void DreamGenContext::purgealocation() { STACK_CHECK; push(ax); @@ -17981,7 +17963,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_pickupconts: pickupconts(); break; case addr_transfercontoex: transfercontoex(); break; case addr_transfertext: transfertext(); break; - case addr_getexpos: getexpos(); break; case addr_purgealocation: purgealocation(); break; case addr_emergencypurge: emergencypurge(); break; case addr_purgeanitem: purgeanitem(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index cc777f4e82..f80c2ebaf2 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -455,7 +455,6 @@ public: static const uint16 addr_purgeanitem = 0xc414; static const uint16 addr_emergencypurge = 0xc410; static const uint16 addr_purgealocation = 0xc40c; - static const uint16 addr_getexpos = 0xc408; static const uint16 addr_transfertext = 0xc404; static const uint16 addr_transfercontoex = 0xc400; static const uint16 addr_pickupconts = 0xc3fc; @@ -1336,7 +1335,7 @@ public: //void clearwork(); void loadtraveltext(); //void worktoscreen(); - void getexpos(); + //void getexpos(); void fadedos(); //void fillspace(); void selectlocation(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 3c4c228471..1ffe3295ef 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1198,6 +1198,17 @@ void DreamGenContext::deletetaken() { } } +void DreamGenContext::getexpos() { + const DynObject *objects = (const DynObject *)segRef(data.word(kExtras)).ptr(kExdata, sizeof(DynObject)); + for (size_t i = 0; i < kNumexobjects; ++i) { + if (objects[i].b2[0] == 0xff) { + data.byte(kExpos) = i; + return; + } + } + data.byte(kExpos) = kNumexobjects; +} + void DreamGenContext::placesetobject() { placesetobject(al); } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 0be9c793cf..c5a1742a9b 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -197,4 +197,6 @@ void drawflags(); void addtopeoplelist(); void addtopeoplelist(ReelRoutine *routine); + void getexpos(); + -- cgit v1.2.3 From 5bfe1f22d59471c50e0a6e65fb2dbf79e67fdf89 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 02:45:53 +0200 Subject: DREAMWEB: 'paneltomap' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 14 -------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.h | 2 +- engines/dreamweb/vgagrafx.cpp | 4 ++++ 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index b76edfe351..bc138cf49f 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -166,6 +166,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'drawflags', 'addtopeoplelist', 'getexpos', + 'paneltomap', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index d2a9651267..6ebb617f7e 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2657,19 +2657,6 @@ nought: goto palloop; } -void DreamGenContext::paneltomap() { - STACK_CHECK; - di = data.word(kMapxstart); - _add(di, data.word(kMapadx)); - bx = data.word(kMapystart); - _add(bx, data.word(kMapady)); - ds = data.word(kMapstore); - si = 0; - cl = data.byte(kMapxsize); - ch = data.byte(kMapysize); - multiget(); -} - void DreamGenContext::maptopanel() { STACK_CHECK; di = data.word(kMapxstart); @@ -17849,7 +17836,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_showpcx: showpcx(); break; case addr_loadpalfromiff: loadpalfromiff(); break; case addr_setmode: setmode(); break; - case addr_paneltomap: paneltomap(); break; case addr_maptopanel: maptopanel(); break; case addr_dumpmap: dumpmap(); break; case addr_pixelcheckset: pixelcheckset(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index f80c2ebaf2..8cf0462d74 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -568,7 +568,6 @@ public: static const uint16 addr_pixelcheckset = 0xc1f8; static const uint16 addr_dumpmap = 0xc1f4; static const uint16 addr_maptopanel = 0xc1f0; - static const uint16 addr_paneltomap = 0xc1ec; static const uint16 addr_setmode = 0xc1dc; static const uint16 addr_loadpalfromiff = 0xc1d8; static const uint16 addr_showpcx = 0xc1cc; @@ -1457,7 +1456,7 @@ public: void runtap(); //void domix(); void priesttext(); - void paneltomap(); + //void paneltomap(); //void obname(); void getridoftemp3(); void getridoftemp2(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index c5a1742a9b..58bda83d84 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -198,5 +198,5 @@ void addtopeoplelist(); void addtopeoplelist(ReelRoutine *routine); void getexpos(); - + void paneltomap(); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 3c92640768..00fb1715ef 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -411,5 +411,9 @@ void DreamGenContext::zoom() { data.byte(kDidzoom) = 1; } +void DreamGenContext::paneltomap() { + multiget(segRef(data.word(kMapstore)).ptr(0, 0), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize)); +} + } /*namespace dreamgen */ -- cgit v1.2.3 From aefdf240fb91efbecc3dc929ae311faa9c8d7b02 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 02:53:49 +0200 Subject: DREAMWEB: 'obpicture' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 33 --------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 12 ++++++++++++ engines/dreamweb/stubs.h | 1 + 5 files changed, 15 insertions(+), 35 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index bc138cf49f..9ecd261a9e 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -167,6 +167,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'addtopeoplelist', 'getexpos', 'paneltomap', + 'obpicture', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 6ebb617f7e..bcc1cbb1e2 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -4487,38 +4487,6 @@ void DreamGenContext::examicon() { showframe(); } -void DreamGenContext::obpicture() { - STACK_CHECK; - al = data.byte(kCommand); - ah = data.byte(kObjecttype); - _cmp(ah, 1); - if (flags.z()) - return /* (setframe) */; - _cmp(ah, 4); - if (flags.z()) - goto exframe; - ds = data.word(kFreeframes); - di = 160; - bx = 68; - cl = al; - _add(al, al); - _add(al, cl); - _inc(al); - ah = 128; - showframe(); - return; -exframe: - ds = data.word(kExtras); - di = 160; - bx = 68; - cl = al; - _add(al, al); - _add(al, cl); - _inc(al); - ah = 128; - showframe(); -} - void DreamGenContext::describeob() { STACK_CHECK; getobtextstart(); @@ -17908,7 +17876,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_openob: openob(); break; case addr_obicons: obicons(); break; case addr_examicon: examicon(); break; - case addr_obpicture: obpicture(); break; case addr_describeob: describeob(); break; case addr_additionaltext: additionaltext(); break; case addr_obsthatdothings: obsthatdothings(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 8cf0462d74..d638722c6c 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -495,7 +495,6 @@ public: static const uint16 addr_obsthatdothings = 0xc36c; static const uint16 addr_additionaltext = 0xc368; static const uint16 addr_describeob = 0xc364; - static const uint16 addr_obpicture = 0xc360; static const uint16 addr_examicon = 0xc35c; static const uint16 addr_obicons = 0xc358; static const uint16 addr_openob = 0xc354; @@ -1871,7 +1870,7 @@ public: void settopleft(); void searchforstring(); //void clearsprites(); - void obpicture(); + //void obpicture(); void selectopenob(); //void widedoor(); void security(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 1ffe3295ef..0f3e6420ef 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1643,6 +1643,18 @@ void DreamGenContext::printmessage(uint16 x, uint16 y, uint8 index, uint8 maxWid printdirect(&string, x, &y, maxWidth, centered); } +void DreamGenContext::obpicture() { + if (data.byte(kObjecttype) == 1) + return; + Frame *frames; + if (data.byte(kObjecttype) == 4) + frames = (Frame *)segRef(data.word(kExtras)).ptr(0, 0); + else + frames = (Frame *)segRef(data.word(kFreeframes)).ptr(0, 0); + uint8 frame = 3 * data.byte(kCommand) + 1; + showframe(frames, 160, 68, frame, 0x80); +} + bool DreamGenContext::isCD() { // The original sources has two codepaths depending if the game is 'if cd' or not // This is a hack to guess which version to use with the assumption that if we have a cd version diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 58bda83d84..17b884cdc5 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -199,4 +199,5 @@ void addtopeoplelist(ReelRoutine *routine); void getexpos(); void paneltomap(); + void obpicture(); -- cgit v1.2.3 From 2fc467dc4f0aa563318458dceb8918d386128129 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 03:11:32 +0200 Subject: DREAMWEB: 'checkifex' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 36 ------------------------------------ engines/dreamweb/dreamgen.h | 5 ++--- engines/dreamweb/stubs.cpp | 24 ++++++++++++++++++++++++ engines/dreamweb/stubs.h | 2 ++ 5 files changed, 29 insertions(+), 39 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 9ecd261a9e..97d33b6c6e 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -108,6 +108,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'doblocks', 'checkifperson', 'checkiffree', + 'checkifex', 'getreelstart', 'findobname', 'copyname', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index bcc1cbb1e2..697eb4ef3f 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -15032,41 +15032,6 @@ notasetid: goto identifyset; } -void DreamGenContext::checkifex() { - STACK_CHECK; - es = data.word(kBuffers); - bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5))+(99*5); - cx = 99; -identifyex: - _cmp(es.byte(bx+4), 255); - if (flags.z()) - goto notanexid; - _cmp(al, es.byte(bx)); - if (flags.c()) - goto notanexid; - _cmp(al, es.byte(bx+2)); - if (!flags.c()) - goto notanexid; - _cmp(ah, es.byte(bx+1)); - if (flags.c()) - goto notanexid; - _cmp(ah, es.byte(bx+3)); - if (!flags.c()) - goto notanexid; - al = es.byte(bx+4); - ah = 4; - obname(); - al = 1; - _cmp(al, 0); - return; -notanexid: - _sub(bx, 5); - _dec(cx); - _cmp(cx, -1); - if (!flags.z()) - goto identifyex; -} - void DreamGenContext::isitdescribed() { STACK_CHECK; push(ax); @@ -18251,7 +18216,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_madmanrun: madmanrun(); break; case addr_identifyob: identifyob(); break; case addr_checkifset: checkifset(); break; - case addr_checkifex: checkifex(); break; case addr_isitdescribed: isitdescribed(); break; case addr_findpathofpoint: findpathofpoint(); break; case addr_findfirstpath: findfirstpath(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index d638722c6c..82d9cd137a 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -118,7 +118,6 @@ public: static const uint16 addr_findfirstpath = 0xc9f0; static const uint16 addr_findpathofpoint = 0xc9ec; static const uint16 addr_isitdescribed = 0xc9e8; - static const uint16 addr_checkifex = 0xc9e0; static const uint16 addr_checkifset = 0xc9dc; static const uint16 addr_identifyob = 0xc9d4; static const uint16 addr_madmanrun = 0xc9cc; @@ -1609,7 +1608,7 @@ public: void errormessage3(); //void deletetaken(); void putundermenu(); - void checkifex(); + void intromonks2(); void intromagic2(); void intromagic3(); void edeninbath(); @@ -1925,6 +1924,7 @@ public: void delcurs(); void randomaccess(); void splitintolines(); + //void checkifex(); //void findobname(); void initialmoncols(); void checkforshake(); @@ -1955,7 +1955,6 @@ public: //void parseblaster(); //void readmouse1(); void makemainscreen(); - void intromonks2(); void usewinch(); void setbotright(); //void readmouse3(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 0f3e6420ef..37125d8870 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1033,6 +1033,30 @@ bool DreamGenContext::checkiffree(uint8 x, uint8 y) { return false; } +void DreamGenContext::checkifex() { + flags._z = not checkifex(al, ah); +} + +bool DreamGenContext::checkifex(uint8 x, uint8 y) { + const ObjPos *exList = (const ObjPos *)segRef(data.word(kBuffers)).ptr(kExlist, 100 * sizeof(ObjPos)); + for (size_t i = 0; i < 100; ++i) { + const ObjPos *objPos = exList + 99 - i; + if (objPos->index == 0xff) + continue; + if (x < objPos->xMin) + continue; + if (x >= objPos->xMax) + continue; + if (y < objPos->yMin) + continue; + if (y >= objPos->yMax) + continue; + obname(objPos->index, 4); + return true; + } + return false; +} + const uint8 *DreamGenContext::findobname(uint8 type, uint8 index) { if (type == 5) { uint16 i = 64 * 2 * (index & 127); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 17b884cdc5..7c4f43acd3 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -126,6 +126,8 @@ bool checkifperson(uint8 x, uint8 y); void checkiffree(); bool checkiffree(uint8 x, uint8 y); + void checkifex(); + bool checkifex(uint8 x, uint8 y); const uint8 *findobname(uint8 type, uint8 index); void copyname(); void copyname(uint8 type, uint8 index, uint8 *dst); -- cgit v1.2.3 From 25675e885857fb152bd47cbce4588fc1f6a81f99 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 03:26:19 +0200 Subject: DREAMWEB: Structs member renaming --- engines/dreamweb/backdrop.cpp | 6 +++--- engines/dreamweb/structs.h | 4 ++-- engines/dreamweb/stubs.cpp | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp index 4ffd58936c..ed7836a20c 100644 --- a/engines/dreamweb/backdrop.cpp +++ b/engines/dreamweb/backdrop.cpp @@ -153,7 +153,7 @@ void DreamGenContext::showallobs() { SetObject *setEntries = (SetObject *)segRef(data.word(kSetdat)).ptr(0, 128 * sizeof(SetObject)); for (size_t i = 0; i < 128; ++i) { SetObject *setEntry = setEntries + i; - if (getmapad(setEntry->b58) == 0) + if (getmapad(setEntry->mapad) == 0) continue; uint8 currentFrame = setEntry->b18[0]; data.word(kCurrentframe) = currentFrame; @@ -308,11 +308,11 @@ void DreamGenContext::showallex() { DynObject *objects = (DynObject *)segRef(data.word(kExtras)).ptr(kExdata, sizeof(DynObject)); for (size_t i = 0; i < 100; ++i, ++data.byte(kCurrentex)) { DynObject *object = objects + i; - if (object->b2[0] == 0xff) + if (object->mapad[0] == 0xff) continue; if (object->currentLocation != data.byte(kReallocation)) continue; - if (getmapad(object->b2) == 0) + if (getmapad(object->mapad) == 0) continue; data.word(kCurrentframe) = 3 * data.byte(kCurrentex); uint8 width, height; diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 0b99b01be9..9b8d823491 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -114,14 +114,14 @@ struct SetObject { uint8 b55; uint8 b56; uint8 b57; - uint8 b58[5]; + uint8 mapad[5]; uint8 b63; }; struct DynObject { uint8 currentLocation; uint8 index; - uint8 b2[5]; + uint8 mapad[5]; uint8 b7; uint8 b8; uint8 b9; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 37125d8870..35f9df0a43 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1198,11 +1198,11 @@ void DreamGenContext::dochange() { void DreamGenContext::dochange(uint8 index, uint8 value, uint8 type) { if (type == 0) { //object - getsetad(index)->b58[0] = value; + getsetad(index)->mapad[0] = value; } else if (type == 1) { //freeobject DynObject *freeObject = getfreead(index); - if (freeObject->b2[0] == 0xff) - freeObject->b2[0] = value; + if (freeObject->mapad[0] == 0xff) + freeObject->mapad[0] = value; } else { //path bx = kPathdata + (type - 100) * 144 + index * 8; es = data.word(kReels); @@ -1217,7 +1217,7 @@ void DreamGenContext::deletetaken() { uint8 location = extraObjects[i].initialLocation; if (location == data.byte(kReallocation)) { uint8 index = extraObjects[i].index; - freeObjects[index].b2[0] = 254; + freeObjects[index].mapad[0] = 0xfe; } } } @@ -1225,7 +1225,7 @@ void DreamGenContext::deletetaken() { void DreamGenContext::getexpos() { const DynObject *objects = (const DynObject *)segRef(data.word(kExtras)).ptr(kExdata, sizeof(DynObject)); for (size_t i = 0; i < kNumexobjects; ++i) { - if (objects[i].b2[0] == 0xff) { + if (objects[i].mapad[0] == 0xff) { data.byte(kExpos) = i; return; } @@ -1239,7 +1239,7 @@ void DreamGenContext::placesetobject() { void DreamGenContext::placesetobject(uint8 index) { findormake(index, 0, 0); - getsetad(index)->b58[0] = 0; + getsetad(index)->mapad[0] = 0; } void DreamGenContext::removesetobject() { @@ -1248,7 +1248,7 @@ void DreamGenContext::removesetobject() { void DreamGenContext::removesetobject(uint8 index) { findormake(index, 0xff, 0); - getsetad(index)->b58[0] = 0xff; + getsetad(index)->mapad[0] = 0xff; } void DreamGenContext::finishedwalking() { -- cgit v1.2.3 From 018e304555e77b333c57f504efbefc5894b3e0c0 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 10:31:42 +0200 Subject: DREAMWEB: Stricter typing --- engines/dreamweb/backdrop.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp index ed7836a20c..2c399af3c4 100644 --- a/engines/dreamweb/backdrop.cpp +++ b/engines/dreamweb/backdrop.cpp @@ -253,9 +253,9 @@ void DreamGenContext::showallfree() { data.word(kDataad) = kFrframedata; data.word(kFramesad) = kFrframes; data.byte(kCurrentfree) = 0; - const uint8 *mapData = segRef(data.word(kFreedat)).ptr(2, 0); + const DynObject *freeObjects = (const DynObject *)segRef(data.word(kFreedat)).ptr(0, 0); for(size_t i = 0; i < 80; ++i) { - uint8 mapad = getmapad(mapData); + uint8 mapad = getmapad(freeObjects[i].mapad); if (mapad != 0) { data.word(kCurrentframe) = 3 * data.byte(kCurrentfree); uint8 width, height; @@ -277,7 +277,6 @@ void DreamGenContext::showallfree() { } ++data.byte(kCurrentfree); - mapData += 16; } } -- cgit v1.2.3 From 0567d6cec5cd11db790b6aec966fcb0463deffba Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 10:52:44 +0200 Subject: DREAMWEB: 'delthisone' isn't used --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 45 --------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 97d33b6c6e..c129b248ce 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -169,6 +169,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'getexpos', 'paneltomap', 'obpicture', + 'delthisone', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 697eb4ef3f..bfead17dc7 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2766,50 +2766,6 @@ void DreamGenContext::createpanel2() { showframe(); } -void DreamGenContext::delthisone() { - STACK_CHECK; - push(ax); - push(ax); - al = ah; - ah = 0; - _add(ax, data.word(kMapady)); - bx = (320); - _mul(bx); - bx = pop(); - bh = 0; - _add(bx, data.word(kMapadx)); - _add(ax, bx); - di = ax; - ax = pop(); - push(ax); - al = ah; - ah = 0; - bx = 22*8; - _mul(bx); - bx = pop(); - bh = 0; - _add(ax, bx); - si = ax; - es = data.word(kWorkspace); - ds = data.word(kMapstore); - dl = cl; - dh = 0; - ax = (320); - _sub(ax, dx); - _neg(dx); - _add(dx, 22*8); -deloneloop: - push(cx); - ch = 0; - _movsb(cx, true); - cx = pop(); - _add(di, ax); - _add(si, dx); - _dec(ch); - if (!flags.z()) - goto deloneloop; -} - void DreamGenContext::transferinv() { STACK_CHECK; di = data.word(kExframepos); @@ -17776,7 +17732,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_createpanel2: createpanel2(); break; case addr_vsync: vsync(); break; case addr_doshake: doshake(); break; - case addr_delthisone: delthisone(); break; case addr_transferinv: transferinv(); break; case addr_transfermap: transfermap(); break; case addr_fadedos: fadedos(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 82d9cd137a..963a864bb3 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -558,7 +558,6 @@ public: static const uint16 addr_fadedos = 0xc248; static const uint16 addr_transfermap = 0xc244; static const uint16 addr_transferinv = 0xc240; - static const uint16 addr_delthisone = 0xc214; static const uint16 addr_doshake = 0xc20c; static const uint16 addr_vsync = 0xc208; static const uint16 addr_createpanel2 = 0xc200; @@ -1517,7 +1516,7 @@ public: void usetempcharset(); void discops(); //void printdirect(); - void delthisone(); + //void delthisone(); //void makebackob(); void middlepanel(); void dumpwatch(); -- cgit v1.2.3 From ed9cf01c78d639f0503ee8ea51c4033ff6158b1b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 30 Aug 2011 12:57:50 +0300 Subject: SAGA: Slight cleanup --- engines/saga/sthread.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/engines/saga/sthread.cpp b/engines/saga/sthread.cpp index afd528f4b5..6e5cc68ae6 100644 --- a/engines/saga/sthread.cpp +++ b/engines/saga/sthread.cpp @@ -102,9 +102,8 @@ void Script::wakeUpThreadsDelayed(int waitType, int sleepTime) { void Script::executeThreads(uint msec) { ScriptThreadList::iterator threadIterator; - if (_vm->_interface->_statusTextInput) { + if (_vm->_interface->_statusTextInput) return; - } threadIterator = _threadList.begin(); @@ -129,11 +128,10 @@ void Script::executeThreads(uint msec) { switch (thread._waitType) { case kWaitTypeDelay: - if (thread._sleepTime < msec) { + if (thread._sleepTime < msec) thread._sleepTime = 0; - } else { + else thread._sleepTime -= msec; - } if (thread._sleepTime == 0) thread._flags &= ~kTFlagWaiting; @@ -141,11 +139,9 @@ void Script::executeThreads(uint msec) { case kWaitTypeWalk: { - ActorData *actor; - actor = (ActorData *)thread._threadObj; - if (actor->_currentAction == kActionWait) { + ActorData *actor = (ActorData *)thread._threadObj; + if (actor->_currentAction == kActionWait) thread._flags &= ~kTFlagWaiting; - } } break; @@ -157,9 +153,8 @@ void Script::executeThreads(uint msec) { } if (!(thread._flags & kTFlagWaiting)) { - if (runThread(thread)) { + if (runThread(thread)) break; - } } ++threadIterator; -- cgit v1.2.3 From b71123ef4f6ecfb8c60fa87d8fb2da0d2f40eded Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 30 Aug 2011 12:58:57 +0300 Subject: SAGA: properly remove the save reminder callback on engine exit This fixes an error when exiting to the launcher and restarting a game --- engines/saga/interface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index fe37ed8995..994b35cbf8 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -324,6 +324,7 @@ Interface::Interface(SagaEngine *vm) : _vm(vm) { } Interface::~Interface() { + _vm->getTimerManager()->removeTimerProc(&saveReminderCallback); } void Interface::saveReminderCallback(void *refCon) { -- cgit v1.2.3 From 6a46429c448aa3899fa93e49dc36cd3617b922c7 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 10:56:49 +0200 Subject: DREAMWEB: 'transferinv' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 50 --------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.h | 1 + engines/dreamweb/vgagrafx.cpp | 17 +++++++++++++ 5 files changed, 20 insertions(+), 52 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index c129b248ce..f0cfe30ea7 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -170,6 +170,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'paneltomap', 'obpicture', 'delthisone', + 'transferinv', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index bfead17dc7..ee034448b5 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2766,55 +2766,6 @@ void DreamGenContext::createpanel2() { showframe(); } -void DreamGenContext::transferinv() { - STACK_CHECK; - di = data.word(kExframepos); - push(di); - al = data.byte(kExpos); - ah = 0; - bx = ax; - _add(ax, ax); - _add(ax, bx); - _inc(ax); - cx = 6; - _mul(cx); - es = data.word(kExtras); - bx = (0); - _add(bx, ax); - _add(di, (0+2080)); - push(bx); - al = data.byte(kItemtotran); - ah = 0; - bx = ax; - _add(ax, ax); - _add(ax, bx); - _inc(ax); - cx = 6; - _mul(cx); - ds = data.word(kFreeframes); - bx = (0); - _add(bx, ax); - si = (0+2080); - al = ds.byte(bx); - ah = 0; - cl = ds.byte(bx+1); - ch = 0; - _add(si, ds.word(bx+2)); - dx = ds.word(bx+4); - bx = pop(); - es.byte(bx+0) = al; - es.byte(bx+1) = cl; - es.word(bx+4) = dx; - _mul(cx); - cx = ax; - push(cx); - _movsb(cx, true); - cx = pop(); - ax = pop(); - es.word(bx+2) = ax; - _add(data.word(kExframepos), cx); -} - void DreamGenContext::transfermap() { STACK_CHECK; di = data.word(kExframepos); @@ -17732,7 +17683,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_createpanel2: createpanel2(); break; case addr_vsync: vsync(); break; case addr_doshake: doshake(); break; - case addr_transferinv: transferinv(); break; case addr_transfermap: transfermap(); break; case addr_fadedos: fadedos(); break; case addr_dofade: dofade(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 963a864bb3..196c630d56 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -557,7 +557,6 @@ public: static const uint16 addr_dofade = 0xc24c; static const uint16 addr_fadedos = 0xc248; static const uint16 addr_transfermap = 0xc244; - static const uint16 addr_transferinv = 0xc240; static const uint16 addr_doshake = 0xc20c; static const uint16 addr_vsync = 0xc208; static const uint16 addr_createpanel2 = 0xc200; @@ -1775,7 +1774,7 @@ public: void look(); void setmouse(); //void checkone(); - void transferinv(); + //void transferinv(); void candles2(); void pickupob(); void error(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 7c4f43acd3..f025e382e4 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -202,4 +202,5 @@ void getexpos(); void paneltomap(); void obpicture(); + void transferinv(); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 00fb1715ef..235d28cc01 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -415,5 +415,22 @@ void DreamGenContext::paneltomap() { multiget(segRef(data.word(kMapstore)).ptr(0, 0), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize)); } +void DreamGenContext::transferinv() { + const Frame *freeFrames = (const Frame *)segRef(data.word(kFreeframes)).ptr(kFrframedata, 0); + const Frame *freeFrame = freeFrames + (3 * data.byte(kItemtotran) + 1); + Frame *exFrames = (Frame *)segRef(data.word(kExtras)).ptr(kExframedata, 0); + Frame *exFrame = exFrames + (3 * data.byte(kExpos) + 1); + exFrame->width = freeFrame->width; + exFrame->height = freeFrame->height; + exFrame->x = freeFrame->x; + exFrame->y = freeFrame->y; + uint16 byteCount = freeFrame->width * freeFrame->height; + const uint8 *src = segRef(data.word(kFreeframes)).ptr(kFrframes + freeFrame->ptr(), byteCount); + uint8 *dst = segRef(data.word(kExtras)).ptr(kExframes + data.word(kExframepos), byteCount); + memcpy(dst, src, byteCount); + exFrame->setPtr(data.word(kExframepos)); + data.word(kExframepos) += byteCount; +} + } /*namespace dreamgen */ -- cgit v1.2.3 From 233592d28a1f0ebf01c6ba29f3c2f6673f97553a Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 30 Aug 2011 12:22:09 +0200 Subject: DREAMWEB: 'maptopanel' and 'dumpmap' ported to C++ --- devtools/tasmrecover/tasm-recover | 2 ++ engines/dreamweb/dreamgen.cpp | 26 -------------------------- engines/dreamweb/dreamgen.h | 6 ++---- engines/dreamweb/stubs.h | 2 ++ engines/dreamweb/vgagrafx.cpp | 8 ++++++++ 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index f0cfe30ea7..658ff74aed 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -168,6 +168,8 @@ generator = cpp(context, "DreamGen", blacklist = [ 'addtopeoplelist', 'getexpos', 'paneltomap', + 'maptopanel', + 'dumpmap', 'obpicture', 'delthisone', 'transferinv', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index ee034448b5..b239842222 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2657,30 +2657,6 @@ nought: goto palloop; } -void DreamGenContext::maptopanel() { - STACK_CHECK; - di = data.word(kMapxstart); - _add(di, data.word(kMapadx)); - bx = data.word(kMapystart); - _add(bx, data.word(kMapady)); - ds = data.word(kMapstore); - si = 0; - cl = data.byte(kMapxsize); - ch = data.byte(kMapysize); - multiput(); -} - -void DreamGenContext::dumpmap() { - STACK_CHECK; - di = data.word(kMapxstart); - _add(di, data.word(kMapadx)); - bx = data.word(kMapystart); - _add(bx, data.word(kMapady)); - cl = data.byte(kMapxsize); - ch = data.byte(kMapysize); - multidump(); -} - void DreamGenContext::pixelcheckset() { STACK_CHECK; push(ax); @@ -17676,8 +17652,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_showpcx: showpcx(); break; case addr_loadpalfromiff: loadpalfromiff(); break; case addr_setmode: setmode(); break; - case addr_maptopanel: maptopanel(); break; - case addr_dumpmap: dumpmap(); break; case addr_pixelcheckset: pixelcheckset(); break; case addr_createpanel: createpanel(); break; case addr_createpanel2: createpanel2(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 196c630d56..2eb0b93c6a 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -562,8 +562,6 @@ public: static const uint16 addr_createpanel2 = 0xc200; static const uint16 addr_createpanel = 0xc1fc; static const uint16 addr_pixelcheckset = 0xc1f8; - static const uint16 addr_dumpmap = 0xc1f4; - static const uint16 addr_maptopanel = 0xc1f0; static const uint16 addr_setmode = 0xc1dc; static const uint16 addr_loadpalfromiff = 0xc1d8; static const uint16 addr_showpcx = 0xc1cc; @@ -1290,7 +1288,7 @@ public: //void lockeddoorway(); void isitworn(); //void putundertimed(); - void dumpmap(); + //void dumpmap(); //void multidump(); void channel0only(); void worktoscreenm(); @@ -1539,7 +1537,7 @@ public: void monks2text(); void clearpalette(); void cantdrop(); - void maptopanel(); + //void maptopanel(); //void calcmapad(); void getridofall(); void copper(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index f025e382e4..f137707220 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -201,6 +201,8 @@ void addtopeoplelist(ReelRoutine *routine); void getexpos(); void paneltomap(); + void maptopanel(); + void dumpmap(); void obpicture(); void transferinv(); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 235d28cc01..5c63b88682 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -415,6 +415,14 @@ void DreamGenContext::paneltomap() { multiget(segRef(data.word(kMapstore)).ptr(0, 0), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize)); } +void DreamGenContext::maptopanel() { + multiput(segRef(data.word(kMapstore)).ptr(0, 0), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize)); +} + +void DreamGenContext::dumpmap() { + multidump(data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize)); +} + void DreamGenContext::transferinv() { const Frame *freeFrames = (const Frame *)segRef(data.word(kFreeframes)).ptr(kFrframedata, 0); const Frame *freeFrame = freeFrames + (3 * data.byte(kItemtotran) + 1); -- cgit v1.2.3 From cee156d5963a2eae868cf4d93ebca57d8cdb2b83 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 31 Aug 2011 22:18:11 +1000 Subject: TSAGE: Implemented missing functionality for first game scene --- engines/tsage/blue_force/blueforce_logic.cpp | 48 +++++++++++++++++ engines/tsage/blue_force/blueforce_logic.h | 3 +- engines/tsage/blue_force/blueforce_scenes3.cpp | 72 ++++++++++++++++++-------- engines/tsage/blue_force/blueforce_scenes3.h | 13 ++--- engines/tsage/blue_force/blueforce_ui.cpp | 2 +- engines/tsage/core.cpp | 60 +++++++++++++++++---- engines/tsage/core.h | 5 +- engines/tsage/events.cpp | 2 +- engines/tsage/globals.cpp | 2 + engines/tsage/globals.h | 2 + 10 files changed, 165 insertions(+), 44 deletions(-) diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 985a1578ab..31ebab3c47 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -314,6 +314,38 @@ void NamedObject::synchronize(Serializer &s) { s.syncAsSint16LE(_useLineNum); } +void NamedObject::startAction(CursorType action) { + bool handled = true; + + switch (action) { + case CURSOR_LOOK: + if (_lookLineNum == -1) + handled = false; + else + SceneItem::display2(_resNum, _lookLineNum); + break; + case CURSOR_USE: + if (_useLineNum == -1) + handled = false; + else + SceneItem::display2(_resNum, _useLineNum); + break; + case CURSOR_TALK: + if (_talkLineNum == -1) + handled = false; + else + SceneItem::display2(_resNum, _talkLineNum); + break; + default: + handled = false; + break; + } +/* + if (!handled) + ((SceneExt *)BF_GLOBALS._sceneManager._scene)->display(action); +*/ +} + void NamedObject::setup(int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { _resNum = resNum; _lookLineNum = lookLineNum; @@ -336,6 +368,7 @@ void NamedObject::setup(int resNum, int lookLineNum, int talkLineNum, int useLin } } + /*--------------------------------------------------------------------------*/ CountdownObject::CountdownObject(): NamedObject() { @@ -467,6 +500,21 @@ void SceneExt::loadScene(int sceneNum) { _v51C34.bottom = 300; } +void SceneExt::checkGun() { + if (BF_GLOBALS.getFlag(fLoadedSpare) && (BF_GLOBALS._v4CEBA > 0)) { + if (--BF_GLOBALS._v4CEBA == 0) + BF_GLOBALS.clearFlag(fGunLoaded); + } else { + if (BF_GLOBALS._v4CEB8 > 0) + --BF_GLOBALS._v4CEB8; + + if (!BF_GLOBALS._v4CEB8) + BF_GLOBALS.clearFlag(fGunLoaded); + } + + BF_GLOBALS._sound3.play(4); +} + /*--------------------------------------------------------------------------*/ GameScene::GameScene() { diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index a3bcf9ea01..9de7add49d 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -106,6 +106,7 @@ public: virtual Common::String getClassName() { return "NamedObject"; } virtual void synchronize(Serializer &s); virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void startAction(CursorType action); void setup(int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item); }; @@ -151,7 +152,7 @@ public: virtual void process(Event &event); virtual void dispatch(); virtual void loadScene(int sceneNum); - virtual void proc13() { warning("TODO: SceneExt::proc13"); } + virtual void checkGun(); void addTimer(Timer *timer) { _timerList.add(timer); } void removeTimer(Timer *timer) { _timerList.remove(timer); } diff --git a/engines/tsage/blue_force/blueforce_scenes3.cpp b/engines/tsage/blue_force/blueforce_scenes3.cpp index 42c5c5dcde..fd1e613d00 100644 --- a/engines/tsage/blue_force/blueforce_scenes3.cpp +++ b/engines/tsage/blue_force/blueforce_scenes3.cpp @@ -36,18 +36,18 @@ namespace BlueForce { * *--------------------------------------------------------------------------*/ -void Scene300::Object::startMover(CursorType action) { +void Scene300::Object::startAction(CursorType action) { if (action == CURSOR_TALK) { Scene300 *scene = (Scene300 *)BF_GLOBALS._sceneManager._scene; scene->_stripManager.start(_stripNumber, scene); } else { - NamedObject::startMover(action); + NamedObject::startAction(action); } } -void Scene300::Object17::startMover(CursorType action) { +void Scene300::Object17::startAction(CursorType action) { if ((action != CURSOR_USE) || !BF_GLOBALS.getFlag(3)) { - NamedObject::startMover(action); + NamedObject::startAction(action); } else if ((BF_GLOBALS._dayNumber != 2) || (BF_GLOBALS._bookmark >= bEndDayOne)) { Scene300 *scene = (Scene300 *)BF_GLOBALS._sceneManager._scene; setAction(&scene->_action4); @@ -56,32 +56,32 @@ void Scene300::Object17::startMover(CursorType action) { } } -void Scene300::Item1::startMover(CursorType action) { - if (action == CURSOR_TALK) { +void Scene300::Item1::startAction(CursorType action) { + if (action == CURSOR_USE) { Scene300 *scene = (Scene300 *)BF_GLOBALS._sceneManager._scene; BF_GLOBALS._player.disableControl(); scene->_sceneMode = 305; scene->setAction(&scene->_sequenceManager1, scene, 305, &BF_GLOBALS._player, &scene->_object8, NULL); } else { - NamedHotspot::startMover(action); + NamedHotspot::startAction(action); } } -void Scene300::Item2::startMover(CursorType action) { +void Scene300::Item2::startAction(CursorType action) { if ((action == CURSOR_LOOK) || (action == CURSOR_USE)) { Scene300 *scene = (Scene300 *)BF_GLOBALS._sceneManager._scene; scene->setAction(&scene->_sequenceManager1, scene, 304, &scene->_object11, NULL); } else { - NamedHotspot::startMover(action); + NamedHotspot::startAction(action); } } -void Scene300::Item14::startMover(CursorType action) { +void Scene300::Item14::startAction(CursorType action) { ADD_PLAYER_MOVER_NULL(BF_GLOBALS._player, 151, 54); } -void Scene300::Item15::startMover(CursorType action) { +void Scene300::Item15::startAction(CursorType action) { ADD_PLAYER_MOVER_NULL(BF_GLOBALS._player, 316, 90); } @@ -94,10 +94,10 @@ void Scene300::Action1::signal() { setDelay(1); break; case 1: - if (BF_GLOBALS.getFlag(7)) - SceneItem::display2(300, 0); - else + if (BF_GLOBALS.getFlag(fWithLyle)) SceneItem::display2(666, 27); + else + SceneItem::display2(300, 0); setDelay(1); break; case 2: { @@ -222,6 +222,8 @@ void Scene300::Action5::signal() { Scene300::Scene300(): SceneExt(), _object13(3000), _object14(3001), _object15(3002), _object16(3003) { _field2760 = _field2762 = 0; + + _cursorVisage.setVisage(1, 8); } void Scene300::postInit(SceneObjectList *OwnerList) { @@ -341,6 +343,20 @@ BF_GLOBALS._player.setStrip(1); setAction(&_sequenceManager1, this, 306, &BF_GLOBALS._player, &_object8, NULL); break; } + + _item10.setup(4, 300, 7, 13, 16, 1); + _item11.setup(2, 300, 9, 13, 18, 1); + _item12.setup(5, 300, 10, 13, 19, 1); + _item13.setup(3, 300, 25, 26, 27, 1); + _item2.setup(Rect(266, 54, 272, 59), 300, -1, -1, -1, 1, NULL); + _item1.setup(Rect(262, 47, 299, 76), 300, 1, 13, -1, 1, NULL); + _item4.setup(Rect(0, 85, SCREEN_WIDTH - 1, BF_INTERFACE_Y - 1), 300, 6, 13, 15, 1, NULL); + _item7.setup(Rect(219, 46, 251, 74), 300, 22, 23, 24, 1, NULL); + _item8.setup(Rect(301, 53, 319, 78), 300, 22, 23, 24, 1, NULL); + _item5.setup(Rect(179, 44, 200, 55), 300, 8, 13, 17, 1, NULL); + _item6.setup(Rect(210, 46, 231, 55), 300, 8, 13, 17, 1, NULL); + _item3.setup(Rect(160, 0, SCREEN_WIDTH - 1, 75), 300, 4, 13, 14, 1, NULL); + _item9.setup(Rect(0, 0, SCREEN_WIDTH, BF_INTERFACE_Y), 300, 29, 30, 31, 1, NULL); } void Scene300::signal() { @@ -509,19 +525,16 @@ void Scene300::signal() { void Scene300::process(Event &event) { SceneExt::process(event); - if ((BF_GLOBALS._player._field8E != 0) && !_eventHandler && (event.mousePos.y < (BF_INTERFACE_Y - 1))) { - Visage visage; - + if (BF_GLOBALS._player._enabled && !_eventHandler && (event.mousePos.y < (BF_INTERFACE_Y - 1))) { if (_item14.contains(event.mousePos)) { - visage.setVisage(1, 8); - GfxSurface surface = visage.getFrame(2); + GfxSurface surface = _cursorVisage.getFrame(2); BF_GLOBALS._events.setCursor(surface); } else if (_item15.contains(event.mousePos)) { - visage.setVisage(1, 8); - GfxSurface surface = visage.getFrame(3); + GfxSurface surface = _cursorVisage.getFrame(3); BF_GLOBALS._events.setCursor(surface); } else { - CursorType cursorId = BF_GLOBALS._events.hideCursor(); + // In case an exit cursor was being shown, restore the previously selected cursor + CursorType cursorId = BF_GLOBALS._events.getCursor(); BF_GLOBALS._events.setCursor(cursorId); } } @@ -530,7 +543,7 @@ void Scene300::process(Event &event) { void Scene300::dispatch() { SceneExt::dispatch(); - if (_action) { + if (!_action) { int regionIndex = BF_GLOBALS._player.getRegionIndex(); if ((regionIndex == 1) && (_field2762 == 1)) { BF_GLOBALS._player.disableControl(); @@ -546,6 +559,19 @@ void Scene300::dispatch() { ADD_MOVER(BF_GLOBALS._player, BF_GLOBALS._player._position.x + 20, BF_GLOBALS._player._position.y - 5); } + + if (BF_GLOBALS._player._position.x <= 5) + setAction(&_action2); + + if (BF_GLOBALS._player._position.x >= 315) { + if (BF_GLOBALS.getFlag(onDuty) || (BF_GLOBALS._bookmark == bNone) || !BF_GLOBALS.getFlag(fWithLyle)) { + setAction(&_action1); + } else { + BF_GLOBALS._player.disableControl(); + _sceneMode = 317; + setAction(&_sequenceManager1, this, 1301, &BF_GLOBALS._player, NULL); + } + } } } diff --git a/engines/tsage/blue_force/blueforce_scenes3.h b/engines/tsage/blue_force/blueforce_scenes3.h index 42ae69fc3f..4acb424207 100644 --- a/engines/tsage/blue_force/blueforce_scenes3.h +++ b/engines/tsage/blue_force/blueforce_scenes3.h @@ -46,29 +46,29 @@ class Scene300: public SceneExt { public: Object(int stripNumber) { _stripNumber = stripNumber; } - virtual void startMover(CursorType action); + virtual void startAction(CursorType action); }; class Object17: public NamedObject { public: - virtual void startMover(CursorType action); + virtual void startAction(CursorType action); }; /* Items */ class Item1: public NamedHotspot { public: - virtual void startMover(CursorType action); + virtual void startAction(CursorType action); }; class Item2: public NamedHotspot { public: - virtual void startMover(CursorType action); + virtual void startAction(CursorType action); }; class Item14: public NamedHotspot { public: - virtual void startMover(CursorType action); + virtual void startAction(CursorType action); }; class Item15: public NamedHotspot { public: - virtual void startMover(CursorType action); + virtual void startAction(CursorType action); }; /* Actions */ @@ -97,6 +97,7 @@ private: public: SequenceManager _sequenceManager1, _sequenceManager2; SequenceManager _sequenceManager3, _sequenceManager4; + Visage _cursorVisage; NamedObject _object1; FollowerObject _object2, _object3, _object4, _object5, _object6, _object7; SceneObject _object8, _object9, _object10; diff --git a/engines/tsage/blue_force/blueforce_ui.cpp b/engines/tsage/blue_force/blueforce_ui.cpp index b455541dd4..56c13572cc 100644 --- a/engines/tsage/blue_force/blueforce_ui.cpp +++ b/engines/tsage/blue_force/blueforce_ui.cpp @@ -201,7 +201,7 @@ void UICollection::draw() { /*--------------------------------------------------------------------------*/ void UIElements::process(Event &event) { - if (_clearScreen && BF_GLOBALS._player._field8E && (BF_GLOBALS._sceneManager._sceneNumber != 50)) { + if (_clearScreen && BF_GLOBALS._player._enabled && (BF_GLOBALS._sceneManager._sceneNumber != 50)) { if (_bounds.contains(event.mousePos)) { } else if (_field4E) { diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 4842284442..10d2663fe0 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1463,7 +1463,11 @@ bool SceneItem::contains(const Common::Point &pt) { } void SceneItem::display(int resNum, int lineNum, ...) { - Common::String msg = !resNum ? Common::String() : _resourceManager->getMessage(resNum, lineNum); + Common::String msg = (!resNum || (resNum == -1)) ? Common::String() : + _resourceManager->getMessage(resNum, lineNum); + + if ((_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) + BF_GLOBALS._uiElements.hide(); if (_globals->_sceneObjects->contains(&_globals->_sceneText)) { _globals->_sceneText.remove(); @@ -1475,12 +1479,15 @@ void SceneItem::display(int resNum, int lineNum, ...) { Rect textRect; int maxWidth = 120; bool keepOnscreen = false; - bool centerText = true; + bool centerText = _vm->getGameID() == GType_Ringworld; - if (resNum) { + if (resNum != 0) { va_list va; va_start(va, lineNum); + if (resNum == -1) + msg = Common::String(va_arg(va, const char *)); + int mode; do { // Get next instruction @@ -1590,6 +1597,9 @@ void SceneItem::display(int resNum, int lineNum, ...) { _globals->_sceneText.remove(); } + + if ((_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) + BF_GLOBALS._uiElements.show(); } void SceneItem::display2(int resNum, int lineNum) { @@ -1603,23 +1613,46 @@ void SceneItem::display2(int resNum, int lineNum) { display(resNum, lineNum, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); } +void SceneItem::display(const Common::String &msg) { + assert(_vm->getGameID() == GType_BlueForce); + + display(-1, -1, msg.c_str(), + SET_WIDTH, 312, + SET_X, 4 + GLOBALS._sceneManager._scene->_sceneBounds.left, + SET_Y, GLOBALS._sceneManager._scene->_sceneBounds.top + BF_INTERFACE_Y + 2, + SET_FONT, 4, SET_BG_COLOR, 1, SET_FG_COLOR, 19, SET_EXT_BGCOLOR, 9, + SET_EXT_FGCOLOR, 13, LIST_END); +} + /*--------------------------------------------------------------------------*/ void SceneHotspot::doAction(int action) { switch ((int)action) { case CURSOR_LOOK: - display(1, 0, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + if (_vm->getGameID() == GType_BlueForce) + SceneItem::display(LOOK_SCENE_HOTSPOT); + else + display(1, 0, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); break; case CURSOR_USE: - display(1, 5, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + if (_vm->getGameID() == GType_BlueForce) + SceneItem::display(USE_SCENE_HOTSPOT); + else + display(1, 5, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); break; case CURSOR_TALK: - display(1, 15, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + if (_vm->getGameID() == GType_BlueForce) + SceneItem::display(TALK_SCENE_HOTSPOT); + else + display(1, 15, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); break; case CURSOR_WALK: break; default: - display(2, action, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + if (_vm->getGameID() == GType_BlueForce) + SceneItem::display(DEFAULT_SCENE_HOTSPOT); + else + display(2, action, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); break; } } @@ -1639,18 +1672,24 @@ void NamedHotspot::doAction(int action) { case CURSOR_LOOK: if (_lookLineNum == -1) SceneHotspot::doAction(action); + else if (_vm->getGameID() == GType_BlueForce) + SceneItem::display2(_resNum, _lookLineNum); else SceneItem::display(_resNum, _lookLineNum, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); break; case CURSOR_USE: if (_useLineNum == -1) SceneHotspot::doAction(action); + else if (_vm->getGameID() == GType_BlueForce) + SceneItem::display2(_resNum, _useLineNum); else SceneItem::display(_resNum, _useLineNum, SET_Y, 20, SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); break; case CURSOR_TALK: if (_talkLineNum == -1) SceneHotspot::doAction(action); + else if (_vm->getGameID() == GType_BlueForce) + SceneItem::display2(_resNum, _talkLineNum); else SceneItem::display2(_resNum, _talkLineNum); break; @@ -2814,7 +2853,7 @@ void Player::disableControl() { _canWalk = false; _uiEnabled = false; _globals->_events.setCursor(CURSOR_NONE); - _field8E = 0; + _enabled = false; if ((_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) BF_GLOBALS._uiElements.hide(); @@ -2823,6 +2862,7 @@ void Player::disableControl() { void Player::enableControl() { _canWalk = true; _uiEnabled = true; + _enabled = true; _globals->_events.setCursor(CURSOR_WALK); switch (_globals->_events.getCursor()) { @@ -2863,7 +2903,7 @@ void Player::synchronize(Serializer &s) { s.syncAsSint16LE(_field8C); if (_vm->getGameID() == GType_BlueForce) - s.syncAsSint16LE(_field8E); + s.syncAsByte(_enabled); } /*--------------------------------------------------------------------------*/ @@ -3662,7 +3702,7 @@ void SceneHandler::process(Event &event) { if (i != _globals->_sceneItems.end()) { // Pass the action to the item - (*i)->doAction(_globals->_events.getCursor()); + (*i)->startAction(_globals->_events.getCursor()); event.handled = _globals->_events.getCursor() != CURSOR_WALK; if (_globals->_player._uiEnabled && _globals->_player._canWalk && diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 9cd28b1e89..13761cec79 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -412,7 +412,7 @@ public: virtual Common::String getClassName() { return "SceneItem"; } virtual void remove(); virtual void destroy() {} - virtual void startMover(CursorType action) { doAction(action); } + virtual void startAction(CursorType action) { doAction(action); } virtual void doAction(int action); bool contains(const Common::Point &pt); @@ -420,6 +420,7 @@ public: void setBounds(const int ys, const int xe, const int ye, const int xs) { _bounds = Rect(MIN(xs, xe), MIN(ys, ye), MAX(xs, xe), MAX(ys, ye)); } static void display(int resNum, int lineNum, ...); static void display2(int resNum, int lineNum); + static void display(const Common::String &msg); }; class SceneItemExt : public SceneItem { @@ -617,7 +618,7 @@ public: bool _canWalk; bool _uiEnabled; int _field8C; - int _field8E; + bool _enabled; public: Player(); diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp index 72393832c8..6bda6c9af8 100644 --- a/engines/tsage/events.cpp +++ b/engines/tsage/events.cpp @@ -293,7 +293,7 @@ void EventsClass::setCursor(GfxSurface &cursor) { CursorMan.replaceCursor(cursorData, cursor.getBounds().width(), cursor.getBounds().height(), cursor._centroid.x, cursor._centroid.y, cursor._transColor); - _currentCursor = CURSOR_NONE; + _lastCursor = CURSOR_NONE; } void EventsClass::setCursorFromFlag() { diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index f8b42ec604..ebad77abc4 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -189,6 +189,8 @@ BlueForceGlobals::BlueForceGlobals(): Globals() { _dayNumber = 1; _v4CEA4 = 0; _v4CEA8 = 0; + _v4CEB8 = 0; + _v4CEBA = 0; _driveFromScene = 0; _driveToScene = 0; _v4CF9E = 0; diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index c5324c38cd..dda95a9ef7 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -169,6 +169,8 @@ public: int _dayNumber; int _v4CEA4; int _v4CEA8; + int _v4CEB8; + int _v4CEBA; int _driveFromScene; int _driveToScene; int _v4CF9E; -- cgit v1.2.3 From cd5af89557d458e4eef1fd8b0b23c865ce6de3fe Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 31 Aug 2011 11:24:34 +0200 Subject: DREAMWEB: 'getanyad' ported to C++ --- engines/dreamweb/structs.h | 5 +++++ engines/dreamweb/stubs.cpp | 16 ++++++++++++++++ engines/dreamweb/stubs.h | 1 + 3 files changed, 22 insertions(+) diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 9b8d823491..9f7c23181c 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -77,6 +77,8 @@ struct SetObject { uint8 b3; uint8 b4; uint8 priority; + uint16 w4() const { return READ_LE_UINT16(&b4); } + void setW4(uint16 v) { WRITE_LE_UINT16(&b4, v); } uint8 b6; uint8 delay; uint8 type; @@ -124,6 +126,9 @@ struct DynObject { uint8 mapad[5]; uint8 b7; uint8 b8; + uint16 w7() const { return READ_LE_UINT16(&b7); } + void setW7(uint16 v) { WRITE_LE_UINT16(&b7, v); } + uint8 b9; uint8 b10; uint8 initialLocation; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 35f9df0a43..88e590f4a3 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1188,6 +1188,22 @@ DynObject *DreamGenContext::geteitheradCPP() { return getfreead(data.byte(kItemframe)); } +void *DreamGenContext::getanyad(uint16 *value) { + if (data.byte(kObjecttype) == 4) { + DynObject *exObject = getexad(data.byte(kCommand)); + *value = exObject->w7(); + return exObject; + } else if (data.byte(kObjecttype) == 2) { + DynObject *freeObject = getfreead(data.byte(kCommand)); + *value = freeObject->w7(); + return freeObject; + } else { + SetObject *setObject = getsetad(data.byte(kCommand)); + *value = setObject->w4(); // Suspicious : conflicts with priority being a byte? + return setObject; + } +} + SetObject *DreamGenContext::getsetad(uint8 index) { return (SetObject *)segRef(data.word(kSetdat)).ptr(0, 0) + index; } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index f137707220..ac68da850a 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -162,6 +162,7 @@ DynObject *getexad(uint8 index); DynObject *geteitheradCPP(); SetObject *getsetad(uint8 index); + void *getanyad(uint16 *value); void setallchanges(); void dochange(); void dochange(uint8 index, uint8 value, uint8 type); -- cgit v1.2.3 From 1f531c6f7fc90d78a4d14cda377e5aed7c7f4eb0 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 31 Aug 2011 23:38:34 +0200 Subject: DREAMWEB: 'obicons' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 23 ----------------------- engines/dreamweb/dreamgen.h | 5 ++--- engines/dreamweb/structs.h | 5 ----- engines/dreamweb/stubs.cpp | 21 +++++++++++++++++---- engines/dreamweb/stubs.h | 3 ++- 6 files changed, 22 insertions(+), 36 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 658ff74aed..29d24a5e59 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -173,6 +173,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'obpicture', 'delthisone', 'transferinv', + 'obicons', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index b239842222..58c461963f 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -4338,28 +4338,6 @@ void DreamGenContext::openob() { cs.word(bx) = ax; } -void DreamGenContext::obicons() { - STACK_CHECK; - al = data.byte(kCommand); - getanyad(); - _cmp(al, 255); - if (flags.z()) - goto cantopenit; - ds = data.word(kIcons2); - di = 210; - bx = 1; - al = 4; - ah = 0; - showframe(); -cantopenit: - ds = data.word(kIcons2); - di = 260; - bx = 1; - al = 1; - ah = 0; - showframe(); -} - void DreamGenContext::examicon() { STACK_CHECK; ds = data.word(kIcons2); @@ -17718,7 +17696,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_openinv: openinv(); break; case addr_showryanpage: showryanpage(); break; case addr_openob: openob(); break; - case addr_obicons: obicons(); break; case addr_examicon: examicon(); break; case addr_describeob: describeob(); break; case addr_additionaltext: additionaltext(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 2eb0b93c6a..04bef1670d 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -495,7 +495,6 @@ public: static const uint16 addr_additionaltext = 0xc368; static const uint16 addr_describeob = 0xc364; static const uint16 addr_examicon = 0xc35c; - static const uint16 addr_obicons = 0xc358; static const uint16 addr_openob = 0xc354; static const uint16 addr_showryanpage = 0xc350; static const uint16 addr_openinv = 0xc34c; @@ -1292,6 +1291,7 @@ public: //void multidump(); void channel0only(); void worktoscreenm(); + //void obicons(); void removeemm(); //void frameoutbh(); void getobtextstart(); @@ -1634,7 +1634,7 @@ public: //void readabyte(); //void showframe(); void random(); - void obicons(); + void mainman(); void mansatstill(); void channel1only(); void checkbasemem(); @@ -2019,7 +2019,6 @@ public: void accesslightoff(); void usehole(); void useobject(); - void mainman(); void volumeadjust(); //void checkiffree(); }; diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 9f7c23181c..9b8d823491 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -77,8 +77,6 @@ struct SetObject { uint8 b3; uint8 b4; uint8 priority; - uint16 w4() const { return READ_LE_UINT16(&b4); } - void setW4(uint16 v) { WRITE_LE_UINT16(&b4, v); } uint8 b6; uint8 delay; uint8 type; @@ -126,9 +124,6 @@ struct DynObject { uint8 mapad[5]; uint8 b7; uint8 b8; - uint16 w7() const { return READ_LE_UINT16(&b7); } - void setW7(uint16 v) { WRITE_LE_UINT16(&b7, v); } - uint8 b9; uint8 b10; uint8 initialLocation; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 88e590f4a3..e400a5bbf3 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1188,18 +1188,21 @@ DynObject *DreamGenContext::geteitheradCPP() { return getfreead(data.byte(kItemframe)); } -void *DreamGenContext::getanyad(uint16 *value) { +void *DreamGenContext::getanyad(uint8 *value1, uint8 *value2) { if (data.byte(kObjecttype) == 4) { DynObject *exObject = getexad(data.byte(kCommand)); - *value = exObject->w7(); + *value1 = exObject->b7; + *value2 = exObject->b8; return exObject; } else if (data.byte(kObjecttype) == 2) { DynObject *freeObject = getfreead(data.byte(kCommand)); - *value = freeObject->w7(); + *value1 = freeObject->b7; + *value2 = freeObject->b8; return freeObject; } else { SetObject *setObject = getsetad(data.byte(kCommand)); - *value = setObject->w4(); // Suspicious : conflicts with priority being a byte? + *value1 = setObject->b4; + *value2 = setObject->priority; return setObject; } } @@ -1695,6 +1698,16 @@ void DreamGenContext::obpicture() { showframe(frames, 160, 68, frame, 0x80); } +void DreamGenContext::obicons() { + uint8 value1, value2; + getanyad(&value1, &value2); + if (value1 == 0xff) { + showframe((Frame *)segRef(data.word(kIcons2)).ptr(0, 0), 260, 1, 1, 0); + } else { + showframe((Frame *)segRef(data.word(kIcons2)).ptr(0, 0), 210, 1, 4, 0); + } +} + bool DreamGenContext::isCD() { // The original sources has two codepaths depending if the game is 'if cd' or not // This is a hack to guess which version to use with the assumption that if we have a cd version diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index ac68da850a..7bba6a9d52 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -162,7 +162,7 @@ DynObject *getexad(uint8 index); DynObject *geteitheradCPP(); SetObject *getsetad(uint8 index); - void *getanyad(uint16 *value); + void *getanyad(uint8 *value1, uint8 *value2); void setallchanges(); void dochange(); void dochange(uint8 index, uint8 value, uint8 type); @@ -206,4 +206,5 @@ void dumpmap(); void obpicture(); void transferinv(); + void obicons(); -- cgit v1.2.3 From 0534b70b6d73b6d5afbf107021d52f46a13fcbe9 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 1 Sep 2011 00:11:07 +0200 Subject: DREAMWEB: 'getaddir' ported to C++ --- engines/dreamweb/stubs.cpp | 9 +++++++++ engines/dreamweb/stubs.h | 1 + 2 files changed, 10 insertions(+) diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index e400a5bbf3..923c63602a 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1207,6 +1207,15 @@ void *DreamGenContext::getanyad(uint8 *value1, uint8 *value2) { } } +void *DreamGenContext::getanyaddir(uint8 index, uint8 flag) { + if (flag == 4) + return getexad(index); + else if (flag == 2) + return getfreead(index); + else + return getsetad(index); +} + SetObject *DreamGenContext::getsetad(uint8 index) { return (SetObject *)segRef(data.word(kSetdat)).ptr(0, 0) + index; } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 7bba6a9d52..6d431a856f 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -163,6 +163,7 @@ DynObject *geteitheradCPP(); SetObject *getsetad(uint8 index); void *getanyad(uint8 *value1, uint8 *value2); + void *getanyaddir(uint8 index, uint8 flag); void setallchanges(); void dochange(); void dochange(uint8 index, uint8 value, uint8 type); -- cgit v1.2.3 From 31d41731369697ca38900b3a6a89d9a6e1ac8a8c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 1 Sep 2011 00:22:20 +0200 Subject: CGE: Fix thumbnails display when a game is loaded. --- engines/cge/cge.h | 2 +- engines/cge/cge_main.cpp | 4 ++-- engines/cge/snail.cpp | 23 ++++++++++++++++------- engines/cge/vga13h.cpp | 7 +------ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 98f9ba8bc2..2ad66fc74a 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -41,7 +41,7 @@ namespace CGE { class Console; class Sprite; -#define kSavegameVersion 1 +#define kSavegameVersion 2 #define kSavegameStrSize 11 #define kPocketX 174 #define kPocketY 176 diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 4b834c9800..aa332ed8ea 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -266,7 +266,7 @@ void CGEEngine::saveGame(int slotNumber, const Common::String &desc) { writeSavegameHeader(saveFile, header); // Write out the data of the savegame - syncGame(NULL, saveFile); + syncGame(NULL, saveFile, false); // Finish writing out game data saveFile->finalize(); @@ -324,7 +324,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt if (s.isSaving()) { // Loop through saving the sprite data for (Sprite *spr = _vga->_spareQ->first(); spr; spr = spr->_next) { - if ((spr->_ref >= 1000) && !s.err()) + if (!s.err()) spr->sync(s); } } else { diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 7893b9d539..0e9d834d17 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -826,17 +826,26 @@ void CGEEngine::snBackPt(Sprite *spr, int stp) { void CGEEngine::snLevel(Sprite *spr, int lev) { debugC(1, kCGEDebugEngine, "CGEEngine::snLevel(spr, %d)", lev); - while (_lev < lev) { - _lev++; - spr = _vga->_spareQ->locate(100 + _lev); + assert((lev >= 0) && (lev < 5)); + + for (int i = 0; i < 5; i++) { + spr = _vga->_spareQ->locate(100 + i); if (spr) { - spr->backShow(true); - spr->_cave = 0; + if (i <= lev) { + spr->backShow(true); + spr->_cave = 0; + spr->_flags._hide = false; + } else { + spr->_flags._hide = true; + spr->_cave = -1; + } + } else { + warning("SPR not found! ref: %d", 100 + i); } } + + _lev = lev; _maxCave = _maxCaveArr[_lev]; - if (spr) - spr->_flags._hide = false; } void CGEEngine::snFlag(int indx, bool v) { diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d510b98f45..3db504425f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -99,13 +99,8 @@ BitmapPtr Sprite::shp() { return NULL; int i = e->_seq[_seqPtr]._now; - if (i >= _shpCnt) { - //char s[256]; - //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", - // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); - //VGA::Exit(s, File); + if (i >= _shpCnt) error("Invalid PHASE in SPRITE::Shp() %s", _file); - } return e->_shpList[i]; } -- cgit v1.2.3 From 690d94eb0376252818b5c27e86e0c70a6d01435d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 1 Sep 2011 00:32:20 +0200 Subject: CGE: Take fingolfin's remark into account: suppress the two leading underscore in define names --- engines/cge/bitmap.h | 4 ++-- engines/cge/cge_main.h | 4 ++-- engines/cge/events.h | 4 ++-- engines/cge/fileio.h | 4 ++-- engines/cge/game.h | 4 ++-- engines/cge/general.h | 4 ++-- engines/cge/snail.h | 4 ++-- engines/cge/snddrv.h | 13 ++----------- engines/cge/sound.h | 4 ++-- engines/cge/talk.h | 4 ++-- engines/cge/text.h | 4 ++-- engines/cge/vga13h.h | 4 ++-- engines/cge/vmenu.h | 4 ++-- engines/cge/walk.h | 4 ++-- 14 files changed, 28 insertions(+), 37 deletions(-) diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index 8896d13bb4..cd4f8267d1 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_BITMAP__ -#define __CGE_BITMAP__ +#ifndef CGE_BITMAP_H +#define CGE_BITMAP_H #include "cge/fileio.h" //#include "cge/general.h" diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index cce3122235..5e2e3bbe46 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_CGE__ -#define __CGE_CGE__ +#ifndef CGE_CGEMAIN_H +#define CGE_CGEMAIN_H #include "cge/vga13h.h" #include "cge/events.h" diff --git a/engines/cge/events.h b/engines/cge/events.h index 9b7de9efd4..62841dabe4 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_CGE_EVENTS__ -#define __CGE_CGE_EVENTS__ +#ifndef CGE_EVENTS_H +#define CGE_EVENTS_H #include "common/events.h" #include "cge/game.h" diff --git a/engines/cge/fileio.h b/engines/cge/fileio.h index 7cb5ce07e0..4ac8e13292 100644 --- a/engines/cge/fileio.h +++ b/engines/cge/fileio.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_FILEIO__ -#define __CGE_FILEIO__ +#ifndef CGE_FILEIO_H +#define CGE_FILEIO_H #include "cge/general.h" #include "common/stream.h" diff --git a/engines/cge/game.h b/engines/cge/game.h index bb4f3655a2..63d686239e 100644 --- a/engines/cge/game.h +++ b/engines/cge/game.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_GAME__ -#define __CGE_GAME__ +#ifndef CGE_GAME_H +#define CGE_GAME_H #include "cge/vga13h.h" diff --git a/engines/cge/general.h b/engines/cge/general.h index 6a0bc13675..ad5abba6b1 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_GENERAL__ -#define __CGE_GENERAL__ +#ifndef CGE_GENERAL_H +#define CGE_GENERAL_H #include "common/system.h" #include "common/file.h" diff --git a/engines/cge/snail.h b/engines/cge/snail.h index c2290da911..c6157a0096 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_SNAIL__ -#define __CGE_SNAIL__ +#ifndef CGE_SNAIL_H +#define CGE_SNAIL_H #include "cge/cge.h" diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 9e937d1cbf..987582190c 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -25,17 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -// ****************************************************** -// * Sound Driver by Hedges (c) 1995 LK AVALON * -// * Ver 1.00: 01-Mar-95 * -// * Ver 1.10: 03-Mar-95 * -// * Ver 1.20: 07-Mar-95 * -// * Ver 1.30: 09-Mar-95 * -// * Ver 1.40: 11-Mar-95 * -// ****************************************************** - -#ifndef __CGE_SNDDRV__ -#define __CGE_SNDDRV__ +#ifndef CGE_SNDDRV_H +#define CGE_SNDDRV_H namespace CGE { diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 53f57a19b0..1474b78c28 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_SOUND__ -#define __CGE_SOUND__ +#ifndef CGE_SOUND_H +#define CGE_SOUND_H #include "cge/fileio.h" #include "cge/snddrv.h" diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 3591fc6fcc..6b06e8009c 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_TALK__ -#define __CGE_TALK__ +#ifndef CGE_TALK_H +#define CGE_TALK_H #include "cge/general.h" #include "cge/vga13h.h" diff --git a/engines/cge/text.h b/engines/cge/text.h index d4607f8f3c..7ea0a947db 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_TEXT__ -#define __CGE_TEXT__ +#ifndef CGE_TEXT_H +#define CGE_TEXT_H #include "cge/talk.h" diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index e917e86a32..3312065492 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_VGA13H__ -#define __CGE_VGA13H__ +#ifndef CGE_VGA13H_H +#define CGE_VGA13H_H #include "common/serializer.h" #include "graphics/surface.h" diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 0ddcfdb91d..30fcb53f4b 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_VMENU__ -#define __CGE_VMENU__ +#ifndef CGE_VMENU_H +#define CGE_VMENU_H #include "cge/talk.h" diff --git a/engines/cge/walk.h b/engines/cge/walk.h index e924976927..a0dce1f715 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -25,8 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#ifndef __CGE_WALK__ -#define __CGE_WALK__ +#ifndef CGE_WALK_H +#define CGE_WALK_H #include "cge/vga13h.h" #include "cge/events.h" -- cgit v1.2.3 From 6ab4a0ceee71293c100a810c591dde823c2b76ba Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 1 Sep 2011 00:06:30 +0200 Subject: DREAMWEB: 'compare' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 18 ------------------ engines/dreamweb/dreamgen.h | 5 ++--- engines/dreamweb/stubs.cpp | 15 +++++++++++++++ engines/dreamweb/stubs.h | 2 ++ 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 29d24a5e59..75da6715ba 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -174,6 +174,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'delthisone', 'transferinv', 'obicons', + 'compare', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 58c461963f..a426cedb73 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -10535,23 +10535,6 @@ doselob: useroutine(); } -void DreamGenContext::compare() { - STACK_CHECK; - _sub(dl, 'A'); - _sub(dh, 'A'); - _sub(cl, 'A'); - _sub(ch, 'A'); - push(cx); - push(dx); - getanyaddir(); - dx = pop(); - cx = pop(); - _cmp(es.word(bx+12), cx); - if (!flags.z()) - return /* (comparefin) */; - _cmp(es.word(bx+14), dx); -} - void DreamGenContext::findsetobject() { STACK_CHECK; _sub(al, 'A'); @@ -17893,7 +17876,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_useelvdoor: useelvdoor(); break; case addr_withwhat: withwhat(); break; case addr_selectob: selectob(); break; - case addr_compare: compare(); break; case addr_findsetobject: findsetobject(); break; case addr_findexobject: findexobject(); break; case addr_isryanholding: isryanholding(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 04bef1670d..3b680025cd 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -297,7 +297,6 @@ public: static const uint16 addr_isryanholding = 0xc6cc; static const uint16 addr_findexobject = 0xc6c8; static const uint16 addr_findsetobject = 0xc6c4; - static const uint16 addr_compare = 0xc6c0; static const uint16 addr_selectob = 0xc6bc; static const uint16 addr_withwhat = 0xc6b8; static const uint16 addr_useelvdoor = 0xc6b4; @@ -1359,7 +1358,7 @@ public: void showdiscops(); void advisor(); void additionaltext(); - //void kernchars(); + //void compare(); void othersmoker(); void dofade(); //void setuptimedtemp(); @@ -1406,7 +1405,7 @@ public: //void addtopeoplelist(); void hangoncurs(); void sparkydrip(); - void compare(); + //void kernchars(); void printcurs(); //void convertkey(); void outofopen(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 923c63602a..3a01872542 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1717,6 +1717,21 @@ void DreamGenContext::obicons() { } } +void DreamGenContext::compare() { + char id[4] = { cl, ch, dl, dh }; + flags._z = compare(al, ah, id); +} + +bool DreamGenContext::compare(uint8 index, uint8 flag, const char id[4]) { + void *ptr = getanyaddir(index, flag); + const char *objId = (const char *)(((const uint8 *)ptr) + 12); // whether it is a DynObject or a SetObject + for (size_t i = 0; i < 4; ++i) { + if(id[i] != objId[i] + 'A') + return false; + } + return true; +} + bool DreamGenContext::isCD() { // The original sources has two codepaths depending if the game is 'if cd' or not // This is a hack to guess which version to use with the assumption that if we have a cd version diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 6d431a856f..f99f0d6fbb 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -208,4 +208,6 @@ void obpicture(); void transferinv(); void obicons(); + void compare(); + bool compare(uint8 index, uint8 flag, const char id[4]); -- cgit v1.2.3 From d9c7b9dd39ced4c2954aca9f1537d667d576eafb Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 1 Sep 2011 01:04:15 +0200 Subject: DREAMWEB: Asserts --- engines/dreamweb/vgagrafx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 5c63b88682..beb2d61f7e 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -43,6 +43,8 @@ void DreamGenContext::multiget() { } void DreamGenContext::multiget(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h) { + assert(x < 320); + assert(y < 200); const uint8 *src = workspace() + x + y * kScreenwidth; if (y + h > 200) h = 200 - y; @@ -64,6 +66,8 @@ void DreamGenContext::multiput() { } void DreamGenContext::multiput(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h) { + assert(x < 320); + assert(y < 200); uint8 *dst = workspace() + x + y * kScreenwidth; if (y + h > 200) h = 200 - y; -- cgit v1.2.3 From 6c0b7b6deb994b0d57d8dc858ee10a71cebfc4cb Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 1 Sep 2011 01:27:59 +0200 Subject: DREAMWEB: Fix of the bug when you are in the inventory and drag the gun agains the upper border of the screen --- engines/dreamweb/stubs.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 3a01872542..89df661974 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1611,9 +1611,11 @@ void DreamGenContext::showpointer() { height = 12; data.byte(kPointerxs) = width; data.byte(kPointerys) = height; - data.word(kOldpointerx) -= width / 2; - data.word(kOldpointery) -= height / 2; - multiget(segRef(data.word(kBuffers)).ptr(kPointerback, 0), x - width / 2, y - height / 2, width, height); + uint16 xMin = (x >= width / 2) ? x - width / 2 : 0; + uint16 yMin = (y >= height / 2) ? y - height / 2 : 0; + data.word(kOldpointerx) = xMin; + data.word(kOldpointery) = yMin; + multiget(segRef(data.word(kBuffers)).ptr(kPointerback, 0), xMin, yMin, width, height); showframe(frames, x, y, 3 * data.byte(kItemframe) + 1, 128); showframe(icons1, x, y, 3, 128); } else { -- cgit v1.2.3 From efd8c41d35a2807ea2026f6966c3efb83de4dc65 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 1 Sep 2011 01:39:12 +0200 Subject: DREAMWEB: 'frameoutv' know how to clip on the left and upper borders --- engines/dreamweb/stubs.h | 2 +- engines/dreamweb/vgagrafx.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index f99f0d6fbb..ede60259a4 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -25,7 +25,7 @@ void clearwork(); void multidump(); void multidump(uint16 x, uint16 y, uint8 width, uint8 height); - void frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y); + void frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, int16 x, int16 y); void frameoutnm(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y); void frameoutbh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y); void frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index beb2d61f7e..ecc90f172a 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -286,11 +286,23 @@ void DreamGenContext::showpcx() { pcxFile.close(); } -void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { +void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, int16 x, int16 y) { // NB : These resilience checks were not in the original engine, but did they result in undefined behaviour // or was something broken during porting to C++? assert(pitch == 320); + if(x < 0) { + assert(width >= -x); + width -= -x; + src += -x; + x = 0; + } + if(y < 0) { + assert(height >= -y); + height -= -y; + src += (-y) * width; + y = 0; + } if(x >= 320) return; if(y >= 200) -- cgit v1.2.3 From b089f084af7cc2263b3ef18f197249e7ff543fd1 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 1 Sep 2011 01:41:01 +0200 Subject: DREAMWEB: Cleaning in 'doshake' --- engines/dreamweb/vgagrafx.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index ecc90f172a..ee05ebfc15 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -154,11 +154,10 @@ void DreamGenContext::frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uin void DreamGenContext::doshake() { uint8 &counter = data.byte(kShakecounter); - _cmp(counter, 48); - if (flags.z()) + if (counter == 48) return; - _add(counter, 1); + ++counter; static const int shakeTable[] = { 0, -2, 3, -2, 0, 2, 4, -1, 1, -3, 3, 2, 0, -2, 3, -2, -- cgit v1.2.3 From 0d3c6fddaebfbf25e5668c4af73862ed4a66e407 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Fri, 2 Sep 2011 06:14:20 +0100 Subject: PARALLACTION: Add Graphics Debug Output. Minor Whitespace Fixes. This adds debug output for graphics object access to help with investigation of bug #2969913 i.e. "NIPPON: Katana graphics not shown (regression)" as well as cleanup of whitespace in this class. --- engines/parallaction/gfxbase.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/engines/parallaction/gfxbase.cpp b/engines/parallaction/gfxbase.cpp index 48d84ed101..c351551e36 100644 --- a/engines/parallaction/gfxbase.cpp +++ b/engines/parallaction/gfxbase.cpp @@ -55,17 +55,14 @@ const char *GfxObj::getName() const { return _name; } - uint GfxObj::getNum() { return _frames->getNum(); } - void GfxObj::getRect(uint f, Common::Rect &r) { _frames->getRect(f, r); } - byte *GfxObj::getData(uint f) { return _frames->getData(f); } @@ -77,7 +74,6 @@ uint GfxObj::getSize(uint f) { return _frames->getSize(f); } - void GfxObj::setFlags(uint32 flags) { _flags |= flags; } @@ -108,6 +104,7 @@ void Gfx::resetSceneDrawList() { } GfxObj* Gfx::loadAnim(const char *name) { + debugC(1, kDebugGraphics, "Gfx::loadAnim(\"%s\")", name); Frames* frames = _disk->loadFrames(name); assert(frames); @@ -146,7 +143,6 @@ GfxObj* Gfx::loadDoor(const char *name) { return obj; } - void Gfx::freeLocationObjects() { freeDialogueObjects(); freeLabels(); @@ -157,6 +153,7 @@ void Gfx::freeCharacterObjects() { } void BackgroundInfo::loadGfxObjMask(const char *name, GfxObj *obj) { + debugC(1, kDebugGraphics, "BackgroundInfo::loadGfxObjMask(\"%s\")", name); Common::Rect rect; obj->getRect(0, rect); @@ -180,6 +177,7 @@ void Gfx::showGfxObj(GfxObj* obj, bool visible) { if (!obj) { return; } + debugC(1, kDebugGraphics, "Gfx::showGfxObj(\"%s\", visible:%d)", obj->getName(), visible ? 1 : 0); if (visible) { obj->setFlags(kGfxObjVisible); @@ -188,27 +186,27 @@ void Gfx::showGfxObj(GfxObj* obj, bool visible) { } if (obj->_hasMask) { + debugC(1, kDebugGraphics, "\tHas Mask"); _backgroundInfo->toggleMaskPatch(obj->_maskId, obj->x, obj->y, visible); } if (obj->_hasPath) { + debugC(1, kDebugGraphics, "\tHas Path"); _backgroundInfo->togglePathPatch(obj->_pathId, obj->x, obj->y, visible); } } - - bool compareZ(const GfxObj* a1, const GfxObj* a2) { return (a1->z == a2->z) ? (a1->_prog < a2->_prog) : (a1->z < a2->z); } void Gfx::sortScene() { + debugC(3, kDebugGraphics, "Gfx::sortScene()"); GfxObjArray::iterator first = _sceneObjects.begin(); GfxObjArray::iterator last = _sceneObjects.end(); Common::sort(first, last, compareZ); } - void Gfx::drawGfxObject(GfxObj *obj, Graphics::Surface &surf) { if (!obj->isVisible()) { return; @@ -236,16 +234,13 @@ void Gfx::drawGfxObject(GfxObj *obj, Graphics::Surface &surf) { } - void Gfx::drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color) { byte *dst = (byte*)surf->getBasePtr(x, y); font->setColor(color); font->drawString(dst, surf->w, text); } - void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) { - byte *d = _unpackedBitmap; uint pixelsLeftInLine = r.width(); @@ -273,7 +268,6 @@ void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surf blt(r, _unpackedBitmap, surf, z, scale, transparentColor); } - void Gfx::bltMaskScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) { if (scale == 100) { // use optimized path @@ -301,7 +295,6 @@ void Gfx::bltMaskScale(const Common::Rect& r, byte *data, Graphics::Surface *sur dstRect.clip(clipper); if (!dstRect.isValidRect()) return; - // clipped source rectangle Common::Rect srcRect; srcRect.left = (dstRect.left - scaledLeft) * 100 / scale; @@ -448,10 +441,8 @@ void Gfx::bltNoMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface } } - void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) { bltMaskScale(r, data, surf, z, scale, transparentColor); } - } // namespace Parallaction -- cgit v1.2.3 From aa654943bb987ceebfa26be14c8db93ded67ef5c Mon Sep 17 00:00:00 2001 From: D G Turner Date: Fri, 2 Sep 2011 07:04:04 +0100 Subject: DEVTOOLS: Remove Unecessary Makefiles. These have been replaced by "make devtools" and are unused. --- devtools/create_drascula/Makefile | 4 ---- devtools/create_lure/Makefile | 4 ---- devtools/create_mads/Makefile | 4 ---- 3 files changed, 12 deletions(-) delete mode 100644 devtools/create_drascula/Makefile delete mode 100644 devtools/create_lure/Makefile delete mode 100644 devtools/create_mads/Makefile diff --git a/devtools/create_drascula/Makefile b/devtools/create_drascula/Makefile deleted file mode 100644 index 3052436b55..0000000000 --- a/devtools/create_drascula/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $Id$ - -all: - g++ -I../.. create_drascula.cpp -o create_drascula diff --git a/devtools/create_lure/Makefile b/devtools/create_lure/Makefile deleted file mode 100644 index 1ed33b594c..0000000000 --- a/devtools/create_lure/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $Id$ - -all: - g++ -I../.. create_lure_dat.cpp process_actions.cpp -o create_lure diff --git a/devtools/create_mads/Makefile b/devtools/create_mads/Makefile deleted file mode 100644 index c2776f5d17..0000000000 --- a/devtools/create_mads/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $Id$ - -all: - g++ -I../.. main.cpp parser.cpp -o create_mads -- cgit v1.2.3 From f01479e8419d40dc2b9c410fd7228b9771dd2e3c Mon Sep 17 00:00:00 2001 From: D G Turner Date: Fri, 2 Sep 2011 07:06:00 +0100 Subject: DEVTOOLS: Minor correction to remove GCC Warning. --- devtools/create_kyradat/create_kyradat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/create_kyradat/create_kyradat.h b/devtools/create_kyradat/create_kyradat.h index 983ba3c228..cabf65706f 100644 --- a/devtools/create_kyradat/create_kyradat.h +++ b/devtools/create_kyradat/create_kyradat.h @@ -277,7 +277,7 @@ enum kSpecial { kTalkieVersion, kDemoVersion, kTalkieDemoVersion, - kOldFloppy, + kOldFloppy }; enum kGame { -- cgit v1.2.3 From e84ea10ad456ed1e90246c3c96c4fafcf44d4e3b Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 1 Sep 2011 19:00:13 +0200 Subject: DREAMWEB: 'checkpixelset' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/backdrop.cpp | 2 +- engines/dreamweb/dreamgen.cpp | 41 --------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/sprite.cpp | 20 +++++++++---------- engines/dreamweb/structs.h | 2 +- engines/dreamweb/stubs.h | 3 +++ engines/dreamweb/vgagrafx.cpp | 16 +++++++++++++++ 8 files changed, 33 insertions(+), 55 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 75da6715ba..a962d65e2f 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -175,6 +175,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'transferinv', 'obicons', 'compare', + 'pixelcheckset', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp index 2c399af3c4..f0e03502dd 100644 --- a/engines/dreamweb/backdrop.cpp +++ b/engines/dreamweb/backdrop.cpp @@ -162,7 +162,7 @@ void DreamGenContext::showallobs() { calcfrframe(); uint16 x, y; finalframe(&x, &y); - setEntry->b17 = setEntry->b18[0]; + setEntry->index = setEntry->b18[0]; if ((setEntry->type == 0) && (setEntry->priority != 5) && (setEntry->priority != 6)) { x += data.word(kMapadx); y += data.word(kMapady); diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index a426cedb73..9c584bea90 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2657,46 +2657,6 @@ nought: goto palloop; } -void DreamGenContext::pixelcheckset() { - STACK_CHECK; - push(ax); - _sub(al, es.byte(bx)); - _sub(ah, es.byte(bx+1)); - push(es); - push(bx); - push(cx); - push(ax); - al = es.byte(bx+4); - getsetad(); - al = es.byte(bx+17); - es = data.word(kSetframes); - bx = (0); - ah = 0; - cx = 6; - _mul(cx); - _add(bx, ax); - ax = pop(); - push(ax); - al = ah; - ah = 0; - cl = es.byte(bx); - ch = 0; - _mul(cx); - cx = pop(); - ch = 0; - _add(ax, cx); - _add(ax, es.word(bx+2)); - bx = ax; - _add(bx, (0+2080)); - al = es.byte(bx); - dl = al; - cx = pop(); - bx = pop(); - es = pop(); - ax = pop(); - _cmp(dl, 0); -} - void DreamGenContext::createpanel() { STACK_CHECK; di = 0; @@ -17613,7 +17573,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_showpcx: showpcx(); break; case addr_loadpalfromiff: loadpalfromiff(); break; case addr_setmode: setmode(); break; - case addr_pixelcheckset: pixelcheckset(); break; case addr_createpanel: createpanel(); break; case addr_createpanel2: createpanel2(); break; case addr_vsync: vsync(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 3b680025cd..2b8174cc79 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -559,7 +559,6 @@ public: static const uint16 addr_vsync = 0xc208; static const uint16 addr_createpanel2 = 0xc200; static const uint16 addr_createpanel = 0xc1fc; - static const uint16 addr_pixelcheckset = 0xc1f8; static const uint16 addr_setmode = 0xc1dc; static const uint16 addr_loadpalfromiff = 0xc1d8; static const uint16 addr_showpcx = 0xc1cc; @@ -1618,7 +1617,7 @@ public: void playchannel0(); void usemon(); void steady(); - void pixelcheckset(); + //void pixelcheckset(); void reexfrominv(); void examinventory(); void talk(); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index c2ec27739c..7b41bbddab 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -297,7 +297,7 @@ void DreamGenContext::constant(Sprite *sprite, SetObject *objData) { sprite->frame = 0; } uint8 b18 = objData->b18[sprite->frame]; - objData->b17 = b18; + objData->index = b18; sprite->b15 = b18; } @@ -361,7 +361,7 @@ void DreamGenContext::dodoor(Sprite *sprite, SetObject *objData) { if (objData->b18[sprite->frame] == 255) { --sprite->frame; } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + sprite->b15 = objData->index = objData->b18[sprite->frame]; data.byte(kThroughdoor) = 1; return; shutdoor: @@ -375,14 +375,14 @@ shutdoor: if (sprite->frame != 0) { --sprite->frame; } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + sprite->b15 = objData->index = objData->b18[sprite->frame]; if (sprite->frame == 5) //nearly data.byte(kThroughdoor) = 0; } void DreamGenContext::steady(Sprite *sprite, SetObject *objData) { uint8 b18 = objData->b18[0]; - objData->b17 = b18; + objData->index = b18; sprite->b15 = b18; } @@ -426,7 +426,7 @@ void DreamGenContext::lockeddoorway(Sprite *sprite, SetObject *objData) { --sprite->frame; } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + sprite->b15 = objData->index = objData->b18[sprite->frame]; if (sprite->frame == 5) data.byte(kThroughdoor) = 1; return; @@ -442,7 +442,7 @@ shutdoor2: } data.byte(kThroughdoor) = 0; - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + sprite->b15 = objData->index = objData->b18[sprite->frame]; if (sprite->frame == 0) { turnpathoffCPP(data.byte(kDoorpath)); @@ -461,7 +461,7 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { data.byte(kLiftflag) = 3; } sprite->frame = 0; - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + sprite->b15 = objData->index = objData->b18[sprite->frame]; } else if (liftFlag == 1) { //liftopen turnpathonCPP(data.byte(kLiftpath)); @@ -472,7 +472,7 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { data.byte(kLiftflag) = 2; } sprite->frame = 12; - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + sprite->b15 = objData->index = objData->b18[sprite->frame]; } else if (liftFlag == 3) { //openlift if (sprite->frame == 12) { @@ -484,7 +484,7 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { al = 2; liftnoise(); } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + sprite->b15 = objData->index = objData->b18[sprite->frame]; } else { //closeLift assert(liftFlag == 2); if (sprite->frame == 0) { @@ -496,7 +496,7 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { al = 3; liftnoise(); } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + sprite->b15 = objData->index = objData->b18[sprite->frame]; } } diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 9b8d823491..07419459a6 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -85,7 +85,7 @@ struct SetObject { uint8 b11; uint8 name[4]; uint8 b16; - uint8 b17; + uint8 index; uint8 b18[13]; // NB: Don't know the size yet uint8 b31; uint8 b32; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index ede60259a4..d085fb880b 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -210,4 +210,7 @@ void obicons(); void compare(); bool compare(uint8 index, uint8 flag, const char id[4]); + void pixelcheckset(); + bool pixelcheckset(ObjPos *pos, uint8 x, uint8 y); + diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index ee05ebfc15..8d437c2c73 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -455,5 +455,21 @@ void DreamGenContext::transferinv() { data.word(kExframepos) += byteCount; } +void DreamGenContext::pixelcheckset() { + uint8 x = al; + uint8 y = ah; + ObjPos *pos = (ObjPos *)es.ptr(bx, sizeof(ObjPos)); + flags._z = !pixelcheckset(pos, x, y); +} + +bool DreamGenContext::pixelcheckset(ObjPos *pos, uint8 x, uint8 y) { + x -= pos->xMin; + y -= pos->yMin; + SetObject *setObject = getsetad(pos->index); + Frame *frame = (Frame *)segRef(data.word(kSetframes)).ptr(kFramedata, 0) + setObject->index; + const uint8 *ptr = segRef(data.word(kSetframes)).ptr(kFrames, 0) + frame->ptr() + y * frame->width + x; + return *ptr != 0; +} + } /*namespace dreamgen */ -- cgit v1.2.3 From fa91f3abf1a4b332594a51f119ab643509cec25c Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 00:24:29 +0200 Subject: DREAMWEB: Fix : getexpos returns info in es:di --- engines/dreamweb/stubs.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 89df661974..bb05a2b0d2 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1251,14 +1251,15 @@ void DreamGenContext::deletetaken() { } void DreamGenContext::getexpos() { + es = data.word(kExtras); const DynObject *objects = (const DynObject *)segRef(data.word(kExtras)).ptr(kExdata, sizeof(DynObject)); for (size_t i = 0; i < kNumexobjects; ++i) { if (objects[i].mapad[0] == 0xff) { - data.byte(kExpos) = i; + di = kExdata + i * sizeof(DynObject); return; } } - data.byte(kExpos) = kNumexobjects; + di = kExdata + kNumexobjects * sizeof(DynObject); } void DreamGenContext::placesetobject() { -- cgit v1.2.3 From 35d88d498cbb4d5e94befc1d976539c1079dd5bf Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 01:05:32 +0200 Subject: DREAMWEB: Fix : getexpos has a return value AND a side-effect --- engines/dreamweb/stubs.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index bb05a2b0d2..9e98fd068e 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1255,10 +1255,12 @@ void DreamGenContext::getexpos() { const DynObject *objects = (const DynObject *)segRef(data.word(kExtras)).ptr(kExdata, sizeof(DynObject)); for (size_t i = 0; i < kNumexobjects; ++i) { if (objects[i].mapad[0] == 0xff) { + data.byte(kExpos) = i; di = kExdata + i * sizeof(DynObject); return; } } + data.byte(kExpos) = kNumexobjects; di = kExdata + kNumexobjects * sizeof(DynObject); } -- cgit v1.2.3 From 65e2494265f1252bcd1fa4a7f80402ab6bf8ae7b Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 3 Sep 2011 11:02:03 +0200 Subject: DREAMWEB: 'turnpathon' et 'turnpathoff' ported to C++ --- devtools/tasmrecover/tasm-recover | 2 ++ engines/dreamweb/dreamgen.cpp | 48 --------------------------------------- engines/dreamweb/dreamgen.h | 8 +++---- engines/dreamweb/pathfind.cpp | 34 +++++++++++++++------------ engines/dreamweb/sprite.cpp | 8 +++---- engines/dreamweb/stubs.h | 6 +++-- 6 files changed, 33 insertions(+), 73 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index a962d65e2f..71c211805f 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -176,6 +176,8 @@ generator = cpp(context, "DreamGen", blacklist = [ 'obicons', 'compare', 'pixelcheckset', + 'turnpathon', + 'turnpathoff', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 9c584bea90..9bd4f0ee63 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -14946,52 +14946,6 @@ gotfirst: al = es.byte(bx+6); } -void DreamGenContext::turnpathon() { - STACK_CHECK; - push(ax); - push(ax); - cl = 255; - ch = data.byte(kRoomnum); - _add(ch, 100); - findormake(); - ax = pop(); - getroomspaths(); - ax = pop(); - _cmp(al, 255); - if (flags.z()) - return /* (nopathon) */; - ah = 0; - _add(ax, ax); - _add(ax, ax); - _add(ax, ax); - _add(bx, ax); - al = 255; - es.byte(bx+6) = al; -} - -void DreamGenContext::turnpathoff() { - STACK_CHECK; - push(ax); - push(ax); - cl = 0; - ch = data.byte(kRoomnum); - _add(ch, 100); - findormake(); - ax = pop(); - getroomspaths(); - ax = pop(); - _cmp(al, 255); - if (flags.z()) - return /* (nopathoff) */; - ah = 0; - _add(ax, ax); - _add(ax, ax); - _add(ax, ax); - _add(bx, ax); - al = 0; - es.byte(bx+6) = al; -} - void DreamGenContext::turnanypathon() { STACK_CHECK; push(ax); @@ -18016,8 +17970,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_isitdescribed: isitdescribed(); break; case addr_findpathofpoint: findpathofpoint(); break; case addr_findfirstpath: findfirstpath(); break; - case addr_turnpathon: turnpathon(); break; - case addr_turnpathoff: turnpathoff(); break; case addr_turnanypathon: turnanypathon(); break; case addr_turnanypathoff: turnanypathoff(); break; case addr_checkifpathison: checkifpathison(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 2b8174cc79..6291994bb2 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -113,8 +113,6 @@ public: static const uint16 addr_checkifpathison = 0xca04; static const uint16 addr_turnanypathoff = 0xca00; static const uint16 addr_turnanypathon = 0xc9fc; - static const uint16 addr_turnpathoff = 0xc9f8; - static const uint16 addr_turnpathon = 0xc9f4; static const uint16 addr_findfirstpath = 0xc9f0; static const uint16 addr_findpathofpoint = 0xc9ec; static const uint16 addr_isitdescribed = 0xc9e8; @@ -1275,7 +1273,6 @@ public: void uselighter(); void showmenu(); void usepoolreader(); - void showgroup(); void startdmablock(); void useopenbox(); void clearbuffers(); @@ -1648,7 +1645,7 @@ public: void purgeanitem(); void madman(); void createpanel(); - void turnpathon(); + //void turnpathon(); void enablesoundint(); void madmanstelly(); void constant(); @@ -1766,6 +1763,7 @@ public: void drawitall(); void usestereo(); void showcurrentfile(); + //void turnpathoff(); //void copyname(); void look(); void setmouse(); @@ -1942,7 +1940,7 @@ public: void usecontrol(); void buttonseven(); void redrawmainscrn(); - void turnpathoff(); + void showgroup(); void findallryan(); //void channel0tran(); void buttonpress(); diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index 2579105c6f..4b1d590bec 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -27,22 +27,28 @@ namespace DreamGen { -void DreamGenContext::turnpathonCPP(uint8 param) { - al = param; - push(es); - push(bx); - turnpathon(); - bx = pop(); - es = pop(); +void DreamGenContext::turnpathon() { + turnpathon(al); } -void DreamGenContext::turnpathoffCPP(uint8 param) { - al = param; - push(es); - push(bx); - turnpathoff(); - bx = pop(); - es = pop(); +void DreamGenContext::turnpathon(uint8 param) { + findormake(param, 0xff, data.byte(kRoomnum) + 100); + uint8 *roomsPaths = getroomspathsCPP(); + if (param == 0xff) + return; + roomsPaths[8 * param + 6] = 0xff; +} + +void DreamGenContext::turnpathoff() { + turnpathoff(al); +} + +void DreamGenContext::turnpathoff(uint8 param) { + findormake(param, 0x00, data.byte(kRoomnum) + 100); + uint8 *roomsPaths = getroomspathsCPP(); + if (param == 0xff) + return; + roomsPaths[8 * param + 6] = 0x00; } void DreamGenContext::getroomspaths() { diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 7b41bbddab..13db909dbe 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -414,7 +414,7 @@ void DreamGenContext::lockeddoorway(Sprite *sprite, SetObject *objData) { } if (sprite->frame == 6) { - turnpathonCPP(data.byte(kDoorpath)); + turnpathon(data.byte(kDoorpath)); } if ((data.byte(kThroughdoor) == 1) && (sprite->frame == 0)) { @@ -445,7 +445,7 @@ shutdoor2: sprite->b15 = objData->index = objData->b18[sprite->frame]; if (sprite->frame == 0) { - turnpathoffCPP(data.byte(kDoorpath)); + turnpathoff(data.byte(kDoorpath)); data.byte(kLockstatus) = 1; } } @@ -453,7 +453,7 @@ shutdoor2: void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { uint8 liftFlag = data.byte(kLiftflag); if (liftFlag == 0) { //liftclosed - turnpathoffCPP(data.byte(kLiftpath)); + turnpathoff(data.byte(kLiftpath)); if (data.byte(kCounttoopen) != 0) { _dec(data.byte(kCounttoopen)); @@ -464,7 +464,7 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { sprite->b15 = objData->index = objData->b18[sprite->frame]; } else if (liftFlag == 1) { //liftopen - turnpathonCPP(data.byte(kLiftpath)); + turnpathon(data.byte(kLiftpath)); if (data.byte(kCounttoclose) != 0) { _dec(data.byte(kCounttoclose)); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index d085fb880b..57016a4f67 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -103,8 +103,10 @@ void showreelframe(); void showreelframe(Reel *reel); const Frame *getreelframeax(uint16 frame); - void turnpathonCPP(uint8 param); - void turnpathoffCPP(uint8 param); + void turnpathon(uint8 param); + void turnpathoff(uint8 param); + void turnpathon(); + void turnpathoff(); void getroomspaths(); uint8 *getroomspathsCPP(); void makebackob(SetObject *objData); -- cgit v1.2.3 From 09def52554212871c6b68c60fb5f93b1c96b1002 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 3 Sep 2011 10:24:23 +0200 Subject: SCI: Fix QFG3 run/walk/sleep menu on touch devices The analysis and fix are from m_kiewitz. --- engines/sci/graphics/cursor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index ec49a38814..18ff1fd0b9 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -229,6 +229,7 @@ static const SciCursorSetPositionWorkarounds setPositionWorkarounds[] = { { GID_ISLANDBRAIN, 84, 109, 46, 76, 174, 243 }, // island of dr. brain / game menu { GID_LSL5, 23, 171, 0, 0, 26, 320 }, // larry 5 / skip forward helper { GID_QFG1VGA, 64, 174, 40, 37, 74, 284 }, // Quest For Glory 1 VGA / run/walk/sleep sub-menu + { GID_QFG3, 70, 170, 40, 61, 81, 258 }, // Quest For Glory 3 / run/walk/sleep sub-menu { (SciGameId)0, -1, -1, -1, -1, -1, -1 } }; -- cgit v1.2.3 From 49d1872876d9f26f8a30fa81056a6adea5cb30d2 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 3 Sep 2011 13:50:59 +0200 Subject: DREAMWEB: 'turnanypathon' and 'turnanypathoff' ported to C++ --- devtools/tasmrecover/tasm-recover | 2 ++ engines/dreamweb/dreamgen.cpp | 54 --------------------------------------- engines/dreamweb/dreamgen.h | 14 +++++----- engines/dreamweb/pathfind.cpp | 21 +++++++++++++++ engines/dreamweb/stubs.h | 4 +++ 5 files changed, 33 insertions(+), 62 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 71c211805f..b87d80c98b 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -178,6 +178,8 @@ generator = cpp(context, "DreamGen", blacklist = [ 'pixelcheckset', 'turnpathon', 'turnpathoff', + 'turnanypathon', + 'turnanypathoff', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 9bd4f0ee63..11d2a5117d 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -14946,58 +14946,6 @@ gotfirst: al = es.byte(bx+6); } -void DreamGenContext::turnanypathon() { - STACK_CHECK; - push(ax); - push(ax); - cl = 255; - ch = ah; - _add(ch, 100); - findormake(); - ax = pop(); - al = ah; - ah = 0; - cx = 144; - _mul(cx); - es = data.word(kReels); - bx = (0); - _add(bx, ax); - ax = pop(); - ah = 0; - _add(ax, ax); - _add(ax, ax); - _add(ax, ax); - _add(bx, ax); - al = 255; - es.byte(bx+6) = al; -} - -void DreamGenContext::turnanypathoff() { - STACK_CHECK; - push(ax); - push(ax); - cl = 0; - ch = ah; - _add(ch, 100); - findormake(); - ax = pop(); - al = ah; - ah = 0; - cx = 144; - _mul(cx); - es = data.word(kReels); - bx = (0); - _add(bx, ax); - ax = pop(); - ah = 0; - _add(ax, ax); - _add(ax, ax); - _add(ax, ax); - _add(bx, ax); - al = 0; - es.byte(bx+6) = al; -} - void DreamGenContext::checkifpathison() { STACK_CHECK; push(ax); @@ -17970,8 +17918,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_isitdescribed: isitdescribed(); break; case addr_findpathofpoint: findpathofpoint(); break; case addr_findfirstpath: findfirstpath(); break; - case addr_turnanypathon: turnanypathon(); break; - case addr_turnanypathoff: turnanypathoff(); break; case addr_checkifpathison: checkifpathison(); break; case addr_afternewroom: afternewroom(); break; case addr_atmospheres: atmospheres(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 6291994bb2..6a991878cd 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -111,8 +111,6 @@ public: static const uint16 addr_atmospheres = 0xca0c; static const uint16 addr_afternewroom = 0xca08; static const uint16 addr_checkifpathison = 0xca04; - static const uint16 addr_turnanypathoff = 0xca00; - static const uint16 addr_turnanypathon = 0xc9fc; static const uint16 addr_findfirstpath = 0xc9f0; static const uint16 addr_findpathofpoint = 0xc9ec; static const uint16 addr_isitdescribed = 0xc9e8; @@ -1305,7 +1303,7 @@ public: void bresenhams(); void getbackfromops(); //void frameoutv(); - void opensarters(); + void showbyte(); void screenupdate(); //void addlength(); void wornerror(); @@ -1317,7 +1315,7 @@ public: void mainscreen(); void watchreel(); void showfolder(); - void turnanypathoff(); + //void turnanypathoff(); void openfilefromc(); void gettime(); //void clearwork(); @@ -1342,7 +1340,7 @@ public: void opentomb(); //void makename(); void buttonfour(); - void dosometalk(); + void restoreall(); //void lockmon(); //void dochange(); void getanyaddir(); @@ -1418,7 +1416,6 @@ public: //void cancelch1(); void loadold(); void loadtempcharset(); - void showbyte(); void useslab(); void dumpzoom(); //void aboutturn(); @@ -1525,7 +1522,7 @@ public: void wearwatch(); void runintroseq(); //void doblocks(); - void restoreall(); + void opensarters(); //void delpointer(); void attendant(); void nextsymbol(); @@ -1828,7 +1825,7 @@ public: void gates(); void newgame(); void showwatch(); - void turnanypathon(); + //void turnanypathon(); void restorereels(); void setwalk(); void useroutine(); @@ -1992,6 +1989,7 @@ public: void emergencypurge(); void usemenu(); void alleybarksound(); + void dosometalk(); void usecart(); void intromusic(); void quitkey(); diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index 4b1d590bec..f7fbb854bc 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -51,6 +51,27 @@ void DreamGenContext::turnpathoff(uint8 param) { roomsPaths[8 * param + 6] = 0x00; } +void DreamGenContext::turnanypathon(uint8 param, uint8 room) { + findormake(param, 0xff, room + 100); + uint8 *paths = segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); + paths[8 * param + 6] = 0xff; +} + + +void DreamGenContext::turnanypathon() { + turnanypathon(al, ah); +} + +void DreamGenContext::turnanypathoff(uint8 param, uint8 room) { + findormake(param, 0x00, room + 100); + uint8 *paths = segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); + paths[8 * param + 6] = 0x00; +} + +void DreamGenContext::turnanypathoff() { + turnanypathoff(al, ah); +} + void DreamGenContext::getroomspaths() { es = data.word(kReels); bx = data.byte(kRoomnum) * 144; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 57016a4f67..8244e5e218 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -107,6 +107,10 @@ void turnpathoff(uint8 param); void turnpathon(); void turnpathoff(); + void turnanypathon(uint8 param, uint8 room); + void turnanypathoff(uint8 param, uint8 room); + void turnanypathon(); + void turnanypathoff(); void getroomspaths(); uint8 *getroomspathsCPP(); void makebackob(SetObject *objData); -- cgit v1.2.3 From 4782c7e34e83cdef57c613c08bb313ea4c6fbd24 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 3 Sep 2011 14:24:44 +0200 Subject: DREAMWEB: Introduction of a Path structure --- engines/dreamweb/pathfind.cpp | 40 ++++++++++++++++++++-------------------- engines/dreamweb/sprite.cpp | 4 ++-- engines/dreamweb/structs.h | 10 ++++++++++ engines/dreamweb/stubs.h | 4 ++-- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index f7fbb854bc..873fe794cb 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -33,10 +33,10 @@ void DreamGenContext::turnpathon() { void DreamGenContext::turnpathon(uint8 param) { findormake(param, 0xff, data.byte(kRoomnum) + 100); - uint8 *roomsPaths = getroomspathsCPP(); + Path *roomsPaths = getroomspathsCPP(); if (param == 0xff) return; - roomsPaths[8 * param + 6] = 0xff; + roomsPaths[param].b6 = 0xff; } void DreamGenContext::turnpathoff() { @@ -45,16 +45,16 @@ void DreamGenContext::turnpathoff() { void DreamGenContext::turnpathoff(uint8 param) { findormake(param, 0x00, data.byte(kRoomnum) + 100); - uint8 *roomsPaths = getroomspathsCPP(); + Path *roomsPaths = getroomspathsCPP(); if (param == 0xff) return; - roomsPaths[8 * param + 6] = 0x00; + roomsPaths[param].b6 = 0x00; } void DreamGenContext::turnanypathon(uint8 param, uint8 room) { findormake(param, 0xff, room + 100); - uint8 *paths = segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); - paths[8 * param + 6] = 0xff; + Path *paths = (Path *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); + paths[param].b6 = 0xff; } @@ -64,8 +64,8 @@ void DreamGenContext::turnanypathon() { void DreamGenContext::turnanypathoff(uint8 param, uint8 room) { findormake(param, 0x00, room + 100); - uint8 *paths = segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); - paths[8 * param + 6] = 0x00; + Path *paths = (Path *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); + paths[param].b6 = 0x00; } void DreamGenContext::turnanypathoff() { @@ -77,21 +77,21 @@ void DreamGenContext::getroomspaths() { bx = data.byte(kRoomnum) * 144; } -uint8 *DreamGenContext::getroomspathsCPP() { +Path *DreamGenContext::getroomspathsCPP() { void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144); - return (uint8 *)result; + return (Path *)result; } void DreamGenContext::autosetwalk() { al = data.byte(kManspath); if (data.byte(kFinaldest) == al) return; - const uint8 *roomsPaths = getroomspathsCPP(); + const Path *roomsPaths = getroomspathsCPP(); checkdest(roomsPaths); - data.word(kLinestartx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12; - data.word(kLinestarty) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12; - data.word(kLineendx) = roomsPaths[data.byte(kDestination) * 8 + 0] - 12; - data.word(kLineendy) = roomsPaths[data.byte(kDestination) * 8 + 1] - 12; + data.word(kLinestartx) = roomsPaths[data.byte(kManspath)].x - 12; + data.word(kLinestarty) = roomsPaths[data.byte(kManspath)].y - 12; + data.word(kLineendx) = roomsPaths[data.byte(kDestination)].x - 12; + data.word(kLineendy) = roomsPaths[data.byte(kDestination)].y - 12; bresenhams(); if (data.byte(kLinedirection) != 0) { data.byte(kLinepointer) = data.byte(kLinelength) - 1; @@ -101,8 +101,8 @@ void DreamGenContext::autosetwalk() { data.byte(kLinepointer) = 0; } -void DreamGenContext::checkdest(const uint8 *roomsPaths) { - const uint8 *p = roomsPaths + 12 * 8; +void DreamGenContext::checkdest(const Path *roomsPaths) { + const uint8 *p = (const uint8 *)roomsPaths + 12 * 8; ah = data.byte(kManspath) << 4; al = data.byte(kDestination); uint8 destination = data.byte(kDestination); @@ -124,9 +124,9 @@ void DreamGenContext::checkdest(const uint8 *roomsPaths) { } void DreamGenContext::findxyfrompath() { - const uint8 *roomsPaths = getroomspathsCPP(); - data.byte(kRyanx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12; - data.byte(kRyany) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12; + const Path *roomsPaths = getroomspathsCPP(); + data.byte(kRyanx) = roomsPaths[data.byte(kManspath)].x - 12; + data.byte(kRyany) = roomsPaths[data.byte(kManspath)].y - 12; } } /*namespace dreamgen */ diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 13db909dbe..8de829ae05 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -501,8 +501,8 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { } void DreamGenContext::facerightway() { - uint8 *paths = getroomspathsCPP(); - uint8 dir = paths[8 * data.byte(kManspath) + 7]; + Path *paths = getroomspathsCPP(); + uint8 dir = paths[data.byte(kManspath)].b7; data.byte(kTurntoface) = dir; data.byte(kLeavedirection) = dir; } diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 07419459a6..c0d5636538 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -228,4 +228,14 @@ struct Change { uint8 type; }; +struct Path { + uint8 x; + uint8 y; + uint8 b2; + uint8 b3; + uint8 b4; + uint8 b5; + uint8 b6; + uint8 b7; +}; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 8244e5e218..2602f11a9c 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -84,7 +84,7 @@ void facerightway(); void walking(Sprite *sprite); void autosetwalk(); - void checkdest(const uint8 *roomsPaths); + void checkdest(const Path *roomsPaths); void aboutturn(Sprite *sprite); void backobject(Sprite *sprite); void constant(Sprite *sprite, SetObject *objData); @@ -112,7 +112,7 @@ void turnanypathon(); void turnanypathoff(); void getroomspaths(); - uint8 *getroomspathsCPP(); + Path *getroomspathsCPP(); void makebackob(SetObject *objData); void modifychar(); void lockmon(); -- cgit v1.2.3 From 20f9028d9d75af0f73933728a35d70b6305a1687 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 3 Sep 2011 15:09:21 +0200 Subject: DREAMWEB: Refining of the pathfinding structures --- engines/dreamweb/pathfind.cpp | 41 ++++++++++++++++++++--------------------- engines/dreamweb/sprite.cpp | 4 ++-- engines/dreamweb/structs.h | 14 ++++++++++++-- engines/dreamweb/stubs.h | 4 ++-- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index 873fe794cb..ef07199211 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -33,7 +33,7 @@ void DreamGenContext::turnpathon() { void DreamGenContext::turnpathon(uint8 param) { findormake(param, 0xff, data.byte(kRoomnum) + 100); - Path *roomsPaths = getroomspathsCPP(); + PathNode *roomsPaths = getroomspathsCPP()->nodes; if (param == 0xff) return; roomsPaths[param].b6 = 0xff; @@ -45,7 +45,7 @@ void DreamGenContext::turnpathoff() { void DreamGenContext::turnpathoff(uint8 param) { findormake(param, 0x00, data.byte(kRoomnum) + 100); - Path *roomsPaths = getroomspathsCPP(); + PathNode *roomsPaths = getroomspathsCPP()->nodes; if (param == 0xff) return; roomsPaths[param].b6 = 0x00; @@ -53,7 +53,7 @@ void DreamGenContext::turnpathoff(uint8 param) { void DreamGenContext::turnanypathon(uint8 param, uint8 room) { findormake(param, 0xff, room + 100); - Path *paths = (Path *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); + PathNode *paths = (PathNode *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); paths[param].b6 = 0xff; } @@ -64,7 +64,7 @@ void DreamGenContext::turnanypathon() { void DreamGenContext::turnanypathoff(uint8 param, uint8 room) { findormake(param, 0x00, room + 100); - Path *paths = (Path *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); + PathNode *paths = (PathNode *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); paths[param].b6 = 0x00; } @@ -77,21 +77,21 @@ void DreamGenContext::getroomspaths() { bx = data.byte(kRoomnum) * 144; } -Path *DreamGenContext::getroomspathsCPP() { +RoomPaths *DreamGenContext::getroomspathsCPP() { void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144); - return (Path *)result; + return (RoomPaths *)result; } void DreamGenContext::autosetwalk() { al = data.byte(kManspath); if (data.byte(kFinaldest) == al) return; - const Path *roomsPaths = getroomspathsCPP(); + const RoomPaths *roomsPaths = getroomspathsCPP(); checkdest(roomsPaths); - data.word(kLinestartx) = roomsPaths[data.byte(kManspath)].x - 12; - data.word(kLinestarty) = roomsPaths[data.byte(kManspath)].y - 12; - data.word(kLineendx) = roomsPaths[data.byte(kDestination)].x - 12; - data.word(kLineendy) = roomsPaths[data.byte(kDestination)].y - 12; + data.word(kLinestartx) = roomsPaths->nodes[data.byte(kManspath)].x - 12; + data.word(kLinestarty) = roomsPaths->nodes[data.byte(kManspath)].y - 12; + data.word(kLineendx) = roomsPaths->nodes[data.byte(kDestination)].x - 12; + data.word(kLineendy) = roomsPaths->nodes[data.byte(kDestination)].y - 12; bresenhams(); if (data.byte(kLinedirection) != 0) { data.byte(kLinepointer) = data.byte(kLinelength) - 1; @@ -101,30 +101,29 @@ void DreamGenContext::autosetwalk() { data.byte(kLinepointer) = 0; } -void DreamGenContext::checkdest(const Path *roomsPaths) { - const uint8 *p = (const uint8 *)roomsPaths + 12 * 8; +void DreamGenContext::checkdest(const RoomPaths *roomsPaths) { + const PathSegment *segments = roomsPaths->segments; ah = data.byte(kManspath) << 4; al = data.byte(kDestination); uint8 destination = data.byte(kDestination); for (size_t i = 0; i < 24; ++i) { - dh = p[0] & 0xf0; - dl = p[0] & 0x0f; + dh = segments[i].b0 & 0xf0; + dl = segments[i].b0 & 0x0f; if (ax == dx) { - data.byte(kDestination) = p[1] & 0x0f; + data.byte(kDestination) = segments[i].b1 & 0x0f; return; } - dl = (p[0] & 0xf0) >> 4; - dh = (p[0] & 0x0f) << 4; + dl = (segments[i].b0 & 0xf0) >> 4; + dh = (segments[i].b0 & 0x0f) << 4; if (ax == dx) { - destination = p[1] & 0x0f; + destination = segments[i].b1 & 0x0f; } - p += 2; } data.byte(kDestination) = destination; } void DreamGenContext::findxyfrompath() { - const Path *roomsPaths = getroomspathsCPP(); + const PathNode *roomsPaths = getroomspathsCPP()->nodes; data.byte(kRyanx) = roomsPaths[data.byte(kManspath)].x - 12; data.byte(kRyany) = roomsPaths[data.byte(kManspath)].y - 12; } diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 8de829ae05..e938f868a5 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -501,8 +501,8 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { } void DreamGenContext::facerightway() { - Path *paths = getroomspathsCPP(); - uint8 dir = paths[data.byte(kManspath)].b7; + PathNode *paths = getroomspathsCPP()->nodes; + uint8 dir = paths[data.byte(kManspath)].dir; data.byte(kTurntoface) = dir; data.byte(kLeavedirection) = dir; } diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index c0d5636538..7c9d9a5814 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -228,7 +228,7 @@ struct Change { uint8 type; }; -struct Path { +struct PathNode { uint8 x; uint8 y; uint8 b2; @@ -236,6 +236,16 @@ struct Path { uint8 b4; uint8 b5; uint8 b6; - uint8 b7; + uint8 dir; +}; + +struct PathSegment { + uint8 b0; + uint8 b1; +}; + +struct RoomPaths { + PathNode nodes[12]; + PathSegment segments[24]; }; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 2602f11a9c..15ff2ee62c 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -84,7 +84,7 @@ void facerightway(); void walking(Sprite *sprite); void autosetwalk(); - void checkdest(const Path *roomsPaths); + void checkdest(const RoomPaths *roomsPaths); void aboutturn(Sprite *sprite); void backobject(Sprite *sprite); void constant(Sprite *sprite, SetObject *objData); @@ -112,7 +112,7 @@ void turnanypathon(); void turnanypathoff(); void getroomspaths(); - Path *getroomspathsCPP(); + RoomPaths *getroomspathsCPP(); void makebackob(SetObject *objData); void modifychar(); void lockmon(); -- cgit v1.2.3 From 44bc1bff0691ea085bd4619de6f611d9f0106493 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 2 Sep 2011 18:07:12 +0200 Subject: SCUMM: Limit Indy4 Amiga specific code to that version. --- engines/scumm/palette.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 7a6be90f68..64f40b96c4 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -584,10 +584,12 @@ void ScummEngine::stopCycle(int i) { assertRange(0, i, 16, "stopCycle: cycle"); if (i != 0) { _colorCycle[i - 1].delay = 0; - cycl = &_colorCycle[i - 1]; - for (int j = cycl->start; j <= cycl->end && j < 32; ++j) { - _shadowPalette[j] = j; - _colorUsedByCycle[j] = 0; + if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) { + cycl = &_colorCycle[i - 1]; + for (int j = cycl->start; j <= cycl->end && j < 32; ++j) { + _shadowPalette[j] = j; + _colorUsedByCycle[j] = 0; + } } return; } -- cgit v1.2.3 From f85fd9b4f1168bcf0659ef6cf747c6616408921c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 2 Sep 2011 18:08:23 +0200 Subject: SCUMM: Fix text color bug in Indy4 Amiga outro. --- engines/scumm/palette.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 64f40b96c4..2c10758730 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -913,7 +913,7 @@ void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int const byte *palptr = getPalettePtr(_curPalIndex, _roomResource) + startColor * 3; for (int i = startColor; i <= endColor; ++i) { - if (i >= 16 && i < 48) { + if (i > 16 && i < 48) { if (cycleFlag) _colorUsedByCycle[i - 16] &= ~2; else -- cgit v1.2.3 From 41cc1932d2cc19e6179f54d1b149a245420dba7a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 3 Sep 2011 14:50:58 +0300 Subject: SCI32: Added an initial skeleton structure for the SCI2 text drawing code This includes kCreateTextBitmap, and moves all of the text drawing code into the new GfxText32 class --- engines/sci/engine/kgraphics.cpp | 18 ++- engines/sci/graphics/frameout.cpp | 86 +------------- engines/sci/graphics/text32.cpp | 238 ++++++++++++++++++++++++++++++++++++++ engines/sci/graphics/text32.h | 71 ++++++++++++ engines/sci/module.mk | 1 + engines/sci/sci.cpp | 4 + engines/sci/sci.h | 2 + 7 files changed, 335 insertions(+), 85 deletions(-) create mode 100644 engines/sci/graphics/text32.cpp create mode 100644 engines/sci/graphics/text32.h diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 36de767464..556e5249b6 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -49,6 +49,7 @@ #include "sci/graphics/text16.h" #include "sci/graphics/view.h" #ifdef ENABLE_SCI32 +#include "sci/graphics/text32.h" #include "sci/graphics/frameout.h" #include "sci/video/robot_decoder.h" #endif @@ -1380,15 +1381,19 @@ reg_t kIsOnMe(EngineState *s, int argc, reg_t *argv) { } reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) { - // TODO: argument 0 is usually 0, and arguments 1 and 2 are usually 1 switch (argv[0].toUint16()) { case 0: { if (argc != 4) { warning("kCreateTextBitmap(0): expected 4 arguments, got %i", argc); return NULL_REG; } - //reg_t object = argv[3]; - //Common::String text = s->_segMan->getString(readSelector(s->_segMan, object, SELECTOR(text))); + reg_t object = argv[3]; + Common::String text = s->_segMan->getString(readSelector(s->_segMan, object, SELECTOR(text))); + debugC(kDebugLevelStrings, "kCreateTextBitmap case 0 (%04x:%04x, %04x:%04x, %04x:%04x)", + PRINT_REG(argv[1]), PRINT_REG(argv[2]), PRINT_REG(argv[3])); + debugC(kDebugLevelStrings, "%s", text.c_str()); + // TODO: arguments 1 and 2 + g_sci->_gfxText32->createTextBitmap(object); break; } case 1: { @@ -1396,8 +1401,11 @@ reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) { warning("kCreateTextBitmap(0): expected 2 arguments, got %i", argc); return NULL_REG; } - //reg_t object = argv[1]; - //Common::String text = s->_segMan->getString(readSelector(s->_segMan, object, SELECTOR(text))); + reg_t object = argv[1]; + Common::String text = s->_segMan->getString(readSelector(s->_segMan, object, SELECTOR(text))); + debugC(kDebugLevelStrings, "kCreateTextBitmap case 1 (%04x:%04x)", PRINT_REG(argv[1])); + debugC(kDebugLevelStrings, "%s", text.c_str()); + g_sci->_gfxText32->createTextBitmap(object); break; } default: diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 11948d5d38..5499a2d192 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -43,6 +43,7 @@ #include "sci/graphics/paint32.h" #include "sci/graphics/palette.h" #include "sci/graphics/picture.h" +#include "sci/graphics/text32.h" #include "sci/graphics/frameout.h" #include "sci/video/robot_decoder.h" @@ -316,44 +317,6 @@ void GfxFrameout::sortPlanes() { Common::sort(_planes.begin(), _planes.end(), planeSortHelper); } -static int16 GetLongest(const char *text, int16 maxWidth, GfxFont *font) { - uint16 curChar = 0; - int16 maxChars = 0, curCharCount = 0; - uint16 width = 0; - - while (width <= maxWidth) { - curChar = (*(const byte *)text++); - - switch (curChar) { - // We need to add 0xD, 0xA and 0xD 0xA to curCharCount and then exit - // which means, we split text like - // 'Mature, experienced software analyst available.' 0xD 0xA - // 'Bug installation a proven speciality. "No version too clean."' (normal game text, this is from lsl2) - // and 0xA '-------' 0xA (which is the official sierra subtitle separator) - // Sierra did it the same way. - case 0xD: - // Check, if 0xA is following, if so include it as well - if ((*(const unsigned char *)text) == 0xA) - curCharCount++; - // it's meant to pass through here - case 0xA: - curCharCount++; - // and it's also meant to pass through here - case 0: - return curCharCount; - case ' ': - maxChars = curCharCount; // return count up to (but not including) breaking space - break; - } - if (width + font->getCharWidth(curChar) > maxWidth) - break; - width += font->getCharWidth(curChar); - curCharCount++; - } - - return maxChars; -} - void GfxFrameout::kernelFrameout() { if (g_sci->_robotDecoder->isVideoLoaded()) { bool skipVideo = false; @@ -578,62 +541,25 @@ void GfxFrameout::kernelFrameout() { } } else { // Most likely a text entry - // This draws text the "SCI0-SCI11" way. In SCI2, text is prerendered in kCreateTextBitmap - // TODO: rewrite this the "SCI2" way (i.e. implement the text buffer to draw inside kCreateTextBitmap) if (lookupSelector(_segMan, itemEntry->object, SELECTOR(text), NULL, NULL) == kSelectorVariable) { - reg_t stringObject = readSelector(_segMan, itemEntry->object, SELECTOR(text)); - - // The object in the text selector of the item can be either a raw string - // or a Str object. In the latter case, we need to access the object's data - // selector to get the raw string. - if (_segMan->isHeapObject(stringObject)) - stringObject = readSelector(_segMan, stringObject, SELECTOR(data)); - - Common::String text = _segMan->getString(stringObject); - GfxFont *font = _cache->getFont(readSelectorValue(_segMan, itemEntry->object, SELECTOR(font))); - bool dimmed = readSelectorValue(_segMan, itemEntry->object, SELECTOR(dimmed)); - uint16 foreColor = readSelectorValue(_segMan, itemEntry->object, SELECTOR(fore)); - - itemEntry->y = ((itemEntry->y * _screen->getHeight()) / scriptsRunningHeight); - itemEntry->x = ((itemEntry->x * _screen->getWidth()) / scriptsRunningWidth); - - uint16 startX = itemEntry->x + it->planeRect.left; - uint16 curY = itemEntry->y + it->planeRect.top; - const char *txt = text.c_str(); + TextEntry *textEntry = g_sci->_gfxText32->getTextEntry(itemEntry->object); + uint16 startX = ((textEntry->x * _screen->getWidth()) / scriptsRunningWidth) + it->planeRect.left; + uint16 startY = ((textEntry->y * _screen->getHeight()) / scriptsRunningHeight) + it->planeRect.top; // HACK. The plane sometimes doesn't contain the correct width. This // hack breaks the dialog options when speaking with Grace, but it's // the best we got up to now. This happens because of the unimplemented // kTextWidth function in SCI32. // TODO: Remove this once kTextWidth has been implemented. uint16 w = it->planeRect.width() >= 20 ? it->planeRect.width() : _screen->getWidth() - 10; - int16 charCount; // Upscale the coordinates/width if the fonts are already upscaled if (_screen->fontIsUpscaled()) { startX = startX * _screen->getDisplayWidth() / _screen->getWidth(); - curY = curY * _screen->getDisplayHeight() / _screen->getHeight(); + startY = startY * _screen->getDisplayHeight() / _screen->getHeight(); w = w * _screen->getDisplayWidth() / _screen->getWidth(); } - while (*txt) { - charCount = GetLongest(txt, w, font); - if (charCount == 0) - break; - - uint16 curX = startX; - - for (int i = 0; i < charCount; i++) { - unsigned char curChar = txt[i]; - font->draw(curChar, curY, curX, foreColor, dimmed); - curX += font->getCharWidth(curChar); - } - - curY += font->getHeight(); - txt += charCount; - while (*txt == ' ') - txt++; // skip over breaking spaces - } - + g_sci->_gfxText32->drawTextBitmap(itemEntry->object, startX, startY, w); } } } diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp new file mode 100644 index 0000000000..21372f1502 --- /dev/null +++ b/engines/sci/graphics/text32.cpp @@ -0,0 +1,238 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/engines/sci/graphics/text16.cpp $ + * $Id: text16.cpp 55178 2011-01-08 23:16:44Z thebluegr $ + * + */ + +#include "common/util.h" +#include "common/stack.h" +#include "graphics/primitives.h" + +#include "sci/sci.h" +#include "sci/engine/kernel.h" +#include "sci/engine/selector.h" +#include "sci/engine/state.h" +#include "sci/graphics/cache.h" +#include "sci/graphics/font.h" +#include "sci/graphics/screen.h" +#include "sci/graphics/text32.h" + +namespace Sci { + +GfxText32::GfxText32(SegManager *segMan, GfxCache *fonts, GfxScreen *screen) + : _segMan(segMan), _cache(fonts), _screen(screen) { +} + +GfxText32::~GfxText32() { + purgeCache(); +} + +void GfxText32::purgeCache() { + for (TextCache::iterator cacheIterator = _textCache.begin(); cacheIterator != _textCache.end(); cacheIterator++) { + delete[] cacheIterator->_value->surface; + delete cacheIterator->_value; + cacheIterator->_value = 0; + } + + _textCache.clear(); +} + +void GfxText32::createTextBitmap(reg_t textObject) { + if (_textCache.size() >= MAX_CACHED_TEXTS) + purgeCache(); + + uint32 textId = (textObject.segment << 16) | textObject.offset; + + if (_textCache.contains(textId)) { + // Delete the old entry + TextEntry *oldEntry = _textCache[textId]; + delete[] oldEntry->surface; + delete oldEntry; + _textCache.erase(textId); + } + + _textCache[textId] = createTextEntry(textObject); +} + +// TODO: Finish this! +void GfxText32::drawTextBitmap(reg_t textObject, uint16 textX, uint16 textY, uint16 w) { + uint32 textId = (textObject.segment << 16) | textObject.offset; + + if (!_textCache.contains(textId)) + createTextBitmap(textObject); + + TextEntry *entry = _textCache[textId]; + + // This draws text the "SCI0-SCI11" way. In SCI2, text is prerendered in kCreateTextBitmap + // TODO: rewrite this the "SCI2" way (i.e. implement the text buffer to draw inside kCreateTextBitmap) + GfxFont *font = _cache->getFont(readSelectorValue(_segMan, textObject, SELECTOR(font))); + bool dimmed = readSelectorValue(_segMan,textObject, SELECTOR(dimmed)); + uint16 foreColor = readSelectorValue(_segMan, textObject, SELECTOR(fore)); + + const char *txt = entry->text.c_str(); + int16 charCount; + + while (*txt) { + charCount = GetLongest(txt, w, font); + if (charCount == 0) + break; + + uint16 curX = textX; + + for (int i = 0; i < charCount; i++) { + unsigned char curChar = txt[i]; + font->draw(curChar, textY, curX, foreColor, dimmed); + curX += font->getCharWidth(curChar); + } + + textY += font->getHeight(); + txt += charCount; + while (*txt == ' ') + txt++; // skip over breaking spaces + } + + // TODO: The "SCI2" way of font drawing. Currently buggy + /* + for (int x = textX; x < entry->width; x++) { + for (int y = textY; y < entry->height; y++) { + byte pixel = entry->surface[y * entry->width + x]; + if (pixel) + _screen->putPixel(x, y, 1, pixel, 0, 0); + } + } + */ +} + +TextEntry *GfxText32::getTextEntry(reg_t textObject) { + uint32 textId = (textObject.segment << 16) | textObject.offset; + + if (!_textCache.contains(textId)) + createTextBitmap(textObject); + + return _textCache[textId]; +} + +// TODO: Finish this! Currently buggy. +TextEntry *GfxText32::createTextEntry(reg_t textObject) { + reg_t stringObject = readSelector(_segMan, textObject, SELECTOR(text)); + + // The object in the text selector of the item can be either a raw string + // or a Str object. In the latter case, we need to access the object's data + // selector to get the raw string. + if (_segMan->isHeapObject(stringObject)) + stringObject = readSelector(_segMan, stringObject, SELECTOR(data)); + + const char *text = _segMan->getString(stringObject).c_str(); + GfxFont *font = _cache->getFont(readSelectorValue(_segMan, textObject, SELECTOR(font))); + bool dimmed = readSelectorValue(_segMan, textObject, SELECTOR(dimmed)); + uint16 foreColor = readSelectorValue(_segMan, textObject, SELECTOR(fore)); + uint16 x = readSelectorValue(_segMan, textObject, SELECTOR(x)); + uint16 y = readSelectorValue(_segMan, textObject, SELECTOR(y)); + + // Now get the bounding box from the associated plane + reg_t planeObject = readSelector(_segMan, textObject, SELECTOR(plane)); + Common::Rect planeRect; + if (!planeObject.isNull()) { + planeRect.top = readSelectorValue(_segMan, planeObject, SELECTOR(top)); + planeRect.left = readSelectorValue(_segMan, planeObject, SELECTOR(left)); + planeRect.bottom = readSelectorValue(_segMan, planeObject, SELECTOR(bottom)) + 1; + planeRect.right = readSelectorValue(_segMan, planeObject, SELECTOR(right)) + 1; + } else { + planeRect.top = 0; + planeRect.left = 0; + planeRect.bottom = _screen->getHeight(); + planeRect.right = _screen->getWidth(); + } + + TextEntry *newEntry = new TextEntry(); + newEntry->object = stringObject; + newEntry->x = x; + newEntry->y = y; + newEntry->width = planeRect.width(); + newEntry->height = planeRect.height(); + newEntry->surface = new byte[newEntry->width * newEntry->height]; + memset(newEntry->surface, 0, newEntry->width * newEntry->height); + newEntry->text = _segMan->getString(stringObject); + + int16 maxTextWidth, charCount; + uint16 curX = 0, curY = 0; + + maxTextWidth = 0; + while (*text) { + charCount = GetLongest(text, planeRect.width(), font); + if (charCount == 0) + break; + + for (int i = 0; i < charCount; i++) { + unsigned char curChar = text[i]; + font->drawToBuffer(curChar, curY, curX, foreColor, dimmed, newEntry->surface, newEntry->width, newEntry->height); + curX += font->getCharWidth(curChar); + } + + curY += font->getHeight(); + text += charCount; + while (*text == ' ') + text++; // skip over breaking spaces + } + + return newEntry; +} + +int16 GfxText32::GetLongest(const char *text, int16 maxWidth, GfxFont *font) { + uint16 curChar = 0; + int16 maxChars = 0, curCharCount = 0; + uint16 width = 0; + + while (width <= maxWidth) { + curChar = (*(const byte *)text++); + + switch (curChar) { + // We need to add 0xD, 0xA and 0xD 0xA to curCharCount and then exit + // which means, we split text like + // 'Mature, experienced software analyst available.' 0xD 0xA + // 'Bug installation a proven speciality. "No version too clean."' (normal game text, this is from lsl2) + // and 0xA '-------' 0xA (which is the official sierra subtitle separator) + // Sierra did it the same way. + case 0xD: + // Check, if 0xA is following, if so include it as well + if ((*(const unsigned char *)text) == 0xA) + curCharCount++; + // it's meant to pass through here + case 0xA: + curCharCount++; + // and it's also meant to pass through here + case 0: + return curCharCount; + case ' ': + maxChars = curCharCount; // return count up to (but not including) breaking space + break; + } + if (width + font->getCharWidth(curChar) > maxWidth) + break; + width += font->getCharWidth(curChar); + curCharCount++; + } + + return maxChars; +} + +} // End of namespace Sci diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h new file mode 100644 index 0000000000..39fe710a86 --- /dev/null +++ b/engines/sci/graphics/text32.h @@ -0,0 +1,71 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/engines/sci/graphics/text16.h $ + * $Id: text16.h 55178 2011-01-08 23:16:44Z thebluegr $ + * + */ + +#ifndef SCI_GRAPHICS_TEXT32_H +#define SCI_GRAPHICS_TEXT32_H + +#include "common/hashmap.h" + +namespace Sci { + +struct TextEntry { + reg_t object; + uint16 x; + uint16 y; + uint16 width; + uint16 height; + byte *surface; + Common::String text; +}; + +// TODO: Move to Cache, perhaps? +#define MAX_CACHED_TEXTS 20 +typedef Common::HashMap TextCache; + +/** + * Text32 class, handles text calculation and displaying of text for SCI2, SCI21 and SCI3 games + */ +class GfxText32 { +public: + GfxText32(SegManager *segMan, GfxCache *fonts, GfxScreen *screen); + ~GfxText32(); + void createTextBitmap(reg_t textObject); + void drawTextBitmap(reg_t textObject, uint16 textX, uint16 textY, uint16 w); + int16 GetLongest(const char *text, int16 maxWidth, GfxFont *font); + TextEntry *getTextEntry(reg_t textObject); + +private: + TextEntry *createTextEntry(reg_t textObject); + void purgeCache(); + + SegManager *_segMan; + GfxCache *_cache; + TextCache _textCache; + GfxScreen *_screen; +}; + +} // End of namespace Sci + +#endif diff --git a/engines/sci/module.mk b/engines/sci/module.mk index 2202002e2e..c129ae5439 100644 --- a/engines/sci/module.mk +++ b/engines/sci/module.mk @@ -80,6 +80,7 @@ ifdef ENABLE_SCI32 MODULE_OBJS += \ graphics/frameout.o \ graphics/paint32.o \ + graphics/text32.o \ video/robot_decoder.o endif diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 792b2b2055..6c1b6e4dd6 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -61,6 +61,7 @@ #include "sci/graphics/transitions.h" #ifdef ENABLE_SCI32 +#include "sci/graphics/text32.h" #include "sci/graphics/frameout.h" #include "sci/video/robot_decoder.h" #endif @@ -146,6 +147,7 @@ SciEngine::~SciEngine() { DebugMan.clearAllDebugChannels(); #ifdef ENABLE_SCI32 + delete _gfxText32; delete _robotDecoder; delete _gfxFrameout; #endif @@ -598,6 +600,7 @@ void SciEngine::initGraphics() { _gfxText16 = 0; _gfxTransitions = 0; #ifdef ENABLE_SCI32 + _gfxText32 = 0; _robotDecoder = 0; _gfxFrameout = 0; _gfxPaint32 = 0; @@ -627,6 +630,7 @@ void SciEngine::initGraphics() { _gfxCompare = new GfxCompare(_gamestate->_segMan, _kernel, _gfxCache, _gfxScreen, _gfxCoordAdjuster); _gfxPaint32 = new GfxPaint32(_resMan, _gamestate->_segMan, _kernel, _gfxCoordAdjuster, _gfxCache, _gfxScreen, _gfxPalette); _gfxPaint = _gfxPaint32; + _gfxText32 = new GfxText32(_gamestate->_segMan, _gfxCache, _gfxScreen); _robotDecoder = new RobotDecoder(g_system->getMixer(), getPlatform() == Common::kPlatformMacintosh); _gfxFrameout = new GfxFrameout(_gamestate->_segMan, _resMan, _gfxCoordAdjuster, _gfxCache, _gfxScreen, _gfxPalette, _gfxPaint32); } else { diff --git a/engines/sci/sci.h b/engines/sci/sci.h index b419d862a4..81bbdc51de 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -71,6 +71,7 @@ class GfxPalette; class GfxPorts; class GfxScreen; class GfxText16; +class GfxText32; class GfxTransitions; #ifdef ENABLE_SCI32 @@ -313,6 +314,7 @@ public: GfxPorts *_gfxPorts; // Port managment for 16-bit gfx GfxScreen *_gfxScreen; GfxText16 *_gfxText16; + GfxText32 *_gfxText32; GfxTransitions *_gfxTransitions; // transitions between screens for 16-bit gfx GfxMacIconBar *_gfxMacIconBar; // Mac Icon Bar manager -- cgit v1.2.3 From e05382839cf9b82d171abe2e2a816e10ad8aa3cd Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 3 Sep 2011 17:19:00 +0200 Subject: NEWS: Mention Indy4 Amiga palette improvements. --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 91a3c85e7d..df13fa500a 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,8 @@ For a more comprehensive changelog of the latest experimental code, see: better, since important notes are not interrupted anymore. - Implemented CMS support for Loom, The Secret of Monkey Island and Indiana Jones and the Last Crusade. + - Improved palette handling for the Amiga version of Indiana Jones and the + Fate of Atlantis. SDL ports: - Added support for OpenGL (GSoC Task). -- cgit v1.2.3 From 06021e46678bfa9524cc1a7ace1345b04fdd6317 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 3 Sep 2011 17:20:17 +0200 Subject: NEWS: Properly format Winnie entry. --- NEWS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index df13fa500a..1f62960d44 100644 --- a/NEWS +++ b/NEWS @@ -11,7 +11,8 @@ For a more comprehensive changelog of the latest experimental code, see: - Added PlayStation 3 port. AGI: - - Implemented sound support for the DOS version of Winnie the Pooh in the Hundred Acre Wood. + - Implemented sound support for the DOS version of Winnie the Pooh in the + Hundred Acre Wood. AGOS: - Implemented support for loading data directly from InstallShield -- cgit v1.2.3 From eebd5a28f9a76f3021041480fd22d218bcfa18d9 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 31 Aug 2011 13:41:43 +0200 Subject: GOB: Add Util::readString() --- engines/gob/util.cpp | 25 +++++++++++++++++++++---- engines/gob/util.h | 8 ++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 6d83745602..1add604ccb 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -20,6 +20,10 @@ * */ +#include "common/stream.h" +#include "common/events.h" + +#include "graphics/palette.h" #include "gob/gob.h" #include "gob/util.h" @@ -31,10 +35,6 @@ #include "gob/videoplayer.h" #include "gob/sound/sound.h" -#include "common/events.h" - -#include "graphics/palette.h" - namespace Gob { Util::Util(GobEngine *vm) : _vm(vm) { @@ -534,6 +534,23 @@ Common::String Util::setExtension(const Common::String &str, const Common::Strin return str + ext; } +Common::String Util::readString(Common::SeekableReadStream &stream, int n) { + Common::String str; + + char c; + while (n-- > 0) { + if ((c = stream.readByte()) == '\0') + break; + + str += c; + } + + if (n > 0) + stream.skip(n); + + return str; +} + /* NOT IMPLEMENTED */ void Util::checkJoystick() { _vm->_global->_useJoystick = 0; diff --git a/engines/gob/util.h b/engines/gob/util.h index a6a689c1d2..7c1e44c0f6 100644 --- a/engines/gob/util.h +++ b/engines/gob/util.h @@ -23,8 +23,13 @@ #ifndef GOB_UTIL_H #define GOB_UTIL_H +#include "common/str.h" #include "common/keyboard.h" +namespace Common { + class SeekableReadStream; +} + namespace Gob { class GobEngine; @@ -131,6 +136,9 @@ public: static char *setExtension(char *str, const char *ext); static Common::String setExtension(const Common::String &str, const Common::String &ext); + /** Read a constant-length string out of a stream. */ + static Common::String readString(Common::SeekableReadStream &stream, int n); + Util(GobEngine *vm); protected: -- cgit v1.2.3 From cceaa04ef23d766bc666324e69b8fa6fbfa1e39a Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 31 Aug 2011 13:43:38 +0200 Subject: GOB: Make Util::setExtension() not add an extension to an empty string --- engines/gob/util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 1add604ccb..58dfc9c7ad 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -518,6 +518,11 @@ void Util::deleteList(List *list) { } char *Util::setExtension(char *str, const char *ext) { + assert(str && ext); + + if (str[0] == '\0') + return str; + char *dot = strrchr(str, '.'); if (dot) *dot = '\0'; @@ -527,6 +532,9 @@ char *Util::setExtension(char *str, const char *ext) { } Common::String Util::setExtension(const Common::String &str, const Common::String &ext) { + if (str.empty()) + return str; + const char *dot = strrchr(str.c_str(), '.'); if (dot) return Common::String(str.c_str(), dot - str.c_str()) + ext; -- cgit v1.2.3 From 44b83551aa1d6aee8e6e9a643bfade93d1aa5fef Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 2 Sep 2011 01:23:49 +0200 Subject: GOB: Add the Amiga version of Geisha --- engines/gob/detection_tables.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/engines/gob/detection_tables.h b/engines/gob/detection_tables.h index 4c1ff9a8e3..9c13b4f7b8 100644 --- a/engines/gob/detection_tables.h +++ b/engines/gob/detection_tables.h @@ -2513,6 +2513,20 @@ static const GOBGameDescription gameDescriptions[] = { kFeaturesEGA | kFeaturesAdLib, "disk1.stk", "intro.tot", 0 }, + { + { + "geisha", + "", + AD_ENTRY1s("disk1.stk", "e5892f00917c62423e93f5fd9920cf47", 208120), + UNK_LANG, + kPlatformAmiga, + ADGF_NO_FLAGS, + GUIO_NOSUBTITLES | GUIO_NOSPEECH + }, + kGameTypeGeisha, + kFeaturesEGA, + "disk1.stk", "intro.tot", 0 + }, { { "gob3", -- cgit v1.2.3 From 2985f118b802d231aa5ec328c8b61e1419c14e48 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 1 Sep 2011 13:58:45 +0200 Subject: GOB: Add class RXYFile Handles RXY files, containing relative sprite coordinates. Used in hardcoded "actiony" parts of gob games, like Geisha's minigames. --- engines/gob/module.mk | 1 + engines/gob/rxyfile.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/gob/rxyfile.h | 76 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 engines/gob/rxyfile.cpp create mode 100644 engines/gob/rxyfile.h diff --git a/engines/gob/module.mk b/engines/gob/module.mk index 0300bcc3f0..a0269649a3 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -53,6 +53,7 @@ MODULE_OBJS := \ mult_v2.o \ palanim.o \ resources.o \ + rxyfile.o \ scenery.o \ scenery_v1.o \ scenery_v2.o \ diff --git a/engines/gob/rxyfile.cpp b/engines/gob/rxyfile.cpp new file mode 100644 index 0000000000..5311eece0f --- /dev/null +++ b/engines/gob/rxyfile.cpp @@ -0,0 +1,82 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/stream.h" + +#include "gob/rxyfile.h" + +namespace Gob { + +RXYFile::RXYFile(Common::SeekableReadStream &rxy) : _width(0), _height(0) { + load(rxy); +} + +RXYFile::~RXYFile() { +} + +uint RXYFile::size() const { + return _coords.size(); +} + +uint16 RXYFile::getWidth() const { + return _width; +} + +uint16 RXYFile::getHeight() const { + return _height; +} + +uint16 RXYFile::getRealCount() const { + return _realCount; +} + +const RXYFile::Coordinates &RXYFile::operator[](uint i) const { + assert(i < _coords.size()); + + return _coords[i]; +} + +void RXYFile::load(Common::SeekableReadStream &rxy) { + if (rxy.size() < 2) + return; + + rxy.seek(0); + + _realCount = rxy.readUint16LE(); + + uint16 count = (rxy.size() - 2) / 8; + + _coords.resize(count); + for (CoordArray::iterator c = _coords.begin(); c != _coords.end(); ++c) { + c->left = rxy.readUint16LE(); + c->right = rxy.readUint16LE(); + c->top = rxy.readUint16LE(); + c->bottom = rxy.readUint16LE(); + + if (c->left != 0xFFFF) { + _width = MAX(_width , c->right + 1); + _height = MAX(_height, c->bottom + 1); + } + } +} + +} // End of namespace Gob diff --git a/engines/gob/rxyfile.h b/engines/gob/rxyfile.h new file mode 100644 index 0000000000..828f8b73c7 --- /dev/null +++ b/engines/gob/rxyfile.h @@ -0,0 +1,76 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GOB_RXYFILE_H +#define GOB_RXYFILE_H + +#include "common/system.h" +#include "common/array.h" + +namespace Common { + class SeekableReadStream; +} + +namespace Gob { + +/** A RXY file, containing relative sprite coordinates. + * + * Used in hardcoded "actiony" parts of gob games. + */ +class RXYFile { +public: + struct Coordinates { + uint16 left; + uint16 top; + uint16 right; + uint16 bottom; + }; + + RXYFile(Common::SeekableReadStream &rxy); + ~RXYFile(); + + uint size() const; + + uint16 getWidth () const; + uint16 getHeight() const; + + uint16 getRealCount() const; + + const Coordinates &operator[](uint i) const; + +private: + typedef Common::Array CoordArray; + + CoordArray _coords; + + uint16 _realCount; + + uint16 _width; + uint16 _height; + + + void load(Common::SeekableReadStream &rxy); +}; + +} // End of namespace Gob + +#endif // GOB_RXYFILE_H -- cgit v1.2.3 From 37964e8e85137ff7cb3a317c34b6a6210b7564d4 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 1 Sep 2011 14:00:17 +0200 Subject: GOB: Add class DECFile Handles DEC files, describing "decals" (backgrounds). Used in hardcoded "actiony" parts of gob games, like Geisha's minigames. --- engines/gob/decfile.cpp | 214 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/gob/decfile.h | 111 +++++++++++++++++++++++++ engines/gob/module.mk | 1 + 3 files changed, 326 insertions(+) create mode 100644 engines/gob/decfile.cpp create mode 100644 engines/gob/decfile.h diff --git a/engines/gob/decfile.cpp b/engines/gob/decfile.cpp new file mode 100644 index 0000000000..f5910f0654 --- /dev/null +++ b/engines/gob/decfile.cpp @@ -0,0 +1,214 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/str.h" +#include "common/stream.h" +#include "common/substream.h" + +#include "gob/gob.h" +#include "gob/util.h" +#include "gob/dataio.h" +#include "gob/surface.h" +#include "gob/video.h" +#include "gob/rxyfile.h" +#include "gob/decfile.h" + +namespace Gob { + +DECFile::Layer::Layer() : surface(0), coordinates(0) { +} + +DECFile::Layer::~Layer() { + delete coordinates; + delete surface; +} + + +DECFile::DECFile(GobEngine *vm, const Common::String &fileName, + uint16 width, uint16 height, uint8 bpp) : _vm(vm), + _width(width), _height(height), _bpp(bpp), _hasPadding(false) { + + _backdrop = new Surface(_width, _height, _bpp); + + Common::SeekableReadStream *dec = _vm->_dataIO->getFile(fileName); + if (dec) { + Common::SeekableSubReadStreamEndian sub(dec, 0, dec->size(), false, DisposeAfterUse::YES); + + load(sub, fileName); + return; + } + + // File doesn't exist, try to open the big-endian'd alternate file + Common::String alternateFileName = fileName; + alternateFileName.setChar('_', 0); + + dec = _vm->_dataIO->getFile(alternateFileName); + if (dec) { + Common::SeekableSubReadStreamEndian sub(dec, 0, dec->size(), true, DisposeAfterUse::YES); + + // The big endian version pads a few fields to even size + _hasPadding = true; + + load(sub, fileName); + return; + } + + warning("DECFile::DECFile(): No such file \"%s\"", fileName.c_str()); +} + +DECFile::~DECFile() { + delete _backdrop; +} + +void DECFile::load(Common::SeekableSubReadStreamEndian &dec, const Common::String &fileName) { + dec.skip(2); // Unused + + int16 backdropCount = dec.readUint16(); + int16 layerCount = dec.readUint16(); + + // Sanity checks + if (backdropCount > 1) + warning("DECFile::load(): More than one backdrop (%d) in file \"%s\"", + backdropCount, fileName.c_str()); + if (layerCount < 1) + warning("DECFile::load(): Less than one layer (%d) in file \"%s\"", + layerCount, fileName.c_str()); + + // Load the backdrop + if (backdropCount > 0) { + loadBackdrop(dec); + + // We only support one backdrop, skip the rest + dec.skip((backdropCount - 1) * (13 + (_hasPadding ? 1 : 0))); + } + + // Load the layers + _layers.resize(MAX(0, layerCount - 1)); + for (LayerArray::iterator l = _layers.begin(); l != _layers.end(); ++l) + loadLayer(*l, dec); + + // Load the backdrop parts + if (backdropCount > 0) + loadParts(dec); +} + +void DECFile::loadBackdrop(Common::SeekableSubReadStreamEndian &dec) { + // Interestingly, DEC files reference "FOO.LBM" instead of "FOO.CMP" + Common::String file = Util::setExtension(Util::readString(dec, 13), ".CMP"); + if (_hasPadding) + dec.skip(1); + + if (file.empty() || !_vm->_dataIO->hasFile(file)) + return; + + _vm->_video->drawPackedSprite(file.c_str(), *_backdrop); +} + +void DECFile::loadLayer(Layer &layer, Common::SeekableSubReadStreamEndian &dec) { + Common::String file = Util::readString(dec, 13); + if (_hasPadding) + dec.skip(1); + + if (file.empty()) + return; + + Common::String fileRXY = Util::setExtension(file, ".RXY"); + Common::String fileCMP = Util::setExtension(file, ".CMP"); + if (!_vm->_dataIO->hasFile(fileRXY) || !_vm->_dataIO->hasFile(fileCMP)) + return; + + loadLayer(layer, fileRXY, fileCMP); +} + +void DECFile::loadLayer(Layer &layer, const Common::String &fileRXY, + const Common::String &fileCMP) { + + Common::SeekableReadStream *dataRXY = _vm->_dataIO->getFile(fileRXY); + if (!dataRXY) + return; + + layer.coordinates = new RXYFile(*dataRXY); + layer.surface = new Surface(_width, layer.coordinates->getHeight(), _bpp); + + _vm->_video->drawPackedSprite(fileCMP.c_str(), *layer.surface); +} + +void DECFile::loadParts(Common::SeekableSubReadStreamEndian &dec) { + dec.skip(13); // Name + if (_hasPadding) + dec.skip(1); + + dec.skip(13); // File? + if (_hasPadding) + dec.skip(1); + + uint16 partCount = dec.readUint16(); + + _parts.resize(partCount); + for (PartArray::iterator p = _parts.begin(); p != _parts.end(); ++p) + loadPart(*p, dec); +} + +void DECFile::loadPart(Part &part, Common::SeekableSubReadStreamEndian &dec) { + part.layer = dec.readByte() - 1; + part.part = dec.readByte(); + + dec.skip(1); // Unknown + + part.x = dec.readUint16(); + part.y = dec.readUint16(); + + part.transp = dec.readByte() != 0; +} + +void DECFile::draw(Surface &dest) const { + drawBackdrop(dest); + + for (PartArray::const_iterator p = _parts.begin(); p != _parts.end(); ++p) + drawLayer(dest, p->layer, p->part, p->x, p->y, p->transp ? 0 : -1); +} + +void DECFile::drawBackdrop(Surface &dest) const { + dest.blit(*_backdrop); +} + +void DECFile::drawLayer(Surface &dest, uint16 layer, uint16 part, + uint16 x, uint16 y, int32 transp) const { + + if (layer >= _layers.size()) + return; + + const Layer &l = _layers[layer]; + if (!l.surface || !l.coordinates) + return; + + if (part >= l.coordinates->size()) + return; + + const RXYFile::Coordinates &c = (*l.coordinates)[part]; + if (c.left == 0xFFFF) + return; + + dest.blit(*l.surface, c.left, c.top, c.right, c.bottom, x, y, transp); +} + +} // End of namespace Gob diff --git a/engines/gob/decfile.h b/engines/gob/decfile.h new file mode 100644 index 0000000000..31d90180d3 --- /dev/null +++ b/engines/gob/decfile.h @@ -0,0 +1,111 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GOB_DECFILE_H +#define GOB_DECFILE_H + +#include "common/system.h" + +namespace Common { + class String; + class SeekableSubReadStreamEndian; +} + +namespace Gob { + +class GobEngine; +class Surface; +class RXYFile; + +/** A DEC file, describing a "decal" (background). + * + * Used in hardcoded "actiony" parts of gob games. + * The principle is similar to a Static in Scenery (see scenery.cpp), but + * instead of referencing indices in the sprites array, DECs reference sprites + * directly by filename. + */ +class DECFile { +public: + DECFile(GobEngine *vm, const Common::String &fileName, + uint16 width, uint16 height, uint8 bpp = 1); + ~DECFile(); + + /** Draw the background, including all default layer parts. */ + void draw(Surface &dest) const; + + /** Explicitly draw the backdrop. */ + void drawBackdrop(Surface &dest) const; + + /** Explicitly draw a layer part. */ + void drawLayer(Surface &dest, uint16 layer, uint16 part, + uint16 x, uint16 y, int32 transp = -1) const; + +private: + struct Layer { + Surface *surface; ///< The surface containing the layer sprite. + RXYFile *coordinates; ///< The coordinates describing the layer sprite parts. + + Layer(); + ~Layer(); + }; + + struct Part { + uint8 layer; + uint8 part; + + uint16 x; + uint16 y; + bool transp; + }; + + typedef Common::Array LayerArray; + typedef Common::Array PartArray; + + GobEngine *_vm; + + uint16 _width; + uint16 _height; + uint8 _bpp; + + byte _hasPadding; + + Surface *_backdrop; + + LayerArray _layers; + PartArray _parts; + + + void load(Common::SeekableSubReadStreamEndian &dec, const Common::String &fileName); + + void loadBackdrop(Common::SeekableSubReadStreamEndian &dec); + + void loadLayer(Layer &layer, Common::SeekableSubReadStreamEndian &dec); + void loadLayer(Layer &layer, const Common::String &fileRXY, + const Common::String &fileCMP); + + void loadParts(Common::SeekableSubReadStreamEndian &dec); + void loadPart(Part &part, Common::SeekableSubReadStreamEndian &dec); +}; + +} // End of namespace Gob + +#endif // GOB_DECFILE_H diff --git a/engines/gob/module.mk b/engines/gob/module.mk index a0269649a3..0fdbdf9762 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ dataio.o \ databases.o \ dbase.o \ + decfile.o \ detection.o \ draw.o \ draw_v1.o \ -- cgit v1.2.3 From a4f42017d7a43ae0e8cd7c61d6af746a19c410f5 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 1 Sep 2011 17:52:13 +0200 Subject: GOB: Add class ANIFile Handles ANI files, describing animations. Used in hardcoded "actiony" parts of gob games, like Geisha's minigames. --- engines/gob/anifile.cpp | 326 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/gob/anifile.h | 161 ++++++++++++++++++++++++ engines/gob/module.mk | 1 + 3 files changed, 488 insertions(+) create mode 100644 engines/gob/anifile.cpp create mode 100644 engines/gob/anifile.h diff --git a/engines/gob/anifile.cpp b/engines/gob/anifile.cpp new file mode 100644 index 0000000000..1a905f1083 --- /dev/null +++ b/engines/gob/anifile.cpp @@ -0,0 +1,326 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/stream.h" +#include "common/substream.h" + +#include "gob/gob.h" +#include "gob/util.h" +#include "gob/dataio.h" +#include "gob/surface.h" +#include "gob/video.h" +#include "gob/anifile.h" + +namespace Gob { + +ANIFile::Layer::Layer() : surface(0), coordinates(0) { +} + +ANIFile::Layer::~Layer() { + delete coordinates; + delete surface; +} + + +ANIFile::ANIFile(GobEngine *vm, const Common::String &fileName, + uint16 width, uint8 bpp) : _vm(vm), + _width(width), _bpp(bpp), _hasPadding(false) { + + Common::SeekableReadStream *ani = _vm->_dataIO->getFile(fileName); + if (ani) { + Common::SeekableSubReadStreamEndian sub(ani, 0, ani->size(), false, DisposeAfterUse::YES); + + load(sub, fileName); + return; + } + + // File doesn't exist, try to open the big-endian'd alternate file + Common::String alternateFileName = fileName; + alternateFileName.setChar('_', 0); + + ani = _vm->_dataIO->getFile(alternateFileName); + if (ani) { + Common::SeekableSubReadStreamEndian sub(ani, 0, ani->size(), true, DisposeAfterUse::YES); + + // The big endian version pads a few fields to even size + _hasPadding = true; + + load(sub, fileName); + return; + } + + warning("ANIFile::ANIFile(): No such file \"%s\"", fileName.c_str()); +} + +ANIFile::~ANIFile() { +} + +void ANIFile::load(Common::SeekableSubReadStreamEndian &ani, const Common::String &fileName) { + ani.skip(2); // Unused + + uint16 animationCount = ani.readUint16(); + uint16 layerCount = ani.readUint16(); + + if (layerCount < 1) + warning("ANIFile::load(): Less than one layer (%d) in file \"%s\"", + layerCount, fileName.c_str()); + + // Load the layers + if (layerCount > 0) { + ani.skip(13); // The first layer is ignored? + if (_hasPadding) + ani.skip(1); + + _layers.resize(layerCount - 1); + for (LayerArray::iterator l = _layers.begin(); l != _layers.end(); ++l) + loadLayer(*l, ani); + } + + _maxWidth = 0; + _maxHeight = 0; + + // Load the animations + _animations.resize(animationCount); + _frames.resize(animationCount); + + for (uint16 animation = 0; animation < animationCount; animation++) { + loadAnimation(_animations[animation], _frames[animation], ani); + + _maxWidth = MAX(_maxWidth , _animations[animation].width); + _maxHeight = MAX(_maxHeight, _animations[animation].height); + } +} + +void ANIFile::loadAnimation(Animation &animation, FrameArray &frames, + Common::SeekableSubReadStreamEndian &ani) { + + // Animation properties + + animation.name = Util::readString(ani, 13); + if (_hasPadding) + ani.skip(1); + + ani.skip(13); // The name a second time?!? + if (_hasPadding) + ani.skip(1); + + ani.skip(2); // Unknown + + animation.x = (int16) ani.readUint16(); + animation.y = (int16) ani.readUint16(); + animation.deltaX = (int16) ani.readUint16(); + animation.deltaY = (int16) ani.readUint16(); + + animation.transp = ani.readByte() != 0; + + if (_hasPadding) + ani.skip(1); + + uint16 frameCount = ani.readUint16(); + + // Load the frames + + frames.resize(MAX(1, frameCount)); + loadFrames(frames, ani); + + animation.frameCount = frames.size(); + + animation.width = 0; + animation.height = 0; + + // Calculate the areas of each frame + + animation.frameAreas.resize(animation.frameCount); + for (uint16 i = 0; i < animation.frameCount; i++) { + const ChunkList &frame = frames[i]; + FrameArea &area = animation.frameAreas[i]; + + area.left = area.top = 0x7FFF; + area.right = area.bottom = -0x7FFF; + + for (ChunkList::const_iterator c = frame.begin(); c != frame.end(); c++) { + const Layer *layer; + const RXYFile::Coordinates *coords; + + if (!getPart(c->layer, c->part, layer, coords)) + continue; + + const uint16 width = coords->right - coords->left + 1; + const uint16 height = coords->bottom - coords->top + 1; + + const uint16 l = c->x; + const uint16 t = c->y; + const uint16 r = l + width - 1; + const uint16 b = t + height - 1; + + area.left = MIN(area.left , l); + area.top = MIN(area.top , t); + area.right = MAX(area.right , r); + area.bottom = MAX(area.bottom, b); + } + + if ((area.left <= area.right) && (area.top <= area.bottom)) { + animation.width = MAX(animation.width , area.right - area.left + 1); + animation.height = MAX(animation.height, area.bottom - area.top + 1); + } + } +} + +void ANIFile::loadFrames(FrameArray &frames, Common::SeekableSubReadStreamEndian &ani) { + uint32 curFrame = 0; + + bool end = false; + while (!end) { + frames[curFrame].push_back(AnimationChunk()); + AnimationChunk &chunk = frames[curFrame].back(); + + uint8 layerFlags = ani.readByte(); + + // Chunk properties + chunk.layer = (layerFlags & 0x0F) - 1; + chunk.part = ani.readByte(); + chunk.x = (int8) ani.readByte(); + chunk.y = (int8) ani.readByte(); + + // X multiplier/offset + int16 xOff = ((layerFlags & 0xC0) >> 6) << 7; + if (chunk.x >= 0) + chunk.x += xOff; + else + chunk.x -= xOff; + + // Y multiplier/offset + int16 yOff = ((layerFlags & 0x30) >> 4) << 7; + if (chunk.y >= 0) + chunk.y += yOff; + else + chunk.y -= yOff; + + uint8 multiPart = ani.readByte(); + if (multiPart == 0xFF) // No more frames in this animation + end = true; + else if (multiPart != 0x01) // No more chunks in this frame + curFrame++; + + // Shouldn't happen, but just to be safe + if (curFrame >= frames.size()) + frames.resize(curFrame + 1); + + if (_hasPadding) + ani.skip(1); + + if (ani.eos() || ani.err()) + error("ANIFile::loadFrames(): Read error"); + } +} + +void ANIFile::loadLayer(Layer &layer, Common::SeekableSubReadStreamEndian &ani) { + Common::String file = Util::readString(ani, 13); + if (_hasPadding) + ani.skip(1); + + if (file.empty()) + return; + + Common::String fileRXY = Util::setExtension(file, ".RXY"); + Common::String fileCMP = Util::setExtension(file, ".CMP"); + if (!_vm->_dataIO->hasFile(fileRXY) || !_vm->_dataIO->hasFile(fileCMP)) + return; + + loadLayer(layer, fileRXY, fileCMP); +} + +void ANIFile::loadLayer(Layer &layer, const Common::String &fileRXY, + const Common::String &fileCMP) { + + Common::SeekableReadStream *dataRXY = _vm->_dataIO->getFile(fileRXY); + if (!dataRXY) + return; + + layer.coordinates = new RXYFile(*dataRXY); + layer.surface = new Surface(_width, layer.coordinates->getHeight(), _bpp); + + _vm->_video->drawPackedSprite(fileCMP.c_str(), *layer.surface); +} + +uint16 ANIFile::getAnimationCount() const { + return _animations.size(); +} + +void ANIFile::getMaxSize(uint16 &width, uint16 &height) const { + width = _maxWidth; + height = _maxHeight; +} + +const ANIFile::Animation &ANIFile::getAnimationInfo(uint16 animation) const { + assert(animation < _animations.size()); + + return _animations[animation]; +} + +bool ANIFile::getPart(uint16 layer, uint16 part, + const Layer *&l, const RXYFile::Coordinates *&c) const { + + if (layer >= _layers.size()) + return false; + + l = &_layers[layer]; + if (!l->surface || !l->coordinates) + return false; + + if (part >= l->coordinates->size()) + return false; + + c = &(*l->coordinates)[part]; + if (c->left == 0xFFFF) + return false; + + return true; +} + +void ANIFile::draw(Surface &dest, uint16 animation, uint16 frame, int16 x, int16 y) const { + if (animation >= _animations.size()) + return; + + const Animation &anim = _animations[animation]; + if (frame >= anim.frameCount) + return; + + const ChunkList &chunks = _frames[animation][frame]; + + for (ChunkList::const_iterator c = chunks.begin(); c != chunks.end(); ++c) + drawLayer(dest, c->layer, c->part, x + c->x, y + c->y, anim.transp ? 0 : -1); +} + +void ANIFile::drawLayer(Surface &dest, uint16 layer, uint16 part, + int16 x, int16 y, int32 transp) const { + + const Layer *l; + const RXYFile::Coordinates *c; + + if (!getPart(layer, part, l, c)) + return; + + dest.blit(*l->surface, c->left, c->top, c->right, c->bottom, x, y, transp); +} + +} // End of namespace Gob diff --git a/engines/gob/anifile.h b/engines/gob/anifile.h new file mode 100644 index 0000000000..1e10da6ff4 --- /dev/null +++ b/engines/gob/anifile.h @@ -0,0 +1,161 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GOB_ANIFILE_H +#define GOB_ANIFILE_H + +#include "common/system.h" +#include "common/str.h" +#include "common/array.h" +#include "common/list.h" + +#include "gob/rxyfile.h" + +namespace Common { + class SeekableSubReadStreamEndian; +} + +namespace Gob { + +class GobEngine; +class Surface; + +/** An ANI file, describing an animation. + * + * Used in hardcoded "actiony" parts of gob games. + * The principle is similar to an Anim in Scenery (see scenery.cpp), but + * instead of referencing indices in the sprites array, ANIs reference sprites + * directly by filename. + */ +class ANIFile { +public: + /** The relative area a frame sprite occupies. */ + struct FrameArea { + int16 left; + int16 top; + int16 right; + int16 bottom; + }; + + /** An animation within an ANI file. */ + struct Animation { + Common::String name; ///< The name of the animation. + + uint16 frameCount; ///< The number of frames in this animation. + + int16 x; ///< The default x position for this animation. + int16 y; ///< The default y position for this animation. + bool transp; ///< Should the animation frames be drawn with transparency? + + int16 deltaX; ///< # of pixels to advance in X direction after each cycle. + int16 deltaY; ///< # of pixels to advance in Y direction after each cycle. + + /** The relative area each frame sprite occupies. */ + Common::Array frameAreas; + + uint16 width; ///< The maximum width of this animation's frames. + uint16 height; ///< The maximum height of this animation's frames. + }; + + + ANIFile(GobEngine *vm, const Common::String &fileName, + uint16 width = 320, uint8 bpp = 1); + ~ANIFile(); + + /** Return the number of animations in this ANI file. */ + uint16 getAnimationCount() const; + + /** Return the maximum size of all animation frames. */ + void getMaxSize(uint16 &width, uint16 &height) const; + + /** Get this animation's properties. */ + const Animation &getAnimationInfo(uint16 animation) const; + + /** Draw an animation frame. */ + void draw(Surface &dest, uint16 animation, uint16 frame, int16 x, int16 y) const; + +private: + /** A sprite layer. */ + struct Layer { + Surface *surface; ///< The surface containing the layer sprite. + RXYFile *coordinates; ///< The coordinates describing the layer sprite parts. + + Layer(); + ~Layer(); + }; + + typedef Common::Array LayerArray; + typedef Common::Array AnimationArray; + + /** A "chunk" of an animation frame. */ + struct AnimationChunk { + int16 x; ///< The relative x offset of this chunk. + int16 y; ///< The relative y offset of this chunk. + + uint16 layer; ///< The layer the chunk's sprite is on. + uint16 part; ///< The layer part the chunk's sprite is. + }; + + typedef Common::List ChunkList; + typedef Common::Array FrameArray; + typedef Common::Array AnimationFrameArray; + + + GobEngine *_vm; + + uint16 _width; ///< The width of a sprite layer. + uint8 _bpp; ///< Number of bytes per pixel in a sprite layer. + + byte _hasPadding; + + LayerArray _layers; ///< The animation sprite layers. + AnimationArray _animations; ///< The animations. + AnimationFrameArray _frames; ///< The animation frames. + + uint16 _maxWidth; + uint16 _maxHeight; + + + // Loading helpers + + void load(Common::SeekableSubReadStreamEndian &ani, const Common::String &fileName); + + void loadLayer(Layer &layer, Common::SeekableSubReadStreamEndian &ani); + void loadLayer(Layer &layer, const Common::String &fileRXY, + const Common::String &fileCMP); + + void loadAnimation(Animation &animation, FrameArray &frames, + Common::SeekableSubReadStreamEndian &ani); + void loadFrames(FrameArray &frames, Common::SeekableSubReadStreamEndian &ani); + + // Drawing helpers + + bool getPart(uint16 layer, uint16 part, + const Layer *&l, const RXYFile::Coordinates *&c) const; + + void drawLayer(Surface &dest, uint16 layer, uint16 part, + int16 x, int16 y, int32 transp) const; +}; + +} // End of namespace Gob + +#endif // GOB_ANIFILE_H diff --git a/engines/gob/module.mk b/engines/gob/module.mk index 0fdbdf9762..a2a78bc5c7 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -1,6 +1,7 @@ MODULE := engines/gob MODULE_OBJS := \ + anifile.o \ console.o \ dataio.o \ databases.o \ -- cgit v1.2.3 From 220fc2b59307734a26057fa6446ed13fa2c543a1 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 3 Sep 2011 12:41:06 +0200 Subject: GOB: Add class ANIObject Controls an animation stored within an ANI file. --- engines/gob/aniobject.cpp | 185 ++++++++++++++++++++++++++++++++++++++++++++++ engines/gob/aniobject.h | 99 +++++++++++++++++++++++++ engines/gob/module.mk | 1 + 3 files changed, 285 insertions(+) create mode 100644 engines/gob/aniobject.cpp create mode 100644 engines/gob/aniobject.h diff --git a/engines/gob/aniobject.cpp b/engines/gob/aniobject.cpp new file mode 100644 index 0000000000..c6a9234eb9 --- /dev/null +++ b/engines/gob/aniobject.cpp @@ -0,0 +1,185 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "gob/surface.h" +#include "gob/anifile.h" +#include "gob/aniobject.h" + +namespace Gob { + +ANIObject::ANIObject(const ANIFile &ani) : _ani(&ani), _visible(false), + _x(0), _y(0), _background(0), _drawn(false) { + + setAnimation(0); + setPosition(); +} + +ANIObject::~ANIObject() { + delete _background; +} + +void ANIObject::setVisible(bool visible) { + _visible = visible; +} + +bool ANIObject::isVisible() const { + return _visible; +} + +void ANIObject::setAnimation(uint16 animation) { + _animation = animation; + _frame = 0; +} + +void ANIObject::setPosition() { + if (_animation >= _ani->getAnimationCount()) + return; + + const ANIFile::Animation &animation = _ani->getAnimationInfo(_animation); + + _x = animation.x; + _y = animation.y; +} + +void ANIObject::setPosition(int16 x, int16 y) { + _x = x; + _y = y; +} + +void ANIObject::getPosition(int16 &x, int16 &y) const { + x = _x; + y = _y; +} + +void ANIObject::getFramePosition(int16 &x, int16 &y) const { + if (_animation >= _ani->getAnimationCount()) + return; + + const ANIFile::Animation &animation = _ani->getAnimationInfo(_animation); + if (_frame >= animation.frameCount) + return; + + x = _x + animation.frameAreas[_frame].left; + y = _y + animation.frameAreas[_frame].top; +} + +void ANIObject::getFrameSize(int16 &width, int16 &height) const { + if (_animation >= _ani->getAnimationCount()) + return; + + const ANIFile::Animation &animation = _ani->getAnimationInfo(_animation); + if (_frame >= animation.frameCount) + return; + + width = animation.frameAreas[_frame].right - animation.frameAreas[_frame].left + 1; + height = animation.frameAreas[_frame].bottom - animation.frameAreas[_frame].top + 1; +} + +void ANIObject::draw(Surface &dest, int16 &left, int16 &top, + int16 &right, int16 &bottom) { + + if (!_visible) + return; + + if (!_background) { + uint16 width, height; + + _ani->getMaxSize(width, height); + + _background = new Surface(width, height, dest.getBPP()); + } + + const ANIFile::Animation &animation = _ani->getAnimationInfo(_animation); + if (_frame >= animation.frameCount) + return; + + const ANIFile::FrameArea &area = animation.frameAreas[_frame]; + + _backgroundLeft = CLIP(area.left + _x, 0, dest.getWidth () - 1); + _backgroundTop = CLIP(area.top + _y, 0, dest.getHeight() - 1); + _backgroundRight = CLIP(area.right + _x, 0, dest.getWidth () - 1); + _backgroundBottom = CLIP(area.bottom + _y, 0, dest.getHeight() - 1); + + _background->blit(dest, _backgroundLeft , _backgroundTop, + _backgroundRight, _backgroundBottom, 0, 0); + + _ani->draw(dest, _animation, _frame, _x, _y); + + _drawn = true; + + left = _backgroundLeft; + top = _backgroundTop; + right = _backgroundRight; + bottom = _backgroundBottom; +} + +void ANIObject::clear(Surface &dest, int16 &left, int16 &top, + int16 &right, int16 &bottom) { + + if (!_drawn) + return; + + const int16 bgRight = _backgroundRight - _backgroundLeft; + const int16 bgBottom = _backgroundBottom - _backgroundTop; + + dest.blit(*_background, 0, 0, bgRight, bgBottom, _backgroundLeft, _backgroundTop); + + _drawn = false; + + left = _backgroundLeft; + top = _backgroundTop; + right = _backgroundRight; + bottom = _backgroundBottom; +} + +void ANIObject::advance() { + if (_animation >= _ani->getAnimationCount()) + return; + + const ANIFile::Animation &animation = _ani->getAnimationInfo(_animation); + + _frame = (_frame + 1) % animation.frameCount; + + if (_frame == 0) { + _x += animation.deltaX; + _y += animation.deltaY; + } +} + +uint16 ANIObject::getAnimation() const { + return _animation; +} + +uint16 ANIObject::getFrame() const { + return _frame; +} + +bool ANIObject::lastFrame() const { + if (_animation >= _ani->getAnimationCount()) + return true; + + const ANIFile::Animation &animation = _ani->getAnimationInfo(_animation); + + return (_frame + 1) >= animation.frameCount; +} + +} // End of namespace Gob diff --git a/engines/gob/aniobject.h b/engines/gob/aniobject.h new file mode 100644 index 0000000000..357c2a9bcc --- /dev/null +++ b/engines/gob/aniobject.h @@ -0,0 +1,99 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GOB_ANIOBJECT_H +#define GOB_ANIOBJECT_H + +#include "common/system.h" + +namespace Gob { + +class ANIFile; +class Surface; + +/** An ANI object, controlling an animation within an ANI file. */ +class ANIObject { +public: + ANIObject(const ANIFile &ani); + virtual ~ANIObject(); + + /** Make the object visible/invisible. */ + void setVisible(bool visible); + + /** Is the object currently visible? */ + bool isVisible() const; + + /** Set the current position to the animation's default. */ + void setPosition(); + /** Set the current position. */ + void setPosition(int16 x, int16 y); + + /** Return the current position. */ + void getPosition(int16 &x, int16 &y) const; + + /** Return the current frame position. */ + void getFramePosition(int16 &x, int16 &y) const; + /** Return the current frame size. */ + void getFrameSize(int16 &width, int16 &height) const; + + /** Set the animation number. */ + void setAnimation(uint16 animation); + + /** Return the current animation number. */ + uint16 getAnimation() const; + /** Return the current frame number. */ + uint16 getFrame() const; + + /** Is this the last frame within this animation cycle? */ + bool lastFrame() const; + + /** Draw the current frame onto the surface and return the affected rectangle. */ + void draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom); + /** Draw the current frame from the surface and return the affected rectangle. */ + void clear(Surface &dest, int16 &left , int16 &top, int16 &right, int16 &bottom); + + /** Advance the animation to the next frame. */ + virtual void advance(); + +private: + const ANIFile *_ani; ///< The managed ANI file. + + uint16 _animation; ///< The current animation number + uint16 _frame; ///< The current frame. + + bool _visible; ///< Is the object currently visible? + + int16 _x; ///< The current X position. + int16 _y; ///< The current Y position. + + Surface *_background; ///< The saved background. + bool _drawn; ///< Was the animation drawn? + + int16 _backgroundLeft; ///< The left position of the saved background. + int16 _backgroundTop; ///< The top of the saved background. + int16 _backgroundRight; ///< The right position of the saved background. + int16 _backgroundBottom; ///< The bottom position of the saved background. +}; + +} // End of namespace Gob + +#endif // GOB_ANIOBJECT_H diff --git a/engines/gob/module.mk b/engines/gob/module.mk index a2a78bc5c7..d451e250ff 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -2,6 +2,7 @@ MODULE := engines/gob MODULE_OBJS := \ anifile.o \ + aniobject.o \ console.o \ dataio.o \ databases.o \ -- cgit v1.2.3 From dbb70e3d6f3b6ce5ff0497dbded420783edb3256 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 3 Sep 2011 15:51:37 +0200 Subject: GOB: Add class Geisha::EvilFish An "evil" fish in Geisha's "Diving" minigame. --- engines/gob/minigames/geisha/evilfish.cpp | 163 ++++++++++++++++++++++++++++++ engines/gob/minigames/geisha/evilfish.h | 86 ++++++++++++++++ engines/gob/module.mk | 1 + 3 files changed, 250 insertions(+) create mode 100644 engines/gob/minigames/geisha/evilfish.cpp create mode 100644 engines/gob/minigames/geisha/evilfish.h diff --git a/engines/gob/minigames/geisha/evilfish.cpp b/engines/gob/minigames/geisha/evilfish.cpp new file mode 100644 index 0000000000..e2672d75c8 --- /dev/null +++ b/engines/gob/minigames/geisha/evilfish.cpp @@ -0,0 +1,163 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "gob/minigames/geisha/evilfish.h" + +namespace Gob { + +namespace Geisha { + +EvilFish::EvilFish(const ANIFile &ani, uint16 screenWidth, + uint16 animSwimLeft, uint16 animSwimRight, + uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie) : + ANIObject(ani), _screenWidth(screenWidth), + _animSwimLeft(animSwimLeft), _animSwimRight(animSwimRight), + _animTurnLeft(animTurnLeft), _animTurnRight(animTurnRight), _animDie(animDie), + _shouldLeave(false), _state(kStateNone) { + +} + +EvilFish::~EvilFish() { +} + +bool EvilFish::isIn(int16 x, int16 y) const { + int16 frameX, frameY, frameWidth, frameHeight; + getFramePosition(frameX, frameY); + getFrameSize(frameWidth, frameHeight); + + if ((x < frameX) || (y < frameY)) + return false; + if ((x > (frameX + frameWidth)) || (y > (frameY + frameHeight))) + return false; + + return true; +} + +void EvilFish::enter(Direction from, int16 y) { + _shouldLeave = false; + + bool left = from == kDirectionLeft; + + setAnimation(left ? _animSwimLeft : _animSwimRight); + + int16 width, height; + getFrameSize(width, height); + + setPosition(left ? -width : _screenWidth, y); + setVisible(true); + + _state = left ? kStateSwimLeft : kStateSwimRight; +} + +void EvilFish::leave() { + if (_state == kStateNone) + return; + + _shouldLeave = true; +} + +void EvilFish::die() { + if ((_state == kStateNone) || (_state == kStateDie)) + return; + + int16 x, y; + getFramePosition(x, y); + + setAnimation(_animDie); + setPosition(x, y); + + _state = kStateDie; +} + +void EvilFish::advance() { + if (_state == kStateNone) + return; + + bool wasLastFrame = lastFrame(); + + ANIObject::advance(); + + int16 x, y, width, height; + getFramePosition(x, y); + getFrameSize(width, height); + + switch (_state) { + case kStateNone: + break; + + case kStateSwimLeft: + if (!_shouldLeave && (x >= _screenWidth - width)) { + setAnimation(_animTurnRight); + setPosition(x, y); + _state = kStateTurnRight; + } + + if (_shouldLeave && (x >= _screenWidth)) { + setVisible(false); + + _shouldLeave = false; + _state = kStateNone; + } + break; + + case kStateSwimRight: + if (!_shouldLeave && (x <= 0)) { + setAnimation(_animTurnLeft); + setPosition(x, y); + _state = kStateTurnLeft; + } + + if (_shouldLeave && (x < -width)) { + setVisible(false); + + _shouldLeave = false; + _state = kStateNone; + } + break; + + case kStateTurnLeft: + if (wasLastFrame) { + setAnimation(_animSwimLeft); + _state = kStateSwimLeft; + } + break; + + case kStateTurnRight: + if (wasLastFrame) { + setAnimation(_animSwimRight); + _state = kStateSwimRight; + } + break; + + case kStateDie: + if (wasLastFrame) { + setVisible(false); + + _state = kStateNone; + } + break; + } +} + +} // End of namespace Geisha + +} // End of namespace Gob diff --git a/engines/gob/minigames/geisha/evilfish.h b/engines/gob/minigames/geisha/evilfish.h new file mode 100644 index 0000000000..9144cefb4b --- /dev/null +++ b/engines/gob/minigames/geisha/evilfish.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GOB_MINIGAMES_GEISHA_EVILFISH_H +#define GOB_MINIGAMES_GEISHA_EVILFISH_H + +#include "gob/aniobject.h" + +namespace Gob { + +namespace Geisha { + +/** An "evil" fish in Geisha's "Diving" minigame. */ +class EvilFish : public ANIObject { +public: + enum Direction { + kDirectionLeft, + kDirectionRight + }; + + EvilFish(const ANIFile &ani, uint16 screenWidth, + uint16 animSwimLeft, uint16 animSwimRight, + uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie); + ~EvilFish(); + + /** Are there coordinates within the fish's sprite? */ + bool isIn(int16 x, int16 y) const; + + /** Enter from this direction / screen edge. */ + void enter(Direction from, int16 y); + /** Leave the screen in the current direction. */ + void leave(); + + /** Kill the fish. */ + void die(); + + /** Advance the animation to the next frame. */ + void advance(); + +private: + enum State { + kStateNone, + kStateSwimLeft, + kStateSwimRight, + kStateTurnLeft, + kStateTurnRight, + kStateDie + }; + + uint16 _screenWidth; + + uint16 _animSwimLeft; + uint16 _animSwimRight; + uint16 _animTurnLeft; + uint16 _animTurnRight; + uint16 _animDie; + + bool _shouldLeave; + + State _state; +}; + +} // End of namespace Geisha + +} // End of namespace Gob + +#endif // GOB_MINIGAMES_GEISHA_EVILFISH_H diff --git a/engines/gob/module.mk b/engines/gob/module.mk index d451e250ff..0ea4f2617d 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -73,6 +73,7 @@ MODULE_OBJS := \ demos/demoplayer.o \ demos/scnplayer.o \ demos/batplayer.o \ + minigames/geisha/evilfish.o \ save/savefile.o \ save/savehandler.o \ save/saveload.o \ -- cgit v1.2.3 From 26dd2f5f603b10b3b54664b6589c8feb6c4f7b82 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 3 Sep 2011 17:21:25 +0200 Subject: GOB: Move keyPressed() to Util --- engines/gob/inter.h | 2 -- engines/gob/inter_geisha.cpp | 14 +------------- engines/gob/util.cpp | 12 ++++++++++++ engines/gob/util.h | 1 + 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/engines/gob/inter.h b/engines/gob/inter.h index c84cc384ce..d1c28fcb2f 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -362,8 +362,6 @@ protected: void oGeisha_caress2(OpGobParams ¶ms); int16 loadSound(int16 slot); - - bool keyPressed(); }; class Inter_v2 : public Inter_v1 { diff --git a/engines/gob/inter_geisha.cpp b/engines/gob/inter_geisha.cpp index 6c3e97c2a7..d72dd798a4 100644 --- a/engines/gob/inter_geisha.cpp +++ b/engines/gob/inter_geisha.cpp @@ -82,18 +82,6 @@ void Inter_Geisha::oGeisha_loadCursor(OpFuncParams ¶ms) { o1_loadCursor(params); } -bool Inter_Geisha::keyPressed() { - int16 key = _vm->_util->checkKey(); - if (key) - return true; - - int16 x, y; - MouseButtons buttons; - - _vm->_util->getMouseState(&x, &y, &buttons); - return buttons != kMouseButtonsNone; -} - struct TOTTransition { const char *to; const char *from; @@ -134,7 +122,7 @@ void Inter_Geisha::oGeisha_loadTot(OpFuncParams ¶ms) { } if (needWait) - while (!keyPressed()) + while (!_vm->_util->keyPressed()) _vm->_util->longDelay(1); } diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 58dfc9c7ad..7f9c6131fd 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -257,6 +257,18 @@ bool Util::checkKey(int16 &key) { return true; } +bool Util::keyPressed() { + int16 key = checkKey(); + if (key) + return true; + + int16 x, y; + MouseButtons buttons; + + getMouseState(&x, &y, &buttons); + return buttons != kMouseButtonsNone; +} + void Util::getMouseState(int16 *pX, int16 *pY, MouseButtons *pButtons) { Common::Point mouse = g_system->getEventManager()->getMousePos(); *pX = mouse.x + _vm->_video->_scrollOffsetX - _vm->_video->_screenDeltaX; diff --git a/engines/gob/util.h b/engines/gob/util.h index 7c1e44c0f6..4228dac768 100644 --- a/engines/gob/util.h +++ b/engines/gob/util.h @@ -108,6 +108,7 @@ public: int16 getKey(); int16 checkKey(); bool checkKey(int16 &key); + bool keyPressed(); void getMouseState(int16 *pX, int16 *pY, MouseButtons *pButtons); void setMousePos(int16 x, int16 y); -- cgit v1.2.3 From 7f5f9c9f91eb8cd52ebcffe208d0e778f8ff6448 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 3 Sep 2011 17:24:34 +0200 Subject: GOB: Stub classes for Geisha's Diving and Penetration minigames --- engines/gob/inter.h | 11 +- engines/gob/inter_geisha.cpp | 42 ++++---- engines/gob/minigames/geisha/diving.cpp | 155 +++++++++++++++++++++++++++ engines/gob/minigames/geisha/diving.h | 68 ++++++++++++ engines/gob/minigames/geisha/penetration.cpp | 106 ++++++++++++++++++ engines/gob/minigames/geisha/penetration.h | 61 +++++++++++ engines/gob/module.mk | 2 + 7 files changed, 426 insertions(+), 19 deletions(-) create mode 100644 engines/gob/minigames/geisha/diving.cpp create mode 100644 engines/gob/minigames/geisha/diving.h create mode 100644 engines/gob/minigames/geisha/penetration.cpp create mode 100644 engines/gob/minigames/geisha/penetration.h diff --git a/engines/gob/inter.h b/engines/gob/inter.h index d1c28fcb2f..6fd4dc2187 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -33,6 +33,11 @@ namespace Gob { +namespace Geisha { + class Diving; + class Penetration; +} + // This is to help devices with small memory (PDA, smartphones, ...) // to save a bit of memory used by opcode names in the Gob engine. #ifndef REDUCE_MEMORY_USAGE @@ -337,7 +342,7 @@ protected: class Inter_Geisha : public Inter_v1 { public: Inter_Geisha(GobEngine *vm); - virtual ~Inter_Geisha() {} + virtual ~Inter_Geisha(); protected: virtual void setupOpcodesDraw(); @@ -362,6 +367,10 @@ protected: void oGeisha_caress2(OpGobParams ¶ms); int16 loadSound(int16 slot); + +private: + Geisha::Diving *_diving; + Geisha::Penetration *_penetration; }; class Inter_v2 : public Inter_v1 { diff --git a/engines/gob/inter_geisha.cpp b/engines/gob/inter_geisha.cpp index d72dd798a4..c5b91a484b 100644 --- a/engines/gob/inter_geisha.cpp +++ b/engines/gob/inter_geisha.cpp @@ -38,6 +38,9 @@ #include "gob/sound/sound.h" #include "gob/sound/sounddesc.h" +#include "gob/minigames/geisha/diving.h" +#include "gob/minigames/geisha/penetration.h" + namespace Gob { #define OPCODEVER Inter_Geisha @@ -45,7 +48,16 @@ namespace Gob { #define OPCODEFUNC(i, x) _opcodesFunc[i]._OPCODEFUNC(OPCODEVER, x) #define OPCODEGOB(i, x) _opcodesGob[i]._OPCODEGOB(OPCODEVER, x) -Inter_Geisha::Inter_Geisha(GobEngine *vm) : Inter_v1(vm) { +Inter_Geisha::Inter_Geisha(GobEngine *vm) : Inter_v1(vm), + _diving(0), _penetration(0) { + + _diving = new Geisha::Diving(vm); + _penetration = new Geisha::Penetration(vm); +} + +Inter_Geisha::~Inter_Geisha() { + delete _penetration; + delete _diving; } void Inter_Geisha::setupOpcodesDraw() { @@ -251,30 +263,24 @@ void Inter_Geisha::oGeisha_writeData(OpFuncParams ¶ms) { } void Inter_Geisha::oGeisha_gamePenetration(OpGobParams ¶ms) { - uint16 var1 = _vm->_game->_script->readUint16(); - uint16 var2 = _vm->_game->_script->readUint16(); - uint16 var3 = _vm->_game->_script->readUint16(); - uint16 var4 = _vm->_game->_script->readUint16(); - - WRITE_VAR_UINT32(var4, 0); + uint16 var1 = _vm->_game->_script->readUint16(); + uint16 var2 = _vm->_game->_script->readUint16(); + uint16 var3 = _vm->_game->_script->readUint16(); + uint16 resultVar = _vm->_game->_script->readUint16(); - warning("Geisha Stub: Minigame \"Penetration\": %d, %d, %d, %d", var1, var2, var3, var4); + bool result = _penetration->play(var1, var2, var3); - // Fudge a win for now - WRITE_VAR_UINT32(var4, 1); + WRITE_VAR_UINT32(resultVar, result ? 1 : 0); } void Inter_Geisha::oGeisha_gameDiving(OpGobParams ¶ms) { - uint16 var1 = _vm->_game->_script->readUint16(); - uint16 var2 = _vm->_game->_script->readUint16(); - uint16 var3 = _vm->_game->_script->readUint16(); - - WRITE_VAR_UINT32(var3, 1); + uint16 playerCount = _vm->_game->_script->readUint16(); + uint16 hasPearlLocation = _vm->_game->_script->readUint16(); + uint16 resultVar = _vm->_game->_script->readUint16(); - warning("Geisha Stub: Minigame \"Diving\": %d, %d, %d", var1, var2, var3); + bool result = _diving->play(playerCount, hasPearlLocation); - // Fudge a win for now - WRITE_VAR_UINT32(var3, 0); + WRITE_VAR_UINT32(resultVar, result ? 1 : 0); } void Inter_Geisha::oGeisha_loadTitleMusic(OpGobParams ¶ms) { diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp new file mode 100644 index 0000000000..0d216abf43 --- /dev/null +++ b/engines/gob/minigames/geisha/diving.cpp @@ -0,0 +1,155 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/list.h" + +#include "gob/global.h" +#include "gob/util.h" +#include "gob/draw.h" +#include "gob/video.h" +#include "gob/decfile.h" +#include "gob/anifile.h" + +#include "gob/minigames/geisha/evilfish.h" +#include "gob/minigames/geisha/diving.h" + +namespace Gob { + +namespace Geisha { + +Diving::Diving(GobEngine *vm) : _vm(vm), _background(0), + _objects(0), _gui(0), _oko(0), _lungs(0), _heart(0) { + +} + +Diving::~Diving() { + deinit(); +} + +bool Diving::play(uint16 playerCount, bool hasPearlLocation) { + init(); + initScreen(); + + _vm->_draw->blitInvalidated(); + _vm->_video->retrace(); + + EvilFish shark(*_objects, 320, 0, 14, 8, 9, 3); + + Common::List objects; + + objects.push_back(_water); + objects.push_back(&shark); + + shark.enter(EvilFish::kDirectionLeft, 90); + + while (!_vm->_util->keyPressed() && !_vm->shouldQuit()) { + int16 left, top, right, bottom; + + // Clear the previous animation frames + for (Common::List::iterator o = objects.reverse_begin(); + o != objects.end(); --o) { + + (*o)->clear(*_vm->_draw->_backSurface, left, top, right, bottom); + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom); + } + + // Draw the current animation frames + for (Common::List::iterator o = objects.begin(); + o != objects.end(); ++o) { + + (*o)->draw(*_vm->_draw->_backSurface, left, top, right, bottom); + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom); + + (*o)->advance(); + } + + _vm->_draw->blitInvalidated(); + + _vm->_util->waitEndFrame(); + _vm->_util->processInput(); + } + + deinit(); + return true; +} + +void Diving::init() { + _background = new DECFile(_vm, "tperle.dec" , 320, 200); + _objects = new ANIFile(_vm, "tperle.ani" , 320); + _gui = new ANIFile(_vm, "tperlcpt.ani", 320); + _oko = new ANIFile(_vm, "tplonge.ani" , 320); + + _water = new ANIObject(*_objects); + _lungs = new ANIObject(*_gui); + _heart = new ANIObject(*_gui); + + _water->setAnimation(7); + _water->setPosition(); + _water->setVisible(true); + + _lungs->setAnimation(0); + _lungs->setPosition(); + _lungs->setVisible(true); + + _heart->setAnimation(1); + _heart->setPosition(); + _heart->setVisible(true); +} + +void Diving::deinit() { + delete _heart; + delete _lungs; + delete _water; + + delete _oko; + delete _gui; + delete _objects; + delete _background; + + _water = 0; + _heart = 0; + _lungs = 0; + + _oko = 0; + _gui = 0; + _objects = 0; + _background = 0; +} + +void Diving::initScreen() { + _vm->_util->setFrameRate(15); + + _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); + + _vm->_draw->_backSurface->clear(); + _background->draw(*_vm->_draw->_backSurface); + + int16 left, top, right, bottom; + _lungs->draw(*_vm->_draw->_backSurface, left, top, right, bottom); + _heart->draw(*_vm->_draw->_backSurface, left, top, right, bottom); + + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199); +} + +} // End of namespace Geisha + +} // End of namespace Gob diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h new file mode 100644 index 0000000000..238a1ad75b --- /dev/null +++ b/engines/gob/minigames/geisha/diving.h @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GOB_MINIGAMES_GEISHA_DIVING_H +#define GOB_MINIGAMES_GEISHA_DIVING_H + +#include "common/system.h" + +namespace Gob { + +class GobEngine; +class DECFile; +class ANIFile; +class ANIObject; + +namespace Geisha { + +/** Geisha's "Diving" minigame. */ +class Diving { +public: + Diving(GobEngine *vm); + ~Diving(); + + bool play(uint16 playerCount, bool hasPearlLocation); + +private: + GobEngine *_vm; + + DECFile *_background; + ANIFile *_objects; + ANIFile *_gui; + ANIFile *_oko; + + ANIObject *_water; + ANIObject *_lungs; + ANIObject *_heart; + + + void init(); + void deinit(); + + void initScreen(); +}; + +} // End of namespace Geisha + +} // End of namespace Gob + +#endif // GOB_MINIGAMES_GEISHA_DIVING_H diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp new file mode 100644 index 0000000000..4334cae21a --- /dev/null +++ b/engines/gob/minigames/geisha/penetration.cpp @@ -0,0 +1,106 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "gob/global.h" +#include "gob/util.h" +#include "gob/draw.h" +#include "gob/video.h" +#include "gob/decfile.h" +#include "gob/anifile.h" + +#include "gob/minigames/geisha/penetration.h" + +namespace Gob { + +namespace Geisha { + +static byte kPalette[48] = { + 0x16, 0x16, 0x16, + 0x12, 0x14, 0x16, + 0x34, 0x00, 0x25, + 0x1D, 0x1F, 0x22, + 0x24, 0x27, 0x2A, + 0x2C, 0x0D, 0x22, + 0x2B, 0x2E, 0x32, + 0x12, 0x09, 0x20, + 0x3D, 0x3F, 0x00, + 0x3F, 0x3F, 0x3F, + 0x00, 0x00, 0x00, + 0x15, 0x15, 0x3F, + 0x25, 0x22, 0x2F, + 0x1A, 0x14, 0x28, + 0x3F, 0x00, 0x00, + 0x15, 0x3F, 0x15 +}; + +Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _objects(0) { + _background = new Surface(320, 200, 1); +} + +Penetration::~Penetration() { + deinit(); + + delete _background; +} + +bool Penetration::play(uint16 var1, uint16 var2, uint16 var3) { + init(); + initScreen(); + + _vm->_draw->blitInvalidated(); + _vm->_video->retrace(); + while (!_vm->_util->keyPressed() && !_vm->shouldQuit()) + _vm->_util->longDelay(1); + + deinit(); + return true; +} + +void Penetration::init() { + _background->clear(); + + _vm->_video->drawPackedSprite("hyprmef2.cmp", *_background); + + _objects = new ANIFile(_vm, "tcite.ani", 320); +} + +void Penetration::deinit() { + delete _objects; + + _objects = 0; +} + +void Penetration::initScreen() { + _vm->_util->setFrameRate(15); + + memcpy(_vm->_draw->_vgaPalette , kPalette, 48); + memcpy(_vm->_draw->_vgaSmallPalette, kPalette, 48); + + _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); + + _vm->_draw->_backSurface->blit(*_background); + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199); +} + +} // End of namespace Geisha + +} // End of namespace Gob diff --git a/engines/gob/minigames/geisha/penetration.h b/engines/gob/minigames/geisha/penetration.h new file mode 100644 index 0000000000..c346a7bf5a --- /dev/null +++ b/engines/gob/minigames/geisha/penetration.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GOB_MINIGAMES_GEISHA_PENETRATION_H +#define GOB_MINIGAMES_GEISHA_PENETRATION_H + +#include "common/system.h" + +namespace Gob { + +class GobEngine; +class Surface; +class ANIFile; + +namespace Geisha { + +/** Geisha's "Penetration" minigame. */ +class Penetration { +public: + Penetration(GobEngine *vm); + ~Penetration(); + + bool play(uint16 var1, uint16 var2, uint16 var3); + +private: + GobEngine *_vm; + + Surface *_background; + ANIFile *_objects; + + + void init(); + void deinit(); + + void initScreen(); +}; + +} // End of namespace Geisha + +} // End of namespace Gob + +#endif // GOB_MINIGAMES_GEISHA_PENETRATION_H diff --git a/engines/gob/module.mk b/engines/gob/module.mk index 0ea4f2617d..bf040c5428 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -74,6 +74,8 @@ MODULE_OBJS := \ demos/scnplayer.o \ demos/batplayer.o \ minigames/geisha/evilfish.o \ + minigames/geisha/diving.o \ + minigames/geisha/penetration.o \ save/savefile.o \ save/savehandler.o \ save/saveload.o \ -- cgit v1.2.3 From b893f9f93f58413bd45daec5d4b88a0ca4bb5db1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 4 Sep 2011 19:11:59 +1000 Subject: TSAGE: Implemented missing interface functionality, including gun loading dialog --- engines/tsage/blue_force/blueforce_dialogs.cpp | 169 ++++++++++++ engines/tsage/blue_force/blueforce_dialogs.h | 18 ++ engines/tsage/blue_force/blueforce_logic.cpp | 342 ++++++++++++++++--------- engines/tsage/blue_force/blueforce_logic.h | 118 ++++----- engines/tsage/blue_force/blueforce_ui.cpp | 81 ++++-- engines/tsage/blue_force/blueforce_ui.h | 9 +- engines/tsage/core.cpp | 35 ++- engines/tsage/core.h | 3 +- engines/tsage/events.cpp | 26 +- engines/tsage/events.h | 21 ++ engines/tsage/globals.cpp | 36 ++- engines/tsage/globals.h | 3 + engines/tsage/tsage.cpp | 6 + 13 files changed, 633 insertions(+), 234 deletions(-) diff --git a/engines/tsage/blue_force/blueforce_dialogs.cpp b/engines/tsage/blue_force/blueforce_dialogs.cpp index ec99df8c3b..be72b78622 100644 --- a/engines/tsage/blue_force/blueforce_dialogs.cpp +++ b/engines/tsage/blue_force/blueforce_dialogs.cpp @@ -196,6 +196,175 @@ void RightClickDialog::execute() { _gfxManager.deactivate(); } +/*--------------------------------------------------------------------------*/ + +AmmoBeltDialog::AmmoBeltDialog() : GfxDialog() { + _cursorNum = BF_GLOBALS._events.getCursor(); + _inDialog = -1; + _closeFlag = false; + + // Get the dialog image + _surface = surfaceFromRes(9, 5, 2); + + // Set the dialog position + _dialogRect.resize(_surface, 0, 0, 100); + _dialogRect.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); + + _bounds = _dialogRect; + _gfxManager._bounds = _bounds; + _savedArea = NULL; + + // Set up area rects + _gunRect.set(0, 0, 82, 48); + _clip1Rect.set(90, 6, _bounds.width(), 39); + _clip2Rect.set(90, 40, _bounds.width(), _bounds.height()); + _loadedRect.set(50, 40, 60, 50); +} + +AmmoBeltDialog::~AmmoBeltDialog() { + BF_GLOBALS._events.setCursor(_cursorNum); +} + +void AmmoBeltDialog::execute() { + // Draw the dialog + draw(); + + // Dialog event handler loop + _gfxManager.activate(); + + while (!_vm->shouldQuit() && !_closeFlag) { + Event evt; + while (_globals->_events.getEvent(evt, EVENT_MOUSE_MOVE | EVENT_BUTTON_DOWN)) { + evt.mousePos.x -= _bounds.left; + evt.mousePos.y -= _bounds.top; + + process(evt); + } + + g_system->delayMillis(10); + g_system->updateScreen(); + } + + _gfxManager.deactivate(); +} + +bool AmmoBeltDialog::process(Event &event) { + switch (event.eventType) { + case EVENT_MOUSE_MOVE: { + // Handle updating cursor depending on whether cursor is in dialog or not + int inDialog = Rect(0, 0, _bounds.width(), _bounds.height()).contains(event.mousePos); + if (inDialog != _inDialog) { + // Update cursor + BF_GLOBALS._events.setCursor(inDialog ? CURSOR_USE : CURSOR_EXIT); + _inDialog = inDialog; + } + return true; + } + + case EVENT_BUTTON_DOWN: + if (!_inDialog) + // Clicked outside dialog, so flag to close it + _closeFlag = true; + else { + int v = (BF_GLOBALS.getFlag(fGunLoaded) ? 1 : 0) * (BF_GLOBALS.getFlag(fLoadedSpare) ? 2 : 1); + + // Handle first clip + if ((v != 1) && _clip1Rect.contains(event.mousePos)) { + if (BF_GLOBALS.getFlag(fGunLoaded)) { + event.mousePos.x = event.mousePos.y = 0; + } + + BF_GLOBALS.setFlag(fGunLoaded); + BF_GLOBALS.clearFlag(fLoadedSpare); + } + + // Handle second clip + if ((v != 2) && _clip2Rect.contains(event.mousePos)) { + if (BF_GLOBALS.getFlag(fGunLoaded)) { + event.mousePos.x = event.mousePos.y = 0; + } + + BF_GLOBALS.setFlag(fGunLoaded); + BF_GLOBALS.setFlag(fLoadedSpare); + } + + if (_gunRect.contains(event.mousePos) && BF_GLOBALS.getFlag(fGunLoaded)) { + BF_GLOBALS.clearFlag(fGunLoaded); + v = (BF_GLOBALS.getFlag(fGunLoaded) ? 1 : 0) * (BF_GLOBALS.getFlag(fLoadedSpare) ? 2 : 1); + + if (v != 2) + BF_GLOBALS.clearFlag(fLoadedSpare); + } + + draw(); + } + + return true; + + case EVENT_KEYPRESS: + if ((event.kbd.keycode == Common::KEYCODE_ESCAPE) || (event.kbd.keycode == Common::KEYCODE_RETURN)) { + // Escape pressed, so flag to close dialog + _closeFlag = true; + return true; + } + break; + + default: + break; + } + + return false; +} + +void AmmoBeltDialog::draw() { + Rect bounds = _bounds; + + if (!_savedArea) { + // Save the covered background area + _savedArea = Surface_getArea(_globals->_gfxManagerInstance.getSurface(), _bounds); + } else { + bounds.moveTo(0, 0); + } + + // Draw the dialog image + _globals->gfxManager().copyFrom(_surface, bounds.left, bounds.top); + + // Setup clip flags + bool clip1 = true, clip2 = true; + bool gunLoaded = BF_GLOBALS.getFlag(fGunLoaded); + if (gunLoaded) { + // A clip is currently loaded. Hide the appropriate clip + if (BF_GLOBALS.getFlag(fLoadedSpare)) + clip2 = false; + else + clip1 = false; + } + + // Draw the first clip if necessary + if (clip1) { + GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip1Frame); + _clip1Rect.resize(clipSurface, _clip1Rect.left, _clip1Rect.top, 100); + _globals->gfxManager().copyFrom(clipSurface, bounds.left + _clip1Rect.left, + bounds.top + _clip1Rect.top); + } + + // Draw the second clip if necessary + if (clip2) { + GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip2Frame); + _clip2Rect.resize(clipSurface, _clip2Rect.left, _clip2Rect.top, 100); + _globals->gfxManager().copyFrom(clipSurface, bounds.left + _clip2Rect.left, + bounds.top + _clip2Rect.top); + } + + // If a clip is loaded, draw the 'loaded' portion of the gun + if (gunLoaded) { + GfxSurface loadedSurface = surfaceFromRes(9, 7, 1); + _loadedRect.resize(loadedSurface, _loadedRect.left, _loadedRect.top, 100); + _globals->gfxManager().copyFrom(loadedSurface, bounds.left + _loadedRect.left, + bounds.top + _loadedRect.top); + } +} + } // End of namespace BlueForce } // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_dialogs.h b/engines/tsage/blue_force/blueforce_dialogs.h index 1ead39a089..0fee0eb4a8 100644 --- a/engines/tsage/blue_force/blueforce_dialogs.h +++ b/engines/tsage/blue_force/blueforce_dialogs.h @@ -54,6 +54,24 @@ public: void execute(); }; +class AmmoBeltDialog : public GfxDialog { +private: + GfxSurface _surface; + Visage _cursorImages; + Rect _dialogRect, _loadedRect, _gunRect, _clip1Rect, _clip2Rect; + CursorType _cursorNum; + int _inDialog; + bool _closeFlag; +public: + AmmoBeltDialog(); + ~AmmoBeltDialog(); + + virtual void draw(); + virtual bool process(Event &event); + void execute(); +}; + + } // End of namespace BlueForce } // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 31ebab3c47..3eafac7a08 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -551,12 +551,15 @@ void SceneHandlerExt::postInit(SceneObjectList *OwnerList) { // Load the low end palette data BF_GLOBALS._scenePalette.loadPalette(2); BF_GLOBALS._scenePalette.refresh(); - - // Setup the user interface - BF_GLOBALS._uiElements.setup(Common::Point(0, BF_INTERFACE_Y - 2)); } void SceneHandlerExt::process(Event &event) { + if (BF_GLOBALS._uiElements._active) { + BF_GLOBALS._uiElements.process(event); + if (event.handled) + return; + } + SceneHandler::process(event); // TODO: All the new stuff from Blue Force @@ -701,142 +704,227 @@ SpeakerJakeNoHead::SpeakerJakeNoHead(): VisualSpeaker() { /*--------------------------------------------------------------------------*/ BlueForceInvObjectList::BlueForceInvObjectList(): - _business_card(9, 4, 2, 0), - _lauras_sweater(9, 4, 3, 0), - _handcuffs(9, 1, 4, 0), - _magnum(9, 1, 5, 0), - _ticket_book(9, 1, 6, 0), - _miranda_card(9, 1, 7, 0), - _forest_follet(9, 1, 8, 0), - _bradford_id(9, 1, 9, 0), - _baseball_card(9, 1, 10, 0), - _slip_bradford(9, 1, 11, 0), - _flare(9, 1, 12, 0), - _rap_sheet(9, 1, 13, 0), - _cartridges(9, 1, 14, 0), - _rifle(9, 1, 15, 0), - _wig(9, 1, 16, 0), - _frankies_id(9, 1, 17, 0), - _tyrones_id(9, 1, 18, 0), - _pistol22(9, 1, 19, 0), - _unused(1, 1, 1, 0), - _slip_frankie(9, 2, 1, 0), - _slip_tyrone(9, 2, 2, 0), - _atf_teletype(9, 2, 3, 0), - _da_note(9, 2, 4, 0), - _blueprints(9, 2, 5, 0), - _planter_key(9, 2, 6, 0), - _center_punch(9, 2, 7, 0), - _tranquilizer(9, 2, 8, 0), - _boat_hook(9, 2, 9, 0), - _oily_rags(9, 2, 10, 0), - _fuel_jar(9, 2, 11, 0), - _screwdriver(9, 2, 12, 0), - _floppy_disk1(9, 2, 13, 0), - _floppy_disk2(9, 2, 14, 0), - _driftwood(9, 2, 15, 0), - _crate_piece1(9, 2, 16, 0), - _crate_piece2(9, 2, 17, 0), - _shoebox(9, 2, 18, 0), - _badge(9, 2, 19, 0), - _unused2(1, 1, 1, 0), - _rental_coupons(9, 3, 1, 0), - _nickel(9, 3, 2, 0), - _calendar(9, 3, 3, 0), - _dixon_note(9, 3, 4, 0), - _cobb_mugshot(9, 3, 5, 0), - _murder_article(9, 3, 6, 0), - _microfiche(9, 3, 7, 0), - _future_wave_keys(9, 3, 8, 0), - _rental_boat_keys(9, 3, 9, 0), - _napkin(9, 3, 10, 0), - _cobb_printout(9, 3, 11, 0), - _fishing_net(9, 3, 12, 0), - _id(9, 3, 13, 0), - _rounds_9mm(9, 3, 14, 0), - _dates_note(9, 3, 15, 0), - _hand_grenade(9, 3, 16, 0), - _cord_110(9, 3, 17, 0), - _cord_110_plug(9, 3, 18, 0), - _cord_220(9, 3, 19, 0), - _unused3(1, 1, 1, 0), - _cord_220_plug(9, 4, 1, 0), - _official_document(9, 4, 2, 0), - _red_sweater(9, 4, 3, 0), - _jackknife(9, 4, 4, 0), - _whistle(9, 4, 5, 0), - _gun(9, 1, 2, 0), - _alley_cat_key(9, 4, 7, 0) { + _none(9, 5, 1), + _colt45(9, 1, 1), + _ammoClip(9, 4, 2), + _spareClip(9, 4, 3), + _handcuffs(9, 1, 4), + _greensGun(9, 1, 5), + _ticketBook(9, 1, 6), + _mirandaCard(9, 1, 7), + _forestRap(9, 1, 8), + _greenId(9, 1, 9), + _baseballCard(9, 1, 10), + _bookingGreen(9, 1, 11), + _flare(9, 1, 12), + _cobbRap(9, 1, 13), + _bullet22(9, 1, 14), + _autoRifle(9, 1, 15), + _wig(9, 1, 16), + _frankieId(9, 1, 17), + _tyroneId(9, 1, 18), + _snub22(9, 1, 19), + _bug(1, 1, 1), + _bookingFrankie(9, 2, 1), + _bookingGang(9, 2, 2), + _fbiTeletype(9, 2, 3), + _daNote(9, 2, 4), + _printOut(9, 2, 5), + _warehouseKeys(9, 2, 6), + _centerPunch(9, 2, 7), + _tranqGun(9, 2, 8), + _hook(9, 2, 9), + _rags(9, 2, 10), + _jar(9, 2, 11), + _screwdriver(9, 2, 12), + _dFloppy(9, 2, 13), + _blankDisk(9, 2, 14), + _stick(9, 2, 15), + _crate1(9, 2, 16), + _crate2(9, 2, 17), + _shoebox(9, 2, 18), + _badge(9, 2, 19), + _bug2(1, 1, 1), + _rentalCoupon(9, 3, 1), + _nickel(9, 3, 2), + _lyleCard(9, 3, 3), + _carterNote(9, 3, 4), + _mugshot(9, 3, 5), + _clipping(9, 3, 6), + _microfilm(9, 3, 7), + _waveKeys(9, 3, 8), + _rentalKeys(9, 3, 9), + _napkin(9, 3, 10), + _dmvPrintout(9, 3, 11), + _fishingNet(9, 3, 12), + _id(9, 3, 13), + _bullets9mm(9, 3, 14), + _schedule(9, 3, 15), + _grenades(9, 3, 16), + _yellowCord(9, 3, 17), + _halfYellowCord(9, 3, 18), + _blackCord(9, 3, 19), + _bug3(1, 1, 1), + _halfBlackCord(9, 4, 1), + _warrant(9, 4, 2), + _jacket(9, 4, 3), + _greensKnife(9, 4, 4), + _dogWhistle(9, 4, 5), + _ammoBelt(9, 1, 2), + _lastInvent(9, 4, 7) { // Add the items to the list - _itemList.push_back(&_business_card); - _itemList.push_back(&_lauras_sweater); + _itemList.push_back(&_none); + _itemList.push_back(&_colt45); + _itemList.push_back(&_ammoClip); + _itemList.push_back(&_spareClip); _itemList.push_back(&_handcuffs); - _itemList.push_back(&_magnum); - _itemList.push_back(&_ticket_book); - _itemList.push_back(&_miranda_card); - _itemList.push_back(&_forest_follet); - _itemList.push_back(&_bradford_id); - _itemList.push_back(&_baseball_card); - _itemList.push_back(&_slip_bradford); + _itemList.push_back(&_greensGun); + _itemList.push_back(&_ticketBook); + _itemList.push_back(&_mirandaCard); + _itemList.push_back(&_forestRap); + _itemList.push_back(&_greenId); + _itemList.push_back(&_baseballCard); + _itemList.push_back(&_bookingGreen); _itemList.push_back(&_flare); - _itemList.push_back(&_rap_sheet); - _itemList.push_back(&_cartridges); - _itemList.push_back(&_rifle); + _itemList.push_back(&_cobbRap); + _itemList.push_back(&_bullet22); + _itemList.push_back(&_autoRifle); _itemList.push_back(&_wig); - _itemList.push_back(&_frankies_id); - _itemList.push_back(&_tyrones_id); - _itemList.push_back(&_pistol22); - _itemList.push_back(&_unused); - _itemList.push_back(&_slip_frankie); - _itemList.push_back(&_slip_tyrone); - _itemList.push_back(&_atf_teletype); - _itemList.push_back(&_da_note); - _itemList.push_back(&_blueprints); - _itemList.push_back(&_planter_key); - _itemList.push_back(&_center_punch); - _itemList.push_back(&_tranquilizer); - _itemList.push_back(&_boat_hook); - _itemList.push_back(&_oily_rags); - _itemList.push_back(&_fuel_jar); + _itemList.push_back(&_frankieId); + _itemList.push_back(&_tyroneId); + _itemList.push_back(&_snub22); + _itemList.push_back(&_bug); + _itemList.push_back(&_bookingFrankie); + _itemList.push_back(&_bookingGang); + _itemList.push_back(&_fbiTeletype); + _itemList.push_back(&_daNote); + _itemList.push_back(&_printOut); + _itemList.push_back(&_warehouseKeys); + _itemList.push_back(&_centerPunch); + _itemList.push_back(&_tranqGun); + _itemList.push_back(&_hook); + _itemList.push_back(&_rags); + _itemList.push_back(&_jar); _itemList.push_back(&_screwdriver); - _itemList.push_back(&_floppy_disk1); - _itemList.push_back(&_floppy_disk2); - _itemList.push_back(&_driftwood); - _itemList.push_back(&_crate_piece1); - _itemList.push_back(&_crate_piece2); + _itemList.push_back(&_dFloppy); + _itemList.push_back(&_blankDisk); + _itemList.push_back(&_stick); + _itemList.push_back(&_crate1); + _itemList.push_back(&_crate2); _itemList.push_back(&_shoebox); _itemList.push_back(&_badge); - _itemList.push_back(&_unused2); - _itemList.push_back(&_rental_coupons); + _itemList.push_back(&_bug2); + _itemList.push_back(&_rentalCoupon); _itemList.push_back(&_nickel); - _itemList.push_back(&_calendar); - _itemList.push_back(&_dixon_note); - _itemList.push_back(&_cobb_mugshot); - _itemList.push_back(&_murder_article); - _itemList.push_back(&_microfiche); - _itemList.push_back(&_future_wave_keys); - _itemList.push_back(&_rental_boat_keys); + _itemList.push_back(&_lyleCard); + _itemList.push_back(&_carterNote); + _itemList.push_back(&_mugshot); + _itemList.push_back(&_clipping); + _itemList.push_back(&_microfilm); + _itemList.push_back(&_waveKeys); + _itemList.push_back(&_rentalKeys); _itemList.push_back(&_napkin); - _itemList.push_back(&_cobb_printout); - _itemList.push_back(&_fishing_net); + _itemList.push_back(&_dmvPrintout); + _itemList.push_back(&_fishingNet); _itemList.push_back(&_id); - _itemList.push_back(&_rounds_9mm); - _itemList.push_back(&_dates_note); - _itemList.push_back(&_hand_grenade); - _itemList.push_back(&_cord_110); - _itemList.push_back(&_cord_110_plug); - _itemList.push_back(&_cord_220); - _itemList.push_back(&_unused3); - _itemList.push_back(&_cord_220_plug); - _itemList.push_back(&_official_document); - _itemList.push_back(&_red_sweater); - _itemList.push_back(&_jackknife); - _itemList.push_back(&_whistle); - _itemList.push_back(&_gun); - _itemList.push_back(&_alley_cat_key); -} + _itemList.push_back(&_bullets9mm); + _itemList.push_back(&_schedule); + _itemList.push_back(&_grenades); + _itemList.push_back(&_yellowCord); + _itemList.push_back(&_halfYellowCord); + _itemList.push_back(&_blackCord); + _itemList.push_back(&_bug3); + _itemList.push_back(&_halfBlackCord); + _itemList.push_back(&_warrant); + _itemList.push_back(&_jacket); + _itemList.push_back(&_greensKnife); + _itemList.push_back(&_dogWhistle); + _itemList.push_back(&_ammoBelt); + _itemList.push_back(&_lastInvent); +} + +void BlueForceInvObjectList::reset() { + // Reset all object scene numbers + SynchronizedList::iterator i; + for (i = _itemList.begin(); i != _itemList.end(); ++i) { + (*i)->_sceneNumber = 0; + } + + // Set up default inventory + setObjectRoom(INV_COLT45, 1); + setObjectRoom(INV_HANDCUFFS, 1); + setObjectRoom(INV_AMMO_BELT, 1); + setObjectRoom(INV_ID, 1); + + // Set default room for other objects + setObjectRoom(INV_TICKET_BOOK, 60); + setObjectRoom(INV_MIRANDA_CARD, 60); + setObjectRoom(INV_FOREST_RAP, 320); + setObjectRoom(INV_GREEN_ID, 370); + setObjectRoom(INV_BASEBALL_CARD, 840); + setObjectRoom(INV_BOOKING_GREEN, 390); + setObjectRoom(INV_FLARE, 355); + setObjectRoom(INV_COBB_RAPP, 810); + setObjectRoom(INV_22_BULLET, 415); + setObjectRoom(INV_AUTO_RIFLE, 415); + setObjectRoom(INV_WIG, 415); + setObjectRoom(INV_FRANKIE_ID, 410); + setObjectRoom(INV_TYRONE_ID, 410); + setObjectRoom(INV_22_SNUB, 410); + setObjectRoom(INV_FBI_TELETYPE, 320); + setObjectRoom(INV_DA_NOTE, 320); + setObjectRoom(INV_PRINT_OUT, 570); + setObjectRoom(INV_WHAREHOUSE_KEYS, 360); + setObjectRoom(INV_CENTER_PUNCH, 0); + setObjectRoom(INV_TRANQ_GUN, 830); + setObjectRoom(INV_HOOK, 350); + setObjectRoom(INV_RAGS, 870); + setObjectRoom(INV_JAR, 870); + setObjectRoom(INV_SCREWDRIVER, 355); + setObjectRoom(INV_D_FLOPPY, 570); + setObjectRoom(INV_BLANK_DISK, 560); + setObjectRoom(INV_STICK, 710); + setObjectRoom(INV_CRATE1, 710); + setObjectRoom(INV_CRATE2, 870); + setObjectRoom(INV_SHOEBOX, 270); + setObjectRoom(INV_BADGE, 560); + setObjectRoom(INV_RENTAL_COUPON, 0); + setObjectRoom(INV_NICKEL, 560); + setObjectRoom(INV_LYLE_CARD, 270); + setObjectRoom(INV_CARTER_NOTE, 830); + setObjectRoom(INV_MUG_SHOT, 810); + setObjectRoom(INV_CLIPPING, 810); + setObjectRoom(INV_MICROFILM, 810); + setObjectRoom(INV_WAVE_KEYS, 840); + setObjectRoom(INV_RENTAL_KEYS, 840); + setObjectRoom(INV_NAPKIN, 115); + setObjectRoom(INV_DMV_PRINTOUT, 810); + setObjectRoom(INV_FISHING_NET, 830); + setObjectRoom(INV_9MM_BULLETS, 930); + setObjectRoom(INV_SCHEDULE, 930); + setObjectRoom(INV_GRENADES, 355); + setObjectRoom(INV_GREENS_KNIFE, 370); + setObjectRoom(INV_JACKET, 880); + setObjectRoom(INV_DOG_WHISTLE, 880); + setObjectRoom(INV_YELLOW_CORD, 910); + setObjectRoom(INV_BLACK_CORD, 910); +} + +void BlueForceInvObjectList::setObjectRoom(int objectNum, int sceneNumber) { + // Find the appropriate object + int num = objectNum; + SynchronizedList::iterator i = _itemList.begin(); + while (num-- > 0) ++i; + (*i)->_sceneNumber = sceneNumber; + + // If the item is the currently active one, default back to the use cursor + if (BF_GLOBALS._events.getCursor() == objectNum) + BF_GLOBALS._events.setCursor(CURSOR_USE); + // Update the user interface if necessary + BF_GLOBALS._uiElements.updateInventory(); +} } // End of namespace BlueForce diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index 9de7add49d..5d2c3a7955 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -217,74 +217,78 @@ public: class BlueForceInvObjectList : public InvObjectList { public: - InvObject _business_card; - InvObject _lauras_sweater; + InvObject _none; + InvObject _colt45; + InvObject _ammoClip; + InvObject _spareClip; InvObject _handcuffs; - InvObject _magnum; - InvObject _ticket_book; - InvObject _miranda_card; - InvObject _forest_follet; - InvObject _bradford_id; - InvObject _baseball_card; - InvObject _slip_bradford; + InvObject _greensGun; + InvObject _ticketBook; + InvObject _mirandaCard; + InvObject _forestRap; + InvObject _greenId; + InvObject _baseballCard; + InvObject _bookingGreen; InvObject _flare; - InvObject _rap_sheet; - InvObject _cartridges; - InvObject _rifle; + InvObject _cobbRap; + InvObject _bullet22; + InvObject _autoRifle; InvObject _wig; - InvObject _frankies_id; - InvObject _tyrones_id; - InvObject _pistol22; - InvObject _unused; - InvObject _slip_frankie; - InvObject _slip_tyrone; - InvObject _atf_teletype; - InvObject _da_note; - InvObject _blueprints; - InvObject _planter_key; - InvObject _center_punch; - InvObject _tranquilizer; - InvObject _boat_hook; - InvObject _oily_rags; - InvObject _fuel_jar; + InvObject _frankieId; + InvObject _tyroneId; + InvObject _snub22; + InvObject _bug; + InvObject _bookingFrankie; + InvObject _bookingGang; + InvObject _fbiTeletype; + InvObject _daNote; + InvObject _printOut; + InvObject _warehouseKeys; + InvObject _centerPunch; + InvObject _tranqGun; + InvObject _hook; + InvObject _rags; + InvObject _jar; InvObject _screwdriver; - InvObject _floppy_disk1; - InvObject _floppy_disk2; - InvObject _driftwood; - InvObject _crate_piece1; - InvObject _crate_piece2; + InvObject _dFloppy; + InvObject _blankDisk; + InvObject _stick; + InvObject _crate1; + InvObject _crate2; InvObject _shoebox; InvObject _badge; - InvObject _unused2; - InvObject _rental_coupons; + InvObject _bug2; + InvObject _rentalCoupon; InvObject _nickel; - InvObject _calendar; - InvObject _dixon_note; - InvObject _cobb_mugshot; - InvObject _murder_article; - InvObject _microfiche; - InvObject _future_wave_keys; - InvObject _rental_boat_keys; + InvObject _lyleCard; + InvObject _carterNote; + InvObject _mugshot; + InvObject _clipping; + InvObject _microfilm; + InvObject _waveKeys; + InvObject _rentalKeys; InvObject _napkin; - InvObject _cobb_printout; - InvObject _fishing_net; + InvObject _dmvPrintout; + InvObject _fishingNet; InvObject _id; - InvObject _rounds_9mm; - InvObject _dates_note; - InvObject _hand_grenade; - InvObject _cord_110; - InvObject _cord_110_plug; - InvObject _cord_220; - InvObject _unused3; - InvObject _cord_220_plug; - InvObject _official_document; - InvObject _red_sweater; - InvObject _jackknife; - InvObject _whistle; - InvObject _gun; - InvObject _alley_cat_key; + InvObject _bullets9mm; + InvObject _schedule; + InvObject _grenades; + InvObject _yellowCord; + InvObject _halfYellowCord; + InvObject _blackCord; + InvObject _bug3; + InvObject _halfBlackCord; + InvObject _warrant; + InvObject _jacket; + InvObject _greensKnife; + InvObject _dogWhistle; + InvObject _ammoBelt; + InvObject _lastInvent; BlueForceInvObjectList(); + void reset(); + void setObjectRoom(int objectNum, int sceneNumber); virtual Common::String getClassName() { return "BlueForceInvObjectList"; } }; diff --git a/engines/tsage/blue_force/blueforce_ui.cpp b/engines/tsage/blue_force/blueforce_ui.cpp index 56c13572cc..42605b4c5f 100644 --- a/engines/tsage/blue_force/blueforce_ui.cpp +++ b/engines/tsage/blue_force/blueforce_ui.cpp @@ -21,6 +21,7 @@ */ #include "tsage/blue_force/blueforce_ui.h" +#include "tsage/blue_force/blueforce_dialogs.h" #include "tsage/blue_force/blueforce_logic.h" #include "tsage/tsage.h" #include "tsage/core.h" @@ -112,26 +113,35 @@ void UIScore::updateScore() { UIInventorySlot::UIInventorySlot(): UIElement() { _objIndex = 0; + _object = NULL; } void UIInventorySlot::synchronize(Serializer &s) { UIElement::synchronize(s); s.syncAsSint16LE(_objIndex); + SYNC_POINTER(_object); } void UIInventorySlot::process(Event &event) { if (event.eventType == EVENT_BUTTON_DOWN) { event.handled = true; - if (_objIndex == 66) { - // Handle showing gun and ammo - warning("TODO: show gun"); - } else if (_objIndex != 0) { - GLOBALS._events.setCursor((CursorType)_objIndex); + if (_objIndex == INV_AMMO_BELT) { + // Handle showing ammo belt + showAmmoBelt(); + + } else if (_objIndex != INV_NONE) { + _object->setCursor(); } } } +void UIInventorySlot::showAmmoBelt() { + AmmoBeltDialog *dlg = new AmmoBeltDialog(); + dlg->execute(); + delete dlg; +} + /*--------------------------------------------------------------------------*/ UIInventoryScroll::UIInventoryScroll() { @@ -155,7 +165,7 @@ void UIInventoryScroll::process(Event &event) { UICollection::UICollection(): EventHandler() { _clearScreen = false; _visible = false; - _field4E = 0; + _cursorChanged = false; } void UICollection::setup(const Common::Point &pt) { @@ -200,18 +210,46 @@ void UICollection::draw() { /*--------------------------------------------------------------------------*/ +UIElements::UIElements(): UICollection() { + _cursorVisage.setVisage(1, 5); +} + void UIElements::process(Event &event) { if (_clearScreen && BF_GLOBALS._player._enabled && (BF_GLOBALS._sceneManager._sceneNumber != 50)) { if (_bounds.contains(event.mousePos)) { + // Cursor inside UI area + if (!_cursorChanged) { + if (BF_GLOBALS._events.isInventoryIcon()) { + // Inventory icon being displayed, so leave alone + } else { + // Change to the inventory use cursor + GfxSurface surface = _cursorVisage.getFrame(6); + BF_GLOBALS._events.setCursor(surface); + } + _cursorChanged = true; + } + + // Pass event to any element that the cursor falls on + for (int idx = (int)_objList.size() - 1; idx >= 0; --idx) { + if (_objList[idx]->_bounds.contains(event.mousePos) && _objList[idx]->_enabled) { + _objList[idx]->process(event); + if (event.handled) + break; + } + } + + if (event.eventType == EVENT_BUTTON_DOWN) + event.handled = true; - } else if (_field4E) { - BF_GLOBALS._events.hideCursor(); - BF_GLOBALS._events.setCursor((CursorType)1); - _field4E = 0; + } else if (_cursorChanged) { + // Cursor outside UI area, so reset as necessary + BF_GLOBALS._events.setCursor(BF_GLOBALS._events.getCursor()); + _cursorChanged = false; SceneExt *scene = (SceneExt *)BF_GLOBALS._sceneManager._scene; if (scene->_eventHandler) { - error("TODO: UIElements::process _eventHandler"); + GfxSurface surface = _cursorVisage.getFrame(7); + BF_GLOBALS._events.setCursor(surface); } } } @@ -313,12 +351,14 @@ void UIElements::updateInventory() { // Handle refreshing slot graphics UIInventorySlot *slotList[4] = { &_slot1, &_slot2, &_slot3, &_slot4 }; - + + // Loop through the inventory objects SynchronizedList::iterator i; int objIndex = 0; for (i = BLUE_INVENTORY._itemList.begin(); i != BLUE_INVENTORY._itemList.end(); ++i, ++objIndex) { InvObject *obj = *i; + // Check whether the object is in any of the four inventory slots for (int slotIndex = 0; slotIndex < 4; ++slotIndex) { int idx = _slotStart + slotIndex; int objectIdx = (idx < (int)_itemList.size()) ? _itemList[idx] : 0; @@ -327,6 +367,7 @@ void UIElements::updateInventory() { UIInventorySlot *slot = slotList[slotIndex]; slot->_objIndex = objIndex; + slot->_object = obj; slot->setVisage(obj->_visage); slot->setStrip(obj->_strip); slot->setFrame(obj->_frame); @@ -334,6 +375,7 @@ void UIElements::updateInventory() { } } + // Refresh the display if necessary if (_active) draw(); } @@ -354,21 +396,6 @@ void UIElements::updateInvList() { } } -/** - * Updates an inventory slot with the item to be displayed - -void UIElements::updateInvSlot(UIInventorySlot *slot, int objIndex) { - slot->_objIndex = objIndex; - int itemId = (objIndex < (int)_itemList.size()) ? _itemList[objIndex] : 0; - InvObject *obj = BF_GLOBALS._inventory->_itemList[itemId + 2]; - - // TODO: Validate usage of fields - slot->setVisage(obj._displayResNum); - slot->setStrip(obj._rlbNum); - slot->setFrame(obj._cursorNum); -} -*/ - } // End of namespace BlueForce } // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_ui.h b/engines/tsage/blue_force/blueforce_ui.h index 809701f83e..766f7dd6e5 100644 --- a/engines/tsage/blue_force/blueforce_ui.h +++ b/engines/tsage/blue_force/blueforce_ui.h @@ -69,8 +69,11 @@ public: }; class UIInventorySlot: public UIElement { +private: + void showAmmoBelt(); public: int _objIndex; + InvObject *_object; UIInventorySlot(); virtual Common::String getClassName() { return "UIInventorySlot"; } @@ -96,7 +99,7 @@ public: Rect _bounds; bool _visible; bool _clearScreen; - int _field4E; + bool _cursorChanged; Common::Array _objList; UICollection(); @@ -110,7 +113,6 @@ public: class UIElements: public UICollection { private: void add(UIElement *obj); - void updateInventory(); void updateInvList(); public: UIElement _object1; @@ -122,11 +124,14 @@ public: int _itemCount, _slotStart, _scoreValue; bool _active; Common::Array _itemList; + Visage _cursorVisage; + UIElements(); virtual void postInit(SceneObjectList *OwnerList = NULL) { error("Wrong init() called"); } virtual void process(Event &event); void setup(const Common::Point &pt); + void updateInventory(); }; } // End of namespace BlueForce diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 10d2663fe0..4dc4c72fc8 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -55,21 +55,30 @@ InvObject::InvObject(int sceneNumber, int rlbNum, int cursorNum, CursorType curs DEALLOCATE(imgData); } -InvObject::InvObject(int visage, int strip, int frame, int sceneNumber) { +InvObject::InvObject(int visage, int strip, int frame) { + assert(_vm->getGameID() == GType_BlueForce); _visage = visage; _strip = strip; _frame = frame; - _sceneNumber = sceneNumber; + _sceneNumber = 0; + _iconResNum = 10; } void InvObject::setCursor() { - _globals->_events._currentCursor = _cursorId; + if (_vm->getGameID() == GType_BlueForce) { + // Blue Force cursor handling + _cursorId = (CursorType)BF_GLOBALS._inventory->indexOf(this); + _globals->_events.setCursor(_cursorId); + } else { + // Ringworld cursor handling + _globals->_events._currentCursor = _cursorId; - if (_iconResNum != -1) { - GfxSurface s = surfaceFromRes(_iconResNum, _rlbNum, _cursorNum); + if (_iconResNum != -1) { + GfxSurface s = surfaceFromRes(_iconResNum, _rlbNum, _cursorNum); - Graphics::Surface src = s.lockSurface(); - _globals->_events.setCursor(src, s._transColor, s._centroid, _cursorId); + Graphics::Surface src = s.lockSurface(); + _globals->_events.setCursor(src, s._transColor, s._centroid, _cursorId); + } } } @@ -84,6 +93,18 @@ void InvObjectList::synchronize(Serializer &s) { SYNC_POINTER(_selectedItem); } +int InvObjectList::indexOf(InvObject *obj) const { + int idx = 0; + SynchronizedList::const_iterator i; + + for (i = _itemList.begin(); i != _itemList.end(); ++i, ++idx) { + if ((*i) == obj) + return idx; + } + + return -1; +} + /*--------------------------------------------------------------------------*/ void EventHandler::dispatch() { diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 13761cec79..ede1bfc1af 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -61,7 +61,7 @@ public: int _frame; public: InvObject(int sceneNumber, int rlbNum, int cursorNum, CursorType cursorId, const Common::String description); - InvObject(int visage, int strip, int frame, int sceneNumber); + InvObject(int visage, int strip, int frame); bool inInventory() const { return _sceneNumber == 1; } void setCursor(); @@ -78,6 +78,7 @@ public: InvObject *_selectedItem; InvObjectList(); + int indexOf(InvObject *obj) const; virtual Common::String getClassName() { return "InvObjectList"; } virtual void synchronize(Serializer &s); diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp index 6bda6c9af8..00c200eeea 100644 --- a/engines/tsage/events.cpp +++ b/engines/tsage/events.cpp @@ -149,6 +149,7 @@ void EventsClass::setCursor(CursorType cursorType) { const byte *cursor; bool delFlag = true; uint size; + bool questionEnabled = false; switch (cursorType) { case CURSOR_NONE: @@ -191,6 +192,13 @@ void EventsClass::setCursor(CursorType cursorType) { _currentCursor = CURSOR_TALK; break; + case CURSOR_EXIT: + // Exit cursor (Blue Force) + assert(_vm->getGameID() == GType_BlueForce); + cursor = _resourceManager->getSubResource(1, 5, 7, &size); + _currentCursor = CURSOR_TALK; + break; + case CURSOR_ARROW: // Arrow cursor cursor = CURSOR_ARROW_DATA; @@ -199,14 +207,22 @@ void EventsClass::setCursor(CursorType cursorType) { case CURSOR_WALK: default: - // Walk cursor if (_vm->getGameID() == GType_BlueForce) { - cursor = _resourceManager->getSubResource(1, 5, 1, &size); + if (cursorType == CURSOR_WALK) { + cursor = _resourceManager->getSubResource(1, 5, 1, &size); + } else { + // Inventory icon + cursor = _resourceManager->getSubResource(10, ((int)cursorType - 1) / 20 + 1, + ((int)cursorType - 1) % 20 + 1, &size); + questionEnabled = true; + } + _currentCursor = cursorType; } else { + // For Ringworld, always treat as the walk cursor cursor = CURSOR_WALK_DATA; + _currentCursor = CURSOR_WALK; delFlag = false; } - _currentCursor = CURSOR_WALK; break; } @@ -220,6 +236,10 @@ void EventsClass::setCursor(CursorType cursorType) { if (delFlag) DEALLOCATE(cursor); + + // For Blue Force, enable the question button when an inventory icon is selected + if (_vm->getGameID() == GType_BlueForce) + BF_GLOBALS._uiElements._question.setEnabled(questionEnabled); } void EventsClass::pushCursor(CursorType cursorType) { diff --git a/engines/tsage/events.h b/engines/tsage/events.h index db1941082d..d23e9db9c6 100644 --- a/engines/tsage/events.h +++ b/engines/tsage/events.h @@ -54,6 +54,7 @@ public: }; enum CursorType { + // Ringworld objects OBJECT_STUNNER = 0, OBJECT_SCANNER = 1, OBJECT_STASIS_BOX = 2, OBJECT_INFODISK = 3, OBJECT_STASIS_NEGATOR = 4, OBJECT_KEY_DEVICE = 5, OBJECT_MEDKIT = 6, OBJECT_LADDER = 7, OBJECT_ROPE = 8, OBJECT_KEY = 9, OBJECT_TRANSLATOR = 10, OBJECT_ALE = 11, @@ -63,7 +64,26 @@ enum CursorType { OBJECT_NULLIFIER = 25, OBJECT_PEG = 26, OBJECT_VIAL = 27, OBJECT_JACKET = 28, OBJECT_TUNIC2 = 29, OBJECT_BONE = 30, OBJECT_EMPTY_JAR = 31, OBJECT_JAR = 32, + // Blue Force objects + INV_NONE = 0, INV_COLT45 = 1, INV_AMMO_CLIP = 2, INV_SPARE_CLIP = 3, INV_HANDCUFFS = 4, + INV_GREENS_GUN = 5, INV_TICKET_BOOK = 6, INV_MIRANDA_CARD = 7, INV_FOREST_RAP = 8, + INV_GREEN_ID = 9, INV_BASEBALL_CARD = 10, INV_BOOKING_GREEN = 11, INV_FLARE = 12, + INV_COBB_RAPP = 13, INV_22_BULLET = 14, INV_AUTO_RIFLE = 15, INV_WIG = 16, INV_FRANKIE_ID = 17, + INV_TYRONE_ID = 18, INV_22_SNUB = 19, INV_BOOKING_FRANKIE = 21, INV_BOOKING_GANG = 22, + INV_FBI_TELETYPE = 23, INV_DA_NOTE = 24, INV_PRINT_OUT = 25, INV_WHAREHOUSE_KEYS = 26, + INV_CENTER_PUNCH = 27, INV_TRANQ_GUN = 28, INV_HOOK = 29, INV_RAGS = 30, INV_JAR = 31, + INV_SCREWDRIVER = 32, INV_D_FLOPPY = 33, INV_BLANK_DISK = 34, INV_STICK = 35, + INV_CRATE1 = 36, INV_CRATE2 = 37, INV_SHOEBOX = 38, INV_BADGE = 39, INV_RENTAL_COUPON = 41, + INV_NICKEL = 42, INV_LYLE_CARD = 43, INV_CARTER_NOTE = 44, INV_MUG_SHOT = 45, + INV_CLIPPING = 46, INV_MICROFILM = 47, INV_WAVE_KEYS = 48, INV_RENTAL_KEYS = 49, + INV_NAPKIN = 50, INV_DMV_PRINTOUT = 51, INV_FISHING_NET = 52, INV_ID = 53, + INV_9MM_BULLETS = 54, INV_SCHEDULE = 55, INV_GRENADES = 56, INV_YELLOW_CORD = 57, + INV_HALF_YELLOW_CORD = 58, INV_BLACK_CORD = 59, INV_HALF_BLACK_CORD = 61, INV_WARRANT = 62, + INV_JACKET = 63, INV_GREENS_KNIFE = 64, INV_DOG_WHISTLE = 65, INV_AMMO_BELT = 66, + + // Cursors CURSOR_WALK = 0x100, CURSOR_LOOK = 0x200, CURSOR_700 = 700, CURSOR_USE = 0x400, CURSOR_TALK = 0x800, + CURSOR_1000 = 0x1000, CURSOR_EXIT = 0x7004, CURSOR_NONE = -1, CURSOR_CROSSHAIRS = -2, CURSOR_ARROW = -3 }; @@ -101,6 +121,7 @@ public: Common::EventType type() { return _event.type; } uint32 getFrameNumber() const { return _frameNumber; } void delay(int numFrames); + bool isInventoryIcon() const { return _currentCursor < 256; } virtual void listenerSynchronize(Serializer &s); static void loadNotifierProc(bool postFlag); diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index ebad77abc4..9d48fa508d 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -184,26 +184,42 @@ void Globals::dispatchSounds() { namespace BlueForce { BlueForceGlobals::BlueForceGlobals(): Globals() { +} + +void BlueForceGlobals::synchronize(Serializer &s) { + Globals::synchronize(s); + error("Sync variables"); +} + +void BlueForceGlobals::reset() { + Globals::reset(); + _scenePalette.clearListeners(); + + _scrollFollower = &_player; + _bookmark = bNone; + + // Reset the inventory + ((BlueForceInvObjectList *)_inventory)->reset(); + BF_GLOBALS._uiElements.updateInventory(); + BF_GLOBALS._uiElements._scoreValue = 0; + + _mapLocationId = 1; + _driveFromScene = 300; + _driveToScene = 0; + _interfaceY = 0; _v51C44 = 1; - _dayNumber = 1; + _dayNumber = 0; _v4CEA4 = 0; _v4CEA8 = 0; _v4CEB8 = 0; _v4CEBA = 0; - _driveFromScene = 0; - _driveToScene = 0; _v4CF9E = 0; _v4E238 = 0; _v501FC = 0; _v51C42 = 0; - _bookmark = bNone; - _mapLocationId = 1; -} - -void BlueForceGlobals::synchronize(Serializer &s) { - Globals::synchronize(s); - error("Sync variables"); + _clip1Frame = 8; + _clip2Frame = 8; } } // end of namespace BlueForce diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index dda95a9ef7..c8eb21a927 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -181,8 +181,11 @@ public: int _interfaceY; Bookmark _bookmark; int _mapLocationId; + int _clip1Frame, _clip2Frame; BlueForceGlobals(); + void reset(); + virtual Common::String getClassName() { return "BFGlobals"; } virtual void synchronize(Serializer &s); }; diff --git a/engines/tsage/tsage.cpp b/engines/tsage/tsage.cpp index 2fcabff16c..ca63c4c3e0 100644 --- a/engines/tsage/tsage.cpp +++ b/engines/tsage/tsage.cpp @@ -82,6 +82,12 @@ void TSageEngine::initialize() { _resourceManager->addLib("TSAGE.RLB"); } _globals = new BlueForce::BlueForceGlobals(); + + // Setup the user interface + BF_GLOBALS._uiElements.setup(Common::Point(0, BF_INTERFACE_Y - 2)); + + // Reset all global variables + BF_GLOBALS.reset(); } _globals->gfxManager().setDefaults(); -- cgit v1.2.3 From 8f9af262928242eebf10f5a51b9f461e7d47d610 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 4 Sep 2011 21:09:22 +1000 Subject: TSAGE: Added missing default item response code logic in Blue Force --- engines/tsage/blue_force/blueforce_dialogs.cpp | 4 +- engines/tsage/blue_force/blueforce_logic.cpp | 51 ++++++++++++++++++++++---- engines/tsage/blue_force/blueforce_logic.h | 3 ++ engines/tsage/events.h | 1 + engines/tsage/globals.cpp | 12 ++++-- engines/tsage/globals.h | 5 +-- 6 files changed, 60 insertions(+), 16 deletions(-) diff --git a/engines/tsage/blue_force/blueforce_dialogs.cpp b/engines/tsage/blue_force/blueforce_dialogs.cpp index be72b78622..f71d3d7393 100644 --- a/engines/tsage/blue_force/blueforce_dialogs.cpp +++ b/engines/tsage/blue_force/blueforce_dialogs.cpp @@ -342,7 +342,7 @@ void AmmoBeltDialog::draw() { // Draw the first clip if necessary if (clip1) { - GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip1Frame); + GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip1Bullets); _clip1Rect.resize(clipSurface, _clip1Rect.left, _clip1Rect.top, 100); _globals->gfxManager().copyFrom(clipSurface, bounds.left + _clip1Rect.left, bounds.top + _clip1Rect.top); @@ -350,7 +350,7 @@ void AmmoBeltDialog::draw() { // Draw the second clip if necessary if (clip2) { - GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip2Frame); + GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip2Bullets); _clip2Rect.resize(clipSurface, _clip2Rect.left, _clip2Rect.top, 100); _globals->gfxManager().copyFrom(clipSurface, bounds.left + _clip2Rect.left, bounds.top + _clip2Rect.top); diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 3eafac7a08..41d16ad998 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -340,10 +340,9 @@ void NamedObject::startAction(CursorType action) { handled = false; break; } -/* + if (!handled) ((SceneExt *)BF_GLOBALS._sceneManager._scene)->display(action); -*/ } void NamedObject::setup(int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { @@ -501,20 +500,58 @@ void SceneExt::loadScene(int sceneNum) { } void SceneExt::checkGun() { - if (BF_GLOBALS.getFlag(fLoadedSpare) && (BF_GLOBALS._v4CEBA > 0)) { - if (--BF_GLOBALS._v4CEBA == 0) + // Remove a bullet from the currently loaded clip + if (BF_GLOBALS.getFlag(fLoadedSpare) && (BF_GLOBALS._clip2Bullets > 0)) { + if (--BF_GLOBALS._clip2Bullets == 0) BF_GLOBALS.clearFlag(fGunLoaded); } else { - if (BF_GLOBALS._v4CEB8 > 0) - --BF_GLOBALS._v4CEB8; + if (BF_GLOBALS._clip1Bullets > 0) + --BF_GLOBALS._clip1Bullets; - if (!BF_GLOBALS._v4CEB8) + if (!BF_GLOBALS._clip1Bullets) BF_GLOBALS.clearFlag(fGunLoaded); } BF_GLOBALS._sound3.play(4); } +void SceneExt::display(CursorType action) { + switch (action) { + case CURSOR_LOOK: + SceneItem::display2(9000, BF_GLOBALS._randomSource.getRandomNumber(2)); + break; + case CURSOR_USE: + SceneItem::display2(9000, BF_GLOBALS._randomSource.getRandomNumber(2) + 6); + break; + case CURSOR_TALK: + SceneItem::display2(9000, BF_GLOBALS._randomSource.getRandomNumber(2) + 3); + break; + case INV_COLT45: + gunDisplay(); + break; + default: + if (action < BF_LAST_INVENT) + SceneItem::display2(9002, (int)action); + break; + } +} + +void SceneExt::gunDisplay() { + if (!BF_GLOBALS.getFlag(gunDrawn)) { + // Gun not drawn + SceneItem::display2(1, BF_GLOBALS.getFlag(fCanDrawGun) ? 0 : 4); + } else if (!BF_GLOBALS.getFlag(fGunLoaded)) { + // Gun not loaded + SceneItem::display2(1, 1); + } else if (!BF_GLOBALS.getHasBullets()) { + // Out of ammunition + SceneItem::display2(1, 2); + } else { + // Check scene for whether gun can fire + checkGun(); + } +} + /*--------------------------------------------------------------------------*/ GameScene::GameScene() { diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index 5d2c3a7955..ddc32d488f 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -137,6 +137,8 @@ public: }; class SceneExt: public Scene { +private: + void gunDisplay(); public: AObjectArray _timerList, _objArray2; int _field372; @@ -156,6 +158,7 @@ public: void addTimer(Timer *timer) { _timerList.add(timer); } void removeTimer(Timer *timer) { _timerList.remove(timer); } + void display(CursorType action); }; class GameScene: public SceneExt { diff --git a/engines/tsage/events.h b/engines/tsage/events.h index d23e9db9c6..ee77c6ff86 100644 --- a/engines/tsage/events.h +++ b/engines/tsage/events.h @@ -80,6 +80,7 @@ enum CursorType { INV_9MM_BULLETS = 54, INV_SCHEDULE = 55, INV_GRENADES = 56, INV_YELLOW_CORD = 57, INV_HALF_YELLOW_CORD = 58, INV_BLACK_CORD = 59, INV_HALF_BLACK_CORD = 61, INV_WARRANT = 62, INV_JACKET = 63, INV_GREENS_KNIFE = 64, INV_DOG_WHISTLE = 65, INV_AMMO_BELT = 66, + BF_LAST_INVENT = 67, // Cursors CURSOR_WALK = 0x100, CURSOR_LOOK = 0x200, CURSOR_700 = 700, CURSOR_USE = 0x400, CURSOR_TALK = 0x800, diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index 9d48fa508d..086720dd50 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -212,14 +212,18 @@ void BlueForceGlobals::reset() { _dayNumber = 0; _v4CEA4 = 0; _v4CEA8 = 0; - _v4CEB8 = 0; - _v4CEBA = 0; _v4CF9E = 0; _v4E238 = 0; _v501FC = 0; _v51C42 = 0; - _clip1Frame = 8; - _clip2Frame = 8; + _clip1Bullets = 8; + _clip2Bullets = 8; +} + +bool BlueForceGlobals::getHasBullets() { + if (!getFlag(fGunLoaded)) + return false; + return BF_GLOBALS.getFlag(fLoadedSpare) ? (_clip2Bullets > 0) : (_clip1Bullets > 0); } } // end of namespace BlueForce diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index c8eb21a927..314822546e 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -169,8 +169,6 @@ public: int _dayNumber; int _v4CEA4; int _v4CEA8; - int _v4CEB8; - int _v4CEBA; int _driveFromScene; int _driveToScene; int _v4CF9E; @@ -181,10 +179,11 @@ public: int _interfaceY; Bookmark _bookmark; int _mapLocationId; - int _clip1Frame, _clip2Frame; + int _clip1Bullets, _clip2Bullets; BlueForceGlobals(); void reset(); + bool getHasBullets(); virtual Common::String getClassName() { return "BFGlobals"; } virtual void synchronize(Serializer &s); -- cgit v1.2.3 From cb410d5837571fad42faea0c625c8479e4d9b876 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 4 Sep 2011 21:17:20 +1000 Subject: TSAGE: Fixed Options dialog Sound button not showing sound dialog --- engines/tsage/dialogs.cpp | 10 ++++++++++ engines/tsage/dialogs.h | 7 +++++++ engines/tsage/ringworld/ringworld_logic.cpp | 9 ++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/engines/tsage/dialogs.cpp b/engines/tsage/dialogs.cpp index d5e7b1514d..841a7b776d 100644 --- a/engines/tsage/dialogs.cpp +++ b/engines/tsage/dialogs.cpp @@ -367,6 +367,7 @@ void OptionsDialog::show() { _globals->_game->restartGame(); } else if (btn == &dlg->_btnSound) { // Sound dialog + SoundDialog::execute(); } else if (btn == &dlg->_btnSave) { // Save button _globals->_game->saveGame(); @@ -414,5 +415,14 @@ OptionsDialog::OptionsDialog() { setCenter(160, 100); } +/*--------------------------------------------------------------------------*/ + +void SoundDialog::execute() { + ConfigDialog *dlg = new ConfigDialog(); + dlg->runModal(); + delete dlg; + _globals->_soundManager.syncSounds(); + _globals->_events.setCursorFromFlag(); +} } // End of namespace TsAGE diff --git a/engines/tsage/dialogs.h b/engines/tsage/dialogs.h index 7355ea1cf9..35ed60ba1a 100644 --- a/engines/tsage/dialogs.h +++ b/engines/tsage/dialogs.h @@ -99,6 +99,13 @@ public: static void show(); }; +/*--------------------------------------------------------------------------*/ + +class SoundDialog { +public: + static void execute(); +}; + } // End of namespace TsAGE #endif diff --git a/engines/tsage/ringworld/ringworld_logic.cpp b/engines/tsage/ringworld/ringworld_logic.cpp index 366076d7aa..72c56973d9 100644 --- a/engines/tsage/ringworld/ringworld_logic.cpp +++ b/engines/tsage/ringworld/ringworld_logic.cpp @@ -1449,15 +1449,10 @@ void RingworldGame::processEvent(Event &event) { MessageDialog::show(HELP_MSG, OK_BTN_STRING); break; - case Common::KEYCODE_F2: { + case Common::KEYCODE_F2: // F2 - Sound Options - ConfigDialog *dlg = new ConfigDialog(); - dlg->runModal(); - delete dlg; - _globals->_soundManager.syncSounds(); - _globals->_events.setCursorFromFlag(); + SoundDialog::execute(); break; - } case Common::KEYCODE_F3: // F3 - Quit -- cgit v1.2.3 From 7eed29c1a0e02f31d615e5f3780705e43ee4922d Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 01:49:14 +0200 Subject: DREAMWEB: 'isitdescribed' ported to C++ --- engines/dreamweb/dreamgen.cpp | 24 ------------------------ engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 11 +++++++++++ engines/dreamweb/stubs.h | 3 ++- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 11d2a5117d..7309b4f75a 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -14836,29 +14836,6 @@ notasetid: goto identifyset; } -void DreamGenContext::isitdescribed() { - STACK_CHECK; - push(ax); - push(cx); - push(es); - push(bx); - al = es.byte(bx+4); - ah = 0; - _add(ax, ax); - bx = ax; - es = data.word(kSetdesc); - _add(bx, (0)); - ax = es.word(bx); - _add(ax, (0+(130*2))); - bx = ax; - dl = es.byte(bx); - bx = pop(); - es = pop(); - cx = pop(); - ax = pop(); - _cmp(dl, 0); -} - void DreamGenContext::findpathofpoint() { STACK_CHECK; push(ax); @@ -17915,7 +17892,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_madmanrun: madmanrun(); break; case addr_identifyob: identifyob(); break; case addr_checkifset: checkifset(); break; - case addr_isitdescribed: isitdescribed(); break; case addr_findpathofpoint: findpathofpoint(); break; case addr_findfirstpath: findfirstpath(); break; case addr_checkifpathison: checkifpathison(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 6a991878cd..4e5505c1ee 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -113,7 +113,6 @@ public: static const uint16 addr_checkifpathison = 0xca04; static const uint16 addr_findfirstpath = 0xc9f0; static const uint16 addr_findpathofpoint = 0xc9ec; - static const uint16 addr_isitdescribed = 0xc9e8; static const uint16 addr_checkifset = 0xc9dc; static const uint16 addr_identifyob = 0xc9d4; static const uint16 addr_madmanrun = 0xc9cc; @@ -1463,7 +1462,7 @@ public: void candles1(); void lookininterface(); void manasleep(); - void isitdescribed(); + //void isitdescribed(); void hotelbell(); void loadspeech(); void interupttest(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 9e98fd068e..5b42e37079 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1737,6 +1737,17 @@ bool DreamGenContext::compare(uint8 index, uint8 flag, const char id[4]) { return true; } +void DreamGenContext::isitdescribed() { + ObjPos *pos = (ObjPos *)es.ptr(bx, sizeof(ObjPos)); + flags._z = !isitdescribed(pos); +} + +bool DreamGenContext::isitdescribed(ObjPos *pos) { + uint16 offset = segRef(data.word(kSetdesc)).word(kSettextdat + pos->index * 2); + uint8 result = segRef(data.word(kSetdesc)).byte(kSettext + offset); + return result != 0; +} + bool DreamGenContext::isCD() { // The original sources has two codepaths depending if the game is 'if cd' or not // This is a hack to guess which version to use with the assumption that if we have a cd version diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 15ff2ee62c..6cb96e9c0f 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -218,5 +218,6 @@ bool compare(uint8 index, uint8 flag, const char id[4]); void pixelcheckset(); bool pixelcheckset(ObjPos *pos, uint8 x, uint8 y); - + void isitdescribed(); + bool isitdescribed(ObjPos *objPos); -- cgit v1.2.3 From 7b71e9842ee11e5f35256083f3dff63bede0a296 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 5 Sep 2011 12:14:17 +0200 Subject: SCI: Fix Island of Dr. Brain copyprot pause menu on touch devices Patch from m_kiewitz. --- engines/sci/graphics/cursor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index 18ff1fd0b9..57c65aa6e0 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -227,6 +227,7 @@ void GfxCursor::kernelSetView(GuiResourceId viewNum, int loopNum, int celNum, Co // Game, newPosition, validRect static const SciCursorSetPositionWorkarounds setPositionWorkarounds[] = { { GID_ISLANDBRAIN, 84, 109, 46, 76, 174, 243 }, // island of dr. brain / game menu + { GID_ISLANDBRAIN,143, 135, 57, 102, 163, 218 },// island of dr. brain / pause menu within copy protection { GID_LSL5, 23, 171, 0, 0, 26, 320 }, // larry 5 / skip forward helper { GID_QFG1VGA, 64, 174, 40, 37, 74, 284 }, // Quest For Glory 1 VGA / run/walk/sleep sub-menu { GID_QFG3, 70, 170, 40, 61, 81, 258 }, // Quest For Glory 3 / run/walk/sleep sub-menu -- cgit v1.2.3 From 483fae0c564973ff27878133749c51fc8111304f Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 03:55:52 +0200 Subject: DREAMWEB: 'checkifset' ported to C++ --- devtools/tasmrecover/tasm-recover | 2 ++ engines/dreamweb/dreamgen.cpp | 42 --------------------------------------- engines/dreamweb/dreamgen.h | 5 ++--- engines/dreamweb/stubs.cpp | 33 ++++++++++++++++++++++++++++-- engines/dreamweb/stubs.h | 6 ++++-- engines/dreamweb/vgagrafx.cpp | 4 ++-- 6 files changed, 41 insertions(+), 51 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index b87d80c98b..7967acc87c 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -180,6 +180,8 @@ generator = cpp(context, "DreamGen", blacklist = [ 'turnpathoff', 'turnanypathon', 'turnanypathoff', + 'isitdescribed', + 'checkifset', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 7309b4f75a..d59ff61a94 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -14795,47 +14795,6 @@ nothingund: blank(); } -void DreamGenContext::checkifset() { - STACK_CHECK; - es = data.word(kBuffers); - bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32))+(127*5); - cx = 127; -identifyset: - _cmp(es.byte(bx+4), 255); - if (flags.z()) - goto notasetid; - _cmp(al, es.byte(bx)); - if (flags.c()) - goto notasetid; - _cmp(al, es.byte(bx+2)); - if (!flags.c()) - goto notasetid; - _cmp(ah, es.byte(bx+1)); - if (flags.c()) - goto notasetid; - _cmp(ah, es.byte(bx+3)); - if (!flags.c()) - goto notasetid; - pixelcheckset(); - if (flags.z()) - goto notasetid; - isitdescribed(); - if (flags.z()) - goto notasetid; - al = es.byte(bx+4); - ah = 1; - obname(); - al = 0; - _cmp(al, 1); - return; -notasetid: - _sub(bx, 5); - _dec(cx); - _cmp(cx, -1); - if (!flags.z()) - goto identifyset; -} - void DreamGenContext::findpathofpoint() { STACK_CHECK; push(ax); @@ -17891,7 +17850,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_mainscreen: mainscreen(); break; case addr_madmanrun: madmanrun(); break; case addr_identifyob: identifyob(); break; - case addr_checkifset: checkifset(); break; case addr_findpathofpoint: findpathofpoint(); break; case addr_findfirstpath: findfirstpath(); break; case addr_checkifpathison: checkifpathison(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 4e5505c1ee..a27665bf37 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -113,7 +113,6 @@ public: static const uint16 addr_checkifpathison = 0xca04; static const uint16 addr_findfirstpath = 0xc9f0; static const uint16 addr_findpathofpoint = 0xc9ec; - static const uint16 addr_checkifset = 0xc9dc; static const uint16 addr_identifyob = 0xc9d4; static const uint16 addr_madmanrun = 0xc9cc; static const uint16 addr_mainscreen = 0xc9c8; @@ -1440,7 +1439,6 @@ public: void selectslot2(); void runtap(); //void domix(); - void priesttext(); //void paneltomap(); //void obname(); void getridoftemp3(); @@ -1449,7 +1447,7 @@ public: void runendseq(); void dumpdiarykeys(); void disablesoundint(); - void checkifset(); + void priesttext(); //void showallex(); void openpoolboss(); void buttontwo(); @@ -1651,6 +1649,7 @@ public: void bossman(); void getridofpit(); void convnum(); + //void checkifset(); void nothelderror(); //void readheader(); void getsetad(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 5b42e37079..ff79a90088 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1738,11 +1738,11 @@ bool DreamGenContext::compare(uint8 index, uint8 flag, const char id[4]) { } void DreamGenContext::isitdescribed() { - ObjPos *pos = (ObjPos *)es.ptr(bx, sizeof(ObjPos)); + const ObjPos *pos = (const ObjPos *)es.ptr(bx, sizeof(ObjPos)); flags._z = !isitdescribed(pos); } -bool DreamGenContext::isitdescribed(ObjPos *pos) { +bool DreamGenContext::isitdescribed(const ObjPos *pos) { uint16 offset = segRef(data.word(kSetdesc)).word(kSettextdat + pos->index * 2); uint8 result = segRef(data.word(kSetdesc)).byte(kSettext + offset); return result != 0; @@ -1755,5 +1755,34 @@ bool DreamGenContext::isCD() { // Maybe detect the version during game id? return (data.byte(kSpeechloaded) == 1); } + +void DreamGenContext::checkifset() { + flags._z = !checkifset(al, ah); +} + +bool DreamGenContext::checkifset(uint8 x, uint8 y) { + const ObjPos *setList = (const ObjPos *)segRef(data.word(kBuffers)).ptr(kSetlist, sizeof(ObjPos) * 128); + for (size_t i = 0; i < 128; ++i) { + const ObjPos *pos = setList + 127 - i; + if (pos->index == 0xff) + continue; + if (x < pos->xMin) + continue; + if (x >= pos->xMax) + continue; + if (y < pos->yMin) + continue; + if (y >= pos->yMax) + continue; + if (! pixelcheckset(pos, x, y)) + continue; + if (! isitdescribed(pos)) + continue; + obname(pos->index, 1); + return true; + } + return false; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 6cb96e9c0f..f6d57c18bf 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -217,7 +217,9 @@ void compare(); bool compare(uint8 index, uint8 flag, const char id[4]); void pixelcheckset(); - bool pixelcheckset(ObjPos *pos, uint8 x, uint8 y); + bool pixelcheckset(const ObjPos *pos, uint8 x, uint8 y); void isitdescribed(); - bool isitdescribed(ObjPos *objPos); + bool isitdescribed(const ObjPos *objPos); + void checkifset(); + bool checkifset(uint8 x, uint8 y); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 8d437c2c73..be3f58ce63 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -458,11 +458,11 @@ void DreamGenContext::transferinv() { void DreamGenContext::pixelcheckset() { uint8 x = al; uint8 y = ah; - ObjPos *pos = (ObjPos *)es.ptr(bx, sizeof(ObjPos)); + const ObjPos *pos = (const ObjPos *)es.ptr(bx, sizeof(ObjPos)); flags._z = !pixelcheckset(pos, x, y); } -bool DreamGenContext::pixelcheckset(ObjPos *pos, uint8 x, uint8 y) { +bool DreamGenContext::pixelcheckset(const ObjPos *pos, uint8 x, uint8 y) { x -= pos->xMin; y -= pos->yMin; SetObject *setObject = getsetad(pos->index); -- cgit v1.2.3 From 3a5e17d5525bfe1f42a465247b47f4b74d6f5c6c Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 04:33:05 +0200 Subject: DREAMWEB: Removal of stubs that became useless --- engines/dreamweb/stubs.cpp | 5 ----- engines/dreamweb/stubs.h | 2 -- engines/dreamweb/vgagrafx.cpp | 7 ------- 3 files changed, 14 deletions(-) diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index ff79a90088..d63e8843f6 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1737,11 +1737,6 @@ bool DreamGenContext::compare(uint8 index, uint8 flag, const char id[4]) { return true; } -void DreamGenContext::isitdescribed() { - const ObjPos *pos = (const ObjPos *)es.ptr(bx, sizeof(ObjPos)); - flags._z = !isitdescribed(pos); -} - bool DreamGenContext::isitdescribed(const ObjPos *pos) { uint16 offset = segRef(data.word(kSetdesc)).word(kSettextdat + pos->index * 2); uint8 result = segRef(data.word(kSetdesc)).byte(kSettext + offset); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index f6d57c18bf..da743c05f0 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -216,9 +216,7 @@ void obicons(); void compare(); bool compare(uint8 index, uint8 flag, const char id[4]); - void pixelcheckset(); bool pixelcheckset(const ObjPos *pos, uint8 x, uint8 y); - void isitdescribed(); bool isitdescribed(const ObjPos *objPos); void checkifset(); bool checkifset(uint8 x, uint8 y); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index be3f58ce63..53db811313 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -455,13 +455,6 @@ void DreamGenContext::transferinv() { data.word(kExframepos) += byteCount; } -void DreamGenContext::pixelcheckset() { - uint8 x = al; - uint8 y = ah; - const ObjPos *pos = (const ObjPos *)es.ptr(bx, sizeof(ObjPos)); - flags._z = !pixelcheckset(pos, x, y); -} - bool DreamGenContext::pixelcheckset(const ObjPos *pos, uint8 x, uint8 y) { x -= pos->xMin; y -= pos->yMin; -- cgit v1.2.3 From 850501147253fa1f0c3f1458ccfb11a733eaa355 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 5 Sep 2011 20:57:06 +1000 Subject: TSAGE: Further user interface fixes, and minor dialog tweaks --- engines/tsage/blue_force/blueforce_logic.cpp | 44 ++++++++++++++++++++++++++ engines/tsage/blue_force/blueforce_logic.h | 1 + engines/tsage/blue_force/blueforce_scenes0.cpp | 1 + engines/tsage/blue_force/blueforce_ui.cpp | 4 +-- engines/tsage/core.cpp | 13 +++++++- engines/tsage/core.h | 2 ++ engines/tsage/globals.cpp | 2 +- engines/tsage/scenes.cpp | 7 +--- engines/tsage/staticres.cpp | 9 ++++-- engines/tsage/staticres.h | 3 +- 10 files changed, 72 insertions(+), 14 deletions(-) diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 41d16ad998..048aaf14de 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -142,6 +142,50 @@ void BlueForceGame::rightClick() { delete dlg; } +void BlueForceGame::processEvent(Event &event) { + if (event.eventType == EVENT_KEYPRESS) { + switch (event.kbd.keycode) { + case Common::KEYCODE_F1: + // F1 - Help + MessageDialog::show(HELP_MSG, OK_BTN_STRING); + break; + + case Common::KEYCODE_F2: + // F2 - Sound Options + SoundDialog::execute(); + break; + + case Common::KEYCODE_F3: + // F3 - Quit + quitGame(); + event.handled = false; + break; + + case Common::KEYCODE_F4: + // F4 - Restart + restartGame(); + _globals->_events.setCursorFromFlag(); + break; + + case Common::KEYCODE_F7: + // F7 - Restore + restoreGame(); + _globals->_events.setCursorFromFlag(); + break; + + case Common::KEYCODE_F10: + // F10 - Pause + GfxDialog::setPalette(); + MessageDialog::show(GAME_PAUSED_MSG, OK_BTN_STRING); + _globals->_events.setCursorFromFlag(); + break; + + default: + break; + } + } +} + /*--------------------------------------------------------------------------*/ AObjectArray::AObjectArray(): EventHandler() { diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index ddc32d488f..762833be41 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -42,6 +42,7 @@ public: virtual void start(); virtual Scene *createScene(int sceneNumber); virtual void rightClick(); + virtual void processEvent(Event &event); }; #define OBJ_ARRAY_SIZE 10 diff --git a/engines/tsage/blue_force/blueforce_scenes0.cpp b/engines/tsage/blue_force/blueforce_scenes0.cpp index f33312494a..d6583986c4 100644 --- a/engines/tsage/blue_force/blueforce_scenes0.cpp +++ b/engines/tsage/blue_force/blueforce_scenes0.cpp @@ -191,6 +191,7 @@ void Scene20::postInit(SceneObjectList *OwnerList) { _object8.changeZoom(100); setAction(&_action1); + BF_GLOBALS._dialogCenter.y = 165; } /*-------------------------------------------------------------------------- diff --git a/engines/tsage/blue_force/blueforce_ui.cpp b/engines/tsage/blue_force/blueforce_ui.cpp index 42605b4c5f..8fc686090e 100644 --- a/engines/tsage/blue_force/blueforce_ui.cpp +++ b/engines/tsage/blue_force/blueforce_ui.cpp @@ -202,8 +202,6 @@ void UICollection::draw() { for (uint idx = 0; idx < _objList.size(); ++idx) _objList[idx]->draw(); - // Update the screen - g_system->updateScreen(); _clearScreen = 1; } } @@ -322,6 +320,8 @@ void UIElements::add(UIElement *obj) { _objList.push_back(obj); obj->setPosition(Common::Point(_bounds.left + obj->_position.x, _bounds.top + obj->_position.y)); + obj->reposition(); + GfxSurface s = obj->getFrame(); s.draw(obj->_position); } diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 4dc4c72fc8..71f001db80 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1619,8 +1619,13 @@ void SceneItem::display(int resNum, int lineNum, ...) { _globals->_sceneText.remove(); } - if ((_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) + if ((_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) { + // Show user interface BF_GLOBALS._uiElements.show(); + + // Re-show the cursor + BF_GLOBALS._events.setCursor(BF_GLOBALS._events.getCursor()); + } } void SceneItem::display2(int resNum, int lineNum) { @@ -2774,6 +2779,12 @@ void SceneText::synchronize(Serializer &s) { _textSurface.synchronize(s); } +void SceneText::updateScreen() { + // In Blue Force, stop clearing text in the user interface area screwing up user interface + if ((_vm->getGameID() != GType_BlueForce) || (_bounds.top < BF_INTERFACE_Y)) + SceneObject::updateScreen(); +} + /*--------------------------------------------------------------------------*/ Visage::Visage() { diff --git a/engines/tsage/core.h b/engines/tsage/core.h index ede1bfc1af..d8a21c74b3 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -612,6 +612,7 @@ public: virtual void synchronize(Serializer &s); virtual Common::String getClassName() { return "SceneText"; } virtual GfxSurface getFrame() { return _textSurface; } + virtual void updateScreen(); }; class Player : public SceneObject { @@ -728,6 +729,7 @@ public: _objList.remove(sceneObj); _listAltered = true; } + void clear() { _objList.clear(); } }; class ScenePriorities : public Common::List { diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index 086720dd50..c1b42855da 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -74,7 +74,7 @@ Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface _gfxColors.foreground = 83; _fontColors.background = 88; _fontColors.foreground = 92; - _dialogCenter.y = 165; + _dialogCenter.y = 140; } else if ((_vm->getGameID() == GType_Ringworld) && (_vm->getFeatures() & GF_CD)) { _gfxFontNumber = 50; _gfxColors.background = 53; diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index 5aeacda6fe..e8b3189481 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -77,12 +77,7 @@ void SceneManager::sceneChange() { } // Clear the secondary scene object list - io = _globals->_sceneManager._altSceneObjects.begin(); - while (io != _globals->_sceneManager._altSceneObjects.end()) { - SceneObject *sceneObj = *io; - ++io; - sceneObj->removeObject(); - } + _altSceneObjects.clear(); // Clear the hotspot list SynchronizedList::iterator ii = _globals->_sceneItems.begin(); diff --git a/engines/tsage/staticres.cpp b/engines/tsage/staticres.cpp index 819cf56f31..03e1954de6 100644 --- a/engines/tsage/staticres.cpp +++ b/engines/tsage/staticres.cpp @@ -75,9 +75,6 @@ const char *RESTORING_NOT_ALLOWED_MSG = "Restoring is not allowed at this time." const char *RESTART_CONFIRM_MSG = "Do you want to restart your game?"; const char *INV_EMPTY_MSG = "You have nothing in your possesion."; -const char *HELP_MSG = "Ringworld\rRevenge of the Patriarch\x14\rScummVM Version\r\r\ -\x01 Keyboard shortcuts...\rF2 - Sound options\rF3 - Quit\r\ -F4 - Restart\rF5 - Save game\rF7 - Restore Game\rF10 - Pause game"; const char *QUIT_CONFIRM_MSG = "Do you want to quit playing this game?"; const char *RESTART_MSG = "Do you want to restart this game?"; const char *GAME_PAUSED_MSG = "Game is paused."; @@ -97,6 +94,9 @@ const char *PICK_BTN_STRING = "Pick"; namespace Ringworld { // Dialog resources +const char *HELP_MSG = "Ringworld\rRevenge of the Patriarch\x14\rScummVM Version\r\r\ +\x01 Keyboard shortcuts...\rF2 - Sound options\rF3 - Quit\r\ +F4 - Restart\rF5 - Save game\rF7 - Restore Game\rF10 - Pause game"; const char *WATCH_INTRO_MSG = "Do you wish to watch the introduction?"; const char *START_PLAY_BTN_STRING = " Start Play "; const char *INTRODUCTION_BTN_STRING = "Introduction"; @@ -129,6 +129,9 @@ const char *DEMO_RESUME_BTN_STRING = "Resume"; namespace BlueForce { // Dialog resources +const char *HELP_MSG = "Blue Force\x14\rScummVM Version\r\r\ +Keyboard shortcuts...\rF2 - Sound options\rF3 - Quit\r\ +F4 - Restart\rF5 - Save game\rF7 - Restore Game\rF10 - Pause game"; const char *WATCH_INTRO_MSG = "Do you wish to watch the introduction?"; const char *START_PLAY_BTN_STRING = " Play "; const char *INTRODUCTION_BTN_STRING = " Watch "; diff --git a/engines/tsage/staticres.h b/engines/tsage/staticres.h index b08e92def2..1baf29f33c 100644 --- a/engines/tsage/staticres.h +++ b/engines/tsage/staticres.h @@ -42,7 +42,6 @@ extern const char *RESTORING_NOT_ALLOWED_MSG; extern const char *RESTART_CONFIRM_MSG; // Dialogs -extern const char *HELP_MSG; extern const char *QUIT_CONFIRM_MSG; extern const char *RESTART_MSG; extern const char *GAME_PAUSED_MSG; @@ -62,6 +61,7 @@ extern const char *INV_EMPTY_MSG; namespace Ringworld { // Dialog resources +extern const char *HELP_MSG; extern const char *WATCH_INTRO_MSG; extern const char *START_PLAY_BTN_STRING; extern const char *INTRODUCTION_BTN_STRING; @@ -95,6 +95,7 @@ extern const char *DEMO_RESUME_BTN_STRING; namespace BlueForce { // Dialog resources +extern const char *HELP_MSG; extern const char *WATCH_INTRO_MSG; extern const char *START_PLAY_BTN_STRING; extern const char *INTRODUCTION_BTN_STRING; -- cgit v1.2.3 From 98a6b339afcb6bb177ef898f2a83633269d2eea7 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 06:38:08 +0200 Subject: DREAMWEB: 'checkpathison' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 15 --------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/pathfind.cpp | 18 ++++++++++++++---- engines/dreamweb/structs.h | 2 +- engines/dreamweb/stubs.h | 2 ++ 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 7967acc87c..1d5e11bdae 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -182,6 +182,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'turnanypathoff', 'isitdescribed', 'checkifset', + 'checkifpathison', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index d59ff61a94..79e4746fb4 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -14882,20 +14882,6 @@ gotfirst: al = es.byte(bx+6); } -void DreamGenContext::checkifpathison() { - STACK_CHECK; - push(ax); - getroomspaths(); - ax = pop(); - ah = 0; - _add(ax, ax); - _add(ax, ax); - _add(ax, ax); - _add(bx, ax); - al = es.byte(bx+6); - _cmp(al, 255); -} - void DreamGenContext::afternewroom() { STACK_CHECK; _cmp(data.byte(kNowinnewroom), 0); @@ -17852,7 +17838,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_identifyob: identifyob(); break; case addr_findpathofpoint: findpathofpoint(); break; case addr_findfirstpath: findfirstpath(); break; - case addr_checkifpathison: checkifpathison(); break; case addr_afternewroom: afternewroom(); break; case addr_atmospheres: atmospheres(); break; case addr_walkintoroom: walkintoroom(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index a27665bf37..c2674c2d42 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -110,7 +110,6 @@ public: static const uint16 addr_walkintoroom = 0xca10; static const uint16 addr_atmospheres = 0xca0c; static const uint16 addr_afternewroom = 0xca08; - static const uint16 addr_checkifpathison = 0xca04; static const uint16 addr_findfirstpath = 0xc9f0; static const uint16 addr_findpathofpoint = 0xc9ec; static const uint16 addr_identifyob = 0xc9d4; @@ -1576,7 +1575,7 @@ public: void usecooker(); void loadmenu(); void checkforemm(); - void checkifpathison(); + //void checkifpathison(); //void finalframe(); void receptionist(); void selectslot(); diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index ef07199211..9069c9d3be 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -36,7 +36,7 @@ void DreamGenContext::turnpathon(uint8 param) { PathNode *roomsPaths = getroomspathsCPP()->nodes; if (param == 0xff) return; - roomsPaths[param].b6 = 0xff; + roomsPaths[param].on = 0xff; } void DreamGenContext::turnpathoff() { @@ -48,13 +48,13 @@ void DreamGenContext::turnpathoff(uint8 param) { PathNode *roomsPaths = getroomspathsCPP()->nodes; if (param == 0xff) return; - roomsPaths[param].b6 = 0x00; + roomsPaths[param].on = 0x00; } void DreamGenContext::turnanypathon(uint8 param, uint8 room) { findormake(param, 0xff, room + 100); PathNode *paths = (PathNode *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); - paths[param].b6 = 0xff; + paths[param].on = 0xff; } @@ -65,7 +65,7 @@ void DreamGenContext::turnanypathon() { void DreamGenContext::turnanypathoff(uint8 param, uint8 room) { findormake(param, 0x00, room + 100); PathNode *paths = (PathNode *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); - paths[param].b6 = 0x00; + paths[param].on = 0x00; } void DreamGenContext::turnanypathoff() { @@ -128,5 +128,15 @@ void DreamGenContext::findxyfrompath() { data.byte(kRyany) = roomsPaths[data.byte(kManspath)].y - 12; } +void DreamGenContext::checkifpathison() { + flags._z = checkifpathison(al); +} + +bool DreamGenContext::checkifpathison(uint8 index) { + RoomPaths *roomsPaths = getroomspathsCPP(); + uint8 pathOn = roomsPaths->nodes[index].on; + return pathOn == 0xff; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 7c9d9a5814..0d7bbb6cbf 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -235,7 +235,7 @@ struct PathNode { uint8 b3; uint8 b4; uint8 b5; - uint8 b6; + uint8 on; uint8 dir; }; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index da743c05f0..a272407b4f 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -220,4 +220,6 @@ bool isitdescribed(const ObjPos *objPos); void checkifset(); bool checkifset(uint8 x, uint8 y); + void checkifpathison(); + bool checkifpathison(uint8 index); -- cgit v1.2.3 From c51797dae69a8f4925d320a20228777dbc2add82 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 07:56:50 +0200 Subject: DREAMWEB: Removal of a useless stub --- engines/dreamweb/pathfind.cpp | 17 ++++++----------- engines/dreamweb/sprite.cpp | 2 +- engines/dreamweb/stubs.h | 3 +-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index 9069c9d3be..080f99a477 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -33,7 +33,7 @@ void DreamGenContext::turnpathon() { void DreamGenContext::turnpathon(uint8 param) { findormake(param, 0xff, data.byte(kRoomnum) + 100); - PathNode *roomsPaths = getroomspathsCPP()->nodes; + PathNode *roomsPaths = getroomspaths()->nodes; if (param == 0xff) return; roomsPaths[param].on = 0xff; @@ -45,7 +45,7 @@ void DreamGenContext::turnpathoff() { void DreamGenContext::turnpathoff(uint8 param) { findormake(param, 0x00, data.byte(kRoomnum) + 100); - PathNode *roomsPaths = getroomspathsCPP()->nodes; + PathNode *roomsPaths = getroomspaths()->nodes; if (param == 0xff) return; roomsPaths[param].on = 0x00; @@ -72,12 +72,7 @@ void DreamGenContext::turnanypathoff() { turnanypathoff(al, ah); } -void DreamGenContext::getroomspaths() { - es = data.word(kReels); - bx = data.byte(kRoomnum) * 144; -} - -RoomPaths *DreamGenContext::getroomspathsCPP() { +RoomPaths *DreamGenContext::getroomspaths() { void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144); return (RoomPaths *)result; } @@ -86,7 +81,7 @@ void DreamGenContext::autosetwalk() { al = data.byte(kManspath); if (data.byte(kFinaldest) == al) return; - const RoomPaths *roomsPaths = getroomspathsCPP(); + const RoomPaths *roomsPaths = getroomspaths(); checkdest(roomsPaths); data.word(kLinestartx) = roomsPaths->nodes[data.byte(kManspath)].x - 12; data.word(kLinestarty) = roomsPaths->nodes[data.byte(kManspath)].y - 12; @@ -123,7 +118,7 @@ void DreamGenContext::checkdest(const RoomPaths *roomsPaths) { } void DreamGenContext::findxyfrompath() { - const PathNode *roomsPaths = getroomspathsCPP()->nodes; + const PathNode *roomsPaths = getroomspaths()->nodes; data.byte(kRyanx) = roomsPaths[data.byte(kManspath)].x - 12; data.byte(kRyany) = roomsPaths[data.byte(kManspath)].y - 12; } @@ -133,7 +128,7 @@ void DreamGenContext::checkifpathison() { } bool DreamGenContext::checkifpathison(uint8 index) { - RoomPaths *roomsPaths = getroomspathsCPP(); + RoomPaths *roomsPaths = getroomspaths(); uint8 pathOn = roomsPaths->nodes[index].on; return pathOn == 0xff; } diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index e938f868a5..7cd54c9242 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -501,7 +501,7 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { } void DreamGenContext::facerightway() { - PathNode *paths = getroomspathsCPP()->nodes; + PathNode *paths = getroomspaths()->nodes; uint8 dir = paths[data.byte(kManspath)].dir; data.byte(kTurntoface) = dir; data.byte(kLeavedirection) = dir; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index a272407b4f..67bba274a7 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -111,8 +111,7 @@ void turnanypathoff(uint8 param, uint8 room); void turnanypathon(); void turnanypathoff(); - void getroomspaths(); - RoomPaths *getroomspathsCPP(); + RoomPaths *getroomspaths(); void makebackob(SetObject *objData); void modifychar(); void lockmon(); -- cgit v1.2.3 From 3fff4d97b5a16686a1eedd52554b61ef38fd0a40 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 07:59:52 +0200 Subject: DREAMWEB: Useless stub removal --- engines/dreamweb/sprite.cpp | 11 ----------- engines/dreamweb/stubs.h | 1 - 2 files changed, 12 deletions(-) diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 7cd54c9242..df134b696d 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -90,17 +90,6 @@ Sprite *DreamGenContext::makesprite(uint8 x, uint8 y, uint16 updateCallback, uin return sprite; } -void DreamGenContext::makesprite() { // NB: returns new sprite in es:bx - Sprite *sprite = makesprite(si & 0xff, si >> 8, cx, dx, di); - - // Recover es:bx from sprite - es = data.word(kBuffers); - bx = kSpritetable; - Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16); - bx += sizeof(Sprite) * (sprite - sprites); - // -} - void DreamGenContext::spriteupdate() { Sprite *sprites = spritetable(); sprites[0].hidden = data.byte(kRyanon); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 67bba274a7..e1abc1b1dc 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -76,7 +76,6 @@ void multiput(); void eraseoldobs(); void clearsprites(); - void makesprite(); Sprite *makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 frameData, uint16 somethingInDi); void spriteupdate(); void initman(); -- cgit v1.2.3 From c8782389d6e6f54e1dfa09ff1259fe5b7a7a83f8 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 08:07:24 +0200 Subject: DREAMWEB: 'delsprite' is useless --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 9 --------- engines/dreamweb/dreamgen.h | 3 +-- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 1d5e11bdae..e3a232ef53 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -183,6 +183,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'isitdescribed', 'checkifset', 'checkifpathison', + 'delsprite', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 79e4746fb4..44400ecfb2 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2050,14 +2050,6 @@ forcenext: _cmp(al, al); } -void DreamGenContext::delsprite() { - STACK_CHECK; - di = bx; - cx = (32); - al = 255; - _stosb(cx, true); -} - void DreamGenContext::checkforexit() { STACK_CHECK; cl = data.byte(kRyanx); @@ -17373,7 +17365,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_sparky: sparky(); break; case addr_train: train(); break; case addr_checkspeed: checkspeed(); break; - case addr_delsprite: delsprite(); break; case addr_mainman: mainman(); break; case addr_checkforexit: checkforexit(); break; case addr_adjustdown: adjustdown(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index c2674c2d42..ae6887c829 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -575,7 +575,6 @@ public: static const uint16 addr_adjustdown = 0xc14c; static const uint16 addr_checkforexit = 0xc148; static const uint16 addr_mainman = 0xc138; - static const uint16 addr_delsprite = 0xc11c; static const uint16 addr_checkspeed = 0xc110; static const uint16 addr_train = 0xc104; static const uint16 addr_sparky = 0xc100; @@ -1451,7 +1450,7 @@ public: void openpoolboss(); void buttontwo(); //void usetimedtext(); - void delsprite(); + //void delsprite(); //void getroomspaths(); //void dumptextline(); void fadescreendownhalf(); -- cgit v1.2.3 From 214cff8db8253759d2dd358273b8e1b83c141169 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 08:12:33 +0200 Subject: DREAMWEB: 'dumpeverything' is useless --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 59 --------------------------------------- engines/dreamweb/dreamgen.h | 3 +- 3 files changed, 2 insertions(+), 61 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index e3a232ef53..3e04ddd1dd 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -184,6 +184,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'checkifset', 'checkifpathison', 'delsprite', + 'dumpeverything', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 44400ecfb2..0fd6ae19d2 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2552,64 +2552,6 @@ bigroom: _add(data.byte(kMapysize), 8); } -void DreamGenContext::dumpeverything() { - STACK_CHECK; - es = data.word(kBuffers); - bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)); -dumpevery1: - ax = es.word(bx); - cx = es.word(bx+2); - _cmp(ax, 0x0ffff); - if (flags.z()) - goto finishevery1; - _cmp(ax, es.word(bx+(40*5))); - if (!flags.z()) - goto notskip1; - _cmp(cx, es.word(bx+(40*5)+2)); - if (flags.z()) - goto skip1; -notskip1: - push(bx); - push(es); - push(ds); - bl = ah; - bh = 0; - ah = 0; - di = ax; - _add(di, data.word(kMapadx)); - _add(bx, data.word(kMapady)); - multidump(); - ds = pop(); - es = pop(); - bx = pop(); -skip1: - _add(bx, 5); - goto dumpevery1; -finishevery1: - bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40))+(40*5); -dumpevery2: - ax = es.word(bx); - cx = es.word(bx+2); - _cmp(ax, 0x0ffff); - if (flags.z()) - return /* (finishevery2) */; - push(bx); - push(es); - push(ds); - bl = ah; - bh = 0; - ah = 0; - di = ax; - _add(di, data.word(kMapadx)); - _add(bx, data.word(kMapady)); - multidump(); - ds = pop(); - es = pop(); - bx = pop(); - _add(bx, 5); - goto dumpevery2; -} - void DreamGenContext::loadpalfromiff() { STACK_CHECK; dx = 2481; @@ -17384,7 +17326,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_soundonreels: soundonreels(); break; case addr_reconstruct: reconstruct(); break; case addr_deleverything: deleverything(); break; - case addr_dumpeverything: dumpeverything(); break; case addr_showpcx: showpcx(); break; case addr_loadpalfromiff: loadpalfromiff(); break; case addr_setmode: setmode(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index ae6887c829..c8dc1924f4 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -555,7 +555,6 @@ public: static const uint16 addr_setmode = 0xc1dc; static const uint16 addr_loadpalfromiff = 0xc1d8; static const uint16 addr_showpcx = 0xc1cc; - static const uint16 addr_dumpeverything = 0xc1c4; static const uint16 addr_deleverything = 0xc1c0; static const uint16 addr_reconstruct = 0xc1ac; static const uint16 addr_soundonreels = 0xc1a8; @@ -1611,7 +1610,7 @@ public: void examinventory(); void talk(); void usedryer(); - void dumpeverything(); + //void dumpeverything(); //void readmouse2(); //void zoom(); void outofinv(); -- cgit v1.2.3 From 1de8427361de7b810b5043a80827bb38e474b974 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 09:11:48 +0200 Subject: DREAMWEB: 'isitworn' and 'makeworn' ported to C++ --- devtools/tasmrecover/tasm-recover | 2 ++ engines/dreamweb/dreamgen.cpp | 18 ------------------ engines/dreamweb/dreamgen.h | 6 ++---- engines/dreamweb/stubs.cpp | 17 +++++++++++++++++ engines/dreamweb/stubs.h | 4 ++++ 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 3e04ddd1dd..a9fb1539a4 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -185,6 +185,8 @@ generator = cpp(context, "DreamGen", blacklist = [ 'checkifpathison', 'delsprite', 'dumpeverything', + 'isitworn', + 'makeworn', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 0fd6ae19d2..c28c289b77 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -4015,22 +4015,6 @@ finishfill: bx = pop(); } -void DreamGenContext::isitworn() { - STACK_CHECK; - al = es.byte(bx+12); - _cmp(al, 'W'-'A'); - if (!flags.z()) - return /* (notworn) */; - al = es.byte(bx+13); - _cmp(al, 'E'-'A'); -} - -void DreamGenContext::makeworn() { - STACK_CHECK; - es.byte(bx+12) = 'W'-'A'; - es.byte(bx+13) = 'E'-'A'; -} - void DreamGenContext::examineob() { STACK_CHECK; data.byte(kPointermode) = 0; @@ -17385,8 +17369,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_findallryan: findallryan(); break; case addr_findallopen: findallopen(); break; case addr_obtoinv: obtoinv(); break; - case addr_isitworn: isitworn(); break; - case addr_makeworn: makeworn(); break; case addr_examineob: examineob(); break; case addr_makemainscreen: makemainscreen(); break; case addr_getbackfromob: getbackfromob(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index c8dc1924f4..f3b502a8f6 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -494,8 +494,6 @@ public: static const uint16 addr_getbackfromob = 0xc344; static const uint16 addr_makemainscreen = 0xc340; static const uint16 addr_examineob = 0xc33c; - static const uint16 addr_makeworn = 0xc338; - static const uint16 addr_isitworn = 0xc334; static const uint16 addr_obtoinv = 0xc330; static const uint16 addr_findallopen = 0xc32c; static const uint16 addr_findallryan = 0xc328; @@ -1273,7 +1271,7 @@ public: void neterror(); void storeit(); //void lockeddoorway(); - void isitworn(); + //void isitworn(); //void putundertimed(); //void dumpmap(); //void multidump(); @@ -1667,7 +1665,7 @@ public: //void showallfree(); void loadnews(); void rollem(); - void makeworn(); + //void makeworn(); void examineobtext(); void startup(); void savegame(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index d63e8843f6..731396697d 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1779,5 +1779,22 @@ bool DreamGenContext::checkifset(uint8 x, uint8 y) { return false; } +void DreamGenContext::isitworn() { + flags._z = isitworn((const DynObject *)es.ptr(bx, sizeof(DynObject))); +} + +bool DreamGenContext::isitworn(const DynObject *object) { + return (object->id[0] == 'W'-'A') && (object->id[1] == 'E'-'A'); +} + +void DreamGenContext::makeworn() { + makeworn((DynObject *)es.ptr(bx, sizeof(DynObject))); +} + +void DreamGenContext::makeworn(DynObject *object) { + object->id[0] = 'W'-'A'; + object->id[1] = 'E'-'A'; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index e1abc1b1dc..4d22fcc0bf 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -220,4 +220,8 @@ bool checkifset(uint8 x, uint8 y); void checkifpathison(); bool checkifpathison(uint8 index); + void isitworn(); + bool isitworn(const DynObject *object); + void makeworn(); + void makeworn(DynObject *object); -- cgit v1.2.3 From e0b77beb99138cf840dee93037ca11ea98a9e333 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 09:35:52 +0200 Subject: DREAMWEB: 'obtoinv' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 61 --------------------------------------- engines/dreamweb/dreamgen.h | 3 +- engines/dreamweb/stubs.cpp | 20 +++++++++++++ engines/dreamweb/stubs.h | 2 ++ 5 files changed, 24 insertions(+), 63 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index a9fb1539a4..94276642b4 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -187,6 +187,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'dumpeverything', 'isitworn', 'makeworn', + 'obtoinv', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index c28c289b77..3ee8c791ce 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -3955,66 +3955,6 @@ findopen2a: goto findopen1a; } -void DreamGenContext::obtoinv() { - STACK_CHECK; - push(bx); - push(es); - push(si); - push(ax); - push(ax); - push(di); - push(bx); - ds = data.word(kIcons1); - _sub(di, 2); - _sub(bx, 1); - al = 10; - ah = 0; - showframe(); - bx = pop(); - di = pop(); - ax = pop(); - _cmp(al, 255); - if (flags.z()) - goto finishfill; - push(bx); - push(di); - push(ax); - ds = data.word(kExtras); - _cmp(ah, 4); - if (flags.z()) - goto isanextra; - ds = data.word(kFreeframes); -isanextra: - cl = al; - _add(al, al); - _add(al, cl); - _inc(al); - ah = 128; - _add(bx, 19); - _add(di, 18); - showframe(); - ax = pop(); - di = pop(); - bx = pop(); - push(bx); - getanyaddir(); - isitworn(); - bx = pop(); - if (!flags.z()) - goto finishfill; - ds = data.word(kIcons1); - _sub(di, 3); - _sub(bx, 2); - al = 7; - ah = 0; - showframe(); -finishfill: - ax = pop(); - si = pop(); - es = pop(); - bx = pop(); -} - void DreamGenContext::examineob() { STACK_CHECK; data.byte(kPointermode) = 0; @@ -17368,7 +17308,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_fillopen: fillopen(); break; case addr_findallryan: findallryan(); break; case addr_findallopen: findallopen(); break; - case addr_obtoinv: obtoinv(); break; case addr_examineob: examineob(); break; case addr_makemainscreen: makemainscreen(); break; case addr_getbackfromob: getbackfromob(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index f3b502a8f6..68e7b65ac2 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -494,7 +494,6 @@ public: static const uint16 addr_getbackfromob = 0xc344; static const uint16 addr_makemainscreen = 0xc340; static const uint16 addr_examineob = 0xc33c; - static const uint16 addr_obtoinv = 0xc330; static const uint16 addr_findallopen = 0xc32c; static const uint16 addr_findallryan = 0xc328; static const uint16 addr_fillopen = 0xc324; @@ -1480,7 +1479,7 @@ public: void checkspeed(); //void printchar(); void showkeypad(); - void obtoinv(); + //void obtoinv(); //void getroomdata(); void removeobfrominv(); void usecoveredbox(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 731396697d..e6c868530d 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1796,5 +1796,25 @@ void DreamGenContext::makeworn(DynObject *object) { object->id[1] = 'E'-'A'; } +void DreamGenContext::obtoinv() { + obtoinv(al, ah, di, bx); +} + +void DreamGenContext::obtoinv(uint8 index, uint8 flag, uint16 x, uint16 y) { + Frame *icons1 = (Frame *)segRef(data.word(kIcons1)).ptr(0, 0); + showframe(icons1, x - 2, y - 1, 10, 0); + if (index == 0xff) + return; + + Frame *extras = (Frame *)segRef(data.word(kExtras)).ptr(0, 0); + Frame *frees = (Frame *)segRef(data.word(kFreeframes)).ptr(0, 0); + Frame *frames = (ah == 4) ? extras : frees; + showframe(frames, x + 18, y + 19, 3 * index + 1, 128); + const DynObject *object = (const DynObject *)getanyaddir(index, flag); + bool worn = isitworn(object); + if (worn) + showframe(icons1, x - 3, y - 2, 7, 0); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 4d22fcc0bf..70ba5f70d5 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -224,4 +224,6 @@ bool isitworn(const DynObject *object); void makeworn(); void makeworn(DynObject *object); + void obtoinv(); + void obtoinv(uint8 index, uint8 flag, uint16 x, uint16 y); -- cgit v1.2.3 From ecfbaebf87145e2c9237f4ece9d8d7829c2bbbfe Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 5 Sep 2011 20:16:16 +0200 Subject: DREAMWEB: Removal of a useless register usage --- engines/dreamweb/stubs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index e6c868530d..394de96e05 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1808,7 +1808,7 @@ void DreamGenContext::obtoinv(uint8 index, uint8 flag, uint16 x, uint16 y) { Frame *extras = (Frame *)segRef(data.word(kExtras)).ptr(0, 0); Frame *frees = (Frame *)segRef(data.word(kFreeframes)).ptr(0, 0); - Frame *frames = (ah == 4) ? extras : frees; + Frame *frames = (flag == 4) ? extras : frees; showframe(frames, x + 18, y + 19, 3 * index + 1, 128); const DynObject *object = (const DynObject *)getanyaddir(index, flag); bool worn = isitworn(object); -- cgit v1.2.3 From 1163a83f3587f5ceef41f7c2c429c30e2e8b6887 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 5 Sep 2011 20:45:41 +0200 Subject: DREAMWEB: Ported 'showryanpage' to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 25 ------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 6 ++++++ engines/dreamweb/stubs.h | 1 + 5 files changed, 9 insertions(+), 27 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 94276642b4..2193954cca 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -188,6 +188,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'isitworn', 'makeworn', 'obtoinv', + 'showryanpage', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 3ee8c791ce..a03aa62b83 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -4101,30 +4101,6 @@ void DreamGenContext::openinv() { data.byte(kCommandtype) = 255; } -void DreamGenContext::showryanpage() { - STACK_CHECK; - ds = data.word(kIcons1); - di = (80)+167; - bx = (58)-12; - al = 12; - ah = 0; - showframe(); - al = 13; - _add(al, data.byte(kRyanpage)); - push(ax); - al = data.byte(kRyanpage); - ah = 0; - cx = 18; - _mul(cx); - ds = data.word(kIcons1); - di = (80)+167; - _add(di, ax); - bx = (58)-12; - ax = pop(); - ah = 0; - showframe(); -} - void DreamGenContext::openob() { STACK_CHECK; al = data.byte(kOpenedob); @@ -17313,7 +17289,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_getbackfromob: getbackfromob(); break; case addr_incryanpage: incryanpage(); break; case addr_openinv: openinv(); break; - case addr_showryanpage: showryanpage(); break; case addr_openob: openob(); break; case addr_examicon: examicon(); break; case addr_describeob: describeob(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 68e7b65ac2..6c62e9b0ae 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -488,7 +488,6 @@ public: static const uint16 addr_describeob = 0xc364; static const uint16 addr_examicon = 0xc35c; static const uint16 addr_openob = 0xc354; - static const uint16 addr_showryanpage = 0xc350; static const uint16 addr_openinv = 0xc34c; static const uint16 addr_incryanpage = 0xc348; static const uint16 addr_getbackfromob = 0xc344; @@ -1949,7 +1948,7 @@ public: //void drawflags(); void zoomonoff(); void updatesymboltop(); - void showryanpage(); + //void showryanpage(); void printlogo(); void allpointer(); void showseconduse(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 394de96e05..8985392cfc 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1816,5 +1816,11 @@ void DreamGenContext::obtoinv(uint8 index, uint8 flag, uint16 x, uint16 y) { showframe(icons1, x - 3, y - 2, 7, 0); } +void DreamGenContext::showryanpage() { + Frame *icons1 = (Frame *)segRef(data.word(kIcons1)).ptr(0, 0); + showframe(icons1, kInventx + 167, kInventy - 12, 12, 0); + showframe(icons1, kInventx + 167 + 18 * data.byte(kRyanpage), kInventy - 12, 13 + data.byte(kRyanpage), 0); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 70ba5f70d5..10cb2e8866 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -226,4 +226,5 @@ void makeworn(DynObject *object); void obtoinv(); void obtoinv(uint8 index, uint8 flag, uint16 x, uint16 y); + void showryanpage(); -- cgit v1.2.3 From a6b6d05a2c5052a86c9bf3ca31f548c7ba08b5ee Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 5 Sep 2011 21:42:06 +0200 Subject: DREAMWEB: Ported 'findallryan' to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 36 ------------------------------------ engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 19 +++++++++++++++++++ engines/dreamweb/stubs.h | 2 ++ 5 files changed, 23 insertions(+), 38 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 2193954cca..6d07d76800 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -189,6 +189,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'makeworn', 'obtoinv', 'showryanpage', + 'findallryan', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index a03aa62b83..ad9cb5fbae 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -3847,41 +3847,6 @@ nextopenslot: undertextline(); } -void DreamGenContext::findallryan() { - STACK_CHECK; - push(di); - cx = 30; - ax = 0x0ffff; - _stosw(cx, true); - di = pop(); - cl = 4; - ds = data.word(kExtras); - bx = (0+2080+30000); - ch = 0; -findryanloop: - _cmp(ds.byte(bx+2), cl); - if (!flags.z()) - goto notinryaninv; - _cmp(ds.byte(bx+3), 255); - if (!flags.z()) - goto notinryaninv; - al = ds.byte(bx+4); - ah = 0; - push(di); - _add(di, ax); - _add(di, ax); - al = ch; - ah = 4; - _stosw(); - di = pop(); -notinryaninv: - _add(bx, 16); - _inc(ch); - _cmp(ch, (114)); - if (!flags.z()) - goto findryanloop; -} - void DreamGenContext::findallopen() { STACK_CHECK; push(di); @@ -17282,7 +17247,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_monprint: monprint(); break; case addr_fillryan: fillryan(); break; case addr_fillopen: fillopen(); break; - case addr_findallryan: findallryan(); break; case addr_findallopen: findallopen(); break; case addr_examineob: examineob(); break; case addr_makemainscreen: makemainscreen(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 6c62e9b0ae..8465c59885 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -494,7 +494,6 @@ public: static const uint16 addr_makemainscreen = 0xc340; static const uint16 addr_examineob = 0xc33c; static const uint16 addr_findallopen = 0xc32c; - static const uint16 addr_findallryan = 0xc328; static const uint16 addr_fillopen = 0xc324; static const uint16 addr_fillryan = 0xc320; static const uint16 addr_monprint = 0xc314; @@ -1929,7 +1928,7 @@ public: void buttonseven(); void redrawmainscrn(); void showgroup(); - void findallryan(); + //void findallryan(); //void channel0tran(); void buttonpress(); //void parseblaster(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 8985392cfc..51a79d72fa 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1822,5 +1822,24 @@ void DreamGenContext::showryanpage() { showframe(icons1, kInventx + 167 + 18 * data.byte(kRyanpage), kInventy - 12, 13 + data.byte(kRyanpage), 0); } +void DreamGenContext::findallryan() { + findallryan(es.ptr(di, 60)); +} + +void DreamGenContext::findallryan(uint8 *inv) { + memset(inv, 0xff, 60); + for (size_t i = 0; i < kNumexobjects; ++i) { + DynObject *extra = getexad(i); + if (extra->mapad[0] != 4) + continue; + if (extra->mapad[1] != 0xff) + continue; + uint8 slot = extra->mapad[2]; + assert(slot < 30); + inv[2 * slot + 0] = i; + inv[2 * slot + 1] = 4; + } +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 10cb2e8866..c8fbd9bf82 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -227,4 +227,6 @@ void obtoinv(); void obtoinv(uint8 index, uint8 flag, uint16 x, uint16 y); void showryanpage(); + void findallryan(); + void findallryan(uint8 *inv); -- cgit v1.2.3 From e6162f1a786af00974f814ea5c11dbd4e76bd972 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 6 Sep 2011 08:54:01 +0200 Subject: DREAMWEB: Ported 'fillryan' to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 46 --------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 14 ++++++++++++ engines/dreamweb/stubs.h | 1 + 5 files changed, 17 insertions(+), 48 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 6d07d76800..bf0f1343ae 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -190,6 +190,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'obtoinv', 'showryanpage', 'findallryan', + 'fillryan', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index ad9cb5fbae..6e56a68369 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -3758,51 +3758,6 @@ nottrigger2: data.byte(kKerning) = 0; } -void DreamGenContext::fillryan() { - STACK_CHECK; - es = data.word(kBuffers); - di = (0+(228*13)+32); - findallryan(); - si = (0+(228*13)+32); - al = data.byte(kRyanpage); - ah = 0; - cx = 20; - _mul(cx); - _add(si, ax); - di = (80); - bx = (58); - cx = 2; -ryanloop2: - push(cx); - push(di); - push(bx); - cx = 5; -ryanloop1: - push(cx); - push(di); - push(bx); - ax = es.word(si); - _add(si, 2); - push(si); - push(es); - obtoinv(); - es = pop(); - si = pop(); - bx = pop(); - di = pop(); - cx = pop(); - _add(di, (44)); - if (--cx) - goto ryanloop1; - bx = pop(); - di = pop(); - cx = pop(); - _add(bx, (44)); - if (--cx) - goto ryanloop2; - showryanpage(); -} - void DreamGenContext::fillopen() { STACK_CHECK; deltextline(); @@ -17245,7 +17200,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_set16colpalette: set16colpalette(); break; case addr_realcredits: realcredits(); break; case addr_monprint: monprint(); break; - case addr_fillryan: fillryan(); break; case addr_fillopen: fillopen(); break; case addr_findallopen: findallopen(); break; case addr_examineob: examineob(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 8465c59885..42beacb6f1 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -495,7 +495,6 @@ public: static const uint16 addr_examineob = 0xc33c; static const uint16 addr_findallopen = 0xc32c; static const uint16 addr_fillopen = 0xc324; - static const uint16 addr_fillryan = 0xc320; static const uint16 addr_monprint = 0xc314; static const uint16 addr_realcredits = 0xc2f8; static const uint16 addr_set16colpalette = 0xc2f4; @@ -1746,7 +1745,7 @@ public: void dropobject(); void isitright(); void reexfromopen(); - void fillryan(); + //void fillryan(); void drawitall(); void usestereo(); void showcurrentfile(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 51a79d72fa..a481bb2979 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1841,5 +1841,19 @@ void DreamGenContext::findallryan(uint8 *inv) { } } +void DreamGenContext::fillryan() { + uint8 *inv = segRef(data.word(kBuffers)).ptr(kRyaninvlist, 60); + findallryan(inv); + inv += data.byte(kRyanpage) * 2 * 10; + for (size_t i = 0; i < 2; ++i) { + for (size_t j = 0; j < 5; ++j) { + uint8 objIndex = *inv++; + uint8 objType = *inv++; + obtoinv(objIndex, objType, kInventx + j * kItempicsize, kInventy + i * kItempicsize); + } + } + showryanpage(); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index c8fbd9bf82..a2d25b905c 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -229,4 +229,5 @@ void showryanpage(); void findallryan(); void findallryan(uint8 *inv); + void fillryan(); -- cgit v1.2.3 From ad85a25f88f6d060f8477df7a6b5bfec1c620d84 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 Sep 2011 19:54:22 +1000 Subject: TSAGE: Added new walking code for Blue Force that uses flipped horizontal images --- engines/tsage/core.cpp | 83 +++++++++++++++++++++++++++++++++++--------------- engines/tsage/core.h | 10 ++++-- 2 files changed, 66 insertions(+), 27 deletions(-) diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 71f001db80..ad082d6f1b 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -22,6 +22,7 @@ #include "common/system.h" #include "common/config-manager.h" +#include "common/util.h" #include "engines/engine.h" #include "graphics/palette.h" #include "tsage/tsage.h" @@ -307,8 +308,12 @@ void ObjectMover::dispatch() { void ObjectMover::setup(const Common::Point &destPos) { _sceneObject->calcAngle(destPos); - if ((_sceneObject->_objectWrapper) && !(_sceneObject->_flags & OBJFLAG_SUPPRESS_DISPATCH)) - _sceneObject->_objectWrapper->dispatch(); + if ((_sceneObject->_objectWrapper) && !(_sceneObject->_flags & OBJFLAG_SUPPRESS_DISPATCH)) { + if (_vm->getGameID() == GType_Ringworld) + _sceneObject->_objectWrapper->dispatch(); + else + _sceneObject->updateAngle(destPos); + } // Get the difference int diffX = destPos.x - _sceneObject->_position.x; @@ -1799,11 +1804,11 @@ void SceneObjectWrapper::dispatch() { void SceneObjectWrapper::check() { _visageImages.setVisage(_sceneObject->_visage); - int frameCount = _visageImages.getFrameCount(); + int visageCount = _visageImages.getFrameCount(); int angle = _sceneObject->_angle; int strip = _sceneObject->_strip; - if (frameCount == 4) { + if (visageCount == 4) { if ((angle > 314) || (angle < 45)) strip = 4; if ((angle > 44) && (angle < 135)) @@ -1812,7 +1817,7 @@ void SceneObjectWrapper::check() { strip = 3; if ((angle >= 225) && (angle < 315)) strip = 2; - } else if (frameCount == 8) { + } else if (visageCount == 8) { if ((angle > 330) || (angle < 30)) strip = 4; if ((angle >= 30) && (angle < 70)) @@ -1831,8 +1836,8 @@ void SceneObjectWrapper::check() { strip = 8; } - if (strip > frameCount) - strip = frameCount; + if (strip > visageCount) + strip = visageCount; _sceneObject->setStrip(strip); } @@ -2165,9 +2170,16 @@ SceneObject *SceneObject::clone() const { } void SceneObject::checkAngle(const SceneObject *obj) { - _angle = GfxManager::getAngle(_position, obj->_position); + checkAngle(obj->_position); +} - if (_objectWrapper) +void SceneObject::checkAngle(const Common::Point &pt) { + int angleAmount = GfxManager::getAngle(_position, pt); + if ((_vm->getGameID() == GType_Ringworld) || + ((angleAmount != -1) && (_animateMode == ANIM_MODE_9))) + _angle = angleAmount; + + if (_objectWrapper && (_vm->getGameID() == GType_Ringworld)) _objectWrapper->dispatch(); } @@ -2438,8 +2450,8 @@ void SceneObject::updateScreen() { } } -void SceneObject::updateAngle(SceneObject *sceneObj) { - checkAngle(sceneObj); +void SceneObject::updateAngle(const Common::Point &pt) { + checkAngle(pt); if (_objectWrapper) _objectWrapper->check(); } @@ -2780,8 +2792,10 @@ void SceneText::synchronize(Serializer &s) { } void SceneText::updateScreen() { - // In Blue Force, stop clearing text in the user interface area screwing up user interface - if ((_vm->getGameID() != GType_BlueForce) || (_bounds.top < BF_INTERFACE_Y)) + // FIXME: Hack for Blue Force to handle not refreshing the screen if the user interface + // has been re-activated after showing some scene text + if ((_vm->getGameID() != GType_BlueForce) || (_bounds.top < BF_INTERFACE_Y) || + !BF_GLOBALS._uiElements._active) SceneObject::updateScreen(); } @@ -2791,6 +2805,7 @@ Visage::Visage() { _resNum = -1; _rlbNum = -1; _data = NULL; + _flipHoriz = false; } Visage::Visage(const Visage &v) { @@ -2821,20 +2836,25 @@ void Visage::setVisage(int resNum, int rlbNum) { // In Ringworld, we immediately get the data _data = _resourceManager->getResource(RES_VISAGE, resNum, rlbNum); } else { - // Blue Force has an extra indirection via a visage index file + // Blue Force has an extra indirection via the visage index file byte *indexData = _resourceManager->getResource(RES_VISAGE, resNum, 9999); - if (rlbNum == 0) - rlbNum = 1; + if (rlbNum == 9999) { + _data = indexData; + } else { + if (rlbNum == 0) + rlbNum = 1; - // Get the flags/rlbNum to use - uint32 flags = READ_LE_UINT32(indexData + (rlbNum - 1) * 4 + 2); + // Get the flags/rlbNum to use + uint32 v = READ_LE_UINT32(indexData + (rlbNum - 1) * 4 + 2); + int flags = v >> 30; - if (flags & 0xC0000000) { - // TODO: See whether rest of flags dword is needed - rlbNum = (int)(flags & 0xff); - } + if (flags & 3) { + rlbNum = (int)(v & 0xff); + } + _flipHoriz = flags & 1; - _data = _resourceManager->getResource(RES_VISAGE, resNum, rlbNum); + _data = _resourceManager->getResource(RES_VISAGE, resNum, rlbNum); + } } assert(_data); @@ -2855,13 +2875,28 @@ GfxSurface Visage::getFrame(int frameNum) { int offset = READ_LE_UINT32(_data + 2 + frameNum * 4); byte *frameData = _data + offset; - return surfaceFromRes(frameData); + GfxSurface result = surfaceFromRes(frameData); + if (_flipHoriz) flip(result); + return result; } int Visage::getFrameCount() const { return READ_LE_UINT16(_data); } +void Visage::flip(GfxSurface &gfxSurface) { + Graphics::Surface s = gfxSurface.lockSurface(); + + for (int y = 0; y < s.h; ++y) { + // Flip the line + byte *lineP = (byte *)s.getBasePtr(0, y); + for (int x = 0; x < (s.w / 2); ++x) + SWAP(lineP[x], lineP[s.w - x - 1]); + } + + gfxSurface.unlockSurface(); +} + /*--------------------------------------------------------------------------*/ Player::Player(): SceneObject() { diff --git a/engines/tsage/core.h b/engines/tsage/core.h index d8a21c74b3..5496087cc8 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -467,9 +467,12 @@ class SceneObject; class Visage { private: byte *_data; + + void flip(GfxSurface &s); public: int _resNum; int _rlbNum; + bool _flipHoriz; public: Visage(); Visage(const Visage &v); @@ -478,7 +481,7 @@ public: void setVisage(int resNum, int rlbNum = 9999); GfxSurface getFrame(int frameNum); int getFrameCount() const; - Visage &operator=(const Visage &s); + Visage &operator=(const Visage &gfxSurface); }; class SceneObjectWrapper : public EventHandler { @@ -562,6 +565,7 @@ public: void animate(AnimateMode animMode, ...); SceneObject *clone() const; void checkAngle(const SceneObject *obj); + void checkAngle(const Common::Point &pt); void hide(); void show(); int getSpliceArea(const SceneObject *obj); @@ -580,8 +584,8 @@ public: virtual void draw(); virtual void proc19() {} virtual void updateScreen(); - // New methods introduced by Blue FOrce - virtual void updateAngle(SceneObject *sceneObj); + // New methods introduced by Blue Force + virtual void updateAngle(const Common::Point &pt); virtual void changeAngle(int angle); void setup(int visage, int stripFrameNum, int frameNum, int posX, int posY, int priority); -- cgit v1.2.3 From 9908fa3b61bff96a921160b3c90c73e6f2a40ccc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 Sep 2011 19:55:29 +1000 Subject: TSAGE: Some cleanup of Blue Force Scene 300, and implementing Scene 190 --- engines/tsage/blue_force/blueforce_logic.cpp | 11 +- engines/tsage/blue_force/blueforce_logic.h | 7 +- engines/tsage/blue_force/blueforce_scenes1.cpp | 281 ++++++++++++++++++++++++- engines/tsage/blue_force/blueforce_scenes1.h | 54 ++++- engines/tsage/blue_force/blueforce_scenes3.cpp | 13 +- engines/tsage/blue_force/blueforce_scenes3.h | 1 - engines/tsage/converse.cpp | 2 +- 7 files changed, 348 insertions(+), 21 deletions(-) diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 048aaf14de..99e3c38850 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -67,8 +67,10 @@ Scene *BlueForceGame::createScene(int sceneNumber) { case 150: case 160: case 180: - case 190: error("Scene group 1 not implemented"); + case 190: + // Front of Police Station + return new Scene190(); case 200: case 210: case 220: @@ -501,6 +503,7 @@ SceneExt::SceneExt(): Scene() { _field372 = 0; _field37A = 0; _eventHandler = NULL; + _cursorVisage.setVisage(1, 8); } void SceneExt::postInit(SceneObjectList *OwnerList) { @@ -598,17 +601,17 @@ void SceneExt::gunDisplay() { /*--------------------------------------------------------------------------*/ -GameScene::GameScene() { +GroupedScene::GroupedScene() { } -void GameScene::postInit(SceneObjectList *OwnerList) { +void GroupedScene::postInit(SceneObjectList *OwnerList) { _field794 = 0; _field412 = 1; SceneExt::postInit(OwnerList); } -void GameScene::remove() { +void GroupedScene::remove() { SceneExt::remove(); if (_field794 == 1) { for (SynchronizedList::iterator i = BF_GLOBALS._sceneObjects->begin(); diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index 762833be41..c4c1b22efd 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -137,6 +137,8 @@ public: void setup(SceneObject *object, int visage, int frameNum, int yDiff); }; +enum ExitFrame { EXITFRAME_NE = 2, EXITFRAME_E = 3 }; + class SceneExt: public Scene { private: void gunDisplay(); @@ -145,6 +147,7 @@ public: int _field372; int _field37A; EventHandler *_eventHandler; + Visage _cursorVisage; Rect _v51C34; public: @@ -162,12 +165,12 @@ public: void display(CursorType action); }; -class GameScene: public SceneExt { +class GroupedScene: public SceneExt { public: int _field412; int _field794; public: - GameScene(); + GroupedScene(); virtual void postInit(SceneObjectList *OwnerList = NULL); virtual void remove(); diff --git a/engines/tsage/blue_force/blueforce_scenes1.cpp b/engines/tsage/blue_force/blueforce_scenes1.cpp index 7cccb0d284..acb1592abc 100644 --- a/engines/tsage/blue_force/blueforce_scenes1.cpp +++ b/engines/tsage/blue_force/blueforce_scenes1.cpp @@ -346,11 +346,11 @@ void Scene109::Text::dispatch() { /*--------------------------------------------------------------------------*/ -Scene109::Scene109(): GameScene() { +Scene109::Scene109(): GroupedScene() { } void Scene109::postInit(SceneObjectList *OwnerList) { - GameScene::postInit(OwnerList); + GroupedScene::postInit(OwnerList); loadScene(999); _protaginist2.postInit(); @@ -427,6 +427,283 @@ void Scene109::signal() { } } +/*-------------------------------------------------------------------------- + * Scene 190 - Front of Police Station + * + *--------------------------------------------------------------------------*/ + +void Scene190::Object4::startAction(CursorType action) { + Scene190 *scene = (Scene190 *)BF_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: { + BF_GLOBALS._player.disableControl(); + scene->_sceneMode = 13; + Common::Point pt(62, 96); + PlayerMover *mover = new PlayerMover(); + BF_GLOBALS._player.addMover(mover, &pt, scene); + break; + } + default: + NamedObject::startAction(action); + break; + } +} + +/*--------------------------------------------------------------------------*/ + +void Scene190::Item1::startAction(CursorType action) { + Scene190 *scene = (Scene190 *)BF_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + scene->setAction(&scene->_action1); + break; + default: + NamedHotspot::startAction(action); + break; + } +} + +void Scene190::Item2::startAction(CursorType action) { + Scene190 *scene = (Scene190 *)BF_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + scene->_stripManager.start(1900, scene); + break; + default: + NamedHotspot::startAction(action); + break; + } +} + +void Scene190::Exit::startAction(CursorType action) { + Scene190 *scene = (Scene190 *)BF_GLOBALS._sceneManager._scene; + + Common::Point pt(316, 91); + PlayerMover *mover = new PlayerMover(); + BF_GLOBALS._player.addMover(mover, &pt, scene); +} + +/*--------------------------------------------------------------------------*/ + +void Scene190::Action1::signal() { + Scene190 *scene = (Scene190 *)BF_GLOBALS._sceneManager._scene; + + switch (_actionIndex++) { + case 0: + BF_GLOBALS._player.disableControl(); + setDelay(2); + break; + case 1: { + ADD_MOVER(BF_GLOBALS._player, 165, 91); + break; + } + case 2: + scene->_sound.play(82); + scene->_object2.animate(ANIM_MODE_5, this); + break; + case 3: + ADD_MOVER(BF_GLOBALS._player, 180, 86); + break; + case 4: + scene->_sound.play(82); + scene->_object2.animate(ANIM_MODE_6, this); + break; + case 5: + BF_GLOBALS._sound1.fadeOut2(NULL); + BF_GLOBALS._sceneManager.changeScene(315); + break; + } +} + +/*--------------------------------------------------------------------------*/ + +Scene190::Scene190(): SceneExt() { + _fieldB52 = true; + _cursorVisage.setVisage(1, 8); +} + +void Scene190::postInit(SceneObjectList *OwnerList) { + BF_GLOBALS._dialogCenter.y = 100; + if ((BF_GLOBALS._sceneManager._previousScene == 100) || + (BF_GLOBALS._sceneManager._previousScene == 20)) { +// clearScreen(); + } + if (BF_GLOBALS._dayNumber == 0) + // If at start of game, change to first day + BF_GLOBALS._dayNumber = 1; + + // Load the scene data + loadScene(190); + BF_GLOBALS._scenePalette.loadPalette(2); + + _stripManager.addSpeaker(&_speaker); + BF_GLOBALS._player.postInit(); + BF_GLOBALS._player.disableControl(); + + // Initialise objects + _object2.postInit(); + _object2.setVisage(190); + _object2.setStrip(1); + _object2.setPosition(Common::Point(179, 88)); + + _object3.postInit(); + _object3.setVisage(190); + _object3.setStrip(2); + _object3.fixPriority(200); + _object3.setPosition(Common::Point(170, 31)); + _object3.animate(ANIM_MODE_7, 0, NULL); + _object3.setup(190, 8, 26, 19, 1, NULL); + + if (BF_GLOBALS.getFlag(fWithLyle)) { + BF_GLOBALS._player.setVisage(303); + BF_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper()); + BF_GLOBALS._player.animate(ANIM_MODE_1, NULL); + BF_GLOBALS._player._moveDiff = Common::Point(3, 1); + + _object4.postInit(); + _object4.setVisage(444); + _object4.setFrame(2); + _object4.setPosition(Common::Point(54, 114)); + _object4.setup(190, -1, -1, -1, 1, NULL); + + switch (BF_GLOBALS._sceneManager._previousScene) { + case 300: { + _sceneMode = 12; + BF_GLOBALS._player.setPosition(Common::Point(316, 91)); + ADD_MOVER(BF_GLOBALS._player, 305, 91); + break; + } + case 315: + _sceneMode = 1901; + setAction(&_sequenceManager, this, 1901, &BF_GLOBALS._player, &_object2, NULL); + break; + case 50: + case 60: + default: + _fieldB52 = false; + BF_GLOBALS._player.setPosition(Common::Point(62, 96)); + BF_GLOBALS._player._strip = 3; + BF_GLOBALS._player.enableControl(); + break; + } + } else { + BF_GLOBALS._player.setVisage(BF_GLOBALS._player._visage); + BF_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper()); + BF_GLOBALS._player.animate(ANIM_MODE_1, NULL); + + switch (BF_GLOBALS._sceneManager._previousScene) { + case 300: { + if (!BF_GLOBALS.getFlag(onBike)) { + BF_GLOBALS._player._moveDiff = Common::Point(3, 1); + _sceneMode = BF_GLOBALS.getFlag(onDuty) ? 11 : 12; + BF_GLOBALS._player.setVisage(BF_GLOBALS.getFlag(onDuty) ? 1304 : 303); + BF_GLOBALS._player.setPosition(Common::Point(316, 91)); + ADD_MOVER(BF_GLOBALS._player, 305, 91); + } else { + BF_GLOBALS._player.disableControl(); + _sceneMode = BF_GLOBALS.getFlag(onDuty) ? 193 : 191; + setAction(&_sequenceManager, this, 193, &BF_GLOBALS._player, NULL); + } + break; + } + case 315: + BF_GLOBALS._player._moveDiff = Common::Point(3, 1); + _sceneMode = BF_GLOBALS.getFlag(onDuty) ? 1900 : 1901; + setAction(&_sequenceManager, this, _sceneMode, &BF_GLOBALS._player, &_object2, NULL); + break; + case 50: + case 60: + default: + BF_GLOBALS.setFlag(onBike); + BF_GLOBALS._player.disableControl(); + _sceneMode = BF_GLOBALS.getFlag(onDuty) ? 192 : 190; + setAction(&_sequenceManager, this, _sceneMode, &BF_GLOBALS._player, NULL); + break; + } + } + + if (BF_GLOBALS.getFlag(onBike)) { + BF_GLOBALS._sound1.play(BF_GLOBALS.getFlag(onDuty) ? 37 : 29); + } else if (BF_GLOBALS._sceneManager._previousScene != 300) { + BF_GLOBALS._sound1.play(33); + } + + _exit.setup(Rect(310, 50, 320, 125), 190, -1, -1, -1, 1, NULL); + _item2.setup(Rect(108, 1, 111, 94), 190, 7, 11, 18, 1, NULL); + _item4.setup(2, 190, 5, 10, 16, 1); + _item3.setup(1, 190, 4, 10, 15, 1); + _item8.setup(6, 190, 20, 21, 22, 1); + _item1.setup(7, 190, 1, 10, -1, 1); + _item7.setup(5, 190, 0, 10, 12, 1); + _item6.setup(4, 190, 2, 10, 13, 1); + _item5.setup(3, 190, 3, 10, 14, 1); + _item9.setup(Rect(0, 0, 89, 68), 190, 6, 10, 17, 1, NULL); + _item10.setup(Rect(0, 0, SCREEN_WIDTH, BF_INTERFACE_Y), 190, 23, -1, -1, 1, NULL); +} + +void Scene190::signal() { + switch (_sceneMode) { + case 10: + if ((BF_GLOBALS._dayNumber == 2) && (BF_GLOBALS._bookmark < bEndDayOne)) + BF_GLOBALS._sound1.changeSound(49); + BF_GLOBALS._sceneManager.changeScene(300); + break; + case 11: + case 12: + case 1900: + case 1901: + BF_GLOBALS._player.enableControl(); + _fieldB52 = false; + break; + case 13: + case 191: + case 193: + BF_GLOBALS._sceneManager.changeScene(60); + break; + case 190: + case 192: + BF_GLOBALS._sceneManager.changeScene(300); + break; + case 0: + default: + BF_GLOBALS._player.enableControl(); + break; + } +} + +void Scene190::process(Event &event) { + SceneExt::process(event); + + if (BF_GLOBALS._player._enabled && !_eventHandler && (event.mousePos.y < (BF_INTERFACE_Y - 1))) { + // Check if the cursor is on an exit + if (_exit.contains(event.mousePos)) { + GfxSurface surface = _cursorVisage.getFrame(3); + BF_GLOBALS._events.setCursor(surface); + } else { + // In case an exit cursor was being shown, restore the previously selected cursor + CursorType cursorId = BF_GLOBALS._events.getCursor(); + BF_GLOBALS._events.setCursor(cursorId); + } + } +} + +void Scene190::dispatch() { + SceneExt::dispatch(); + + if (!_action && !_fieldB52 && (BF_GLOBALS._player._position.x >= 310) + && !BF_GLOBALS.getFlag(onBike)) { + // Handle walking off to the right side of the screen + BF_GLOBALS._player.disableControl(); + _fieldB52 = true; + _sceneMode = 10; + + ADD_MOVER(BF_GLOBALS._player, 330, BF_GLOBALS._player._position.y); + } +} + } // End of namespace BlueForce } // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_scenes1.h b/engines/tsage/blue_force/blueforce_scenes1.h index 2b07e2b48f..3f4d1cb3d2 100644 --- a/engines/tsage/blue_force/blueforce_scenes1.h +++ b/engines/tsage/blue_force/blueforce_scenes1.h @@ -79,7 +79,7 @@ public: virtual void signal(); }; -class Scene109: public GameScene { +class Scene109: public GroupedScene { /* Actions */ class Action1: public Action { public: @@ -124,6 +124,58 @@ public: virtual void signal(); }; +class Scene190: public SceneExt { + /* Objects */ + class Object4: public NamedObject { + public: + virtual void startAction(CursorType action); + }; + + /* Items */ + class Item1: public NamedHotspot { + public: + virtual void startAction(CursorType action); + }; + class Item2: public NamedHotspot { + public: + virtual void startAction(CursorType action); + }; + class Exit: public NamedHotspot { + public: + virtual void startAction(CursorType action); + }; + + /* Actions */ + class Action1: public Action { + public: + virtual void signal(); + }; +public: + SequenceManager _sequenceManager; + FollowerObject _object1; + NamedObject _object2, _object3; + Object4 _object4; + Item1 _item1; + Item2 _item2; + NamedHotspot _item3, _item4, _item5, _item6; + NamedHotspot _item7, _item8, _item9, _item10; + Exit _exit; + Action1 _action1; + ASoundExt _sound; + SpeakerGameText _speaker; + bool _fieldB52; + + Scene190(); + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); + virtual void process(Event &event); + virtual void dispatch(); + virtual void synchronize(Serializer &s) { + SceneExt::synchronize(s); + s.syncAsSint16LE(_fieldB52); + } +}; + } // End of namespace BlueForce } // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_scenes3.cpp b/engines/tsage/blue_force/blueforce_scenes3.cpp index fd1e613d00..d9d7590c82 100644 --- a/engines/tsage/blue_force/blueforce_scenes3.cpp +++ b/engines/tsage/blue_force/blueforce_scenes3.cpp @@ -222,8 +222,6 @@ void Scene300::Action5::signal() { Scene300::Scene300(): SceneExt(), _object13(3000), _object14(3001), _object15(3002), _object16(3003) { _field2760 = _field2762 = 0; - - _cursorVisage.setVisage(1, 8); } void Scene300::postInit(SceneObjectList *OwnerList) { @@ -282,12 +280,6 @@ void Scene300::postInit(SceneObjectList *OwnerList) { _object11.setPosition(Common::Point(265, 91)); _object11.hide(); - //***DEBUG*** -BF_GLOBALS.setFlag(2); -BF_GLOBALS._sceneManager._previousScene = 315; // 190; -BF_GLOBALS._player.setVisage(190); -BF_GLOBALS._player.setStrip(1); - switch (BF_GLOBALS._sceneManager._previousScene) { case 50: case 60: @@ -526,11 +518,12 @@ void Scene300::process(Event &event) { SceneExt::process(event); if (BF_GLOBALS._player._enabled && !_eventHandler && (event.mousePos.y < (BF_INTERFACE_Y - 1))) { + // Check if the cursor is on an exit if (_item14.contains(event.mousePos)) { - GfxSurface surface = _cursorVisage.getFrame(2); + GfxSurface surface = _cursorVisage.getFrame(EXITFRAME_NE); BF_GLOBALS._events.setCursor(surface); } else if (_item15.contains(event.mousePos)) { - GfxSurface surface = _cursorVisage.getFrame(3); + GfxSurface surface = _cursorVisage.getFrame(EXITFRAME_E); BF_GLOBALS._events.setCursor(surface); } else { // In case an exit cursor was being shown, restore the previously selected cursor diff --git a/engines/tsage/blue_force/blueforce_scenes3.h b/engines/tsage/blue_force/blueforce_scenes3.h index 4acb424207..fba2d04478 100644 --- a/engines/tsage/blue_force/blueforce_scenes3.h +++ b/engines/tsage/blue_force/blueforce_scenes3.h @@ -97,7 +97,6 @@ private: public: SequenceManager _sequenceManager1, _sequenceManager2; SequenceManager _sequenceManager3, _sequenceManager4; - Visage _cursorVisage; NamedObject _object1; FollowerObject _object2, _object3, _object4, _object5, _object6, _object7; SceneObject _object8, _object9, _object10; diff --git a/engines/tsage/converse.cpp b/engines/tsage/converse.cpp index 615b1c36fd..af9bca238d 100644 --- a/engines/tsage/converse.cpp +++ b/engines/tsage/converse.cpp @@ -287,7 +287,7 @@ void SequenceManager::signal() { /* Following indexes were introduced for Blue Force */ case 35: v1 = getNextValue(); - _sceneObject->updateAngle(_objectList[v1]); + _sceneObject->updateAngle(_objectList[v1]->_position); break; case 36: _sceneObject->animate(ANIM_MODE_9, NULL); -- cgit v1.2.3 From edeff6c84931b8f7ec8b1fedfec8aaec3ecc6a3a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 Sep 2011 20:50:08 +1000 Subject: TSAGE: Added extra debugger command for showing available hotspot regions This is different from the hotspots command, since that only shows regions explicitly assigned to a hotspot --- engines/tsage/debugger.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++- engines/tsage/debugger.h | 1 + 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/engines/tsage/debugger.cpp b/engines/tsage/debugger.cpp index e3c4569dd2..2a6b4eb66b 100644 --- a/engines/tsage/debugger.cpp +++ b/engines/tsage/debugger.cpp @@ -32,6 +32,7 @@ Debugger::Debugger() : GUI::Debugger() { DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene)); DCmd_Register("walk_regions", WRAP_METHOD(Debugger, Cmd_WalkRegions)); DCmd_Register("priority_regions", WRAP_METHOD(Debugger, Cmd_PriorityRegions)); + DCmd_Register("scene_regions", WRAP_METHOD(Debugger, Cmd_SceneRegions)); DCmd_Register("setflag", WRAP_METHOD(Debugger, Cmd_SetFlag)); DCmd_Register("getflag", WRAP_METHOD(Debugger, Cmd_GetFlag)); DCmd_Register("clearflag", WRAP_METHOD(Debugger, Cmd_ClearFlag)); @@ -170,6 +171,59 @@ bool Debugger::Cmd_PriorityRegions(int argc, const char **argv) { return true; } +/* + * This command draws the scene regions onto the screen. These are the regions + * used by hotspots that have non-rectangular areas. + */ +bool Debugger::Cmd_SceneRegions(int argc, const char **argv) { + int regionNum = 0; + + // Check for an optional specific region to display + if (argc == 2) + regionNum = strToInt(argv[1]); + + // Color index to use for the first priority region + int color = 16; + int count = 0; + + // Lock the background surface for access + Graphics::Surface destSurface = _globals->_sceneManager._scene->_backSurface.lockSurface(); + + Common::List::iterator i = _globals->_sceneRegions.begin(); + Common::String regionsDesc; + + for (; i != _globals->_sceneRegions.end(); ++i, ++color, ++count) { + Region &r = *i; + + if ((regionNum == 0) || (regionNum == (count + 1))) { + for (int y = 0; y < destSurface.h; ++y) { + byte *destP = (byte *)destSurface.getBasePtr(0, y); + + for (int x = 0; x < destSurface.w; ++x) { + if (r.contains(Common::Point(_globals->_sceneManager._scene->_sceneBounds.left + x, + _globals->_sceneManager._scene->_sceneBounds.top + y))) + *destP = color; + ++destP; + } + } + } + + regionsDesc += Common::String::format("Region id = %d bounds=%d,%d,%d,%d\n", + r._regionId, r._bounds.left, r._bounds.top, r._bounds.right, r._bounds.bottom); + } + + // Release the surface + _globals->_sceneManager._scene->_backSurface.unlockSurface(); + + // Mark the scene as requiring a full redraw + _globals->_paneRefreshFlag[0] = 2; + + DebugPrintf("Total regions = %d\n", count); + DebugPrintf("%s", regionsDesc.c_str()); + + return true; +} + /* * This command sets a flag */ @@ -414,7 +468,7 @@ bool Debugger::Cmd_Hotspots(int argc, const char **argv) { if (ri != _globals->_sceneRegions.end()) { // Fill out the areas defined by the region Region &r = *ri; - + for (int y = r._bounds.top; y < r._bounds.bottom; ++y) { LineSliceSet set = r.getLineSlices(y); diff --git a/engines/tsage/debugger.h b/engines/tsage/debugger.h index 8bc1b06336..fcdbc2d243 100644 --- a/engines/tsage/debugger.h +++ b/engines/tsage/debugger.h @@ -37,6 +37,7 @@ protected: bool Cmd_Scene(int argc, const char **argv); bool Cmd_WalkRegions(int argc, const char **argv); bool Cmd_PriorityRegions(int argc, const char **argv); + bool Cmd_SceneRegions(int argc, const char **argv); bool Cmd_SetFlag(int argc, const char **argv); bool Cmd_GetFlag(int argc, const char **argv); bool Cmd_ClearFlag(int argc, const char **argv); -- cgit v1.2.3 From d43fbc8dfa0bf416cdba545525e67be9e5e2c46b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 Sep 2011 20:50:34 +1000 Subject: TSAGE: Fixed problem with NamedHotspot items not getting added to scenes --- engines/tsage/core.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index ad082d6f1b..21d5390f62 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1768,6 +1768,18 @@ void NamedHotspot::setup(int sceneRegionId, int resNum, int lookLineNum, int tal _lookLineNum = lookLineNum; _talkLineNum = talkLineNum; _useLineNum = useLineNum; + + // Handle adding hotspot to scene items list as necessary + switch (mode) { + case 2: + GLOBALS._sceneItems.push_front(this); + break; + case 3: + break; + default: + GLOBALS._sceneItems.push_back(this); + break; + } } void NamedHotspot::synchronize(Serializer &s) { -- cgit v1.2.3 From 862a4ca929ef82044601a4c2597d7f3bc69e70f8 Mon Sep 17 00:00:00 2001 From: Scott Thomas Date: Tue, 6 Sep 2011 21:59:24 +0930 Subject: GROOVIE: Remove dither code from ROQ --- engines/groovie/roq.cpp | 51 ------------------------------------------------- engines/groovie/roq.h | 11 ----------- 2 files changed, 62 deletions(-) diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 7f477c41fa..ca896a8d21 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -43,9 +43,6 @@ namespace Groovie { ROQPlayer::ROQPlayer(GroovieEngine *vm) : -#ifdef DITHER - _dither(NULL), -#endif VideoPlayer(vm), _codingTypeCount(0), _fg(&_vm->_graphicsMan->_foreground), _bg(&_vm->_graphicsMan->_background) { @@ -55,38 +52,13 @@ ROQPlayer::ROQPlayer(GroovieEngine *vm) : if (_vm->_mode8bit) { byte pal[256 * 3]; -#ifdef DITHER - // Initialize to a black palette - memset(pal, 0, 256 * 3); - - // Build a basic color palette - for (int r = 0; r < 4; r++) { - for (int g = 0; g < 4; g++) { - for (int b = 0; b < 4; b++) { - byte col = (r << 4) | (g << 2) | (b << 0); - pal[3 * col + 0] = r << 6; - pal[3 * col + 1] = g << 6; - pal[3 * col + 2] = b << 6; - } - } - } - - // Initialize the dithering algorithm - _paletteLookup = new Graphics::PaletteLUT(8, Graphics::PaletteLUT::kPaletteYUV); - _paletteLookup->setPalette(pal, Graphics::PaletteLUT::kPaletteRGB, 8); - for (int i = 0; (i < 64) && !_vm->shouldQuit(); i++) { - debug("Groovie::ROQ: Building palette table: %02d/63", i); - _paletteLookup->buildNext(); - } -#else // !DITHER // Set a grayscale palette for (int i = 0; i < 256; i++) { pal[(i * 3) + 0] = i; pal[(i * 3) + 1] = i; pal[(i * 3) + 2] = i; } -#endif // DITHER _syst->getPaletteManager()->setPalette(pal, 0, 256); } @@ -98,12 +70,6 @@ ROQPlayer::~ROQPlayer() { delete _currBuf; _prevBuf->free(); delete _prevBuf; - -#ifdef DITHER - // Free the dithering algorithm - delete _dither; - delete _paletteLookup; -#endif } uint16 ROQPlayer::loadInternal() { @@ -147,22 +113,13 @@ uint16 ROQPlayer::loadInternal() { } void ROQPlayer::buildShowBuf() { -#ifdef DITHER - // Start a new frame dithering - _dither->newFrame(); -#endif - for (int line = 0; line < _bg->h; line++) { byte *out = (byte *)_bg->getBasePtr(0, line); byte *in = (byte *)_currBuf->getBasePtr(0, line / _scaleY); for (int x = 0; x < _bg->w; x++) { if (_vm->_mode8bit) { -#ifdef DITHER - *out = _dither->dither(*in, *(in + 1), *(in + 2), x); -#else // Just use the luminancy component *out = *in; -#endif // DITHER #ifdef USE_RGB_COLOR } else { // Do the format conversion (YUV -> RGB -> Screen format) @@ -178,9 +135,6 @@ void ROQPlayer::buildShowBuf() { if (!(x % _scaleX)) in += _currBuf->format.bytesPerPixel; } -#ifdef DITHER - _dither->nextLine(); -#endif } // Swap buffers @@ -349,11 +303,6 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) { *ptr2++ = 128; } -#ifdef DITHER - // Reset the dithering algorithm with the new width - delete _dither; - _dither = new Graphics::SierraLight(width * _scaleX, _paletteLookup); -#endif } return true; diff --git a/engines/groovie/roq.h b/engines/groovie/roq.h index ddb307065c..c5d3f255d3 100644 --- a/engines/groovie/roq.h +++ b/engines/groovie/roq.h @@ -25,12 +25,6 @@ #include "groovie/player.h" -//#define DITHER - -#ifdef DITHER -#include "graphics/dither.h" -#endif - namespace Groovie { class GroovieEngine; @@ -89,11 +83,6 @@ private: bool _dirty; byte _alpha; -#ifdef DITHER - // Dithering - Graphics::PaletteLUT *_paletteLookup; - Graphics::SierraLight *_dither; -#endif }; } // End of Groovie namespace -- cgit v1.2.3 From b92a087857d91ffc4299acdbcdf323c5a8400248 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 6 Sep 2011 14:33:50 +0200 Subject: GOB: Remove unused include. --- engines/gob/inter_v6.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/gob/inter_v6.cpp b/engines/gob/inter_v6.cpp index 589328dfdb..505993ee4d 100644 --- a/engines/gob/inter_v6.cpp +++ b/engines/gob/inter_v6.cpp @@ -21,7 +21,6 @@ */ #include "common/str.h" -#include "graphics/dither.h" #include "gob/gob.h" #include "gob/inter.h" -- cgit v1.2.3 From 1d412ff7f736f890bef62ebba18c23751728235e Mon Sep 17 00:00:00 2001 From: Scott Thomas Date: Tue, 6 Sep 2011 22:31:52 +0930 Subject: NEWS: Mention T7G iOS support --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 1f62960d44..29230561ba 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ For a more comprehensive changelog of the latest experimental code, see: - Implemented support for loading data directly from InstallShield cabinets in The Feeble Files and Simon the Sorcerer's Puzzle Pack. + Groovie: + - Added support for the iOS version of The 7th Guest. + SCUMM: - Implemented PC Speaker support for SCUMM v5 games. - Fixed priority bug in iMuse. As a result the AdLib music should sound -- cgit v1.2.3 From 3bcc4ce1fdd22de41a2e772f8dedcb17c4a48347 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 16:41:54 +0200 Subject: DREAMWEB: 'useroutine' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 86 ------------------- engines/dreamweb/dreamgen.h | 4 +- engines/dreamweb/module.mk | 1 + engines/dreamweb/stubs.h | 1 + engines/dreamweb/use.cpp | 169 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 173 insertions(+), 89 deletions(-) create mode 100644 engines/dreamweb/use.cpp diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index bf0f1343ae..78c2bb6418 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -191,6 +191,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'showryanpage', 'findallryan', 'fillryan', + 'useroutine', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 6e56a68369..958476512d 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -8162,91 +8162,6 @@ douse: useroutine(); } -void DreamGenContext::useroutine() { - STACK_CHECK; - _cmp(data.byte(kReallocation), 50); - if (flags.c()) - goto nodream7; - _cmp(data.byte(kPointerpower), 0); - if (!flags.z()) - goto powerok; - return; -powerok: - data.byte(kPointerpower) = 0; -nodream7: - getanyad(); - dx = data; - ds = dx; - si = offset_uselist; -checkuselist: - push(si); - _lodsb(); - _sub(al, 'A'); - _cmp(al, es.byte(bx+12)); - if (!flags.z()) - goto failed; - _lodsb(); - _sub(al, 'A'); - _cmp(al, es.byte(bx+13)); - if (!flags.z()) - goto failed; - _lodsb(); - _sub(al, 'A'); - _cmp(al, es.byte(bx+14)); - if (!flags.z()) - goto failed; - _lodsb(); - _sub(al, 'A'); - _cmp(al, es.byte(bx+15)); - if (!flags.z()) - goto failed; - _lodsw(); - si = pop(); - __dispatch_call(ax); - return; -failed: - si = pop(); - _add(si, 6); - _cmp(ds.byte(si), 140); - if (!flags.z()) - goto checkuselist; - delpointer(); - getobtextstart(); - findnextcolon(); - _cmp(al, 0); - if (flags.z()) - goto cantuse2; - findnextcolon(); - _cmp(al, 0); - if (flags.z()) - goto cantuse2; - al = es.byte(si); - _cmp(al, 0); - if (flags.z()) - goto cantuse2; - usetext(); - cx = 400; - hangonp(); - putbackobstuff(); - return; -cantuse2: - createpanel(); - showpanel(); - showman(); - showexit(); - obicons(); - di = 33; - bx = 100; - al = 63; - dl = 241; - printmessage(); - worktoscreenm(); - cx = 50; - hangonp(); - putbackobstuff(); - data.byte(kCommandtype) = 255; -} - void DreamGenContext::wheelsound() { STACK_CHECK; al = 17; @@ -17326,7 +17241,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_printcurs: printcurs(); break; case addr_delcurs: delcurs(); break; case addr_useobject: useobject(); break; - case addr_useroutine: useroutine(); break; case addr_wheelsound: wheelsound(); break; case addr_runtap: runtap(); break; case addr_playguitar: playguitar(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 42beacb6f1..34c2ed9c5c 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -368,7 +368,6 @@ public: static const uint16 addr_playguitar = 0xc590; static const uint16 addr_runtap = 0xc58c; static const uint16 addr_wheelsound = 0xc588; - static const uint16 addr_useroutine = 0xc584; static const uint16 addr_useobject = 0xc580; static const uint16 addr_delcurs = 0xc57c; static const uint16 addr_printcurs = 0xc578; @@ -642,7 +641,6 @@ public: static const uint16 offset_openchangesize = 0x0a1c; static const uint16 offset_keys = 0x0b14; static const uint16 offset_mainlist2 = 0x1440; - static const uint16 offset_uselist = 0x0ba8; static const uint16 offset_gameerror2 = 0x0fb2; static const uint16 offset_loadlist = 0x0ef0; static const uint16 offset_gameerror6 = 0x10be; @@ -1817,7 +1815,7 @@ public: //void turnanypathon(); void restorereels(); void setwalk(); - void useroutine(); + //void useroutine(); void zoomicon(); //void findlen(); void findpathofpoint(); diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk index bdacbe79f3..8cacbdc91e 100644 --- a/engines/dreamweb/module.mk +++ b/engines/dreamweb/module.mk @@ -11,6 +11,7 @@ MODULE_OBJS := \ saveload.o \ sprite.o \ stubs.o \ + use.o \ vgagrafx.o # This module can be built as a plugin diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index a2d25b905c..fc92e5744f 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -230,4 +230,5 @@ void findallryan(); void findallryan(uint8 *inv); void fillryan(); + void useroutine(); diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp new file mode 100644 index 0000000000..237c8d4fad --- /dev/null +++ b/engines/dreamweb/use.cpp @@ -0,0 +1,169 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "dreamweb/dreamweb.h" + +namespace DreamGen { + + +typedef void (DreamGenContext::*UseCallback)(void); + +struct UseListEntry { + uint8 id[5]; // 0-terminal because it is easier syntatically to initialize the array + UseCallback callback; +}; + +void DreamGenContext::useroutine() { + + static const UseListEntry kUseList[] = { + { "NETW", &DreamGenContext::usemon }, + { "ELVA", &DreamGenContext::useelevator1 }, + { "ELVB", &DreamGenContext::useelevator2 }, + { "ELVC", &DreamGenContext::useelevator3 }, + { "ELVE", &DreamGenContext::useelevator4 }, + { "ELVF", &DreamGenContext::useelevator5 }, + { "CGAT", &DreamGenContext::usechurchgate }, + { "REMO", &DreamGenContext::usestereo }, + { "BUTA", &DreamGenContext::usebuttona }, + { "CBOX", &DreamGenContext::usewinch }, + { "LITE", &DreamGenContext::uselighter }, + { "PLAT", &DreamGenContext::useplate }, + { "LIFT", &DreamGenContext::usecontrol }, + { "WIRE", &DreamGenContext::usewire }, + { "HNDL", &DreamGenContext::usehandle }, + { "HACH", &DreamGenContext::usehatch }, + { "DOOR", &DreamGenContext::useelvdoor }, + { "CSHR", &DreamGenContext::usecashcard }, + { "GUNA", &DreamGenContext::usegun }, + { "CRAA", &DreamGenContext::usecardreader1 }, + { "CRBB", &DreamGenContext::usecardreader2 }, + { "CRCC", &DreamGenContext::usecardreader3 }, + { "SEAT", &DreamGenContext::sitdowninbar }, + { "MENU", &DreamGenContext::usemenu }, + { "COOK", &DreamGenContext::usecooker }, + { "ELCA", &DreamGenContext::callhotellift }, + { "EDCA", &DreamGenContext::calledenslift }, + { "DDCA", &DreamGenContext::calledensdlift }, + { "ALTR", &DreamGenContext::usealtar }, + { "LOKA", &DreamGenContext::openhoteldoor }, + { "LOKB", &DreamGenContext::openhoteldoor2 }, + { "ENTA", &DreamGenContext::openlouis }, + { "ENTB", &DreamGenContext::openryan }, + { "ENTE", &DreamGenContext::openpoolboss }, + { "ENTC", &DreamGenContext::openyourneighbour }, + { "ENTD", &DreamGenContext::openeden }, + { "ENTH", &DreamGenContext::opensarters }, + { "WWAT", &DreamGenContext::wearwatch }, + { "POOL", &DreamGenContext::usepoolreader }, + { "WSHD", &DreamGenContext::wearshades }, + { "GRAF", &DreamGenContext::grafittidoor }, + { "TRAP", &DreamGenContext::trapdoor }, + { "CDPE", &DreamGenContext::edenscdplayer }, + { "DLOK", &DreamGenContext::opentvdoor }, + { "HOLE", &DreamGenContext::usehole }, + { "DRYR", &DreamGenContext::usedryer }, + { "HOLY", &DreamGenContext::usechurchhole }, + { "WALL", &DreamGenContext::usewall }, + { "BOOK", &DreamGenContext::usediary }, + { "AXED", &DreamGenContext::useaxe }, + { "SHLD", &DreamGenContext::useshield }, + { "BCNY", &DreamGenContext::userailing }, + { "LIDC", &DreamGenContext::usecoveredbox }, + { "LIDU", &DreamGenContext::useclearbox }, + { "LIDO", &DreamGenContext::useopenbox }, + { "PIPE", &DreamGenContext::usepipe }, + { "BALC", &DreamGenContext::usebalcony }, + { "WIND", &DreamGenContext::usewindow }, + { "PAPR", &DreamGenContext::viewfolder }, + { "UWTA", &DreamGenContext::usetrainer }, + { "UWTB", &DreamGenContext::usetrainer }, + { "STAT", &DreamGenContext::entersymbol }, + { "TLID", &DreamGenContext::opentomb }, + { "SLAB", &DreamGenContext::useslab }, + { "CART", &DreamGenContext::usecart }, + { "FCAR", &DreamGenContext::usefullcart }, + { "SLBA", &DreamGenContext::slabdoora }, + { "SLBB", &DreamGenContext::slabdoorb }, + { "SLBC", &DreamGenContext::slabdoorc }, + { "SLBD", &DreamGenContext::slabdoord }, + { "SLBE", &DreamGenContext::slabdoore }, + { "SLBF", &DreamGenContext::slabdoorf }, + { "PLIN", &DreamGenContext::useplinth }, + { "LADD", &DreamGenContext::useladder }, + { "LADB", &DreamGenContext::useladderb }, + { "GUMA", &DreamGenContext::chewy }, + { "SQEE", &DreamGenContext::wheelsound }, + { "TAPP", &DreamGenContext::runtap }, + { "GUIT", &DreamGenContext::playguitar }, + { "CONT", &DreamGenContext::hotelcontrol }, + { "BELL", &DreamGenContext::hotelbell }, + }; + + if (data.byte(kReallocation) >= 50) { + if (data.byte(kPointerpower) == 0) + return; + data.byte(kPointerpower) = 0; + } + + getanyad(); + const uint8 *id = es.ptr(bx + 12, 4); + + for (size_t i = 0; i < sizeof(kUseList)/sizeof(UseListEntry); ++i) { + const UseListEntry &entry = kUseList[i]; + if (('A' + id[0] == entry.id[0]) && ('A' + id[1] == entry.id[1]) && ('A' + id[2] == entry.id[2]) && ('A' + id[3] == entry.id[3])) { + (this->*entry.callback)(); + return; + } + } + + delpointer(); + getobtextstart(); + findnextcolon(); + if (al != 0) { + findnextcolon(); + if (al != 0) { + al = es.byte(si); + if (al != 0) { + usetext(); + cx = 400; + hangonp(); + putbackobstuff(); + return; + } + } + } + + createpanel(); + showpanel(); + showman(); + showexit(); + obicons(); + printmessage(33, 100, 63, 241, true); + worktoscreenm(); + cx = 50; + hangonp(); + putbackobstuff(); + data.byte(kCommandtype) = 255; +} + +} /*namespace dreamgen */ + -- cgit v1.2.3 From d9d366dbc9c2535949bb9b70ab472e73564c8f0d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 6 Sep 2011 16:51:04 +0200 Subject: GRAPHICS: Remove dithering code. The code is not used anymore and neither the Mohawk developers, who expressed that they might need dithering for some games, nor DrMcCoy, who wrote it, need this code anymore. In the worst case if anyone needs it again, we can revert this commit. --- graphics/dither.cpp | 313 ---------------------------------------------------- graphics/dither.h | 195 -------------------------------- graphics/module.mk | 1 - 3 files changed, 509 deletions(-) delete mode 100644 graphics/dither.cpp delete mode 100644 graphics/dither.h diff --git a/graphics/dither.cpp b/graphics/dither.cpp deleted file mode 100644 index 3876db152b..0000000000 --- a/graphics/dither.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "graphics/dither.h" - -#include "common/endian.h" -#include "common/stream.h" - -namespace Graphics { - -PaletteLUT::PaletteLUT(byte depth, PaletteFormat format) { - assert((depth > 1) && (depth < 9)); - - // For adjusting depth - _depth1 = depth; - _depth2 = 2 * _depth1; - _shift = 8 - _depth1; - - // The table's dimensions - _dim1 = (1 << _depth1); - _dim2 = _dim1 * _dim1; - _dim3 = _dim1 * _dim1 * _dim1; - - _format = format; - - // What's already built - _got = _dim1; - _gots = new byte[_dim1]; - - // The lookup table - _lut = new byte[_dim3]; - - memset(_lutPal, 0, 768); - memset(_realPal, 0, 768); - memset(_gots, 1, _dim1); -} - -void PaletteLUT::setPalette(const byte *palette, PaletteFormat format, - byte depth, int transp) { - - assert((depth > 1) && (depth < 9)); - - _transp = transp; - - int shift = 8 - depth; - - // Checking for the table's and the palette's pixel format - if ((_format == kPaletteRGB) && (format == kPaletteYUV)) { - byte *newPal = _realPal; - const byte *oldPal = palette; - for (int i = 0; i < 256; i++, newPal += 3, oldPal += 3) - YUV2RGB(oldPal[0] << shift, oldPal[1] << shift, oldPal[2] << shift, - newPal[0], newPal[1], newPal[2]); - } else if ((_format == kPaletteYUV) && (format == kPaletteRGB)) { - byte *newPal = _realPal; - const byte *oldPal = palette; - for (int i = 0; i < 256; i++, newPal += 3, oldPal += 3) - RGB2YUV(oldPal[0] << shift, oldPal[1] << shift, oldPal[2] << shift, - newPal[0], newPal[1], newPal[2]); - } else - memcpy(_realPal, palette, 768); - - // Using the specified depth for the lookup - byte *newPal = _lutPal, *oldPal = _realPal; - for (int i = 0; i < 768; i++) - *newPal++ = (*oldPal++) >> _shift; - - // Everything has to be rebuilt - _got = 0; - memset(_gots, 0, _dim1); -} - -PaletteLUT::~PaletteLUT() { - delete[] _lut; - delete[] _gots; -} - -void PaletteLUT::buildNext() { - if (_got >= _dim1) - return; - - build(_got++); -} - -#define SQR(x) ((x) * (x)) -// Building one "slice" -void PaletteLUT::build(int d1) { - // First dimension - byte *lut = _lut + d1 * _dim2; - - // Second dimension - for (uint32 j = 0; j < _dim1; j++) { - // Third dimension - for (uint32 k = 0; k < _dim1; k++) { - const byte *p = _lutPal; - uint32 d = 0xFFFFFFFF; - byte n = 0; - - // Going over every palette entry, searching for the closest - for (int c = 0; c < 256; c++, p += 3) { - // Ignore the transparent color - if (c == _transp) - continue; - - uint32 di = SQR(d1 - p[0]) + SQR(j - p[1]) + SQR(k - p[2]); - if (di < d) { - d = di; - n = c; - if (d == 0) - break; - } - } - - *lut++ = n; - } - } - - // Got this slice now - _gots[d1] = 1; -} - -inline int PaletteLUT::getIndex(byte c1, byte c2, byte c3) const { - return ((c1 >> _shift) << _depth2) | ((c2 >> _shift) << _depth1) | (c3 >> _shift); -} - -void PaletteLUT::getEntry(byte index, byte &c1, byte &c2, byte &c3) const { - c1 = _realPal[index * 3 + 0]; - c2 = _realPal[index * 3 + 1]; - c3 = _realPal[index * 3 + 2]; -} - -byte PaletteLUT::findNearest(byte c1, byte c2, byte c3) { - return _lut[getIndex(c1, c2, c3)]; -} - -byte PaletteLUT::findNearest(byte c1, byte c2, byte c3, byte &nC1, byte &nC2, byte &nC3) { - // If we don't have the required "slice" yet, build it - if (!_gots[c1 >> _shift]) - build(c1 >> _shift); - - int palIndex = _lut[getIndex(c1, c2, c3)]; - int i = palIndex * 3; - - nC1 = _realPal[i + 0]; - nC2 = _realPal[i + 1]; - nC3 = _realPal[i + 2]; - - return palIndex; -} - -bool PaletteLUT::save(Common::WriteStream &stream) { - // The table has to be completely built before we can save - while (_got < _dim1) - buildNext(); - - stream.writeUint32BE(MKTAG('P','L','U','T')); // Magic - stream.writeUint32BE(kVersion); - stream.writeByte(_depth1); - if (stream.write(_realPal, 768) != 768) - return false; - if (stream.write(_lutPal, 768) != 768) - return false; - if (stream.write(_lut, _dim3) != _dim3) - return false; - if (!stream.flush()) - return false; - - if (stream.err()) - return false; - - return true; -} - -bool PaletteLUT::load(Common::SeekableReadStream &stream) { - // _realPal + _lutPal + _lut + _depth1 + magic + version - int32 needSize = 768 + 768 + _dim3 + 1 + 4 + 4; - - if ((stream.size() - stream.pos()) < needSize) - return false; - - // Magic - if (stream.readUint32BE() != MKTAG('P','L','U','T')) - return false; - - if (stream.readUint32BE() != kVersion) - return false; - - byte depth1 = stream.readByte(); - - if (depth1 != _depth1) - return false; - - if (stream.read(_realPal, 768) != 768) - return false; - if (stream.read(_lutPal, 768) != 768) - return false; - if (stream.read(_lut, _dim3) != _dim3) - return false; - - _got = _dim1; - memset(_gots, 1, _dim1); - - return true; -} - -SierraLight::SierraLight(int16 width, PaletteLUT *palLUT) { - assert(width > 0); - - _width = width; - _palLUT = palLUT; - - // Big buffer for the errors of the current and next line - _errorBuf = new int32[3 * (2 * (_width + 2*1))]; - memset(_errorBuf, 0, (3 * (2 * (_width + 2*1))) * sizeof(int32)); - - _curLine = 0; - _errors[0] = _errorBuf + 3; - _errors[1] = _errors[0] + 3 * (_width + 2*1); -} - -SierraLight::~SierraLight() { - delete[] _errorBuf; -} - -void SierraLight::newFrame() { - _curLine = 0; - memset(_errors[0], 0, 3 * _width * sizeof(int32)); - memset(_errors[1], 0, 3 * _width * sizeof(int32)); -} - -void SierraLight::nextLine() { - // Clear the finished line, it will become the last line in the buffer - memset(_errors[_curLine], 0, 3 * _width * sizeof(int32)); - - _curLine = (_curLine + 1) % 2; -} - -byte SierraLight::dither(byte c1, byte c2, byte c3, uint32 x) { - assert(_palLUT); - assert(x < (uint32)_width); - - int32 eC1, eC2, eC3; - - getErrors(x, eC1, eC2, eC3); - - // Apply error on values - c1 = CLIP(c1 + eC1, 0, 255); - c2 = CLIP(c2 + eC2, 0, 255); - c3 = CLIP(c3 + eC3, 0, 255); - - // Find color - byte newC1, newC2, newC3; - byte newPixel = _palLUT->findNearest(c1, c2, c3, newC1, newC2, newC3); - - // Calculate new error - eC1 = c1 - newC1; - eC2 = c2 - newC2; - eC3 = c3 - newC3; - - // Add them - addErrors(x, eC1, eC2, eC3); - - return newPixel; -} - -inline void SierraLight::getErrors(uint32 x, int32 &eC1, int32 &eC2, int32 &eC3) { - int32 *errCur = _errors[_curLine]; - - x *= 3; - eC1 = errCur[x + 0] >> 2; - eC2 = errCur[x + 1] >> 2; - eC3 = errCur[x + 2] >> 2; -} - -inline void SierraLight::addErrors(uint32 x, int32 eC1, int32 eC2, int32 eC3) { - int32 *errCur = _errors[_curLine]; - int32 *errNext = _errors[(_curLine + 1) % 2]; - - // Indices for current error - int x0 = 3 * (x + 1); - int x1 = 3 * (x + 0); - int x2 = 3 * (x - 1); - - errCur [x0 + 0] += eC1 << 1; - errCur [x0 + 1] += eC2 << 1; - errCur [x0 + 2] += eC3 << 1; - errNext[x1 + 0] += eC1; - errNext[x1 + 1] += eC2; - errNext[x1 + 2] += eC3; - errNext[x2 + 0] += eC1; - errNext[x2 + 1] += eC2; - errNext[x2 + 2] += eC3; -} - -} // End of namespace Graphics diff --git a/graphics/dither.h b/graphics/dither.h deleted file mode 100644 index dbde03df82..0000000000 --- a/graphics/dither.h +++ /dev/null @@ -1,195 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef GRAPHICS_DITHER_H -#define GRAPHICS_DITHER_H - -#include "common/util.h" - -namespace Common { -class SeekableReadStream; -class WriteStream; -} - -namespace Graphics { - -/** A palette lookup table to find the nearest matching entry of a fixed palette to a true color. - * - * The table can be build up in slices, one slice consisting of all entries for - * one value of the first color component. - */ -class PaletteLUT { -public: - /** Palette format. */ - enum PaletteFormat { - kPaletteRGB, ///< Palette in RGB colorspace - kPaletteYUV ///< Palette in YUV colorspace - }; - - /** Converting a color from YUV to RGB colorspace. */ - inline static void YUV2RGB(byte y, byte u, byte v, byte &r, byte &g, byte &b) { - r = CLIP(y + ((1357 * (v - 128)) >> 10), 0, 255); - g = CLIP(y - (( 691 * (v - 128)) >> 10) - ((333 * (u - 128)) >> 10), 0, 255); - b = CLIP(y + ((1715 * (u - 128)) >> 10), 0, 255); - } - /** Converting a color from RGB to YUV colorspace. */ - inline static void RGB2YUV(byte r, byte g, byte b, byte &y, byte &u, byte &v) { - y = CLIP( ((r * 306) >> 10) + ((g * 601) >> 10) + ((b * 117) >> 10) , 0, 255); - u = CLIP(-((r * 172) >> 10) - ((g * 340) >> 10) + ((b * 512) >> 10) + 128, 0, 255); - v = CLIP( ((r * 512) >> 10) - ((g * 429) >> 10) - ((b * 83) >> 10) + 128, 0, 255); - } - - /** Create a lookup table of a given depth and palette format. - * - * @param depth How many bits of each color component to consider. - * @param format The format the palette should be in. - */ - PaletteLUT(byte depth, PaletteFormat format); - ~PaletteLUT(); - - /** Setting a palette. - * - * Any already built slices will be purged. - * - * @param palette The palette, plain 256 * 3 color components. - * @param format The format the palette is in. - * @param depth The number of significant bits in each color component. - * @param transp An index that's seen as transparent and therefore ignored. - */ - void setPalette(const byte *palette, PaletteFormat format, byte depth, int transp = -1); - - /** Build the next slice. - * - * This will build the next slice, if any. - */ - void buildNext(); - - /** Querying the color components to a given palette entry index. */ - void getEntry(byte index, byte &c1, byte &c2, byte &c3) const; - /** Finding the nearest matching entry. - * - * @param c1 The first component of the wanted color. - * @param c2 The second component of the wanted color. - * @param c3 The third component of the wanted color. - * @return The palette entry matching the wanted color best. - */ - byte findNearest(byte c1, byte c2, byte c3); - /** Finding the nearest matching entry, together with its color components. - * - * @param c1 The first component of the wanted color. - * @param c2 The second component of the wanted color. - * @param c3 The third component of the wanted color. - * @paran nC1 The first component of the found color. - * @paran nC2 The second component of the found color. - * @paran nC3 The third component of the found color. - * @return The palette entry matching the wanted color best. - */ - byte findNearest(byte c1, byte c2, byte c3, byte &nC1, byte &nC2, byte &nC3); - - /** Save the table to a stream. - * - * This will build the whole table first. - */ - bool save(Common::WriteStream &stream); - /** Load the table from a stream. */ - bool load(Common::SeekableReadStream &stream); - -private: - static const uint32 kVersion = 1; - - byte _depth1; ///< The table's depth for one dimension. - byte _depth2; ///< The table's depth for two dimensions. - byte _shift; ///< Amount to shift to adjust for the table's depth. - - uint32 _dim1; ///< The table's entry offset for one dimension. - uint32 _dim2; ///< The table's entry offset for two dimensions. - uint32 _dim3; ///< The table's entry offset for three dimensions. - - int _transp; ///< The transparent palette index. - - PaletteFormat _format; ///< The table's palette format. - byte _lutPal[768]; ///< The palette used for looking up a color. - byte _realPal[768]; ///< The original palette. - - uint32 _got; ///< Number of slices generated. - byte *_gots; ///< Map of generated slices. - byte *_lut; ///< The lookup table. - - /** Building a specified slice. */ - void build(int d1); - /** Calculates the index into the lookup table for a given color. */ - inline int getIndex(byte c1, byte c2, byte c3) const; -}; - -/** The Sierra-2-4A ("Filter Light") error distribution dithering algorithm. - * - * The image will be dithered line by line and pixel by pixel, without earlier - * values having to be changed. -*/ -class SierraLight { -public: - /** Constructor. - * - * @param width The width of the image to dither. - * @param palLUT The palette to which to dither. - */ - SierraLight(int16 width, PaletteLUT *palLUT); - ~SierraLight(); - - /** Signals that a new frame or image is about to be dithered. - * - * This clears all collected errors, so that a new image (of the same - * height and with the same palette) can be dithered. - */ - void newFrame(); - /** Signals that a new line is about the begin. - * - * The current line's errors will be forgotten and values collected for the - * next line will now count as the current line's. - */ - void nextLine(); - /** Dither a pixel. - * - * @param c1 The first color component of the pixel. - * @param c2 The second color component of the pixel. - * @param c3 The third color component of the pixel. - * @param x The pixel's x coordinate within the image. - */ - byte dither(byte c1, byte c2, byte c3, uint32 x); - -protected: - int16 _width; ///< The image's width. - - PaletteLUT *_palLUT; ///< The palette against which to dither. - - int32 *_errorBuf; ///< Big buffer for all collected errors. - int32 *_errors[2]; ///< Pointers into the error buffer for two lines. - int _curLine; ///< Which one is the current line? - - /** Querying a pixel's errors. */ - inline void getErrors(uint32 x, int32 &eC1, int32 &eC2, int32 &eC3); - /** Adding a pixel's errors. */ - inline void addErrors(uint32 x, int32 eC1, int32 eC2, int32 eC3); -}; - -} // End of namespace Graphics - -#endif diff --git a/graphics/module.mk b/graphics/module.mk index 469ee42047..02c88d98ba 100644 --- a/graphics/module.mk +++ b/graphics/module.mk @@ -3,7 +3,6 @@ MODULE := graphics MODULE_OBJS := \ conversion.o \ cursorman.o \ - dither.o \ font.o \ fontman.o \ fonts/bdf.o \ -- cgit v1.2.3 From b94cce639d6466cb24ab19cca5b1964648b02567 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 6 Sep 2011 22:10:02 +0200 Subject: DREAMWEB: 'hangon' and 'hangonp' ported to C++ --- devtools/tasmrecover/tasm-recover | 2 ++ engines/dreamweb/dreamgen.cpp | 59 --------------------------------------- engines/dreamweb/dreamgen.h | 8 ++---- engines/dreamweb/stubs.cpp | 52 +++++++++++++++++++++++++++++++--- engines/dreamweb/stubs.h | 5 ++++ engines/dreamweb/use.cpp | 6 ++-- 6 files changed, 60 insertions(+), 72 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 78c2bb6418..7b317e45a1 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -192,6 +192,8 @@ generator = cpp(context, "DreamGen", blacklist = [ 'findallryan', 'fillryan', 'useroutine', + 'hangon', + 'hangonp', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 958476512d..068f3fcff3 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -15242,53 +15242,6 @@ void DreamGenContext::allpointer() { dumppointer(); } -void DreamGenContext::hangonp() { - STACK_CHECK; - push(cx); - _add(cx, cx); - ax = pop(); - _add(cx, ax); - data.word(kMaintimer) = 0; - al = data.byte(kPointerframe); - ah = data.byte(kPickup); - push(ax); - data.byte(kPointermode) = 3; - data.byte(kPickup) = 0; - push(cx); - data.byte(kCommandtype) = 255; - readmouse(); - animpointer(); - showpointer(); - vsync(); - dumppointer(); - cx = pop(); -hangloop: - push(cx); - delpointer(); - readmouse(); - animpointer(); - showpointer(); - vsync(); - dumppointer(); - cx = pop(); - ax = data.word(kMousebutton); - _cmp(ax, 0); - if (flags.z()) - goto notpressed; - _cmp(ax, data.word(kOldbutton)); - if (!flags.z()) - goto getoutofit; -notpressed: - if (--cx) - goto hangloop; -getoutofit: - delpointer(); - ax = pop(); - data.byte(kPointerframe) = al; - data.byte(kPickup) = ah; - data.byte(kPointermode) = 0; -} - void DreamGenContext::hangonw() { STACK_CHECK; hangloopw: @@ -15415,16 +15368,6 @@ void DreamGenContext::randomnum2() { ds = pop(); } -void DreamGenContext::hangon() { - STACK_CHECK; -hangonloop: - push(cx); - vsync(); - cx = pop(); - if (--cx) - goto hangonloop; -} - void DreamGenContext::loadtraveltext() { STACK_CHECK; dx = 2234; @@ -17521,7 +17464,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_worktoscreenm: worktoscreenm(); break; case addr_blank: blank(); break; case addr_allpointer: allpointer(); break; - case addr_hangonp: hangonp(); break; case addr_hangonw: hangonw(); break; case addr_hangoncurs: hangoncurs(); break; case addr_getunderzoom: getunderzoom(); break; @@ -17533,7 +17475,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_readkey: readkey(); break; case addr_randomnum1: randomnum1(); break; case addr_randomnum2: randomnum2(); break; - case addr_hangon: hangon(); break; case addr_loadtraveltext: loadtraveltext(); break; case addr_loadintotemp: loadintotemp(); break; case addr_loadintotemp2: loadintotemp2(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 34c2ed9c5c..6db6f73048 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -74,7 +74,6 @@ public: static const uint16 addr_loadintotemp2 = 0xcb1c; static const uint16 addr_loadintotemp = 0xcb18; static const uint16 addr_loadtraveltext = 0xcb14; - static const uint16 addr_hangon = 0xcb10; static const uint16 addr_randomnum2 = 0xcb08; static const uint16 addr_randomnum1 = 0xcb04; static const uint16 addr_readkey = 0xcafc; @@ -86,7 +85,6 @@ public: static const uint16 addr_getunderzoom = 0xcab4; static const uint16 addr_hangoncurs = 0xcab0; static const uint16 addr_hangonw = 0xcaac; - static const uint16 addr_hangonp = 0xcaa8; static const uint16 addr_allpointer = 0xcaa4; static const uint16 addr_blank = 0xcaa0; static const uint16 addr_worktoscreenm = 0xca9c; @@ -1713,7 +1711,7 @@ public: void initialinv(); void quitsymbol(); //void modifychar(); - void hangon(); + //void initman(); void settopright(); void findsetobject(); void singlekey(); @@ -1832,7 +1830,7 @@ public: void read(); void fadescreenups(); //void checkdest(); - //void initman(); + //void hangon(); void loadpalfromiff(); //void facerightway(); void startup1(); @@ -1959,7 +1957,7 @@ public: void parser(); void hangonw(); void intro(); - void hangonp(); + //void hangonp(); void fadescreendowns(); void openhoteldoor2(); void getridoftempsp(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index a481bb2979..60bd317a2b 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -145,8 +145,7 @@ void DreamGenContext::dreamweb() { // "endofgame" clearbeforeload(); fadescreendowns(); - cx = 200; - hangon(); + hangon(200); endgame(); quickquit2(); return; @@ -186,8 +185,7 @@ void DreamGenContext::dreamweb() { clearbeforeload(); showgun(); fadescreendown(); - cx = 100; - hangon(); + hangon(100); } } @@ -1855,5 +1853,51 @@ void DreamGenContext::fillryan() { showryanpage(); } +void DreamGenContext::hangon() { + hangon(cx); +} + +void DreamGenContext::hangon(uint16 frameCount) { + while (frameCount) { + vsync(); + --frameCount; + } +} + +void DreamGenContext::hangonp() { + hangonp(cx); +} + +void DreamGenContext::hangonp(uint16 count) { + data.word(kMaintimer) = 0; + uint8 pointerFrame = data.byte(kPointerframe); + uint8 pickup = data.byte(kPickup); + data.byte(kPointermode) = 3; + data.byte(kPickup) = 0; + data.byte(kCommandtype) = 255; + readmouse(); + animpointer(); + showpointer(); + vsync(); + dumppointer(); + for (size_t i = 0; i < count * 3; ++i) { + delpointer(); + readmouse(); + animpointer(); + showpointer(); + vsync(); + dumppointer(); + if (data.word(kMousebutton) == 0) + continue; + if (data.word(kMousebutton) != data.word(kOldbutton)) + break; + } + + delpointer(); + data.byte(kPointerframe) = pointerFrame; + data.byte(kPickup) = pickup; + data.byte(kPointermode) = 0; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index fc92e5744f..943d890afa 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -231,4 +231,9 @@ void findallryan(uint8 *inv); void fillryan(); void useroutine(); + void hangon(); + void hangon(uint16 frameCount); + void hangonp(); + void hangonp(uint16 count); + diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp index 237c8d4fad..194aed461d 100644 --- a/engines/dreamweb/use.cpp +++ b/engines/dreamweb/use.cpp @@ -144,8 +144,7 @@ void DreamGenContext::useroutine() { al = es.byte(si); if (al != 0) { usetext(); - cx = 400; - hangonp(); + hangonp(400); putbackobstuff(); return; } @@ -159,8 +158,7 @@ void DreamGenContext::useroutine() { obicons(); printmessage(33, 100, 63, 241, true); worktoscreenm(); - cx = 50; - hangonp(); + hangonp(50); putbackobstuff(); data.byte(kCommandtype) = 255; } -- cgit v1.2.3 From eda43c2d8656458979c0aa15b7ad44f2125fa906 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sat, 3 Sep 2011 11:38:50 -0400 Subject: CREATE_PROJECT: Disable XCode support by default --- devtools/create_project/create_project.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 0b190b3f0e..fafe680014 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -20,6 +20,8 @@ * */ +//#define ENABLE_XCODE + // HACK to allow building with the SDL backend on MinGW // see bug #1800764 "TOOLS: MinGW tools building broken" #ifdef main @@ -177,6 +179,7 @@ int main(int argc, char *argv[]) { projectType = kProjectMSVC; +#ifdef ENABLE_XCODE } else if (!std::strcmp(argv[i], "--xcode")) { if (projectType != kProjectNone) { std::cerr << "ERROR: You cannot pass more than one project type!\n"; @@ -184,6 +187,7 @@ int main(int argc, char *argv[]) { } projectType = kProjectXcode; +#endif } else if (!std::strcmp(argv[i], "--msvc-version")) { if (i + 1 >= argc) { -- cgit v1.2.3 From 7cfed737d7fead674ca61b74d704e6a8ba0b577d Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 6 Sep 2011 16:01:10 -0400 Subject: CREATE_PROJECT: Add support for creating Visual Studio projects for the dev tools - Move project name and description to BuildSetup structure - Add list of tools to generate project for (similar to the list of features) --- devtools/create_project/codeblocks.cpp | 32 +++--- devtools/create_project/codeblocks.h | 2 +- devtools/create_project/create_project.cpp | 172 +++++++++++++++++++++-------- devtools/create_project/create_project.h | 21 +++- devtools/create_project/msbuild.cpp | 69 ++++++------ devtools/create_project/msbuild.h | 4 +- devtools/create_project/msvc.cpp | 35 +++--- devtools/create_project/msvc.h | 2 +- devtools/create_project/visualstudio.cpp | 53 ++++----- devtools/create_project/visualstudio.h | 6 +- 10 files changed, 254 insertions(+), 142 deletions(-) diff --git a/devtools/create_project/codeblocks.cpp b/devtools/create_project/codeblocks.cpp index e73dc11089..3458ca5a19 100644 --- a/devtools/create_project/codeblocks.cpp +++ b/devtools/create_project/codeblocks.cpp @@ -32,20 +32,20 @@ CodeBlocksProvider::CodeBlocksProvider(StringList &global_warnings, std::map\n" "\n"; - workspace << "\t\n"; + workspace << "\t\n"; - writeReferences(workspace); + writeReferences(setup, workspace); // Note we assume that the UUID map only includes UUIDs for enabled engines! for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == PROJECT_NAME) + if (i->first == setup.projectName) continue; workspace << "\t\tfirst << ".cbp\" />\n"; @@ -88,15 +88,15 @@ void CodeBlocksProvider::createProjectFile(const std::string &name, const std::s "\t\t