diff --git a/src/sys/graphics/Makefile b/src/sys/graphics/Makefile index a0089ac..0e47204 100755 --- a/src/sys/graphics/Makefile +++ b/src/sys/graphics/Makefile @@ -23,7 +23,7 @@ $(G++) -o $@ $(OBJS) # Compile the source files -.C.o: +.cpp.o: $(G++) -Wall -O -I./ -c -o $@ $< .cc.s: diff --git a/src/sys/graphics/main.C b/src/sys/graphics/main.C deleted file mode 100755 index a4c82fd..0000000 --- a/src/sys/graphics/main.C +++ /dev/null @@ -1,18 +0,0 @@ -#include "objgfx30.h" -#include - -int main() { - TMode_Rec Mode_Rec; - TVESA_Rec VESA_Rec; - TPixelFmt pixfmt; - TRGB rgb[256]; - TGfx0* buf=0; - buf = new TGfx0(); - // cout << sizeof(buf->pal) << endl; - // cout << sizeof(rgb) << endl; - pixfmt.BPP=8; - buf->create(400,400,&pixfmt); - cout << buf->getMaxX() << endl; - if (buf) delete buf; - return(0); -} diff --git a/src/sys/graphics/main.cpp b/src/sys/graphics/main.cpp new file mode 100755 index 0000000..75a2a95 --- /dev/null +++ b/src/sys/graphics/main.cpp @@ -0,0 +1,12 @@ +#include "objgfx30.h" +#include + +int main() { + TPixelFmt pixfmt; + TGfx0* buf=0; + buf = new TGfx0(); + pixfmt.BPP=8; + buf->create(400,400,&pixfmt); + if (buf) delete buf; + return(0); +} diff --git a/src/sys/graphics/objgfx30.C b/src/sys/graphics/objgfx30.C deleted file mode 100755 index a617e7e..0000000 --- a/src/sys/graphics/objgfx30.C +++ /dev/null @@ -1,85 +0,0 @@ -#include "objgfx30.h" -#include - -// TGfx0 constructor - -TGfx0::TGfx0() { - DataState = og_None; - Buffer = 0; - LineOfs = 0; - *pal = 0; - xRes = 0; - yRes = 0; - MaxX = 0; - MaxY = 0; - bSize = 0; - lSize = 0; - TransparentColor = 0; - BPP = 0; - RedShifter = 0; - GreenShifter = 0; - BlueShifter = 0; - RedFieldPosition = 0; - GreenFieldPosition = 0; - BlueFieldPosition = 0; - return; -} // TGfx0::TGfx0() - - -bool TGfx0::create(UInt32 _xRes, UInt32 _yRes, TPixelFmt* _pixformat) { - UInt32 yy; - if (DataState==og_Owner) { - if (Buffer) free(Buffer); - if (LineOfs) free(LineOfs); - if (*pal) free(*pal); - } // if datastate - BPP = _pixformat->BPP; - bSize=_xRes*_yRes*((BPP+7) >> 3); - Buffer = malloc(bSize); - if (!Buffer) return FALSE; - lSize = _yRes*sizeof(UInt32); - LineOfs = (UInt32*)malloc(lSize); - if (!LineOfs) return FALSE; - // allocate pal here - // *pal=malloc(sizeof( - MaxX=_xRes-1; - xRes=_xRes; - MaxY=_yRes-1; - LineOfs[0]=0; - for (yy=1; yy> 3); - DataState = og_Owner; - // For 8bpp modes the next part doesn't matter - RedFieldPosition=_pixformat->RedFieldPosition; - GreenFieldPosition=_pixformat->GreenFieldPosition; - BlueFieldPosition=_pixformat->BlueFieldPosition; - // The next part is only used by 15/16hpp - RedShifter=8-_pixformat->RedMaskSize; - GreenShifter=8-_pixformat->GreenMaskSize; - BlueShifter=8-_pixformat->BlueMaskSize; - Owner = this; - return TRUE; -} // TGfx0::create - -UInt32 TGfx0::getMaxX() { - return MaxX; -} // TGfx0::getMaxX - -UInt32 TGfx0::getMaxY() { - return MaxY; -} // TGfx0::getMaxY - -TGfx0::~TGfx0() { - if (DataState == og_Owner) { - if (*pal) free(pal); - if (Buffer) free(Buffer); - if (LineOfs) free(LineOfs); - } // if datastate - *pal=0; - LineOfs=0; - Buffer=0; - bSize=0; - lSize=0; - DataState = og_None; - return; -} // TGfx0::~TGfx0() diff --git a/src/sys/graphics/objgfx30.cpp b/src/sys/graphics/objgfx30.cpp new file mode 100755 index 0000000..0b0bd14 --- /dev/null +++ b/src/sys/graphics/objgfx30.cpp @@ -0,0 +1,86 @@ +#include "objgfx30.h" +#include + +// TGfx0 constructor + +TGfx0::TGfx0() { + DataState = og_None; + Buffer = 0; + LineOfs = 0; + pal = 0; + xRes = 0; + yRes = 0; + MaxX = 0; + MaxY = 0; + bSize = 0; + lSize = 0; + TransparentColor = 0; + BPP = 0; + RedShifter = 0; + GreenShifter = 0; + BlueShifter = 0; + RedFieldPosition = 0; + GreenFieldPosition = 0; + BlueFieldPosition = 0; + return; +} // TGfx0::TGfx0() + + +bool TGfx0::create(UInt32 _xRes, UInt32 _yRes, TPixelFmt* _pixformat) { + UInt32 yy; + if (DataState==og_Owner) { + if (Buffer) free(Buffer); + if (LineOfs) free(LineOfs); + if (pal) free(pal); + } // if datastate + BPP = _pixformat->BPP; + bSize=_xRes*_yRes*((BPP+7) >> 3); + Buffer = malloc(bSize); + if (!Buffer) return FALSE; + lSize = _yRes*sizeof(UInt32); + LineOfs = (UInt32*)malloc(lSize); + if (!LineOfs) return FALSE; + pal = (TRGB*)malloc(256*sizeof(TRGB)); + if (!pal) return FALSE; + MaxX=_xRes-1; + xRes=_xRes; + MaxY=_yRes-1; + yRes=_yRes; + LineOfs[0]=0; + for (yy=1; yy<=MaxY; yy++) + LineOfs[yy]=LineOfs[yy-1]+xRes*((BPP+7) >> 3); + DataState = og_Owner; + // For 8bpp modes the next part doesn't matter + RedFieldPosition=_pixformat->RedFieldPosition; + GreenFieldPosition=_pixformat->GreenFieldPosition; + BlueFieldPosition=_pixformat->BlueFieldPosition; + // The next part is only used by 15/16hpp + RedShifter=8-_pixformat->RedMaskSize; + GreenShifter=8-_pixformat->GreenMaskSize; + BlueShifter=8-_pixformat->BlueMaskSize; + Owner = this; + return TRUE; +} // TGfx0::create + +UInt32 TGfx0::getMaxX() { + return MaxX; +} // TGfx0::getMaxX + +UInt32 TGfx0::getMaxY() { + return MaxY; +} // TGfx0::getMaxY + +TGfx0::~TGfx0() { + if (DataState == og_Owner) { + if (pal) free(pal); + if (Buffer) free(Buffer); + if (LineOfs) free(LineOfs); + } // if datastate + pal=0; + LineOfs=0; + Buffer=0; + bSize=0; + lSize=0; + DataState = og_None; + return; +} // TGfx0::~TGfx0() diff --git a/src/sys/graphics/objgfx30.h b/src/sys/graphics/objgfx30.h index d735484..af74031 100755 --- a/src/sys/graphics/objgfx30.h +++ b/src/sys/graphics/objgfx30.h @@ -112,7 +112,7 @@ TGfx0* Owner; void* Buffer; UInt32* LineOfs; - TRGB* pal[256]; + TRGB* pal; UInt32 xRes, yRes; UInt32 MaxX, MaxY; UInt32 bSize; // buffer size (in bytes)