Hello All,
There are no getr16() getg16() getb16() functions in A5, yet more code to write myself!
I have 16 bit colours read from an old tileset file in "unsigned short int" format. Under A4 they decode perfectly using getr16() etc.
Any ideas on best way of decoding it under A5? I am thinking bit shifting.
<rant>I am considering devoting my life to created Allegro425 which makes A4 code run under A5. All the simplicity of 4 with the features of 5. Here's to ALLEGRO_BITMAP->w (can't be that hard now can it?)</rant>
The reason for opaque data types in A5 is to avoid exposing implementation to help ensure binary compatibility. If from one day to the next A5 added ALLEGRO_BITMAP->something_new then it would no longer be binary compatible. I believe one of the goals of A5 is binary compatibility.
You could just copy/paste the functions from Allegro 4's source.
Note that storing raw 16-bit data directly in a file and using Allegro 4 getr16 isn't even guaranteed to work if you are doing it after set_gfx_mode is called because the RGB ordering is machine dependent.
Regarding the ALLEGRO_BITMAP->w comment, Allegro 5 does not expose internal struct data when it's not necessary. That is a good design decision.
You'll have to use the shift values that relate to whatever RGB order you are using.
Untested and pseudocodish:
// Assuming rgb ordering rshift = 11; gshift = 5; bshift = 0; r5 = (color >> rshift) & 0x1F; g6 = (color >> gshift) & 0x3F; b5 = (color >> bshift) & 0x1F; r8 = r5*255/31; g8 = g6*255/63; g8 = b5*255/31;
Thanks I will look try it out. This is for legacy import so won't be used very often (the importer will be available in the game).
Looks like it will just have to be #define gbw(lolz) al_get_bitmap_width(lolz)
After a few months of "expanding" [making more portable] my code to A5 we almost have a ported version of Mowteor which I am very happy about.
The important part (for me) is that this game tests my underlying library which is essentially an in-house class-based wrapper for Allegro allowing me to develop loads of games and larger "Meteor sized" projects with ease and without duplication.
Disclaimers:
Not thoroughly tested
Could use some more scale tables to smooth out rounding
Not built for speed