00001 //& **************************************************************************** 00002 //& 00003 //& Copyright (C) 2004 HP-GCC Team 00004 //& 00005 //& **************************************************************************** 00006 //& 00007 //& This file is part of HP-GCC. 00008 //& 00009 //& HP-GCC is free software; you can redistribute it and/or modify 00010 //& it under the terms of the GNU General Public License as published by 00011 //& the Free Software Foundation; either version 2, or (at your option) 00012 //& any later version. 00013 //& 00014 //& HP-GCC is distributed in the hope that it will be useful, 00015 //& but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 //& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 //& GNU General Public License for more details. 00018 //& 00019 //& You should have received a copy of the GNU General Public License 00020 //& along with HP-GCC; see the file COPYING. 00021 //& 00022 //& As a special exception, you may use this file as part of a free software 00023 //& library without restriction. Specifically, if other files instantiate 00024 //& templates or use macros or inline functions from this file, or you compile 00025 //& this file and link it with other files to produce an executable, this 00026 //& file does not by itself cause the resulting executable to be covered by 00027 //& the GNU General Public License. This exception does not however 00028 //& invalidate any other reasons why the executable file might be covered by 00029 //& the GNU General Public License. 00030 //& 00031 //& **************************************************************************** 00032 00067 #define STATEBUFSIZE ((11+6)*4) 00068 00072 #define LCD_H 80 00073 00077 #define LCD_W 160 00078 00087 #define SCREENBUFSIZE ((LCD_W>>2)*(LCD_H)*2) 00088 00089 // data types/structures 00090 00091 // surface used for bitblt operations 00092 // notes: 00093 // a surface is infinite in both width and height, there are no memory limits 00094 // .addr must be a word aligned address 00095 // .width is used only to find a new scanline, and can be changed at will 00096 // the width is given in pixels and it can be arbitrary (no alignement needed) 00097 // for normal drawing primitives, (0,0) is the word-aligned address pointed by .addr, 00098 // disregarding of the values in .x and .y 00099 // for bitblt operations, .x and .y give the origin (top-left corner) of the region to use 00100 // the surface is nibble-aligned, so a 1 pixel wide surface will contain 8 00101 // rows of pixels per word 00102 00112 typedef struct { 00113 int *addr; 00114 int width; 00115 int x,y; 00116 } gglsurface; 00117 00138 typedef unsigned int (*gglfilter)(unsigned int pixels,int param); 00139 00159 typedef unsigned int (*ggloperator)(unsigned int dest,unsigned int source,int param); 00160 00161 00162 // general routines 00163 00175 void ggl_initscr(gglsurface *srf); // allocate screen buffer 00176 00177 00184 void ggl_freescr(); // FREE SCREEN BUFFER 00185 00186 00187 00199 void ggl_gethpgscreen(gglsurface *srf); 00200 00216 #define ggl_setmode(framebuf) sys_lcdsetmode(MODE_16GRAY,framebuf); 00217 00218 00241 #define ggl_save(buf) sys_lcdsave(buf) 00242 00263 #define ggl_restore(buf) sys_lcdrestore(buf) 00264 00265 /* 00266 * \brief Causes a different GGL surface to be displayed. 00267 * 00268 * This function allows the use of several GGL surfaces as the main screen 00269 * in an application. It causes the LCD controller to begin displaying a 00270 * different screen. No VSYNC is performed, so some tearing is possible 00271 * unless external VSYNC is checked before calling this function. 00272 * 00273 * This function should be used by applications that use GGL exclusively. If 00274 * HPG is in use, the application should use hpg_flip to accomplish page 00275 * flipping. 00276 * 00277 * \param framebuf A pointer to the new LCD screen's frame buffer. This is 00278 * generally found in the gglsurface::addr field of a 00279 * ::gglsurface. 00280 */ 00281 void ggl_show(int *buffer); // display buffer, no vertical sync 00282 00283 // drawing primitives 00284 // general pixel set/read routines 00285 00300 void ggl_pltnib(int *buff,int off,int color); // poke a pixel (off in nibbles) 00301 00317 int ggl_getnib(int *buff,int off); // peek a pixel (off in nibbles) 00318 00319 // general drawing primitives 00320 00321 // note: the argument color is a 32-bit value containing a different 00322 // color for each pixel. For solid colors, set color to contain the same value 00323 // on every nibble (for color 8, color=0x88888888) 00324 // or call ggl_mkcolor for that purpose 00325 00344 void ggl_hline(gglsurface *srf,int y,int xl,int xr, int color); // fast low-level horizontal line 00345 00365 void ggl_vline(gglsurface *srf,int x,int yt,int yb, int color); // fast low-level vertical line 00366 00388 void ggl_rect(gglsurface *srf,int x1,int y1,int x2,int y2,int color); // low-level rectangle 00389 00409 void ggl_rectp(gglsurface *srf,int x1,int y1,int x2,int y2,int *color); // low-level rectangle with 8x8 pattern 00410 00411 // rectangle blt 00412 // note: see gglsurface above for complete understanding of the behavior of these routines 00413 // ggl_bitblt loops from top to bottom 00414 00435 void ggl_bitblt(gglsurface *dest,gglsurface *src,int width, int height); // copy a rectangular region 00436 00437 // ggl_revblt loops from bottom to top, for overlapping zones 00457 void ggl_revblt(gglsurface *dest,gglsurface *src,int width, int height); // copy a rectangular region, reverse loop 00458 // ggl_ovlblt chooses to use normal/reverse loop based on the addresses 00459 // use it when the direcction of movement is unknown 00479 void ggl_ovlblt(gglsurface *dest,gglsurface *src,int width, int height); // copy overlapped regions 00480 // ggl_bitbltmask behaves exactly as ggl_bitblt but using tcol as a transparent color 00481 00482 00505 #define ggl_bitbltmask(dest,src,width,height,tcol) ggl_bitbltoper(dest,src,width,height,tcol,&ggl_opmask) 00506 00507 00508 // rectangle scrolling routines 00509 // dest contains the surface to scroll, and width and height define the rectangle 00510 // the area that needs to be redrawn after the scroll is not erased or modified by these routines 00528 void ggl_scrollup(gglsurface *dest,int width, int height, int npixels); // scroll npixels up 00547 void ggl_scrolldn(gglsurface *dest,int width, int height, int npixels); // scroll npixels dn 00548 00566 void ggl_scrolllf(gglsurface *dest,int width, int height, int npixels); // scroll npixels left 00584 void ggl_scrollrt(gglsurface *dest,int width, int height, int npixels); // scroll npixels right 00585 00586 // custom filters and operators 00587 00588 // bitmap filtering routine 00607 void ggl_filter(gglsurface *dest,int width, int height, int param, gglfilter filterfunc); 00608 00609 // bitblt operator routine 00631 void ggl_bitbltoper(gglsurface *dest,gglsurface *src,int width, int height,int param,ggloperator fop); 00632 00633 // predefined filters and operators 00634 00635 // filters (unary operators) 00636 // ligthens an image by subtracting param from all pixels 00637 00650 unsigned ggl_fltlighten(unsigned word,int param); 00651 // darkens an image by adding param to all pixels 00652 00665 unsigned ggl_fltdarken(unsigned word,int param); 00666 00667 // operators (between two surfaces) 00668 // standard mask, tcolor in src is considered transparent 00669 00670 00685 unsigned ggl_opmask(unsigned dest,unsigned src,int tcolor); 00686 // transparency blend, weight is 0 = src is opaque, 16 = src is fully transparent 00687 00703 unsigned ggl_optransp(unsigned dest,unsigned src,int weight); 00704 00705 00706 00707 00708 // miscellaneous 00709 00710 // ggl_mkcolor repeats the same color on every nibble 00711 // ggl_mkcolor(2) will return 0x22222222 00721 int ggl_mkcolor(int color); // solid color generator 00722 00723 // ggl_mkcolor32 creates virtual 32-colors by using 8x8 patterns 00724 // col32 is a value from 0 to 30, being 30=black, 0=white 00725 // note: the user is responsible to provide a valid int[8] buffer in the 00726 // pattern argument 00740 void ggl_mkcolor32(int col32, int *pattern); // 50% dither pattern generator for 31 colors 00741 00742 // ANTIALIAS INITIALIZATION 00743 00744 // ggl_initaline initializes tables needed for antialiased lines 00754 void ggl_initaline(); 00755 00756 // for antialiased lines, call first ggl_initaline and call ggl_endaline for cleanup 00757 // notice that ggl_init/ggl_exit do NOT call ggl_initaline 00758 // anitaliased lines are always 3 pixels wide 00774 void ggl_aline(gglsurface *srf,int x1,int y1,int x2,int y2); // ANTIALIASED LINES 00775 00776 // ggl_endaline cleans up the memory allocated by ggl_initaline 00786 void ggl_endaline();