コード例 #1
0
ファイル: main.c プロジェクト: leventguel/c-lang-exercises
/* Music update thread. Calls UpdateMusic approximately twenty times a second.
   This decouples the music system from the game loop. See the text for an
   explanation. */
int UpdateMusicThread(void *arg)
{
    arg++; // avoid compiler warning
    for (;;) {
	UpdateMusic();
	SDL_Delay(50);
    }

    return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: leventguel/c-lang-exercises
/* Music update thread. Calls UpdateMusic approximately twenty times a second.
   This decouples the music system from the game loop. See the text for an
   explanation. */
int UpdateMusicThread(void *arg)
{
    /* Avoid compiler warning. */
    arg += 0;

    for (;;) {
	UpdateMusic();
	SDL_Delay(10);
    }

    return 0;
}
コード例 #3
0
bool CRecentlyAddedJob::DoWork()
{
  bool ret = true;
  if (m_flag & Audio)
    ret &= UpdateMusic();
  
  if (m_flag & Video)
    ret &= UpdateVideo();
  
  if (m_flag & Totals)
    ret &= UpdateTotal();
    
  return ret; 
}
コード例 #4
0
ファイル: HomeShelfJob.cpp プロジェクト: MrMC/mrmc
bool CHomeShelfJob::DoWork()
{
  bool ret = true;
  if (m_flag & Audio)
    ret &= UpdateMusic();

  if (m_flag & Video)
    ret &= UpdateVideo();

  if (m_flag & Totals)
    ret &= UpdateTotal();

  return ret;
}
コード例 #5
0
ファイル: gameplay_state.cpp プロジェクト: google/zooshi
void GameplayState::AdvanceFrame(int delta_time, int* next_state) {
  // Update the world.
  world_->entity_manager.UpdateComponents(delta_time);
  UpdateMainCamera(&main_camera_, world_);
  UpdateMusic(&world_->entity_manager, &previous_lap_, &percent_, delta_time,
              &music_channel_lap_1_, &music_channel_lap_2_,
              &music_channel_lap_3_);

  if (input_system_->GetButton(fplbase::FPLK_F9).went_down()) {
    world_->draw_debug_physics = !world_->draw_debug_physics;
  }
  if (input_system_->GetButton(fplbase::FPLK_F8).went_down()) {
    world_->skip_rendermesh_rendering = !world_->skip_rendermesh_rendering;
  }

  // The state machine for the world may request a state change.
  *next_state = requested_state_;

  // Switch into scene lab if the keyboard requests.
  // Switch back to scene lab if we're single stepping.
  if (scene_lab_ && (input_system_->GetButton(fplbase::FPLK_F10).went_down() ||
                     input_system_->GetButton(fplbase::FPLK_1).went_down() ||
                     world_->is_single_stepping)) {
    if (!world_->is_single_stepping) {
      scene_lab::GenericCamera camera;
      camera.position = main_camera_.position();
      camera.facing = main_camera_.facing();
      camera.up = main_camera_.up();
      scene_lab_->SetInitialCamera(camera);
    }
    *next_state = kGameStateSceneLab;
    world_->is_single_stepping = false;
  }

  // Pause the game.
  if (input_system_->GetButton(fplbase::FPLK_ESCAPE).went_down() ||
      input_system_->GetButton(fplbase::FPLK_AC_BACK).went_down()) {
    audio_engine_->PlaySound(sound_pause_);
    *next_state = kGameStatePause;
  }
  fader_->AdvanceFrame(delta_time);
}
コード例 #6
0
void HBlank()
{
	DISABLE_INTERRUPTS();

	if(f_hbla_pal)
	{
		f_hbla_pal = false;
		VDP_SetAddr(0, VDP_CRAM_Write);

		for(int i = 0; i < 64; i++)
			VDP_Data(v_pal_water[i]);

		VDP_RegWrite(0x0A, 223); // reset HBlank register

		if(f_FFFFF64F)
		{
			f_FFFFF64F = false;
			V_H_BlankCommon();
			UpdateMusic();
		}
	}
}
コード例 #7
0
void VBlank()
{
	auto routine = v_vbla_routine;

	if(routine != 0)
	{
		VDP_SetAddr(0, VDP_VSRAM_Write);
		VDP_Data(v_scrposy_dup);
		VBlankWaitPAL();
		v_vbla_routine = 0;
		f_hbla_pal = true;
	}

	switch(routine)
	{
		case VBlank_00:
			if(v_gamemode & GameMode_Level && v_zone == Zone_LZ)
			{
				// VBlankWaitPAL();
				f_hbla_pal = true;
				STOP_Z80();
				WAIT_Z80();
				VBlankWriteWaterPalette();
				SetHBlankRegister();
				START_Z80();
			}
			break;

		// Seeeeegaaaaaa!
		case VBlank_Sega:
			VBlankCommon();
			// fall through
		// One frame between SEGA palette cycle and SEEEGAAAA
		case VBlank_SegaSwitch:
			VBlankDecreaseDemoLength();
			break;

		// Title screen, Credits screen
		case VBlank_Title:
			VBlankCommon();
			DrawTitleCreditsBGTiles();
			PLC_Decode9Tiles();
			break;

		// Palette fading
		case VBlank_PaletteFade:
			VBlankCommon();
			SetHBlankRegister();
			PLC_Decode9Tiles();
			break;

		case VBlank_06:
			VBlankCommon();
			break;

		case VBlank_0E:
			VBlankCommon();
			v_FFFFF628++;
			v_vbla_routine = 0x0E;
			break;

		// Game paused
		case VBlank_Paused:
			if(v_gamemode == GameMode_Special)
				goto _vblank0A;
			// fall through
		// Level main loop
		case VBlank_Level:
			VBlankCommon2();
			VBlankBackupScrollVars();

			if(v_hbla_line >= 96)
				V_H_BlankCommon();
			else
			{
				f_FFFFF64F = true;
				v_vbla_count++;
				return;
			}
			break;

		// Waiting for level title card, special stage results screen
		case VBlank_Title:
		// Ending screen
		case VBlank_Ending:
			VBlankCommon2();
			VBlankBackupScrollVars();
			LoadTilesAsYouMove();
			AnimateLevelGfx();
			HUD_Update();
			PLC_Decode9Tiles();
			break;

		// Special stage
		case VBlank_Special:
		_vblank0A:
			STOP_Z80();
			WAIT_Z80();
			ReadJoypads();
			WriteCRAM(v_pal_dry, 0x80, 0);
			VBlankWriteSpriteAndScroll();
			START_Z80();
			PalCycle_SS();
			VBlankWriteSonic();
			VBlankDecreaseDemoLength();
			break;

		// Continue screen, special stage spin-and-fade-to-white
		case VBlank_Continue:
			STOP_Z80();
			WAIT_Z80();
			ReadJoypads();
			WriteCRAM(v_pal_dry, 0x80, 0);
			VBlankWriteSpriteAndScroll();
			START_Z80();
			VBlankWriteSonic();
			VBlankDecreaseDemoLength();
			break;

		default: assert(false);
	}

	UpdateMusic();
	v_vbla_count++;
}