void GrimEngine::playAspyrLogo() { // A trimmed down version of the code found in mainloop // for the purpose of playing the Aspyr-logo. // The reason for this, is that the logo needs a different // codec than all the other videos (which are Bink). // Code is provided to keep within the fps-limit, as well as to // allow for pressing ESC to skip the movie. MoviePlayer *defaultPlayer = g_movie; g_movie = CreateQuickTimePlayer(); g_movie->play("AMWI.m4b", false, 0, 0); setMode(SmushMode); while (g_movie->isPlaying()) { _doFlip = true; uint32 startTime = g_system->getMillis(); updateDisplayScene(); if (_doFlip) { doFlip(); } // Process events to allow the user to skip the logo. Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { // Ignore everything but ESC when movies are playing Common::EventType type = event.type; if (type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) { g_movie->stop(); break; } } uint32 endTime = g_system->getMillis(); if (startTime > endTime) continue; uint32 diffTime = endTime - startTime; if (_speedLimitMs == 0) continue; if (diffTime < _speedLimitMs) { uint32 delayTime = _speedLimitMs - diffTime; g_system->delayMillis(delayTime); } } delete g_movie; setMode(NormalMode); g_movie = defaultPlayer; }
void GrimEngine::mainLoop() { _movieTime = 0; _frameTime = 0; _frameStart = g_system->getMillis(); _frameCounter = 0; _timeAccum = 0; _frameTimeCollection = 0; _prevSmushFrame = 0; _savegameLoadRequest = false; _savegameSaveRequest = false; _savegameFileName = NULL; _refreshShadowMask = false; for (;;) { uint32 startTime = g_system->getMillis(); if (_savegameLoadRequest) { savegameRestore(); } if (_savegameSaveRequest) { savegameSave(); } g_imuse->flushTracks(); g_imuse->refreshScripts(); if (_mode == ENGINE_MODE_IDLE) { // don't kill CPU g_system->delayMillis(10); continue; } // Process events Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { // Handle any buttons, keys and joystick operations if (event.type == Common::EVENT_KEYDOWN) { if (_mode != ENGINE_MODE_DRAW && _mode != ENGINE_MODE_SMUSH && (event.kbd.ascii == 'q')) { handleExit(); break; } else { handleChars(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii); } } if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP) { handleControls(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii); } // Check for "Hard" quit" if (event.type == Common::EVENT_QUIT) return; if (event.type == Common::EVENT_SCREEN_CHANGED) _refreshDrawNeeded = true; } luaUpdate(); if (_mode != ENGINE_MODE_PAUSE) { updateDisplayScene(); doFlip(); } if (g_imuseState != -1) { g_imuse->setMusicState(g_imuseState); g_imuseState = -1; } uint32 endTime = g_system->getMillis(); if (startTime > endTime) continue; uint32 diffTime = endTime - startTime; if (_speedLimitMs == 0) continue; if (diffTime < _speedLimitMs) { uint32 delayTime = _speedLimitMs - diffTime; g_system->delayMillis(delayTime); } } }
int main(int argc, char** argv) { int i; imageInfoStruct imageInfo; bmpFileStruct sourceFile; unsigned char *imageArray; char path[BUFFER_SIZE]; char *label; int reps; clock_t time; clock_t allTime; flipFunc_pointer_t func; reps = DEF_REPS; strcpy(path, ""); printf("\n"); /* The parser of string with parameters. */ for (i=1; i<argc; i++) { if(argv[i][0] == '-') { switch (argv[i][1]) { case 'p': strncpy(path, &argv[i][2], BUFFER_SIZE); path[BUFFER_SIZE - 1] = '\0'; break; case 'r': reps = strtol(&argv[i][2], NULL, 0); if (reps == 0) showError("Wrong the number of repetitions."); break; default: printf("Wrong argument: %s\n", argv[i]); usage(); } } if(argv[i][0] == '/') { switch (argv[i][1]) { case '?': usage(); break; default: printf("Wrong argument: %s\n", argv[i]); usage(); } } } if (strlen(path) == 0) usage(); printf("Path to BMP file: %s\n", path); printf("Reps: %d\n",reps); imageInfo = loadImageFile(path, &sourceFile, &imageArray); printf("Resolution: %dx%d\n", imageInfo.width, imageInfo.height); func = &flipImageC; label = "Test 1 - using pure C"; doFlip(label, "_1_c_", reps, imageArray, imageInfo, sourceFile, path, func); func = &flipImageC_memcpy; label = "Test 2 - using C with memcpy function"; doFlip(label, "_2_c_memcpy_", reps, imageArray, imageInfo, sourceFile, path, func); func = &flipImageAsm; label = "Test 3 - using pure Asm"; doFlip(label, "_3_asm_", reps, imageArray, imageInfo, sourceFile, path, func); func = &flipImageMMX; label = "Test 4 - using asm with MMX"; doFlip(label, "_4_mmx_", reps, imageArray, imageInfo, sourceFile, path, func); free(imageArray); return 0; }