diff --git a/src/sys/graphics/main.cpp b/src/sys/graphics/main.cpp index 79083b7..00c458a 100755 --- a/src/sys/graphics/main.cpp +++ b/src/sys/graphics/main.cpp @@ -5,7 +5,8 @@ **********************************************************************/ #include "objgfx30.h" -#include +#include "objfont.h" +#include int main() { TPixelFmt pixfmt; @@ -13,9 +14,7 @@ buf = new TGfx0(); pixfmt.BPP=8; buf->create(400,400,(TPixelFmt *)&def_pixfmt_16bpp); - cout << (int)def_pixfmt_16bpp.BPP << endl; - cout << (int)buf->BPP << endl; - cout << (int)buf->RedShifter << endl; + printf("BPP: %d\n", buf->BPP); if (buf) delete buf; return(0); } diff --git a/src/sys/graphics/objfont.h b/src/sys/graphics/objfont.h new file mode 100755 index 0000000..ce14e76 --- /dev/null +++ b/src/sys/graphics/objfont.h @@ -0,0 +1,33 @@ +#ifndef OBJFONT_H +#define OBJFONT_H + +#include "objgfx30.h" + +#define LeftText 0 +#define CenterText 1 +#define RightText 2 +#define BottomText 0 +#define TopText 2 + +enum TFontType {BLF, BMF, DPF}; + +typedef struct { + char ID[4]; + UInt8 BPP; + UInt8 paddington[10]; + } TFontHeader; + +typedef struct { + char ID[3]; + UInt8 Version; + UInt8 Width, Height; + UInt8 NumOfChars; + UInt8 StartingChar; + UInt8 ColourType; + UInt8 paddington[7]; + } TDPFHeader; + +class TFont { + +}; +#endif diff --git a/src/sys/graphics/objgfx30.cpp b/src/sys/graphics/objgfx30.cpp index 36337b5..d11ce41 100755 --- a/src/sys/graphics/objgfx30.cpp +++ b/src/sys/graphics/objgfx30.cpp @@ -66,6 +66,33 @@ return TRUE; } // TGfx0::create +void TGfx0::flip(TGfx0* SrcObject) { + UInt32 count, xCount, yCount; + UInt32 xx, yy; + UInt8 r, g, b; + if (!Buffer) return; + if (!SrcObject->Buffer) return; + xCount = SrcObject->MaxX+1; + if (xCount>MaxX+1) xCount=MaxX; + yCount = SrcObject->MaxY+1; + if (yCount>MaxY+1) yCount=MaxY; + if ((BPP!=SrcObject->BPP) || (RedShifter!=SrcObject->RedShifter) || + (BlueShifter!=SrcObject->BlueShifter) || + (GreenShifter!=SrcObject->GreenShifter)) { + for (yy=0; yy<=yCount; yy++) + for (xx=0; xx<=xCount; xx++) { + SrcObject->unpackRGB(SrcObject->getpixel(xx,yy),&r,&g,&b); + // putpixel(xx,yy,RGB(r,g,b); + } // for + } // if + else + { + xCount=xCount*((BPP+7) >> 3); // adjust for bpp + for (count=0; count<=yCount; count++) ; + // memcpy( + } // else +} // TGfx0::flip + UInt32 TGfx0::getMaxX(void) { return MaxX; } // TGfx0::getMaxX @@ -74,6 +101,46 @@ return MaxY; } // TGfx0::getMaxY +UInt32 TGfx0::getpixel(UInt32 x, UInt32 y) { + return 0; +} // TGfx0::getpixel + +void TGfx0::putpixel(UInt32 x, UInt32 y, UInt32 colour) { + return; +} // TGfx0::putpixel + +UInt32 TGfx0::RGB(UInt8 red, UInt8 green, UInt8 blue) { + return 0; +} // TGfx0::RGB + +void TGfx0::unpackRGB(UInt32 colour, UInt8* red, UInt8* green, UInt8* blue) { + switch (BPP) { + case 8: + if (colour>255) colour=colour & 255; + *red = pal[colour].red; + *green = pal[colour].green; + *blue = pal[colour].blue; + break; + case 15: + case 16: + *red = ((colour >> RedFieldPosition) << RedShifter); + *green = ((colour >> GreenFieldPosition) << GreenShifter); + *blue = ((colour >> BlueFieldPosition) << BlueShifter); + break; + case 24: + case 32: + *red = colour >> RedFieldPosition; + *green = colour >> GreenFieldPosition; + *blue = colour >> BlueFieldPosition; + break; + default: + *red = 0; + *green = 0; + *blue = 0; + } + return; +} // TGfx0:unpackRGB + TGfx0::~TGfx0(void) { if (DataState == og_Owner) { if (pal) free(pal); diff --git a/src/sys/graphics/objgfx30.h b/src/sys/graphics/objgfx30.h index b55305c..71989ea 100755 --- a/src/sys/graphics/objgfx30.h +++ b/src/sys/graphics/objgfx30.h @@ -140,8 +140,13 @@ public: TGfx0(void); bool create(UInt32, UInt32,TPixelFmt*); + void flip(TGfx0*); UInt32 getMaxX(void); UInt32 getMaxY(void); + UInt32 getpixel(UInt32, UInt32); + void putpixel(UInt32, UInt32, UInt32); + UInt32 RGB(UInt8, UInt8, UInt8); + void unpackRGB(UInt32, UInt8*, UInt8*, UInt8*); ~TGfx0(void); }; // gfx0