diff --git a/ediv/CHANGE_LOG.txt b/ediv/CHANGE_LOG.txt index a5c3212..96ce849 100644 --- a/ediv/CHANGE_LOG.txt +++ b/ediv/CHANGE_LOG.txt @@ -1,3 +1,12 @@ +19/10/2002 +---------- + * Añado la rutina e_free() en ediv.c. Se encarga de comprobar si hay un puntero + en uso, y si es cierto lo libera primero y luego le asigna NULL. (Daijo) + * Añado el archivo errors.h a la carpeta shared con el motivo de que sea mas + claro identificar errores mediante un nombre en lugar de un numero. (Daijo) + * Limpio el archivo extern.h y comentarizo segun las normas de ANSI C99. (Daijo) + * Elimino varias variables no utilizadas en las dll's. (Daijo) + 17/10/2002 ---------- * Eliminados archivos parser.* y compiler.* de la carpeta STUB ya que no los diff --git a/ediv/src/dlls/graphics/main.c b/ediv/src/dlls/graphics/main.c index a3bf001..0f1a69f 100644 --- a/ediv/src/dlls/graphics/main.c +++ b/ediv/src/dlls/graphics/main.c @@ -9,6 +9,7 @@ //#include //#include #include "export.h" +#include "errors.h" #include #include "graphics.h" #include "SDL_rotozoom.h" @@ -921,13 +922,11 @@ int eDIV_LOAD_FPG(FUNCTION_PARAMS2) SDL_Color p[256]; - // TODO: quitar printf's y exit's y poner fp->Runtime_Error() - archivo = getstrparm() ; f=fopen(archivo,"rb"); if(f==NULL) { - fp->Runtime_Error(105); + fp->Runtime_Error(ERR_CANNOTOPENFPG); } fseek(f,0,SEEK_END); @@ -942,7 +941,7 @@ int eDIV_LOAD_FPG(FUNCTION_PARAMS2) if(strcmp(cabecera.header,"f16\x1A\x0D\x0A")) { if(strcmp(cabecera.header,"f24\x1A\x0D\x0A")) { if(strcmp(cabecera.header,"f32\x1A\x0D\x0A")) { - fp->Runtime_Error(106); + fp->Runtime_Error(ERR_INVALIDFPGHEADER); } else { bpp=32; @@ -975,7 +974,7 @@ int eDIV_LOAD_FPG(FUNCTION_PARAMS2) fread(&infomapa,1,sizeof(FPGMAPINFO),f); num=infomapa.code; if(num>999 || num<0) { - fp->Runtime_Error(111); + fp->Runtime_Error(ERR_INVALIDMAPCODE); } if ( files[0].mapa[num].existe == 1 ) return -1 ; diff --git a/ediv/src/dlls/math/math.c b/ediv/src/dlls/math/math.c index 64b27f8..4b2a4c2 100644 --- a/ediv/src/dlls/math/math.c +++ b/ediv/src/dlls/math/math.c @@ -24,8 +24,9 @@ */ #include #include -#include "math.h" +#include +#include "math.h" #include "main.h" int seno[90001] ; @@ -103,7 +104,7 @@ int eDiv_Sqrt(FUNCTION_PARAMS) int eDiv_Rand(FUNCTION_PARAMS) { - int a,b,n,i ; + int a,b,n ; b = getparm() ; a = getparm() ; n = (int)(rand()%(b-a+1))+a ; diff --git a/ediv/src/dlls/scroll/scroll.c b/ediv/src/dlls/scroll/scroll.c index 7f11351..beb05b6 100644 --- a/ediv/src/dlls/scroll/scroll.c +++ b/ediv/src/dlls/scroll/scroll.c @@ -83,11 +83,14 @@ int eDiv_StartScroll(FUNCTION_PARAMS) void frame(FUNCTION_PARAMS) { + /* + * de momento solo hay esta demostracion de que fp->Dibuja funciona xDD + * falta hacer los scrolls :P + */ +/* SDL_Rect srcrect, dstrect ; - // de momento solo hay esta demostracion de que fp->Dibuja funciona xDD - // falta hacer los scrolls :P -/* + if ( fp->existe.dibuja ) { if ( fp->files[0].existe ) diff --git a/ediv/src/dlls/text/text.c b/ediv/src/dlls/text/text.c index 331a381..b8252ed 100644 --- a/ediv/src/dlls/text/text.c +++ b/ediv/src/dlls/text/text.c @@ -168,8 +168,6 @@ int eDiv_WriteInt(FUNCTION_PARAMS) int fuente , x , y , centrado , offset_var ; char *texto ; char texto2[30] ; - char *texp ; - int temp ; offset_var = getparm() ; centrado = getparm() ; y = getparm() ; diff --git a/ediv/src/ediv/ediv.c b/ediv/src/ediv/ediv.c index 8d16263..f250858 100644 --- a/ediv/src/ediv/ediv.c +++ b/ediv/src/ediv/ediv.c @@ -354,6 +354,14 @@ void* e_malloc(size_t size) return ret; } +void *e_free(void *puntero) +{ + if (puntero) { + free(puntero); + puntero=NULL; + } +} + void errormem() { printf(translate(24)); @@ -362,7 +370,7 @@ void errormem() /* - * Gestión de errores + * Gestión de errores */ int _le,_t; byte *_ie; diff --git a/ediv/src/shared/extern.h b/ediv/src/shared/extern.h index cdc0fd8..22ebbbd 100644 --- a/ediv/src/shared/extern.h +++ b/ediv/src/shared/extern.h @@ -1,7 +1,7 @@ /* * eDiv Compiler - * Copyleft (C) 2000-2002 Sion Entertainment - * http://www.sion-e.com + * Copyright (C) 2000-2002 Sion Entertainment + * http://www.sionhq.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 @@ -21,44 +21,41 @@ #ifndef __EXTERN_H #define __EXTERN_H - /*#ifdef _WIN32 -# include "dll_load.h" -#endif*/ - #include #include "main.h" #include "varindex.h" -#define MAX_EXTERN_FUNCS 0xFFFF // ¿Demasiado? +#define MAX_EXTERN_FUNCS 0xFFFF /* ¿Demasiado? */ #define MAX_EXTFUNC_PARMS 0xFF #define MAX_DLLS 0xFF #define MAX_ENTRYPOINTS 0xFF -#define P_SIEMPRE 512 // yo creo ke esto vale +#define P_SIEMPRE 512 /* yo creo ke esto vale */ #define P_NUNCA -512 -char fichdll[256]; // Nombre de la DLL que se está ejecutando ahora +char fichdll[256]; /* Nombre de la DLL que se está ejecutando ahora */ -/////////// -// EXPORT +/* + * EXPORT + */ -int EDIV_Export(char* cadena, int nparam, void* hfuncion); // Funcion -int EDIV_Export_Const(char* cadena, int valor); // Constante -int EDIV_Export_Global(char* cadena, int valor); // Global -int EDIV_Export_Global_Tab(char* cadena, int numregs); // Tabla global -int EDIV_Export_Global_Struct(char* cadena, int numregs); // Struct global -int EDIV_Export_Member_Int(char* cadena, int valor); // Miembro int -int EDIV_Export_Member_Str(char* cadena, int tamano); // Miembro string -int EDIV_Export_Member_Tab(char* cadena, int numregs); // Miembro tabla -int EDIV_Export_EndStruct(); // Cierra struct -int EDIV_Export_Local(char* cadena, int valor); // Local -int EDIV_Export_Local_Tab(char* cadena, int numregs); // Tabla local (NO USADO EN DIV2) -int EDIV_Export_Local_Struct(char* cadena, int numregs); // Struct local -int EDIV_Export_Entrypoint(int ep, void* hfuncion); // Entrypoint -int EDIV_Export_Priority(int priority); // Prioridad de la DLL +int EDIV_Export(char* cadena, int nparam, void* hfuncion); /* Funcion */ +int EDIV_Export_Const(char* cadena, int valor); /* Constante */ +int EDIV_Export_Global(char* cadena, int valor); /* Global */ +int EDIV_Export_Global_Tab(char* cadena, int numregs); /* Tabla global */ +int EDIV_Export_Global_Struct(char* cadena, int numregs); /* Struct global */ +int EDIV_Export_Member_Int(char* cadena, int valor); /* Miembro int */ +int EDIV_Export_Member_Str(char* cadena, int tamano); /* Miembro string */ +int EDIV_Export_Member_Tab(char* cadena, int numregs); /* Miembro tabla */ +int EDIV_Export_EndStruct(); /* Cierra struct */ +int EDIV_Export_Local(char* cadena, int valor); /* Local */ +int EDIV_Export_Local_Tab(char* cadena, int numregs); /* Tabla local (NO USADO EN DIV2) */ +int EDIV_Export_Local_Struct(char* cadena, int numregs); /* Struct local */ +int EDIV_Export_Entrypoint(int ep, void* hfuncion); /* Entrypoint */ +int EDIV_Export_Priority(int priority); /* Prioridad de la DLL */ -// TYPEOF_EXPORT +/* TYPEOF_EXPORT */ typedef int (TYPEOF_EDIV_Export)(char* cadena, int nparam, void* hfuncion); typedef int (TYPEOF_EDIV_Export_Const)(char* cadena, int valor); @@ -75,84 +72,63 @@ typedef int (TYPEOF_EDIV_Export_Local_Struct)(char* cadena, int numregs); typedef int (TYPEOF_EDIV_Export_Entrypoint)(int ep, void* hfuncion); typedef int (TYPEOF_EDIV_Export_Priority)(int priority); -// Call_Entrypoint +/* Call_Entrypoint */ typedef int (TYPEOF_Call_Entrypoint)(int ep, ...); -// Dibuja +/* Dibuja */ typedef int (TYPEOF_Dibuja)(SDL_Surface *, SDL_Rect , SDL_Rect , int , int ) ; -// Errores +/* Errores */ typedef void (TYPEOF_Runtime_Error)(int, ...); typedef void (TYPEOF_Critical_Error)(int, ...); // Obtiene offset de variable indexada dinámicamente typedef int (TYPEOF_GetVarOffset)(tipo_t tipo,char* nombre); -///////////// -// ENTRY-POINTS -/////////// -// Estas funciones son llamadas por el STUB en determinados eventos -// (Cuando una DLL hace cierta acción, lo avisa al Stub y el stub se encarga de llamar -// a las correspondientes rutinas de las dll's, ordenadas por prioridad) -///////// - -// Constantes para EDIV_Export_Entrypoint - -#define EDIV_set_video_mode 1 // Al activar un nuevo modo de vídeo -#define EDIV_process_palette 2 // Al cargar una paleta -#define EDIV_process_active_palette 3 // Al modificar la paleta activa (usada en los fades) -#define EDIV_process_sound 4 // Al cargar un efecto sonoro -#define EDIV_process_map 5 // Al cargar un mapa -#define EDIV_process_fpg 6 // Al cargar un FPG -#define EDIV_process_fnt 7 // Al cargar una fuente -#define EDIV_background_to_buffer 8 // Volcar el fondo al buffer -#define EDIV_buffer_to_video 9 // Volcar el buffer a la memoria de video -#define EDIV_post_process_scroll 10 // Tras dibujar una ventana de scroll (sin los sprites) -#define EDIV_post_process_m7 11 // Tras dibujar una ventana de modo7 (sin los sprites) -#define EDIV_post_process_m8 12 // Tras dibujar una ventana de modo8 (sin los sprites) -#define EDIV_post_process_buffer 13 // Tras haber terminado de dibujarlo todo -#define EDIV_post_process 14 // Tras ejecutar el frame de un proceso (cualquier %) -#define EDIV_put_sprite 15 // Dibujar un sprite -#define EDIV_ss_init 16 // Inicio de salvapantallas -#define EDIV_ss_frame 17 // Frame de salvapantallas -#define EDIV_ss_end 18 // Fin de salvapantallas -#define EDIV_frame 19 // En cada frame -#define EDIV_trace 20 // Después de ejecutar cada instrucción de bytecode (solo en debug) -#define EDIV_debug 21 // Invocar al trazador - sentencia debug (solo en debug) -#define EDIV_first_load 22 // Se ejecuta al cargar la DLL en ejecucion -#define EDIV_quit 23 // Llamado por stub_quit() - - -// Call_Entrypoint -// Devuelve el número de entrypoints a los que corresponde ese identificador. -// (0 si no hay ninguno) -int Call_Entrypoint(int ep, ...); - -// Prototipos de los entrypoints (no hacen falta aki) /* -void set_video_mode(void); -void process_palette(void); -void process_active_palette(void); -void process_sound(char *sound,int lenght); -void process_fpg(char *fpg,int fpg_lenght); -void process_map(char *map,int map_lenght); -void process_fnt(char *fnt,int fnt_lenght); -void background_to_buffer(void); -void buffer_to_video(void); -void post_process_scroll(void); -void post_process_m7(void); -void post_process_m8(void); -void post_process_buffer(void); -void post_process(void); -void put_sprite(unsigned char * si, int x,int y, int an, int al, int xg, int yg, - int ang, int size, int flags); -void ss_init(void); -void ss_frame(void); -void ss_end(void); -void frame(void); -*/ -////////////////////////////// + * ENTRY-POINTS + * + * Estas funciones son llamadas por el STUB en determinados eventos + * (Cuando una DLL hace cierta acción, lo avisa al Stub y el stub se encarga de llamar + * a las correspondientes rutinas de las dll's, ordenadas por prioridad) + */ +/* + * Constantes para EDIV_Export_Entrypoint + */ + +#define EDIV_set_video_mode 1 // Al activar un nuevo modo de vídeo */ +#define EDIV_process_palette 2 // Al cargar una paleta */ +#define EDIV_process_active_palette 3 // Al modificar la paleta activa (usada en los fades) */ +#define EDIV_process_sound 4 // Al cargar un efecto sonoro */ +#define EDIV_process_map 5 // Al cargar un mapa */ +#define EDIV_process_fpg 6 // Al cargar un FPG */ +#define EDIV_process_fnt 7 // Al cargar una fuente */ +#define EDIV_background_to_buffer 8 // Volcar el fondo al buffer */ +#define EDIV_buffer_to_video 9 // Volcar el buffer a la memoria de video */ +#define EDIV_post_process_scroll 10 // Tras dibujar una ventana de scroll (sin los sprites) */ +#define EDIV_post_process_m7 11 // Tras dibujar una ventana de modo7 (sin los sprites) */ +#define EDIV_post_process_m8 12 // Tras dibujar una ventana de modo8 (sin los sprites) */ +#define EDIV_post_process_buffer 13 // Tras haber terminado de dibujarlo todo */ +#define EDIV_post_process 14 // Tras ejecutar el frame de un proceso (cualquier %) */ +#define EDIV_put_sprite 15 // Dibujar un sprite */ +#define EDIV_ss_init 16 // Inicio de salvapantallas */ +#define EDIV_ss_frame 17 // Frame de salvapantallas */ +#define EDIV_ss_end 18 // Fin de salvapantallas */ +#define EDIV_frame 19 // En cada frame */ +#define EDIV_trace 20 // Después de ejecutar cada instrucción de bytecode (solo en debug) */ +#define EDIV_debug 21 // Invocar al trazador - sentencia debug (solo en debug) */ +#define EDIV_first_load 22 // Se ejecuta al cargar la DLL en ejecucion */ +#define EDIV_quit 23 // Llamado por stub_quit() */ + + +/* + * Call_Entrypoint + * + * Devuelve el número de entrypoints a los que corresponde ese identificador. + * (0 si no hay ninguno) + */ +int Call_Entrypoint(int ep, ...); #define EXPORTAFUNCS_PARAMS \ EDIV_Export ,\ @@ -188,14 +164,14 @@ TYPEOF_EDIV_Export_Priority * -/// FUNCIONES PREDEFINIDAS /// +/* FUNCIONES PREDEFINIDAS */ typedef int (TYPEOF_ExportaFuncs)(EXPORTAFUNCS_PARAMS_DECLARE); -// FUNCIÓN EXTERNA +/* FUNCIÓN EXTERNA */ -// ¡ojo! debe ser igual en export.h +/* ¡ojo! debe ser igual en export.h */ #define FUNCTION_PARAMS \ int *params, int *sp, \ int mem[], \ @@ -204,13 +180,13 @@ typedef int (TYPEOF_ExportaFuncs)(EXPORTAFUNCS_PARAMS_DECLARE); TYPEOF_Call_Entrypoint *Call_Entrypoint struct _procs_s{ - int id ; // offset de los datos locales del proceso - int tipo ; // tipo de proceso - int orden ; // indice en proc_orden[] - int num_params ; // numero de parametros k coje ( NO SE PARA K SIRVE PERO PARA ALGO ESTARA CBP NO ? ) - int imem ; // Posicion en la k se quedo suspendido el proceso - int priority ; // Priority - int frame; // Frame completado + int id ; /* offset de los datos locales del proceso */ + int tipo ; /* tipo de proceso */ + int orden ; /* indice en proc_orden[] */ + int num_params ; /* numero de parametros k coje ( NO SE PARA K SIRVE PERO PARA ALGO ESTARA CBP NO ? ) */ + int imem ; /* Posicion en la k se quedo suspendido el proceso */ + int priority ; /* Priority */ + int frame; /* Frame completado */ int graph ; } procs_s[ 4096 ] ; @@ -256,7 +232,7 @@ struct _fun_params{ struct _regions *regions ; struct _existe existe ; struct _files *files ; - TYPEOF_Dibuja *Dibuja ; // <- Tienes una funcion identica a esta variable (Daijo) <<- Y que? , la funcion no esta dentro de esta estructura :P (Riseven) + TYPEOF_Dibuja *Dibuja ; TYPEOF_Call_Entrypoint *Call_Entrypoint ; TYPEOF_Runtime_Error *Runtime_Error ; TYPEOF_Critical_Error *Critical_Error ; @@ -265,41 +241,35 @@ struct _fun_params{ -// La pila de parametros y su señalador o como se llame -//int params[MAX_EXTFUNC_PARMS]; -//int sp; +/* + * La pila de parametros y su señalador o como se llame + * int params[MAX_EXTFUNC_PARMS]; + * int sp; + */ -void* extfuncs[MAX_EXTERN_FUNCS]; // tabla de punteros a las funciones de las DLLs (stub) -int extparms[MAX_EXTERN_FUNCS]; // nº de parámetros de cada función externa (necesario para la sobrecarga) +void* extfuncs[MAX_EXTERN_FUNCS]; /* tabla de punteros a las funciones de las DLLs (stub) +int extparms[MAX_EXTERN_FUNCS]; /* nº de parámetros de cada función externa (necesario para la sobrecarga) struct _entrypoints { - int tipo; // Ver #defines de entrypoints más arriba - int dll; // DLL que contiene este entrypoint - void* hfuncion; // Puntero a la función entrypoint de la DLL + int tipo; /* Ver #defines de entrypoints más arriba */ + int dll; /* DLL que contiene este entrypoint */ + void* hfuncion; /* Puntero a la función entrypoint de la DLL */ } entrypoints[MAX_ENTRYPOINTS]; struct _dlls { - char* nombre; // nombre de la DLL (ej: "sample.so") - byte usado; // si la dll es requerida por el programa - int mem_nombre; // posición del nombre en mem[] - int prioridad; // prioridad por defecto de la DLL + char* nombre; /* nombre de la DLL (ej: "sample.so") */ + byte usado; /* si la dll es requerida por el programa */ + int mem_nombre; /* posición del nombre en mem[] */ + int prioridad; /* prioridad por defecto de la DLL */ void* hDLL; -// int mem_size; // tamaño ocupado en mem[] -// int loc_size; // tamaño ocupado en loc[] -// int nfuncs; // numero de funciones que contiene -// struct _extfunc ext_funcs[MAX_EXTERN_FUNCS]; } dlls[MAX_DLLS]; -int dimem; // indices para poder devolver offsets de variables segun se van declarando +int dimem; /* indices para poder devolver offsets de variables segun se van declarando */ int diloc; -int numdlls; // Número de DLLs encontradas en el directorio -int n_dlls; // Número de DLLs requeridas por el programa -int n_externs; // Número de funciones importadas -int n_entrypoints; // Número de entrypoints declarados - -// usar putparm() para poner los parametros en la pila de parametros en el orden normal -// (del primero al ultimo) -//#define putparm(a) params[sp++]=(int)a +int numdlls; /* Número de DLLs encontradas en el directorio */ +int n_dlls; /* Número de DLLs requeridas por el programa */ +int n_externs; /* Número de funciones importadas */ +int n_entrypoints; /* Número de entrypoints declarados */ #endif // __EXTERN_H \ No newline at end of file