- Bdisp Intro
- Bdisp_AllClr_DD/VRAM/DDVRAM()
- Bdisp_PutDisp_DD()
- Bdisp_DrawLineVRAM()
- Bdisp_ClearLineVRAM()
- Bdisp_AreaClr_DD/VRAM/DDVRAM()
- Bdisp_AreaReverseVRAM()
- Bdisp_GetDisp_DD/VRAM()
- Bdisp_PutDispArea_DD()
- Bdisp_SetPoint_DD/VRAM/DDVRAM()
- Bdisp_GetPoint_VRAM()
- Bdisp_WriteGraph_DD/VRAM/DDVRAM()
- Bdisp_ReadArea_DD/VRAM()
Bdisp Intro
Bdisp functions are all about the screen of the calculator. There are two screens you can draw to. DD and VRAM. DD known as the Display Driver. It is what you see. It is the screen of the calculator. The VRAM is the same thing as RAM in a computer. You can draw to the VRAM first then transfer the data from VRAM to DD. This enables faster drawing. Plus some functions like drawline can only be drawn to VRAM.
Another thing to keep in mind is the Screen Dimensions. It is a 128x64 screen. These are the used by the co ordinates for the screen. It basically means 128 pixels across the x axis and 64 across the y. The top left corner and the co ordinates of (0,0) while the Lower right hand corner is (127,63). These have to be precise when drawing otherwise you picture will get screwed up. You need the exact pixel location and your dealing with 128x64 pixels. Which adds up to 8192 pixels to choose from.
Bdisp_AllClr_DD/VRAM/DDVRAM();
This is the function you would most likely call at the very start of the add in to clear the menu of the screen. It basically clears the screen. You can choose to clear the DD, VRAM or both.
Clearing the DD at the start
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){ Bdisp_AllClr_DD(); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma sectionThis simple code clears the Display Driver. It would leave the information on the VRAM but the menu is only on the DD.
Clearing the VRAM
Clearing just the VRAM could be useful. You could leave and image on the display as another is drawn to the VRAM. Then clear the display and then put the VRAM to DD. Here is an example using print_mini to print some text to VRAM but leave the menu on the DD. The after 3 seconds clear the Display and put the text there. Then clear the VRAM and draw some more text. but wait 3 seconds till its drawn.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){ PrintMini(0,0,(unsigned char*)"Text 1",MINI_OVER); Sleep(3000); Bdisp_AllClr_DD(); Bdisp_PutDisp_DD(); Bdisp_AllClr_VRAM(); PrintMini(0,0,(unsigned char*)"Text 2",MINI_OVER); Sleep(3000); Bdisp_AllClr_DD(); Bdisp_PutDisp_DD(); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma sectionClearing everything
Bdisp_AllClr_DDVRAM clears both the disply and vram. This is almost always used at the start.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){ Bdisp_AllClr_DDVRAM(); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma sectionThis clears the screen and waits 3 seconds. It clears both the DD and VRAM.
Bdisp_PutDisp_DD()
Bdisp_PutDisp_DD() basicly transfers all of the data from the VRAM to the DD. Here is an example.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){ Bdisp_AllClr_DDVRAM(); PrintMini(0,0,(unsigned char*)"I am printed to the the VRAM",MINI_OVER); PrintMini(0,7,(unsigned char*)"first and then transfered ",MINI_OVER); PrintMini(0,14,(unsigned char*)"to the DD",MINI_OVER); Bdisp_PutDisp_DD(); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_DrawLineVRAM()
This function draws a line onto the VRAM. It takes 4 arguments. x1, y1, x2, and y2. These are the co ordinates of the line. x1 and y1 are the co ordinates for the first point of the line. x2 and y2 are the end points. A line is then drawn between them.
The following example draws a border around the screen and then a cross through the center. This is the transferred to the DD.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){ Bdisp_AllClr_DDVRAM(); Bdisp_DrawLineVRAM(0,0,127,0); Bdisp_DrawLineVRAM(127,0,127,63); Bdisp_DrawLineVRAM(127,63,0,63); Bdisp_DrawLineVRAM(0,63,0,0); Bdisp_DrawLineVRAM(0,0,127,64); Bdisp_DrawLineVRAM(127,0,0,63); Bdisp_PutDisp_DD(); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_ClearLineVRAM()
This is the same as Bdisp_DrawLineVRAM() except that it clears the line instead of drawing it. It takes the same amount of arguments as drawline.
The following example uses a for loop to Draw lines the make the screen black. Then it does the same as the draw line example but its white on black.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){int y; Bdisp_AllClr_DDVRAM(); for(y=0;y<=63;y++){ Bdisp_DrawLineVRAM(0,y,127,y); } Bdisp_PutDisp_DD(); Sleep(3000); Bdisp_ClearLineVRAM(0,0,127,0); Bdisp_ClearLineVRAM(127,0,127,63); Bdisp_ClearLineVRAM(127,63,0,63); Bdisp_ClearLineVRAM(0,63,0,0); Bdisp_ClearLineVRAM(0,0,127,63); Bdisp_ClearLineVRAM(127,0,0,63); Bdisp_AllClr_DD(); Bdisp_PutDisp_DD(); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_AreaClr_DD/VRAM/DDVRAM()
This clears an area from the DD VRAM or both. This introduces a new type of argument. A DISPBOX which is basically a predefined set of variables. First you have to declare a new DISPBOX and give it a name. Then you have to give the variables values.
DISPBOX cleararea;cleararea.left = 10;cleararea.top = 10;cleararea.right = 20;cleararea.bottom = 20;This is a basic DISPBOX.
Now we will create a black screen and clear a center box.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){int y;DISPBOX cleararea;cleararea.left = 54;cleararea.top = 22;cleararea.right = 74;cleararea.bottom = 42; Bdisp_AllClr_DDVRAM(); for(y=0;y<=63;y++){ Bdisp_DrawLineVRAM(0,y,127,y); } Bdisp_PutDisp_DD(); Sleep(3000); Bdisp_AreaClr_DDVRAM(&cleararea); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_AreaReverseVRAM()
This function reverses the area of the VRAM within the co ordinates. You have four arguments. x1, y1, x2, and y2. These four co ordinates declare a rectangle and every pixel within this rectange is reversed in colour. We will do the same example as the AreaClr except this way is far more simpler.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){ Bdisp_AllClr_DDVRAM(); Bdisp_AreaReverseVRAM(0,0,127,63); Bdisp_PutDisp_DD(); Sleep(3000); Bdisp_AllClr_DD(); Bdisp_AreaReverseVRAM(54,22,74,42); Bdisp_PutDisp_DD(); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_GetDisp_DD/VRAM()
This gets the data or the bitmap from either DD or VRAM and stores it in an array. The array has to be of char type and be 1024 in size. In this example we will draw the same example as before and then copy it to an array.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){char bitmap[1024]; Bdisp_AllClr_DDVRAM(); Bdisp_AreaReverseVRAM(0,0,127,63); Bdisp_PutDisp_DD(); Sleep(3000); Bdisp_AllClr_DD(); Bdisp_AreaReverseVRAM(54,22,74,42); Bdisp_PutDisp_DD(); Bdisp_GetDisp_DD(&bitmap); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_PutDispArea_DD()
Now this one I never use if I can help it. Sometimes the entire box doesn't get transferred.
This function also uses a DISPBOX. It transfers the rectangle declared in the DISPBOX to the DD. Here is an example. It makes the screen black and then clears the VRAM. Then it transfers the middle section to the DD.
This code is a classic example of not transferring all the data.
#include "fxlib.h"#include "dispbios.h"int AddIn_main(int isAppli, unsigned short OptionNum){DISPBOX cleararea;cleararea.left = 1;cleararea.top = 1;cleararea.right = 126;cleararea.bottom =62; Bdisp_AllClr_DDVRAM(); Bdisp_AreaReverseVRAM(0,0,127,63); Bdisp_PutDisp_DD(); Bdisp_AreaReverseVRAM(0,0,127,63); Sleep(3000); Bdisp_PutDispArea_DD(&cleararea); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_SetPoint_DD/VRAM/DDVRAM()
This just turns a pixel to the colour stated. It takes 3 arguments. x, y and the colour. x and y are just the position on the screen. The color is if the pixel is black or white. If it is set to 1 then it is turned black. If it is set to 0 then it is set to white. Here is an example.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){ Bdisp_AllClr_DDVRAM(); Bdisp_SetPoint_DDVRAM(15,36,1); Bdisp_SetPoint_DDVRAM(82,48,1); Bdisp_SetPoint_DDVRAM(43,25,1); Bdisp_SetPoint_DDVRAM(103,51,1); Sleep(3000); Bdisp_AllClr_DDVRAM(); Bdisp_AreaReverseVRAM(0,0,127,63); Bdisp_SetPoint_VRAM(15,36,0); Bdisp_SetPoint_VRAM(82,48,0); Bdisp_SetPoint_VRAM(43,25,0); Bdisp_SetPoint_VRAM(103,51,0); Bdisp_PutDisp_DD(); Sleep(3000);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_GetPoint_VRAM()
This returns a value to and int. It takes 2 arguments. x and y. These are the position of the pixel to read. It basically reads the pixel to see what colour it is. Then returns a value accordingly. If it returns 1 then the pixel is black. If it returns 0 then the pixel is white.
Here is an example. It Creates a while loop. This will make the center pixel flash on and off. If gets the pixel colour then sets it to the opposite.
#include "fxlib.h"int AddIn_main(int isAppli, unsigned short OptionNum){int pixel; Bdisp_AllClr_DDVRAM(); while(IsKeyDown(KEY_CTRL_EXIT)==0){ pixel = Bdisp_GetPoint_VRAM(64,32); if(pixel == 1){ Bdisp_SetPoint_DDVRAM(64,32,0); } if(pixel == 0){ Bdisp_SetPoint_DDVRAM(64,32,1); } Sleep(500); }}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma sectionBdisp_WriteGraph_DD/VRAM/DDVRAM()
This function copies a bitmap array onto the DD, VRAM or both. In this one we have 2 different types of Predefined variable structures. GRAPHDATA and DISPGRAPH. The GRAPHDATA is responsible for the information about the picture. The DISPBOX however is responsible for where and how the picture is displayed.
Here is an example. It draws a cross to the VRAM and copies it to a buffer. Then we use a void and throw the bitmap to it. It then draws it to the screen.
#include "fxlib.h"#include "dispbios.h"void draw(unsigned char bitmap[]){GRAPHDATA picturedata;DISPGRAPH pictureinfo;picturedata.width = 128;picturedata.height = 64;picturedata.pBitmap = bitmap;pictureinfo.x = 0;pictureinfo.y = 0;pictureinfo.GraphData = picturedata;pictureinfo.WriteModify = IMB_WRITEMODIFY_NORMAL;pictureinfo.WriteKind = IMB_WRITEKIND_OVER; Bdisp_WriteGraph_DDVRAM(&pictureinfo); Sleep(3000);}int AddIn_main(int isAppli, unsigned short OptionNum){char bitmap[1024]; Bdisp_AllClr_DDVRAM(); Bdisp_DrawLineVRAM(0,0,127,0); Bdisp_DrawLineVRAM(127,0,127,63); Bdisp_DrawLineVRAM(127,63,0,63); Bdisp_DrawLineVRAM(0,63,0,0); Bdisp_DrawLineVRAM(0,0,127,63); Bdisp_DrawLineVRAM(127,0,0,63); Bdisp_GetDisp_VRAM(bitmap); Bdisp_AllClr_VRAM(); Sleep(3000); draw(bitmap);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
Bdisp_ReadArea_DD/VRAM()
This function reads the data only from a certain area of the screen. It uses the DISPBOX function to do it.
Here is an example of the same thing as above except it only reads a small bit. the middle square, and then transfers it.
#include "fxlib.h"#include "dispbios.h"void draw(unsigned char bitmap[]){GRAPHDATA picturedata;DISPGRAPH pictureinfo;picturedata.width = 20;picturedata.height = 20;picturedata.pBitmap = bitmap;pictureinfo.x = 54;pictureinfo.y = 22;pictureinfo.GraphData = picturedata;pictureinfo.WriteModify = IMB_WRITEMODIFY_NORMAL;pictureinfo.WriteKind = IMB_WRITEKIND_OVER; Bdisp_WriteGraph_DDVRAM(&pictureinfo); Sleep(3000);}int AddIn_main(int isAppli, unsigned short OptionNum){char bitmap[1024];DISPBOX readarea;readarea.left = 54;readarea.top = 22;readarea.right = 74;readarea.bottom = 42; Bdisp_AllClr_DDVRAM(); Bdisp_DrawLineVRAM(0,0,127,0); Bdisp_DrawLineVRAM(127,0,127,63); Bdisp_DrawLineVRAM(127,63,0,63); Bdisp_DrawLineVRAM(0,63,0,0); Bdisp_DrawLineVRAM(0,0,127,63); Bdisp_DrawLineVRAM(127,0,0,63); Bdisp_ReadArea_VRAM(&readarea, &bitmap); Bdisp_AllClr_VRAM(); Sleep(3000); draw(bitmap);}#pragma section _BR_Sizeunsigned long BR_Size;#pragma section#pragma section _TOPint InitializeSystem(int isAppli, unsigned short OptionNum){ return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}#pragma section
And that is my Bdisp tutorial. If you find anything wrong with it or would like to add anything please tell me. Or if you have the mod power edit it in XD