/*
 * eDiv Compiler
 * Copyright (C) 2001 Sion Entertainment
 * http://www.sion-e.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/* Este fichero es la cabecera para las DLL's de eDIV.
 * Para saber cómo se utiliza, consulte el eDIV SDK de la documentación de eDIV
 * ESTE FICHERO -NO- HA DE SER MODIFICADO PARA CREAR DLLs, TAN SÓLO POR
 * DESARROLLADORES DE eDIV. EN CASO DE SER MODIFICADO, SE PERDERÁ LA
 * COMPATIBILIDAD CON eDIV Y EL RESTO DE DLLs.
 * En caso de encontrar cualquier bug o anomalía en este archivo, por favor
 * notifíquelo a Sion Entertainment en bugs@edivcentral.com
 */

// COMPATIBILIDAD WIN <-> LINUX

#ifdef WIN32
#	define DllMain() WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
#	include <windows.h>
#else
	typedef enum { FALSE, TRUE } bool;
#endif

// Funciones de exportación de datos
typedef int (TYPEOF_EDIV_Export)(char* cadena, int nparam, void* hfuncion);
typedef int (TYPEOF_EDIV_Export_Const)(char* cadena, int valor);
typedef int* (TYPEOF_EDIV_Export_Global)(char* cadena, int valor);
typedef int* (TYPEOF_EDIV_Export_Global_Tab)(char* cadena, int numregs);
typedef void* (TYPEOF_EDIV_Export_Global_Struct)(char* cadena, int numregs);
typedef int* (TYPEOF_EDIV_Export_Member_Int)(char* cadena, int valor);
typedef char* (TYPEOF_EDIV_Export_Member_Str)(char* cadena, int tamano);
typedef int* (TYPEOF_EDIV_Export_Member_Tab)(char* cadena, int numregs);
typedef int (TYPEOF_EDIV_Export_EndStruct)();
typedef int (TYPEOF_EDIV_Export_Local)(char* cadena, int valor);
typedef int (TYPEOF_EDIV_Export_Local_Tab)(char* cadena, int numregs);
typedef int (TYPEOF_EDIV_Export_Local_Struct)(char* cadena, int numregs);

// estilo BO2K, sólo para "defaultear" las funciones como NULL
/*extern TYPEOF_EDIV_Export				*EDIV_Export;
extern TYPEOF_EDIV_Export_Const			*EDIV_Export_Const;
extern TYPEOF_EDIV_Export_Global		*EDIV_Export_Global;
extern TYPEOF_EDIV_Export_Global_Tab	*EDIV_Export_Global_Tab;
extern TYPEOF_EDIV_Export_Global_Struct	*EDIV_Export_Global_Struc;
extern TYPEOF_EDIV_Export_Member_Int	*EDIV_Export_Member_Int;
extern TYPEOF_EDIV_Export_Member_Str	*EDIV_Export_Member_Str;
extern TYPEOF_EDIV_Export_Member_Tab	*EDIV_Export_Member_Tab;
extern TYPEOF_EDIV_Export_EndStruct		*EDIV_Export_EndStruct;
extern TYPEOF_EDIV_Export_Local			*EDIV_Export_Local;
extern TYPEOF_EDIV_Export_Local_Tab		*EDIV_Export_Local_Tab;
extern TYPEOF_EDIV_Export_Local_Struct	*EDIV_Export_Local_Struct;*/

/*TYPEOF_EDIV_Export					*EDIV_Export              =NULL;
TYPEOF_EDIV_Export_Const        	*EDIV_Export_Const        =NULL;
TYPEOF_EDIV_Export_Global       	*EDIV_Export_Global       =NULL;
TYPEOF_EDIV_Export_Global_Tab   	*EDIV_Export_Global_Tab   =NULL;
TYPEOF_EDIV_Export_Global_Struct	*EDIV_Export_Global_Struct=NULL;
TYPEOF_EDIV_Export_Member_Int   	*EDIV_Export_Member_Int   =NULL;
TYPEOF_EDIV_Export_Member_Str   	*EDIV_Export_Member_Str   =NULL;
TYPEOF_EDIV_Export_Member_Tab   	*EDIV_Export_Member_Tab   =NULL;
TYPEOF_EDIV_Export_EndStruct    	*EDIV_Export_EndStruct    =NULL;
TYPEOF_EDIV_Export_Local        	*EDIV_Export_Local        =NULL;
TYPEOF_EDIV_Export_Local_Tab    	*EDIV_Export_Local_Tab    =NULL;
TYPEOF_EDIV_Export_Local_Struct 	*EDIV_Export_Local_Struct =NULL;*/


// EXPORTAFUNCS_PARAMS deben usarse como parßmetros para ExportaFuncs
#define EXPORTAFUNCS_PARAMS \
TYPEOF_EDIV_Export                  *EDIV_Export              ,\
TYPEOF_EDIV_Export_Const            *EDIV_Export_Const        ,\
TYPEOF_EDIV_Export_Global           *EDIV_Export_Global       ,\
TYPEOF_EDIV_Export_Global_Tab       *EDIV_Export_Global_Tab   ,\
TYPEOF_EDIV_Export_Global_Struct    *EDIV_Export_Global_Struct,\
TYPEOF_EDIV_Export_Member_Int       *EDIV_Export_Member_Int   ,\
TYPEOF_EDIV_Export_Member_Str       *EDIV_Export_Member_Str   ,\
TYPEOF_EDIV_Export_Member_Tab       *EDIV_Export_Member_Tab   ,\
TYPEOF_EDIV_Export_EndStruct        *EDIV_Export_EndStruct    ,\
TYPEOF_EDIV_Export_Local            *EDIV_Export_Local        ,\
TYPEOF_EDIV_Export_Local_Tab        *EDIV_Export_Local_Tab    ,\
TYPEOF_EDIV_Export_Local_Struct     *EDIV_Export_Local_Struct


// Voy a poner unos #defines para que la declaración de datos sea un poco más BASIC... :p
#ifdef CONST
#	undef CONST
#endif
#define FUNCTION		EDIV_Export
#define CONST			EDIV_Export_Const
#define GLOBAL			EDIV_Export_Global
#define GLOBAL_ARRAY	EDIV_Export_Global_Tab
#define GLOBAL_STRUCT	EDIV_Export_Global_Struct
#define _INT			EDIV_Export_Member_Int
#define _STRING			EDIV_Export_Member_Str
#define _ARRAY			EDIV_Export_Member_Tab
#define END_STRUCT		EDIV_Export_EndStruct()
#define LOCAL			EDIV_Export_Local
#define LOCAL_ARRAY		EDIV_Export_Local_Tab
#define LOCAL_STRUCT	EDIV_Export_Local_Struct


// FUNCTION_PARAMS deben usarse como parametros para TODAS las funciones
#define FUNCTION_PARAMS		int *params, int sp

// Se usa igual que el getparm() de DIV
#define getparm()	params[--sp]

// Y esto por si los despistes xD
#define retval(a)	return (a)
