Bennu Game Development

English Forums => Documentation => Topic started by: handsource-dyko on March 16, 2012, 03:08:22 PM

Title: new articles on the wiki
Post by: handsource-dyko on March 16, 2012, 03:08:22 PM
As suggested by DoctorN, I decided to create new topic for this.

Currently I'm working on mod_map, and have added/modified so far:

- pcx_load
- bdf_load
- get_rgb  / get_rgba (needs checking for correctness)
- rgb / rgba (extra optional "depth" parameter  as once desired by Sandman in this topic: http://forum.bennugd.org/index.php?topic=312.msg3622#msg3622 (http://forum.bennugd.org/index.php?topic=312.msg3622#msg3622), modified article needs checking by Spliter or other expert)

- graphic_set (is the same thing as map_info_set)
- map_info / map_info_get
- map_buffer


I have a lot of trouble with fnt_new. It doesn't seem to work for me: http://forum.bennugd.org/index.php?topic=3012.0 (http://forum.bennugd.org/index.php?topic=3012.0). Some more comments in bennu's own sourcecode would be helpfull in general.  ;D ;)

I might have found a bug in get_colors() and set_colors().  Both functions crash bennu when I try to use them. The bennupack example in 2 Medium\fenix test\Fenix Test3\test_GET_COLORS.prg  (and test_set_colors.prg) do not run sucessfully. They seem to crash.

I've looked in the bennu souce  modules/libgrbase/g_pal.c and found this in the functions pal_get() and pal_set():
in pal_get()


539     *pal++ = spal->rgb[ color ].r ;
540     *pal++ = spal->rgb[ color ].g ;
541     *pal++ = spal->rgb[ color++ ].b ;


in pal_set()


561     spal->rgb[ color ].r = *pal++ ;
562     spal->rgb[ color ].g = *pal++ ;
563     spal->rgb[ color++ ].b = *pal++ ;


the lines 541 and 563 seem a bit odd :-\ . Why whould have to different from 540, 541, 561 and 562? Maybe the cause of the problem? I've searched on the spanish section and there was some problem mentioned: http://forum.bennugd.org/index.php?topic=464.msg6025#msg6025 (http://forum.bennugd.org/index.php?topic=464.msg6025#msg6025). Maybe the bug is still around?

Title: Re:new articles on the wiki
Post by: SplinterGU on March 16, 2012, 10:32:27 PM
code sample... please.
Title: Re:new articles on the wiki
Post by: handsource-dyko on March 17, 2012, 12:39:11 PM
Spliter, here's the code that crashes. It is an reworked fenix test sample from bennupack, that I tydied up for the wiki:


IMPORT "mod_say";
IMPORT "mod_debug";
IMPORT "mod_key";
IMPORT "mod_map";
IMPORT "mod_video";
IMPORT "mod_wm";
IMPORT "mod_draw";
IMPORT "mod_screen";
IMPORT "mod_text";
IMPORT "mod_timers";


GLOBAL

  STRUCT original_palette[255];
    byte r;
    byte g;
    byte b;
  END
 
  STRUCT new_palette[255];
    byte r;
    byte g;
    byte b;
  END
 
  int count;
  int set_palette;
  int color_index_number;

  int status;
 
PROCESS main();

