/* ================================================================================== */
/* Copyright (c) 1998-1999 3Com Corporation or its subsidiaries. All rights reserved. */
/* ================================================================================== */

#ifndef _APPPREFERENCES_H_
#define _APPPREFERENCES_H_

#include "Miscellaneous.h"		// AppInfoList, DeviceType
#include "Platform_Files.h"		// FileReference


typedef deque<FileReference>	FileRefList;


class AppPreferences
{
	public:
								AppPreferences		(void)		{ Initialize (); }
		void					Initialize			(void);

		Bool					ValidateSettings	(void);

		enum { MRU_COUNT = 9 };
		enum { kGrayBackground, kWhiteBackground };
		enum { kNoFrame, kCaseFrame };
		enum { kSaveAlways, kSaveAsk, kSaveNever };
		enum { kNormalLogging = 0x01,
				kGremlinLogging = 0x02,
				kAllLogging = kNormalLogging | kGremlinLogging,
				kCurrentLogging = 0x80 };

		struct Configuration
		{
			Configuration ();

			DeviceType				fDeviceType;
			SilkscreenType			fSilkscreenType;
			uae_s32					fRAMSize;
			FileReference			fROMFile;
		};

		struct GremlinInfo
		{
			GremlinInfo ();

			long				fNumber;
			long				fSteps;
			long				fSaveFrequency;
			AppInfoList			fAppList;
			bool				fContinuePastWarnings;
		};


	// Getters

		uae_u8					GetScale			(void)		{ return fScale; }
		Bool					SingleSize			(void)		{ return GetScale () == 1; }
		Bool					DoubleSize			(void)		{ return GetScale () == 2; }
		uae_u8					GetBackground		(void)		{ return fScreenBackground; }
		Bool					GrayBackground		(void)		{ return GetBackground () == AppPreferences::kGrayBackground; }
		Bool					WhiteBackground		(void)		{ return GetBackground () == AppPreferences::kWhiteBackground; }
		uae_u8					GetCloseAction		(void)		{ return fCloseAction; }
		Bool					SaveAlways			(void)		{ return GetCloseAction () == AppPreferences::kSaveAlways; }
		Bool					SaveAsk				(void)		{ return GetCloseAction () == AppPreferences::kSaveAsk; }
		Bool					SaveNever			(void)		{ return GetCloseAction () == AppPreferences::kSaveNever; }
		string					GetCommPort			(void)		{ return fCommPort; }
		void					GetCommPort			(unsigned char*);

		Bool					RedirectNetLib		(void)		{ return fRedirectNetLib; }

		void					SetWindowLocation	(const Point& p)	{ fWindowLocation = p; }
		Point					GetWindowLocation	(void)				{ return fWindowLocation; }

		void					SetGCWLocation		(const Point& p)	{ fGCWLocation = p; }
		Point					GetGCWLocation		(void)				{ return fGCWLocation; }

		Configuration			GetLastConfiguration(void)		{ return fLastConfiguration; }
		GremlinInfo&			GetGremlinInfo		(void)		{ return fGremlinInfo; }

		FileReference&			GetLastRAMFile		(void)		{ return fLastRAMFile; }
		FileReference&			GetPRCMRU			(int);
		FileReference&			GetRAMMRU			(int);

		string					GetUserName			(void)		{ return fUserName; }

		Bool					ReportCorruptedHeap				(void)	{ return fReportCorruptedHeap; }
		Bool					ReportFreeChunkAccess			(void)	{ return fReportFreeChunkAccess; }
		Bool					ReportHardwareRegisterAccess	(void)	{ return fReportHardwareRegisterAccess; }
		Bool					ReportInvalidPC					(void)	{ return fReportInvalidPC; }
		Bool					ReportLowMemoryAccess			(void)	{ return fReportLowMemoryAccess; }
		Bool					ReportLowStackAccess			(void)	{ return fReportLowStackAccess; }
		Bool					ReportMemMgrDataAccess			(void)	{ return fReportMemMgrDataAccess; }
		Bool					ReportMemMgrSemaphore			(void)	{ return fReportMemMgrSemaphore; }
		Bool					ReportScreenAccess				(void)	{ return fReportScreenAccess; }
		Bool					ReportStackAlmostOverflow		(void)	{ return fReportStackAlmostOverflow; }
		Bool					ReportStackOverflow				(void)	{ return fReportStackOverflow; }
		Bool					ReportStorageHeapAccess			(void)	{ return fReportStorageHeapAccess; }
		Bool					ReportSysFatalAlert				(void)	{ return fReportSysFatalAlert; }
		Bool					ReportSystemGlobalAccess		(void)	{ return fReportSystemGlobalAccess; }
		Bool					ReportUnhandledException		(void)	{ return fReportUnhandledException; }
		Bool					ReportUnimplementedTrap			(void)	{ return fReportUnimplementedTrap; }
		Bool					ReportUninitializedChunkAccess	(void)	{ return fReportUninitializedChunkAccess; }
		Bool					ReportUninitializedStackAccess	(void)	{ return fReportUninitializedStackAccess; }
		Bool					ReportUnlockedChunkAccess		(void)	{ return fReportUnlockedChunkAccess; }

