int KyraEngine_MR::o3_wipeDownMouseItem(EMCState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v2::o3_wipeDownMouseItem(%p) (-, %d, %d)", (const void *)script, stackPos(1), stackPos(2)); _screen->hideMouse(); const int x = stackPos(1) - 12; const int y = stackPos(2) - 19; if (_itemInHand >= 0) { backUpGfxRect32x32(x, y); uint8 *shape = getShapePtr(_itemInHand+248); for (int curY = y, height = 20; height > 0; height -= 2, curY += 2) { restoreGfxRect32x32(x, y); _screen->setNewShapeHeight(shape, height); const uint32 waitTime = _system->getMillis() + _tickLength; _screen->drawShape(0, shape, x, curY, 0, 0); _screen->updateScreen(); delayUntil(waitTime); } restoreGfxRect32x32(x, y); _screen->resetShapeHeight(shape); } _screen->showMouse(); removeHandItem(); return 0; }
void KyraEngine_HoF::scrollInventoryWheel() { WSAMovie_v2 movie(this); movie.open("INVWHEEL.WSA", 0, 0); int frames = movie.opened() ? movie.frames() : 6; memcpy(_screenBuffer, _screen->getCPagePtr(2), 64000); uint8 overlay[0x100]; _screen->generateOverlay(_screen->getPalette(0), overlay, 0, 50); _screen->copyRegion(0x46, 0x90, 0x46, 0x79, 0x71, 0x17, 0, 2, Screen::CR_NO_P_CHECK); snd_playSoundEffect(0x25); bool breakFlag = false; for (int i = 0; i <= 6 && !breakFlag; ++i) { if (movie.opened()) { movie.displayFrame(i % frames, 0, 0, 0, 0, 0, 0); _screen->updateScreen(); } uint32 endTime = _system->getMillis() + _tickLength; int y = (i * 981) >> 8; if (y >= 23 || i == 6) { y = 23; breakFlag = true; } _screen->applyOverlay(0x46, 0x79, 0x71, 0x17, 2, overlay); _screen->copyRegion(0x46, y+0x79, 0x46, 0x90, 0x71, 0x2E, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); delayUntil(endTime); } _screen->copyBlockToPage(2, 0, 0, 320, 200, _screenBuffer); movie.close(); }
void *runPeriodicTask (void *t){ TaskInfo s; // self reference Time c = 0; // completion time Time d = 0; // deadline s = periodicTaskTable[*(int *)t]; while (systemNotCompleted()){ // Compute the deadline or the next activation d=nextActivation(s.period); putHeader (s.name); putString ("activated"); newLine(); // Simulate the execution of this task using // computeDuringTimeSpan. Provide the name of the task, its worst // case execution time, and the period of the task. ATTENTION : // the period parameter in computeDuringTimeSPan is used to // compute the execution priority. It returns the completion time // that should be used to check whether the task missed its // deadline. Use variable c to save this value. See tasks.h. // NYI("compute task for its computation time"); //******************************************************** c = computeDuringTimeSpan(s.name, s.computation, s.period); // NYI("save the completion time in variable c for later use"); //******************************************************** // c = timeAfterTimeSpan(s.computation); putHeader (s.name); putString ("completed"); newLine(); // Check that the completion time did not occur after the deadline if (d < c) { putHeader (s.name); putString ("OVERRUN "); putTime (d); putString (" < "); putTime (c); newLine(); break; }; // Wait for the next activation. In other words, wait for the deadline. // NYI("wait for the next activation"); //********************************************************** delayUntil(d); } return NULL; }
void *runPollingServer (void *t){ TaskInfo s; EventInfo e; TimeSpan c = 0; Time d = 0; int i; s = periodicTaskTable[*(int *)t]; // Schedule the initial replenishment event e.kind = PRODUCE; e.name = s.name; e.activation = nextActivation (s.period); e.computation = s.computation; s.computation = 0; appendEvent (e); // Print the event pushed in the queue putHeader (s.name); putString ("@"); putTime (e.activation); putString (" "); putString (s.name); putString ("=+"); putTime (e.computation); newLine (); while (systemNotCompleted () && (0 <= lastEvent)) { e = getEvent (firstEvent); // When the first event to handle happens in the future, release the // server budget // NYI("if next event happens in the future, release the server budget"); recharger //********************************************************************** if ((((localClock() + 10000) / s.period) * s.period) < e.activation){ s.computation = 0; } // Before handling next event check the server budget is not empty if (s.computation == 0) { // Look for the first PRODUCE event for (i=firstEvent; i <= lastEvent; i++){ e = getEvent(i); if (e.kind == PRODUCE) { if (systemCompletedAt (e.activation)) { return NULL; } // Remove PRODUCE event and then wait for its activation time. // NYI("remove event and wait for its activation"); //**************************************************************** removeEvent(i); delayUntil(e.activation); // Update the server budget and schedule the next PRODUCE // event. To do so compute the next activation time and the // computation time related to this replenishment event. // NYI("update server budget and schedule replenishment"); //****************************************************************** s.computation = e.computation; e.activation = nextActivation (s.period); appendEvent (e); // Print the arrival of this event putHeader (s.name); putString (s.name); putString ("=+"); putTime (e.computation); newLine (); // Print the event pushed in the queue putHeader (s.name); putString ("@"); putTime (e.activation); putString (" "); putString (s.name); putString ("=+"); putTime (e.computation); newLine (); break; } } } e = getEvent (firstEvent); if (systemCompletedAt (e.activation)){ return NULL; } if (e.kind == PRODUCE) { // Remove PRODUCE event and then wait for its activation time // NYI("remove event and wait for its activation time"); //******************************************************************* removeEvent(firstEvent); delayUntil(e.activation); // As there are no Consume events to handle, the server discards // its budget. But it schedules its replenishment. // NYI ("update server budget and schedule its replenishment"); //*************************************************************** s.computation = e.computation; e.activation = nextActivation (s.period); appendEvent (e); // Print the event pushed in the queue putHeader (s.name); putString ("@"); putTime (e.activation); putString (" "); putString (s.name); putString ("=+"); putTime (e.computation); newLine (); } else { // Wait for event activation // NYI("wait for event activation"); delayUntil(e.activation); // Evaluate the computation time needed to handle this // event that is the computation time requested and the // one available on the server. // NYI ("evaluate computation time for event"); //*********************************************** c = e.computation; // Update computation time needed to complete event in queue. // Remove the event once it is completed. // Do not update server budget yet. // We want to print the server status before and after this operation. // NYI("evaluate remaining computation time of current event"); // NYI("remove event when completed"); //NYI("update event in queue when not completed"); //*********************************************************************** if (e.computation <= s.computation){ e.computation = 0; removeEvent(firstEvent); }else{ removeEvent(firstEvent); e.computation = e.computation - s.computation; e.activation = e.activation + 1; appendEvent (e); c = s.computation; } // Print status of both server and event status putHeader (s.name); putString (s.name); putString ("="); putTime (s.computation); putString ("-"); putTime (c); putString (" "); putString (e.name); putString ("="); putTime (e.computation); newLine (); // Update the server budget after this operation. // Simulate the execution of this event using // computeDuringTimeSpan. Provide the name of the event, its // worst case execution time, and the period of the server. // ATTENTION : the period parameter in computeDuringTimeSPan is // used to compute the execution priority. See tasks.h. // NYI("update server budget"); // NYI("compute event"); if (e.computation > 0){ computeDuringTimeSpan(e.name, s.computation, s.period); s.computation = 0; }else{ computeDuringTimeSpan(e.name, c, s.period); s.computation -= c; } // Print event completion if needed if (e.computation == 0) { putHeader (s.name); putString ("completed "); putString (e.name); newLine (); } } } return NULL; }
Common::Error KyraEngine_MR::go() { bool running = true; preinit(); _screen->hideMouse(); initMainMenu(); _screen->clearPage(0); _screen->clearPage(2); const bool firstTimeGame = !saveFileLoadable(0); if (firstTimeGame) { playVQA("K3INTRO"); _wasPlayingVQA = false; } if (_gameToLoad != -1 || firstTimeGame) { while (!_screen->isMouseVisible()) _screen->showMouse(); uninitMainMenu(); _musicSoundChannel = -1; startup(); runLoop(); running = false; } while (running && !shouldQuit()) { _screen->_curPage = 0; _screen->clearPage(0); _screen->setScreenPalette(_screen->getPalette(0)); playMenuAudioFile(); for (int i = 0; i < 64 && !shouldQuit(); ++i) { uint32 nextRun = _system->getMillis() + 3 * _tickLength; _menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0); _screen->updateScreen(); delayUntil(nextRun); } for (int i = 64; i > 29 && !shouldQuit(); --i) { uint32 nextRun = _system->getMillis() + 3 * _tickLength; _menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0); _screen->updateScreen(); delayUntil(nextRun); } _eventList.clear(); switch (_menu->handle(3)) { case 2: _menuDirectlyToLoad = true; // fall through case 0: uninitMainMenu(); fadeOutMusic(60); _screen->fadeToBlack(60); _musicSoundChannel = -1; startup(); runLoop(); running = false; break; case 1: playVQA("K3INTRO"); _wasPlayingVQA = false; _screen->hideMouse(); break; case 3: fadeOutMusic(60); _screen->fadeToBlack(60); uninitMainMenu(); quitGame(); running = false; break; default: break; } } if (_showOutro && !shouldQuit()) playVQA("CREDITS"); return Common::kNoError; }