BEGIN

   write(0,10,10,3,"Test GET_COLORS para Fenix...");
   write(0,160,35,4,"Get Colors Paleta...");
   write(0,160,190,4,"Pulsa ESC para Salir...");
 
   x=160;
   y=115;
 
   graph=new_map(16,16,8);
   size=800;
 
   FOR (count=0; count<256; count++)
      new_palette[count].r=0;
      new_palette[count].g=count;
      new_palette[count].b=0;
      say("count: "+count);
   END

   
   say("status: "+status);
   status=get_colors(0,256,&original_palette); // it crashes here
   say("status: "+status);

   say("status: "+status);
   status=set_colors(0,256,&new_palette); // this one too, same thing, it crashes
   say("status: "+status);

   draw_palette();
   
   LOOP
   
      IF (key(_esc))
         BREAK;
      END
     
      IF (key(_enter) AND set_palette==0)
         FRAME(100);
         set_colors(0,256,&original_palette);
         set_palette=1;
      END
     
      IF (key(_enter) AND set_palette==1)
         FRAME(100);
         set_colors(0,256,&new_palette);
         set_palette=0;
      END
     
      FRAME;     
   END

   timer[0]=0;
 
   REPEAT
 
      IF (timer[0]>=300 AND NOT set_palette)
         set_colors(0,256,&original_palette);
         set_palette=1;
         timer[0]=0;
      END
   
      IF (timer[0]>=300 AND set_palette)
         set_colors(0,256,&new_palette);
         set_palette=0;
         timer[0]=0;
      END
   
      FRAME;
   UNTIL(key(_esc))

END // end of main program



PROCESS draw_palette();

BEGIN

   say("drawing palette");
   color_index_number=0;
   
   FROM y=0 TO 15;
 
      FROM x=0 TO 15;
         map_put_pixel(0,father.graph,x,y,color_index_number);
         color_index_number++;
         say("color_index_number"+color_index_number);
      END
   
   END
 
END



It seems that both set_colors and get_colors crash, and I think it has something to do with line 541 and line 563 in g_pal.c, but that's just out curiousity when I looked for the paramters of the function, and I wondered why these two lines are different.
Title: Re:new articles on the wiki
Post by: SplinterGU on March 17, 2012, 04:57:08 PM
fixed, thanks!
Title: Re:new articles on the wiki
Post by: handsource-dyko on March 17, 2012, 05:00:21 PM
Ok! :)

I added most of the palette functions to the wiki (thanks to bomerlink for those good examples in bennupack).
These are still to be added:

- convert_palette()
- roll_palette()
- pal_sys_set()

The rest of the palette functions are done!
Title: Re:new articles on the wiki
Post by: MisterN on March 17, 2012, 07:28:08 PM
I just sent you an email about text's
Title: Re:new articles on the wiki
Post by: handsource-dyko on March 18, 2012, 01:53:54 PM
Added roll_palette(), convert_palette() and fixed fnt_new() (with example). I would like to be able to upload images to the wiki for certain articles.

Still trying to figure out what pal_sys_set() does. It looks like pal_refresh() but doesn't seem to behave the same way. If anybody knows exactly, please let me know. The function is mysterious and I don't think it really necessary in most cases.
Title: Re:new articles on the wiki
Post by: handsource-dyko on March 19, 2012, 02:45:46 PM
get_colors()
set_colors()

sound_init()
sound_close()

have been added, but need checking. I'm unsure of some things. I think that get_colors and set_colors are the same as pal_get and pal_set, but with a few small differences I cannot really pinpoint.

Still to do:

- background loader functions (can wait untill later)
- joy_get_accell (cannoo specific???)
- pal_sys_set

Besides these things I consider it pretty much done for now, untill new functions and features are made. If you have find an error somewhere, you can change it.
Title: Re:new articles on the wiki
Post by: MisterN on March 25, 2012, 02:03:28 AM
I think that this is truly what bennugd needs because people like me only know so much and we get all this stuff to study from once it comes out XD
Title: Re:new articles on the wiki
Post by: handsource-dyko on March 25, 2012, 10:23:54 AM
It would be nice if Sandman were to show up again. He knows a lot about the internals. I looked in bennu's source code for most of the stuff. But it's not not easy you if only know a few small things about C. I've got a book about C that I read a lot, so I understand the basics although I don't write C programs myself (c compilers and make files are insanely complicated  ;D ).  Some functions are easier to document then others, because some are mapped to standard C functions and the sound stuff I could find in SDL articles. But what I don't understand is why the code itself is so sparse on internal documentation (function body's with explaination of what each function does, and what arguments it expects ??? ). It is so cryptic sometimes! :( Well it helps that I still have my DIV manual and documentation wich made it easier to do certain articles. Especially the scroll and mode7 stuff, I can imagine it's a bit mysterious if you don't have examples.
Title: Re:new articles on the wiki
Post by: l1nk3rn3l on March 25, 2012, 12:38:54 PM
thx for you work.. wiki now is more big..
Title: Re:new articles on the wiki
Post by: handsource-dyko on March 25, 2012, 12:48:37 PM
Of course before I forget, the samples in bennu pack are a great resource, too. I used and converted some of them for the examples by the articles on the wiki. ;) This also why some palette functions are now fixed, simply because I tested an old fenix test sample with bennu, and it didn't work, but now it does with the latest version.  :) (This is what they call regression testing). And I wouldn't have figured out the working of the pathfinding functions if it wasn't for TYCO's example. It really helped me out.
Title: Re:new articles on the wiki
Post by: handsource-dyko on March 26, 2012, 02:39:24 PM
Updates completed:

