Example #1
0
		void MainScreen::RunFrame(float dt) {
			SPADES_MARK_FUNCTION();
			if(subview){
				try{
					subview->RunFrame(dt);
					if(subview->WantsToBeClosed()) {
						subview->Closing();
						subview = NULL;
						RestoreRenderer();
					}else{
						return;
					}
				}catch(const std::exception& ex) {
					SPLog("[!] Error while running a game client: %s", ex.what());
					subview->Closing();
					subview = NULL;
					RestoreRenderer();
					helper->errorMessage = ex.what();
				}
			}
			if(timeToStartInitialization > 100.f){
				timeToStartInitialization = 0.2f;
			}
			if(timeToStartInitialization > 0.f){
				DrawStartupScreen();
				timeToStartInitialization -= dt;
				if(timeToStartInitialization <= 0.f){
					// do init
					DoInit();
				}
				return;
			}
			
			static ScriptFunction func("MainScreenUI", "void RunFrame(float)");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c->SetArgFloat(0, dt);
			c.ExecuteChecked();
		}
Example #2
0
		void Client::RunFrame(float dt) {
			SPADES_MARK_FUNCTION();
			
			fpsCounter.MarkFrame();
			
			if(frameToRendererInit > 0){
				// waiting for renderer initialization
				
				DrawStartupScreen();
				
				frameToRendererInit--;
				if(frameToRendererInit == 0){
					DoInit();
					
				}else{
					return;
				}
			}
			
			timeSinceInit += std::min(dt, .03f);
			
			// update network
			try{
				if(net->GetStatus() == NetClientStatusConnected)
					net->DoEvents(0);
				else
					net->DoEvents(10);
			}catch(const std::exception& ex){
				if(net->GetStatus() == NetClientStatusNotConnected){
					SPLog("Disconnected because of error:\n%s", ex.what());
					NetLog("Disconnected because of error:\n%s", ex.what());
					throw;
				}else{
					SPLog("Exception while processing network packets (ignored):\n%s", ex.what());
				}
			}
			
			hurtRingView->Update(dt);
			centerMessageView->Update(dt);
			mapView->Update(dt);
			largeMapView->Update(dt);
			
			UpdateAutoFocus(dt);
			
			if(world){
				UpdateWorld(dt);
			}else{
				renderer->SetFogColor(MakeVector3(0.f, 0.f, 0.f));
			}
			
			chatWindow->Update(dt);
			killfeedWindow->Update(dt);
			limbo->Update(dt);
			
			// CreateSceneDefinition also can be used for sounds
			SceneDefinition sceneDef = CreateSceneDefinition();
			lastSceneDef = sceneDef;
			
			// Update sounds
			try{
				audioDevice->Respatialize(sceneDef.viewOrigin,
										  sceneDef.viewAxis[2],
										  sceneDef.viewAxis[1]);
			}catch(const std::exception& ex){
				SPLog("Audio subsystem returned error (ignored):\n%s",
					  ex.what());
			}
			
			// render scene
			DrawScene();
			
			// draw 2d
			Draw2D();
			
			// draw scripted GUI
			scriptedUI->RunFrame(dt);
			if(scriptedUI->WantsClientToBeClosed())
				readyToClose = true;
			
			// Well done!
			renderer->FrameDone();
			renderer->Flip();
            
            // reset all "delayed actions" (in case we forget to reset these)
            hasDelayedReload = false;
			
			time += dt;
		}
