Re: [AD] Another GFX_SAFE patch, now the demo

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Grzegorz Adam Hankiewicz <gradha@xxxxxxxxxx> wrote:
> 
> Here's a patch which makes the Allegro demo game work on any color depth.

I was reading the patch, and just thought that this was much too
much work to be doing just to load the graphics.  `demo.c' is
already hard enough to read, so I think we should just force it to
run in 8 bpp modes or abort.  OTOH, it'd be a waste of your work.

> Since this patch shows that it's not so easy to write games supporting
> every color depth, I think I'm going to write some functions which given a
> datafile convert all of it's BMP/RLE sprites to the actual color depth, so
> that you could do something like this in a program:
> 
> 	set_gfx_mode(GFX_SAFE, 0, 0, 0, 0)
> 	data = load_datafile ("data.dat");
> 	convert_datafile_graphics (data, data[GAME_PAL].dat);
> 
> Does that look right? Any visible problems with such code?

How about a convenience function to convert just one bitmap?
`convert_datafile_graphics' could be a wrapper (very liberal
pseudo-code follows):

    for i in datafile:
        if datafile[i] is bitmap:
	    convert_bitmap (&datafile[i].dat, some_palette);

where `convert_bitmap' has a prototype like:

      void convert_bitmap (BITMAP **bmp, RGB *some_palette)

This function could then be used in a convoluted way to solve the
problem of multiple palettes:

    for i in datafile:
        if datafile[i] is bitmap:
            prop = get_datafile_property (datafile[i], DAT_ID (PAL));
	    if prop:
		convert_bitmap (&datafile[i].dat, 
				find_datafile_object (datafile, prop)->dat);
	    else:
	        convert_bitmap (&datafile[i].dat, some_palette);

Editing datafile properties is a pain, but that's a tool problem :-)
Anyway, just thinking out aloud.

-- 
SNORFING (SNORF ing), n.  The little game waitresses love to play of
waiting until your mouth is full before sneaking up and asking, "Is
everything okay?"  -- Rich Hall, "Sniglets"



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/