- now if set_mode fail return -1, else return 0 <DONE>/UPDATED


- Add new functions <DONE>/UPDATED
WRITE* (fontid, x, y, z, alignm, ...)      <DONE>/UPDATED
WRITE_int (fontid, x, y, z, alignm, ...)   <DONE>/UPDATED
WRITE_string (fontid, x, y, z, alignm, ...)<DONE>/UPDATED
WRITE_var (fontid, x, y, z, alignm, ...)   <DONE>/UPDATED
WRITE_float (fontid, x, y, z, alignm, ...) <DONE>/UPDATED
SET_TEXT_COLOR(textid, color)              <DONE>/UPDATED
GET_TEXT_COLOR(textid)                     <DONE>/UPDATED
MOVE_TEXT(textid, x, y, z)                 <DONE>/UPDATED

- add new backgound load functions <DONE>
LOAD_MAP(filename, &id) <DONE>
LOAD_PNG(filename, &id) <DONE>
LOAD_PCX(filename, &id) <DONE>
LOAD_FPG(filename, &id) <DONE>/MODIFIED
LOAD_SONG(filename, &id)<DONE>
LOAD_WAV(filename, &id) <DONE>
LOAD_PAL(filename, &id) <DONE>
LOAD_FNT(filename, &id) <DONE>
LOAD_BDF(filename, &id) <DONE>
MAP_LOAD(filename, &id) <DONE>
PNG_LOAD(filename, &id) <DONE>
PCX_LOAD(filename, &id) <DONE>
FPG_LOAD(filename, &id) <DONE>/MODIFIED
SONG_LOAD(filename, &id)<DONE>
WAV_LOAD(filename, &id) <DONE>
PAL_LOAD(filename, &id) <DONE>
FNT_LOAD(filename, &id) <DONE>
BDF_LOAD(filename, &id) <DONE>

With most of these updates I added a note that the "modifications" apply to version rc282 and newer, so that people that use older versions don't get confused.
Title: Re:new articles on the wiki
Post by: gecko on March 26, 2012, 11:50:17 PM
a big karma for you! :)
Title: Re:new articles on the wiki
Post by: handsource-dyko on March 27, 2012, 08:41:51 AM
Thanks! :)
Title: Re:new articles on the wiki
Post by: josebita on March 28, 2012, 11:19:54 PM
Guy, you're awesome! Thanks :)
Title: Re:new articles on the wiki
Post by: SplinterGU on March 29, 2012, 03:47:30 AM
karma!
Title: Re:new articles on the wiki
Post by: Kloppix on July 22, 2012, 05:33:17 PM
Handsource-dyko, thank you for your wonderful work keeping the wiki updated :) There are still a couple of missing functions. Could you (or anybody) please help? Are the last ones.

in mod_flic is missing:
INT FLI_END(INTEGER) Which apparently is not the same as END_FLI()
INT FLI_FRAME(INTEGER) Which apparently is not the same as FRAME_FLI()
INT FLI_RESET(INTEGER) Which apparently is not the same as RESET_FLI()

