/****************************************************************************
*
* SAVEGAME.H
*
* PROGRAMMER : Chris
*    VERSION : 00.00
*    CREATED : 03/06/98
*   MODIFIED : 03/06/98
*       TABS : 5
*
* DESCRIPTION
*	Header file for SAVEGAME.C
*
*****************************************************************************/

#ifndef _SAVEGAME_H
#define _SAVEGAME_H

#ifdef __cplusplus
extern "C" {
#endif

/*---------------------------------------------------------------------------
 *	Import Headers
\*--------------------------------------------------------------------------*/

#ifdef PSX_VERSION
#include "../spec_psx/typedefs.h"
#else
#include "..\specific\stypes.h"
#endif

#include "gameflow.h"
#include "setup.h"

/*---------------------------------------------------------------------------
 *	Constants
\*--------------------------------------------------------------------------*/

#define FULL_SAVE
#define MAX_SAVEGAME_BUFFER (12*1024+128)

/*---------------------------------------------------------------------------
 *	Type Definitions
\*--------------------------------------------------------------------------*/

typedef struct start_info {
	uint16 pistol_ammo, magnum_ammo, uzi_ammo, shotgun_ammo, m16_ammo, rocket_ammo, harpoon_ammo, grenade_ammo;
	unsigned char num_medis, num_big_medis, num_scions, num_flares, num_sgcrystals ;
	char gun_status, gun_type;
	uint16 available:1;
	uint16 got_pistols:1;
	uint16 got_magnums:1;
	uint16 got_uzis:1;
	uint16 got_shotgun:1;
	uint16 got_m16:1;
	uint16 got_rocket:1;
	uint16 got_grenade:1;
	uint16 got_harpoon:1;
	uint16 secrets; // actually records whether player has secrets at end of level
	unsigned char num_icon1, num_icon2, num_icon3, num_icon4;
	uint32 	timer;
	uint32	ammo_used, ammo_hit;
	uint32	distance_travelled;
	uint16 	kills;
	unsigned char	secrets_found; // bit packed
	unsigned char	health_used; // in units of small medi paks
} START_INFO;

typedef struct savegame_info {
#ifdef PSX_VERSION
	sint16	iconfig;
	sint16 	VibrateOn;
	sint16	SFX_volume;
	sint16	CD_volume;
	sint16	screen_x,screen_y;
	uint32 	best_assault_times[10];
	uint32	best_quadbike_times[10];
	uint32	QuadbikeKeyFlag;
#endif
	START_INFO start[MAXIMUM_LEVELS+1];
	uint32 	timer;
	uint32	ammo_used, ammo_hit;
	uint32	distance_travelled;
	uint16 	kills;
	unsigned char	secrets; // bit packed
	unsigned char	health_used; // in units of small medi paks

/* Stuff for current position. */
	uint32 	cp_timer;
	uint32	cp_ammo_used, cp_ammo_hit;
	uint32	cp_distance_travelled;
	uint16 	cp_kills;
	unsigned char	cp_secrets; // bit packed
	unsigned char	cp_health_used; // in units of small medi paks
//

	sint16 	current_level;
	unsigned char bonus_flag;
	unsigned char num_pickup1, num_pickup2;
	unsigned char num_puzzle1, num_puzzle2, num_puzzle3, num_puzzle4;
	unsigned char num_key1, num_key2, num_key3, num_key4;

	signed char	checksum;
	signed char GameComplete;
	uint32 mid_level_save:1;
	uint32 AfterAdventureSave:1;
	uint32 WorldRequired:3;

	uint32 IndiaComplete:1;
	uint32 SPacificComplete:1;
	uint32 LondonComplete:1;
	uint32 NevadaComplete:1;
	uint32 AntarcticaComplete:1;
	uint32 PeruComplete:1;
	uint32 AfterIndia:3;
	uint32 AfterSPacific:3;
	uint32 AfterLondon:3;
	uint32 AfterNevada:3;
	char   	buffer[MAX_SAVEGAME_BUFFER];
} SAVEGAME_INFO;

/*---------------------------------------------------------------------------
 *	Prototypes
\*--------------------------------------------------------------------------*/

extern int number_cameras;

extern SAVEGAME_INFO savegame;

#ifdef PSX_VERSION
extern SAVEGAME_INFO savegame_backup;
#endif

extern int  LoadSaveGameInfo();
extern void InitialiseStartInfo();
extern void ModifyStartInfo(int level_number);
extern void CreateStartInfo(int level_number);
extern void CreateSaveGameInfo();
extern void ExtractSaveGameInfo();
extern void ResetSG();
extern void WriteSG(void *pointer, int size);
extern void ReadSG(void *pointer, int size);
extern int  ConfirmSave(int fade);
extern void CompleteSave(int fade);
extern int  CheckSumValid(SAVEGAME_INFO *buffer);

#ifdef PSX_VERSION
extern void CreateCheckSum(SAVEGAME_INFO *sg);
#else
extern void CreateCheckSum();
#endif

/*---------------------------------------------------------------------------
 *	Macros
\*--------------------------------------------------------------------------*/

#ifdef PSX_VERSION
#define VibrateOn			savegame.VibrateOn
#define iconfig			savegame.iconfig
#define Option_SoundFX_Volume	savegame.SFX_volume
#define Option_Music_Volume	savegame.CD_volume
#endif

#ifdef __cplusplus
}
#endif

#endif
