<commit_before>#include "HEALTH.H"

#include "DELTAPAK.H"
#include "DRAW.H"
#if PSXENGINE
#include "GPU.H"
#include "DRAWPHAS.H"
#include "FXTRIG.H"
#include "PSXINPUT.H"
#include "SHADOWS.H"
#endif
#include "GAMEFLOW.H"
#include "LARA.H"
#include "SPOTCAM.H"
#include "SAVEGAME.H"

#include <stdio.h>
#include "SPECIFIC.H"
#include "OBJECTS.H"
#include "NEWINV2.H"
#include "TEXT.H"

int health_bar_timer = 0;
char PoisonFlag = 0;
struct DISPLAYPU pickups[8];
short PickupX = 0;
short PickupY = 0;
short PickupVel = 0;
short CurrentPickup = 0;

void AddDisplayPickup(short object_number)//3B6F4, ? (F)
{
	struct DISPLAYPU* pu = &pickups[0];
	long lp;
	if (gfCurrentLevel == LVL5_SUBMARINE && object_number == PUZZLE_ITEM1 ||
		gfCurrentLevel == LVL5_OLD_MILL && object_number == PUZZLE_ITEM3)
	{
		object_number = CROWBAR_ITEM;
	}

	for(lp = 0; lp < 8; lp++, pu++)
	{
		if (pu->life < 0)
		{
			pu->life = 45;
			pu->object_number = object_number;
			break;
		}
	}

	DEL_picked_up_object(object_number);
}

void DrawPickups(int timed)// (F)
{
	struct DISPLAYPU* pu = &pickups[CurrentPickup];
	long lp;

	if (pu->life > 0)
	{
		if (PickupX > 0)
		{
			PickupX += (-PickupX >> 3);
		}
		else
		{
			pu->life--;
		}
	}
	else if (pu->life == 0)
	{
		if (PickupX < 128)
		{
			if (PickupVel < 16)
				PickupX += ++PickupVel;
		}
		else
		{
			pu->life = -1;
			PickupVel = 0;
		}
	}
	else
	{
		for (lp = 0; lp < 8; lp++)
		{
			if (pickups[(CurrentPickup + lp) % 8].life > 0)
				break;
		}

		if (lp == 8)
		{
			CurrentPickup = 0;
			return;
		}

		CurrentPickup = (CurrentPickup + lp) % 8;
	}

	S_DrawPickup(pu->object_number);
}

void InitialisePickUpDisplay()//3B580, 3B9DC (F)
{
	int i;
	for (i = 7; i > -1; i--)
	{
		pickups[i].life = -1;
	}

	PickupY = 128;
	PickupX = 128;
	PickupVel = 0;
	CurrentPickup = 0;
}

