view scn2k/scn2k_flags.h @ 63:4b9ffe15a87d

Refactor Load/LoadSys
author Thibaut GIRKA <thib@sitedethib.com>
date Sat, 06 Feb 2010 17:29:33 +0100
parents c7bcc0ec2267
children 4416cfac86ae
line wrap: on
line source

#ifndef __SCN2K_FLAGS_H__
#define __SCN2K_FLAGS_H__

#include <set>
#include <string>

struct VarInfo {
#define TYPE_NONSYSVARMAX 5
#define TYPE_VARMAX 9
#define TYPE_VARLOCSTR 10
#define TYPE_VARSYSSTR 12
#define TYPE_VARSTR 18
#define TYPE_STR 58
#define TYPE_VAL 68
#define TYPE_SYS 0xc8
#define TYPE_END 0x7f

#define TYPE_SYS_SYS 0
#define TYPE_SYS_SKIPMODE 1
	int type;
	int number;
	int value;
	VarInfo() { type = TYPE_VAL; value = 0;}
	VarInfo(int n) { type = TYPE_VAL; value = n;}
	VarInfo(const VarInfo& i) { type = i.type; number = i.number; value = i.value;}
};

class Flags {
/* flag:
**  type 0-5 : ¥í¡Œ¥«¥ëÀ°¿ô¡¢³Æ2000žÄ
**  type 6, 25 : ¥°¥í¡Œ¥Ð¥ëÀ°¿ô¡¢2000žÄ
**      type 10,11: ¥í¡Œ¥«¥ëÀ°¿ô??¡¢³Æ2000žÄ
**	type 12 : ¥°¥í¡Œ¥Ð¥ëÊž»úÎó¡¢2000žÄ (º£€Ï̵»ë€·€Æ€âÎÉ€€€¬)
**	type 18 : ¥í¡Œ¥«¥ëÊž»úÎó¡¢2000žÄ
**	type 25: ¥·¥¹¥Æ¥àÊÑ¿ô¡Ê¥Þ¥Š¥¹ºÂÉž€Ê€É¡©¡Ë 1000 žÄ¡©
**  type 26-32, 51 : 1-bit access to 0-6, 25
**  type 52-58, 77 : 2-bit access to 0-6, 25
**  type 78-84, 103 : 4-bit access to 0-6, 25
**  type 104-110, 129 : 8-bit access to 0-6, 25
*/
	private:
		typedef unsigned int uint;
		int sys;
		int var[TYPE_VARMAX+1][2000];
		std::string str[2000];
		std::string sys_str[2000];
		std::string loc_str[3];
	public:
		Flags(void);
		int operator () () const;
		int operator () (VarInfo info) const;
		void Str(int type, unsigned int number, char* buf, int sz) const;
		std::string Str(int type, unsigned int number) const;
		std::set<int> cgm_data;

		bool IsInt(int type) const;
		int MaxIndex(int type) const;

		void Set(VarInfo info, int value);
		int Get(int type, int number) const;
		void SetSys(int value);
		void SetStr(VarInfo info, std::string val);

		bool Exec(class Cmd& cmd);

		void Load(const char* str);
		void LoadSys(const char* str);
		void Load(const char* str, bool sys);

		void Save(std::string& str);
		void SaveSys(std::string& str);
};

#endif