diff options
-rw-r--r-- | devtools/create_xeen/create_xeen.cpp | 2 | ||||
-rw-r--r-- | devtools/create_xeen/file.h | 3 | ||||
-rw-r--r-- | devtools/create_xeen/map.cpp | 248 | ||||
-rw-r--r-- | devtools/create_xeen/map.h | 38 | ||||
-rw-r--r-- | devtools/create_xeen/module.mk | 1 | ||||
-rw-r--r-- | engines/xeen/files.cpp | 10 | ||||
-rw-r--r-- | engines/xeen/files.h | 10 |
7 files changed, 311 insertions, 1 deletions
diff --git a/devtools/create_xeen/create_xeen.cpp b/devtools/create_xeen/create_xeen.cpp index 94af74f517..92c7a3bcf6 100644 --- a/devtools/create_xeen/create_xeen.cpp +++ b/devtools/create_xeen/create_xeen.cpp @@ -35,6 +35,7 @@ #include "cc.h" #include "file.h" #include "constants.h" +#include "map.h" #define VERSION_NUMBER 1 @@ -59,6 +60,7 @@ int main(int argc, char *argv[]) { CCArchive cc(outputFile); writeVersion(cc); writeConstants(cc); + writeMap(cc); cc.close(); return 0; diff --git a/devtools/create_xeen/file.h b/devtools/create_xeen/file.h index 8fdb9b44a9..7ea5acfb4a 100644 --- a/devtools/create_xeen/file.h +++ b/devtools/create_xeen/file.h @@ -98,6 +98,9 @@ public: void writeByte(byte v) { write(&v, sizeof(byte)); } + void writeShort(int8 v) { + write(&v, sizeof(int8)); + } void writeByte(byte v, int len) { byte *b = new byte[len]; memset(b, v, len); diff --git a/devtools/create_xeen/map.cpp b/devtools/create_xeen/map.cpp new file mode 100644 index 0000000000..254528c8a3 --- /dev/null +++ b/devtools/create_xeen/map.cpp @@ -0,0 +1,248 @@ +/* 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. + * + */ + + // Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +// HACK to allow building with the SDL backend on MinGW +// see bug #1800764 "TOOLS: MinGW tools building broken" +#ifdef main +#undef main +#endif // main + +#include "file.h" +#include "map.h" + +#define MAP_WIDTH 16 +#define MAP_HEIGHT 16 +#define FLAG_IS_OUTDOORS 32768 + +#define MIRROR_COUNT 1 +const MirrorEntry MIRROR_TEXT[MIRROR_COUNT] = { + { "scummvm", 255, 7, 1, 0 } +}; + +const byte MAZE_255[MAP_HEIGHT][MAP_WIDTH] = { + { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }, + { 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9 }, + { 9, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 9 }, + { 9, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 4,14,14,14,14,14,14, 4, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 4,14, 6, 6, 6, 6,14, 4, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 4,14, 6, 7, 7, 6,14, 4, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 4,14, 6, 7, 7, 6,14, 4, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 4,14, 6, 6, 6, 6,14, 4, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 4,14,14,14,14,14,14, 4, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 9 }, + { 9, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 9 }, + { 9, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 9 }, + { 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9 }, + { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 } +}; + +const byte WALL_TYPES_255[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const byte SURFACE_TYPES_255[16] = { 1, 1, 2, 3, 4, 0, 6, 7, 0, 9, 0, 0, 0, 0, 14, 15 }; + +/** + * Write out new mirror entries + */ +void writeMirrorText(CCArchive &cc) { + Common::MemFile f; + + for (int idx = 0; idx < MIRROR_COUNT; ++idx) { + const MirrorEntry &me = MIRROR_TEXT[idx]; + f.write(me._name, 28); + f.writeByte(me._mapId); + f.writeShort(me._posX); + f.writeShort(me._posY); + f.writeByte(me._direction); + } + + cc.add("xeenmirr.ext", f); +} + +/** + * Write out the maze + */ +void writeMaze(CCArchive &cc) { + Common::MemFile f; + + // Wall data + for (int y = 0; y < MAP_HEIGHT; ++y) + for (int x = 0; x < MAP_WIDTH; ++x) + f.writeWord(MAZE_255[y][x]); + + // Surface and flags + for (int y = 0; y < MAP_HEIGHT; ++y) + f.write(MAZE_255[y], MAP_WIDTH); + + f.writeWord(255); // Maze number + for (int idx = 0; idx < 4; ++idx) + f.writeWord(0); // No surrounding mazes + f.writeWord(0); // Maze flags 1 + f.writeWord(FLAG_IS_OUTDOORS); // Maze flags 2 + f.write(WALL_TYPES_255, 16); + f.write(SURFACE_TYPES_255, 16); + f.writeByte(0); // Floor type (unused) + f.writeByte(7); // Run position X + f.writeByte(0, 8); // Difficulties + f.writeByte(0); // Run position Y + f.writeByte(0); // Trap damage + f.writeByte(0); // Wall kind + f.writeByte(0); // Tavern tips + f.writeByte(0, MAP_WIDTH * MAP_HEIGHT / 8); // Seen tiles + f.writeByte(0, MAP_WIDTH * MAP_HEIGHT / 8); // Stepped on tiles + + cc.add("mazex255.dat", f); +} + +/** + * Write out the maze name + */ +void writeMazeName(CCArchive &cc) { + Common::MemFile f; + char mazeName[33]; + memset(mazeName, 0, 33); + strcpy(mazeName, "ScummVM"); + f.write(mazeName, 33); + + cc.add("xeenx255.txt", f); +} + +/** + * Write out maze events + */ +void writeMazeEvents(CCArchive &cc) { + Common::MemFile f; + + // Mirror events + const byte MIRROR_EVENTS[32] = { + 6, 7, 0, 2, 0, 40, 1, // Play VOC: "Where to?" + 9, 7, 0, 2, 1, 21, 0, 3, 0, 0, // Get destination + 5, 7, 0, 2, 2, 18, // Exit + 8, 7, 0, 2, 3, 7, 0, 0, 0 // Teleport and exit + }; + f.write(MIRROR_EVENTS, 32); + + // Bench 1 events + const byte BENCH1_EVENTS[21] = { + 14, 7, 8, 0, 0, 20, 34, 10000 % 256, 10000 / 256, 0, 0, 0, 0, 0, 0, // Give gold + 5, 7, 8, 0, 1, 18 // Exit + }; + const byte BENCH2_EVENTS[19] = { + 14, 8, 8, 0, 0, 20, 35, 1000 % 256, 1000 / 256, 0, 0, 0, 0, // Give gems + 5, 8, 8, 0, 1, 18 // Exit + }; + f.write(BENCH1_EVENTS, 21); + f.write(BENCH2_EVENTS, 19); + + cc.add("mazex255.evt", f); +} + +/** + * Write out maze event text + */ +void writeMazeText(CCArchive &cc) { + Common::MemFile f; + + f.writeString("Where to?"); + + cc.add("aazex255.txt", f); +} + +/** + * Write out the monster/object data + */ +void writeMonstersObjects(CCArchive &cc) { + Common::MemFile f; + f.writeByte(8); // Object sprites + f.writeByte(2); + f.writeByte(0xff, 14); + + f.writeByte(0xff, 16); // Monster sprites + f.writeByte(0xff, 16); // Wall item sprites + + for (int idx = 0; idx < 6; ++idx) { + switch (idx) { + case 0: + // Mirror + f.writeShort(7); + f.writeShort(0); + f.writeByte(0); + f.writeShort(2); + // Benches + f.writeShort(7); + f.writeShort(8); + f.writeShort(1); + f.writeShort(0); + f.writeShort(8); + f.writeShort(8); + f.writeShort(1); + f.writeShort(0); + break; + case 2: + // End of monster/objects + f.writeShort(0); + f.writeShort(0); + f.writeByte(0); + f.writeShort(0); + break; + case 4: + f.writeShort(0x80); + f.writeShort(0x80); + f.writeByte(0); + f.writeShort(0); + break; + default: + f.writeShort(-1); + f.writeShort(-1); + f.writeByte(0xff); + f.writeShort(-1); + break; + } + } + + cc.add("mazex255.mob", f); +} + +/** + * Write out the data for the head danger senses + */ +void writeHeadData(CCArchive &cc) { + Common::MemFile f; + f.writeByte(0, MAP_HEIGHT * MAP_HEIGHT * 2); + cc.add("aazex255.hed", f); +} + +/** + * Write out the new ScummVM map + */ +void writeMap(CCArchive &cc) { + writeMirrorText(cc); + writeMaze(cc); + writeMazeName(cc); + writeMazeEvents(cc); + writeMazeText(cc); + writeMonstersObjects(cc); + writeHeadData(cc); +} diff --git a/devtools/create_xeen/map.h b/devtools/create_xeen/map.h new file mode 100644 index 0000000000..fa64789d55 --- /dev/null +++ b/devtools/create_xeen/map.h @@ -0,0 +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. + * + */ + +#ifndef MAP_H +#define MAP_H + +#include "common/scummsys.h" +#include "cc.h" + +struct MirrorEntry { + char _name[28]; + byte _mapId; + int8 _posX, _posY; + byte _direction; +}; + +extern void writeMap(CCArchive &cc); + +#endif diff --git a/devtools/create_xeen/module.mk b/devtools/create_xeen/module.mk index d382fc6bd6..e325d6e9b8 100644 --- a/devtools/create_xeen/module.mk +++ b/devtools/create_xeen/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ cc.o \ constants.o \ hashmap.o \ + map.o \ memorypool.o \ str.o diff --git a/engines/xeen/files.cpp b/engines/xeen/files.cpp index 2ba3b6f993..a424bd510b 100644 --- a/engines/xeen/files.cpp +++ b/engines/xeen/files.cpp @@ -328,7 +328,11 @@ bool File::open(const Common::String &filename, int ccMode) { int oldMode = files._isDarkCc ? 1 : 0; files.setGameCc(ccMode); - File::open(filename, *_currentArchive); + if (File::exists(filename, *_currentArchive)) + File::open(filename, *_currentArchive); + else + File::open(filename); + files.setGameCc(oldMode); return true; @@ -390,6 +394,10 @@ bool File::exists(const Common::String &filename, int ccMode) { return result; } +bool File::exists(const Common::String &filename, Common::Archive &archive) { + return archive.hasFile(filename); +} + void File::syncBitFlags(Common::Serializer &s, bool *startP, bool *endP) { byte data = 0; diff --git a/engines/xeen/files.h b/engines/xeen/files.h index 4ceadcd753..306ec96657 100644 --- a/engines/xeen/files.h +++ b/engines/xeen/files.h @@ -187,9 +187,19 @@ public: * Checks if a given file exists * * @param filename the file to check for + * @param ccMode Archive to use * @return true if the file exists, false otherwise */ static bool exists(const Common::String &filename, int ccMode); + + /** + * Checks if a given file exists + * + * @param filename the file to check for + * @param archive Archive to use + * @return true if the file exists, false otherwise + */ + static bool exists(const Common::String &filename, Common::Archive &archive); }; /** |