		int						UseLoggingOptions				(int);
		Bool					GetLogErrorMessages				(void)	{ return (fLogErrorMessages & kCurrentLogging) != 0; }
		Bool					GetLogWarningMessages			(void)	{ return (fLogWarningMessages & kCurrentLogging) != 0; }
		Bool					GetLogGremlins					(void)	{ return (fLogGremlins & kCurrentLogging) != 0; }
		Bool					GetLogCPUOpcodes				(void)	{ return (fLogCPUOpcodes & kCurrentLogging) != 0; }
		Bool					GetLogEnqueuedEvents			(void)	{ return (fLogEnqueuedEvents & kCurrentLogging) != 0; }
		Bool					GetLogDequeuedEvents			(void)	{ return (fLogDequeuedEvents & kCurrentLogging) != 0; }
		Bool					GetLogSystemCalls				(void)	{ return (fLogSystemCalls & kCurrentLogging) != 0; }
		Bool					GetLogApplicationCalls			(void)	{ return (fLogApplicationCalls & kCurrentLogging) != 0; }
		Bool					GetLogSerial					(void)	{ return (fLogSerial & kCurrentLogging) != 0; }
		Bool					GetLogSerialData				(void)	{ return (fLogSerialData & kCurrentLogging) != 0; }
		Bool					GetLogNetLib					(void)	{ return (fLogNetLib & kCurrentLogging) != 0; }
		Bool					GetLogNetLibData				(void)	{ return (fLogNetLibData & kCurrentLogging) != 0; }
		Bool					GetLogExgMgr					(void)	{ return (fLogExgMgr & kCurrentLogging) != 0; }
		Bool					GetLogExgMgrData				(void)	{ return (fLogExgMgrData & kCurrentLogging) != 0; }
		Bool					GetLogHLDebugger				(void)	{ return (fLogHLDebugger & kCurrentLogging) != 0; }
		Bool					GetLogHLDebuggerData			(void)	{ return (fLogHLDebuggerData & kCurrentLogging) != 0; }
		Bool					GetLogLLDebugger				(void)	{ return (fLogLLDebugger & kCurrentLogging) != 0; }
		Bool					GetLogLLDebuggerData			(void)	{ return (fLogLLDebuggerData & kCurrentLogging) != 0; }

		Bool					ReportMemoryLeaks				(void)	{ return fReportMemoryLeaks; }
		Bool					ReportLockedRecords				(void)	{ return fReportLockedRecords; }

		Bool					FillNewBlocks					(void)	{ return fFillNewBlocks; }
		Bool					FillResizedBlocks				(void)	{ return fFillResizedBlocks; }
		Bool					FillDisposedBlocks				(void)	{ return fFillDisposedBlocks; }
		Bool					FillStack						(void)	{ return fFillStack; }

	// Setters

		void					SetCommPort			(const string& port)		{ fCommPort = port; }

		void					SetLastConfiguration(const Configuration& t)	{ fLastConfiguration = t; }
		void					SetGremlinInfo		(const GremlinInfo& t)		{ fGremlinInfo = t; }

		void					SetLastRAMFile		(const FileReference& f)	{ fLastRAMFile = f; }

		void					UpdatePRCMRU		(const FileReference&);
		void					UpdateRAMMRU		(const FileReference&);
		void					UpdateMRU			(FileRefList&, const FileReference&);

		void					RemovePRCMRU		(const FileReference&);
		void					RemoveRAMMRU		(const FileReference&);
		void					RemoveMRU			(FileRefList&, const FileReference&);

	protected:
		uae_u8					fScale;
		uae_u8					fScreenBackground;
		uae_u8					fWindowFrame;
		uae_u8					fCloseAction;
		string					fCommPort;
		Point					fWindowLocation;
		Point					fGCWLocation;
		bool					fRedirectNetLib;

		bool					fReportCorruptedHeap;			// Always true
		bool					fReportFreeChunkAccess;
		bool					fReportHardwareRegisterAccess;
		bool					fReportInvalidPC;				// Always true
		bool					fReportLowMemoryAccess;
		bool					fReportLowStackAccess;
		bool					fReportMemMgrDataAccess;
		bool					fReportMemMgrSemaphore;
		bool					fReportScreenAccess;
		bool					fReportStackAlmostOverflow;
		bool					fReportStackOverflow;			// Always true
		bool					fReportStorageHeapAccess;
		bool					fReportSysFatalAlert;			// Always true
		bool					fReportSystemGlobalAccess;
		bool					fReportUnhandledException;		// Always true
		bool					fReportUnimplementedTrap;		// Always true
		bool					fReportUninitializedChunkAccess;
		bool					fReportUninitializedStackAccess;
		bool					fReportUnlockedChunkAccess;

		uae_u8					fLogErrorMessages;
		uae_u8					fLogWarningMessages;
		uae_u8					fLogGremlins;
		uae_u8					fLogCPUOpcodes;
		uae_u8					fLogEnqueuedEvents;
		uae_u8					fLogDequeuedEvents;
		uae_u8					fLogSystemCalls;
		uae_u8					fLogApplicationCalls;
		uae_u8					fLogSerial;
		uae_u8					fLogSerialData;
		uae_u8					fLogNetLib;
		uae_u8					fLogNetLibData;
		uae_u8					fLogExgMgr;
		uae_u8					fLogExgMgrData;
		uae_u8					fLogHLDebugger;
		uae_u8					fLogHLDebuggerData;
		uae_u8					fLogLLDebugger;
		uae_u8					fLogLLDebuggerData;

		bool					fReportMemoryLeaks;
		bool					fReportLockedRecords;

		bool					fFillNewBlocks;
		bool					fFillResizedBlocks;
		bool					fFillDisposedBlocks;
		bool					fFillStack;

		Configuration			fLastConfiguration;
		GremlinInfo				fGremlinInfo;

		FileReference			fLastRAMFile;
		FileRefList				fPRC_MRU;
		FileRefList				fRAM_MRU;

		string					fUserName;

		int						fCurLoggingType;
};


extern AppPreferences*	gPrefs;

#endif /* _APPPREFERENCES_H_ */

