bool DrasculaEngine::loadGame(const char *gameName) { int l, savedChapter, roomNum = 0; Common::InSaveFile *sav; previousMusic = roomMusic; _menuScreen = false; if (currentChapter != 1) clearRoom(); if (!(sav = _saveFileMan->openForLoading(gameName))) { error("missing savegame file"); } savedChapter = sav->readSint32LE(); if (savedChapter != currentChapter) { strcpy(saveName, gameName); currentChapter = savedChapter - 1; loadedDifferentChapter = 1; return false; } sav->read(currentData, 20); curX = sav->readSint32LE(); curY = sav->readSint32LE(); trackProtagonist = sav->readSint32LE(); for (l = 1; l < ARRAYSIZE(inventoryObjects); l++) { inventoryObjects[l] = sav->readSint32LE(); } for (l = 0; l < NUM_FLAGS; l++) { flags[l] = sav->readSint32LE(); } takeObject = sav->readSint32LE(); pickedObject = sav->readSint32LE(); loadedDifferentChapter = 0; if (!sscanf(currentData, "%d.ald", &roomNum)) { error("Bad save format"); } enterRoom(roomNum); selectVerb(kVerbNone); return true; }
void DrasculaEngine::screenSaver() { int xr, yr; byte *copia, *ghost; float coeff = 0, coeff2 = 0; int count = 0; int count2 = 0; int tempLine[320]; int tempRow[200]; hideCursor(); clearRoom(); loadPic("sv.alg", bgSurface, HALF_PAL); // inicio_ghost(); copia = (byte *)malloc(64000); ghost = (byte *)malloc(65536); // carga_ghost(); Common::SeekableReadStream *stream = _archives.open("ghost.drv"); if (!stream) error("Cannot open file ghost.drv"); stream->read(ghost, 65536); delete stream; updateEvents(); xr = _mouseX; yr = _mouseY; while (!shouldQuit()) { // efecto(bgSurface); memcpy(copia, bgSurface, 64000); coeff += 0.1f; coeff2 = coeff; if (++count > 319) count = 0; for (int i = 0; i < 320; i++) { tempLine[i] = (int)(sin(coeff2) * 16); coeff2 += 0.02f; tempLine[i] = checkWrapY(tempLine[i]); } coeff2 = coeff; for (int i = 0; i < 200; i++) { tempRow[i] = (int)(sin(coeff2) * 16); coeff2 += 0.02f; tempRow[i] = checkWrapX(tempRow[i]); } if (++count2 > 199) count2 = 0; int x1_, y1_, off1, off2; Graphics::Surface *screenSurf = _system->lockScreen(); byte *screenBuffer = (byte *)screenSurf->getPixels(); uint16 screenPitch = screenSurf->pitch; for (int i = 0; i < 200; i++) { for (int j = 0; j < 320; j++) { x1_ = j + tempRow[i]; x1_ = checkWrapX(x1_); y1_ = i + count2; y1_ = checkWrapY(y1_); off1 = 320 * y1_ + x1_; x1_ = j + count; x1_ = checkWrapX(x1_); y1_ = i + tempLine[j]; y1_ = checkWrapY(y1_); off2 = 320 * y1_ + x1_; screenBuffer[screenPitch * i + j] = ghost[bgSurface[off2] + (copia[off1] << 8)]; } } _system->unlockScreen(); _system->updateScreen(); _system->delayMillis(20); // end of efecto() updateEvents(); if (_rightMouseButton == 1 || _leftMouseButton == 1) break; if (_mouseX != xr) break; if (_mouseY != yr) break; } // fin_ghost(); free(copia); free(ghost); loadPic(_roomNumber, bgSurface, HALF_PAL); showCursor(); }
bool DrasculaEngine::saveLoadScreen() { char names[10][23]; char file[50]; char fileEpa[50]; int n, n2, num_sav = 0, y = 27; Common::InSaveFile *sav; clearRoom(); snprintf(fileEpa, 50, "%s.epa", _targetName.c_str()); if (!(sav = _saveFileMan->openForLoading(fileEpa))) { Common::OutSaveFile *epa; if (!(epa = _saveFileMan->openForSaving(fileEpa))) error("Can't open %s file", fileEpa); for (n = 0; n < NUM_SAVES; n++) epa->writeString("*\n"); epa->finalize(); delete epa; if (!(sav = _saveFileMan->openForLoading(fileEpa))) { error("Can't open %s file", fileEpa); } } for (n = 0; n < NUM_SAVES; n++) { strncpy(names[n], sav->readLine().c_str(), 23); names[n][22] = '\0'; // make sure the savegame name is 0-terminated } delete sav; loadPic("savescr.alg", bgSurface, HALF_PAL); color_abc(kColorLightGreen); select[0] = 0; _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); setCursor(kCursorCrosshair); while (!shouldQuit()) { y = 27; copyBackground(); for (n = 0; n < NUM_SAVES; n++) { print_abc(names[n], 116, y); y = y + 9; } print_abc(select, 117, 15); updateScreen(); y = 27; updateEvents(); if (leftMouseButton == 1) { delay(50); for (n = 0; n < NUM_SAVES; n++) { if (mouseX > 115 && mouseY > y + (9 * n) && mouseX < 115 + 175 && mouseY < y + 10 + (9 * n)) { strcpy(select, names[n]); if (strcmp(select, "*")) selectionMade = 1; else { enterName(); strcpy(names[n], select); if (selectionMade == 1) { snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); saveGame(file); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { error("Can't open %s file", fileEpa); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); tsav->writeString("\n"); } tsav->finalize(); delete tsav; } } print_abc(select, 117, 15); y = 27; for (n2 = 0; n2 < NUM_SAVES; n2++) { print_abc(names[n2], 116, y); y = y + 9; } if (selectionMade == 1) { snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); } num_sav = n; } } if (mouseX > 117 && mouseY > 15 && mouseX < 295 && mouseY < 24 && selectionMade == 1) { enterName(); strcpy(names[num_sav], select); print_abc(select, 117, 15); y = 27; for (n2 = 0; n2 < NUM_SAVES; n2++) { print_abc(names[n2], 116, y); y = y + 9; } if (selectionMade == 1) { snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); saveGame(file); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { error("Can't open %s file", fileEpa); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); tsav->writeString("\n"); } tsav->finalize(); delete tsav; } } if (mouseX > 125 && mouseY > 123 && mouseX < 199 && mouseY < 149 && selectionMade == 1) { if (!loadGame(file)) { _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); return false; } break; } else if (mouseX > 208 && mouseY > 123 && mouseX < 282 && mouseY < 149 && selectionMade == 1) { saveGame(file); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { error("Can't open %s file", fileEpa); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); tsav->writeString("\n"); } tsav->finalize(); delete tsav; } else if (mouseX > 168 && mouseY > 154 && mouseX < 242 && mouseY < 180) break; else if (selectionMade == 0) { print_abc("Please select a slot", 117, 15); } updateScreen(); delay(200); } y = 26; delay(5); } selectVerb(kVerbNone); clearRoom(); loadPic(roomNumber, bgSurface, HALF_PAL); selectionMade = 0; _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); return true; }
void TileMap::clearRooms(){ for(x = 0; x < numRooms; x++){ clearRoom(x); } }