Besides, the wiki says joy_getball has 2 or 3 arguments...
INT joy_getball ( [ <INT JoyID> ] , <POINTER dx> , <POINTER dy>)

...instead 3 or 4
FUNC( "JOY_GETBALL" , "IPP" , TYPE_INT , modjoy_get_ball ),
FUNC( "JOY_GETBALL" , "IIPP" , TYPE_INT , modjoy_get_ball_specific ),

Lastly, did you finally figured out what pal_sys_set() and joy_getaccel() does?
Title: Re:new articles on the wiki
Post by: handsource-dyko on July 23, 2012, 07:06:43 AM
Mmm.... That's strange with the Fli functions. Are they really different? From what I've understood from bennu's source the functions you mention seem aliases to me. Anyway I'll have a look.

About the joy get ball / get acecel functions, I believe they are caannoo specific. I can't test those because I don't have one, I only have digital joysticks for my pc.

Pal_sys_set is still a bit of a mistery to me unfortunatly.
Title: Re:new articles on the wiki
Post by: DCelso on July 23, 2012, 02:40:33 PM
Great job. karma++++.

Title: Re:new articles on the wiki
Post by: handsource-dyko on July 23, 2012, 02:45:37 PM
Regarding the differences with the fli functions, Isn't it because you normally can only have one active fli animation?
I've just looked at end_fli() and now I come to think of it, end_fli(interger) is probably a variation of the same function, but in this case to allow
more then one fli animation. Where the argument is the id of the fli. At least that's what I'm thinking about at the moment.
Title: Re:new articles on the wiki
Post by: SplinterGU on July 23, 2012, 03:00:27 PM
alias.
Title: Re:new articles on the wiki
Post by: Kloppix on July 23, 2012, 04:14:19 PM
This is why I said they are not the same.

FUNC( "END_FLI"         , ""            , TYPE_INT , modflic_end          ),
FUNC( "FLI_END"         , "I"           , TYPE_INT , modflic_endx         ),

FUNC( "FRAME_FLI"       , ""            , TYPE_INT , modflic_frame        ),
FUNC( "FLI_FRAME"       , "I"           , TYPE_INT , modflic_framex       ),

FUNC( "RESET_FLI"       , ""            , TYPE_INT , modflic_reset        ),
FUNC( "FLI_RESET"       , "I"           , TYPE_INT , modflic_resetx       ),

For example fli_end() without arguments doesn't even compile
      Incorrect number of parameters. Function: FLI_END MinParams: 1.

and the same with end_fli with arguments
      Incorrect number of parameters. Function: END_FLI MinParams: 0.

I know you guys already told me it's just an alias, but I don't get it :(
(sorry to be a pain)
Title: Re:new articles on the wiki
Post by: handsource-dyko on July 23, 2012, 05:29:14 PM
 :-\ That's weird. But still, are there two different variants in terms of functionality? Like with mode 7 and scrolls there exist two versions, a simple one and a more sophisticated variant where the scroll or the mode 7 can blitted on a map.
Title: Re:new articles on the wiki
Post by: SplinterGU on July 23, 2012, 11:30:23 PM
no weird...

all new functions have a prefix that depend their belonging group... MAP_* map functions, PAL_* palette functions, FPG_* fpg functions, etc.

FLI_* are new functions... new functions return/work with an identifier... FLI_START return an identifier that is used as input in all other functions.
Title: Re:new articles on the wiki
Post by: handsource-dyko on July 24, 2012, 07:18:33 AM
Ooook. So it's still only one fli animation instance?
Title: Re:new articles on the wiki
Post by: Kloppix on July 24, 2012, 08:09:10 AM
Understood :) So, while Start_fli only returns if it was successfull,  Fli_start returns a "fliID", used for all fli_*functions. I'm going to uptade the wiki today.

Quote from: handsource-dyko on July 24, 2012, 07:18:33 AM
Ooook. So it's still only one fli animation instance?

