Hello everybody.
What do the command Bdisp_WriteGraph_DDVRAM?
Bdisp_writegraph_ddvram
Started by
Horrowind
, Mar 21 2007 07:17 PM
5 replies to this topic
#1
Posted 21 March 2007 - 07:17 PM
#2
Posted 21 March 2007 - 07:56 PM
It draw a bitmap to screen and VRAM.
#3
Posted 21 March 2007 - 09:07 PM
can you give me an example code?
#4
Posted 22 March 2007 - 08:00 PM
can you give me an example code?
Let me help you.
If you want graphics to be drawn really fast, you can use the Bdisp_WriteGraph_VRAM() function. Here's an example code that draws a #8 Pool Ball image very quickly:
/* Draws a #8 Pool Ball Demonstration Written by: kucalc Contact: <u title="Email protected, replace " AT " by "@"">kucalc[i] AT [/i]gmail.com</u> */ #include "fxlib.h" int AddIn_main(int isAppli, unsigned short OptionNum) { unsigned int key; DISPGRAPH picture; GRAPHDATA picture_info; unsigned long Image_C0[] = {0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0000003F,0xFC000000,0x 00000000,0x00000000,0x000001FF,0xFFC00000,0x00000000,0x00000000,0x00000FFF,0xFFF 80000,0x00000000,0x00000000,0x000023FF,0xFFFE0000,0x00000000,0x00000000,0x0000CF FF,0xFFFF8000,0x00000000,0x00000000,0x0003FFFF,0xFFFFC000,0x00000000,0x00000000, 0x0007FFFF,0xFFFFF000,0x00000000,0x00000000,0x000FFFFF,0xFFFFF800,0x00000000,0x0 0000000,0x001FFFFF,0xFFFFFC00,0x00000000,0x00000000,0x003F81FF,0xFFFFFE00,0x0000 0000,0x00000000,0x007C007F,0xFFFFFF00,0x00000000,0x00000000,0x00F8003F,0xFFFFFF8 0,0x00000000,0x00000000,0x01E0001F,0xFFFFFE40,0x00000000,0x00000000,0x03E0000F,0 xFFFFFD40,0x00000000,0x00000000,0x03C0600F,0xFFFFFCA0,0x00000000,0x00000000,0x07 808807,0xFFFFFE90,0x00000000,0x00000000,0x07810807,0xFFFFFFD0,0x00000000,0x00000 000,0x0F008807,0xFFFFFFF8,0x00000000,0x00000000,0x0F039007,0xFFFFFFF8,0x00000000 ,0x00000000,0x1F042007,0xFFFFFFFC,0x00000000,0x00000000,0x1F0C2007, 0xFFFFFFFC,0x00000000,0x00000000,0x3F081007,0xFFFFFFFC,0x00000000,0x0000000 0,0x3F041007,0xFFFFFFFE,0x00000000,0x00000000,0x3F06300F,0xFFFFFFFE,0x00000000,0 x00000000,0x3F00E00F,0xFFFFFFFE,0x00000000,0x00000000,0x7F00000F,0xFFFFFFFE,0x00 000000,0x00000000,0x7F80001F,0xFFFFFFFE,0x00000000,0x00000000,0x7F80003F,0xFFFFF FFF,0x00000000,0x00000000,0x7FC0007F,0xFFFFFFFF,0x00000000,0x00000000,0x7FE000FF ,0xFFFFFFFF,0x00000000,0x00000000,0x7FF003FF,0xFFFFFFFF,0x00000000,0x00000000,0x 7FFE0FFF,0xFFFFFFFF,0x00000000,0x00000000,0x7FFFFFFF,0xFFFFFFFF,0x00000000,0x000 00000,0x7FFFFFFF,0xFFFFFFFF,0x00000000,0x00000000,0x7FFFFFFF,0xFFFFFFFF,0x000000 00,0x00000000,0x7FFFFFFF,0xFFFFFFFE,0x00000000,0x00000000,0x7FFFFFFF,0xFFFFFFFE, 0x00000000,0x00000000,0x3FFFFFFF,0xFFFFFFFE,0x00000000,0x00000000,0x3FFFFFFF,0xF FFFFFFE,0x00000000,0x00000000,0x3FFFFFFF,0xFFFFFFFE,0x00000000,0x00000000,0x1FFF FFFF,0xFFFFFFFC,0x00000000,0x00000000,0x17FFFFFF,0xFFFFFFFC,0x00000000,0x0000000 0,0x12FFFFFF, 0xFFFFFFFC,0x00000000,0x00000000,0x0AFFFFFF,0xFFFFFFF8,0x00000000,0x0000000 0,0x097FFFFF,0xFFFFFFF8,0x00000000,0x00000000,0x05FFFFFF,0xFFFFFFF0,0x00000000,0 x00000000,0x06FFFFFF,0xFFFFFFF0,0x00000000,0x00000000,0x03FFFFFF,0xFFFFFFE0,0x00 000000,0x00000000,0x01FFFFFF,0xFFFFFFC0,0x00000000,0x00000000,0x01FFFFFF,0xFFFFF FC0,0x00000000,0x00000000,0x00FFFFFF,0xFFFFFF80,0x00000000,0x00000000,0x007FFFFF ,0xFFFFFF00,0x00000000,0x00000000,0x003FFFFF,0xFFFFFE00,0x00000000,0x00000000,0x 001FFFFF,0xFFFFEC00,0x00000000,0x00000000,0x000FFFFF,0xFFFFD800,0x00000000,0x000 00000,0x0007FFFF,0xFFFF3000,0x00000000,0x00000000,0x0001FFFF,0xFFFFC000,0x000000 00,0x00000000,0x0000FFFF,0xFFFF8000,0x00000000,0x00000000,0x00003FFF,0xFFFE0000, 0x00000000,0x00000000,0x00000FFF,0xFFF80000,0x00000000,0x00000000,0x000001FF,0xF FC00000,0x00000000,0x00000000,0x0000001F,0xFC000000,0x00000000,0x00000000,0x0000 0000,0x00000000,0x00000000}; Bdisp_AllClr_DDVRAM(); picture_info.width = 128; picture_info.height = 64; picture_info.pBitmap = (unsigned long*)Image_C0; picture.x = 0; picture.y = 0; picture.GraphData = picture_info; picture.WriteModify = IMB_WRITEMODIFY_NORMAL; picture.WriteKind = IMB_WRITEKIND_OR; Bdisp_WriteGraph_VRAM(&picture); Bdisp_PutDisp_DD(); while(1){ GetKey(&key); } return 1; } #pragma section _BR_Size unsigned long BR_Size; #pragma section #pragma section _TOP int InitializeSystem(int isAppli, unsigned short OptionNum) { return INIT_ADDIN_APPLICATION(isAppli, OptionNum); } #pragma section
Where it says unsigned long Image_C0[] = ... is where the image data is stored. I didn't write all the image data by hand, I used a utility to convert a BMP to a C array (source code): http://www.ticalc.or.../180/18067.html. Using that utility (TI Paint Plus), go to MS Paint and draw up a 128x64 image (or you can choose you own dimensions, but as for an example...). Run TI Paint Plus, and in the first tab, look where it says, Taille de l'image and in the scroll down select Personnalise. Then where it says Largeur and Hauteur, type in 128 in the first and 64 in the second box (or whatever dimension the picture is). Next, click on Ouvrir and then select your BMP file. After that, you would then click on the second tab: Enregistrer, and then click on the Enregistrer button. A File window will pop up telling you where to save the file. Before you save, select Sprite (Language C) where it says Save as type:. Now you can save the file and once it's saved, you can just open the file and copy&paste the code into your own source code.
Going back to the source code, look where it says:
DISPGRAPH picture; GRAPHDATA picture_info;
This defines the structures you need to draw a sprite.
picture_info.width = 128; picture_info.height = 64; picture_info.pBitmap = (unsigned long*)Image_C0; picture.x = 0; picture.y = 0;
This is how you change the dimensions and the location of the image.
picture.GraphData = picture_info; picture.WriteModify = IMB_WRITEMODIFY_NORMAL; picture.WriteKind = IMB_WRITEKIND_OR; Bdisp_WriteGraph_VRAM(&picture); Bdisp_PutDisp_DD();
This is how you can change the properties of a sprite. Remember to always call Bdisp_PutDisp_DD() after using a function that draw to the V(ideo)RAM. This copies the VRAM to the DD(Display Driver) or the LCD.
Hope this helps.
If you need more help contact me at kucalc AT gmail.com, or on MSN at kucalc AT hotmail.com.
#5
Posted 23 March 2007 - 07:52 PM
This help a lot.
I will try it now... and then nobody can stop me
hehehehe
I will try it now... and then nobody can stop me
hehehehe
#6
Posted 23 March 2007 - 11:04 PM
That's good to hear, remember to email for help if you need it.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users