From 042fcd72976335db4d2b790363e11972c052c16843b4c54c91c320a420b51906 Mon Sep 17 00:00:00 2001 From: Gabriel Lorenzo Date: Tue, 24 Sep 2002 00:47:12 +0000 Subject: [PATCH] =?UTF-8?q?IMPORTANTE=20LEER=20CHANGELOG=20-=20SDK=20MODIF?= =?UTF-8?q?ICADO=20-=20indexado=20din=C3=A1mico=20r00lz!=20:)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ediv/CHANGE_LOG.txt | 25 +++++++ ediv/doc/html/index.dok | 2 + ediv/doc/html/template.txt | 3 + ediv/propuestas.txt | 4 +- ediv/src/dlls/dinmem/dinmem.c | 2 +- ediv/src/dlls/dinmem/dinmem.vcproj | 3 - ediv/src/dlls/dlls.suo | Bin 18944 -> 19968 bytes ediv/src/dlls/edivstd/edivstd.c | 5 +- ediv/src/dlls/edivstd/edivstd.vcproj | 3 - ediv/src/dlls/export.h | 95 ++++++++------------------- ediv/src/dlls/file/file.c | 6 +- ediv/src/dlls/file/file.vcproj | 3 - ediv/src/dlls/graphics/main.c | 89 +++++++++++++------------ ediv/src/dlls/input/input.c | 4 +- ediv/src/dlls/input/input.vcproj | 3 - ediv/src/dlls/math/math.c | 19 +++--- ediv/src/dlls/scroll/scroll.c | 2 +- ediv/src/dlls/scroll/scroll.vcproj | 3 - ediv/src/dlls/text/text.c | 4 +- ediv/src/dlls/text/text.vcproj | 3 - ediv/src/ediv/compiler.c | 53 +++++++++++++-- ediv/src/ediv/ediv_export.c | 20 ++++-- ediv/src/ediv/varindex.c | 56 +++++++++++++--- ediv/src/shared/extern.h | 5 ++ ediv/src/shared/varindex.h | 30 +++++++-- ediv/src/stub/inte.c | 9 +-- ediv/src/stub/main.h | 2 +- ediv/src/stub/stub.c | 49 +++++++++----- ediv/src/visual c/ediv/ediv.vcproj | 6 ++ ediv/src/visual c/ediv_ws.suo | Bin 23552 -> 24576 bytes ediv/src/visual c/stub/stub.vcproj | 3 + 31 files changed, 307 insertions(+), 204 deletions(-) diff --git a/ediv/CHANGE_LOG.txt b/ediv/CHANGE_LOG.txt index 2349b74..dadf6ec 100644 --- a/ediv/CHANGE_LOG.txt +++ b/ediv/CHANGE_LOG.txt @@ -1,3 +1,28 @@ +24/9/2002 +--------- + * ¡¡Añadido indexado de variables dinámico!! (¿contento Rise?) :D + +------------------------------+ + | LEER ESTO CON MUCHA ATENCIÓN | + +------------------------------+ + 1) Compilad la documentación (doc/html/makedokNT.bat) y leed bien el + varindex-howto.html. Las macros a que hace referencia se encuentran en + varindex.h (para el stub) y export.h (para las dll's), por si quereis + verlas. + 2) NO INCLUYÁIS VARINDEX.H EN LAS DLL's, sólamente export.h + + Ya tenéis acceso a cualquier variable, tabla o estructura de cualquier dll + desde cualquier otra dll. Falta hacer un sistema de dependencias, rara vez + se va a dar el caso de que una dll dependa de otra (a excepción de la + graphics o la edivstd), pero vendrá muy bien de todas formas y aseguraremos + la robustez de ediv, especialmente de cara a dll's hechas por usuarios. + Al compilar, ediv (compilado como Debug) guarda en varindex.out la tabla + de variables sin comprimir, que podeis comparar con la lista que muestra + el stub en stdout al arrancar, por si hay que comprobar errores. (Er_Makina) + * Naturalmente ha sido necesario adaptar el stub y todas las dlls. De paso he + aprovechado para cambiar alguna cosilla por ahí para quitar warnings (uf + la graphics tiene cada warnings mas peligrosos.. variables sin inicializar.. + de to) :P (Er_Makina) + 9/9/2002 -------- * Le he añadido icono al stub, y también he hecho un programa (iconchanger) diff --git a/ediv/doc/html/index.dok b/ediv/doc/html/index.dok index e11e1c7..44eb5fc 100644 --- a/ediv/doc/html/index.dok +++ b/ediv/doc/html/index.dok @@ -86,6 +86,8 @@ sdk +diferencias_compiladores +estructura_dll +export_h ++varindex +++varindex-howto explicacion_source +compilador_ediv ++ediv_c diff --git a/ediv/doc/html/template.txt b/ediv/doc/html/template.txt index 878760f..314a4f7 100644 --- a/ediv/doc/html/template.txt +++ b/ediv/doc/html/template.txt @@ -11,3 +11,6 @@ "en cualquiera de los documentos que\nse incluyen en este proyecto, por favor " "comuníquenoslo a bugs@edivcentral.com. " "Gracias.
\n© Copyleft Sion Entertainment, 2000-2002\n\n\n" +<%code%> "

"
+<%/code%> "

" diff --git a/ediv/propuestas.txt b/ediv/propuestas.txt index 6be1496..b3b16a6 100644 --- a/ediv/propuestas.txt +++ b/ediv/propuestas.txt @@ -268,4 +268,6 @@ http://www.cs.ukc.ac.uk/people/staff/rej/gc.html screen_color(int color) rellena el fondo con un color -Incluir Psycle (tracker musical) en el IDE: http://sourceforge.net/projects/psycle/ \ No newline at end of file +Incluir Psycle (tracker musical) en el IDE: http://sourceforge.net/projects/psycle/ + +punteros a estructuras genericos (que no haga falta indicarle a qué tipo de estructura apuntan) \ No newline at end of file diff --git a/ediv/src/dlls/dinmem/dinmem.c b/ediv/src/dlls/dinmem/dinmem.c index 5d56a4e..c2af7d2 100644 --- a/ediv/src/dlls/dinmem/dinmem.c +++ b/ediv/src/dlls/dinmem/dinmem.c @@ -1,6 +1,6 @@ #include -#include "../../shared/varindex.h" +//#include "../../shared/varindex.h" #include "dinmem.h" diff --git a/ediv/src/dlls/dinmem/dinmem.vcproj b/ediv/src/dlls/dinmem/dinmem.vcproj index f3b4e39..d2dca49 100644 --- a/ediv/src/dlls/dinmem/dinmem.vcproj +++ b/ediv/src/dlls/dinmem/dinmem.vcproj @@ -153,9 +153,6 @@ - - zfxMrJ@! zpvddO1|P%x0UIxXMbiIF?2>G_(lC z2j&ABa1Mt!I0K~%u)GPso52>a6;O9YSeoXK6~Eea3IC)6M*bzP%5bGA;b@_vE3I4K zaLw?#Gj!M0Y!=;TWPC)zH#s@qCghq|D#EPwOHds78M-X#K6zNI5;4*25OyJ9{R)nC zppM4$s##%3t-#J&-jme0k_s5g6*)anF4<|&)1f&b@`uVkMF*T%8IAio9R74R9^Z-{7!Qd9F!exR&Nb{6S+NUoy>RV@ONcuh%Q0Ci#a_#}iCecH zk%s7{P(vWLj}3be(TBW3n0&GakRdC6fT<5!f+Gxg2k;c)HN9vH(s+Z9`r8#c)$m4U z$m{)rHa0fV(MXuo#(Fx`9;TnX^;X2NC5I^&sb`nbhT>&flT@0Y<=|;4i>VW*qY0;2&@wJOB^D zBk&kJ0Z+j*@ElB>=sH$dk#OnK4~;L_r%GBg8n=s&=zn9eHLY8hoGrYjZp>Qi#<;H{ zwA|vMMc2)1ai@)jvG=o)jv1#FOl~hk`)o8Gt)`>3NqK}i8<*0*fiTWBLsp delta 1134 zcmY*YOH30{6uoblwnIBD{ehr}d`b((7$_*g_-UXLC@2-turLt=_(`e~9S!nHFmdUk za#^_W!$vo{KqfIpHz<@<5HSj0T&ii=od}UUTURQ8wnCny+BY}dCeUt^r)y2 z&?TGk#QCkQ!R~>zMew*Mp~GZlnm^iB1fi0DdJ@+48bwJx07c2U$%4#GQHgNKz*-z~ zv$lp`hITpRiB&niKU|GwNu?&Ith9v%an=`i3whISAb%noe%z0<(e8)%Rpnp)E=f%z zpbFclRfq@$I2~-(Wr%FtztBuDX^FCn|3srWsms>-Hi-cPBqgiBvpLmtPc^Pqu*+A) zVb#ZdTjPA7YoV|OR~n}%O>xY($RA6}&GM3AT@Hc{T%b!dO4ms4THwWNgoYtrr>l^L z!N1F5&e0V*1Hbby4Z%e8LAL%PL<1txlbKMEYeIo2OZ_a|QrL-TLN@3sVy@6-NGY%( z>0!V+W*yp%pQM!6Lw;WER{2XJgdQyOV7OCq6x46^B^8NU_Rh#Se~wh}oLA$Oww*3Q zX>r;|r)b3d9qG_ETHUa!%juVy=kL-q8qW*W8u3rjN=<&eftj_YN}g5TFEqD1H)0Pa zb?izq?|dw04qAO>;}GUP2#fsB@>bVtkX%FfS^X>XWz4Ra)786$KR4QBjrJbupe9ax zOZi*7m!G#M06#y7bnx9oAFp@!TLlh=!<_C(bL@!9>tX*wT}t7n_3!vb^ -#include "../../shared/varindex.h" +//#include "../../shared/varindex.h" #include "main.h" @@ -168,7 +168,8 @@ int eDiv_GetId(FUNCTION_PARAMS) last_proc = i ; id1 = fp->procs_s[ fp->proc_orden[ i ] ].id ; //Si el proceso se corresponde con el type - if ( fp->mem[ id1 + fp->varindex[ _res_process_type ] ] == a ) +// if ( fp->mem[ id1 + fp->varindex[ _res_process_type ] ] == a ) + if ( reserved("process_type",id1) == a ) { return ( fp->procs_s[ fp->proc_orden[ i ] ].id ) ; } diff --git a/ediv/src/dlls/edivstd/edivstd.vcproj b/ediv/src/dlls/edivstd/edivstd.vcproj index cc08aa9..274d9e2 100644 --- a/ediv/src/dlls/edivstd/edivstd.vcproj +++ b/ediv/src/dlls/edivstd/edivstd.vcproj @@ -148,9 +148,6 @@ - - mem[fp->GetVarOffset(v_global,nombre)] +#define reserved(nombre,id) fp->mem[(id)+fp->GetVarOffset(v_reserved,nombre)] +#define local(nombre,id) fp->mem[(id)+fp->GetVarOffset(v_local,nombre)] +#define globalptr(nombre) fp->GetVarOffset(v_global,nombre) +#define reservedptr(nombre) fp->GetVarOffset(v_reserved,nombre) +#define localptr(nombre) fp->GetVarOffset(v_local,nombre) + +///// FIN DE VARINDEX ///// + + #include // Funciones de exportación de datos @@ -69,6 +91,9 @@ typedef int (TYPEOF_Dibuja)(SDL_Surface *, SDL_Rect, SDL_Rect, int, int); 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); + // estilo BO2K, sólo para "defaultear" las funciones como NULL /*extern TYPEOF_EDIV_Export *EDIV_Export; extern TYPEOF_EDIV_Export_Const *EDIV_Export_Const; @@ -233,6 +258,7 @@ struct _fun_params{ TYPEOF_Call_Entrypoint *Call_Entrypoint ; TYPEOF_Runtime_Error *Runtime_Error ; TYPEOF_Critical_Error *Critical_Error ; + TYPEOF_GetVarOffset *GetVarOffset ; } ; @@ -273,75 +299,6 @@ void first_load(FUNCTION_PARAMS) ; ////////////////////////////// -//// VARIABLES INDEXADAS //// - -// copio y pasteo brutalmente, no pongo #include para que el export.h sea independiente -/* -#define var(a) mem[varindex[a]] - - -////////////////////////////// -/// GLOBALES /// -////////////////////////////// - -#define _glo_timer 0 -#define _glo_max_process_time 1 -#define _glo_argc 2 -#define _glo_argv 3 - - -////////////////////////////// -/// LOCALES /// -////////////////////////////// - -// Estructura reserved - -#define _res_process_id 4 -#define _res_id_scan 5 -#define _res_process_type 6 -#define _res_type_scan 7 -#define _res_status 8 -#define _res_parameters 9 -#define _res_param_offset 10 -#define _res_program_index 11 -#define _res_stack_pointer 12 -#define _res_is_executed 13 -#define _res_is_painted 14 -#define _res_m8_object 15 -#define _res_old_ctype 16 -#define _res_frame_percent 17 -#define _res_box_x0 18 -#define _res_box_y0 19 -#define _res_box_x1 20 -#define _res_box_y1 21 -#define _res_f_count 22 -#define _res_caller_id 23 - -// Jerarquía de procesos -#define _loc_father 24 -#define _loc_son 25 -#define _loc_smallbro 26 -#define _loc_bigbro 27 - -// Variables locales varias -#define _loc_priority 28 -#define _loc_ctype 29 -#define _loc_x 30 -#define _loc_y 31 -#define _loc_z 32 -#define _loc_graph 33 -#define _loc_size 34 -#define _loc_angle 35 -#define _loc_region 36 -#define _loc_file 37 -#define _loc_xgraph 38 -#define _loc_height 39 -#define _loc_cnumber 40 -#define _loc_resolution 41 -#define _loc_flags 42 -#define _loc_transparency 43 -*/ - #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/ediv/src/dlls/file/file.c b/ediv/src/dlls/file/file.c index f59204e..42fc181 100644 --- a/ediv/src/dlls/file/file.c +++ b/ediv/src/dlls/file/file.c @@ -1,7 +1,7 @@ #include #include -#include "../../shared/varindex.h" +//#include "../../shared/varindex.h" #include "file.h" @@ -93,7 +93,7 @@ int eDiv_Fread(FUNCTION_PARAMS) int eDiv_Ftell(FUNCTION_PARAMS) { - int handle ; + int handle=getparm(); if ( !existe[handle] ) return -1 ; @@ -126,7 +126,7 @@ int eDiv_Flush(FUNCTION_PARAMS) int eDiv_Fclose(FUNCTION_PARAMS) { - int handle, num ; + int handle=getparm(), num ; if ( handle == 0 ) if ( ( num = _fcloseall() ) == EOF ) diff --git a/ediv/src/dlls/file/file.vcproj b/ediv/src/dlls/file/file.vcproj index 8918c12..a913540 100644 --- a/ediv/src/dlls/file/file.vcproj +++ b/ediv/src/dlls/file/file.vcproj @@ -153,9 +153,6 @@ - - #include "graphics.h" -#include "varindex.h" +//#include "varindex.h" #define FUNCTION_PARAMS2 struct _fun_params *fp @@ -430,21 +430,21 @@ int eDIV_COLLISION(FUNCTION_PARAMS) if ( a < 4000000 ) { id1 = fp->procs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id ; - g1 = fp->mem[ id1 + fp->varindex[_loc_graph] ] ; - f1 = fp->mem[ id1 + fp->varindex[_loc_file] ] ; + g1 = local("graph",id1) ; + f1 = local("file",id1) ; if ( files[f1].existe == 0 || files[f1].mapa[g1].existe == 0 ) return -1 ; - r1.x = fp->mem[ id1 + fp->varindex[_loc_x] ] ; - r1.y = fp->mem[ id1 + fp->varindex[_loc_y] ] ; + r1.x = local("x",id1) ; + r1.y = local("y",id1) ; r1.w = files[f1].mapa[g1].Surface->w ; r1.h = files[f1].mapa[g1].Surface->h ; id2 = a ; - g2 = fp->mem[ id2 + fp->varindex[_loc_graph] ] ; + g2 = local("graph",id2) ; if ( files[f2].existe == 0 || files[f2].mapa[g2].existe == 0 ) return -1 ; - f2 = fp->mem[ id2 + fp->varindex[_loc_file] ] ; - r2.x = fp->mem[ id2 + fp->varindex[_loc_x] ] ; - r2.y = fp->mem[ id2 + fp->varindex[_loc_y] ] ; + f2 = local("file",id2) ; + r2.x = local("x",id2) ; + r2.y = local("y",id2) ; r2.w = files[f2].mapa[g2].Surface->w ; r2.h = files[f2].mapa[g1].Surface->h ; //Colision barata :P @@ -458,23 +458,23 @@ int eDIV_COLLISION(FUNCTION_PARAMS) { id1 = fp->procs_s[ fp->proc_orden[ i ] ].id ; //Si el proceso se corresponde con el type - if ( fp->mem[ id1 + fp->varindex[ _res_process_type ] ] == a ) + if ( reserved("process_type",id1) == a ) { - g1 = fp->mem[ id1 + fp->varindex[_loc_graph] ] ; - f1 = fp->mem[ id1 + fp->varindex[_loc_file] ] ; + g1 = local("graph",id1) ; + f1 = local("file",id1) ; if ( files[f1].existe == 0 || files[f1].mapa[g1].existe == 0 ) return -1 ; - r1.x = fp->mem[ id1 + fp->varindex[_loc_x] ] ; - r1.y = fp->mem[ id1 + fp->varindex[_loc_y] ] ; + r1.x = local("x",id1) ; + r1.y = local("y",id1) ; r1.w = files[f1].mapa[g1].Surface->w ; r1.h = files[f1].mapa[g1].Surface->h ; id2 = a ; - g2 = fp->mem[ id2 + fp->varindex[_loc_graph] ] ; + g2 = local("graph",id2) ; if ( files[f2].existe == 0 || files[f2].mapa[g2].existe == 0 ) return -1 ; - f2 = fp->mem[ id2 + fp->varindex[_loc_file] ] ; - r2.x = fp->mem[ id2 + fp->varindex[_loc_x] ] ; - r2.y = fp->mem[ id2 + fp->varindex[_loc_y] ] ; + f2 = local("file",id2) ; + r2.x = local("x",id2) ; + r2.y = local("y",id2) ; r2.w = files[f2].mapa[g2].Surface->w ; r2.h = files[f2].mapa[g1].Surface->h ; //Colision barata :P @@ -546,11 +546,11 @@ int eDIV_ADVANCE(FUNCTION_PARAMS) int a , id1 , x , y , angulo ; a = getparm() ; id1 = fp->procs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id ; - angulo = fp->mem[ id1 + fp->varindex[ _loc_angle ] ] ; + angulo = local("angle",id1) ; x = (int) ((double)a * cos( (angulo/1000) * PIOVER180 )) ; y = (int) ((double)a * sin( (angulo/1000) * PIOVER180 )) ; - fp->mem[ id1 + fp->varindex[ _loc_x ] ] += x; - fp->mem[ id1 + fp->varindex[ _loc_y ] ] += y ; + local("x",id1) += x; + local("y",id1) += y ; return 1 ; } @@ -564,8 +564,8 @@ int eDIV_XADVANCE(FUNCTION_PARAMS) angulo = a ; x = (int) ((double)b * cos( (angulo/1000) * PIOVER180 )) ; y = (int) ((double)b * sin( (angulo/1000) * PIOVER180 )) ; - fp->mem[ id1 + fp->varindex[ _loc_x ] ] += x ; - fp->mem[ id1 + fp->varindex[ _loc_y ] ] += y ; + local("x",id1) += x ; + local("y",id1) += y ; return 1 ; } @@ -933,14 +933,14 @@ int eDIV_OUT_REGION(FUNCTION_PARAMS2) r = getparm() ; id = getparm() ; - f = fp->mem[ id + fp->varindex[_loc_file] ] ; - g = fp->mem[ id + fp->varindex[_loc_graph] ] ; + f = local("file",id) ; + g = local("graph",id) ; if ( !files[f].existe || !files[f].mapa[g].existe ) return -1 ; - x = fp->mem[ id + fp->varindex[_loc_x] ] ; - y = fp->mem[ id + fp->varindex[_loc_y] ] ; + x = local("x",id) ; + y = local("y",id) ; if ( x < fp->regions[r].x + fp->regions[r].w && x + files[f].mapa[g].Surface->w > fp->regions[r].x && y < fp->regions[r].y + fp->regions[r].h && y + files[f].mapa[g].Surface->h > fp->regions[r].y ) @@ -1035,7 +1035,7 @@ int eDIV_MOVE_DRAW(FUNCTION_PARAMS2) SDL_SetAlpha( draws[id].Surface , SDL_SRCALPHA | SDL_RLEACCEL , 17 * (o) ) ; else if ( o == 15 ) - SDL_SetAlpha( draws[id].Surface , NULL , 255 ) ; + SDL_SetAlpha( draws[id].Surface , 0 , 255 ) ; return 1 ; } @@ -1089,6 +1089,8 @@ int eDIV_LOAD_FPG(FUNCTION_PARAMS2) //Uint8 r,g,b; SDL_Color p[256]; + // TODO: quitar printf's y exit's y poner fp->Runtime_Error() + archivo = getstrparm() ; printf("LOAD_FPG %s\n",archivo); @@ -1106,6 +1108,8 @@ int eDIV_LOAD_FPG(FUNCTION_PARAMS2) fread(&cabecera,1,sizeof(FPGHEADER),f); + // TODO: optimizar esto ligeramente (comprobar primero los bytes comunes y luego + // leer "pg","16","24","32") if(strcmp(cabecera.header,"fpg\x1A\x0D\x0A")) { if(strcmp(cabecera.header,"f16\x1A\x0D\x0A")) { if(strcmp(cabecera.header,"f24\x1A\x0D\x0A")) { @@ -1230,10 +1234,11 @@ int eDIV_GET_REAL_POINT(FUNCTION_PARAMS2) dy = getparm() ; dx = getparm() ; n = getparm() ; - f = fp->mem[ fp->procs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id + fp->varindex[_loc_file] ] ; - g = fp->mem[ fp->procs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id + fp->varindex[_loc_graph] ] ; - x = fp->mem[ fp->procs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id + fp->varindex[_loc_x] ] ; - y = fp->mem[ fp->procs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id + fp->varindex[_loc_y] ] ; + id = fp->procs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id; + f = local("file",id) ; + g = local("graph",id) ; + x = local("x",id) ; + y = local("y",id) ; if ( !files[f].existe || !files[f].mapa[g].existe ) return -1 ; @@ -1312,7 +1317,7 @@ void frame(FUNCTION_PARAMS2 ) SDL_BlitSurface( fondo , NULL , screen , NULL ) ; // Draws - z = fp->mem[ fp->varindex[_glo_draw_z] ] ; + z = global("draw_z"); for ( i = 0 ; i <= last_draw ; i++ ) { if ( draws[i].existe ) @@ -1341,12 +1346,12 @@ void frame(FUNCTION_PARAMS2 ) for ( i = 0 ; i < *fp->num_procs ; i++ ) { id = fp->procs_s[ fp->proc_orden[i] ].id ; - f = fp->mem[ id + fp->varindex[_loc_file] ]; - g = fp->mem[ id + fp->varindex[_loc_graph] ]; - r = fp->mem[ id + fp->varindex[_loc_region] ] ; - z = fp->mem[ id + fp->varindex[_loc_z] ] ; - dstrect.x = fp->mem[ id + fp->varindex[_loc_x] ] ; - dstrect.y = fp->mem[ id + fp->varindex[_loc_y] ] ; + f = local("file",id); + g = local("graph",id); + r = local("region",id); + z = local("z",id); + dstrect.x = local("x",id); + dstrect.y = local("y",id); dstrect.w = 0 ; dstrect.h = 0 ; if ( files[f].mapa[g].existe ) @@ -1357,10 +1362,10 @@ void frame(FUNCTION_PARAMS2 ) srcrect.h = files[f].mapa[g].Surface->h ; dstrect.x -= files[f].mapa[g].cpoint[0].x ; dstrect.y -= files[f].mapa[g].cpoint[0].y ; - if ( fp->mem[ id + fp->varindex[_loc_flags] ] & 4 ) + if ( local("flags",id) & 4 ) //SDL_SetAlpha(files[f].mapa[g].Surface, SDL_SRCALPHA , fp->mem[ id + fp->varindex[_loc_transparency] ] ) ; - if ( fp->mem[ id + fp->varindex[_loc_flags] ] & 8 ) { - trans = 255 - fp->mem[ id + fp->varindex[_loc_transparency] ] ; + if ( local("flags",id) & 8 ) { + trans = 255 - local("transparency",id); if(trans<0) trans=0; else if(trans>255) trans=255; } else diff --git a/ediv/src/dlls/input/input.c b/ediv/src/dlls/input/input.c index ba273ec..3fb938f 100644 --- a/ediv/src/dlls/input/input.c +++ b/ediv/src/dlls/input/input.c @@ -291,7 +291,7 @@ int eDiv_Key(FUNCTION_PARAMS) } //*************************** ENTRYPOINTS ********************************************** -void first_load() +void first_load(FUNCTION_PARAMS) { int i ; SDL_Init( SDL_INIT_EVENTTHREAD ) ; @@ -501,7 +501,7 @@ void first_load() } -void frame(int mem[], int * varindex, struct _procs_s *procs_s) +void frame(FUNCTION_PARAMS) { int numkeys ; diff --git a/ediv/src/dlls/input/input.vcproj b/ediv/src/dlls/input/input.vcproj index d65857d..d9c388e 100644 --- a/ediv/src/dlls/input/input.vcproj +++ b/ediv/src/dlls/input/input.vcproj @@ -153,9 +153,6 @@ - - #include -#include -#include +#include "math.h" #include "main.h" @@ -192,10 +191,10 @@ int eDiv_GetAngle(FUNCTION_PARAMS) int a = getparm() ; id1 = fp->procs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id ; id2 = a ; - x1 = fp->mem[ id1 + fp->varindex[ _loc_x ] ] ; - y1 = fp->mem[ id1 + fp->varindex[ _loc_y ] ] ; - x2 = fp->mem[ id2 + fp->varindex[ _loc_x ] ] ; - y2 = fp->mem[ id2 + fp->varindex[ _loc_y ] ] ; + x1 = local("x",id1) ; + y1 = local("y",id1) ; + x2 = local("x",id2) ; + y2 = local("y",id2) ; if ( (x2-x1) != 0 ) { a = atan( (double)((y2-y1) / (x2-x1)) ) / PIOVER180 ; @@ -218,10 +217,10 @@ int eDiv_GetDist(FUNCTION_PARAMS) int a = getparm() ; id1 = fp->procs_s[ fp->proc_orden[*fp->proceso_actual] ].id ; id2 = a ; - x1 = fp->mem[ id1 + fp->varindex[ _loc_x ] ] ; - y1 = fp->mem[ id1 + fp->varindex[ _loc_y ] ] ; - x2 = fp->mem[ id2 + fp->varindex[ _loc_x ] ] ; - y2 = fp->mem[ id2 + fp->varindex[ _loc_y ] ] ; + x1 = local("x",id1) ; + y1 = local("y",id1) ; + x2 = local("x",id2) ; + y2 = local("y",id2) ; a = sqrt( pow( x2-x1 , 2 ) + pow( y2-y1 , 2 ) ) ; return a ; } diff --git a/ediv/src/dlls/scroll/scroll.c b/ediv/src/dlls/scroll/scroll.c index bc53dc2..7f11351 100644 --- a/ediv/src/dlls/scroll/scroll.c +++ b/ediv/src/dlls/scroll/scroll.c @@ -2,7 +2,7 @@ #include #include -#include "../../shared/varindex.h" +//#include "../../shared/varindex.h" #include "scroll.h" diff --git a/ediv/src/dlls/scroll/scroll.vcproj b/ediv/src/dlls/scroll/scroll.vcproj index 891dca4..9478776 100644 --- a/ediv/src/dlls/scroll/scroll.vcproj +++ b/ediv/src/dlls/scroll/scroll.vcproj @@ -122,9 +122,6 @@ - - #include -#include "../../shared/varindex.h" +//#include "../../shared/varindex.h" #include "../../shared/edivfont.h" #include "text.h" @@ -200,7 +200,7 @@ int eDiv_WriteInt(FUNCTION_PARAMS) fichero = fopen("wrin.txt" , "w+") ; - fprintf( fichero , "valor: %i\n" , fp->varindex[_glo_fps] ) ; + fprintf( fichero , "valor: %i\n" , global("fps") ) ; fclose(fichero) ; _itoa( fp->mem[ textos[i].offset_var ] , texto2 , 10 ) ; diff --git a/ediv/src/dlls/text/text.vcproj b/ediv/src/dlls/text/text.vcproj index 2da528e..3abae87 100644 --- a/ediv/src/dlls/text/text.vcproj +++ b/ediv/src/dlls/text/text.vcproj @@ -156,9 +156,6 @@ - - #endif +#include #include #include "shared.h" #include "varindex.h" +#include "main.h" +/* struct _vars { tipo_t tipo; char* nombre; @@ -84,6 +87,7 @@ struct _vars { byte hash[NUM_INDEXED_VARS]; static int varptr[NUM_INDEXED_VARS]; +*/ int res_pos=0, loc_pos=0; @@ -92,10 +96,14 @@ byte index_inicializado=0; void inicializa_index() { - int i; - byte *c, h; +// int i; +// byte *c, h; - memset(varptr,0,NUM_INDEXED_VARS*4); + num_indexed_vars=0; + varindex=NULL; + index_inicializado=1; + +/* memset(varptr,0,NUM_INDEXED_VARS*4); for(i=0;i>7))^*c; #ifdef DEBUG_DLL - printf("-- Indexando %s \"%s\" (hash: %d) ptr=%d... ", - tipo==global?"global":tipo==reserved?"reserved":"local", + printf("-- Indexando %s \"%s\" (hash: %d) ptr=%d\n", + tipo==v_global?"global":tipo==v_reserved?"reserved":"local", nombre,h,ptr); #endif + if(varindex) { + varindex=(varindex_t*)realloc(varindex,sizeof(varindex_t)*(num_indexed_vars+1)); + } + else { + varindex=(varindex_t*)e_malloc(sizeof(varindex_t)*(num_indexed_vars+1)); + } + varindex[num_indexed_vars].hash=h; + varindex[num_indexed_vars].tipo=tipo; + varindex[num_indexed_vars].offset=ptr; + varindex[num_indexed_vars].nombre=strdup(nombre); + + num_indexed_vars++; + +/* #ifdef DEBUG_DLL + printf("id asignado: %d\n",num_indexed_vars); + #endif + i=(tipo==reserved)?res_pos:((tipo==local)?loc_pos:0); for(;ihash-bb->hash; +} + +void ordena_varindex() +{ + qsort(varindex,num_indexed_vars,sizeof(varindex_t),varindex_compara); +} + +/*void get_varptr(int** ptr, int* nptr) { *ptr=varptr; *nptr=NUM_INDEXED_VARS; } - +*/ diff --git a/ediv/src/shared/extern.h b/ediv/src/shared/extern.h index 09e4d6b..3f40c07 100644 --- a/ediv/src/shared/extern.h +++ b/ediv/src/shared/extern.h @@ -27,6 +27,7 @@ #include #include "main.h" +#include "varindex.h" #define MAX_EXTERN_FUNCS 0xFFFF // ¿Demasiado? #define MAX_EXTFUNC_PARMS 0xFF @@ -84,6 +85,9 @@ typedef int (TYPEOF_Dibuja)(SDL_Surface *, SDL_Rect , SDL_Rect , int , int ) ; 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 /////////// @@ -253,6 +257,7 @@ struct _fun_params{ TYPEOF_Call_Entrypoint *Call_Entrypoint ; TYPEOF_Runtime_Error *Runtime_Error ; TYPEOF_Critical_Error *Critical_Error ; + TYPEOF_GetVarOffset *GetVarOffset ; } fp ; diff --git a/ediv/src/shared/varindex.h b/ediv/src/shared/varindex.h index 1db2ad4..b6235e3 100644 --- a/ediv/src/shared/varindex.h +++ b/ediv/src/shared/varindex.h @@ -21,20 +21,38 @@ #ifndef __VARINDEX_H #define __VARINDEX_H -typedef enum { global, reserved, local } tipo_t; +typedef enum { v_global, v_reserved, v_local } tipo_t; /// PROTOTIPOS /// // compilador void inicializa_index(); void indexa_variable(tipo_t tipo, char* nombre, int ptr); -void get_varptr(int** ptr, int* nptr); +//void get_varptr(int** ptr, int* nptr); +void ordena_varindex(); +// stub +int GetVarOffset(tipo_t tipo, char* nombre); int num_indexed_vars; -int *varindex; -#define var(a) mem[varindex[a]] +typedef struct { + unsigned char hash; + tipo_t tipo; + char* nombre; + int offset; +} varindex_t; + +varindex_t* varindex; + +//#define var(a) mem[varindex[a]] + +#define global(nombre) mem[GetVarOffset(v_global,nombre)] +#define reserved(nombre,id) mem[(id)+GetVarOffset(v_reserved,nombre)] +#define local(nombre,id) mem[(id)+GetVarOffset(v_local,nombre)] +#define globalptr(nombre) GetVarOffset(v_global,nombre) +#define reservedptr(nombre) GetVarOffset(v_reserved,nombre) +#define localptr(nombre) GetVarOffset(v_local,nombre) /* ////////////////////////////// @@ -102,7 +120,7 @@ int *varindex; #define _glo_fps 45 */ -enum { +/*enum { ////////////////////////////// /// GLOBALES /// @@ -171,6 +189,6 @@ enum { ___last // por si acaso -}; +};*/ #endif // __VARINDEX_H \ No newline at end of file diff --git a/ediv/src/stub/inte.c b/ediv/src/stub/inte.c index 3bbcae9..6d76541 100644 --- a/ediv/src/stub/inte.c +++ b/ediv/src/stub/inte.c @@ -83,6 +83,7 @@ int ini_interprete() fp.existe.dibuja = 0 ; fp.Runtime_Error=error; fp.Critical_Error=critical_error; + fp.GetVarOffset=GetVarOffset; return 1 ; @@ -301,19 +302,19 @@ int proceso( int num ) retcode = 1 ; break ; case lcbp://30 - mem[procs_s[num_proc].id+var(_res_parameters)]=mem[imem++]; - mem[procs_s[num_proc].id+var(_res_param_offset)]=sp-mem[procs_s[num_proc].id+var(_res_parameters)]+1; + reserved("parameters",procs_s[num_proc].id)=mem[imem++]; + reserved("param_offset",procs_s[num_proc].id)=sp-reserved("parameters",procs_s[num_proc].id)+1; /**/procs_s[num_proc].num_params = mem[ imem-1 ] ; break; case lcpa://31 POR HACER #-# - mem[pila[sp--]]=pila[mem[procs_s[num_proc].id+var(_res_param_offset)]++]; + mem[pila[sp--]]=pila[reserved("param_offset",procs_s[num_proc].id)++]; break; case ltyp://32 procs_s[num_proc].id = mem[2] + ( num_proc * iloc_len ) ; if ( procs_s[num_proc].tipo != 0 ) critical_error(3); // redefinición del tipo de proceso procs_s[num_proc].tipo = mem[ imem++ ] ; - mem[ procs_s[num_proc].id + varindex[_res_process_type] ] = procs_s[num_proc].tipo ; + reserved("process_type",procs_s[num_proc].id) = procs_s[num_proc].tipo ; inicio_privadas=mem[6]; break ; case lpri://33 POR HACER diff --git a/ediv/src/stub/main.h b/ediv/src/stub/main.h index fab6d6e..8ab8238 100644 --- a/ediv/src/stub/main.h +++ b/ediv/src/stub/main.h @@ -85,7 +85,7 @@ int* lin; void error(int num, ...); // Mensaje de error no crítico (trazable) void critical_error(int num, ...); // Mensaje de error crítico -void stub_quit(); // Salir del stub +void stub_quit(void); // Salir del stub void* e_malloc(size_t size); // identico a malloc pero con errormsg utomático #endif /* __MAIN_H */ \ No newline at end of file diff --git a/ediv/src/stub/stub.c b/ediv/src/stub/stub.c index 53145f7..09999c8 100644 --- a/ediv/src/stub/stub.c +++ b/ediv/src/stub/stub.c @@ -57,6 +57,7 @@ int main(int argc, char* argv[]) FILE *file_tiempo ; byte * ptr; unsigned long len,len_descomp; + byte* vartemp; #ifdef DBG int start_lin; int linsize; @@ -160,27 +161,40 @@ int main(int argc, char* argv[]) //assert(0); read(f,&num_indexed_vars,4); + read(f,&len_descomp,4); read(f,&len,4); - len_descomp=num_indexed_vars*4; ptr=(byte*)e_malloc(len); read(f,ptr,len); - varindex=(int*)e_malloc(len_descomp); - if(uncompress((byte*)varindex,&len_descomp,ptr,len)) { + vartemp=(byte*)e_malloc(len_descomp); + if(uncompress(vartemp,&len_descomp,ptr,len)) { free(ptr); - free(varindex); + free(vartemp); close(f); critical_error(1); // error leyendo el código del programa } -// assert(0) ; - for(len=0;len + + @@ -176,6 +179,9 @@ + + jZ(o%s#Up2R9tZvl^vlK>WYerbleg> z7!Gz{&UJ_q}=Z=1u3Dnb*h*5g8KCYL%?H zMD!~bi)AKeDQ7{>207fQIQsXfW)~I(fFGEgB3&C)){Cg2J|%Z(WN=sAE0Kh)a+lU= z2naO=vIW3RjNcmac-)vP8hMV%Wov@k2INoNz4=>YAgBXkmSE@-2@)P(g3Xb-^EjtLe!wT_t^1iwx#G#X)A zrF~8ANn)#7ZZpyh5`t(D>gRy?ZHi-N7BnVMCRb5Qjcq|Pw)W$2=>V(yiD&G^JtsE9slPc0)tJmd~r$Rv&1&Du9xmq843M{3BJ56u97 zP2HfTLy|H6&1Os57FFg@D&&wU*2dG`I8<2#>jYD6eDOxb00psizL(40pDSAsfK16D zgd+XQPsMl0kw&JZQGqC9v22Bs>K{pW`grK1@G#cW7K6Jyw>U5-S=4d1ceg8XCTH3+ z^o9HUK@sM6_IW(!$;kSXrCO>(7LQW{!m3B^nrIp6e!CNX^QQ2729cZv=fHVz0bB$< z;1akDu7F-}6dp;4Wc;cMLt_W2=t-$@Ri1auTaM!MIYP zvvHwf(6BK^;ks}|h$~zeftqFv%5Tn%Z)C#D9(|n!zX3m}0nZSw&yb-TDmG)yq zv=a)2(jzhh@_0mtdG}=Pv*kd~1*||GkPn;!Y=9j&2`qY=L{Rm`yKJxL3ftd`DA*`Z zyRJ3}gA8f}m6F%gY~IpkiU21^Ta7nimM&S6#GKX~eO1i1RW0f3g(D4~ak@yu)JFr< zLteT@9pt1E>VhW`kiK5r=^%%+X%n%H!XSH;`Tyk8=|F0=?YKKp9%$4_-84wW)DLY0 z0WLufk&ng@N+uflj~C+35PnspBb9{sJp%_~*?28JDYgb$8;~VgFyVsnOB`4avh*V= zk>A2UOVjNo(&~l14->haf&LM}u0OWz2M;(j+YO?#Q}P6(AJjQ;4`Fg#VY@5URd z80Co+zb+dVJ8!2nvOBSeM^jr3vPaplJaWj|R_ezjLjtUFPJ32clM*c0U~^jHlEtU+ zQieIE{e#R+yk&YX`Y`C8@Q8KcL4wGWO3_gd1nLNdaugE2sqg|x&w_;}SHUs# z@Yy6k6=4M&yms2jD|Loott(i%s*i_vugy|};38FJckK^eNpi8LwuUDv&vC+eeT)}x zK1_o=>FCP&D|7AvnU^Yb!Wya0dcd7v5WWTlzsoeHR3``WM}c)HBRGiA<0fq~Drn0^6Z Cb2u&l diff --git a/ediv/src/visual c/stub/stub.vcproj b/ediv/src/visual c/stub/stub.vcproj index 79dbc73..97ee65b 100644 --- a/ediv/src/visual c/stub/stub.vcproj +++ b/ediv/src/visual c/stub/stub.vcproj @@ -237,6 +237,9 @@ makelib.bat win32.dbg + +