No  ;D I just tested it and unlike Start_fli, Fli_start can be used to start several animations. Then you can stop them individually using the flicID. 

Splinter, sos groso, sabelo.

I think there is a bug or something, though.  Short after stopping the animation I get always  " *** glibc detected *** borrar: double free or corruption (!prev): 0x089541d8 *** "

btw
Quote from: handsource-dyko on July 23, 2012, 05:29:14 PMLike with mode 7 and scrolls there exist two versions, a simple one and a more sophisticated variant where the scroll or the mode 7 can blitted on a map.

It seems are they the same thing now, although following the new "standard" only the MODE7_* ones should be used.
    FUNC( "MODE7_START" , "IIIIIIII"    , TYPE_INT , modm7_start2 ),
    FUNC( "START_MODE7" , "IIIIIIII"    , TYPE_INT , modm7_start2 ),

    FUNC( "MODE7_START" , "IIIIII"      , TYPE_INT , modm7_start  ),
    FUNC( "START_MODE7" , "IIIIII"      , TYPE_INT , modm7_start  ), 

    FUNC( "MODE7_STOP"  , "I"           , TYPE_INT , modm7_stop   ),
    FUNC( "STOP_MODE7"  , "I"           , TYPE_INT , modm7_stop   ),



Title: Re:new articles on the wiki
Post by: handsource-dyko on July 24, 2012, 09:03:49 AM
 :) Great. So you can have more then one fli animation. That must be new improvement.
O, I found out how Sandman added images to wiki articles. It seems they cannot be uploaded, but he (deep) links an image that stored on another server. I simply looked at one of his articles to see how he did that, and now my file dialog tutorial has an screenshot. My picasa album is almost full, and my webhost (woelmuis) doesn't allow deeplinking of images.

I wonder if it technically possible in media wiki to create an image upload (like in the forum) so that it's easier to add images (or other content like fpg's, sounds, etc) to articles. That would be conveint for tutorials.
Title: Re:new articles on the wiki
Post by: Kloppix on July 24, 2012, 09:25:48 AM
Well, there is an "upload file" link under "Toolbar". But you must be logged in.
Title: Re:new articles on the wiki
Post by: Kloppix on July 27, 2012, 01:18:50 PM
 Handsource-dyko, 2 days ago I realized fileinfo had 2 undocumented members: fileinfo.accessed & fileinfo.statechg. Maybe you'll find this useful for your tutorial. I added them in http://wiki.bennugd.org/index.php?title=Fileinfo with a short description. My English is not the best, so feel free to correct it :P
Title: Re:new articles on the wiki
Post by: handsource-dyko on July 27, 2012, 03:10:03 PM
Ok. I looks fine to me.
Title: Re:new articles on the wiki
Post by: SplinterGU on July 27, 2012, 03:32:14 PM
Quote from: Kloppix on July 24, 2012, 08:09:10 AM
Understood :) So, while Start_fli only returns if it was successfull,  Fli_start returns a "fliID", used for all fli_*functions. I'm going to uptade the wiki today.

Quote from: handsource-dyko on July 24, 2012, 07:18:33 AM
Ooook. So it's still only one fli animation instance?

No  ;D I just tested it and unlike Start_fli, Fli_start can be used to start several animations. Then you can stop them individually using the flicID. 

Splinter, sos groso, sabelo.

I think there is a bug or something, though.  Short after stopping the animation I get always  " *** glibc detected *** borrar: double free or corruption (!prev): 0x089541d8 *** "

btw
Quote from: handsource-dyko on July 23, 2012, 05:29:14 PMLike with mode 7 and scrolls there exist two versions, a simple one and a more sophisticated variant where the scroll or the mode 7 can blitted on a map.

