// Load a music file into memory and optionally play it. bool MADDriverClass::LoadMusic(entry_ref* ref, OSType type, bool playIt) { // Safety check. if (!inited) return false; // Try to import the file. BEntry fileEntry(ref); BPath filePath; fileEntry.GetPath(&filePath); char plugName[5]; libraryError = MADMusicIdentifyCString(MADLib, plugName, filePath.Path()); if (libraryError == MADNoErr) { libraryError = MADLoadMusicFileCString(MADLib, &curMusic, plugName, filePath.Path()); if (libraryError == MADNoErr) { MADAttachDriverToMusic(curDriverRec, curMusic); if (playIt) StartMusic(); } } if (libraryError) return false; else return true; }
void PlayDemo (int demonumber) { int length; #ifdef DEMOSEXTERN // debug: load chunk #ifndef SPEARDEMO int dems[4]={T_DEMO0,T_DEMO1,T_DEMO2,T_DEMO3}; #else int dems[1]={T_DEMO0}; #endif CA_CacheGrChunk(dems[demonumber]); demoptr = grsegs[dems[demonumber]]; MM_SetLock (&grsegs[dems[demonumber]],true); #else demoname[4] = '0'+demonumber; CA_LoadFile (demoname,&demobuffer); MM_SetLock (&demobuffer,true); demoptr = (char far *)demobuffer; #endif NewGame (1,0); gamestate.mapon = *demoptr++; gamestate.difficulty = gd_hard; length = *((unsigned far *)demoptr)++; demoptr++; lastdemoptr = demoptr-4+length; VW_FadeOut (); SETFONTCOLOR(0,15); DrawPlayScreen (); VW_FadeIn (); startgame = false; demoplayback = true; SetupGameLevel (); StartMusic (); PM_CheckMainMem (); fizzlein = true; PlayLoop (); #ifdef DEMOSEXTERN UNCACHEGRCHUNK(dems[demonumber]); #else MM_FreePtr (&demobuffer); #endif demoplayback = false; StopMusic (); VW_FadeOut (); ClearMemory (); }
void Widget::CreateButton() { ButtonLayout = new QHBoxLayout; QSize iconSize(40,40);//设置图标大小 StartButton = new QToolButton; StartButton->setIcon(QPixmap(":/image/3.png")); StartButton->setAutoRaise(true);//鼠标放在按钮上面才显示按钮阴影框 StartButton->setIconSize(iconSize); connect(StartButton,SIGNAL(clicked()),this,SLOT(StartMusic())); StopButton = new QToolButton; StopButton->setIcon(QPixmap(":/image/2.png")); StopButton->setVisible(false);//隐藏按钮 StopButton->setAutoRaise(true); StopButton->setIconSize(iconSize); connect(StopButton,SIGNAL(clicked()),this,SLOT(StopMusic())); NextButton = new QToolButton; NextButton->setIcon(QPixmap(":/image/1.png")); NextButton->setAutoRaise(true); NextButton->setIconSize(iconSize); connect(NextButton,SIGNAL(clicked()),this,SLOT(NextMusic())); LastButton = new QToolButton; LastButton->setIcon(QPixmap(":/image/4.png")); LastButton->setAutoRaise(true); LastButton->setIconSize(iconSize); connect(LastButton,SIGNAL(clicked()),this,SLOT(LastMusic())); OpenButton = new QToolButton; OpenButton->setIcon(QPixmap(":/image/6.png")); OpenButton->setAutoRaise(true); OpenButton->setIconSize(iconSize); connect(OpenButton,SIGNAL(clicked()),this,SLOT(OpenFile())); ButtonLayout->addWidget(LastButton,0,0); ButtonLayout->addWidget(StartButton,1,0); ButtonLayout->addWidget(StopButton,1,0); ButtonLayout->addWidget(NextButton,2,0); ButtonLayout->addWidget(OpenButton,3,0); LabelLayout = new QHBoxLayout; timeLabel= new QLabel;//显示播放时间 timeLabel->setText("00:00"); TotaltimeLabel= new QLabel;//显示歌曲时间长度 TotaltimeLabel->setText("00:00"); TitleLabel= new QLabel;//显示歌曲名字 TitleLabel->setText(tr("Music Title")); LabelLayout->addWidget(timeLabel); LabelLayout->addStretch();//中间空开 LabelLayout->addWidget(TotaltimeLabel); }
void randomize_sound_font(void) { StopMusic(); switch (UNSYNC_RANDOM(3)) { case 0: if (LoadAwe32Soundfont("bullfrog")) StartMusic(1, 127); break; case 1: if (LoadAwe32Soundfont("atmos1")) StartMusic(1, 127); break; case 2: if (LoadAwe32Soundfont("atmos2")) StartMusic(1, 127); break; } }
// music bool AudioManager::LoadAndPlayMusic(const string & file) { if ( !mMusic.openFromFile(file) ) { // Log warning return false; } StartMusic(); return true; }
void RecordDemo (void) { int level,esc; CenterWindow(26,3); PrintY+=6; CA_CacheGrChunk(STARTFONT); fontnumber=0; US_Print(" Demo which level(1-10):"); VW_UpdateScreen(); VW_FadeIn (); esc = !US_LineInput (px,py,str,NULL,true,2,0); if (esc) return; level = atoi (str); level--; SETFONTCOLOR(0,15); VW_FadeOut (); #ifndef SPEAR NewGame (gd_hard,level/10); gamestate.mapon = level%10; #else NewGame (gd_hard,0); gamestate.mapon = level; #endif StartDemoRecord (level); DrawPlayScreen (); VW_FadeIn (); startgame = false; demorecord = true; SetupGameLevel (); StartMusic (); PM_CheckMainMem (); fizzlein = true; PlayLoop (); demoplayback = false; StopMusic (); VW_FadeOut (); ClearMemory (); FinishDemoRecord (); }
static void StartQueuedSounds() { CString *p; while( g_SoundsToPlayOnce.read( &p, 1 ) ) { if( *p != "" ) SOUNDMAN->PlayOnce( *p ); delete p; } while( g_SoundsToPlayOnceFromDir.read( &p, 1 ) ) { CString sPath( *p ); DoPlayOnceFromDir( sPath ); delete p; } while( g_SoundsToPlayOnceFromAnnouncer.read( &p, 1 ) ) { CString sPath( *p ); if( sPath != "" ) sPath = ANNOUNCER->GetPathTo( sPath ); DoPlayOnceFromDir( sPath ); delete p; } MusicToPlay *pMusic; while( g_MusicsToPlay.read( &pMusic, 1 ) ) { /* Don't bother starting this music if there's another one in the queue after it. */ /* Actually, it's a little trickier: the editor gives us a stop and then a sound in * quick succession; if we ignore the stop, we won't rewind the sound if it was * already playing. We don't want to waste time loading a sound if it's going * to be replaced immediately, though. So, if we have more music in the queue, * then forcibly stop the current sound. */ if( !g_MusicsToPlay.num_readable() ) StartMusic( *pMusic ); else { CHECKPOINT; /* StopPlaying() can take a while, so don't hold the lock while we stop the sound. */ g_Mutex->Lock(); RageSound *pOldSound = g_Playing->m_Music; g_Playing->m_Music = new RageSound; g_Mutex->Unlock(); SOUNDMAN->DeleteSound( pOldSound ); } delete pMusic; } }
void sound_reinit_after_load(void) { stop_all_things_playing_samples(); stop_any_speech_sample(); if (Non3DEmitter != 0) { S3DDestroySoundEmitterAndSamples(Non3DEmitter); Non3DEmitter = 0; } ambient_sound_stop(); StartMusic(1, 127); init_messages(); randomize_sound_font(); }
//------------------------------------------------------------------------- // CheckMusicToggle() //------------------------------------------------------------------------- void CheckMusicToggle(void) { static boolean M_KeyReleased; if (in_is_binding_pressed(e_bi_music)) { if (M_KeyReleased #if GAME_VERSION != SHAREWARE_VERSION && ((jam_buff[0] != sc_j) || (jam_buff[1] != sc_a)) #endif ) { if (!AdLibPresent) { DISPLAY_TIMED_MSG(NoAdLibCard,MP_BONUS,MT_GENERAL); ::sd_play_player_sound(NOWAYSND, bstone::AC_NO_WAY); return; } else if (MusicMode != smm_Off) { SD_SetMusicMode(smm_Off); memcpy((char *)&MusicOn[58],"OFF.",4); } else { SD_SetMusicMode(smm_AdLib); StartMusic(false); memcpy((char *)&MusicOn[58],"ON. ",4); } DISPLAY_TIMED_MSG(MusicOn,MP_BONUS,MT_GENERAL); M_KeyReleased=false; } } else M_KeyReleased=true; }
void CheckKeys (void) { if (screenfaded) // don't do anything with a faded screen return; // // pause key wierdness can't be checked as a scan code // if (Paused) { CenterWindow (8,3); US_PrintCentered ("PAUSED"); VW_UpdateScreen (); SD_MusicOff(); IN_Ack(); SD_MusicOn(); Paused = false; if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } // // F1-F7/ESC to enter control panel // if ( (LastScan >= sc_F1 && LastScan <= sc_F7) || LastScan == sc_Escape) { StopMusic (); NormalScreen (); FreeUpMemory (); US_CenterWindow (20,8); US_CPrint ("Loading"); VW_UpdateScreen (); US_ControlPanel(); // REFKEEN - Alternative controllers support (maybe user has changed some keys which may currently have an effect) void PrepareGamePlayControllerMapping(void); PrepareGamePlayControllerMapping(); // if (abortgame) { playstate = ex_abort; return; } StartMusic (); IN_ClearKeysDown(); if (restartgame) playstate = ex_resetgame; if (loadedgame) playstate = ex_loadedgame; DrawPlayScreen (); CacheScaleds (); lasttimecount = SD_GetTimeCount(); if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } // // F10-? debug keys // if (Keyboard[sc_F10]) { DebugKeys(); if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse // if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement lasttimecount = SD_GetTimeCount(); } }
/* =================== = = GameLoop = =================== This function controls the flow between states of the game. It loads previous saved games, setup levels states, controls the flow between levels, including when player loses or when completes the game, and checks if the result of the current game is a highscore. The "real" game loop (player actions in like moving, killing, etc.) is in the PlayLoop function. */ void GameLoop (void) { int i,xl,yl,xh,yh; char num[20]; boolean died; #ifdef MYPROFILE /* clock_t type variables may register times, start and and times could be used to measure the speed of the graphics system. Speed is measured in fps- frames per second. */ clock_t start,end; #endif restartgame: ClearMemory (); SETFONTCOLOR(0,15); DrawPlayScreen (); died = false; restart: do { if (!loadedgame) gamestate.score = gamestate.oldscore; DrawScore(); startgame = false; if (loadedgame) loadedgame = false; else SetupGameLevel (); #ifdef SPEAR if (gamestate.mapon == 20) // give them the key allways { gamestate.keys |= 1; DrawKeys (); } #endif ingame = true; StartMusic (); PM_CheckMainMem (); if (!died) PreloadGraphics (); else died = false; fizzlein = true; DrawLevel (); startplayloop: PlayLoop (); #ifdef SPEAR if (spearflag) { SD_StopSound(); SD_PlaySound(GETSPEARSND); if (DigiMode != sds_Off) { long lasttimecount = TimeCount; while(TimeCount < lasttimecount+150) //while(DigiPlaying!=false) SD_Poll(); } else SD_WaitSoundDone(); ClearMemory (); gamestate.oldscore = gamestate.score; gamestate.mapon = 20; SetupGameLevel (); StartMusic (); PM_CheckMainMem (); player->x = spearx; player->y = speary; player->angle = spearangle; spearflag = false; Thrust (0,0); goto startplayloop; } #endif StopMusic (); ingame = false; if (demorecord && playstate != ex_warped) FinishDemoRecord (); if (startgame || loadedgame) goto restartgame; switch (playstate) { case ex_completed: case ex_secretlevel: gamestate.keys = 0; DrawKeys (); VW_FadeOut (); ClearMemory (); LevelCompleted (); // do the intermission #ifdef SPEARDEMO if (gamestate.mapon == 1) { died = true; // don't "get psyched!" VW_FadeOut (); ClearMemory (); CheckHighScore (gamestate.score,gamestate.mapon+1); #pragma warn -sus #ifndef JAPAN _fstrcpy(MainMenu[viewscores].string,STR_VS); #endif MainMenu[viewscores].routine = CP_ViewScores; #pragma warn +sus return; } #endif #ifdef JAPDEMO if (gamestate.mapon == 3) { died = true; // don't "get psyched!" VW_FadeOut (); ClearMemory (); CheckHighScore (gamestate.score,gamestate.mapon+1); #pragma warn -sus #ifndef JAPAN _fstrcpy(MainMenu[viewscores].string,STR_VS); #endif MainMenu[viewscores].routine = CP_ViewScores; #pragma warn +sus return; } #endif gamestate.oldscore = gamestate.score; #ifndef SPEAR // // COMING BACK FROM SECRET LEVEL // if (gamestate.mapon == 9) gamestate.mapon = ElevatorBackTo[gamestate.episode]; // back from secret else // // GOING TO SECRET LEVEL // if (playstate == ex_secretlevel) gamestate.mapon = 9; #else #define FROMSECRET1 3 #define FROMSECRET2 11 // // GOING TO SECRET LEVEL // if (playstate == ex_secretlevel) switch(gamestate.mapon) { case FROMSECRET1: gamestate.mapon = 18; break; case FROMSECRET2: gamestate.mapon = 19; break; } else // // COMING BACK FROM SECRET LEVEL // if (gamestate.mapon == 18 || gamestate.mapon == 19) switch(gamestate.mapon) { case 18: gamestate.mapon = FROMSECRET1+1; break; case 19: gamestate.mapon = FROMSECRET2+1; break; } #endif else // // GOING TO NEXT LEVEL // gamestate.mapon++; break; case ex_died: Died (); died = true; // don't "get psyched!" if (gamestate.lives > -1) break; // more lives left VW_FadeOut (); ClearMemory (); CheckHighScore (gamestate.score,gamestate.mapon+1); #pragma warn -sus #ifndef JAPAN _fstrcpy(MainMenu[viewscores].string,STR_VS); #endif MainMenu[viewscores].routine = CP_ViewScores; #pragma warn +sus return; case ex_victorious: #ifndef SPEAR VW_FadeOut (); #else VL_FadeOut (0,255,0,17,17,300); #endif ClearMemory (); Victory (); ClearMemory (); CheckHighScore (gamestate.score,gamestate.mapon+1); #pragma warn -sus #ifndef JAPAN _fstrcpy(MainMenu[viewscores].string,STR_VS); #endif MainMenu[viewscores].routine = CP_ViewScores; #pragma warn +sus return; default: ClearMemory (); break; } } while (1); }
void SoundManager::StartMusic() { StartMusic(m_curTrack); }
void PlayLoop (void) { id0_int_t give; void (*think)(struct objstruct *); // REFKEEN: C++ patch ingame = true; SD_SetTimeCount(0); playstate = (exittype)0; //playstate = TimeCount = 0; gamestate.shotpower = handheight = 0; pointcount = pointsleft = 0; DrawLevelNumber (gamestate.mapon); DrawBars (); #ifndef PROFILE fizzlein = true; // fizzle fade in the first refresh #endif /*TimeCount = */lasttimecount = lastnuke = 0; PollControls (); // center mouse StartMusic (); do { #ifndef PROFILE PollControls(); #else c.xaxis = 1; // if (++TimeCount == 300) // return; SD_SetTimeCount(SD_GetTimeCount()+1); if (SD_GetTimeCount() == 300) return; #endif for (obj = player;obj;obj = obj->next) if (obj->active) { if (obj->ticcount) { obj->ticcount-=tics; while ( obj->ticcount <= 0) { think = obj->state->thinkptr; if (think) { think (obj); if (!obj->state) { RemoveObj (obj); goto nextactor; } } obj->state = obj->state->next; if (!obj->state) { RemoveObj (obj); goto nextactor; } if (!obj->state->tictime) { obj->ticcount = 0; goto nextactor; } if (obj->state->tictime>0) obj->ticcount += obj->state->tictime; } } think = obj->state->thinkptr; if (think) { think (obj); if (!obj->state) RemoveObj (obj); } nextactor:; } if (bordertime) { bordertime -= tics; if (bordertime<=0) { bordertime = 0; VW_ColorBorder (3); } } if (pointcount) { pointcount -= tics; if (pointcount <= 0) { pointcount += POINTTICS; give = (pointsleft > 1000)? 1000 : ( (pointsleft > 100)? 100 : ((pointsleft < 20)? pointsleft : 20) ); SD_PlaySound (GETPOINTSSND); AddPoints (give); pointsleft -= give; if (!pointsleft) pointcount = 0; } } ThreeDRefresh (); CheckKeys(); // (REFKEEN) SPECIAL - Without this the game // can run very fast, even if it's not noticeable // (a lot of PlayLoop iterations and consumed CPU power) // // Notes: // 1. Should NOT be called from ThreeDRefresh/CalcTics, // because we don't always want that to be done // (e.g., FizzleFade effect right after loading C4 saved game). // 2. SHOULD be called AFTER CheckKeys. That function resets // lasttimecount (just like CalcTics) if the debug key modifier // (F10 in Cat. 3-D/Abyss, Backspace in Armageddon/Apocalypse) // is held. As a consequence, if the wait is done before the // call to CheckKeys then the game may seem to get stuck while // the debug key modifier is held. BE_ST_TimeCountWaitFromSrc(SD_GetTimeCount(), 1); // if (singlestep) { VW_WaitVBL(14); lasttimecount = SD_GetTimeCount(); } if (extravbls) VW_WaitVBL(extravbls); }while (!playstate); StopMusic (); ingame = false; if (bordertime) { bordertime = 0; VW_ColorBorder (3); } if (!abortgame) AddPoints (pointsleft); else abortgame = false; }
INT_PTR CALLBACK GameRun(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); HDC hDC = 0; HBRUSH hBrush; HPEN hPen; PAINTSTRUCT PtStr; switch (message) { case WM_TIMER: SetTimer(hDlg, 0, SPEED * 8 + 200, 0); if (!SnakeRun()) { PostMessage(hDlg, WM_GAMEOVER, wParam, lParam); } RECT rect; GetWindowRect(NULL,&rect); InvalidateRect(hDlg,&rect, false); hDC = GetDC(hDlg); InvalidateRgn(hDlg, NULL, false); UpdateWindow(hDlg); break; case WM_INITDIALOG: { StartMusic(); LinkList q = (LNode*)malloc(sizeof(LNode)); q->data = 1; q->next = NULL; SnakeHead->data = 1; SnakeHead->next = q; Head = q; srand((unsigned)time(NULL)); Food = rand() % (WidthNode*HeightNode) + 1; PostMessage(hDlg, WM_TIMER, wParam, lParam); } break; case WM_PAINT: { hDC = BeginPaint(hDlg, &PtStr); HBITMAP hbm; BITMAP bminfo; HDC memdc = CreateCompatibleDC(hDC); hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); hBrush = CreateSolidBrush(RGB(139, 69, 19)); SelectObject(hDC, hBrush); SelectObject(hDC, hPen); Rectangle(hDC, 0, 0, 1050, 570); hbm = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_SKYBG)); GetObject(hbm, sizeof(bminfo), &bminfo); SelectObject(memdc, hbm); BitBlt(hDC, 10, 10, bminfo.bmWidth, bminfo.bmHeight, memdc, 0, 0, SRCCOPY); DeleteDC(memdc); /* hPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255)); hBrush= CreateSolidBrush(RGB(0, 0, 0)); SelectObject(hDC, hBrush); SelectObject(hDC, hPen); Rectangle(hDC, 10, 10, 1040, 560); */ DrawSnakeFood(hDlg, hDC); EndPaint(hDlg, &PtStr); } break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); PlaySound(NULL, NULL, SND_FILENAME); DialogBox(NULL, MAKEINTRESOURCE(IDD_GAMEOVER), hDlg, GameOverPro); break; case WM_GAMEOVER: KillTimer(hDlg, 0); PlaySound(TEXT("gameover.wav"), NULL, SND_FILENAME | SND_ASYNC); EndFree(); Sleep(3000); PostMessage(hDlg, WM_CLOSE, wParam, lParam); break; default: switch (wParam) { case 0x70: DoCheckMenuItem(hDlg); break; case 0x6B: SPEED = SPEED - 5 < 0 ? 0 : SPEED - 5; break; case 0x6D: SPEED = SPEED + 5 > 100 ? 100 : SPEED + 5; break; case VK_UP: case KEY_W: if (RunDirection != DOWN) { RunDirection = UP; } break; case VK_DOWN: case KEY_S: if (RunDirection != UP) { RunDirection = DOWN; } break; case VK_LEFT: case KEY_A: if (RunDirection != RIGHT){ RunDirection = LEFT; } break; case VK_RIGHT: case KEY_D: if (RunDirection != LEFT) { RunDirection = RIGHT; } break; case VK_LBUTTON: if (message == WM_LBUTTONDOWN) { POINT mousePos; GetCursorPos(&mousePos); ScreenToClient(hDlg, &mousePos); int Space = Head->data; int x = 10 + ((Space - 1) % WidthNode) * 10, y = 10 + Space / WidthNode * 10; double Tan = (mousePos.y - y)*1.0 / (mousePos.x - x); double Result = asin(Tan); int RunDirectionTemp; if (Result > -PI / 2 && Result < -PI / 4) { if (mousePos.y > y) { RunDirectionTemp = UP; } else { RunDirectionTemp = DOWN; } } else if (Result > -PI / 4 && Result < 0) { if (mousePos.y > y) { RunDirectionTemp = LEFT; } else { RunDirectionTemp = RIGHT; } } else if (Result > 0 && Result < PI / 4) { if (mousePos.y > y) { RunDirectionTemp = RIGHT; } else { RunDirectionTemp = LEFT; } } else { if (mousePos.y > y) { RunDirectionTemp = DOWN; } else { RunDirectionTemp = UP; } } switch (RunDirectionTemp) { case UP: if (RunDirection != DOWN) { RunDirection = RunDirectionTemp; } break; case DOWN: if (RunDirection != UP) { RunDirection = RunDirectionTemp; } break; case LEFT: if (RunDirection != RIGHT) { RunDirection = RunDirectionTemp; } break; case RIGHT: if (RunDirection != LEFT) { RunDirection = RunDirectionTemp; } break; default: break; } } break; default: break; } } return (INT_PTR)FALSE; }
void SoundManager::ProcessRedbook() { if (!g_theProfileDB->IsUseRedbookAudio()) return; if (!m_musicEnabled) return; if (GetTickCount() > m_timeToCheckCD) { #if defined(USE_SDL) CDstatus status; if (m_cdrom) { status = SDL_CDStatus(m_cdrom); #else U32 status; if (m_redbook) { status = AIL_redbook_status(m_redbook); #endif switch (status) { #if !defined(USE_SDL) case REDBOOK_ERROR: #else case CD_TRAYEMPTY: break; case CD_ERROR: #endif break; #if !defined(USE_SDL) case REDBOOK_PLAYING: #else case CD_PLAYING: #endif break; #if !defined(USE_SDL) case REDBOOK_PAUSED: #else case CD_PAUSED: #endif break; #if !defined(USE_SDL) case REDBOOK_STOPPED: #else case CD_STOPPED: #endif if (m_curTrack != -1) PickNextTrack(); if (m_curTrack != -1 && !m_stopRedbookTemporarily) StartMusic(m_curTrack); break; } } m_timeToCheckCD = GetTickCount() + k_CHECK_CD_PERIOD; } } void SoundManager::Process(const uint32 &target_milliseconds, uint32 &used_milliseconds) { CivSound *sound; sint32 start_time_ms = GetTickCount(); if ((m_noSound) ||(m_usePlaySound)) { used_milliseconds = GetTickCount() - start_time_ms; return; } if (m_sfxSounds->GetCount() > 0) { m_soundWalker->SetList(m_sfxSounds); while (m_soundWalker->IsValid()) { sound = m_soundWalker->GetObj(); Assert(sound); if (!sound) continue; if (sound->IsPlaying()) { #if !defined(USE_SDL) if (AIL_quick_status(sound->GetHAudio()) == QSTAT_DONE) { #else if (!Mix_Playing(sound->GetChannel())) { #endif m_soundWalker->Remove(); delete sound; } else { m_soundWalker->Next(); } } } } if (m_voiceSounds->GetCount() > 0) { m_soundWalker->SetList(m_voiceSounds); while (m_soundWalker->IsValid()) { sound = m_soundWalker->GetObj(); Assert(sound); if (!sound) continue; if (sound->IsPlaying()) { #if !defined(USE_SDL) if (AIL_quick_status(sound->GetHAudio()) == QSTAT_DONE) { #else if ((-1 == sound->GetChannel()) || (!Mix_Playing(sound->GetChannel()))) { #endif m_soundWalker->Remove(); delete sound; } else { m_soundWalker->Next(); } } } } ProcessRedbook(); used_milliseconds = GetTickCount() - start_time_ms; } bool FindSoundinList(PointerList<CivSound> * sndList, sint32 soundID) { for ( PointerList<CivSound>::Walker walk(sndList); walk.IsValid(); walk.Next() ) { if (walk.GetObj()->GetSoundID() == soundID) { return true; } } return false; } void SoundManager::AddGameSound(const GAMESOUNDS &sound) { sint32 id = gamesounds_GetGameSoundID(sound); AddSound(SOUNDTYPE_SFX, 0, id, 0, 0); }
static void PlayGame() { Uint8 *keystate; int quit = 0; int turn; int prev_ticks = 0, cur_ticks = 0; /* for keeping track of timing */ int awaiting_respawn = 0; /* framerate counter variables */ int start_time, end_time; int frames_drawn = 0; /* respawn timer */ int respawn_timer = -1; prev_ticks = SDL_GetTicks(); start_time = time(NULL); /* Reset the score counters. */ player.score = 0; opponent.score = 0; /* Start sound playback. */ StartAudio(); StartMusic(); /* Start the music update thread. */ music_update_thread = SDL_CreateThread(UpdateMusicThread, NULL); if (music_update_thread == NULL) { printf("Unable to start music update thread.\n"); } /* Start the game! */ while ((quit == 0) && network_ok) { /* Determine how many milliseconds have passed since the last frame, and update our motion scaling. */ prev_ticks = cur_ticks; cur_ticks = SDL_GetTicks(); time_scale = (double)(cur_ticks-prev_ticks)/30.0; /* Update SDL's internal input state information. */ SDL_PumpEvents(); /* Grab a snapshot of the keyboard. */ keystate = SDL_GetKeyState(NULL); /* Lock the mutex so we can access the player's data. */ SDL_LockMutex(player_mutex); /* If this is a network game, take note of variables set by the network thread. These are handled differently for a scripted opponent. */ if (opponent_type == OPP_NETWORK) { /* Has the opponent respawned? */ if (network_opponent_respawn) { printf("Remote player has respawned.\n"); opponent.shields = 100; network_opponent_respawn = 0; awaiting_respawn = 0; } /* Has the local player been hit? */ if (local_player_hit) { local_player_hit--; player.shields -= PHASER_DAMAGE; ShowPhaserHit(&player); /* No need to check for death, the other computer will tell us. */ } } /* Update phasers. */ player.firing -= time_scale; if (player.firing < 0) player.firing = 0; opponent.firing -= time_scale; if (opponent.firing < 0) opponent.firing = 0; ChargePhasers(&player); /* If the local player is destroyed, the respawn timer will start counting. During this time the controls are disabled and explosion sequence occurs. */ if (respawn_timer >= 0) { respawn_timer++; if (respawn_timer >= ((double)RESPAWN_TIME / time_scale)) { respawn_timer = -1; InitPlayer(&player); /* Set the local_player_respawn flag so the network thread will notify the opponent of the respawn. */ local_player_respawn = 1; SetStatusMessage("GOOD LUCK, WARRIOR!"); } } /* Respond to input and network events, but not if we're in a respawn. */ if (respawn_timer == -1) { if (keystate[SDLK_q] || keystate[SDLK_ESCAPE]) quit = 1; /* Left and right arrow keys control turning. */ turn = 0; if (keystate[SDLK_LEFT]) turn += 10; if (keystate[SDLK_RIGHT]) turn -= 10; /* Forward and back arrow keys activate thrusters. */ player.accel = 0; if (keystate[SDLK_UP]) player.accel = PLAYER_FORWARD_THRUST; if (keystate[SDLK_DOWN]) player.accel = PLAYER_REVERSE_THRUST; /* Spacebar fires phasers. */ if (keystate[SDLK_SPACE]) { if (CanPlayerFire(&player)) { FirePhasers(&player); /* If it's a hit, either notify the opponent or exact the damage. Create a satisfying particle burst. */ if (!awaiting_respawn && CheckPhaserHit(&player,&opponent)) { ShowPhaserHit(&opponent); DamageOpponent(); /* If that killed the opponent, set the "awaiting respawn" state, to prevent multiple kills. */ if (opponent.shields <= 0 && opponent_type == OPP_NETWORK) awaiting_respawn = 1; } } } /* Turn. */ player.angle += turn * time_scale; if (player.angle < 0) player.angle += 360; if (player.angle >= 360) player.angle -= 360; /* If this is a network game, the remote player will tell us if we've died. Otherwise we have to check for failed shields. */ if (((opponent_type == OPP_NETWORK) && local_player_dead) || (player.shields <= 0)) { printf("Local player has been destroyed.\n"); local_player_dead = 0; /* Kaboom! */ KillPlayer(); /* Respawn. */ respawn_timer = 0; } } /* If this is a player vs. computer game, give the computer a chance. */ if (opponent_type == OPP_COMPUTER) { if (RunGameScript() != 0) { fprintf(stderr, "Ending game due to script error.\n"); quit = 1; } /* Check for phaser hits against the player. */ if (opponent.firing) { if (CheckPhaserHit(&opponent,&player)) { ShowPhaserHit(&player); player.shields -= PHASER_DAMAGE; /* Did that destroy the player? */ if (respawn_timer < 0 && player.shields <= 0) { KillPlayer(); respawn_timer = 0; } } } ChargePhasers(&opponent); UpdatePlayer(&opponent); } /* Update the player's position. */ UpdatePlayer(&player); /* Update the status information. */ SetPlayerStatusInfo(player.score, player.shields, player.charge); SetOpponentStatusInfo(opponent.score, opponent.shields); /* Make the camera follow the player (but impose limits). */ camera_x = player.world_x - SCREEN_WIDTH/2; camera_y = player.world_y - SCREEN_HEIGHT/2; if (camera_x < 0) camera_x = 0; if (camera_x >= WORLD_WIDTH-SCREEN_WIDTH) camera_x = WORLD_WIDTH-SCREEN_WIDTH-1; if (camera_y < 0) camera_y = 0; if (camera_y >= WORLD_HEIGHT-SCREEN_HEIGHT) camera_y = WORLD_HEIGHT-SCREEN_HEIGHT-1; /* Update the particle system. */ UpdateParticles(); /* Keep OpenAL happy. */ UpdateAudio(&player, &opponent); /* Redraw everything. */ DrawBackground(screen, camera_x, camera_y); DrawParallax(screen, camera_x, camera_y); DrawParticles(screen, camera_x, camera_y); if (opponent.firing) DrawPhaserBeam(&opponent, screen, camera_x, camera_y); if (player.firing) DrawPhaserBeam(&player, screen, camera_x, camera_y); if (respawn_timer < 0) DrawPlayer(&player); if (!awaiting_respawn) DrawPlayer(&opponent); UpdateStatusDisplay(screen); /* Release the mutex so the networking system can get it. It doesn't stay unlocked for very long, but the networking system should still have plenty of time. */ SDL_UnlockMutex(player_mutex); /* Flip the page. */ SDL_Flip(screen); frames_drawn++; } end_time = time(NULL); if (start_time == end_time) end_time++; /* Display the average framerate. */ printf("Drew %i frames in %i seconds, for a framerate of %.2f fps.\n", frames_drawn, end_time-start_time, (float)frames_drawn/(float)(end_time-start_time)); /* Terminate the music update thread. */ if (music_update_thread != NULL) { SDL_KillThread(music_update_thread); music_update_thread = NULL; } /* Stop audio playback. */ StopAudio(); StopMusic(); }
INT_PTR CALLBACK TwoGamePlayer(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); HDC hDC = 0; HBRUSH hBrush; HPEN hPen; PAINTSTRUCT PtStr; switch (message) { case WM_TIMER: SetTimer(hDlg, 0, SPEED * 8 + 200, 0); if (!TwoSnakeRun()) { PostMessage(hDlg, WM_GAMEOVER, wParam, lParam); } RECT rect; GetWindowRect(NULL, &rect); InvalidateRect(hDlg, &rect, false); hDC = GetDC(hDlg); InvalidateRgn(hDlg, NULL, false); UpdateWindow(hDlg); break; case WM_INITDIALOG: StartMusic(); Head_A = (LNode*)malloc(sizeof(LNode)); Head_A->data = 1; Head_A->next = NULL; SnakeHead_A->data = 1; SnakeHead_A->next = Head_A; Head_B = (LNode*)malloc(sizeof(LNode)); Head_B->data = 1; Head_B->next = NULL; SnakeHead_B->data = 1; SnakeHead_B->next = Head_B; srand((unsigned)time(NULL)); FoodQueue.front = 0; FoodQueue.data[FoodQueue.front] = rand() % (WindowWidth*WindowHeight + 1); FoodQueue.front++; PostMessage(hDlg, WM_TIMER, wParam, lParam); break; case WM_PAINT: hDC = BeginPaint(hDlg, &PtStr); hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); hBrush = CreateSolidBrush(RGB(139, 69, 19)); SelectObject(hDC, hBrush); SelectObject(hDC, hPen); Rectangle(hDC, 0, 0, 1050, 570); hPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255)); hBrush = CreateSolidBrush(RGB(0, 0, 0)); SelectObject(hDC, hBrush); SelectObject(hDC, hPen); Rectangle(hDC, 10, 10, 510, 560); Rectangle(hDC, 540, 10, 1040, 560); TwoDrawSnakeFood(hDlg, hDC); EndPaint(hDlg, &PtStr); break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); PlaySound(NULL, NULL, SND_FILENAME); DialogBox(NULL, MAKEINTRESOURCE(IDD_TWOGAMEOVER), hDlg, TwoGameOverPro); break; case WM_GAMEOVER: KillTimer(hDlg, 0); PlaySound(TEXT("E:\\³ÌÐò\\ÓïÑÔ³ÌÐò\\Windows±à³Ì\\Ì°³ÔÉß\\Ì°³ÔÉß\\Ì°³ÔÉß\\gameover.wav"), NULL, SND_FILENAME | SND_ASYNC); Point_A = SnakeHead_A->data - 1; Point_B = SnakeHead_B->data - 1; TwoEndFree(); Sleep(3000); PostMessage(hDlg, WM_CLOSE, wParam, lParam); break; default: switch (wParam) { case 0x70: DoCheckMenuItem(hDlg); break; case 0x6B: SPEED = SPEED - 5 < 0 ? 0 : SPEED - 5; break; case 0x6D: SPEED = SPEED + 5 > 100 ? 100 : SPEED + 5; break; case KEY_A: if (RunDirection_A != RIGHT) { RunDirection_A = LEFT; } break; case KEY_S: if (RunDirection_A != UP) { RunDirection_A = DOWN; } break; case KEY_W: if (RunDirection_A != DOWN) { RunDirection_A = UP; } break; case KEY_D: if (RunDirection_A != LEFT) { RunDirection_A = RIGHT; } case VK_UP: if (RunDirection_B != DOWN) { RunDirection_B = UP; } break; case VK_DOWN: if (RunDirection_B != UP) { RunDirection_B = DOWN; } break; case VK_LEFT: if (RunDirection_B != RIGHT) { RunDirection_B = LEFT; } break; case VK_RIGHT: if (RunDirection_B != LEFT) { RunDirection_B = RIGHT; } break; break; default: break; } break; } return (INT_PTR)FALSE; }
static void PlayGame() { Uint8 *keystate; int quit = 0; int turn; int prev_ticks = 0, cur_ticks = 0; /* for keeping track of timing */ /* framerate counter variables */ int start_time, end_time; int frames_drawn = 0; /* Start audio playback. */ StartAudio(); StartMusic(); /* Start the music update thread. */ music_update_thread = SDL_CreateThread(UpdateMusicThread, NULL); if (music_update_thread == NULL) { printf("Unable to start music update thread.\n"); } prev_ticks = SDL_GetTicks(); start_time = time(NULL); while (quit == 0) { /* Determine how many milliseconds have passed since the last frame, and update our motion scaling. */ prev_ticks = cur_ticks; cur_ticks = SDL_GetTicks(); time_scale = (double)(cur_ticks-prev_ticks)/30.0; /* Update SDL's internal input state information. */ SDL_PumpEvents(); /* Grab a snapshot of the keyboard. */ keystate = SDL_GetKeyState(NULL); /* Respond to input. */ if (keystate[SDLK_q] || keystate[SDLK_ESCAPE]) quit = 1; /* Left and right arrow keys control turning. */ turn = 0; if (keystate[SDLK_LEFT]) turn += 15; if (keystate[SDLK_RIGHT]) turn -= 15; /* Forward and back arrow keys activate thrusters. */ player.accel = 0; if (keystate[SDLK_UP]) player.accel = PLAYER_FORWARD_THRUST; if (keystate[SDLK_DOWN]) player.accel = PLAYER_REVERSE_THRUST; /* Spacebar slows the ship down. */ if (keystate[SDLK_SPACE]) { player.velocity *= 0.8; } /* Just an amusing way to test the particle system. */ if (keystate[SDLK_e]) { CreateParticleExplosion( player.world_x, player.world_y, 255, 255, 255, 10, 300); CreateParticleExplosion( player.world_x, player.world_y, 255, 0, 0, 5, 100); CreateParticleExplosion( player.world_x, player.world_y, 255, 255, 0, 2, 50); } /* Allow a turn of four degrees per frame. */ player.angle += turn * time_scale; if (player.angle < 0) player.angle += 360; if (player.angle >= 360) player.angle -= 360; /* Update the player's position. */ UpdatePlayer(&player); UpdatePlayer(&opponent); /* Make the camera follow the player (but impose limits). */ camera_x = player.world_x - SCREEN_WIDTH/2; camera_y = player.world_y - SCREEN_HEIGHT/2; if (camera_x < 0) camera_x = 0; if (camera_x >= WORLD_WIDTH-SCREEN_WIDTH) camera_x = WORLD_WIDTH-SCREEN_WIDTH-1; if (camera_y < 0) camera_y = 0; if (camera_y >= WORLD_HEIGHT-SCREEN_HEIGHT) camera_y = WORLD_HEIGHT-SCREEN_HEIGHT-1; /* Update the particle system. */ UpdateParticles(); /* Keep OpenAL happy. */ UpdateAudio(&player, &opponent); /* Redraw everything. */ DrawBackground(screen, camera_x, camera_y); DrawParallax(screen, camera_x, camera_y); DrawParticles(screen, camera_x, camera_y); DrawPlayer(&player); DrawPlayer(&opponent); /* Flip the page. */ SDL_Flip(screen); frames_drawn++; } end_time = time(NULL); if (start_time == end_time) end_time++; /* Display the average framerate. */ printf("Drew %i frames in %i seconds, for a framerate of %.2f fps.\n", frames_drawn, end_time-start_time, (float)frames_drawn/(float)(end_time-start_time)); /* Terminate the music update thread. */ if (music_update_thread != NULL) { SDL_KillThread(music_update_thread); music_update_thread = NULL; } /* Stop audio playback. */ StopAudio(); StopMusic(); }
void CheckKeys (void) { boolean one_eighty=false; Uint8 scan; static boolean Plus_KeyReleased; static boolean Minus_KeyReleased; static boolean I_KeyReleased; static boolean S_KeyReleased; #if IN_DEVELOPMENT || BETA_TEST // if (DebugOk && (Keyboard[sc_p] || PP_step)) // PicturePause (); #endif if (screenfaded || demoplayback) // don't do anything with a faded screen return; scan = LastScan; #if IN_DEVELOPMENT #ifdef ACTIVATE_TERMINAL if (Keyboard[sc_9] && Keyboard[sc_0]) ActivateTerminal(true); #endif #endif // // SECRET CHEAT CODE: 'JAM' // #if GAME_VERSION != SHAREWARE_VERSION if (Keyboard[sc_j] || Keyboard[sc_a] || Keyboard[sc_m]) { if (jam_buff[sizeof(jam_buff_cmp)-1] != LastScan) { memcpy(jam_buff,jam_buff+1,sizeof(jam_buff_cmp)-1); jam_buff[sizeof(jam_buff_cmp)-1] = LastScan; } } #endif CheckMusicToggle(); if (gamestate.rpower) { if (in_is_binding_pressed(e_bi_radar_magnify)) { if (Plus_KeyReleased && gamestate.rzoom<2) { UpdateRadarGuage(); gamestate.rzoom++; Plus_KeyReleased=false; } } else Plus_KeyReleased=true; if (in_is_binding_pressed(e_bi_radar_minify)) { if (Minus_KeyReleased && gamestate.rzoom) { UpdateRadarGuage(); gamestate.rzoom--; Minus_KeyReleased=false; } } else Minus_KeyReleased=true; } if (in_is_binding_pressed(e_bi_sfx)) { if (S_KeyReleased) { if ((SoundMode != sdm_Off) || (DigiMode!=sds_Off)) { if (SoundMode != sdm_Off) { SD_WaitSoundDone(); SD_SetSoundMode(sdm_Off); } if (DigiMode!=sds_Off) SD_SetDigiDevice(sds_Off); memcpy((char *)&SoundOn[55],"OFF.",4); } else { ClearMemory(); if (SoundBlasterPresent || AdLibPresent) SD_SetSoundMode(sdm_AdLib); else SD_SetSoundMode(sdm_Off); if (SoundBlasterPresent) SD_SetDigiDevice(sds_SoundBlaster); else if (SoundSourcePresent) SD_SetDigiDevice(sds_SoundSource); else SD_SetDigiDevice(sds_Off); CA_LoadAllSounds(); memcpy((char *)&SoundOn[55],"ON. ",4); } DISPLAY_TIMED_MSG(SoundOn,MP_BONUS,MT_GENERAL); S_KeyReleased=false; } } else S_KeyReleased=true; if (Keyboard[sc_return]) { #if (GAME_VERSION != SHAREWARE_VERSION) || GEORGE_CHEAT char loop; if ((!memcmp(jam_buff,jam_buff_cmp,sizeof(jam_buff_cmp)))) { jam_buff[0]=0; for (loop=0; loop<NUMKEYS; loop++) if (gamestate.numkeys[static_cast<int>(loop)] < MAXKEYS) gamestate.numkeys[static_cast<int>(loop)]=1; gamestate.health = 100; gamestate.ammo = MAX_AMMO; gamestate.rpower = MAX_RADAR_ENERGY; if (!DebugOk) { gamestate.score = 0; gamestate.nextextra = EXTRAPOINTS; } gamestate.TimeCount += 42000L; for (loop=0; loop<NUMWEAPONS-1; loop++) GiveWeapon(loop); DrawWeapon(); DrawHealth(); DrawKeys(); DrawScore(); DISPLAY_TIMED_MSG("\r\r YOU CHEATER!",MP_INTERROGATE,MT_GENERAL); ForceUpdateStatusBar(); ClearMemory (); ClearSplitVWB (); VW_ScreenToScreen (static_cast<Uint16>(displayofs),static_cast<Uint16>(bufferofs),80,160); Message("\n NOW you're jammin'!! \n"); IN_ClearKeysDown(); IN_Ack(); CleanDrawPlayBorder(); } else if (!in_use_modern_bindings) #endif one_eighty=true; } // Handle quick turning! // if (!gamestate.turn_around) { // 90 degrees left // if (in_is_binding_pressed(e_bi_quick_left)) { gamestate.turn_around = -90; gamestate.turn_angle = player->angle + 90; if (gamestate.turn_angle > 359) gamestate.turn_angle -= ANGLES; } // 180 degrees right // if (in_is_binding_pressed(e_bi_turn_around) || one_eighty) { gamestate.turn_around = 180; gamestate.turn_angle = player->angle + 180; if (gamestate.turn_angle > 359) gamestate.turn_angle -= ANGLES; } // 90 degrees right // if (in_is_binding_pressed(e_bi_quick_right)) { gamestate.turn_around = 90; gamestate.turn_angle = player->angle - 90; if (gamestate.turn_angle < 0) gamestate.turn_angle += ANGLES; } } // // pause key weirdness can't be checked as a scan code // if (in_is_binding_pressed(e_bi_pause)) { SD_MusicOff(); fontnumber = 4; BMAmsg(PAUSED_MSG); IN_Ack(); IN_ClearKeysDown(); fontnumber = 2; RedrawStatusAreas(); SD_MusicOn(); Paused = false; ::in_clear_mouse_deltas(); return; } #if IN_DEVELOPMENT if (TestQuickSave) { // TestQuickSave--; scan = sc_f8; } if (TestAutoMapper) PopupAutoMap(); #endif scan = sc_none; if (Keyboard[sc_escape]) scan = sc_escape; else if (in_is_binding_pressed(e_bi_help)) scan = sc_f1; if (in_is_binding_pressed(e_bi_save)) scan = sc_f2; else if (in_is_binding_pressed(e_bi_load)) scan = sc_f3; else if (in_is_binding_pressed(e_bi_sound)) scan = sc_f4; else if (in_is_binding_pressed(e_bi_controls)) scan = sc_f6; else if (in_is_binding_pressed(e_bi_end_game)) scan = sc_f7; else if (in_is_binding_pressed(e_bi_quick_save)) scan = sc_f8; else if (in_is_binding_pressed(e_bi_quick_load)) scan = sc_f9; else if (in_is_binding_pressed(e_bi_quick_exit)) scan = sc_f10; switch (scan) { case sc_f7: // END GAME case sc_f10: // QUIT TO DOS FinishPaletteShifts(); ClearMemory(); US_ControlPanel(scan); CleanDrawPlayBorder(); return; case sc_f2: // SAVE MISSION case sc_f8: // QUICK SAVE // Make sure there's room to save... // ClearMemory(); FinishPaletteShifts(); if (!CheckDiskSpace(DISK_SPACE_NEEDED, CANT_SAVE_GAME_TXT, cds_id_print)) { CleanDrawPlayBorder(); break; } case sc_f1: // HELP case sc_f3: // LOAD MISSION case sc_f4: // SOUND MENU case sc_f5: // RESIZE VIEW case sc_f6: // CONTROLS MENU case sc_f9: // QUICK LOAD case sc_escape: // MAIN MENU refresh_screen = true; if (scan < sc_f8) VW_FadeOut(); StopMusic(); ClearMemory(); ClearSplitVWB(); US_ControlPanel(scan); if (refresh_screen) { boolean old = loadedgame; loadedgame = false; DrawPlayScreen(false); loadedgame = old; } ClearMemory(); if (!sqActive || !loadedgame) StartMusic(false); IN_ClearKeysDown(); if (loadedgame) { PreloadGraphics(); loadedgame = false; DrawPlayScreen(false); } else if (!refresh_screen) CleanDrawPlayBorder(); if (!sqActive) StartMusic(false); return; } scan = sc_none; if (in_is_binding_pressed(e_bi_stats)) PopupAutoMap(); if (Keyboard[sc_back_quote]) { Keyboard[sc_back_quote] = 0; TryDropPlasmaDetonator(); } if ((DebugOk || gamestate.flags & GS_MUSIC_TEST) && (Keyboard[sc_backspace])) { Uint8 old_num=music_num; if (gamestate.flags & GS_MUSIC_TEST) { if (Keyboard[sc_left_arrow]) { if (music_num) music_num--; Keyboard[sc_left_arrow]=false; } else if (Keyboard[sc_right_arrow]) { if (music_num < LASTMUSIC-1) music_num++; Keyboard[sc_right_arrow]=false; } if (old_num != music_num) { ClearMemory(); delete [] audiosegs[STARTMUSIC + old_num]; audiosegs[STARTMUSIC + old_num] = NULL; StartMusic(false); DrawScore(); } } if (old_num == music_num) { fontnumber=4; SETFONTCOLOR(0,15); if (DebugKeys()) { CleanDrawPlayBorder(); } ::in_clear_mouse_deltas(); lasttimecount = TimeCount; return; } } if (in_is_binding_pressed(e_bi_attack_info)) { if (I_KeyReleased) { gamestate.flags ^= GS_ATTACK_INFOAREA; if (gamestate.flags & GS_ATTACK_INFOAREA) DISPLAY_TIMED_MSG(attacker_info_enabled,MP_ATTACK_INFO,MT_GENERAL); else DISPLAY_TIMED_MSG(attacker_info_disabled,MP_ATTACK_INFO,MT_GENERAL); I_KeyReleased = false; } } else I_KeyReleased = true; #ifdef CEILING_FLOOR_COLORS if (in_is_binding_pressed(e_bi_ceiling)) { gamestate.flags ^= GS_DRAW_CEILING; in_reset_binding_state(e_bi_ceiling); } if (in_is_binding_pressed(e_bi_flooring)) { ThreeDRefresh(); ThreeDRefresh(); gamestate.flags ^= GS_DRAW_FLOOR; in_reset_binding_state(e_bi_flooring); #if DUAL_SWAP_FILES ChangeSwapFiles(true); #endif } #endif if (in_is_binding_pressed(e_bi_lightning)) { in_reset_binding_state(e_bi_lightning); gamestate.flags ^= GS_LIGHTING; } }
void CheckKeys (void) { int i; byte scan; unsigned temp; if (screenfaded || demoplayback) // don't do anything with a faded screen return; scan = LastScan; #ifdef SPEAR // // SECRET CHEAT CODE: TAB-G-F10 // if (Keyboard[sc_Tab] && Keyboard[sc_G] && Keyboard[sc_F10]) { WindowH = 160; if (godmode) { Message ("God mode OFF"); SD_PlaySound (NOBONUSSND); } else { Message ("God mode ON"); SD_PlaySound (ENDBONUS2SND); } IN_Ack(); godmode ^= 1; DrawAllPlayBorderSides (); IN_ClearKeysDown(); return; } #endif // // SECRET CHEAT CODE: 'MLI' // if (Keyboard[sc_M] && Keyboard[sc_L] && Keyboard[sc_I]) { gamestate.health = 100; gamestate.ammo = 99; gamestate.keys = 3; gamestate.score = 0; gamestate.TimeCount += 42000L; GiveWeapon (wp_chaingun); DrawWeapon(); DrawHealth(); DrawKeys(); DrawAmmo(); DrawScore(); ClearMemory (); CA_CacheGrChunk (STARTFONT+1); ClearSplitVWB (); VW_ScreenToScreen (displayofs,bufferofs,80,160); Message(STR_CHEATER1"\n" STR_CHEATER2"\n\n" STR_CHEATER3"\n" STR_CHEATER4"\n" STR_CHEATER5); UNCACHEGRCHUNK(STARTFONT+1); PM_CheckMainMem (); IN_ClearKeysDown(); IN_Ack(); DrawAllPlayBorder (); } // // OPEN UP DEBUG KEYS // #ifndef SPEAR if (Keyboard[sc_BackSpace] && Keyboard[sc_LShift] && Keyboard[sc_Alt] && MS_CheckParm("goobers")) #else if (Keyboard[sc_BackSpace] && Keyboard[sc_LShift] && Keyboard[sc_Alt] && MS_CheckParm("debugmode")) #endif { ClearMemory (); CA_CacheGrChunk (STARTFONT+1); ClearSplitVWB (); VW_ScreenToScreen (displayofs,bufferofs,80,160); Message("Debugging keys are\nnow available!"); UNCACHEGRCHUNK(STARTFONT+1); PM_CheckMainMem (); IN_ClearKeysDown(); IN_Ack(); DrawAllPlayBorderSides (); DebugOk=1; } // // TRYING THE KEEN CHEAT CODE! // if (Keyboard[sc_B] && Keyboard[sc_A] && Keyboard[sc_T]) { ClearMemory (); CA_CacheGrChunk (STARTFONT+1); ClearSplitVWB (); VW_ScreenToScreen (displayofs,bufferofs,80,160); Message("Commander Keen is also\n" "available from Apogee, but\n" "then, you already know\n" "that - right, Cheatmeister?!"); UNCACHEGRCHUNK(STARTFONT+1); PM_CheckMainMem (); IN_ClearKeysDown(); IN_Ack(); DrawAllPlayBorder (); } // // pause key weirdness can't be checked as a scan code // if (Paused) { bufferofs = displayofs; LatchDrawPic (20-4,80-2*8,PAUSEDPIC); SD_MusicOff(); IN_Ack(); IN_ClearKeysDown (); SD_MusicOn(); Paused = False; //if (MousePresent) // PORT // Mouse(MDelta); // Clear accumulated mouse movement return; } // // F1-F7/ESC to enter control panel // if ( #ifndef DEBCHECK scan == sc_F10 || #endif scan == sc_F9 || scan == sc_F7 || scan == sc_F8) // pop up quit dialog { ClearMemory (); ClearSplitVWB (); VW_ScreenToScreen (displayofs,bufferofs,80,160); US_ControlPanel(scan); DrawAllPlayBorderSides (); if (scan == sc_F9) StartMusic (); PM_CheckMainMem (); SETFONTCOLOR(0,15); IN_ClearKeysDown(); return; } if ( (scan >= sc_F1 && scan <= sc_F9) || scan == sc_Escape) { StopMusic (); ClearMemory (); VW_FadeOut (); US_ControlPanel(scan); SETFONTCOLOR(0,15); IN_ClearKeysDown(); DrawPlayScreen (); if (!startgame && !loadedgame) { VW_FadeIn (); StartMusic (); } if (loadedgame) playstate = ex_abort; lasttimecount = TimeCount; //if (MousePresent) // PORT // Mouse(MDelta); // Clear accumulated mouse movement PM_CheckMainMem (); return; } // // TAB-? debug keys // if (Keyboard[sc_Tab] && DebugOk) { CA_CacheGrChunk (STARTFONT); fontnumber=0; SETFONTCOLOR(0,15); DebugKeys(); //if (MousePresent) // PORT // Mouse(MDelta); // Clear accumulated mouse movement lasttimecount = TimeCount; return; } }