class ThisCall0 {
public:
	ThisCall0() {
		thisp = funcp = 0;
	}
	template<class T>
	void set(void (T::*func)(), T * t) {
		unsigned long tp, fp;
		_asm {
			mov eax, t
			mov tp, eax
			mov eax, func
			mov fp, eax
		}
		thisp = tp; funcp = fp;
	}
	void call() {
		if(!thisp || !funcp)
			return;
		unsigned long thisp = this->thisp;
		unsigned long funcp = this->funcp;
		_asm {
			mov ecx, thisp
			call funcp
		}		
	}
protected:
	unsigned long thisp;
	unsigned long funcp;
};
//----------------------------------------------------------------------------
template<typename A>
class ThisCall1 {
public:
	ThisCall1() {
		thisp = funcp = 0;
	}
	template<class T>
	void set(void (T::*func)(A a), T * t) {
		unsigned long tp, fp;
		_asm {
			mov eax, t
			mov tp, eax
			mov eax, func
			mov fp, eax
		}
		thisp = tp; funcp = fp;
	}
	void call(A a) {
		if(!thisp || !funcp)
			return;
		unsigned long thisp = this->thisp;
		unsigned long funcp = this->funcp;
		unsigned long aa;
		_asm {
			mov eax, a
			mov aa, eax
			mov ecx, thisp
			push aa
			call funcp
		}
	}
protected:
	unsigned long thisp;
	unsigned long funcp;
};
//----------------------------------------------------------------------------
template<typename A, typename B>
class ThisCall2 {
public:
	ThisCall2() {
		thisp = funcp = 0;
	}
	template<class T>
	void set(void (T::*func)(A a, B b), T * t) {
		unsigned long tp, fp;
		_asm {
			mov eax, t
			mov tp, eax
			mov eax, func
			mov fp, eax
		}
		thisp = tp; funcp = fp;
	}
	void call(A a, B b) {
		if(!thisp || !funcp)
			return;
		unsigned long thisp = this->thisp;
		unsigned long funcp = this->funcp;
		unsigned long aa, ab;
		_asm {
			mov eax, a
			mov aa, eax
			mov eax, b
			mov ab, eax
			mov ecx, thisp
			push ab
			push aa
			call funcp
		}
	}
protected:
	unsigned long thisp;
	unsigned long funcp;
};
//----------------------------------------------------------------------------
template<typename A, typename B, typename C>
class ThisCall3 {
public:
	ThisCall3() {
		thisp = funcp = 0;
	}
	template<class T>
	void set(void (T::*func)(A a, B b, C c), T * t) {
		unsigned long tp, fp;
		_asm {
			mov eax, t
			mov tp, eax
			mov eax, func
			mov fp, eax
		}
		thisp = tp; funcp = fp;
	}
	void call(A a, B b, C c) {
		if(!thisp || !funcp)
			return;
		unsigned long thisp = this->thisp;
		unsigned long funcp = this->funcp;
		unsigned long aa, ab, ac;
		_asm {
			mov eax, a
			mov aa, eax
			mov eax, b
			mov ab, eax
			mov eax, c
			mov ac, eax
			mov ecx, thisp
			push ac
			push ab
			push aa
			call funcp
		}
	}
protected:
	unsigned long thisp;
	unsigned long funcp;
};
//----------------------------------------------------------------------------
template<typename A, typename B, typename C, typename D>
class ThisCall4 {
public:
	ThisCall4() {
		thisp = funcp = 0;
	}
	template<class T>
	void set(void (T::*func)(A a, B b, C c, D d), T * t) {
		unsigned long tp, fp;
		_asm {
			mov eax, t
			mov tp, eax
			mov eax, func
			mov fp, eax
		}
		thisp = tp; funcp = fp;
	}
	void call(A a, B b, C c, D d) {
		if(!thisp || !funcp)
			return;
		unsigned long thisp = this->thisp;
		unsigned long funcp = this->funcp;
		unsigned long aa, ab, ac, ad;
		_asm {
			mov eax, a
			mov aa, eax
			mov eax, b
			mov ab, eax
			mov eax, c
			mov ac, eax
			mov eax, d
			mov ad, eax
			mov ecx, thisp
			push ad
			push ac
			push ab
			push aa
			call funcp
		}
	}
protected:
	unsigned long thisp;
	unsigned long funcp;
};