It seems are they the same thing now, although following the new "standard" only the MODE7_* ones should be used.
    FUNC( "MODE7_START" , "IIIIIIII"    , TYPE_INT , modm7_start2 ),
    FUNC( "START_MODE7" , "IIIIIIII"    , TYPE_INT , modm7_start2 ),

    FUNC( "MODE7_START" , "IIIIII"      , TYPE_INT , modm7_start  ),
    FUNC( "START_MODE7" , "IIIIII"      , TYPE_INT , modm7_start  ), 

    FUNC( "MODE7_STOP"  , "I"           , TYPE_INT , modm7_stop   ),
    FUNC( "STOP_MODE7"  , "I"           , TYPE_INT , modm7_stop   ),





can you send me the sample that you have this glibc errors?
Title: Re:new articles on the wiki
Post by: Kloppix on July 27, 2012, 07:15:01 PM
It was with the example I put in http://wiki.bennugd.org/index.php?title=Fli_end, but better check your e-mail.
Title: Re:new articles on the wiki
Post by: SplinterGU on July 27, 2012, 07:36:55 PM
thanks!
Title: Re:new articles on the wiki
Post by: SplinterGU on July 28, 2012, 02:48:48 AM
Quote from: Kloppix on July 27, 2012, 07:15:01 PM
It was with the example I put in http://wiki.bennugd.org/index.php?title=Fli_end, but better check your e-mail.

hehehe, sure that it will crash... you are free it twice...

right code


Import "mod_video";
Import "mod_key";
Import "mod_flic";

private
  int iAnimation1;
end

begin
  set_mode(640,480,32);
  iAnimation1=Fli_start("lata.flc",50,50);
  //iAnimation1=Fli_start("SPFXDEMO.FLI",50,50);

  while(! key(_esc))
    if(key(_s))Fli_end(iAnimation1);iAnimation1=null;end
    frame;
  end
end
Title: Re:new articles on the wiki
Post by: Kloppix on July 28, 2012, 07:44:08 AM
 I never would have imagined that you have to assign NULL to the Fli_ID after Fli_End! I'm adding this to the Wiki as well.
Title: Re:new articles on the wiki
Post by: DCelso on July 31, 2012, 02:05:05 PM
Quote from: Kloppix on July 28, 2012, 07:44:08 AM
I never would have imagined that you have to assign NULL to the Fli_ID after Fli_End! I'm adding this to the Wiki as well.
Kloppix it is not neccesary. It is a cheat to evade to free more that one time your fli object. So your  explanation in the wiki pages is not correct.
In this code when you press the key "s" the loop while runs the instructions of key "s" several times, because is a loop and you are not using a "on key press method" only are using "is quey pressed" method.
try this another code to understand it.

begin
  set_mode(640,480,32);
  iAnimation1=Fli_start("lata.flc",50,50);
  //iAnimation1=Fli_start("SPFXDEMO.FLI",50,50);

  while(! key(_esc))
    if(key(_s))
           while (key(_s)) frame; end;  // loop to wait to release the key s.
           Fli_end(iAnimation1);           
     end
    frame;
  end
end

Or this other one

begin
  set_mode(640,480,32);
  iAnimation1=Fli_start("lata.flc",50,50);
  //iAnimation1=Fli_start("SPFXDEMO.FLI",50,50);
   frame;
     Fli_end(iAnimation1);           
   frame;
end


So,  only use if(key(_s)) is not enough to do things that you need run once.

Title: Re:new articles on the wiki
Post by: SplinterGU on July 31, 2012, 02:49:16 PM
DCelso, quizas deberiamos hablar en castellano, porque parece que se pierde info de lo que se quiere decir.

el ejemplo de kloppix no esta mal... lo que pasa es que simplemente llama muchas veces a la funcion fli_stop, necesita algun control para no hacerlo tantas veces o simplemente setear el indentificador a NULL para que si entra nuevamente en la funcion, el control interno que tiene la funcion haga que no se realice ninguna operacion al respecto.
Title: Re:new articles on the wiki
Post by: Kloppix on July 31, 2012, 03:26:37 PM
Bueno, en realidad ese ejemplo no es el de la Wiki sino un ejemplo que le envié a Splinter. Aunque en la Wiki tenía la misma confusión.

