bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename)
{
	if (!m_Initialized)
		InitFileSystem();

	const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);

	if (!pFileInfo)
		return false;

	u64 remainingSize = pFileInfo->m_FileSize;
	u64 fileOffset = pFileInfo->m_Offset;

	File::IOFile f(_rExportFilename, "wb");
	if (!f)
		return false;

	bool result = true;

	while (remainingSize)
	{
		// Limit read size to 128 MB
		size_t readSize = (size_t)min(remainingSize, (u64)0x08000000);

		std::vector<u8> buffer(readSize);

		result = m_rVolume->Read(fileOffset, readSize, &buffer[0]);

		if (!result)
			break;

		f.WriteBytes(&buffer[0], readSize);

		remainingSize -= readSize;
		fileOffset += readSize;
	}

	return result;
}
Exemple #2
0
u64 CFileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize,
                               u64 _OffsetInFile)
{
  if (!m_Initialized)
    InitFileSystem();

  const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
  if (pFileInfo == nullptr)
    return 0;

  if (_OffsetInFile >= pFileInfo->m_FileSize)
    return 0;

  u64 read_length = std::min(_MaxBufferSize, pFileInfo->m_FileSize - _OffsetInFile);

  DEBUG_LOG(DISCIO, "Reading %" PRIx64 " bytes at %" PRIx64 " from file %s. Offset: %" PRIx64
                    " Size: %" PRIx64,
            read_length, _OffsetInFile, _rFullPath.c_str(), pFileInfo->m_Offset,
            pFileInfo->m_FileSize);

  m_rVolume->Read(pFileInfo->m_Offset + _OffsetInFile, read_length, _pBuffer, m_Wii);
  return read_length;
}
bool VismaRunnerApplication::Init()
{
	instance = this;
	//if(!InitSimple("Voxel octree application"))
	//return false;

	glm::vec2 windowSize(1280, 768);
#ifdef OCULUS_RENDER
	oculus = share(new OculusImpl());
	oculus->InitOculus();
#endif

	if (!InitContextBasics() || !InitFileSystem() || !LoadConfig())
	{
		return false;
	}

	srand(GetContext().GetTimer()->get_real_time());

	//If we want to override some settings for window.
	auto & video_group = GetContext().GetApplicationSettingsManager()->GetGroup("video");
	video_group.GetVar("window_width").Value(int(windowSize.x));
	video_group.GetVar("window_height").Value(int(windowSize.y));
	InitWindowAndOpenGL("The game app");

#ifdef OCULUS_RENDER
	oculus->InitOculusBuffers();
#endif

	GetContext().SetInputHandler(new InputHandler(GetContext().GetWindow()));
	GetContext().GetWindow()->SigKeyEvent().connect(sigc::mem_fun(this, &VismaRunnerApplication::OnKeyEvent));
	GetContext().SetGUIEnvironment(new GUIEnvironment());

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	glClearColor(0.5f, 0.5f, 0.75f, 0);

	auto fontRenderer = GetContext().GetGUIEnvironment()->GetFontRenderer();
	fontRenderer->CreateFontFamily("voxeltext", 16, "res/gui/fonts/pixel.ttf");
	fontRenderer->CreateFontFamily("voxeltext24", 24, "res/gui/fonts/pixel.ttf");
	fontRenderer->CreateFontFamily("voxeltext48", 48, "res/gui/fonts/pixel.ttf");
	fontRenderer->CreateFontFamily("scoremono32", 36, "res/gui/fonts/pixelmono.otf");
	fontRenderer->CreateFontFamily("scoremono48", 48, "res/gui/fonts/pixelmono.otf");

	soundManager = share(new SoundManager());

	soundManager->AddSoundSource("res/sounds/music/level1.ogg", "BGM_Level1");
	soundManager->AddSoundSource("res/sounds/music/level2.ogg", "BGM_Level2");
	soundManager->AddSoundSource("res/sounds/music/level3.ogg", "BGM_Level3");
	soundManager->AddSoundSource("res/sounds/music/level4.ogg", "BGM_Level4");
	soundManager->AddSoundSource("res/sounds/music/level5.ogg", "BGM_Level5");
	soundManager->AddSoundSource("res/sounds/music/level6.ogg", "BGM_Level6");
	soundManager->AddSoundSource("res/sounds/music/level7.ogg", "BGM_Level7");
	soundManager->AddSoundSource("res/sounds/music/level8.ogg", "BGM_Level8");

	soundManager->AddSoundSource("res/sounds/misc/ready.ogg", "AnnouncerReady");
	soundManager->AddSoundSource("res/sounds/misc/steady.ogg", "AnnouncerSteady");
	soundManager->AddSoundSource("res/sounds/misc/go.ogg", "AnnouncerGo");

	soundManager->AddSoundSource("res/sounds/jumps/SFX_Jump_17.wav", "SFX_Jump");

	soundManager->AddSoundSource("res/sounds/explosions/SFX_Explosion_01.ogg", "SFX_Explosion1");
	soundManager->AddSoundSource("res/sounds/explosions/SFX_Explosion_02.ogg", "SFX_Explosion2");
	soundManager->AddSoundSource("res/sounds/explosions/SFX_Explosion_03.ogg", "SFX_Explosion3");

	soundManager->AddToBGMList("BGM_Level1");
	soundManager->AddToBGMList("BGM_Level2");
	soundManager->AddToBGMList("BGM_Level3");
	soundManager->AddToBGMList("BGM_Level4");
	soundManager->AddToBGMList("BGM_Level5");
	soundManager->AddToBGMList("BGM_Level6");
	soundManager->AddToBGMList("BGM_Level7");
	soundManager->AddToBGMList("BGM_Level8");

	gameStateManager = share(new GameStateManager());

	gameStateManager->RegisterState<MainGameState>("MainGameState");
	gameStateManager->RegisterState<ScoreBoardMenuState>("ScoreBoardMenuState");

	gameStateManager->SetStartingState("ScoreBoardMenuState");

	scoreInfo = share(new ScoreBoardInfo());

	return true;
}
Exemple #4
0
//--------------------------------------------------------------------------
void main(void){
 //-------------------------------------------------------------------------
 if(USBIsAttached()){
   return; //Quit to ROM code to handle USB traffic
 }
 //-------------------------------------------------------------------------
 ph = &fsNandPhys.p; //physical disk is nand flash ROM handler
 map = FsMapTnCreate(ph,0); //logical disk mapper is ROM tiny mapper (read only)
 currentKeyMap = ZeroKeyMap;
 PERIP(GPIO1_MODE) = 0x30; //-\seting
 PERIP(GPIO1_DDR)  = 0x0F; //-/port GPIO1
 //-------------------------------------------------------------------------
 if(InitFileSystem()){
  while(1); // NO File System
 }
  else{ //FAT IS INIT
   minifatInfo.supportedSuffixes = supportedFiles; //play '.ogg' files
   player.totalFiles = OpenFile(0xffffU);
   SetVOL(0x10);
   player.currentFile = 0;
   player.nextStep = 1;
   player.offDelay = 0;
   player.randomOn = 0; /// Off random
   PERIP(GPIO1_ODATA) |= 0x01;
   SetHookFunction((u_int16)PowerOff, MyPowerOff);
   if(OpenFile(player.currentFile) < 0){
    OpenFile(player.currentFile);
    PlayCurrentFile();
   }
   player.currentFile++;
   currentKeyMap = MyKeyMap;
   while (1) {//player loop
    // "Previous" file selected at the first file
    if (player.currentFile < 1) {
     player.currentFile = (player.totalFiles-1);
    }
    // "Next" file selected at or after the last file
    if (player.currentFile >= player.totalFiles){
     player.currentFile = 1;
    }
    if(OpenFile(player.currentFile) < 0){ 
     OpenFile(player.currentFile);
     player.nextStep = 1;
     {
      u_int16 result = PlayCurrentFile();
      if (result == ceFormatNotFound){
       player.currentFile++; //Skip erroneous file
      }
      if(result == ceFormatNotSupported){
       player.currentFile++; //Skip erroneous file
      }
      if(result == ceOtherError){
       player.currentFile++; //Skip erroneous file
      }
     }
     player.currentFile += player.nextStep;
    }
     else{ // Could not OpenFile.
      player.currentFile++; // Revert to playing the first file
     }
   } //end of player loop
  } //end FAT
} //end main