view scn2k/scn2k_flags.h @ 65:4416cfac86ae

Convert EUC-JP files to UTF8
author Thibaut Girka <thib@sitedethib.com>
date Fri, 26 Nov 2010 10:53:15 +0100
parents 4b9ffe15a87d
children
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