gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Pictures in 8bits C header file (not 16bit) and how read it

#163221 - renatobs - Thu Sep 25, 2008 10:36 pm

Hi. Id like to know if someone coul help me:

I usually used the program "pcx2gba" to get to converet a picture (this outputs image in 16bit values (2 pixels per value), and palette in 16bit values into an array in a C header file ) and like this I can work with pictures on the screen. The problem is that now I need know how to get a image into an array in a C header file, but in 8bit value (soime program ?) , or, how can I get only one of the 8bit value from a number like 0x1F02 ( 2 and 16 ) ?
I have a image with a "new font" to use in a game and this have characters with diferents lengths. Cuz of it I need cut a (x, 16) font picture (8bits color ) and put in the specific point in the screen. I also need know how to access only a 8bit value in the screen, not 16bit value ! The bios have function like dmaCopy, swiCopy, but then only work with 16 bit... Please, could someone help me ?!? Maybe have a easy way, but I still don?t get...
Thanks,
Renato.

#163241 - silent_code - Fri Sep 26, 2008 7:48 pm

I'll keep it short and untested - I hope I didn't screw that simple stuff up too much! ;^D

Code:
uint8 ch = 0, cl = 0;
uint16 s = 0x02FF;
cl = s & 0x00FF; // "low" byte
ch = s >> 8; // "high" byte

If you can't figure out the meaning by yourself (I don't have time to explain it atm.), you should take a good (!= BullSchildt) book about C / C++ and start or at least continue reading it. ;^)

Best regards! :^)

PS: So, how do you read 8bit pixels now? By fetching non-8-bit values from VRAM and extracting the values you need.

PPS: You can also do the task in other ways; xor (^) comes to mind. :^)
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.

#163270 - renatobs - Sun Sep 28, 2008 2:09 am

rs... I already had resolved this... and this way that you explained here... but thank you very much !!! ;) !!!

#163276 - silent_code - Sun Sep 28, 2008 1:13 pm

You're welcome. :^)
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.