コード例 #1
0
ファイル: RevLimiter.c プロジェクト: Merp/MerpMod
unsigned char TestClutchSwitchDepressedEvent()
{
	unsigned char ret = 0x00;
	unsigned char result = *pClutchFlags & ClutchBitMask;
	if(result != pRamVariables->ClutchSwitchLast && TestClutchSwitch())
	{
		ret = 0x01;
	}
	pRamVariables->ClutchSwitchLast = result;
	return ret;
}
コード例 #2
0
ファイル: RevLimiter.c プロジェクト: 623y/MerpMod
void RevLimCode()
{	

#if VIN_HACKS
	if (pRamVariables->VinAuth != 0x01)
	{
		// Set the rev-limit fuel cut flag.
		*pFlagsRevLim |= RevLimBitMask;
		VinCheck();
	} 
	else
	{
#endif

	#ifdef pBrakeFlags
		if (!TestClutchSwitch() || TestBrakeSwitch())
	#else
		if (!TestClutchSwitch())//TODO: if this works, change the rest!!
	#endif
		{
				RevLimReset();
		}
		else
		{
			//check for FFS speed threshold
			if (*pVehicleSpeed > pRamVariables->FlatFootShiftSpeedThreshold 
			&& *pEngineSpeed > pRamVariables->FlatFootShiftRpmThreshold 
			&& pRamVariables->FlatFootShiftMode != 0 
			&& *pThrottlePlate > FFSMinimumThrottle)
			{
				pRamVariables->LCEngaged = 0;
				
				//calculate target rpm
				if(pRamVariables->FFSEngaged == 0)
				{
					pRamVariables->FFSEngaged = 1;
					pRamVariables->FFSRPM = *pEngineSpeed;
				}
			}
			else if (*pVehicleSpeed < pRamVariables->LaunchControlSpeedMax && *pThrottlePlate > LCMinimumThrottle)
			{
				// Launch control rev limiter thresholds.
				pRamVariables->FFSEngaged = 0;
				pRamVariables->LCEngaged = 1;
				pRamVariables->RevLimCut = pRamVariables->LaunchControlCut;
				pRamVariables->RevLimResume = pRamVariables->LaunchControlCut - Abs(pRamVariables->LaunchControlHyst);
			}
			else
				RevLimReset();

			}
	
		if (pRamVariables->FFSEngaged == 1)
		{
			#ifdef pCurrentGear
			if (pRamVariables->FlatFootShiftMode == 2)
			{
				float cut =  pRamVariables->FFSRPM;
				cut *=  GearRatios[(int)pRamVariables->FFSGear + 1]; 
				cut *= 1 / GearRatios[(int)pRamVariables->FFSGear];
				cut += pRamVariables->FlatFootShiftAutoDelta;
				pRamVariables->RevLimCut = cut;
				pRamVariables->RevLimResume = pRamVariables->RevLimCut - Abs(pRamVariables->FlatFootShiftHyst);
			}
			else
			{
			#endif
			
				float cut = pRamVariables->RedLineCut - Abs(pRamVariables->FlatFootShiftStaticDelta);
				pRamVariables->RevLimCut = cut;
				pRamVariables->RevLimResume = cut - Abs(pRamVariables->FlatFootShiftHyst);
			
			#ifdef pCurrentGear
			}
			#endif
			pRamVariables->FFSEngaged = 2;
		}
		
	#if PROG_MODE
		if (pRamVariables->ValetMode != ValetModeDisabled)
		{
			pRamVariables->RedLineCut = ValetModeRevLim;
		}
	#endif

	#if SPARK_HACKS
		if (pRamVariables->RevLimMode == RevLimModeSparkCut)
		{
			if (*pEngineSpeed > pRamVariables->RevLimCut)
			{
				// Set the rev-limit fuel cut flag.
				*LCSparkCutFlag |= 0x01;
			} 
			else if (*pEngineSpeed < pRamVariables->RevLimResume)
			{
				// Clear the rev-limit fuel cut flag.
				*LCSparkCutFlag &= 0xFE;
			}
		}
		else if (pRamVariables->RevLimMode == RevLimModeComboCut)
		{
			if (*pEngineSpeed > pRamVariables->RevLimResume)
			{
				// Set the rev-limit fuel cut flag.
				*LCSparkCutFlag |= 0x01;
			} 
			else if (*pEngineSpeed < (pRamVariables->RevLimResume - 50))	///TODO: Add this as an adjustable value??
			{
				// Clear the rev-limit fuel cut flag.
				*LCSparkCutFlag &= 0xFE;
			}
			if (*pEngineSpeed > pRamVariables->RevLimCut)
			{
				// Set the rev-limit fuel cut flag.
				//*((char*)pFlagsRevLim) |= RevLimBitMask; 
				*pFlagsRevLim |= RevLimBitMask;
			} 
			else if (*pEngineSpeed < pRamVariables->RevLimResume)
			{
				// Clear the rev-limit fuel cut flag.
				//*((char*)pFlagsRevLim) &= !RevLimBitMask;
				*pFlagsRevLim &= ~RevLimBitMask;
			}
		}
		else
		{
	#endif
		if (*pEngineSpeed > pRamVariables->RevLimCut || *pEngineSpeed > pRamVariables->RedLineCut)
		{
			*pFlagsRevLim |= RevLimBitMask;
		} 
		else if (*pEngineSpeed < pRamVariables->RevLimResume)
		{
			*pFlagsRevLim &= ~RevLimBitMask;
		}	
#if SPARK_HACKS
	}
#endif

#if VIN_HACKS
	}
#endif
}
コード例 #3
0
ファイル: RevLimiter.c プロジェクト: Merp/MerpMod
void RevLimCode()
{	

#if VIN_HACKS
	if (pRamVariables->VinAuth != 0x01)
	{
		// Set the rev-limit fuel cut flag.
		*pFlagsRevLim |= RevLimBitMask;
		VinCheck();
	} 
	else
	{
#endif
		unsigned char testClutchDepressed = TestClutchSwitchDepressedEvent();
		#ifdef pBrakeFlags
		if(!TestClutchSwitch() || TestBrakeSwitch())
		#else
		if(!TestClutchSwitch())
		#endif
		{
			RevLimReset();
		}
		else if(pRamVariables->LCEngaged == 1)
		{
			TestLCExit();
		}
		else if(pRamVariables->FFSEngaged == 2)
		{
			TestFFSExit();
		}
		//no need to test FFS exit, only depends on clutch!
		else if(testClutchDepressed)
		{
			TestFFSEntry();
		}
		else if (pRamVariables->FFSEngaged == 1)
		{
			#ifdef pCurrentGear
			if (pRamVariables->FlatFootShiftMode == FlatFootShiftModeAuto)
			{
				float cut =  pRamVariables->FFSRPM;
				//int gear1 = (int)pRamVariables->FFSGear-1;
				int gear1 = BandPassInt((int)pRamVariables->FFSGear-1, 0, 5);//(sizeof(GearRatios)/sizeof(GearRatios[0]))-1);
				//int gear2 = (int)pRamVariables->FFSGear;
				int gear2 = BandPassInt((int)pRamVariables->FFSGear, 0, 5);// (sizeof(GearRatios)/sizeof(GearRatios[0]))-1);//TODO: SANITIZE THE LOOKUP!!! 
				float ratio1 = GearRatios[gear1];
				float ratio2 = GearRatios[gear2];
				cut *= ratio2;
				cut *= 1/ratio1;
				//cut *=  GearRatios[(int)pRamVariables->FFSGear + 1]; 
				//cut *= 1 / GearRatios[(int)pRamVariables->FFSGear];
				cut += pRamVariables->FlatFootShiftAutoDelta;
				pRamVariables->RevLimCut = LowPass(cut, pRamVariables->RedLineCut);
				pRamVariables->RevLimResume = pRamVariables->RevLimCut - HighPass(pRamVariables->FlatFootShiftHyst,0.0f);
			}
			else
			{
			#endif
			
				float cut = pRamVariables->RedLineCut - HighPass(pRamVariables->FlatFootShiftStaticDelta,0.0f);
				pRamVariables->RevLimCut = LowPass(cut, pRamVariables->RedLineCut);
				pRamVariables->RevLimResume = cut - HighPass(pRamVariables->FlatFootShiftHyst,0.0f);
			
			#ifdef pCurrentGear
			}
			#endif
			pRamVariables->FFSEngaged = 2;
		}
		else
		{
			TestLCEntry();
		}
		
	#if PROG_MODE
		if (pRamVariables->ValetMode != ValetModeDisabled)
		{
			pRamVariables->RevLimCut = ValetModeRevLim;
			pRamVariables->RevLimResume = pRamVariables->RevLimCut - HighPass(pRamVariables->RedLineHyst,0.0f);
		}
	#endif

	#if SPARK_HACKS
		if (pRamVariables->RevLimMode == RevLimModeSparkCut)
		{
			if (*pEngineSpeed > pRamVariables->RevLimCut)
			{
				// Set the rev-limit fuel cut flag.
				*LCSparkCutFlag |= 0x01;
			} 
			else if (*pEngineSpeed < pRamVariables->RevLimResume)
			{
				// Clear the rev-limit fuel cut flag.
				*LCSparkCutFlag &= 0xFE;
			}
		}
		else if (pRamVariables->RevLimMode == RevLimModeComboCut)
		{
			if (*pEngineSpeed > pRamVariables->RevLimResume)
			{
				// Set the rev-limit fuel cut flag.
				*LCSparkCutFlag |= 0x01;
			} 
			else if (*pEngineSpeed < (pRamVariables->RevLimResume - 50))	///TODO: Add this as an adjustable value??
			{
				// Clear the rev-limit fuel cut flag.
				*LCSparkCutFlag &= 0xFE;
			}
			if (*pEngineSpeed > pRamVariables->RevLimCut)
			{
				// Set the rev-limit fuel cut flag.
				//*((char*)pFlagsRevLim) |= RevLimBitMask; 
				*pFlagsRevLim |= RevLimBitMask;
			} 
			else if (*pEngineSpeed < pRamVariables->RevLimResume)
			{
				// Clear the rev-limit fuel cut flag.
				//*((char*)pFlagsRevLim) &= !RevLimBitMask;
				*pFlagsRevLim &= ~RevLimBitMask;
			}
		}
		else
		{
	#endif
		if (*pEngineSpeed > pRamVariables->RevLimCut || *pEngineSpeed > pRamVariables->RedLineCut)
		{
			*pFlagsRevLim |= RevLimBitMask;
		} 
		else if (*pEngineSpeed < pRamVariables->RevLimResume)
		{
			*pFlagsRevLim &= ~RevLimBitMask;
		}	
#if SPARK_HACKS
	}
#endif

#if VIN_HACKS
	}
#endif
}