HPGCC3 Documentation 3.0 R003
|
00001 //& *** (c) 2006-2011 The HPGCC3 Team *** 00002 //& Claudio Lapilli 00003 //& Ingo Blank 00004 //& 00005 //& This file is licensed under the terms and conditions of the 00006 //& HPGCC3 license that is included with the source distribution. 00007 //& *** (c) 2006-2011 The HPGCC3 Team *** 00008 00009 #ifdef __cplusplus 00010 extern "C" { 00011 #endif 00012 00013 00014 00015 #ifndef GGL_H_ 00016 #define GGL_H_ 00017 00018 00019 00020 00021 00058 #define STATEBUFSIZE ((11+6)*4) 00059 00063 #define LCD_H 80 00064 00068 #define LCD_W 160 00069 00078 #define SCREENBUFSIZE ((LCD_W>>2)*(LCD_H)*2) 00079 00080 // data types/structures 00081 00082 // surface used for bitblt operations 00083 // notes: 00084 // a surface is infinite in both width and height, there are no memory limits 00085 // .addr must be a word aligned address 00086 // .width is used only to find a new scanline, and can be changed at will 00087 // the width is given in pixels and it can be arbitrary (no alignement needed) 00088 // for normal drawing primitives, (0,0) is the word-aligned address pointed by .addr, 00089 // disregarding of the values in .x and .y 00090 // for bitblt operations, .x and .y give the origin (top-left corner) of the region to use 00091 // the surface is nibble-aligned, so a 1 pixel wide surface will contain 8 00092 // rows of pixels per word 00093 00103 typedef struct { 00104 int *addr; 00105 int width; 00106 int x,y; 00107 } gglsurface; 00108 00129 typedef unsigned int (*gglfilter)(unsigned int pixels,int param); 00130 00150 typedef unsigned int (*ggloperator)(unsigned int dest,unsigned int source,int param); 00151 00152 00153 // general routines 00154 00166 void ggl_initscr(gglsurface *srf); // allocate screen buffer 00167 00168 00175 void ggl_freescr(); // FREE SCREEN BUFFER 00176 00177 00178 00190 void ggl_gethpgscreen(gglsurface *srf); 00191 00207 #define ggl_setmode(framebuf) sys_lcdsetmode(MODE_16GRAY,framebuf); 00208 00209 00232 #define ggl_save(buf) sys_lcdsave(buf) 00233 00254 #define ggl_restore(buf) sys_lcdrestore(buf) 00255 00256 /* 00257 * \brief Causes a different GGL surface to be displayed. 00258 * 00259 * This function allows the use of several GGL surfaces as the main screen 00260 * in an application. It causes the LCD controller to begin displaying a 00261 * different screen. No VSYNC is performed, so some tearing is possible 00262 * unless external VSYNC is checked before calling this function. 00263 * 00264 * This function should be used by applications that use GGL exclusively. If 00265 * HPG is in use, the application should use hpg_flip to accomplish page 00266 * flipping. 00267 * 00268 * \param framebuf A pointer to the new LCD screen's frame buffer. This is 00269 * generally found in the gglsurface::addr field of a 00270 * ::gglsurface. 00271 */ 00272 void ggl_show(int *buffer); // display buffer, no vertical sync 00273 00274 // drawing primitives 00275 // general pixel set/read routines 00276 00291 void ggl_pltnib(int *buff,int off,int color); // poke a pixel (off in nibbles) 00292 00308 int ggl_getnib(int *buff,int off); // peek a pixel (off in nibbles) 00309 00310 // general drawing primitives 00311 00312 // note: the argument color is a 32-bit value containing a different 00313 // color for each pixel. For solid colors, set color to contain the same value 00314 // on every nibble (for color 8, color=0x88888888) 00315 // or call ggl_mkcolor for that purpose 00316 00335 void ggl_hline(gglsurface *srf,int y,int xl,int xr, int color); // fast low-level horizontal line 00336 00356 void ggl_vline(gglsurface *srf,int x,int yt,int yb, int color); // fast low-level vertical line 00357 00379 void ggl_rect(gglsurface *srf,int x1,int y1,int x2,int y2,int color); // low-level rectangle 00380 00400 void ggl_rectp(gglsurface *srf,int x1,int y1,int x2,int y2,int *color); // low-level rectangle with 8x8 pattern 00401 00402 // rectangle blt 00403 // note: see gglsurface above for complete understanding of the behavior of these routines 00404 // ggl_bitblt loops from top to bottom 00405 00426 void ggl_bitblt(gglsurface *dest,gglsurface *src,int width, int height); // copy a rectangular region 00427 00428 // ggl_revblt loops from bottom to top, for overlapping zones 00448 void ggl_revblt(gglsurface *dest,gglsurface *src,int width, int height); // copy a rectangular region, reverse loop 00449 // ggl_ovlblt chooses to use normal/reverse loop based on the addresses 00450 // use it when the direcction of movement is unknown 00470 void ggl_ovlblt(gglsurface *dest,gglsurface *src,int width, int height); // copy overlapped regions 00471 // ggl_bitbltmask behaves exactly as ggl_bitblt but using tcol as a transparent color 00472 00473 00496 #define ggl_bitbltmask(dest,src,width,height,tcol) ggl_bitbltoper(dest,src,width,height,tcol,&ggl_opmask) 00497 00498 00499 // rectangle scrolling routines 00500 // dest contains the surface to scroll, and width and height define the rectangle 00501 // the area that needs to be redrawn after the scroll is not erased or modified by these routines 00519 void ggl_scrollup(gglsurface *dest,int width, int height, int npixels); // scroll npixels up 00538 void ggl_scrolldn(gglsurface *dest,int width, int height, int npixels); // scroll npixels dn 00539 00557 void ggl_scrolllf(gglsurface *dest,int width, int height, int npixels); // scroll npixels left 00575 void ggl_scrollrt(gglsurface *dest,int width, int height, int npixels); // scroll npixels right 00576 00577 // custom filters and operators 00578 00579 // bitmap filtering routine 00598 void ggl_filter(gglsurface *dest,int width, int height, int param, gglfilter filterfunc); 00599 00600 // bitblt operator routine 00622 void ggl_bitbltoper(gglsurface *dest,gglsurface *src,int width, int height,int param,ggloperator filterfunc); 00623 00624 // predefined filters and operators 00625 00626 // filters (unary operators) 00627 // ligthens an image by subtracting param from all pixels 00628 00641 unsigned ggl_fltlighten(unsigned word,int param); 00642 // darkens an image by adding param to all pixels 00643 00656 unsigned ggl_fltdarken(unsigned word,int param); 00657 00658 // operators (between two surfaces) 00659 // standard mask, tcolor in src is considered transparent 00660 00661 00676 unsigned ggl_opmask(unsigned dest,unsigned src,int tcolor); 00677 // transparency blend, weight is 0 = src is opaque, 16 = src is fully transparent 00678 00694 unsigned ggl_optransp(unsigned dest,unsigned src,int weight); 00695 00696 00697 00698 00699 // miscellaneous 00700 00701 // ggl_mkcolor repeats the same color on every nibble 00702 // ggl_mkcolor(2) will return 0x22222222 00712 int ggl_mkcolor(int color); // solid color generator 00713 00714 // ggl_mkcolor32 creates virtual 32-colors by using 8x8 patterns 00715 // col32 is a value from 0 to 30, being 30=black, 0=white 00716 // note: the user is responsible to provide a valid int[8] buffer in the 00717 // pattern argument 00731 void ggl_mkcolor32(int col32, int *pattern); // 50% dither pattern generator for 31 colors 00732 00733 // ANTIALIAS INITIALIZATION 00734 00735 // ggl_initaline initializes tables needed for antialiased lines 00745 void ggl_initaline(); 00746 00747 // for antialiased lines, call first ggl_initaline and call ggl_endaline for cleanup 00748 // notice that ggl_init/ggl_exit do NOT call ggl_initaline 00749 // anitaliased lines are always 3 pixels wide 00765 void ggl_aline(gglsurface *srf,int x1,int y1,int x2,int y2); // ANTIALIASED LINES 00766 00767 // ggl_endaline cleans up the memory allocated by ggl_initaline 00777 void ggl_endaline(); 00778 00779 #endif 00780 00781 #ifdef __cplusplus 00782 } 00783 #endif 00784 00785