' ------------------------------------------------------------------------------------------------
' Update Game Logic
' ------------------------------------------------------------------------------------------------
Function MainLoop()
	
	' read current time
	TIMER_Timer = MilliSecs()

	' check if update is allowed
	If (TIMER_Timer > TIMER_Update + TIMER_Lasttimer) Then

		' calculate new timer interval		
		TIMER_Interval = TIMER_Timer - TIMER_Lasttimer

		If TIMER_Interval > TIMER_Safe Then

			' check for framedrops
			TIMER_Interval = TIMER_Safe
			FPS.framedrops:+1

		End If
		
		FPS.multi = GAME_SPEED * TIMER_Interval
		
		' Update Game Logic
		UpdateGame()
		
		' get current camera position
		CAMERA.GetCameraPosition()

		' store last timer
		TIMER_Lasttimer = TIMER_Timer
			
	EndIf

End Function

	
' ------------------------------------------------------------------------------------------------
' Update Game Logic
' ------------------------------------------------------------------------------------------------
Function UpdateGame()

	' Keyboard
	PollKeyBoardInput()
		
	' Hide all Module Pivots	
	HideModules()

	' check which module to display	
	Select GAME_MODULE
	
		Case "Starmap" STARMAP._Show() ; STARMAP._Loop()
	
	End Select
	
End Function