Example #3
0
void Init(void)
{  
  __disable_interrupt();

  ENABLE_LCD_LED();
  DISABLE_LCD_POWER();

  /* clear shipping mode, if set to allow configuration */
  PMMCTL0_H = PMMPW_H;
  PM5CTL0 &= ~LOCKLPM5;  
  PMMCTL0_H = 0x00;
  
  /* disable DMA during read-modify-write cycles */
  DMACTL4 = DMARMWDIS;

  DetermineErrata();
  
#ifdef BOOTLOADER
  /*
   * enable RAM alternate interrupt vectors
   * these are defined in AltVect.s43 and copied to RAM by cstartup
   */
  SYSCTL |= SYSRIVECT;
  ClearBootloaderSignature();
#else
  SaveResetSource();
#endif
  
  SetupClockAndPowerManagementModule();
  
  CheckResetCode();
  if (niReset != NO_RESET_CODE) InitProperty();

  InitBufferPool(); // message queue

  InitBattery();
  CheckClip();

  PrintString2("\r\n*** ", niReset == FLASH_RESET_CODE ? "FLASH" :
    (niReset == MASTER_RESET_CODE ? "MASTER" : "NORMAL"));
  PrintString3(":", niBuild, CR);
  
  ShowWatchdogInfo();
  WhoAmI();

  /* timer for battery checking at a regular frequency. */
  BatteryTimerId = AllocateOneSecondTimer();
  SetupOneSecondTimer(BatteryTimerId,
                      BATTERY_MONITOR_INTERVAL,
                      REPEAT_FOREVER,
                      DISPLAY_QINDEX,
                      MonitorBatteryMsg,
                      MSG_OPT_NONE);
  StartOneSecondTimer(BatteryTimerId);

  InitVibration();
  InitRealTimeClock(); // enable rtc interrupt

  LcdPeripheralInit();
  DrawStartupScreen();
  SerialRamInit();

  /* turn the radio on; initialize the serial port profile or BLE/GATT */
  CreateAndSendMessage(TurnRadioOnMsg, MSG_OPT_NONE);

  DISABLE_LCD_LED();
}
Example #4
0
void G2DTestSystemDriver::SetupFrame ()
{
  if (state_sptr == 0)
  {
    EventOutlet->Broadcast (csevQuit (object_reg));
    return;
  }

  appState curstate = state [state_sptr - 1];
  switch (curstate)
  {
    case stInit:
    case stStartup:
    case stContextInfo:
    case stWindowFixed:
    case stWindowResize:
    case stCustomCursor:
    case stCustomIcon:
    case stAlphaTest:
    case stTestUnicode1:
    case stTestUnicode2:
    case stTestFreetype:
    case stTestLineDraw:
    case stTestLinePerf:
    case stTestTextDraw:
    case stTestTextDraw2:
    case stPixelClipTest:
    case stLineClipTest:
    case stBoxClipTest:
    case stFontClipTest:
    case stBlitTest:
    {
      if (!myG3D->BeginDraw (CSDRAW_2DGRAPHICS))
        break;

      myG2D->Clear (black);
      LeaveState ();
      switch (curstate)
      {
        case stInit:
	  fontLarge = GetFont (CSFONT_LARGE);
	  fontItalic = GetFont (CSFONT_ITALIC);
	  fontCourier = GetFont (CSFONT_COURIER);
	  fontSmall = GetFont (CSFONT_SMALL);
	  {
	    csRef<iVFS> vfs = csQueryRegistry<iVFS> (object_reg);
	    csRef<iImageIO> iio = 
	      csQueryRegistry<iImageIO> (object_reg);
	    if (vfs.IsValid () && iio.IsValid ())
	    {
	      csRef<iFile> testFile = vfs->Open ("/lib/g2dtest/up.png", 
		VFS_FILE_READ);
	      if (testFile.IsValid ())
	      {
		csRef<iDataBuffer> fileData = testFile->GetAllData ();
		blitTestImage = iio->Load (fileData, CS_IMGFMT_TRUECOLOR 
		  | CS_IMGFMT_ALPHA);
	      }
	      testFile = vfs->Open ("/lib/std/cslogo2.png", VFS_FILE_READ);
	      if (testFile.IsValid ())
	      {
		csRef<iDataBuffer> fileData = testFile->GetAllData ();
		alphaBlitImage = iio->Load (fileData, CS_IMGFMT_TRUECOLOR |
		  CS_IMGFMT_ALPHA);
	      }
	    }
	  }
	  EnterState (stStartup);
	  break;
        case stStartup:
          DrawStartupScreen ();
	  EnterState (stContextInfo);
          EnterState (stPause, 5000);
          break;
        case stContextInfo:
          DrawContextInfoScreen ();
          EnterState (stWindowFixed);
          EnterState (stWaitKey);
          break;
        case stWindowFixed:
          DrawWindowScreen ();
          EnterState (stWindowResize);
          EnterState (stWaitKey);
          break;
        case stWindowResize:
          DrawWindowResizeScreen ();
          EnterState (stCustomCursor);
          EnterState (stWaitKey);
          break;
	case stCustomCursor:
          DrawCustomCursorScreen ();
	  SetCustomCursor ();
	  if (lastkey9)
            EnterState (stCustomIcon);
	  else
            EnterState (stCustomCursor);
          break;
	case stCustomIcon:
          SetNormalCursor ();
	  SetCustomIcon ();
          DrawCustomIconScreen ();
	  EnterState (stAlphaTest);
          EnterState (stWaitKey);
          break;
	case stAlphaTest:
          DrawAlphaTestScreen ();
          EnterState (stTestUnicode1);
          EnterState (stWaitKey);
          break;
	case stTestUnicode1:
	  DrawUnicodeTest1 ();
          EnterState (stTestUnicode2);
          EnterState (stWaitKey);
          break;
	case stTestUnicode2:
	  DrawUnicodeTest2 ();
          EnterState (stTestFreetype);
          EnterState (stWaitKey);
          break;
	case stTestFreetype:
	  DrawFreetypeTest ();
          EnterState (stTestLineDraw);
          EnterState (stWaitKey);
          break;
        case stTestLineDraw:
          DrawLineTest ();
          EnterState (stTestLinePerf);
          EnterState (stWaitKey);
          break;
        case stTestLinePerf:
          DrawLinePerf ();
          if (lastkey2)
            EnterState (stTestTextDraw);
          else
            EnterState (stTestLinePerf);
          break;
        case stTestTextDraw:
          DrawTextTest ();
          if (lastkey3)
            EnterState (stTestTextDraw2);
          else
            EnterState (stTestTextDraw);
          break;
        case stTestTextDraw2:
          DrawTextTest2 ();
          if (lastkey4)
            EnterState (stPixelClipTest);
          else
            EnterState (stTestTextDraw2);
          break;
        case stPixelClipTest:
          PixelClipTest ();
          if (lastkey5)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
            EnterState (stLineClipTest);
          }
          else
            EnterState (stPixelClipTest);
          break;
        case stLineClipTest:
          LineClipTest ();
          if (lastkey6)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
            EnterState (stBoxClipTest);
          }
          else
            EnterState (stLineClipTest);
          break;
        case stBoxClipTest:
          BoxClipTest ();
          if (lastkey7)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
	    EnterState (stFontClipTest);
          }
          else
            EnterState (stBoxClipTest);
          break;
        case stFontClipTest:
          FontClipTest ();
          if (lastkey8)
	    EnterState (stBlitTest);
          else
            EnterState (stFontClipTest);
          break;
	case stBlitTest:
	  BlitTest ();
          EnterState (stWaitKey);
          break;
        default:
          break;
      }
      break;
    }
    case stPause:
      if (int (csGetTicks () - timer) > 0)
        LeaveState ();
      else
        csSleep (1);
      break;
    case stWaitKey:
      if (lastkey)
      {
        LeaveState ();
        SwitchBB = false;
      }
      else
      {
        if (SwitchBB)
        {
          myG2D->Print (0);
          csSleep (200);
        }
        else
          csSleep (1);
      }
      break;
  }
}