Ahora si entendí por que se le asigna NULL. Voy a hacer unas pruebas y corrigo el código (es el mismo para fli- *start,*frame, *end y *reset). También tengo que corregir entonces una parte de la descripción. Muchas gracias DCelso y feliz cumpleaños! Ví que cumpliste este mes antes de resucitar :P
Title: Re:new articles on the wiki
Post by: SplinterGU on July 31, 2012, 04:56:03 PM
kloppix no es necesario que lo pongas a NULL, pero si es necesario que el identificador que le pases a las funciones sea un identificador valido, si ya lo cerraste, como si tambien le mandas verdura, vas a obtener un crash... por eso al ponerle NULL estas diciendo que no esta inicializado y el control interno pasa.

podria haber hecho otro metodo y buscar los identificadores en una tabla interna, pero esto seria muy poco performante... aunque probablemente cambie todo el sistema donde devuelven punteros por otra cosa interna mas segura... eso posiblemente lo haga cuando prepare la version 64bits.
Title: Re:new articles on the wiki
Post by: Kloppix on July 31, 2012, 05:14:02 PM
Splinter, tras la explicación de DCelso entendí lo que me escribiste por email perfectamente :)

Creo que para evitar futuros dolores de cabeza, debería ser costumbre resetear el identificador tras Fli_end(). Lo puse como recomendación en la Wiki. http://wiki.bennugd.org/index.php?title=Fli_end Cualquier error, incluyendo el código, háganlo saber.
Title: Re:new articles on the wiki
Post by: SplinterGU on July 31, 2012, 05:18:18 PM
no solo con fli, con toda variable donde guardamos id de mapas, archivos, identificadores de procesos, etc.
Title: Re:new articles on the wiki
Post by: DCelso on July 31, 2012, 07:18:07 PM
Exactisimo todo lo que dijiste SplinterGU. Es justo lo que puse en mi post en inglés, quizás en un inglés paupérrimo como indicas, pero mi intención era la de aclarar las cosas para tener la documentación lo más fiel posible. Quizás no te haya gustado que puse la palabra cheat a lo de hacer el null, y no es la adecuada, quería simplemente decir eso mismo que dices tu, que ponerla a justo después del end es un "truco" para hacer que no vuelva a llamarse a fil_end con el id anterior y así la función fli_end no intente volver a liberar el recurso y puse un ejemplo de como resolver el error sin necesidad de hacer null, por lo que reitero que todo lo que dijiste es cierto, quien va a saber más de esto que tú :D.
Title: Re:new articles on the wiki
Post by: DCelso on July 31, 2012, 07:23:10 PM
Quote from: SplinterGU on July 31, 2012, 04:56:03 PM
.. podria haber hecho otro metodo y buscar los identificadores en una tabla interna, pero esto seria muy poco performante... aunque probablemente cambie todo el sistema donde devuelven punteros por otra cosa interna mas segura... eso posiblemente lo haga cuando prepare la version 64bits.
Totalmente de acuerdo, es una pérdida de rendimiento, tal como está va de lujo, además no siempre le vamos a poner las cosas mascadas al programador ¿no? :D
Title: Re:new articles on the wiki
Post by: MisterN on July 31, 2012, 08:41:52 PM
Gee, I dont understand english, and this is the english board.
Title: Re:new articles on the wiki
Post by: SplinterGU on July 31, 2012, 08:54:58 PM
Quote from: DCelso on July 31, 2012, 07:18:07 PM
Exactisimo todo lo que dijiste SplinterGU. Es justo lo que puse en mi post en inglés, quizás en un inglés paupérrimo como indicas, pero mi intención era la de aclarar las cosas para tener la documentación lo más fiel posible. Quizás no te haya gustado que puse la palabra cheat a lo de hacer el null, y no es la adecuada, quería simplemente decir eso mismo que dices tu, que ponerla a justo después del end es un "truco" para hacer que no vuelva a llamarse a fil_end con el id anterior y así la función fli_end no intente volver a liberar el recurso y puse un ejemplo de como resolver el error sin necesidad de hacer null, por lo que reitero que todo lo que dijiste es cierto, quien va a saber más de esto que tú :D.

