new articles on the wiki

Started by handsource-dyko, March 16, 2012, 03:08:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

handsource-dyko

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, 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. 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. Maybe the bug is still around?


SplinterGU

Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

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.

SplinterGU

Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

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!

MisterN

I just sent you an email about text's
werg

handsource-dyko

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.

handsource-dyko

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.

MisterN

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
werg

handsource-dyko

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.

l1nk3rn3l

thx for you work.. wiki now is more big..

handsource-dyko

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.

handsource-dyko

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.

gecko

Torres Baldi Studio
http://torresbaldi.com

handsource-dyko