void DrawAirBar(int flash_state)//3B3CC
{
#if PC_VERSION
	if (lara.air == 1800 || lara_item->hit_points <= 0)
		return;

	short val = CLAMP(lara.air, 0, 1800);

	if (val > 450 || flash_state)
	{
		S_DrawAirBar(100 * val / 1800);
	}
	else
	{
		S_DrawAirBar(0);
	}

	if (lara.Gassed)
	{
		if (lara.dpoisoned < 2048)
			lara.dpoisoned += 2;

		lara.Gassed = FALSE;
	}
#elif PSX_VERSION

	int air;

	if (lara.air == 1800 || lara_item->hit_points <= 0)
	{
		//loc_3B570
		return;
	}

	air = lara.air;

	//clamp
	if (air < 0)
	{
		air = 0;
	}//loc_3B424
	else if (air > 1080)
	{
		air = 1080;
	}//loc_3B434

	if (air > 450)
	{
		if (flash_state != 0)
		{
			S_DrawGouraudBar(343, 32, 133, ((((((((air * 0x38E38E39) >> 2) - (air >> 31) >> 5) + ((air * 0x38E38E39) >> 2) - (air >> 31)) << 2) + ((air * 0x38E38E39) >> 2) - (air >> 31)) * 0x51EB851F) >> 5) - (((((((air * 0x38E38E39) >> 2) - (air >> 31) >> 5) + ((air * 0x38E38E39) >> 2) - (air >> 31)) << 2) + ((air * 0x38E38E39) >> 2) - (air >> 31)) >> 31), &airBarColourSet);
		}
		else
		{
			//loc_3B4A8
			S_DrawGouraudBar(343, 32, 133, 0, &airBarColourSet);
		}
	}
	else
	{
		//loc_3B4D0
		S_DrawGouraudBar(343, 32, 133, ((((((((air * 0x38E38E39) >> 2) - (air >> 31) << 5) + ((air * 0x38E38E39) >> 2) - (air >> 31)) << 2) + ((air * 0x38E38E39) >> 2) - (air >> 31)) * 0x51EB851F) >> 5) - (((((((air * 0x38E38E39) >> 2) - (air >> 31) << 5) + ((air * 0x38E38E39) >> 2) - (air >> 31)) << 2) + ((air * 0x38E38E39) >> 2) - (air >> 31)) >> 31), &airBarColourSet);
	}

	//loc_3B534
	if (lara.Gassed)// & 0x200 check me
	{
		if (lara.dpoisoned < 2048)
		{
			lara.dpoisoned += 2;
		}
		//loc_3B560
		lara.Gassed = 0;

	}//loc_3B570<commit_msg>PSXPC compile patches<commit_after>#include "HEALTH.H"

#include "DELTAPAK.H"
#include "DRAW.H"
#if PSXENGINE
#include "GPU.H"
#include "DRAWPHAS.H"
#include "FXTRIG.H"
#include "SHADOWS.H"
#endif

#if PSX_VERSION
#include "PSXINPUT.H"
#endif
#if PSXPC_VERSION
#include "PSXPCINPUT.H"
#endif

#include "GAMEFLOW.H"
#include "LARA.H"
#include "SPOTCAM.H"
#include "SAVEGAME.H"

#include <stdio.h>
#include "SPECIFIC.H"
#include "OBJECTS.H"
#include "NEWINV2.H"
#include "TEXT.H"

int health_bar_timer = 0;
char PoisonFlag = 0;
struct DISPLAYPU pickups[8];
short PickupX = 0;
short PickupY = 0;
short PickupVel = 0;
short CurrentPickup = 0;

void AddDisplayPickup(short object_number)//3B6F4, ? (F)
{
	struct DISPLAYPU* pu = &pickups[0];
	long lp;
	if (gfCurrentLevel == LVL5_SUBMARINE && object_number == PUZZLE_ITEM1 ||
		gfCurrentLevel == LVL5_OLD_MILL && object_number == PUZZLE_ITEM3)
	{
		object_number = CROWBAR_ITEM;
	}

	for(lp = 0; lp < 8; lp++, pu++)
	{
		if (pu->life < 0)
		{
			pu->life = 45;
			pu->object_number = object_number;
			break;
		}
	}

	DEL_picked_up_object(object_number);
}

void DrawPickups(int timed)// (F)
{
	struct DISPLAYPU* pu = &pickups[CurrentPickup];
	long lp;

	if (pu->life > 0)
	{
		if (PickupX > 0)
		{
			PickupX += (-PickupX >> 3);
		}
		else
		{
			pu->life--;
		}
	}
	else if (pu->life == 0)
	{
		if (PickupX < 128)
		{
			if (PickupVel < 16)
				PickupX += ++PickupVel;
		}
		else
		{
			pu->life = -1;
			PickupVel = 0;
		}
	}
	else
	{
		for (lp = 0; lp < 8; lp++)
		{
			if (pickups[(CurrentPickup + lp) % 8].life > 0)
				break;
		}

		if (lp == 8)
		{
			CurrentPickup = 0;
			return;
		}

		CurrentPickup = (CurrentPickup + lp) % 8;
	}

	S_DrawPickup(pu->object_number);
}

void InitialisePickUpDisplay()//3B580, 3B9DC (F)
{
	int i;
	for (i = 7; i > -1; i--)
	{
		pickups[i].life = -1;
	}

	PickupY = 128;
	PickupX = 128;
	PickupVel = 0;
	CurrentPickup = 0;
}

void DrawAirBar(int flash_state)//3B3CC
{
#if PC_VERSION
	if (lara.air == 1800 || lara_item->hit_points <= 0)
		return;

	short val = CLAMP(lara.air, 0, 1800);

	if (val > 450 || flash_state)
	{
		S_DrawAirBar(100 * val / 1800);
	}
	else
	{
		S_DrawAirBar(0);
	}

	if (lara.Gassed)
	{
		if (lara.dpoisoned < 2048)
			lara.dpoisoned += 2;

		lara.Gassed = FALSE;
	}
#elif PSX_VERSION

	int air;

	if (lara.air == 1800 || lara_item->hit_points <= 0)
	{
		//loc_3B570
		return;
	}

	air = lara.air;

	//clamp
	if (air < 0)
	{
		air = 0;
	}//loc_3B424
	else if (air > 1080)
	{
		air = 1080;
	}//loc_3B434

	if (air > 450)
	{
		if (flash_state != 0)
		{
			S_DrawGouraudBar(343, 32, 133, ((((((((air * 0x38E38E39) >> 2) - (air >> 31) >> 5) + ((air * 0x38E38E39) >> 2) - (air >> 31)) << 2) + ((air * 0x38E38E39) >> 2) - (air >> 31)) * 0x51EB851F) >> 5) - (((((((air * 0x38E38E39) >> 2) - (air >> 31) >> 5) + ((air * 0x38E38E39) >> 2) - (air >> 31)) << 2) + ((air * 0x38E38E39) >> 2) - (air >> 31)) >> 31), &airBarColourSet);
		}
		else
		{
			//loc_3B4A8
			S_DrawGouraudBar(343, 32, 133, 0, &airBarColourSet);
		}
	}
	else
	{
		//loc_3B4D0
		S_DrawGouraudBar(343, 32, 133, ((((((((air * 0x38E38E39) >> 2) - (air >> 31) << 5) + ((air * 0x38E38E39) >> 2) - (air >> 31)) << 2) + ((air * 0x38E38E39) >> 2) - (air >> 31)) * 0x51EB851F) >> 5) - (((((((air * 0x38E38E39) >> 2) - (air >> 31) << 5) + ((air * 0x38E38E39) >> 2) - (air >> 31)) << 2) + ((air * 0x38E38E39) >> 2) - (air >> 31)) >> 31), &airBarColourSet);
	}

	//loc_3B534
	if (lara.Gassed)
	{
		if (lara.dpoisoned < 2048)
		{
			lara.dpoisoned += 2;
		}
		//loc_3B560
		lara.Gassed = 0;

	}//loc_3B570
{'fraction_non_alphanumeric': 0.19903669074939792, 'fraction_numerical': 0.08839779005524862, 'mean_word_length': 2.997734994337486, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 163, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1915697', 'n_tokens_mistral': 4085, 'n_tokens_neox': 3339, 'n_words': 708}