Ticket #8865: rtz_saturn_updated.diff
File rtz_saturn_updated.diff, 19.1 KB (added by , 17 years ago) |
---|
-
common/util.cpp
288 288 {"macintosh", "mac", "mac", "Macintosh", kPlatformMacintosh}, 289 289 {"pce", "pce", "pce", "PC-Engine", kPlatformPCEngine }, 290 290 {"nes", "nes", "nes", "NES", kPlatformNES}, 291 {"saturn", "saturn", "saturn", "Sega Saturn", kPlatformSaturn}, 291 292 {"segacd", "segacd", "sega", "SegaCD", kPlatformSegaCD}, 292 293 {"windows", "win", "win", "Windows", kPlatformWindows}, 293 294 -
common/util.h
207 207 kPlatformSegaCD, 208 208 kPlatform3DO, 209 209 kPlatformPCEngine, 210 211 210 kPlatformApple2GS, 212 211 kPlatformPC98, 212 kPlatformSaturn, 213 213 214 214 kPlatformUnknown = -1 215 215 }; -
engines/made/cpkplayer.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 #include "common/scummsys.h" 27 #include "common/endian.h" 28 29 #include "made/cpkplayer.h" 30 #include "made/screen.h" 31 32 #include "sound/adpcm.h" 33 34 namespace Made { 35 36 CpkPlayer::CpkPlayer(MadeEngine *vm, Audio::Mixer *mixer) : _fd(NULL), _vm(vm), _mixer(mixer) { 37 } 38 39 CpkPlayer::~CpkPlayer() { 40 } 41 42 struct SampleTableEntry { 43 uint32 offset; 44 uint32 length; 45 uint32 sampleInfo1; 46 uint32 sampleInfo2; 47 }; 48 49 void CpkPlayer::play(const char *filename) { 50 51 // Note: Most of this code is based off the document from http://wiki.multimedia.cx/index.php?title=Sega_FILM 52 53 _abort = false; 54 _surface = new Graphics::Surface(); 55 56 _fd = new Common::File(); 57 _fd->open(filename); 58 59 // FILM Chunk 60 assert(_fd->readUint32BE() == MKID_BE('FILM')); 61 uint32 filmHeaderLength = _fd->readUint32BE(); 62 uint32 filmVersion = _fd->readUint32BE(); 63 _fd->readUint32BE(); // Reserved??? 64 65 // FDSC Chunk 66 assert(_fd->readUint32BE() == MKID_BE('FDSC')); 67 uint32 fdscChunkSize = _fd->readUint32BE(); 68 uint32 videoCodec = _fd->readUint32BE(); 69 uint32 height = _fd->readUint32BE(); 70 uint32 width = _fd->readUint32BE(); 71 _fd->readByte(); // Unknown 72 byte audioChannels = _fd->readByte(); 73 byte audioSamplingBits = _fd->readByte(); 74 _fd->readByte(); // Unknown 75 uint16 audioFrequency = _fd->readUint16BE(); 76 77 // STAB Chunk 78 assert(_fd->readUint32BE() == MKID_BE('STAB')); 79 uint32 stabChunkSize = _fd->readUint32BE(); 80 uint32 frameRateBaseFreq = _fd->readUint32BE(); 81 uint32 sampleTableEntryCount = _fd->readUint32BE(); 82 SampleTableEntry *sampleTableEntries = new SampleTableEntry[sampleTableEntryCount]; 83 for (uint32 i = 0; i < sampleTableEntryCount; i++) { 84 sampleTableEntries[i].offset = _fd->readUint32BE(); 85 sampleTableEntries[i].length = _fd->readUint32BE(); 86 sampleTableEntries[i].sampleInfo1 = _fd->readUint32BE(); 87 sampleTableEntries[i].sampleInfo2 = _fd->readUint32BE(); 88 } 89 90 // Where's the actual frame rate? There is none! It's variable and can differ between frames. 91 92 _mixer->stopAll(); 93 94 byte audioFlags = 0; 95 if (audioChannels == 2) 96 audioFlags |= Audio::Mixer::FLAG_STEREO; 97 if (audioSamplingBits == 16) 98 audioFlags |= Audio::Mixer::FLAG_16BITS; 99 100 _audioStream = Audio::makeAppendableAudioStream(audioFrequency, audioFlags); 101 102 103 // Uh-oh.... is it 8bpp??? 104 _surface->create(width, height, 1); 105 106 for (uint32 i = 0; i < sampleTableEntryCount && !_abort && !_fd->eof(); i++) { 107 _fd->seek(sampleTableEntries[i].offset + filmHeaderLength); 108 109 // Audio Data 110 if (sampleTableEntries[i].sampleInfo1 == (uint32)~0) { 111 Common::SeekableSubReadStream *soundData = new Common::SeekableSubReadStream(_fd, 0, sampleTableEntries[i].length); 112 Audio::AudioStream *adpcmStream = Audio::makeADPCMStream(soundData, false, 0, Audio::kADPCMMS, audioFrequency, audioChannels, 0); 113 // TODO: L R L R L R L R 114 // The Sound data alternates left/right 115 } else { 116 // Video Data 117 // TODO: Cinepak for SEGA 118 } 119 120 handleEvents(); 121 updateScreen(); 122 } 123 124 _audioStream->finish(); 125 _mixer->stopHandle(_audioStreamHandle); 126 127 //delete _audioStream; 128 delete _fd; 129 delete _surface; 130 131 } 132 133 void CpkPlayer::handleEvents() { 134 Common::Event event; 135 while (_vm->_system->getEventManager()->pollEvent(event)) { 136 switch (event.type) { 137 case Common::EVENT_KEYDOWN: 138 if (event.kbd.keycode == Common::KEYCODE_ESCAPE) 139 _abort = true; 140 break; 141 case Common::EVENT_QUIT: 142 _vm->_quit = true; 143 _abort = true; 144 break; 145 default: 146 break; 147 } 148 } 149 } 150 151 void CpkPlayer::updateScreen() { 152 _vm->_system->copyRectToScreen((const byte*)_surface->pixels, _surface->pitch, 153 (320 - _surface->w) / 2, (200 - _surface->h) / 2, _surface->w, _surface->h); 154 _vm->_system->updateScreen(); 155 } 156 157 } -
engines/made/cpkplayer.h
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 #ifndef MADE_CPKPLAYER_H 27 #define MADE_CPKPLAYER_H 28 29 #include "common/system.h" 30 #include "common/events.h" 31 #include "common/file.h" 32 #include "common/endian.h" 33 #include "graphics/surface.h" 34 #include "sound/mixer.h" 35 #include "sound/audiostream.h" 36 37 #include "made/graphics.h" 38 #include "made/sound.h" 39 #include "made/made.h" 40 41 namespace Made { 42 43 class MadeEngine; 44 45 class CpkPlayer { 46 public: 47 CpkPlayer(MadeEngine *vm, Audio::Mixer *mixer); 48 ~CpkPlayer(); 49 void play(const char *filename); 50 protected: 51 MadeEngine *_vm; 52 Audio::Mixer *_mixer; 53 Common::File *_fd; 54 Audio::AppendableAudioStream *_audioStream; 55 Audio::SoundHandle _audioStreamHandle; 56 Graphics::Surface *_surface; 57 bool _abort; 58 void handleEvents(); 59 void updateScreen(); 60 }; 61 62 } 63 64 #endif -
engines/made/database.cpp
39 39 < 0x7FFE object 40 40 */ 41 41 42 Object::Object( ) : _objData(NULL), _freeData(false) {42 Object::Object(bool bigEndian) : _objData(NULL), _freeData(false), _bigEndian(bigEndian) { 43 43 } 44 44 45 45 Object::~Object() { … … 47 47 delete[] _objData; 48 48 } 49 49 50 int Object::loadVersion2(Common::SeekableReadStream &source) { 51 50 int Object::loadVersion2(Common::SeekableReadStream &source) { 52 51 if (_freeData && _objData) 53 52 delete[] _objData; 54 53 … … 102 101 return _objSize; 103 102 } 104 103 104 int Object::loadVersionSegaSaturn(Common::SeekableReadStream &source) { 105 _freeData = true; 106 source.readUint16BE(); // skip flags 107 uint16 type = source.readUint16BE(); 108 if (type == 0x7FFF) { 109 _objSize = source.readUint16BE(); 110 } else if (type == 0x7FFE) { 111 _objSize = source.readUint16BE() * 2; 112 } else if (type < 0x7FFE) { 113 byte count1 = source.readByte(); 114 byte count2 = source.readByte(); 115 _objSize = (count1 + count2) * 2; 116 } 117 source.seek(-6, SEEK_CUR); 118 _objSize += 6; 119 _objData = new byte[_objSize]; 120 source.read(_objData, _objSize); 121 return _objSize; 122 } 123 105 124 int Object::loadVersion3(byte *source) { 106 125 _objData = source; 107 126 _freeData = false; … … 115 134 } 116 135 117 136 uint16 Object::getFlags() const { 137 if (_bigEndian) 138 return READ_BE_UINT16(_objData); 118 139 return READ_LE_UINT16(_objData); 119 140 } 120 141 121 142 uint16 Object::getClass() const { 143 if (_bigEndian) 144 return READ_BE_UINT16(_objData + 2); 122 145 return READ_LE_UINT16(_objData + 2); 123 146 } 124 147 125 148 uint16 Object::getSize() const { 149 if (_bigEndian) 150 return READ_BE_UINT16(_objData + 4); 126 151 return READ_LE_UINT16(_objData + 4); 127 152 } 128 153 … … 181 206 return vector[index]; 182 207 } else if (getClass() == 0x7FFE) { 183 208 int16 *vector = (int16*)getData(); 209 if (_bigEndian) 210 return READ_BE_UINT16(&vector[index]); 184 211 return READ_LE_UINT16(&vector[index]); 185 212 } else if (getClass() < 0x7FFE) { 186 213 int16 *vector = (int16*)getData(); 214 if (_bigEndian) 215 return READ_BE_UINT16(&vector[index]); 187 216 return READ_LE_UINT16(&vector[index]); 188 217 } else { 189 218 // should never reach here … … 198 227 vector[index] = value; 199 228 } else if (getClass() <= 0x7FFE) { 200 229 int16 *vector = (int16*)getData(); 201 WRITE_LE_UINT16(&vector[index], value); 230 if (_bigEndian) 231 WRITE_BE_UINT16(&vector[index], value); 232 else 233 WRITE_LE_UINT16(&vector[index], value); 202 234 } 203 235 } 204 236 … … 245 277 debug(2, "loading version 2 dat"); 246 278 loadVersion2(sourceS); 247 279 } else if (_vm->getGameID() == GID_RTZ) { 248 debug(2, "loading version 3 dat"); 249 loadVersion3(sourceS); 280 if (_vm->getPlatform() == Common::kPlatformSaturn) { 281 debug(2, "loading Sega Saturn dat"); 282 loadVersionSegaSaturn(sourceS); 283 } else { 284 debug(2, "loading version 3 dat"); 285 loadVersion3(sourceS); 286 } 250 287 } 251 288 252 289 } … … 341 378 342 379 } 343 380 381 void GameDatabase::loadVersionSegaSaturn(Common::SeekableReadStream &sourceS) { 382 383 // TODO: Read/verifiy header 384 385 sourceS.seek(0x1E); 386 387 uint32 objectIndexOffs = sourceS.readUint32BE(); 388 uint16 objectCount = sourceS.readUint16BE(); 389 uint32 gameStateOffs = sourceS.readUint32BE(); 390 _gameStateSize = sourceS.readUint32BE(); 391 uint32 objectsOffs = sourceS.readUint32BE(); 392 uint32 objectsSize = sourceS.readUint32BE(); 393 _mainCodeObjectIndex = sourceS.readUint16BE(); 394 395 debug(2, "objectIndexOffs = %08X; objectCount = %d; gameStateOffs = %08X; gameStateSize = %d; objectsOffs = %08X; objectsSize = %d\n", objectIndexOffs, objectCount, gameStateOffs, _gameStateSize, objectsOffs, objectsSize); 396 397 _gameState = new byte[_gameStateSize]; 398 sourceS.seek(gameStateOffs); 399 sourceS.read(_gameState, _gameStateSize); 400 401 Common::Array<uint32> objectOffsets; 402 sourceS.seek(objectIndexOffs); 403 for (uint32 i = 0; i < objectCount; i++) 404 objectOffsets.push_back(sourceS.readUint32BE()); 405 406 for (uint32 i = 0; i < objectCount; i++) { 407 Object *obj = new Object(true); 408 409 // The LSB indicates if it's a constant or variable object. 410 // Constant objects are loaded from disk, while variable objects exist 411 // in the _gameState buffer. 412 413 debug(3, "obj(%04X) ofs = %08X\n", i, objectOffsets[i]); 414 415 if (objectOffsets[i] & 1) { 416 debug(3, "-> const %08X\n", objectsOffs + objectOffsets[i] - 1); 417 sourceS.seek(objectsOffs + objectOffsets[i] - 1); 418 obj->loadVersionSegaSaturn(sourceS); 419 } else { 420 debug(3, "-> var\n"); 421 obj->loadVersion3(_gameState + objectOffsets[i]); 422 } 423 _objects.push_back(obj); 424 } 425 426 } 427 344 428 bool GameDatabase::getSavegameDescription(const char *filename, Common::String &description) { 345 429 346 430 Common::InSaveFile *in; … … 456 540 } 457 541 458 542 int16 GameDatabase::getVar(int16 index) { 543 if (_vm->getPlatform() == Common::kPlatformSaturn) 544 return (int16)READ_BE_UINT16(_gameState + index * 2); 459 545 return (int16)READ_LE_UINT16(_gameState + index * 2); 460 546 } 461 547 462 548 void GameDatabase::setVar(int16 index, int16 value) { 463 WRITE_LE_UINT16(_gameState + index * 2, value); 549 if (_vm->getPlatform() == Common::kPlatformSaturn) 550 WRITE_BE_UINT16(_gameState + index * 2, value); 551 else 552 WRITE_LE_UINT16(_gameState + index * 2, value); 464 553 } 465 554 466 555 int16 *GameDatabase::getObjectPropertyPtrV2(int16 objectIndex, int16 propertyId, int16 &propertyFlag) { … … 625 714 } 626 715 627 716 int16 GameDatabase::getObjectProperty(int16 objectIndex, int16 propertyId) { 628 629 717 if (objectIndex == 0) 630 718 return 0; 631 719 -
engines/made/database.h
39 39 40 40 class Object { 41 41 public: 42 Object( );42 Object(bool bigEndian = false); 43 43 ~Object(); 44 44 45 45 int loadVersion2(Common::SeekableReadStream &source); 46 46 int saveVersion2(Common::WriteStream &dest); 47 47 48 48 int loadVersion3(Common::SeekableReadStream &source); 49 int loadVersionSegaSaturn(Common::SeekableReadStream &source); 49 50 int loadVersion3(byte *source); 50 51 51 52 uint16 getFlags() const; … … 70 71 void dump(const char *filename); 71 72 72 73 protected: 74 bool _bigEndian; 73 75 bool _freeData; 74 76 uint16 _objSize; 75 77 byte *_objData; … … 123 125 void load(Common::SeekableReadStream &sourceS); 124 126 void loadVersion2(Common::SeekableReadStream &sourceS); 125 127 void loadVersion3(Common::SeekableReadStream &sourceS); 128 void loadVersionSegaSaturn(Common::SeekableReadStream &sourceS); 126 129 int16 savegameV2(Common::OutSaveFile *out, const char *description, int16 version); 127 130 int16 loadgameV2(Common::InSaveFile *in, int16 version); 128 131 int16 savegameV3(Common::OutSaveFile *out, const char *description, int16 version); -
engines/made/detection.cpp
227 227 GF_FLOPPY, 228 228 0, 229 229 }, 230 231 { 232 // Return to Zork - Japanese Sega Saturn version 233 { 234 "rtz", 235 "", 236 AD_ENTRY1("rtz.dat", "023e46f6b43913792bd535558cce7bf7"), 237 Common::JA_JPN, 238 Common::kPlatformSaturn, 239 Common::ADGF_NO_FLAGS 240 }, 241 GID_RTZ, 242 0, 243 GF_FLOPPY, 244 0, 245 }, 230 246 231 247 { 232 248 // Return to Zork - Demo -
engines/made/made.cpp
84 84 _system->openCD(cd_num); 85 85 86 86 _pmvPlayer = new PmvPlayer(this, _mixer); 87 _cpkPlayer = new CpkPlayer(this, _mixer); 87 88 _res = new ProjectReader(); 88 89 _screen = new Screen(this); 89 90 _dat = new GameDatabase(this); -
engines/made/made.h
45 45 46 46 #include "engines/engine.h" 47 47 48 #include "made/cpkplayer.h" 49 48 50 namespace Made { 49 51 50 52 enum MadeGameID { … … 65 67 struct MadeGameDescription; 66 68 67 69 class ProjectReader; 70 class CpkPlayer; 68 71 class PmvPlayer; 69 72 class Screen; 70 73 class ScriptInterpreter; … … 97 100 private: 98 101 public: 99 102 PmvPlayer *_pmvPlayer; 103 CpkPlayer *_cpkPlayer; 100 104 ProjectReader *_res; 101 105 Screen *_screen; 102 106 GameDatabase *_dat; -
engines/made/module.mk
1 1 MODULE := engines/made 2 2 3 3 MODULE_OBJS = \ 4 cpkplayer.o \ 4 5 database.o \ 5 6 detection.o \ 6 7 graphics.o \ -
engines/made/script.cpp
191 191 _runningScriptObjectIndex = scriptObjectIndex; 192 192 193 193 _localStackPos = _stack.getStackPos(); 194 194 195 195 _codeBase = _vm->_dat->getObject(_runningScriptObjectIndex)->getData(); 196 196 _codeIp = _codeBase; 197 197 … … 215 215 } 216 216 217 217 int16 ScriptInterpreter::readInt16() { 218 int16 temp = (int16)READ_LE_UINT16(_codeIp); 218 int16 temp; 219 if (_vm->getPlatform() == Common::kPlatformSaturn) 220 temp = (int16)READ_BE_UINT16(_codeIp); 221 else 222 temp = (int16)READ_LE_UINT16(_codeIp); 219 223 _codeIp += 2; 220 224 debug(4, "readInt16() value = %04X", temp); 221 225 return temp; -
engines/made/scriptfuncs.cpp
46 46 _externalFuncNames.push_back(#x); 47 47 void ScriptFunctions::setupExternalsTable() { 48 48 49 External(sfSystemCall); 50 External(sfInitGraf); 51 External(sfRestoreGraf); 49 if (_vm->getPlatform() != Common::kPlatformSaturn) { 50 External(sfSystemCall); 51 External(sfInitGraf); 52 External(sfRestoreGraf); 53 } 54 52 55 External(sfDrawPicture); 53 56 External(sfClearScreen); 54 57 External(sfShowPage); … … 115 118 } 116 119 117 120 if (_vm->getGameID() == GID_RTZ) { 118 External(sfPrintf); 121 if (_vm->getPlatform() != Common::kPlatformSaturn) 122 External(sfPrintf); 119 123 External(sfClearMono); 120 124 External(sfGetSoundEnergy); 121 125 External(sfClearText); … … 150 154 External(sfReadMenu); 151 155 External(sfDrawMenu); 152 156 External(sfGetMenuCount); 153 External(sfSaveGame); 154 External(sfLoadGame); 155 External(sfGetGameDescription); 157 if (_vm->getPlatform() == Common::kPlatformSaturn) { 158 External(sfFaceIcon); 159 } else { 160 External(sfSaveGame); 161 External(sfLoadGame); 162 External(sfGetGameDescription); 163 } 156 164 External(sfShakeScreen); 157 165 External(sfPlaceMenu); 158 166 External(sfSetSoundVolume); … … 880 888 881 889 } 882 890 891 int16 ScriptFunctions::sfFaceIcon(int16 argc, int16 *argv) { 892 // RTZ Sega Saturn 893 warning("Unimplemented opcode: sfFaceIcon"); 894 return 0; 895 } 896 883 897 int16 ScriptFunctions::sfShakeScreen(int16 argc, int16 *argv) { 884 898 // TODO: Used in RTZ 885 899 warning("Unimplemented opcode: sfShakeScreen"); -
engines/made/scriptfuncs.h
161 161 int16 sfSaveGame(int16 argc, int16 *argv); 162 162 int16 sfLoadGame(int16 argc, int16 *argv); 163 163 int16 sfGetGameDescription(int16 argc, int16 *argv); 164 int16 sfFaceIcon(int16 argc, int16 *argv); 164 165 int16 sfShakeScreen(int16 argc, int16 *argv); 165 166 int16 sfPlaceMenu(int16 argc, int16 *argv); 166 167 int16 sfSetSoundVolume(int16 argc, int16 *argv);