#ifndef __IGE_HPP #define __IGE_HPP #include "porttype.hpp" class IGE; //IGE startup&shutdown struct ModeInfo { unsigned width; //width of display in pixels unsigned height; //height of display in pixels unsigned bpp; //bits per pixel unsigned long colors; //2^bpp IGE *ige; }; int switchToGraphicMode(unsigned mode, ModeInfo *info); int restorePreviousMode(ModeInfo *info); extern IGE *ige; extern unsigned ige_vert_res; extern unsigned ige_horz_res; enum PixelOp { //pixel operations //basic po alias c=new color, p=old color po_0=0, po_clear=po_0, //0 po_1=1, po_nor=po_1, //!(p|c) po_2=2, //!c&p po_3=3, po_notput=po_3, //!c po_4=4, //c&!p po_5=5, po_not=po_5, //!p po_6=6, po_xor=po_6, //p^c po_7=7, po_nand=po_7, //!(p&c) po_8=8, po_and=po_8, //p&c po_9=9, po_xnor_po_9, //!(p^c) po_10=10, po_leavealone=po_10, //p po_11=11, //!c|p po_12=12, po_put=po_12, //c po_13=13, //c|!p po_14=14, po_or=po_13, //c|p po_15=15, po_set=po_15 //1 }; class RGB; class IGE { public: virtual ~IGE() {} //Single-pixel API virtual uint32 QueryPixel(unsigned x, unsigned y); virtual void SetPixel(unsigned x, unsigned y, uint32 color, PixelOp po); //Straight line API virtual void DrawLine(unsigned x1, unsigned y1, unsigned x2, unsigned y2, uint32 fcolor, PixelOp fpo, uint32 bcolor, PixelOp bpo, uint32 lineStyle ); //Pattern API virtual void DrawPattern(unsigned lx, unsigned ty, unsigned rx, unsigned by, uint32 fcolor, PixelOp fpo, uint32 bcolor, PixelOp bpo, const uint32 *pattern ); //clipping virtual void SetClip(int lx, int ty, int rx, int by); virtual void QueryClip(int &lx, int &ty, int &rx, int &by); protected: static unsigned clip_lx, clip_ty, clip_rx, clip_by; //colormapping, used by RGB class friend class RGB; virtual uint32 mapcolor(uint8 red, uint8 green, uint8 blue) =0; virtual void unmapcolor(uint32 color, uint8 &red, uint8 &green, uint8 &blue)=0; //pixel, query virtual uint32 QueryPixel_nocheck(unsigned x, unsigned y); virtual uint32 _QueryPixel(unsigned x, unsigned y) =0; //pixel, set virtual void SetPixel_nocheck(unsigned x, unsigned y, uint32 color, PixelOp po); virtual void _SetPixel(unsigned x, unsigned y, uint32 color) =0; typedef void (*setpixel_f)(unsigned x, unsigned y, uint32 color); virtual setpixel_f Query_spf(PixelOp po) =0; //line virtual void DrawLine_diag(unsigned x1, unsigned y1, unsigned x2, unsigned y2, uint32 fcolor, PixelOp fpo, uint32 bcolor, PixelOp bpo, uint32 lineStyle ); virtual void DrawLine_vert(unsigned x, unsigned y1, unsigned y2, uint32 fcolor, PixelOp fpo, uint32 bcolor, PixelOp bpo, uint32 lineStyle ); virtual void DrawLine_vert_nocheck(unsigned x, unsigned y1, unsigned y2, uint32 fcolor, PixelOp fpo, uint32 bcolor, PixelOp bpo, uint32 lineStyle ); virtual void DrawLine_horz(unsigned x1, unsigned x2, unsigned y, uint32 fcolor, PixelOp fpo, uint32 bcolor, PixelOp bpo, uint32 lineStyle ); virtual void DrawLine_horz_nocheck(unsigned x1, unsigned x2, unsigned y, uint32 fcolor, PixelOp fpo, uint32 bcolor, PixelOp bpo, uint32 lineStyle ); //pattern virtual void DrawPattern_nocheck(unsigned lx, unsigned ty, unsigned rx, unsigned by, uint32 fcolor, PixelOp fpo, uint32 bcolor, PixelOp bpo, const uint32 *pattern ); }; class RGB { uint8 c[3]; public: RGB(uint8 r, uint8 g, uint8 b) { c[0]=r; c[1]=g; c[2]=b; } RGB(const RGB &rgb) { c[0]=rgb.c[0]; c[1]=rgb.c[1]; c[2]=rgb.c[2]; } RGB(uint32 color) { ige->unmapcolor(color,c[0],c[1],c[2]); } uint8 red() const { return c[0]; } uint8 green() const { return c[1]; } uint8 blue() const { return c[2]; } operator uint32() const { return ige->mapcolor(c[0],c[1],c[2]); } }; const uint32 nullLine=0; const uint32 solidLine=0xFFFFFFFFUL; extern const uint32 nullPattern[32]; extern const uint32 solidPattern[32]; extern const uint32 forwardHatchPattern[32]; extern const uint32 backwardHatchPattern[32]; extern const uint32 forwardThickHatchPattern[32]; extern const uint32 backwardThickHatchPattern[32]; extern const uint32 crossPattern[32]; extern const uint32 thickCrossPattern[32]; extern const uint32 diagPattern[32]; extern const uint32 thickDiagPattern[32]; #endif