por favor, faltaba mas... no me ha disgustado, simplemente que me parecio que en castellano nos ibamos a entender mejor.
Title: Re:new articles on the wiki
Post by: SplinterGU on July 31, 2012, 08:58:54 PM
Quote from: DoctorN on July 31, 2012, 08:41:52 PM
Gee, I dont understand english, and this is the english board.

don't worry about it, sure kloppix will explain it in the wiki...

please, you don't need remember us that this forum is an english forum... if we need change language for a better understanding of this stuff, then we'll do... or you prefer learn a bad understanding of this stuff because our bad english?
Title: Re:new articles on the wiki
Post by: Kloppix on August 01, 2012, 09:07:48 AM
 
Quote from: SplinterGU on July 31, 2012, 05:18:18 PM
Quote from: Kloppix on July 31, 2012, 05:14:02 PMCreo que para evitar futuros dolores de cabeza, debería ser costumbre resetear el identificador tras Fli_end(). Lo puse como recomendación en la Wiki.
no solo con fli, con toda variable donde guardamos id de mapas, archivos, identificadores de procesos, etc.
Me da mucha verguenza, pero nunca llegué a resetear un handle. Probablemente porque núnca tuve un error similar. Como no creo ser el único novato en Bennu, voy a dejar la recomendación hasta que nos lo des "todo mascado" en la futura versión :)


Quote from: DoctorN on July 31, 2012, 08:41:52 PMGee, I dont understand english, and this is the english board.

Sorry dude. I had a crash using something like this inside a loop:


if(key(_1))   
    fli_end(iAnimation1); 
end


The problem was fli_end(iAnimation); doesn't reset iAnimation, only frees it. That means iAnimation still contains a memory address (now invalid). Beeing inside a loop, fli_end(iAnimation) was executed for a second time and caused the program to crash. Therefore DCelso suggested addind  while (key(_1))  frame;  end; to prevent it...


if(key(_1))
        while (key(_1)) frame; end;    
        fli_end(iAnimation1); 
end


...and Splinter suggested reseting it by adding iAnimation1=null;


if(key(_1))
    fli_end(iAnimation1); 
    iAnimation1=null;
end


Although DCelso's solution works, the danger is still there. Therefore I recomended in the Wiki to reset the Fli_ID after using Fli_end.


And then Splinter said he wanted to make a new and safer internal system. Probably when the x64 version get released.
Title: Re:new articles on the wiki
Post by: SplinterGU on August 01, 2012, 01:07:44 PM
Really your right code must be...

if(iAnimation1 and key(_1))
    fli_end(iAnimation1);
    iAnimation1=null;
end
Title: Re:new articles on the wiki
Post by: Kloppix on August 01, 2012, 01:33:28 PM
Quote from: SplinterGU on August 01, 2012, 01:07:44 PM
Really your right code must be...

if(iAnimation1 and key(_1))
    fli_end(iAnimation1);
    iAnimation1=null;
end

I was just explaining the mistake  :P In the wiki I used something like that.  1 starts/stops one animation and 2 starts/stops the another one. So this is what I done:

    if(key(_1))
      //Do nothing until the key is released
      while(key(_1))frame; end
      if(iAnimation1!=null)    //If the animation wasn't terminated...
        fli_end(iAnimation1);  //...stop only the simple animation...
        iAnimation1=null;      //...and reset the handle
      else
        iAnimation1=fli_start("animation.fli",50,80);
      end
    end

The complete code is in http://wiki.bennugd.org/index.php?title=Fli_end (http://wiki.bennugd.org/index.php?title=Fli_end) Please take a look, as I'm using the same example for 4 functions.
Title: Re:new articles on the wiki
Post by: SplinterGU on August 01, 2012, 02:08:26 PM
very good!