diff --git a/src/bin/launcher/ubixButton.cpp b/src/bin/launcher/ubixButton.cpp index ee874fc..a256da0 100644 --- a/src/bin/launcher/ubixButton.cpp +++ b/src/bin/launcher/ubixButton.cpp @@ -1,7 +1,10 @@ #include +#include -ubixButton::ubixButton(void) : vButton(0) { +ubixButton::ubixButton(void) : vButton(null) { + SetSize(48, 48); return; + } // ubixButton::ubixButton() ubixButton::~ubixButton(void) { diff --git a/src/lib/objgfx40/include/ogDisplay_VESA.h b/src/lib/objgfx40/include/ogDisplay_VESA.h index bf713eb..8bd61dc 100644 --- a/src/lib/objgfx40/include/ogDisplay_VESA.h +++ b/src/lib/objgfx40/include/ogDisplay_VESA.h @@ -76,24 +76,24 @@ void SetPal(void); public: ogDisplay_VESA(void); - virtual bool Alias(ogSurface&, uInt32, uInt32, uInt32, uInt32); - virtual bool Avail(void); - virtual void Clear(uInt32); - virtual bool Clone(ogSurface&); - virtual void CopyLineTo(uInt32, uInt32, const void *, uInt32); - virtual void CopyLineFrom(uInt32, uInt32, void *, uInt32); - virtual void CopyPalette(ogSurface&); - virtual bool Create(uInt32, uInt32, ogPixelFmt); - virtual uInt32 GetPixel(int32, int32); - virtual void * GetPtr(uInt32, uInt32); - virtual void HLine(int32, int32, int32, uInt32); - virtual bool LoadPalette(const char *); - virtual void SetPalette(const ogRGBA8[]); - virtual void SetPixel(int32, int32, uInt32); - virtual void SetPalette(uInt8, uInt8, uInt8, uInt8); - virtual void SetPalette(uInt8, uInt8, uInt8, uInt8, uInt8); - virtual void VFlip(void); - virtual void VLine(int32, int32, int32, uInt32); + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual bool ogAvail(void); + virtual void ogClear(uInt32); + virtual bool ogClone(ogSurface&); + virtual void ogCopyLineTo(uInt32, uInt32, const void *, uInt32); + virtual void ogCopyLineFrom(uInt32, uInt32, void *, uInt32); + virtual void ogCopyPalette(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + virtual uInt32 ogGetPixel(int32, int32); + virtual void * ogGetPtr(uInt32, uInt32); + virtual void ogHLine(int32, int32, int32, uInt32); + virtual bool ogLoadPalette(const char *); + virtual void ogSetPalette(const ogRGBA8[]); + virtual void ogSetPixel(int32, int32, uInt32); + virtual void ogSetPalette(uInt8, uInt8, uInt8, uInt8); + virtual void ogSetPalette(uInt8, uInt8, uInt8, uInt8, uInt8); + virtual void ogVFlip(void); + virtual void ogVLine(int32, int32, int32, uInt32); virtual ~ogDisplay_VESA(void); }; // ogDisplay_VESA diff --git a/src/lib/objgfx40/main.cpp b/src/lib/objgfx40/main.cpp index d9cab6c..cfd5158 100644 --- a/src/lib/objgfx40/main.cpp +++ b/src/lib/objgfx40/main.cpp @@ -26,13 +26,13 @@ ogPixCon * pixCon = new ogPixCon(OG_PIXFMT_32BPP, OG_PIXFMT_16BPP); uInt8 r, g, b; - buf1->Create(100, 100, OG_PIXFMT_32BPP); - buf2->Create(100, 200, OG_PIXFMT_16BPP); + buf1->ogCreate(100, 100, OG_PIXFMT_32BPP); + buf2->ogCreate(100, 200, OG_PIXFMT_16BPP); - buf1->SetPixel(0, 0, buf1->Pack(128, 42, 69)); - buf2->SetPixel(0, 0, pixCon->ConvPix(buf1->GetPixel(0, 0))); + buf1->ogSetPixel(0, 0, buf1->ogPack(128, 42, 69)); + buf2->ogSetPixel(0, 0, pixCon->ConvPix(buf1->ogGetPixel(0, 0))); - buf2->Unpack(buf2->GetPixel(0, 0), r, g, b); + buf2->ogUnpack(buf2->ogGetPixel(0, 0), r, g, b); // cout << "r: " << (uInt32)r << endl; // cout << "g: " << (uInt32)g << endl; // cout << "b: " << (uInt32)b << endl; @@ -41,26 +41,26 @@ void testSetPixel(ogSurface& buf) { uInt32 xx,yy; - buf.Clear(buf.Pack(0,255,0)); - for (yy = 0; yy<=buf.GetMaxY(); yy++) - for (xx = 0; xx<=buf.GetMaxX(); xx++) - buf.SetPixel(xx,yy,xx*yy); + buf.ogClear(buf.ogPack(0,255,0)); + for (yy = 0; yy<=buf.ogGetMaxY(); yy++) + for (xx = 0; xx<=buf.ogGetMaxX(); xx++) + buf.ogSetPixel(xx,yy,xx*yy); getc(stdin); return; } // testSetPixel void testRect(ogSurface& buf) { uInt32 count; - if (buf.GetBPP()==8) + if (buf.ogGetBPP()==8) for (count=0; count<1000; count++) - buf.Rect(buf.GetMaxX() / 2 - count, buf.GetMaxY() / 2 - count, - buf.GetMaxX() / 2 + count, buf.GetMaxY() / 2 + count, + buf.ogRect(buf.ogGetMaxX() / 2 - count, buf.ogGetMaxY() / 2 - count, + buf.ogGetMaxX() / 2 + count, buf.ogGetMaxY() / 2 + count, count); else for (count=0; count<1000; count++) - buf.Rect(buf.GetMaxX() / 2 - count, buf.GetMaxY() / 2 - count, - buf.GetMaxX() / 2 + count, buf.GetMaxY() / 2 + count, - buf.Pack(count,count,count)); + buf.ogRect(buf.ogGetMaxX() / 2 - count, buf.ogGetMaxY() / 2 - count, + buf.ogGetMaxX() / 2 + count, buf.ogGetMaxY() / 2 + count, + buf.ogPack(count,count,count)); getc(stdin); return; } // testRect @@ -68,49 +68,49 @@ void testLine(ogSurface & buf) { uInt32 count; uInt32 colour; - buf.Clear(buf.Pack(0, 0, 0)); + buf.ogClear(buf.ogPack(0, 0, 0)); for (count = 150; count > 0; count--) { - buf.Line(buf.GetMaxX() / 2, buf.GetMaxY() / 2, - buf.GetMaxX(), count*4, buf.Pack(192, 192, 192)); + buf.ogLine(buf.ogGetMaxX() / 2, buf.ogGetMaxY() / 2, + buf.ogGetMaxX(), count*4, buf.ogPack(192, 192, 192)); } // for count getc(stdin); - if (buf.GetBPP()==8) - for (count=0; count<(buf.GetMaxX()+1); count+=2) { - buf.Line(count-10,-10,buf.GetMaxX()-count+10,buf.GetMaxY()+10,count); + if (buf.ogGetBPP()==8) + for (count=0; count<(buf.ogGetMaxX()+1); count+=2) { + buf.ogLine(count-10,-10,buf.ogGetMaxX()-count+10,buf.ogGetMaxY()+10,count); } // for else { colour = 255; - for (count = 0; count < (buf.GetMaxX()+1)/2; count+=4) { - buf.Line(buf.GetMaxX()/2, buf.GetMaxY()/2, - buf.GetMaxX()/2-count,buf.GetMaxY(), - buf.Pack(colour,colour,colour)); - buf.Line(buf.GetMaxX()/2, buf.GetMaxY()/2, - buf.GetMaxX()/2+count,buf.GetMaxY(), - buf.Pack(colour,colour,colour)); - buf.Line(buf.GetMaxX()/2, buf.GetMaxY()/2, - buf.GetMaxX()/2-count,0, - buf.Pack(0,colour,0)); - buf.Line(buf.GetMaxX()/2, buf.GetMaxY()/2, - buf.GetMaxX()/2+count,0, - buf.Pack(0,colour,0)); + for (count = 0; count < (buf.ogGetMaxX()+1)/2; count+=4) { + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX()/2-count,buf.ogGetMaxY(), + buf.ogPack(colour,colour,colour)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX()/2+count,buf.ogGetMaxY(), + buf.ogPack(colour,colour,colour)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX()/2-count,0, + buf.ogPack(0,colour,0)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX()/2+count,0, + buf.ogPack(0,colour,0)); --colour; } // for colour = 255; - for (count = 0; count < (buf.GetMaxY()+1)/2; count+=4) { - buf.Line(buf.GetMaxX()/2, buf.GetMaxY()/2, - 0, buf.GetMaxY()/2-count, - buf.Pack(colour,0,0)); - buf.Line(buf.GetMaxX()/2, buf.GetMaxY()/2, - 0, buf.GetMaxY()/2+count, - buf.Pack(colour,0,0)); - buf.Line(buf.GetMaxX()/2, buf.GetMaxY()/2, - buf.GetMaxX(), buf.GetMaxY()/2-count, - buf.Pack(0,0,colour)); - buf.Line(buf.GetMaxX()/2, buf.GetMaxY()/2, - buf.GetMaxX(), buf.GetMaxY()/2+count, - buf.Pack(0,0,colour)); + for (count = 0; count < (buf.ogGetMaxY()+1)/2; count+=4) { + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + 0, buf.ogGetMaxY()/2-count, + buf.ogPack(colour,0,0)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + 0, buf.ogGetMaxY()/2+count, + buf.ogPack(colour,0,0)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX(), buf.ogGetMaxY()/2-count, + buf.ogPack(0,0,colour)); + buf.ogLine(buf.ogGetMaxX()/2, buf.ogGetMaxY()/2, + buf.ogGetMaxX(), buf.ogGetMaxY()/2+count, + buf.ogPack(0,0,colour)); --colour; } // for } // else @@ -120,18 +120,18 @@ void testClear(ogSurface & buf) { uInt32 count; - if (buf.GetBPP()==8) + if (buf.ogGetBPP()==8) for (count=0; count<256; count++) - buf.Clear(count); + buf.ogClear(count); else { for (count=0; count<256; count+=8) - buf.Clear(buf.Pack(count,0,0)); + buf.ogClear(buf.ogPack(count,0,0)); for (count=0; count<256; count+=8) - buf.Clear(buf.Pack(0,count,0)); + buf.ogClear(buf.ogPack(0,count,0)); for (count=0; count<256; count+=8) - buf.Clear(buf.Pack(0,0,count)); + buf.ogClear(buf.ogPack(0,0,count)); for (count=0; count<256; count+=8) - buf.Clear(buf.Pack(count,count,count)); + buf.ogClear(buf.ogPack(count,count,count)); } // else getc(stdin); return; @@ -139,23 +139,23 @@ void testCircle(ogSurface & buf) { uInt32 count; - if (buf.GetBPP()==8) + if (buf.ogGetBPP()==8) for (count=0; count<1000; count++) - buf.Circle(buf.GetMaxX()/2,buf.GetMaxY()/2, count, count); + buf.ogCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2, count, count); else for (count=0; count<1000; count++) - buf.Circle(buf.GetMaxX()/2,buf.GetMaxY()/2,count,buf.Pack(count,0,count)); + buf.ogCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2,count,buf.ogPack(count,0,count)); getc(stdin); } // testCircle void testVFlip(ogSurface & buf) { - buf.VFlip(); + buf.ogVFlip(); getc(stdin); return; } // testVFlip void testHFlip(ogSurface & buf) { - buf.HFlip(); + buf.ogHFlip(); getc(stdin); return; } // testHFlip @@ -163,17 +163,17 @@ void testArc(ogSurface & buf) { uInt32 radius; uInt32 mid_x, mid_y; - mid_x = buf.GetMaxX()/2; - mid_y = buf.GetMaxY()/2; - if (buf.GetBPP()==8) { + mid_x = buf.ogGetMaxX()/2; + mid_y = buf.ogGetMaxY()/2; + if (buf.ogGetBPP()==8) { for (radius = 1; radius <9; radius++) { - buf.Arc(mid_x, mid_y, radius*10, 0, 90, radius*15); - buf.Arc(mid_x, mid_y, radius*10, 180,270, 249-(radius-1)*16); + buf.ogArc(mid_x, mid_y, radius*10, 0, 90, radius*15); + buf.ogArc(mid_x, mid_y, radius*10, 180,270, 249-(radius-1)*16); } // for } else { for (radius = 1; radius <255; radius++) { - buf.Arc(mid_x, mid_y, radius, 0, 90, buf.Pack(radius,radius,0)); - buf.Arc(mid_x, mid_y, radius, 180,270,buf.Pack(0,255-radius,255-radius)); + buf.ogArc(mid_x, mid_y, radius, 0, 90, buf.ogPack(radius,radius,0)); + buf.ogArc(mid_x, mid_y, radius, 180,270,buf.ogPack(0,255-radius,255-radius)); } // for } // else getchar(); @@ -181,36 +181,37 @@ } // testArc void testCubicBezierCurve(ogSurface & buf) { - buf.CubicBezierCurve(100, 100, + buf.ogCubicBezierCurve(100, 100, 300,50, 400,120, 350,300, - 25, buf.Pack(255,255,255)); + 25, buf.ogPack(255,255,255)); getchar(); return; } // testCubicBezierCurve void testCurve(ogSurface & buf) { - buf.Curve(10,10,100,30,35,160,20,buf.Pack(255,255,255)); + buf.ogCurve(10,10,100,30,35,160,20,buf.ogPack(255,255,255)); getchar(); return; } // testCurve + void testSprite(ogSurface & buf) { uInt32 count; uInt32 w,h; ogSprite * sprite = NULL; sprite = new ogSprite(); - buf.Clear(buf.Pack(0, 0, 0)); + buf.ogClear(buf.ogPack(0, 0, 0)); testLine(buf); - if (buf.GetBPP()==8) + if (buf.ogGetBPP()==8) sprite->Get(buf, - buf.GetMaxX()/2-80,buf.GetMaxY()/2-80, - buf.GetMaxX()/2+80,buf.GetMaxY()/2+80); + buf.ogGetMaxX()/2-80,buf.ogGetMaxY()/2-80, + buf.ogGetMaxX()/2+80,buf.ogGetMaxY()/2+80); else sprite->Get(buf, - buf.GetMaxX()/2-150,buf.GetMaxY()/2-150, - buf.GetMaxX()/2+150,buf.GetMaxY()/2+150); + buf.ogGetMaxX()/2-150,buf.ogGetMaxY()/2-150, + buf.ogGetMaxX()/2+150,buf.ogGetMaxY()/2+150); sprite->Save("test.spr"); delete sprite; @@ -218,23 +219,23 @@ sprite->Load("test.spr"); w = sprite->GetWidth()/2; h = sprite->GetHeight()/2; - buf.Clear(buf.Pack(0, 0, 0)); + buf.ogClear(buf.ogPack(0, 0, 0)); sprite->Put(buf,-10000,-10000); // test *really* off the screen sprite->Put(buf,10000,10000); // test *really* off the screen - sprite->Put(buf,buf.GetMaxX()/2-w,buf.GetMaxY()/2-h); + sprite->Put(buf,buf.ogGetMaxX()/2-w,buf.ogGetMaxY()/2-h); sprite->Put(buf,-w,-h); - sprite->Put(buf,buf.GetMaxX()/2-w,-h); - sprite->Put(buf,buf.GetMaxX()-w,-h); - sprite->Put(buf,-w,buf.GetMaxY()/2-h); - sprite->Put(buf,buf.GetMaxX()-w,buf.GetMaxY()/2-h); - sprite->Put(buf,-w,buf.GetMaxY()-h); - sprite->Put(buf,buf.GetMaxX()/2-w,buf.GetMaxY()-h); - sprite->Put(buf,buf.GetMaxX()-w,buf.GetMaxY()-h); + sprite->Put(buf,buf.ogGetMaxX()/2-w,-h); + sprite->Put(buf,buf.ogGetMaxX()-w,-h); + sprite->Put(buf,-w,buf.ogGetMaxY()/2-h); + sprite->Put(buf,buf.ogGetMaxX()-w,buf.ogGetMaxY()/2-h); + sprite->Put(buf,-w,buf.ogGetMaxY()-h); + sprite->Put(buf,buf.ogGetMaxX()/2-w,buf.ogGetMaxY()-h); + sprite->Put(buf,buf.ogGetMaxX()-w,buf.ogGetMaxY()-h); getc(stdin); for (count = 0; count < 256; count++) { - sprite->Put(buf,random() % (buf.GetMaxX()+sprite->GetWidth()) - sprite->GetWidth(), - random() % (buf.GetMaxY()+sprite->GetHeight()) - sprite->GetHeight()); + sprite->Put(buf,random() % (buf.ogGetMaxX()+sprite->GetWidth()) - sprite->GetWidth(), + random() % (buf.ogGetMaxY()+sprite->GetHeight()) - sprite->GetHeight()); } // for delete sprite; getc(stdin); @@ -248,19 +249,19 @@ blit = new ogBlit(); - buf.Clear(buf.Pack(0, 0, 0)); + buf.ogClear(buf.ogPack(0, 0, 0)); for (xx= 0; xx<= 20; xx++) { - buf.Line(128,0,128-xx*6,255,buf.Pack(255,255,255)); - buf.Line(128,0,128+xx*6,255,buf.Pack(255,255,255)); - buf.Line(128,255,128-xx*6,0,buf.Pack(255,255,255)); - buf.Line(128,255,128+xx*6,0,buf.Pack(255,255,255)); + buf.ogLine(128,0,128-xx*6,255,buf.ogPack(255,255,255)); + buf.ogLine(128,0,128+xx*6,255,buf.ogPack(255,255,255)); + buf.ogLine(128,255,128-xx*6,0,buf.ogPack(255,255,255)); + buf.ogLine(128,255,128+xx*6,0,buf.ogPack(255,255,255)); } // for - buf.FillCircle(128,128,60,buf.Pack(255,255,255)); + buf.ogFillCircle(128,128,60,buf.ogPack(255,255,255)); blit->Get(buf,0,0,255,255); - for (yy = 0; yy<=(int32)buf.GetMaxY(); yy++) - for (xx = 0; xx<=(int32)buf.GetMaxX(); xx++) - buf.SetPixel(xx,yy,xx*yy); + for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++) + for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++) + buf.ogSetPixel(xx,yy,xx*yy); blit->Save("test.blt"); blit2 = new ogBlit(*blit, true); @@ -273,50 +274,50 @@ blit->Put(buf,10000,10000); // test *really* off the screen blit->Put(buf,-128,-128); - blit->Put(buf,buf.GetMaxX()/2-128,-128); - blit->Put(buf,buf.GetMaxX()-128,-128); - blit->Put(buf,-128,buf.GetMaxY()/2-128); - blit->Put(buf,buf.GetMaxX()/2-128,buf.GetMaxY()/2-128); - blit->Put(buf,buf.GetMaxX()-128,buf.GetMaxY()/2-128); - blit->Put(buf,-128,buf.GetMaxY()-128); - blit->Put(buf,buf.GetMaxX()/2-128,buf.GetMaxY()-128); - blit->Put(buf,buf.GetMaxX()-128,buf.GetMaxY()-128); + blit->Put(buf,buf.ogGetMaxX()/2-128,-128); + blit->Put(buf,buf.ogGetMaxX()-128,-128); + blit->Put(buf,-128,buf.ogGetMaxY()/2-128); + blit->Put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128); + blit->Put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()/2-128); + blit->Put(buf,-128,buf.ogGetMaxY()-128); + blit->Put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()-128); + blit->Put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()-128); getc(stdin); - buf.Clear(buf.Pack(0, 0, 0)); - for (yy = 0; yy<=(int32)buf.GetMaxY(); yy++) - for (xx = 0; xx<=(int32)buf.GetMaxX(); xx++) - buf.SetPixel(xx,yy,xx*yy); + buf.ogClear(buf.ogPack(0, 0, 0)); + for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++) + for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++) + buf.ogSetPixel(xx,yy,xx*yy); blit->GetBlitWithMask(buf, - buf.GetMaxX()/2-blit->GetWidth(), - buf.GetMaxY()/2-blit->GetHeight()); - buf.Clear(buf.Pack(0, 0, 0)); + buf.ogGetMaxX()/2-blit->GetWidth(), + buf.ogGetMaxY()/2-blit->GetHeight()); + buf.ogClear(buf.ogPack(0, 0, 0)); blit->Put(buf,-10000,-10000); // test *really* off the screen blit->Put(buf,10000,10000); // test *really* off the screen blit->Put(buf,-128,-128); - blit->Put(buf,buf.GetMaxX()/2-128,-128); - blit->Put(buf,buf.GetMaxX()-128,-128); - blit->Put(buf,-128,buf.GetMaxY()/2-128); - blit->Put(buf,buf.GetMaxX()/2-128,buf.GetMaxY()/2-128); - blit->Put(buf,buf.GetMaxX()-128,buf.GetMaxY()/2-128); - blit->Put(buf,-128,buf.GetMaxY()-128); - blit->Put(buf,buf.GetMaxX()/2-128,buf.GetMaxY()-128); - blit->Put(buf,buf.GetMaxX()-128,buf.GetMaxY()-128); + blit->Put(buf,buf.ogGetMaxX()/2-128,-128); + blit->Put(buf,buf.ogGetMaxX()-128,-128); + blit->Put(buf,-128,buf.ogGetMaxY()/2-128); + blit->Put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128); + blit->Put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()/2-128); + blit->Put(buf,-128,buf.ogGetMaxY()-128); + blit->Put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()-128); + blit->Put(buf,buf.ogGetMaxX()-128,buf.ogGetMaxY()-128); getc(stdin); for (count = 0; count < 1000; count++) { - blit->Put(buf,random() % (buf.GetMaxX()+blit->GetWidth()) - blit->GetWidth(), - random() % (buf.GetMaxY()+blit->GetHeight()) - blit->GetHeight()); + blit->Put(buf,random() % (buf.ogGetMaxX()+blit->GetWidth()) - blit->GetWidth(), + random() % (buf.ogGetMaxY()+blit->GetHeight()) - blit->GetHeight()); } // for getc(stdin); - for (yy = 0; yy<=(int32)buf.GetMaxY(); yy++) - for (xx = 0; xx<=(int32)buf.GetMaxX(); xx++) - buf.SetPixel(xx,yy,xx*yy); + for (yy = 0; yy<=(int32)buf.ogGetMaxY(); yy++) + for (xx = 0; xx<=(int32)buf.ogGetMaxX(); xx++) + buf.ogSetPixel(xx,yy,xx*yy); - blit->GetBlitWithMask(buf,buf.GetMaxX()/2,buf.GetMaxY()-128); - buf.Clear(buf.Pack(128,128,128)); - blit->Put(buf,buf.GetMaxX()/2-128,buf.GetMaxY()/2-128); + blit->GetBlitWithMask(buf,buf.ogGetMaxX()/2,buf.ogGetMaxY()-128); + buf.ogClear(buf.ogPack(128,128,128)); + blit->Put(buf,buf.ogGetMaxX()/2-128,buf.ogGetMaxY()/2-128); getc(stdin); delete blit; delete blit2; @@ -330,59 +331,59 @@ ogSurface * buf2 = new ogSurface(); ogSurface * blitsource = new ogSurface(); uInt32 xx,yy,count,colour; - buf.Clear(buf.Pack(0, 0, 0)); - if (!buf2->Clone(buf)) cout << "Clone failed!!!" << endl; - if (!blitsource->Clone(buf)) cout << "Clone failed!!" << endl; + buf.ogClear(buf.ogPack(0, 0, 0)); + if (!buf2->ogClone(buf)) cout << "Clone failed!!!" << endl; + if (!blitsource->ogClone(buf)) cout << "Clone failed!!" << endl; colour = 255; - for (count = 0; count < (buf2->GetMaxX()+1)/2; count+=4) { - buf2->Line(buf2->GetMaxX()/2, buf2->GetMaxY()/2, - buf2->GetMaxX()/2-count,buf2->GetMaxY(), - buf2->Pack(colour,colour,colour)); - buf2->Line(buf2->GetMaxX()/2, buf2->GetMaxY()/2, - buf2->GetMaxX()/2+count,buf2->GetMaxY(), - buf2->Pack(colour,colour,colour)); - buf2->Line(buf2->GetMaxX()/2, buf2->GetMaxY()/2, - buf2->GetMaxX()/2-count,0, - buf2->Pack(0,colour,0)); - buf2->Line(buf2->GetMaxX()/2, buf2->GetMaxY()/2, - buf2->GetMaxX()/2+count,0, - buf2->Pack(0,colour,0)); + for (count = 0; count < (buf2->ogGetMaxX()+1)/2; count+=4) { + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX()/2-count,buf2->ogGetMaxY(), + buf2->ogPack(colour,colour,colour)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX()/2+count,buf2->ogGetMaxY(), + buf2->ogPack(colour,colour,colour)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX()/2-count,0, + buf2->ogPack(0,colour,0)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX()/2+count,0, + buf2->ogPack(0,colour,0)); --colour; } // for colour = 255; - for (count = 0; count < (buf.GetMaxY()+1)/2; count+=4) { - buf2->Line(buf2->GetMaxX()/2, buf2->GetMaxY()/2, - 0, buf2->GetMaxY()/2-count, - buf2->Pack(colour,0,0)); - buf2->Line(buf2->GetMaxX()/2, buf2->GetMaxY()/2, - 0, buf2->GetMaxY()/2+count, - buf2->Pack(colour,0,0)); - buf2->Line(buf2->GetMaxX()/2, buf2->GetMaxY()/2, - buf2->GetMaxX(), buf2->GetMaxY()/2-count, - buf2->Pack(0,0,colour)); - buf2->Line(buf2->GetMaxX()/2, buf2->GetMaxY()/2, - buf2->GetMaxX(), buf2->GetMaxY()/2+count, - buf2->Pack(0,0,colour)); + for (count = 0; count < (buf.ogGetMaxY()+1)/2; count+=4) { + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + 0, buf2->ogGetMaxY()/2-count, + buf2->ogPack(colour,0,0)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + 0, buf2->ogGetMaxY()/2+count, + buf2->ogPack(colour,0,0)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX(), buf2->ogGetMaxY()/2-count, + buf2->ogPack(0,0,colour)); + buf2->ogLine(buf2->ogGetMaxX()/2, buf2->ogGetMaxY()/2, + buf2->ogGetMaxX(), buf2->ogGetMaxY()/2+count, + buf2->ogPack(0,0,colour)); --colour; } // for - for (yy = 0; yy<=buf2->GetMaxY(); yy++) - for (xx = 0; xx<=buf2->GetMaxX(); xx++) - buf2->SetPixel(xx,yy, xx*yy); + for (yy = 0; yy<=buf2->ogGetMaxY(); yy++) + for (xx = 0; xx<=buf2->ogGetMaxX(); xx++) + buf2->ogSetPixel(xx,yy, xx*yy); for (count = 0; count<200; count++) - blitsource->FillCircle(random() % blitsource->GetMaxX(), random() % blitsource->GetMaxY(), - random() % 35+1,blitsource->Pack(255,255,255)); + blitsource->ogFillCircle(random() % blitsource->ogGetMaxX(), random() % blitsource->ogGetMaxY(), + random() % 35+1,blitsource->ogPack(255,255,255)); - blit->Get(*blitsource,0,0,blitsource->GetMaxX(),blitsource->GetMaxY()); + blit->Get(*blitsource,0,0,blitsource->ogGetMaxX(),blitsource->ogGetMaxY()); blit->Save("bigblit.blt"); delete blit; blit = new ogBlit; blit->Load("bigblit.blt"); for (count = 0; count<=256; count+=4) { - for (yy = 0; yy<=buf2->GetMaxY(); yy++) - for (xx = 0; xx<=buf2->GetMaxX(); xx++) - buf2->SetPixel(xx,yy,xx*yy*count); + for (yy = 0; yy<=buf2->ogGetMaxY(); yy++) + for (xx = 0; xx<=buf2->ogGetMaxX(); xx++) + buf2->ogSetPixel(xx,yy,xx*yy*count); blit->GetBlitWithMask(*buf2,0,0); blit->Put(buf,0,0); @@ -402,21 +403,21 @@ ogSurface * buf2 = NULL; buf2 = new ogSurface(); blit = new ogBlit(); - buf.Clear(buf.Pack(0, 0, 0)); - buf.FillCircle(buf.GetMaxX()/2,buf.GetMaxY()/2,14,buf.Pack(255,255,255)); - blit->Get(buf,buf.GetMaxX()/2-20,buf.GetMaxY()/2-20, - buf.GetMaxX()/2+20,buf.GetMaxY()/2+20); + buf.ogClear(buf.ogPack(0, 0, 0)); + buf.ogFillCircle(buf.ogGetMaxX()/2,buf.ogGetMaxY()/2,14,buf.ogPack(255,255,255)); + blit->Get(buf,buf.ogGetMaxX()/2-20,buf.ogGetMaxY()/2-20, + buf.ogGetMaxX()/2+20,buf.ogGetMaxY()/2+20); blit->Put(buf,0,0); - for (count=0; count<(int32)buf.GetMaxX(); count++) - buf.Line(count,0,count,buf.GetMaxY(),count); - buf2->Clone(buf); + for (count=0; count<(int32)buf.ogGetMaxX(); count++) + buf.ogLine(count,0,count,buf.ogGetMaxY(),count); + buf2->ogClone(buf); blit->GetBlitWithMask(*buf2,10,10); - buf.Clear(buf.Pack(63,63,63)); - for (count=-40; count<(int32)buf.GetMaxX()+10; count++) { - blit->GetBlitWithMask(*buf2,count,buf2->GetMaxY()/2-20); - blit->Put(buf,count,buf.GetMaxY()/2-20); - blit->GetBlitWithMask(*buf2,buf2->GetMaxX()/2-20,count); - blit->Put(buf,buf.GetMaxX()/2-20,count); + buf.ogClear(buf.ogPack(63,63,63)); + for (count=-40; count<(int32)buf.ogGetMaxX()+10; count++) { + blit->GetBlitWithMask(*buf2,count,buf2->ogGetMaxY()/2-20); + blit->Put(buf,count,buf.ogGetMaxY()/2-20); + blit->GetBlitWithMask(*buf2,buf2->ogGetMaxX()/2-20,count); + blit->Put(buf,buf.ogGetMaxX()/2-20,count); } getc(stdin); delete blit; @@ -428,11 +429,11 @@ uInt32 count; testRect(buf); for (count=0; count<256; count++) - buf.SetPalette(count,count,count,count); - if (buf.SavePalette("test.pal")==false) cout << "SavePal() failed" << endl; + buf.ogSetPalette(count,count,count,count); + if (buf.ogSavePalette("test.pal")==false) cout << "SavePal() failed" << endl; for (count=0; count<256; count++) - buf.SetPalette(count,0,0,0); - if (buf.LoadPalette("test.pal")==false) cout << "LoadPal() failed" << endl; + buf.ogSetPalette(count,0,0,0); + if (buf.ogLoadPalette("test.pal")==false) cout << "LoadPal() failed" << endl; testRect(buf); } // testSaveLoadPal @@ -440,12 +441,12 @@ testPolygon(ogSurface & buf) { ogPoint2d points[16]; uInt32 count; - buf.Clear(buf.Pack(0, 0, 0)); + buf.ogClear(buf.ogPack(0, 0, 0)); for (count=0; count<16; count++) { - points[count].x = random() % buf.GetMaxX(); - points[count].y = random() % buf.GetMaxY(); + points[count].x = random() % buf.ogGetMaxX(); + points[count].y = random() % buf.ogGetMaxY(); } // for - buf.FillPolygon(16, points, buf.Pack(random() & 255,random() & 255,random() & 255)); + buf.ogFillPolygon(16, points, buf.ogPack(random() & 255,random() & 255,random() & 255)); getc(stdin); return; } // testPolygon @@ -455,13 +456,13 @@ ogPoint2d points[8]; uInt32 i; for (i=0; i<8; i++) { - points[i].x = random() % buf.GetMaxX(); - points[i].y = random() % buf.GetMaxY(); + points[i].x = random() % buf.ogGetMaxX(); + points[i].y = random() % buf.ogGetMaxY(); } // for - buf.Clear(buf.Pack(0, 0, 0)); - buf.Polygon(8, points, buf.Pack(22,229,52)); - buf.Spline(8, points, 24, buf.Pack(64,64,255)); - buf.BSpline(8, points, 24, buf.Pack(255,128,128)); + buf.ogClear(buf.ogPack(0, 0, 0)); + buf.ogPolygon(8, points, buf.ogPack(22,229,52)); + buf.ogSpline(8, points, 24, buf.ogPack(64,64,255)); + buf.ogBSpline(8, points, 24, buf.ogPack(255,128,128)); getchar(); return; } // testSpline @@ -478,7 +479,7 @@ for (yy = 0; yyGetHeight(); yy++) { for (xx = 0; xx<79; xx++) - if ((buf.GetPixel(xx, yy) & buf.GetAlphaMasker()) == 0) + if ((buf.ogGetPixel(xx, yy) & buf.ogGetAlphaMasker()) == 0) cout << " "; else cout << "*"; @@ -496,13 +497,13 @@ ogRGBA8 colours[4]; r = g = b = 0; - points[0].x = buf.GetMaxX() - 150; + points[0].x = buf.ogGetMaxX() - 150; points[0].y = 0; - points[1].x = buf.GetMaxX(); + points[1].x = buf.ogGetMaxX(); points[1].y = 0; - points[2].x = buf.GetMaxX(); + points[2].x = buf.ogGetMaxX(); points[2].y = 150; - points[3].x = buf.GetMaxX() - 250; + points[3].x = buf.ogGetMaxX() - 250; points[3].y = 250; colours[0].red = 255; colours[0].green = 0; @@ -520,7 +521,7 @@ colours[3].green = 63; colours[3].blue = 63; colours[3].alpha = 255; - buf.FillGouraudPolygon(4, points, colours); + buf.ogFillGouraudPolygon(4, points, colours); getc(stdin); return; } // testGouraud @@ -529,10 +530,10 @@ testCopyBuf(ogSurface & buf) { ogSurface * buf2 = new ogSurface(); ogPixelFmt pixFmt; - buf.GetPixFmt(pixFmt); - buf2->Create(400, 400, OG_PIXFMT_32BPP); - buf2->Clear(buf2->Pack(255, 128, 255)); - buf.CopyBuf(0, 0, *buf2, 0, 0, buf2->GetMaxX(), buf2->GetMaxY()); + buf.ogGetPixFmt(pixFmt); + buf2->ogCreate(400, 400, OG_PIXFMT_32BPP); + buf2->ogClear(buf2->ogPack(255, 128, 255)); + buf.ogCopyBuf(0, 0, *buf2, 0, 0, buf2->ogGetMaxX(), buf2->ogGetMaxY()); delete buf2; getc(stdin); return; @@ -542,7 +543,7 @@ testFillRect(ogSurface & buf) { uInt32 count; for (count = 100; count > 0; count--) { - buf.FillRect(count, count, 0, 0, buf.Pack(count*2, count*2, count*2)); + buf.ogFillRect(count, count, 0, 0, buf.ogPack(count*2, count*2, count*2)); } getc(stdin); @@ -553,16 +554,16 @@ cout << "Starting program" << endl; #ifdef __DJGPP__ buf = new ogDisplay_VESA(); - buf->Create(800, 600, OG_PIXFMT_16BPP); + buf->ogCreate(800, 600, OG_PIXFMT_32BPP); #else buf = new ogSurface(); - if (buf->Create(1024, 768, OG_PIXFMT_16BPP)==false) exit(1); + if (buf->ogCreate(1024, 768, OG_PIXFMT_16BPP)==false) exit(1); #endif srandom(time(NULL)); // buf->SetBlending(true); // buf->SetAlpha(127); - buf->SetAntiAliasing(true); + buf->ogSetAntiAliasing(true); //cout << "testPixCon()" << endl; // testPixCon(); diff --git a/src/lib/objgfx40/objgfx40.cpp b/src/lib/objgfx40/objgfx40.cpp index 4cbc6ab..9ca9cd6 100644 --- a/src/lib/objgfx40/objgfx40.cpp +++ b/src/lib/objgfx40/objgfx40.cpp @@ -170,7 +170,7 @@ currentEdge = activeEdges; while (currentEdge!=NULL) { --currentEdge->count; - if (0 == currentEdge->count) { + if (currentEdge->count == 0) { // this edge is finished, so remove it from the AET *currentEdgePtr = currentEdge->nextEdge; // I'm thinking I should dispose currentEdge here!? @@ -328,13 +328,12 @@ newEdgePtr->xDirection = ((deltaX = x2-x1) > 0) ? 1 : -1; newEdgePtr -> rStepY = ((c2.red - c1.red +1) << 16) / deltaY; - newEdgePtr -> rIncY = 0; newEdgePtr -> gStepY = ((c2.green - c1.green +1) << 16) / deltaY; - newEdgePtr -> gIncY = 0; newEdgePtr -> bStepY = ((c2.blue - c1.blue +1) << 16) / deltaY; - newEdgePtr -> bIncY = 0; newEdgePtr -> aStepY = ((c2.alpha - c1.alpha +1) << 16) / deltaY; - newEdgePtr -> aIncY = 0; + + newEdgePtr -> rIncY = newEdgePtr -> gIncY = 0; + newEdgePtr -> bIncY = newEdgePtr -> aIncY = 0; width = abs(deltaX); newEdgePtr->x = x1; @@ -356,7 +355,7 @@ if ((followingEdge == NULL) || (followingEdge->startY > y1) || ((followingEdge->startY == y1) && - (followingEdge->x>=x1))) { + (followingEdge->x >= x1))) { newEdgePtr->nextEdge = followingEdge; *followingEdgeLink = newEdgePtr; break; @@ -421,7 +420,7 @@ if (currentEdge != NULL) { if (currentEdge->x > leftX) - destObject.HLine(leftX, currentEdge->x-1, yToScan, colour); + destObject.ogHLine(leftX, currentEdge->x-1, yToScan, colour); currentEdge = currentEdge->nextEdge; } // if currentEdge != NULL } // while @@ -493,20 +492,17 @@ dist = currentEdge->x - leftX; rStepX = (dR << 16) / dist; - rIncX = 0; gStepX = (dG << 16) / dist; - gIncX = 0; bStepX = (dB << 16) / dist; - bIncX = 0; aStepX = (dA << 16) / dist; - aIncX = 0; + rIncX = gIncX = bIncX = aIncX = 0; for (count = leftX; count < currentEdge->x; count++) { - destObject.SetPixel(count, yToScan, - lR + (rIncX >> 16), - lG + (gIncX >> 16), - lB + (bIncX >> 16), - lA + (aIncX >> 16) ); + destObject.ogSetPixel(count, yToScan, + lR + (rIncX >> 16), + lG + (gIncX >> 16), + lB + (bIncX >> 16), + lA + (aIncX >> 16) ); rIncX += rStepX; gIncX += gStepX; bIncX += bStepX; @@ -533,7 +529,7 @@ swapOccurred = false; currentEdgePtr = &activeEdges; currentEdge = activeEdges; - while (currentEdge->nextEdge!=NULL) { + while (currentEdge->nextEdge != NULL) { if (currentEdge->x > currentEdge->nextEdge->x) { // the second edge has a lower x than the first // swap them in the AET @@ -555,7 +551,7 @@ ogEdgeState * tmpEdge; tmpEdge = globalEdges; // first walk the global edges and delete any non-null nodes - while (tmpEdge!=NULL) { + while (tmpEdge != NULL) { edge = tmpEdge; tmpEdge = edge->nextEdge; delete edge; @@ -563,7 +559,7 @@ tmpEdge = activeEdges; // next walk the activeEdges and delete any non-null nodes. Note that this should // always be null - while (tmpEdge!=NULL) { + while (tmpEdge != NULL) { edge = tmpEdge; tmpEdge = edge->nextEdge; delete edge; @@ -647,29 +643,29 @@ } // if dx = (x2-x1); - if (dx>=0) xDir=1; else { dx = -dx; xDir=-1; } + if (dx >= 0) xDir=1; else { dx = -dx; xDir=-1; } // dx = abs(dx); dy = (y2 - y1); - if (0 == dy) { - HLine(x1, x2, y1, colour); + if (dy == 0) { + ogHLine(x1, x2, y1, colour); return; } - if (0 == dx) { - VLine(x1, y1, y2, colour); + if (dx == 0) { + ogVLine(x1, y1, y2, colour); return; } - Unpack(colour, r, g, b, a); + ogUnpack(colour, r, g, b, a); - if (!IsBlending()) a = 255; + if (!ogIsBlending()) a = 255; for (i = 0; i < 32; i++) { alphas[i] = static_cast(INTENSITIES[i]*a + 0.5f); } // for - oldBlending = SetBlending(true); + oldBlending = ogSetBlending(true); RawSetPixel(x1, y1, r, g, b, a); @@ -716,8 +712,8 @@ * the paired pixel. */ wgt = erracc >> intshift; - SetPixel(x1, y1, r, g, b, alphas[wgt]); - SetPixel(x1+xDir, y1, r, g, b, alphas[wgt ^ wgtCompMask]); + ogSetPixel(x1, y1, r, g, b, alphas[wgt]); + ogSetPixel(x1+xDir, y1, r, g, b, alphas[wgt ^ wgtCompMask]); } // while } else { @@ -746,15 +742,15 @@ * the paired pixel. */ wgt = erracc >> intshift; - SetPixel(x1, y1, r, g, b, alphas[wgt]); - SetPixel(x1, y1+1, r, g, b, alphas[wgt ^ wgtCompMask]); + ogSetPixel(x1, y1, r, g, b, alphas[wgt]); + ogSetPixel(x1, y1+1, r, g, b, alphas[wgt ^ wgtCompMask]); } // while } // else RawSetPixel(x2, y2, r, g, b, alphas[wgt]); } while (false); - SetBlending(oldBlending); + ogSetBlending(oldBlending); return; } // ogSurface::AARawLine @@ -826,16 +822,16 @@ uInt8 dR, dG, dB; do { - if (IsBlending()) { - Unpack(colour, sR, sG, sB, sA); - if (0 == sA) return; - if (255 == sA) break; + if (ogIsBlending()) { + ogUnpack(colour, sR, sG, sB, sA); + if (sA == 0) return; + if (sA == 255) break; inverseA = 255 - sA; - Unpack(RawGetPixel(x, y), dR, dG, dB); + ogUnpack(RawGetPixel(x, y), dR, dG, dB); newR = (dR * inverseA + sR * sA) >> 8; newG = (dG * inverseA + sG * sA) >> 8; newB = (dB * inverseA + sB * sA) >> 8; - colour = Pack(newR, newG, newB, inverseA); + colour = ogPack(newR, newG, newB, inverseA); } // if } while (false); @@ -906,20 +902,20 @@ uInt32 colour; do { - if (IsBlending()) { - if (0 == a) return; - if (255 == a) { - colour = Pack(r, g, b, a); + if (ogIsBlending()) { + if (a == 0) return; + if (a == 255) { + colour = ogPack(r, g, b, a); break; } // if a == 255 inverseA = 255 - a; - Unpack(RawGetPixel(x, y), dR, dG, dB); + ogUnpack(RawGetPixel(x, y), dR, dG, dB); newR = (dR * inverseA + r * a) >> 8; newG = (dG * inverseA + g * a) >> 8; newB = (dB * inverseA + b * a) >> 8; - colour = Pack(newR, newG, newB, inverseA); - } else colour = Pack(r, g, b, a); + colour = ogPack(newR, newG, newB, inverseA); + } else colour = ogPack(r, g, b, a); } while (false); switch (bytesPerPix) { @@ -1000,25 +996,25 @@ AndResult = 15; OrResult = 0; OutCode = 0; - if (x1<0) OutCode+=8; - if (x1>(int32)maxX) OutCode+=4; - if (y1<0) OutCode+=2; - if (y1>(int32)maxY) OutCode++; + if (x1 < 0) OutCode+=8; + if (x1 > (int32)maxX) OutCode+=4; + if (y1 < 0) OutCode+=2; + if (y1 > (int32)maxY) OutCode++; AndResult &= OutCode; OrResult |= OutCode; OutCode = 0; - if (x2<0) OutCode+=8; - if (x2>(int32)maxX) OutCode+=4; - if (y2<0) OutCode+=2; - if (y2>(int32)maxY) OutCode++; + if (x2 < 0) OutCode+=8; + if (x2 > (int32)maxX) OutCode+=4; + if (y2 < 0) OutCode+=2; + if (y2 > (int32)maxY) OutCode++; AndResult &= OutCode; OrResult |= OutCode; - if (AndResult>0) return false; - if (OrResult==0) return true; + if (AndResult > 0) return false; + if (OrResult == 0) return true; // some clipping is required here. @@ -1027,50 +1023,50 @@ tx2 = x2; ty2 = y2; - if (x1<0) { + if (x1 < 0) { ty1 = (x2*y1-x1*y2) / (x2-x1); tx1 = 0; } // if else - if (x2<0) { + if (x2 < 0) { ty2 = (x2*y1-x1*y2) / (x2-x1); tx2 = 0; } // elseif - if (x1>(int32)maxX) { + if (x1 > (int32)maxX) { ty1 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1); tx1 = maxX; } // if else - if (x2>(int32)maxX) { + if (x2 > (int32)maxX) { ty2 = (y1*(x2-maxX)+y2*(maxX-x1)) / (x2-x1); tx2 = maxX; } // elseif - if (((ty1<0) && (ty2<0)) || + if (((ty1 < 0) && (ty2 < 0)) || ((ty1>(int32)maxY) && (ty2>(int32)maxY))) return false; - if (ty1<0) { + if (ty1 < 0) { tx1 = (x1*y2-x2*y1) / (y2-y1); ty1 = 0; } // if else - if (ty2<0) { + if (ty2 < 0) { tx2 = (x1*y2-x2*y1) / (y2-y1); ty2 = 0; } // elseif - if (ty1>(int32)maxY) { + if (ty1 > (int32)maxY) { tx1 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1); ty1 = maxY; } // if else - if (ty2>(int32)maxY) { + if (ty2 > (int32)maxY) { tx2 = (x1*(y2-maxY)+x2*(maxY-y1)) / (y2-y1); ty2 = maxY; } // elseif - if (((uInt32)tx1>maxX) || ((uInt32)tx2>maxX)) return false; + if (((uInt32)tx1 > maxX) || ((uInt32)tx2 > maxX)) return false; x1 = tx1; y1 = ty1; @@ -1330,7 +1326,7 @@ * */ int32 tc; - if (!Avail()) return; + if (!ogAvail()) return; switch (BPP) { case 8: __asm__ __volatile__( @@ -1639,21 +1635,21 @@ #endif bool -ogSurface::Alias(ogSurface& src, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) { +ogSurface::ogAlias(ogSurface& src, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) { uInt32 tmp; - if (ogOwner == dataState) { - SetLastError(ogAlreadyOwner); + if (dataState == ogOwner) { + ogSetLastError(ogAlreadyOwner); return false; } // if - if (x2 eAngle) { tmp = sAngle; @@ -1720,32 +1716,32 @@ y = radius; p = 3-2*radius; - while (x<=y) { + while (x <= y) { alpha = (180.0/3.14159265358979)*atan((double)x/(double)y); if ((alpha >= sAngle) && (alpha <= eAngle)) - SetPixel(xCenter-x, yCenter-y, colour); + ogSetPixel(xCenter-x, yCenter-y, colour); if ((90-alpha >= sAngle) && (90-alpha <= eAngle)) - SetPixel(xCenter-y, yCenter-x, colour); + ogSetPixel(xCenter-y, yCenter-x, colour); if ((90+alpha >= sAngle) && (90+alpha <= eAngle)) - SetPixel(xCenter-y, yCenter+x, colour); + ogSetPixel(xCenter-y, yCenter+x, colour); if ((180-alpha >= sAngle) && (180-alpha <= eAngle)) - SetPixel(xCenter-x, yCenter+y, colour); + ogSetPixel(xCenter-x, yCenter+y, colour); if ((180+alpha >= sAngle) && (180+alpha <= eAngle)) - SetPixel(xCenter+x, yCenter+y, colour); + ogSetPixel(xCenter+x, yCenter+y, colour); if ((270-alpha >= sAngle) && (270-alpha <= eAngle)) - SetPixel(xCenter+y, yCenter+x, colour); + ogSetPixel(xCenter+y, yCenter+x, colour); if ((270+alpha >= sAngle) && (270+alpha <= eAngle)) - SetPixel(xCenter+y, yCenter-x, colour); + ogSetPixel(xCenter+y, yCenter-x, colour); if ((360-alpha >= sAngle) && (360-alpha <= eAngle)) - SetPixel(xCenter+x, yCenter-y, colour); + ogSetPixel(xCenter+x, yCenter-y, colour); if (p < 0) p += 4*x+6; @@ -1756,12 +1752,12 @@ ++x; } // while return; -} // ogSurface::Arc +} // ogSurface::ogArc bool -ogSurface::Avail(void) { - return ((buffer!=NULL) && (lineOfs!=NULL)); -} // ogSurface::Avail +ogSurface::ogAvail(void) { + return ((buffer != NULL) && (lineOfs != NULL)); +} // ogSurface::ogAvail static int32 calculate(float mu, int32 p0, int32 p1, int32 p2, int32 p3) { @@ -1775,15 +1771,15 @@ void -ogSurface::BSpline(uInt32 numPoints, ogPoint2d* points, uInt32 segments, +ogSurface::ogBSpline(uInt32 numPoints, ogPoint2d* points, uInt32 segments, uInt32 colour) { float mu, mudelta; int32 x1, y1, x2, y2; uInt32 n, h; - if (NULL == points) return; + if (points == NULL) return; - if ((numPoints < 4) || (numPoints > 255) || (0 == segments)) return; + if ((numPoints < 4) || (numPoints > 255) || (segments == 0)) return; mudelta = 1.0/segments; for (n=3; n= 0) { - SetPixel(xCenter+x, yCenter+y, colour); - SetPixel(xCenter+x, yCenter-y, colour); - SetPixel(xCenter-x, yCenter+y, colour); - SetPixel(xCenter-x, yCenter-y, colour); + ogSetPixel(xCenter+x, yCenter+y, colour); + ogSetPixel(xCenter+x, yCenter-y, colour); + ogSetPixel(xCenter-x, yCenter+y, colour); + ogSetPixel(xCenter-x, yCenter-y, colour); if (d + y > 0) { - y--; + --y; d -= 2*y+1; } // if if (x > d) { - x++; + ++x; d += 2*x+1; } // if } // while return; -} // ogSurface::Circle +} // ogSurface::ogCircle void -ogSurface::Clear(uInt32 colour) { +ogSurface::ogClear(uInt32 colour) { uInt32 height = 0; uInt32 xx, yy; uInt8 r, g, b, a; - if (!Avail()) return; + if (!ogAvail()) return; do { - if (IsBlending()) { - Unpack(colour, r, g, b, a); - if (0 == a) return; - if (255 == a) break; + if (ogIsBlending()) { + ogUnpack(colour, r, g, b, a); + if (a == 0) return; + if (a == 255) break; for (yy = 0; yy <= maxY; yy++) for (xx = 0; xx <= maxX; xx++) RawSetPixel(xx, yy, r, g, b, a); @@ -1966,50 +1962,50 @@ break; } // switch return; -} // ogSurface::Clear +} // ogSurface::ogClear bool -ogSurface::Clone(ogSurface& src) { +ogSurface::ogClone(ogSurface& src) { bool created; ogPixelFmt pixFmt; - if (ogNone == src.dataState) { - SetLastError(ogNoSurface); + if (src.dataState == ogNone) { + ogSetLastError(ogNoSurface); return false; } // if - src.GetPixFmt(pixFmt); - created = Create(src.maxX+1, src.maxY+1, pixFmt); + src.ogGetPixFmt(pixFmt); + created = ogCreate(src.maxX+1, src.maxY+1, pixFmt); if (!created) return false; *attributes = *src.attributes; - CopyPalette(src); - Copy(src); + ogCopyPalette(src); + ogCopy(src); return true; -} // ogSurface::Clone +} // ogSurface::ogClone void -ogSurface::Copy(ogSurface& src) { +ogSurface::ogCopy(ogSurface& src) { uInt32 pixMap[256]; uInt32 count, xCount, yCount; uInt32 xx, yy; uInt8 r, g, b, a; void * srcPtr; - if (!Avail()) return; - if (!src.Avail()) return; + if (!ogAvail()) return; + if (!src.ogAvail()) return; xCount = src.maxX+1; - if (xCount>maxX+1) xCount=maxX+1; + if (xCount > maxX+1) xCount = maxX+1; yCount = src.maxY+1; - if (yCount>maxY+1) yCount=maxY+1; + if (yCount > maxY+1) yCount = maxY+1; - if (IsBlending()) { + if (ogIsBlending()) { for (yy = 0; yy < yCount; yy++) for (xx = 0; xx < xCount; xx++) { - src.Unpack(src.RawGetPixel(xx, yy), r, g, b, a); + src.ogUnpack(src.RawGetPixel(xx, yy), r, g, b, a); RawSetPixel(xx, yy, r, g, b, a); } // for xx @@ -2019,10 +2015,10 @@ if (pixFmtID != src.pixFmtID) { if (src.bytesPerPix == 1) { for (xx = 0; xx < 256; xx++) - pixMap[xx] = Pack(src.pal[xx].red, - src.pal[xx].green, - src.pal[xx].blue, - src.pal[xx].alpha); + pixMap[xx] = ogPack(src.pal[xx].red, + src.pal[xx].green, + src.pal[xx].blue, + src.pal[xx].alpha); for (yy = 0; yy < yCount; yy++) for (xx = 0; xx < xCount; xx++) @@ -2030,8 +2026,8 @@ } else { // if src.bytesPerPix == 1 ogPixelFmt srcPixFmt, dstPixFmt; - src.GetPixFmt(srcPixFmt); - GetPixFmt(dstPixFmt); + src.ogGetPixFmt(srcPixFmt); + ogGetPixFmt(dstPixFmt); ogPixCon * pc = new ogPixCon(srcPixFmt, dstPixFmt); for (yy = 0; yy < yCount; yy++) @@ -2045,7 +2041,7 @@ xCount *= bytesPerPix; for (count = 0; count < yCount; count++) - if ((srcPtr = src.GetPtr(0, count)) == NULL) { + if ((srcPtr = src.ogGetPtr(0, count)) == NULL) { /* * if we are here then we couldn't get a direct memory pointer * from the source object. This means that it is not a normal @@ -2059,20 +2055,20 @@ srcPtr = malloc(xCount); // allocate space #endif if (srcPtr != NULL) { - src.CopyLineFrom(0, count, srcPtr, xCount); - CopyLineTo(0, count, srcPtr, xCount); + src.ogCopyLineFrom(0, count, srcPtr, xCount); + ogCopyLineTo(0, count, srcPtr, xCount); #ifdef __UBIXOS_KERNEL__ kfree(srcPtr); #else free(srcPtr); #endif } // if srcPtr!=NULL - } else CopyLineTo(0, count, srcPtr, xCount); + } else ogCopyLineTo(0, count, srcPtr, xCount); } // else -} // ogSurface::Copy +} // ogSurface::ogCopy void -ogSurface::CopyBuf(int32 dX1, int32 dY1, +ogSurface::ogCopyBuf(int32 dX1, int32 dY1, ogSurface& src, int32 sX1, int32 sY1, int32 sX2, int32 sY2) { uInt32 pixMap[256]; int32 xx, yy, count, xCount, yCount; @@ -2081,14 +2077,14 @@ ogPixCon * pc; ogPixelFmt srcPixFmt, dstPixFmt; - if (!Avail()) return; - if (!src.Avail()) return; + if (!ogAvail()) return; + if (!src.ogAvail()) return; - if ((dX1>(int32)maxX) || (dY1>(int32)maxY)) return; + if ((dX1 > (int32)maxX) || (dY1 > (int32)maxY)) return; // if any of the source buffer is out of bounds then do nothing - if (( (uInt32)sX1>src.maxX) || ((uInt32)sX2>src.maxX) || - ( (uInt32)sY1>src.maxY) || ((uInt32)sY2>src.maxY)) return; + if (( (uInt32)sX1 > src.maxX) || ((uInt32)sX2 > src.maxX) || + ( (uInt32)sY1 > src.maxY) || ((uInt32)sY2 > src.maxY)) return; if (sX1 > sX2) { xx = sX1; @@ -2120,35 +2116,35 @@ dY1 = 0; } // if - if ((dX1+xCount<0) || (dY1+yCount<0)) return; + if ((dX1+xCount < 0) || (dY1+yCount < 0)) return; - if (IsBlending()) { + if (ogIsBlending()) { for (yy = 0; yy < yCount; yy++) for (xx = 0; xx < xCount; xx++) { - src.Unpack(src.RawGetPixel(sX1+xx, sY1+yy), r, g, b, a); + src.ogUnpack(src.RawGetPixel(sX1+xx, sY1+yy), r, g, b, a); RawSetPixel(dX1+xx, dY1+yy, r, g, b, a); } // for xx } // if IsBlending if (pixFmtID != src.pixFmtID) { - if (1 == src.bytesPerPix) { - for (xx=0; xx<256; xx++) - pixMap[xx] = Pack(src.pal[xx].red, - src.pal[xx].green, - src.pal[xx].blue, - src.pal[xx].alpha); + if (src.bytesPerPix == 1) { + for (xx = 0; xx < 256; xx++) + pixMap[xx] = ogPack(src.pal[xx].red, + src.pal[xx].green, + src.pal[xx].blue, + src.pal[xx].alpha); for (yy = 0; yy < yCount; yy++) for (xx = 0; xx < xCount; xx++) RawSetPixel(dX1+xx,dY1+yy, - pixMap[src.GetPixel(sX1+xx,sY1+yy)]); + pixMap[src.ogGetPixel(sX1+xx,sY1+yy)]); } else { - src.GetPixFmt(srcPixFmt); - GetPixFmt(dstPixFmt); + src.ogGetPixFmt(srcPixFmt); + ogGetPixFmt(dstPixFmt); pc = new ogPixCon(srcPixFmt, dstPixFmt); // allocate the pixel converter - if (NULL == pc) return; + if (pc == NULL) return; for (yy = 0; yy < yCount; yy++) for (xx = 0; xx < xCount; xx++) { @@ -2163,7 +2159,7 @@ xCount *= bytesPerPix; for (count = 0; count < yCount; count++) - if ((srcPtr = src.GetPtr(sX1, sY1+count)) == NULL) { + if ((srcPtr = src.ogGetPtr(sX1, sY1+count)) == NULL) { // if we are here then we couldn't get a direct memory pointer // from the source object. This means that it is not a normal // "memory" buffer and we have to use the implementation inspecific @@ -2176,20 +2172,20 @@ srcPtr = malloc(xCount); // allocate space #endif if (srcPtr != NULL) { - src.CopyLineFrom(sX1, sY1+count, srcPtr, xCount); - CopyLineTo(dX1, dY1+count, srcPtr, xCount); + src.ogCopyLineFrom(sX1, sY1+count, srcPtr, xCount); + ogCopyLineTo(dX1, dY1+count, srcPtr, xCount); #ifdef __UBIXOS_KERNEL__ kfree(srcPtr); #else free(srcPtr); #endif } // if srcPtr!=NULL - } else CopyLineTo(dX1,dY1+count,srcPtr,xCount); + } else ogCopyLineTo(dX1,dY1+count,srcPtr,xCount); } // else -} // ogSurface::CopyBuf +} // ogSurface::ogCopyBuf void -ogSurface::CopyLineTo(uInt32 dx, uInt32 dy, const void * src, uInt32 size) { +ogSurface::ogCopyLineTo(uInt32 dx, uInt32 dy, const void * src, uInt32 size) { /* * CopyLineTo() * @@ -2222,10 +2218,10 @@ #endif return; -} // ogSurface::CopyLineTo +} // ogSurface::ogCopyLineTo void -ogSurface::CopyLineFrom(uInt32 sx, uInt32 sy, void * dst, uInt32 size) { +ogSurface::ogCopyLineFrom(uInt32 sx, uInt32 sy, void * dst, uInt32 size) { /* * CopyLineFrom() * @@ -2258,22 +2254,22 @@ #endif return; -} // ogSurface::CopyLineFrom +} // ogSurface::ogCopyLineFrom void -ogSurface::CopyPalette(ogSurface& src) { - if (NULL == src.pal) return; - if (NULL == pal) pal = new ogRGBA8[256]; - if (NULL == pal) return; - src.GetPalette(pal); +ogSurface::ogCopyPalette(ogSurface& src) { + if (src.pal == NULL) return; + if (pal == NULL) pal = new ogRGBA8[256]; + if (pal == NULL) return; + src.ogGetPalette(pal); // memcpy(pal, src.pal, sizeof(ogRGBA8)*256); return; -} // ogSurface::CopyPalette +} // ogSurface::ogCopyPalette bool -ogSurface::Create(uInt32 _xRes, uInt32 _yRes, ogPixelFmt _pixFormat) { +ogSurface::ogCreate(uInt32 _xRes, uInt32 _yRes, ogPixelFmt _pixFormat) { /* - * ogSurface::Create() + * ogSurface::ogCreate() * Allocates memory for a buffer of size _xRes by _yRes with * the pixel format defined in _pixformat. Allocates memory * for pal and lineOfs. @@ -2297,7 +2293,7 @@ case 32: break; default: - SetLastError(ogBadBPP); + ogSetLastError(ogBadBPP); return false; } // switch @@ -2315,15 +2311,15 @@ do { - if ((NULL == newBuffer) || (NULL == newLineOfs) || - (NULL == newPal) || (NULL == newAttributes)) { - SetLastError(ogMemAllocFail); + if ((newBuffer == NULL) || (newLineOfs == NULL) || + (newPal == NULL) || (newAttributes == NULL)) { + ogSetLastError(ogMemAllocFail); break; // break out of do {...} while(false) } // if // check to see if we have already allocated memory .. if so, free it - if (ogOwner == dataState) { + if (dataState == ogOwner) { #ifdef __UBIXOS_KERNEL__ kfree(buffer); #else @@ -2349,7 +2345,7 @@ BPP = _pixFormat.BPP; bytesPerPix = (BPP + 7) >> 3; - SetPalette(DEFAULT_PALETTE); + ogSetPalette(DEFAULT_PALETTE); // memcpy(pal, DEFAULT_PALETTE, sizeof(ogRGBA8)*256); maxX = _xRes -1; @@ -2383,19 +2379,19 @@ else alphaMasker = ~0; - if (1 == bytesPerPix) { + if (bytesPerPix == 1) { pixFmtID = 0x08080808; // turn anti aliasing off by default for 8bpp modes - SetAntiAliasing(false); + ogSetAntiAliasing(false); } else { pixFmtID = (redFieldPosition) | (greenFieldPosition << 8) | (blueFieldPosition << 16) | (alphaFieldPosition << 24); - SetAntiAliasing(true); + ogSetAntiAliasing(true); } // else - Clear(Pack(0, 0, 0)); + ogClear(ogPack(0, 0, 0)); owner = this; status = true; @@ -2411,17 +2407,17 @@ if (newAttributes) delete newAttributes; return status; -} // ogSurface::Create +} // ogSurface::ogCreate void -ogSurface::CubicBezierCurve(int32 x1, int32 y1, int32 x2, int32 y2, +ogSurface::ogCubicBezierCurve(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, int32 x4, int32 y4, uInt32 segments, uInt32 colour) { float tX1, tY1, tX2, tY2, tX3, tY3, mu, mu2, mu3, mudelta; int32 xStart, yStart, xEnd, yEnd; uInt32 n; - if (segments<1) return; - if (segments>128) segments=128; + if (segments < 1) return; + if (segments > 128) segments=128; mudelta = 1.0/segments; mu = mudelta; @@ -2435,21 +2431,21 @@ xStart = x1; yStart = y1; - for (n=1; n(mu3*tX1+mu2*tX2+mu*tX3+x1 +0.5f); yEnd = static_cast(mu3*tY1+mu2*tY2+mu*tY3+y1 +0.5f); - Line(xStart, yStart, xEnd, yEnd, colour); + ogLine(xStart, yStart, xEnd, yEnd, colour); mu += mudelta; xStart = xEnd; yStart = yEnd; } // for return; -} // ogSurface::CubicBezierCurve +} // ogSurface::ogCubicBezierCurve void -ogSurface::Curve(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, +ogSurface::ogCurve(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uInt32 segments, uInt32 colour) { int64 ex, ey, fx, fy; int64 t1, t2; @@ -2463,20 +2459,20 @@ fx = ((int64)(x3-(2*x2)+x1) << 16) / (segments*segments); fy = ((int64)(y3-(2*y2)+y1) << 16) / (int64)(segments*segments); - while (--segments>0) { - t1=x3; - t2=y3; - x3=((int64)((fx*segments+ex)*segments) / 65536L)+x1; - y3=((int64)((fy*segments+ey)*segments) / 65536L)+y1; - Line(t1, t2, x3, y3, colour); + while (--segments > 0) { + t1 = x3; + t2 = y3; + x3 = ((int64)((fx*segments+ex)*segments) / 65536L)+x1; + y3 = ((int64)((fy*segments+ey)*segments) / 65536L)+y1; + ogLine(t1, t2, x3, y3, colour); } // while - Line(x3,y3,x1,y1,colour); + ogLine(x3, y3, x1, y1, colour); return; -} // ogSurface::Curve +} // ogSurface::ogCurve void -ogSurface::FillCircle(int32 xCenter, int32 yCenter, +ogSurface::ogFillCircle(int32 xCenter, int32 yCenter, uInt32 radius, uInt32 colour) { int32 x, y, d; x = 0; @@ -2485,8 +2481,8 @@ while (y >= 0) { if (d + y > 0) { - HLine(xCenter-x, xCenter+x, yCenter-y, colour); - if (y != 0) HLine(xCenter-x, xCenter+x, yCenter+y, colour); + ogHLine(xCenter-x, xCenter+x, yCenter-y, colour); + if (y != 0) ogHLine(xCenter-x, xCenter+x, yCenter+y, colour); --y; d -= 4*y+1; @@ -2499,7 +2495,7 @@ } // if } // while return; -} // ogSurface::FillCircle +} // ogSurface::ogFillCircle #if 0 !-/* Scan converts an edge from (X1,Y1) to (X2,Y2), not including the @@ -2687,7 +2683,7 @@ #endif void -ogSurface::FillGouraudPolygon(uInt32 numPoints, ogPoint2d* polyPoints, ogRGBA8 * colours) { +ogSurface::ogFillGouraudPolygon(uInt32 numPoints, ogPoint2d* polyPoints, ogRGBA8 * colours) { ogEdgeTable * edges; int32 currentY = ~0; @@ -2696,7 +2692,7 @@ edges = new ogEdgeTable(); - if (NULL == edges) return; // sanity check + if (edges == NULL) return; // sanity check edges->BuildGET_G(numPoints, polyPoints, colours); @@ -2709,25 +2705,25 @@ edges->AdvanceAET(); edges->XSortAET(); ++currentY; - if (currentY>(int32)maxY) break; // if we've gone past the bottom, stop + if (currentY > (int32)maxY) break; // if we've gone past the bottom, stop } // while delete edges; return; -} // ogSurface::FillGouraudPolygon +} // ogSurface::ogFillGouraudPolygon void -ogSurface::FillPolygon(uInt32 numPoints, ogPoint2d* polyPoints, uInt32 colour) { +ogSurface::ogFillPolygon(uInt32 numPoints, ogPoint2d* polyPoints, uInt32 colour) { ogEdgeTable * edges; int32 currentY = ~0; - if (numPoints<3) return; + if (numPoints < 3) return; - if (!IsBlending()) Polygon(numPoints, polyPoints, colour); + if (!ogIsBlending()) ogPolygon(numPoints, polyPoints, colour); edges = new ogEdgeTable(); - if (NULL == edges) return; // sanity check + if (edges == NULL) return; // sanity check edges->BuildGET(numPoints, polyPoints); @@ -2739,15 +2735,15 @@ edges->ScanOutAET(*this, currentY, colour); edges->AdvanceAET(); edges->XSortAET(); - currentY++; - if (currentY>(int32)maxY) break; // if we've gone past the bottom, stop + ++currentY; + if (currentY > (int32)maxY) break; // if we've gone past the bottom, stop } // while delete edges; return; -} // ogSurface::FillPolygon +} // ogSurface::ogFillPolygon void -ogSurface::FillRect(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) { +ogSurface::ogFillRect(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) { int32 yy, tmp; if (x2 < x1) { @@ -2763,13 +2759,13 @@ } // if if ((y2 < 0) || (y1 > (int32)maxY)) return; - if (y1 < 0) y1=0; - if (y2 > (int32)maxY) y2=maxY; + if (y1 < 0) y1 = 0; + if (y2 > (int32)maxY) y2 = maxY; for (yy = y1; yy <= y2; yy++) - HLine(x1, x2, yy, colour); -} // ogSurface::FillRect + ogHLine(x1, x2, yy, colour); +} // ogSurface::ogFillRect -void ogSurface::FillTriangle(int32 x1, int32 y1, int32 x2, int32 y2, +void ogSurface::ogFillTriangle(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uInt32 colour) { ogPoint2d points[3]; points[0].x = x1; @@ -2779,38 +2775,38 @@ points[2].x = x3; points[2].y = y3; - FillPolygon(3, points, colour); + ogFillPolygon(3, points, colour); return; -} // ogSurface::FillTriangle +} // ogSurface::ogFillTriangle uInt32 -ogSurface::GetAlpha(void) { +ogSurface::ogGetAlpha(void) { if (attributes != NULL) return attributes->defaultAlpha; else return 255L; -} // ogSurface::GetAlpha +} // ogSurface::ogGetAlpha ogErrorCode -ogSurface::GetLastError(void) { +ogSurface::ogGetLastError(void) { ogErrorCode tmp = lastError; lastError = ogOK; return tmp; -} // ogSurface::GetLastError +} // ogSurface::ogGetLastError void -ogSurface::GetPalette(ogRGBA8 _pal[256]) { +ogSurface::ogGetPalette(ogRGBA8 _pal[256]) { #ifdef __UBIXOS_KERNEL__ kmemcpy(_pal, pal, sizeof(_pal)); #else memcpy(_pal, pal, sizeof(_pal)); #endif return; -} // ogSurface::GetPalette +} // ogSurface::ogGetPalette void -ogSurface::GetPixFmt(ogPixelFmt& pixfmt) { +ogSurface::ogGetPixFmt(ogPixelFmt& pixfmt) { pixfmt.BPP = BPP; pixfmt.redFieldPosition = redFieldPosition; pixfmt.greenFieldPosition = greenFieldPosition; @@ -2821,14 +2817,14 @@ pixfmt.blueMaskSize = 8-blueShifter; pixfmt.alphaMaskSize = 8-alphaShifter; return; -} // ogSurface::GetPixFmt +} // ogSurface::ogGetPixFmt uInt32 -ogSurface::GetPixel(int32 x, int32 y) { +ogSurface::ogGetPixel(int32 x, int32 y) { uInt32 result; - if (!Avail()) return GetTransparentColor(); + if (!ogAvail()) return ogGetTransparentColor(); - if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return GetTransparentColor(); + if (((uInt32)x > maxX) || ((uInt32)y > maxY)) return ogGetTransparentColor(); switch (bytesPerPix) { case 4: @@ -2887,29 +2883,29 @@ break; } // switch return result; -} // ogSurface::GetPixel +} // ogSurface::ogGetPixel void * -ogSurface::GetPtr(uInt32 x, uInt32 y) { +ogSurface::ogGetPtr(uInt32 x, uInt32 y) { // return (Avail() ? ( (uInt8*)buffer+(lineOfs[y]+x*((BPP+7) >> 3)) ) : NULL ); return ((uInt8*)buffer+(lineOfs[y]+x*bytesPerPix)); -} // ogSurface::GetPtr +} // ogSurface::ogGetPtr uInt32 -ogSurface::GetTransparentColor(void) { - if (attributes) +ogSurface::ogGetTransparentColor(void) { + if (attributes != NULL) return attributes->transparentColor; else return 0; -} // ogSurface::GetTransparentColor +} // ogSurface::ogGetTransparentColor void -ogSurface::HFlip(void) { +ogSurface::ogHFlip(void) { void * tmpBuf1; void * tmpBuf2; uInt32 xWidth, count; - if (!Avail()) return; + if (!ogAvail()) return; xWidth = (maxX+1)*bytesPerPix; @@ -2923,10 +2919,10 @@ if ((tmpBuf1 != NULL) && (tmpBuf2 != NULL)) for (count = 0; count <= (maxY/2); count++) { - CopyLineFrom(0, count, tmpBuf1, xWidth); - CopyLineFrom(0, maxY-count,tmpBuf2, xWidth); - CopyLineTo(0, maxY-count,tmpBuf1, xWidth); - CopyLineTo(0, count, tmpBuf2, xWidth); + ogCopyLineFrom(0, count, tmpBuf1, xWidth); + ogCopyLineFrom(0, maxY-count,tmpBuf2, xWidth); + ogCopyLineTo(0, maxY-count,tmpBuf1, xWidth); + ogCopyLineTo(0, count, tmpBuf2, xWidth); } // for count #ifdef __UBIXOS_KERNEL__ @@ -2938,15 +2934,15 @@ #endif return; -} // ogSurface::HFlip +} // ogSurface::ogHFlip void -ogSurface::HLine(int32 x1, int32 x2, int32 y, uInt32 colour) { +ogSurface::ogHLine(int32 x1, int32 x2, int32 y, uInt32 colour) { int32 tmp; uInt8 r, g, b, a; - if (!Avail()) return; - if ((uInt32)y>maxY) return; + if (!ogAvail()) return; + if ((uInt32)y > maxY) return; if (x1 > x2) { tmp= x1; @@ -2958,10 +2954,10 @@ if (x2 > (int32)maxX) x2 = maxX; if (x2 < x1) return; - if (IsBlending()) { - Unpack(colour, r, g, b, a); - if (0 == a) return; - if (255 == a) { + if (ogIsBlending()) { + ogUnpack(colour, r, g, b, a); + if (a == 0) return; + if (a == 255) { for (tmp = x1; tmp <= x2; tmp++) RawSetPixel(tmp, y, r, g, b, a); return; @@ -3068,37 +3064,37 @@ break; } // switch return; -} // ogSurface::HLine +} // ogSurface::ogHLine bool -ogSurface::IsAntiAliasing(void) { - if (attributes) +ogSurface::ogIsAntiAliasing(void) { + if (attributes != NULL) return attributes->antiAlias; else return false; -} // ogSurface::IsAntiAliasing +} // ogSurface::ogIsAntiAliasing bool -ogSurface::IsBlending(void) { - if (attributes) +ogSurface::ogIsBlending(void) { + if (attributes != NULL) return attributes->blending; else return false; -} // ogSurface::IsBlending +} // ogSurface::ogIsBlending void -ogSurface::Line(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) { +ogSurface::ogLine(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) { if (ClipLine(x1,y1,x2,y2)) { - if (IsAntiAliasing()) + if (ogIsAntiAliasing()) AARawLine(x1, y1, x2, y2, colour); else RawLine(x1, y1, x2, y2, colour); } // if clipLine return; -} // ogSurface::Line +} // ogSurface::ogLine bool -ogSurface::LoadPalette(const char *palfile) { +ogSurface::ogLoadPalette(const char *palfile) { ogRGBA8 oldPalette[256]; #ifdef __UBIXOS_KERNEL__ fileDescriptor *f; @@ -3109,63 +3105,63 @@ bool result; if (!fileExists(palfile)) { - SetLastError(ogFileNotFound); + ogSetLastError(ogFileNotFound); return false; } // if - if (NULL == pal) { + if (pal == NULL) { pal = new ogRGBA8[256]; - if (NULL == pal) { - SetLastError(ogMemAllocFail); + if (pal == NULL) { + ogSetLastError(ogMemAllocFail); return false; } // if - SetPalette(DEFAULT_PALETTE); + ogSetPalette(DEFAULT_PALETTE); // memcpy(pal, DEFAULT_PALETTE, sizeof(ogRGBA8)*256); } // if - GetPalette(oldPalette); + ogGetPalette(oldPalette); // memcpy(&oldPalette, pal, sizeof(ogRGBA8)*256); - if ((f = fopen(palfile, "rb"))==NULL) return false; + if ((f = fopen(palfile, "rb")) == NULL) return false; lresult = fread(pal, sizeof(ogRGBA8), 256, f); - result = (256 == lresult); + result = (lresult == 256); if (!result) { - SetLastError(ogFileReadError); - SetPalette(oldPalette); + ogSetLastError(ogFileReadError); + ogSetPalette(oldPalette); // memcpy(pal, &oldPalette, sizeof(ogRGBA8)*256); } // if fclose(f); return result; -} // ogSurface::LoadPalette +} // ogSurface::ogLoadPalette void -ogSurface::Polygon(uInt32 numPoints, ogPoint2d* polyPoints, uInt32 colour) { +ogSurface::ogPolygon(uInt32 numPoints, ogPoint2d* polyPoints, uInt32 colour) { uInt32 count; - if (1 == numPoints) - SetPixel(polyPoints[0].x, polyPoints[0].y, colour); + if (numPoints == 1) + ogSetPixel(polyPoints[0].x, polyPoints[0].y, colour); else for (count = 0; count < numPoints; count++) - Line(polyPoints[count].x, polyPoints[count].y, - polyPoints[(count+1) % numPoints].x, - polyPoints[(count+1) % numPoints].y, - colour); + ogLine(polyPoints[count].x, polyPoints[count].y, + polyPoints[(count+1) % numPoints].x, + polyPoints[(count+1) % numPoints].y, + colour); return; -} // ogSurface::Polygon +} // ogSurface::ogPolygon void -ogSurface::Rect(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) { +ogSurface::ogRect(int32 x1, int32 y1, int32 x2, int32 y2, uInt32 colour) { int32 tmp; if ((x1 == x2) || (y1 == y2)) { if ((x1 == x2) && (y1 == y2)) - SetPixel(x1, y1, colour); + ogSetPixel(x1, y1, colour); else - Line(x1, y1, x2, y2, colour); + ogLine(x1, y1, x2, y2, colour); } else { @@ -3175,18 +3171,18 @@ y2 = tmp; } // if - HLine(x1, x2, y1, colour); // Horizline has built in clipping - VLine(x1, y1+1, y2-1, colour); // vertline has built in clipping too - VLine(x2, y1+1, y2-1, colour); - HLine(x1, x2, y2, colour); + ogHLine(x1, x2, y1, colour); // Horizline has built in clipping + ogVLine(x1, y1+1, y2-1, colour); // vertline has built in clipping too + ogVLine(x2, y1+1, y2-1, colour); + ogHLine(x1, x2, y2, colour); } // else return; -} // ogSurface::Rect +} // ogSurface::ogRect uInt32 -ogSurface::Pack(uInt8 red, uInt8 green, uInt8 blue) { +ogSurface::ogPack(uInt8 red, uInt8 green, uInt8 blue) { uInt32 idx, colour; uInt32 rd, gd, bd, dist, newdist; @@ -3196,7 +3192,7 @@ colour = ( (red << redFieldPosition) | (green << greenFieldPosition) | (blue << blueFieldPosition) | - (GetAlpha() << alphaFieldPosition) ); + (ogGetAlpha() << alphaFieldPosition) ); break; case 3: colour = ( (red << redFieldPosition) | @@ -3207,7 +3203,7 @@ colour = ((red >> redShifter) << redFieldPosition) | ((green >> greenShifter) << greenFieldPosition) | ((blue >> blueShifter) << blueFieldPosition) | - ((GetAlpha() >> alphaShifter) << alphaFieldPosition); + ((ogGetAlpha() >> alphaShifter) << alphaFieldPosition); break; case 1: colour = 0; @@ -3228,10 +3224,10 @@ return colour; -} // ogSurface::RGB +} // ogSurface::ogPack uInt32 -ogSurface::Pack(uInt8 red, uInt8 green, uInt8 blue, uInt8 alpha) { +ogSurface::ogPack(uInt8 red, uInt8 green, uInt8 blue, uInt8 alpha) { uInt32 idx, colour; uInt32 rd, gd, bd, dist, newdist; @@ -3272,10 +3268,10 @@ } // switch return colour; -} // ogSurface::Pack +} // ogSurface::ogPack bool -ogSurface::SavePalette(const char *palfile) { +ogSurface::ogSavePalette(const char *palfile) { #ifdef __UBIXOS_KERNEL__ fileDescriptor *f; #else @@ -3283,8 +3279,8 @@ #endif uInt32 lresult; - if (NULL == pal) { - SetLastError(ogNoPalette); + if (pal == NULL) { + ogSetLastError(ogNoPalette); return false; } @@ -3292,23 +3288,23 @@ lresult = fwrite(pal,sizeof(ogRGBA8),256,f); fclose(f); - if (256 == lresult) + if (lresult == 256) return true; else { - SetLastError(ogFileWriteError); + ogSetLastError(ogFileWriteError); return false; } // else -} // ogSurface::SavePal +} // ogSurface::ogSavePal void -ogSurface::Scale(ogSurface& src) { - ScaleBuf(0, 0, maxX, maxY, src, 0, 0, src.maxX, src.maxY); +ogSurface::ogScale(ogSurface& src) { + ogScaleBuf(0, 0, maxX, maxY, src, 0, 0, src.maxX, src.maxY); return; -} // ogSurface::Scale +} // ogSurface::ogScale void -ogSurface::ScaleBuf(int32 dX1, int32 dY1, int32 dX2, int32 dY2, +ogSurface::ogScaleBuf(int32 dX1, int32 dY1, int32 dX2, int32 dY2, ogSurface& src, int32 sX1, int32 sY1, int32 sX2, int32 sY2) { @@ -3325,8 +3321,8 @@ origdX1 = origdY1 = 0; // to keep the compiler from generating a warning - if (!Avail()) return; - if (!src.Avail()) return; + if (!ogAvail()) return; + if (!src.ogAvail()) return; if (sX1 > sX2) { xx = sX1; @@ -3342,8 +3338,8 @@ // if any part of the source falls outside the buffer then don't do anything - if (((uInt32)sX1>src.maxX) || ((uInt32)sX2>src.maxX) || - ((uInt32)sY1>src.maxY) || ((uInt32)sY2>src.maxY)) return; + if (((uInt32)sX1 > src.maxX) || ((uInt32)sX2 > src.maxX) || + ((uInt32)sY1 > src.maxY) || ((uInt32)sY2 > src.maxY)) return; if (dX1 > dX2) { xx = dX1; @@ -3394,7 +3390,7 @@ dX1 = 0; } - if (dY1<0) { + if (dY1 < 0) { yy = (yInc*(-dY1)) >> 16; sY1 += yy; sHeight -= yy; @@ -3409,7 +3405,7 @@ // the image if ((dWidth == sWidth) && (dHeight == sHeight)) { - CopyBuf(dX1, dY1, src,sX1,sY1,sX2,sY2); + ogCopyBuf(dX1, dY1, src, sX1, sY1, sX2, sY2); return; } @@ -3433,14 +3429,14 @@ if (pixFmtID != src.pixFmtID) { tmpBuf = new ogSurface(); - if (tmpBuf==NULL) return; + if (tmpBuf == NULL) return; if (sWidth*sHeight*src.bytesPerPix <= dWidth*dHeight*bytesPerPix) { // if the number of pixels in the source buffer is less than the // number of pixels in the dest buffer then... - GetPixFmt(pixFmt); - if (!tmpBuf->Create(sWidth, sHeight, pixFmt)) return; - tmpBuf->CopyPalette(src); - tmpBuf->CopyBuf(0, 0, src, sX1, sY1, sX2, sY2); + ogGetPixFmt(pixFmt); + if (!tmpBuf->ogCreate(sWidth, sHeight, pixFmt)) return; + tmpBuf->ogCopyPalette(src); + tmpBuf->ogCopyBuf(0, 0, src, sX1, sY1, sX2, sY2); sX2 -= sX1; sY2 -= sY1; sX1 = 0; @@ -3449,9 +3445,9 @@ dBuf = this; doCopyBuf = false; // do we do a copyBuf later? } else { - src.GetPixFmt(pixFmt); - if (!tmpBuf->Create(dWidth,dHeight,pixFmt)) return; - tmpBuf->CopyPalette(*this); + src.ogGetPixFmt(pixFmt); + if (!tmpBuf->ogCreate(dWidth,dHeight,pixFmt)) return; + tmpBuf->ogCopyPalette(*this); origdX1 = dX1; origdY1 = dY1; dX1 = 0; @@ -3482,85 +3478,85 @@ } // for yy if ((doCopyBuf) && (tmpBuf != NULL)) - CopyBuf(origdX1, origdY1, *tmpBuf, 0, 0, tmpBuf->maxX, tmpBuf->maxY); + ogCopyBuf(origdX1, origdY1, *tmpBuf, 0, 0, tmpBuf->maxX, tmpBuf->maxY); delete tmpBuf; return; -} // ogSurface::ScaleBuf +} // ogSurface::ogScaleBuf uInt32 -ogSurface::SetAlpha(uInt32 _newAlpha) { +ogSurface::ogSetAlpha(uInt32 _newAlpha) { uInt32 tmp; - if (attributes) { + if (attributes != NULL) { tmp = attributes->defaultAlpha; attributes->defaultAlpha = _newAlpha; return tmp; } else return _newAlpha; -} // ogSurface::SetAlpha +} // ogSurface::ogSetAlpha bool -ogSurface::SetAntiAliasing(bool _antiAliasing) { +ogSurface::ogSetAntiAliasing(bool _antiAliasing) { bool tmp; - if (attributes) { + if (attributes != NULL) { tmp = attributes->antiAlias; attributes->antiAlias = _antiAliasing; return tmp; } else return _antiAliasing; -} // ogSurface::SetAntiAliasing +} // ogSurface::ogSetAntiAliasing bool -ogSurface::SetBlending(bool _blending) { +ogSurface::ogSetBlending(bool _blending) { bool tmp; - if (attributes) { + if (attributes != NULL) { tmp = attributes->blending; attributes->blending = _blending; return tmp; } else return _blending; -} // ogSurface::SetBlending; +} // ogSurface::ogSetBlending; ogErrorCode -ogSurface::SetLastError(ogErrorCode latestError) { +ogSurface::ogSetLastError(ogErrorCode latestError) { ogErrorCode tmp = lastError; lastError = latestError; return tmp; -} // ogSurface::SetLastError +} // ogSurface::ogSetLastError void -ogSurface::SetPalette(const ogRGBA8 newPal[256]) { - if (NULL == pal) return; +ogSurface::ogSetPalette(const ogRGBA8 newPal[256]) { + if (pal == NULL) return; #ifdef __UBIXOS_KERNEL__ kmemcpy(pal, newPal, sizeof(pal)); #else memcpy(pal, newPal, sizeof(pal)); #endif return; -} // ogSurface::SetPalette +} // ogSurface::ogSetPalette void -ogSurface::SetPixel(int32 x, int32 y, uInt32 colour) { +ogSurface::ogSetPixel(int32 x, int32 y, uInt32 colour) { uInt32 newR, newG, newB, inverseA; uInt8 sR, sG, sB, sA; uInt8 dR, dG, dB; - if (!Avail()) return; + if (!ogAvail()) return; - if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return; + if (((uInt32)x > maxX) || ((uInt32)y > maxY)) return; do { - if (IsBlending()) { - Unpack(colour, sR, sG, sB, sA); - if (0 == sA) return; - if (255 == sA) break; + if (ogIsBlending()) { + ogUnpack(colour, sR, sG, sB, sA); + if (sA == 0) return; + if (sA == 255) break; inverseA = 255 - sA; - Unpack(RawGetPixel(x, y), dR, dG, dB); + ogUnpack(RawGetPixel(x, y), dR, dG, dB); newR = (dR * inverseA + sR * sA) >> 8; newG = (dG * inverseA + sG * sA) >> 8; newB = (dB * inverseA + sB * sA) >> 8; - colour = Pack(newR, newG, newB, inverseA); + colour = ogPack(newR, newG, newB, inverseA); } // if } while (false); @@ -3622,52 +3618,52 @@ break; } // switch return; -} // ogSurface::SetPixel +} // ogSurface::ogSetPixel void -ogSurface::SetPixel(int32 x, int32 y, uInt8 r, uInt8 g, uInt8 b, uInt8 a) { - if (!Avail()) return; - if (((uInt32)x>maxX) || ((uInt32)y>maxY)) return; +ogSurface::ogSetPixel(int32 x, int32 y, uInt8 r, uInt8 g, uInt8 b, uInt8 a) { + if (!ogAvail()) return; + if (((uInt32)x > maxX) || ((uInt32)y > maxY)) return; RawSetPixel(x, y, r, g, b, a); return; -} // ogSurface::SetPixel +} // ogSurface::ogSetPixel void -ogSurface::SetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue, uInt8 alpha) { - if (NULL == pal) return; +ogSurface::ogSetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue, uInt8 alpha) { + if (pal == NULL) return; pal[colour].red = red; pal[colour].green = green; pal[colour].blue = blue; pal[colour].alpha = alpha; return; -} // ogSurface::SetPalette +} // ogSurface::ogSetPalette void -ogSurface::SetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { - if (NULL == pal) return; +ogSurface::ogSetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { + if (pal == NULL) return; pal[colour].red = red; pal[colour].green = green; pal[colour].blue = blue; - pal[colour].alpha = GetAlpha(); + pal[colour].alpha = ogGetAlpha(); return; -} // ogSurface::SetPalette +} // ogSurface::ogSetPalette uInt32 -ogSurface::SetTransparentColor(uInt32 colour) { +ogSurface::ogSetTransparentColor(uInt32 colour) { uInt32 tmp = 0; - if (attributes) { - tmp = attributes->transparentColor & GetAlphaMasker(); - attributes->transparentColor = colour & GetAlphaMasker(); + if (attributes != NULL) { + tmp = attributes->transparentColor & ogGetAlphaMasker(); + attributes->transparentColor = colour & ogGetAlphaMasker(); } // if return tmp; -} // ogSurface::SetTransparentColor +} // ogSurface::ogSetTransparentColor static double f(double g) { return g*g*g-g; } void -ogSurface::Spline(uInt32 numPoints, ogPoint2d* points, uInt32 segments, +ogSurface::ogSpline(uInt32 numPoints, ogPoint2d* points, uInt32 segments, uInt32 colour) { int32 i, oldY, oldX, x, y, j; float part, t, xx, yy, tmp; @@ -3682,7 +3678,7 @@ bool runOnce; - if ((numPoints < 2) || (NULL == points)) return; + if ((numPoints < 2) || (points == NULL)) return; zc = new float[numPoints]; dx = new float[numPoints]; @@ -3694,13 +3690,13 @@ py = new float[numPoints]; do { - if (NULL == zc) break; - if (NULL == dx) break; - if (NULL == dy) break; - if (NULL == wndX1) break; - if (NULL == wndY1) break; - if (NULL == px) break; - if (NULL == py) break; + if (zc == NULL) break; + if (dx == NULL) break; + if (dy == NULL) break; + if (wndX1 == NULL) break; + if (wndY1 == NULL) break; + if (px == NULL) break; + if (py == NULL) break; for (i = 0; (uInt32)i < numPoints; i++) { zc[i] = dx[i] = dy[i] = u[i] = wndX1[i] = wndY1[i] = px[i] = py[i] = 0.0f; @@ -3759,7 +3755,7 @@ // x = Round(part); x = static_cast(part+0.5f); - if (runOnce) Line(oldX, oldY, x, y, colour); else runOnce = true; + if (runOnce) ogLine(oldX, oldY, x, y, colour); else runOnce = true; oldX = x; oldY = y; } // for j @@ -3776,21 +3772,21 @@ delete [] zc; return; -} // ogSurface::Spline +} // ogSurface::ogSpline void -ogSurface::Triangle(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, +ogSurface::ogTriangle(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uInt32 colour) { - Line(x1, y1, x2, y2,colour); - Line(x2, y2, x3, y3,colour); - Line(x3, y3, x1, y1,colour); + ogLine(x1, y1, x2, y2,colour); + ogLine(x2, y2, x3, y3,colour); + ogLine(x3, y3, x1, y1,colour); return; -} // ogSurface::Triangle +} // ogSurface::ogTriangle void -ogSurface::Unpack(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue) { +ogSurface::ogUnpack(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue) { switch (bytesPerPix) { case 4: @@ -3803,20 +3799,18 @@ red = ((colour >> redFieldPosition) << redShifter); green = ((colour >> greenFieldPosition) << greenShifter); blue = ((colour >> blueFieldPosition) << blueShifter); - if (red != 0) red += OG_MASKS[redShifter]; + if (red != 0) red += OG_MASKS[redShifter]; if (green != 0) green += OG_MASKS[greenShifter]; - if (blue != 0) blue += OG_MASKS[blueShifter]; + if (blue != 0) blue += OG_MASKS[blueShifter]; break; case 1: - if (NULL == pal) { - red = 0; - green = 0; - blue = 0; + if (pal == NULL) { + red = green = blue = 0; return; } // if pal == null - if (colour>255) colour &= 255; + if (colour > 255) colour &= 255; red = pal[colour].red; green = pal[colour].green; blue = pal[colour].blue; @@ -3828,10 +3822,10 @@ } // switch return; -} // ogSurface::Unpack +} // ogSurface::ogUnpack void -ogSurface::Unpack(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue, uInt8& alpha) { +ogSurface::ogUnpack(uInt32 colour, uInt8& red, uInt8& green, uInt8& blue, uInt8& alpha) { switch (bytesPerPix) { case 4: @@ -3844,30 +3838,30 @@ red = colour >> redFieldPosition; green = colour >> greenFieldPosition; blue = colour >> blueFieldPosition; - alpha = GetAlpha(); + alpha = ogGetAlpha(); break; case 2: - red = ((colour >> redFieldPosition) << redShifter); + red = ((colour >> redFieldPosition) << redShifter); green = ((colour >> greenFieldPosition) << greenShifter); - blue = ((colour >> blueFieldPosition) << blueShifter); - if (red != 0) red += OG_MASKS[redShifter]; + blue = ((colour >> blueFieldPosition) << blueShifter); + if (red != 0) red += OG_MASKS[redShifter]; if (green != 0) green += OG_MASKS[greenShifter]; - if (blue != 0) blue += OG_MASKS[blueShifter]; + if (blue != 0) blue += OG_MASKS[blueShifter]; if (alphaShifter != 8) { alpha = (colour >> alphaFieldPosition) << alphaShifter; if (alpha != 0) alpha += OG_MASKS[alphaShifter]; - } else alpha = GetAlpha(); + } else alpha = ogGetAlpha(); break; case 1: - if (NULL == pal) { + if (pal == NULL) { red = green = blue = alpha = 0; return; } // if pal == null - if (colour>255) colour &= 255; + if (colour > 255) colour &= 255; red = pal[colour].red; green = pal[colour].green; blue = pal[colour].blue; @@ -3878,13 +3872,13 @@ } // switch return; -} // ogSurface::Unpack +} // ogSurface::ogUnpack void -ogSurface::VFlip(void) { +ogSurface::ogVFlip(void) { uInt32 height; - if (!Avail()) return; + if (!ogAvail()) return; switch (bytesPerPix) { case 4: @@ -3998,14 +3992,14 @@ break; } // switch return; -} // ogSurface::VFlip +} // ogSurface::ogVFlip void -ogSurface::VLine(int32 x, int32 y1, int32 y2, uInt32 colour) { +ogSurface::ogVLine(int32 x, int32 y1, int32 y2, uInt32 colour) { int32 tmp; uInt8 r, g, b, a; - if (!Avail()) return; + if (!ogAvail()) return; if ((uInt32)x > maxX) return; if (y1 > y2) { @@ -4018,13 +4012,13 @@ if (y2 > (int32)maxY) y2 = maxY; if (y2 < y1) return; - if (IsBlending()) { + if (ogIsBlending()) { - Unpack(colour, r, g, b, a); + ogUnpack(colour, r, g, b, a); - if (0 == a) return; + if (a == 0) return; - if (255 != a) { + if (a != 255) { for (tmp = y1; tmp <= y2; tmp++) RawSetPixel(x, tmp, r, g, b, a); return; @@ -4119,7 +4113,7 @@ break; } // switch return; -} // ogSurface::VLine +} // ogSurface::ogVLine ogSurface::~ogSurface(void) { diff --git a/src/lib/objgfx40/objgfx40/objgfx40.h b/src/lib/objgfx40/objgfx40/objgfx40.h index 72a0e3c..3a49404 100644 --- a/src/lib/objgfx40/objgfx40/objgfx40.h +++ b/src/lib/objgfx40/objgfx40/objgfx40.h @@ -116,72 +116,72 @@ void AARawLine(uInt32, uInt32, uInt32, uInt32, uInt32); public: ogSurface(void); - virtual bool Alias(ogSurface&, uInt32, uInt32, uInt32, uInt32); - virtual bool Avail(void); - void Arc(int32, int32, uInt32, uInt32, uInt32, uInt32); - void BSpline(uInt32, ogPoint2d*, uInt32, uInt32); - void Circle(int32, int32, uInt32, uInt32); - virtual void Clear(uInt32); - virtual bool Clone(ogSurface&); - void Copy(ogSurface&); - void CopyBuf(int32, int32, + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual bool ogAvail(void); + void ogArc(int32, int32, uInt32, uInt32, uInt32, uInt32); + void ogBSpline(uInt32, ogPoint2d*, uInt32, uInt32); + void ogCircle(int32, int32, uInt32, uInt32); + virtual void ogClear(uInt32); + virtual bool ogClone(ogSurface&); + void ogCopy(ogSurface&); + void ogCopyBuf(int32, int32, ogSurface&, int32, int32, int32, int32); - virtual void CopyLineTo(uInt32, uInt32, const void *, uInt32); - virtual void CopyLineFrom(uInt32, uInt32, void *, uInt32); - virtual void CopyPalette(ogSurface&); - virtual bool Create(uInt32, uInt32, ogPixelFmt); - void CubicBezierCurve(int32, int32, int32, int32, + virtual void ogCopyLineTo(uInt32, uInt32, const void *, uInt32); + virtual void ogCopyLineFrom(uInt32, uInt32, void *, uInt32); + virtual void ogCopyPalette(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + void ogCubicBezierCurve(int32, int32, int32, int32, int32, int32, int32, int32, uInt32, uInt32); - void Curve(int32,int32, int32,int32, int32,int32, uInt32, uInt32); - void FillCircle(int32, int32, uInt32, uInt32); - void FillGouraudPolygon(uInt32, ogPoint2d*, ogRGBA8 *); - void FillPolygon(uInt32, ogPoint2d*, uInt32); - void FillRect(int32, int32, int32, int32, uInt32); - void FillTriangle(int32,int32, int32,int32, int32,int32, uInt32); - uInt32 GetAlpha(void); - uInt32 GetAlphaMasker(void) const { return alphaMasker; } - uInt32 GetBPP(void) const { return BPP; } - uInt32 GetBytesPerPix(void) const { return bytesPerPix; } - ogDataState GetDataState(void) const { return dataState; } - ogErrorCode GetLastError(void); - uInt32 GetMaxX(void) const { return maxX; } - uInt32 GetMaxY(void) const { return maxY; } - void GetPalette(ogRGBA8[]); - void GetPixFmt(ogPixelFmt&); - uInt32 GetPixFmtID(void) const { return pixFmtID; } - virtual uInt32 GetPixel(int32, int32); - virtual void * GetPtr(uInt32, uInt32); - uInt32 GetTransparentColor(void); - void HFlip(void); - virtual void HLine(int32, int32, int32, uInt32); - bool IsAntiAliasing(void); - bool IsBlending(void); - void Line(int32, int32, int32, int32, uInt32); - virtual bool LoadPalette(const char *); - void Polygon(uInt32, ogPoint2d*, uInt32); - void Rect(int32, int32, int32, int32, uInt32); - uInt32 Pack(uInt8, uInt8, uInt8); - uInt32 Pack(uInt8, uInt8, uInt8, uInt8); - bool SavePalette(const char *); - void Scale(ogSurface&); - void ScaleBuf(int32, int32, int32, int32, + void ogCurve(int32,int32, int32,int32, int32,int32, uInt32, uInt32); + void ogFillCircle(int32, int32, uInt32, uInt32); + void ogFillGouraudPolygon(uInt32, ogPoint2d*, ogRGBA8 *); + void ogFillPolygon(uInt32, ogPoint2d*, uInt32); + void ogFillRect(int32, int32, int32, int32, uInt32); + void ogFillTriangle(int32,int32, int32,int32, int32,int32, uInt32); + uInt32 ogGetAlpha(void); + uInt32 ogGetAlphaMasker(void) const { return alphaMasker; } + uInt32 ogGetBPP(void) const { return BPP; } + uInt32 ogGetBytesPerPix(void) const { return bytesPerPix; } + ogDataState ogGetDataState(void) const { return dataState; } + ogErrorCode ogGetLastError(void); + uInt32 ogGetMaxX(void) const { return maxX; } + uInt32 ogGetMaxY(void) const { return maxY; } + void ogGetPalette(ogRGBA8[]); + void ogGetPixFmt(ogPixelFmt&); + uInt32 ogGetPixFmtID(void) const { return pixFmtID; } + virtual uInt32 ogGetPixel(int32, int32); + virtual void * ogGetPtr(uInt32, uInt32); + uInt32 ogGetTransparentColor(void); + void ogHFlip(void); + virtual void ogHLine(int32, int32, int32, uInt32); + bool ogIsAntiAliasing(void); + bool ogIsBlending(void); + void ogLine(int32, int32, int32, int32, uInt32); + virtual bool ogLoadPalette(const char *); + void ogPolygon(uInt32, ogPoint2d*, uInt32); + void ogRect(int32, int32, int32, int32, uInt32); + uInt32 ogPack(uInt8, uInt8, uInt8); + uInt32 ogPack(uInt8, uInt8, uInt8, uInt8); + bool ogSavePalette(const char *); + void ogScale(ogSurface&); + void ogScaleBuf(int32, int32, int32, int32, ogSurface&, int32, int32, int32, int32); - uInt32 SetAlpha(uInt32); - bool SetAntiAliasing(bool); - bool SetBlending(bool); - virtual ogErrorCode SetLastError(ogErrorCode); - virtual void SetPixel(int32, int32, uInt32); - virtual void SetPixel(int32, int32, uInt8, uInt8, uInt8, uInt8); - virtual void SetPalette(const ogRGBA8[]); - virtual void SetPalette(uInt8, uInt8, uInt8, uInt8, uInt8); - virtual void SetPalette(uInt8, uInt8, uInt8, uInt8); - uInt32 SetTransparentColor(uInt32); - void Spline(uInt32, ogPoint2d*, uInt32, uInt32); - void Triangle(int32, int32, int32, int32, int32, int32, uInt32); - void Unpack(uInt32, uInt8&, uInt8&, uInt8&); - void Unpack(uInt32, uInt8&, uInt8&, uInt8&, uInt8&); - virtual void VFlip(void); - virtual void VLine(int32, int32, int32, uInt32); + uInt32 ogSetAlpha(uInt32); + bool ogSetAntiAliasing(bool); + bool ogSetBlending(bool); + virtual ogErrorCode ogSetLastError(ogErrorCode); + virtual void ogSetPixel(int32, int32, uInt32); + virtual void ogSetPixel(int32, int32, uInt8, uInt8, uInt8, uInt8); + virtual void ogSetPalette(const ogRGBA8[]); + virtual void ogSetPalette(uInt8, uInt8, uInt8, uInt8, uInt8); + virtual void ogSetPalette(uInt8, uInt8, uInt8, uInt8); + uInt32 ogSetTransparentColor(uInt32); + void ogSpline(uInt32, ogPoint2d*, uInt32, uInt32); + void ogTriangle(int32, int32, int32, int32, int32, int32, uInt32); + void ogUnpack(uInt32, uInt8&, uInt8&, uInt8&); + void ogUnpack(uInt32, uInt8&, uInt8&, uInt8&, uInt8&); + virtual void ogVFlip(void); + virtual void ogVLine(int32, int32, int32, uInt32); virtual ~ogSurface(void); }; // ogSurface diff --git a/src/lib/objgfx40/ogBlit.cpp b/src/lib/objgfx40/ogBlit.cpp index 2c19286..4de049c 100644 --- a/src/lib/objgfx40/ogBlit.cpp +++ b/src/lib/objgfx40/ogBlit.cpp @@ -76,8 +76,8 @@ imageSize = 0; blitMaskSize = 0; - aMask = src.GetAlphaMasker(); - tColour = src.GetTransparentColor(); + aMask = src.ogGetAlphaMasker(); + tColour = src.ogGetTransparentColor(); startX = x1; startY = y1; @@ -90,7 +90,7 @@ found = false; while ((!found) && (startX <= x2)) { for (y = y1; y <= y2; y++) - found |= ((src.GetPixel(startX, y) & aMask) != tColour); + found |= ((src.ogGetPixel(startX, y) & aMask) != tColour); if (!found) ++startX; } // while @@ -100,21 +100,21 @@ found = false; while ((!found) && (startY <= y2)) { for (x = startX; x <= x2; x++) - found |= ((src.GetPixel(x,startY) & aMask) != tColour); + found |= ((src.ogGetPixel(x,startY) & aMask) != tColour); if (!found) ++startY; } // while found = false; while ((!found) && (endX >= startX)) { for (y = startY; y <= y2; y++) - found |= ((src.GetPixel(endX,y) & aMask) != tColour); + found |= ((src.ogGetPixel(endX,y) & aMask) != tColour); if (!found) --endX; } // while found = false; while ((!found) && (endY >= startY)) { for (x = startX; x <= endX; x++) - found |= ((src.GetPixel(x,endY) & aMask) != tColour); + found |= ((src.ogGetPixel(x,endY) & aMask) != tColour); if (!found) --endY; } // while @@ -122,17 +122,17 @@ zerocount = 0; blitMaskSize++; // save room for xlcount x = startX; - inZeros = ((src.GetPixel(x,y) & aMask) == tColour); + inZeros = ((src.ogGetPixel(x,y) & aMask) == tColour); while (x <= endX) { switch (inZeros) { case true: zerocount = 0; // How many zeros? - while ((x <= endX) && ((src.GetPixel(x,y) & aMask) == tColour)) { + while ((x <= endX) && ((src.ogGetPixel(x,y) & aMask) == tColour)) { ++x; - if (255 == zerocount) { + if (zerocount == 255) { zerocount = 0; blitMaskSize += 2; } else ++zerocount; @@ -147,14 +147,14 @@ do { ++x; - if (255 == pixcount) { + if (pixcount == 255) { blitMaskSize += 2; pixcount = 0; } else ++pixcount; ++totalPixCount; //mjikaboom imageSize += bm; - } while ((x <= endX) && ((src.GetPixel(x,y) & aMask) != tColour)); + } while ((x <= endX) && ((src.ogGetPixel(x,y) & aMask) != tColour)); inZeros = true; break; // case false } // switch @@ -200,12 +200,12 @@ width = (x2 - x1)+1; height = (y2 - y1)+1; - bytesPerPixel = src.GetBytesPerPix(); + bytesPerPixel = src.ogGetBytesPerPix(); - if (1 == bytesPerPixel) { + if (bytesPerPixel == 1) { if (pal != NULL) pal = new ogRGBA8[256]; // note that tPal will check for null, so this check may be unnecessary - if (pal != NULL) src.GetPalette(pal); + if (pal != NULL) src.ogGetPalette(pal); /* for (tmp = 0; tmp < 256; tmp++) src.Unpack(tmp, pal[tmp].red, @@ -218,11 +218,11 @@ BlitSize(src, x1, y1, x2, y2); - if (NULL == blitMask) return; + if (blitMask == NULL) return; blitMaskPtr = blitMask; - aMask = src.GetAlphaMasker(); - tColour = src.GetTransparentColor(); + aMask = src.ogGetAlphaMasker(); + tColour = src.ogGetTransparentColor(); for (y = y1+startY; y <= y1+endY; y++) { zeroCount = 0; @@ -230,15 +230,15 @@ *lineCountPtr = 0; ++blitMaskPtr; x = x1+startX; - inZeros = ((src.GetPixel(x,y) & aMask) == tColour); + inZeros = ((src.ogGetPixel(x,y) & aMask) == tColour); while (x <= x1+endX) { switch (inZeros) { case true: zeroCount = 0; - while ((x <= x1+endX) && ((src.GetPixel(x,y) & aMask) == tColour)) { + while ((x <= x1+endX) && ((src.ogGetPixel(x,y) & aMask) == tColour)) { ++x; - if (255 == zeroCount) { + if (zeroCount == 255) { ++(*lineCountPtr); *blitMaskPtr = 255; // offset ++blitMaskPtr; // increment to next byte @@ -262,7 +262,7 @@ do { ++x; - if (255 == pixCount) { + if (pixCount == 255) { ++(*lineCountPtr); *blitMaskPtr = 255; // runcount ++blitMaskPtr; // advance pointer @@ -275,7 +275,7 @@ ++(*blitMaskPtr); } while ((x <= (x1+endX)) && - ((src.GetPixel(x,y) & aMask)!=tColour)); + ((src.ogGetPixel(x,y) & aMask) != tColour)); ++blitMaskPtr; inZeros = true; // set inZeros to true to toggle break; // case false @@ -331,10 +331,10 @@ uInt32 distToEdge, xRight, count; ogPixelFmt pixFmt; - if (NULL == blitMask) return; + if (blitMask == NULL) return; - if ( (x + startX > (int32)src.GetMaxX()) || (x + endX < 0) || - (y + startY > (int32)src.GetMaxY()) || (y + endY < 0)) return; + if ( (x + startX > (int32)src.ogGetMaxX()) || (x + endX < 0) || + (y + startY > (int32)src.ogGetMaxY()) || (y + endY < 0)) return; blitMaskPtr = blitMask; @@ -343,12 +343,12 @@ // note that the first time through pixelFmtID will be 0, so this // will get that information - if (src.GetPixFmtID() != pixelFmtID) { + if (src.ogGetPixFmtID() != pixelFmtID) { free(image); image = NULL; imageSize = 0; - src.GetPixFmt(pixFmt); + src.ogGetPixFmt(pixFmt); bitDepth = pixFmt.BPP; RFP = pixFmt.redFieldPosition; @@ -360,14 +360,14 @@ bShift = 8-pixFmt.blueMaskSize; aShift = 8-pixFmt.alphaMaskSize; - bytesPerPixel = src.GetBytesPerPix(); - pixelFmtID = src.GetPixFmtID(); - dAlpha = src.GetAlpha(); - // tColour = src.GetTransparentColor(); // done elsewhere + bytesPerPixel = src.ogGetBytesPerPix(); + pixelFmtID = src.ogGetPixFmtID(); + dAlpha = src.ogGetAlpha(); + // tColour = src.ogGetTransparentColor(); // done elsewhere } // if - if (NULL == image) { + if (image == NULL) { imageSize = totalPixCount * bytesPerPixel; image = malloc(imageSize); } // if @@ -375,8 +375,8 @@ imagePtr = image; // If any part of the blit data is out of bounds, we need to fill it with the // transparent colour - if ( (x + startX < 0) || (x + endX > (int32)src.GetMaxX()) || - (y + startY < 0) || (y + endY > (int32)src.GetMaxY())) { + if ( (x + startX < 0) || (x + endX > (int32)src.ogGetMaxX()) || + (y + startY < 0) || (y + endY > (int32)src.ogGetMaxY())) { for (count = 0; count < totalPixCount; count++) { SetPixel(imagePtr, tColour); (uInt8 *)imagePtr += bytesPerPixel; @@ -397,7 +397,7 @@ ++nsy; lineCount = *blitMaskPtr; ++blitMaskPtr; - while (lineCount>0) { + while (lineCount > 0) { ++blitMaskPtr; pixCount = *blitMaskPtr; ++blitMaskPtr; @@ -408,8 +408,8 @@ } // if // Now do clipping on the bottom edge. This is easy. - if (y+endY > (int32)src.GetMaxY()) - ney = (src.GetMaxY()-y); + if (y+endY > (int32)src.ogGetMaxY()) + ney = (src.ogGetMaxY()-y); else ney = endY; @@ -426,21 +426,21 @@ ++blitMaskPtr; if (pixCount > 0) { - if (sx <= (int32)src.GetMaxX()) { + if (sx <= (int32)src.ogGetMaxX()) { if ((sx < 0) && (sx+pixCount > 0)) { pixCount += sx; // remember, sx is negative (uInt8*)imagePtr -= sx*bytesPerPixel; // remember, sx is negative sx = 0; } // if sx<0 && sx+pixcount>0 - if (sx+pixCount > (int32)src.GetMaxX()+1) { - distToEdge = (src.GetMaxX()-sx)+1; + if (sx+pixCount > (int32)src.ogGetMaxX()+1) { + distToEdge = (src.ogGetMaxX()-sx)+1; xRight = (pixCount - distToEdge)*bytesPerPixel; pixCount = distToEdge; } else xRight = 0; // if sx+pixCount>MaxX if (sx >= 0) - src.CopyLineFrom(sx, y+sy, imagePtr,pixCount*bytesPerPixel); + src.ogCopyLineFrom(sx, y+sy, imagePtr, pixCount*bytesPerPixel); (uInt8*)imagePtr += xRight; // get any remainter from right edge clip } // if sx <= MaxX @@ -475,8 +475,8 @@ uInt32 tmpSize; char headerIdent[4]; - if (fileExists(filename)==false) return false; - if ((infile = fopen(filename,"rb"))==NULL) return false; + if (!fileExists(filename)) return false; + if ((infile = fopen(filename,"rb")) == NULL) return false; fseek(infile, offset, SEEK_SET); // for now just free up the previous image. This will be changed @@ -493,10 +493,10 @@ lresult = fread(headerIdent, sizeof(headerIdent), 1, infile); tresult += lresult*sizeof(headerIdent); - if ((headerIdent[0]!='B') || - (headerIdent[1]!='L') || - (headerIdent[2]!='T') || - (headerIdent[3]!=(char)0x1A)) { + if ((headerIdent[0] != 'B') || + (headerIdent[1] != 'L') || + (headerIdent[2] != 'T') || + (headerIdent[3] != (uInt8)0x1A)) { fclose(infile); return false; } @@ -591,16 +591,17 @@ lresult = fread(image, 1, imageSize, infile); tresult += lresult; - if (bitDepth==8) { + if (bitDepth == 8) { // 8bpp sprites have palettes - if (pal==NULL) pal = new ogRGBA8[256]; - if (pal==NULL) { + if (pal == NULL) pal = new ogRGBA8[256]; + if (pal == NULL) { fclose(infile); return false; } // if pal==NULL lresult = fread(&tmpSize, sizeof(tmpSize), 1, infile); tresult += lresult*sizeof(tmpSize); - if (tmpSize>sizeof(ogRGBA8)*256) { + + if (tmpSize > sizeof(ogRGBA8)*256) { fclose(infile); return false; } @@ -624,13 +625,13 @@ ogPixelFmt pixFmt; // can we draw anything? - if ((NULL == blitMask) || (NULL == image)) return; + if ((blitMask == NULL) || (image == NULL)) return; - if (!dest.Avail()) return; + if (!dest.ogAvail()) return; // see if the blit is oustide the buffer - if ( ((x+startX) > (int32)dest.GetMaxX()) || ((x + endX) < 0) || - ((y+startY) > (int32)dest.GetMaxY()) || ((y + endY) < 0) ) return; + if ( ((x+startX) > (int32)dest.ogGetMaxX()) || ((x + endX) < 0) || + ((y+startY) > (int32)dest.ogGetMaxY()) || ((y + endY) < 0) ) return; blitMaskPtr = blitMask; imagePtr = image; @@ -664,14 +665,14 @@ // I'm going to contradict myself and say that I don't think y is // guaranteed to be >= 0. - if (y+endY > (int32)dest.GetMaxY()) - ney = (dest.GetMaxY()-y); + if (y+endY > (int32)dest.ogGetMaxY()) + ney = (dest.ogGetMaxY()-y); else ney = endY; - dest.GetPixFmt(pixFmt); + dest.ogGetPixFmt(pixFmt); - if ((dest.GetPixFmtID() != pixelFmtID) || (dest.IsBlending())) { + if ((dest.ogGetPixFmtID() != pixelFmtID) || (dest.ogIsBlending())) { for (sy = nsy; (uInt32)sy <= ney; sy++) { sx = x+startX; lineCount = *blitMaskPtr; @@ -684,7 +685,7 @@ ++blitMaskPtr; if (pixCount > 0) { - if (sx <= (int32)dest.GetMaxX()) { + if (sx <= (int32)dest.ogGetMaxX()) { if ((sx < 0) && (sx+(int32)pixCount > 0)) { pixCount += sx; // remember, sx is negative @@ -692,8 +693,8 @@ sx = 0; } // if sx<0 && sx+pixCount>0 - if (sx+pixCount > (int32)dest.GetMaxX()) { - distToEdge = (dest.GetMaxX()-sx)+1; + if (sx+pixCount > (int32)dest.ogGetMaxX()) { + distToEdge = (dest.ogGetMaxX()-sx)+1; xRight = (pixCount-distToEdge)*bytesPerPixel; pixCount = distToEdge; } else xRight = 0; // if sx+pixCount>MaxX @@ -702,7 +703,7 @@ for (xx = 0; xx < pixCount; xx++) { Unpack(GetPixel((uInt8*)imagePtr+(xx*bytesPerPixel)), r, g, b, a); - dest.SetPixel(sx+xx, sy+y, r, g, b, a); + dest.ogSetPixel(sx+xx, sy+y, r, g, b, a); } // for (uInt8*)imagePtr += xRight; } // if sx <= maxX @@ -726,21 +727,21 @@ ++blitMaskPtr; if (pixCount > 0) { - if (sx <= (int32)dest.GetMaxX()) { + if (sx <= (int32)dest.ogGetMaxX()) { if ((sx < 0) && (sx+pixCount > 0)) { pixCount += sx; // remember, sx is negative (uInt8*)imagePtr -= sx*bytesPerPixel; // remember, sx is negative sx = 0; } // if sx<0 && sx+pixCount>0 - if (sx+pixCount>(int32)dest.GetMaxX()+1) { - distToEdge = (dest.GetMaxX()-sx)+1; + if (sx+pixCount > (int32)dest.ogGetMaxX()+1) { + distToEdge = (dest.ogGetMaxX()-sx)+1; xRight = (pixCount - distToEdge)*bytesPerPixel; pixCount = distToEdge; } else xRight = 0; // if sx+pixCount>MaxX if (sx >= 0) - dest.CopyLineTo(sx, y+sy, imagePtr, pixCount*bytesPerPixel); + dest.ogCopyLineTo(sx, y+sy, imagePtr, pixCount*bytesPerPixel); (uInt8*)imagePtr += xRight; } // if sx <= MaxX sx += pixCount; @@ -771,10 +772,10 @@ char headerIdent[4]; uInt32 tmpSize; - if (image==NULL) return false; - if ((bitDepth==8) && (pal==NULL)) return false; + if (image == NULL) return false; + if ((bitDepth == 8) && (pal == NULL)) return false; - if (fileExists(filename)==false) { // file doesn't exist + if (!fileExists(filename)) { // file doesn't exist if ((outfile = fopen(filename,"wb")) == NULL) return false; } else { // file exists. Now we check to see where we put it @@ -783,7 +784,7 @@ } else { // we have an existing file and an offset to place the data if ((outfile = fopen(filename, "wb")) == NULL) return false; - if (offset!=0) fseek(outfile, offset, SEEK_SET); + if (offset != 0) fseek(outfile, offset, SEEK_SET); } // else } // else @@ -792,7 +793,7 @@ headerIdent[0] = 'B'; headerIdent[1] = 'L'; headerIdent[2] = 'T'; - headerIdent[3] = (char)0x1A; // EOF marker + headerIdent[3] = (uInt8)0x1A; // EOF marker // we store exactly how bit this sucker is inside the header. This includes // the header information before it, and the size itself diff --git a/src/lib/objgfx40/ogDisplay_UbixOS.cc b/src/lib/objgfx40/ogDisplay_UbixOS.cc index 4cc578c..6b75b86 100755 --- a/src/lib/objgfx40/ogDisplay_UbixOS.cc +++ b/src/lib/objgfx40/ogDisplay_UbixOS.cc @@ -62,10 +62,10 @@ ogDisplay_UbixOS::FindMode(uInt32 _xRes, uInt32 _yRes, uInt32 _BPP) { uInt16 mode; - if ((320 == _xRes) && (200 == _yRes) && (8 == _BPP)) return 0x13; + if ((_xRes == 320) && (_yRes == 200) && (_BPP == 8)) return 0x13; // if ((VESAInfo==NULL) || (VESAInfo->videoModePtr==NULL)) return 0; - if (NULL == modeInfo) return 0; + if (modeInfo == NULL) return 0; for (mode = 0x100; mode < 0x1FF; mode++) { getModeInfo(mode); @@ -81,7 +81,7 @@ uInt32 size = 0x0, count = 0x0, i = 0x0; - if (mode==0x13) { + if (mode == 0x13) { xRes = 320; yRes = 200; @@ -125,7 +125,7 @@ blueFieldPosition = modeInfo->blueFieldPosition; alphaFieldPosition = modeInfo->alphaFieldPosition; - if (4 == bytesPerPix) { + if (bytesPerPix == 4) { modeInfo->alphaMaskSize = 8; while ((alphaFieldPosition == redFieldPosition) || (alphaFieldPosition == greenFieldPosition) || @@ -148,10 +148,10 @@ owner = this; dataState = ogAliasing; - if ((lineOfs!=NULL) && (lSize!=0)) delete [] lineOfs; + if ((lineOfs != NULL) && (lSize != 0)) delete [] lineOfs; lSize = yRes*sizeof(uInt32); lineOfs = new uInt32[yRes];; - if (NULL == lineOfs) return; + if (lineOfs == NULL) return; lineOfs[0] = 0; for (count = 1; count < yRes; count++) @@ -159,11 +159,11 @@ initVESAMode(mode); - SetAntiAliasing(BPP > 8); - if (NULL == pal) pal = new ogRGBA8[256]; - SetPalette(DEFAULT_PALETTE); + ogSetAntiAliasing(BPP > 8); + if (pal == NULL) pal = new ogRGBA8[256]; + ogSetPalette(DEFAULT_PALETTE); - if (1 == bytesPerPix) { + if (bytesPerPix == 1) { pixFmtID = 0x08080808; } else { pixFmtID = (redFieldPosition) | @@ -192,14 +192,14 @@ } // ogDisplay_UbixOS::SetPal bool -ogDisplay_UbixOS::Alias(ogSurface& SrcObject, uInt32 x1, +ogDisplay_UbixOS::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) { - SetLastError(ogNoAliasing); + ogSetLastError(ogNoAliasing); return false; } // ogDisplay_UbixOS::Alias bool -ogDisplay_UbixOS::Create(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixFormat) { +ogDisplay_UbixOS::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixFormat) { uInt16 mode; mode = 0x111; setMode(mode); @@ -212,33 +212,33 @@ if (mode!=0) setMode(mode); */ return (mode!=0); -} // ogDisplay_UbixOS::Create +} // ogDisplay_UbixOS::ogCreate bool -ogDisplay_UbixOS::Clone(ogSurface& SrcObject) { - SetLastError(ogNoCloning); +ogDisplay_UbixOS::ogClone(ogSurface& SrcObject) { + ogSetLastError(ogNoCloning); return false; } // ogDisplay_UbixOS::Clone void -ogDisplay_UbixOS::CopyPal(ogSurface& SrcObject) { - ogSurface::CopyPal(SrcObject); +ogDisplay_UbixOS::ogCopyPal(ogSurface& SrcObject) { + ogSurface::ogCopyPal(SrcObject); SetPal(); return; -} // ogDisplay_UbixOS::CopyPal +} // ogDisplay_UbixOS::ogCopyPal bool -ogDisplay_UbixOS::LoadPalette(const char *palfile) { +ogDisplay_UbixOS::ogLoadPalette(const char *palfile) { bool result; if ((result = ogSurface::LoadPalette(palfile))==true) SetPal(); return result; -} // ogDisplay_UbixOS::LoadPalette +} // ogDisplay_UbixOS::ogLoadPalette void -ogDisplay_UbixOS::SetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 b +ogDisplay_UbixOS::ogSetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 b lue) { - if (NULL == pal) return; - ogSurface::SetRGBPalette(colour, red, green, blue); + if (pal == NULL) return; + ogSurface::ogSetRGBPalette(colour, red, green, blue); outportb(0x3c8, colour); outportb(0x3c9, red >> 2); outportb(0x3c9, green >> 2); @@ -250,15 +250,15 @@ void ogDisplay_UbixOS::SetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue, uInt8 alpha) { - if (NULL == pal) return; - ogSurface::SetPalette(colour, red, green, blue, alpha); + if (pal == NULL) return; + ogSurface::ogSetPalette(colour, red, green, blue, alpha); outportb(0x3c8, colour); outportb(0x3c9, red >> 2); outportb(0x3c9, green >> 2); outportb(0x3c9, blue >> 2); return; -} // ogDisplay_UbixOS::SetPalette +} // ogDisplay_UbixOS::ogSetPalette ogDisplay_UbixOS::~ogDisplay_UbixOS(void) { delete attributes; diff --git a/src/lib/objgfx40/ogDisplay_VESA.cpp b/src/lib/objgfx40/ogDisplay_VESA.cpp index 38c9ed2..eaf097d 100644 --- a/src/lib/objgfx40/ogDisplay_VESA.cpp +++ b/src/lib/objgfx40/ogDisplay_VESA.cpp @@ -1,1450 +1,1450 @@ -#include "objgfx40.h" -#include "defpal.inc" -#include "ogDisplay_VESA.h" -#include // for __tb -#include -#include -#include -#include -#include - -/* - * - * ogDisplay methods - * - */ - -void -initVESAMode(uInt16 mode) { - __dpmi_regs regs; - regs.x.ax = 0x4f02; - regs.x.bx = mode; - __dpmi_int(0x10, ®s); - return; -} - -ogDisplay_VESA::ogDisplay_VESA(void) : ogSurface() { - pages[0] = pages[1] = NULL; - activePage = visualPage = 0; - inGraphics = false; - VESAInfo = new ogVESAInfo; - modeInfo = new ogModeInfo; - pal = new ogRGBA8[256]; - attributes = new ogAttributes(); - - GetVESAInfo(); - - screenSelector = __dpmi_allocate_ldt_descriptors(1); - - return; -} // ogDisplay_VESA::ogDisplay_VESA - -uInt32 -ogDisplay_VESA::RawGetPixel(uInt32 x, uInt32 y) { - uInt32 result; - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) - " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} - // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - " mov (%%edi),%%eax \n" // eax,word ptr [edi] - " mov %%eax, %4 \n" // mov result, eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 - ); - break; - case 3: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) - " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size - " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size - " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size - " add %%esi, %%edi \n" // add edi, esi - // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] - " add %%ecx, %%edi \n" // add edi, ecx - " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] - " xor %%eax, %%eax \n" - " mov 2(%%edi), %%al \n" // mov al, [edi+2] - " shl $16, %%eax \n" // shl eax, 16 - " mov (%%edi), %%ax \n" // mov ax, [edi] - " mov %%eax, %4 \n" // mov result, eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 - ); - break; - case 2: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} - " add %%ecx, %%edi \n" // add edi, ecx - " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] - " mov %%eax, %4 \n" // mov result, eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 - ); - break; - case 1: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] - " mov %%eax, %4 \n" // mov result, eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 - ); - break; - } // switch - return result; -} // ogDisplay_VESA::RawGetPixel - -void -ogDisplay_VESA::RawSetPixel(uInt32 x, uInt32 y, uInt32 colour) { - uInt32 newR, newG, newB, inverseA; - uInt8 sR, sG, sB, sA; - uInt8 dR, dG, dB; - - do { - if (IsBlending()) { - Unpack(colour, sR, sG, sB, sA); - if (0 == sA) return; - if (255 == sA) break; - inverseA = 255 - sA; - Unpack(RawGetPixel(x, y), dR, dG, dB); - newR = (dR * inverseA + sR * sA) >> 8; - newG = (dG * inverseA + sG * sA) >> 8; - newB = (dB * inverseA + sB * sA) >> 8; - colour = Pack(newR, newG, newB, inverseA); - } // if - } while (false); - - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - " push %%ds \n" // push ds - " mov %%dx, %%ds \n" // mov ds, dx - - " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%eax, (%%edi) \n" // mov [edi], eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), // %2, %3 - "d" (screenSelector) // %4 - ); - break; - case 3: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - // " add (%%esi,%%ebx,4),%%edi \n" // add edi, [esi + ebx * 4] - " push %%ds \n" // push ds - " mov %%dx, %%ds \n" // mov ds, dx - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} - " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} - // { Draw the pixel } - " mov %%ax, (%%edi) \n" // mov [edi], ax - " shr $16, %%eax \n" // shr eax, 16 - " mov %%al, 2(%%edi)\n" // mov [edi+2],al - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), // %2, %3 - "d" (screenSelector) // %4 - ); - break; - case 2: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - " push %%ds \n" // push ds - " mov %%dx, %%ds \n" // mov ds, dx - " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%ax, (%%edi) \n" // mov [edi], al - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), // %2, %3 - "d" (screenSelector) // %4 - ); - break; - case 1: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4] - " push %%ds \n" // push ds - " mov %%dx, %%ds \n" // mov ds, dx - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%al, (%%edi) \n" // mov [edi], al - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), // %2, %3 - "d" (screenSelector) // %4 - ); - break; - } // switch - return; -} // ogDisplay_VESA::RawSetPixel - -void -ogDisplay_VESA::RawSetPixel(uInt32 x, uInt32 y, uInt8 r, uInt8 g, uInt8 b, uInt8 a) { - uInt32 newR, newG, newB, inverseA; - uInt8 dR, dG, dB; - uInt32 colour; - - do { - if (IsBlending()) { - if (0 == a) return; - if (255 == a) { - colour = Pack(r, g, b, a); - break; - } // if a == 255 - - inverseA = 255 - a; - Unpack(RawGetPixel(x, y), dR, dG, dB); - newR = (dR * inverseA + r * a) >> 8; - newG = (dG * inverseA + g * a) >> 8; - newB = (dB * inverseA + b * a) >> 8; - colour = Pack(newR, newG, newB, inverseA); - } else colour = Pack(r, g, b, a); - } while (false); - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - " push %%ds \n" // push ds - " mov %%dx, %%ds \n" // mov ds, dx - - " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%eax, (%%edi) \n" // mov [edi], eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), // %2, %3 - "d" (screenSelector) // %4 - ); - break; - case 3: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - // " add (%%esi,%%ebx,4),%%edi \n" // add edi, [esi + ebx * 4] - " push %%ds \n" // push ds - " mov %%dx, %%ds \n" // mov ds, dx - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} - " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} - // { Draw the pixel } - " mov %%ax, (%%edi) \n" // mov [edi], ax - " shr $16, %%eax \n" // shr eax, 16 - " mov %%al, 2(%%edi)\n" // mov [edi+2],al - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), // %2, %3 - "d" (screenSelector) // %4 - ); - break; - case 2: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - " push %%ds \n" // push ds - " mov %%dx, %%ds \n" // mov ds, dx - " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%ax, (%%edi) \n" // mov [edi], al - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), // %2, %3 - "d" (screenSelector) // %4 - ); - break; - case 1: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4] - " push %%ds \n" // push ds - " mov %%dx, %%ds \n" // mov ds, dx - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%al, (%%edi) \n" // mov [edi], al - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), // %2, %3 - "d" (screenSelector) // %4 - ); - break; - } // switch - return; -} // ogDisplay_VESA::RawSetPixel - -bool -ogDisplay_VESA::Avail(void) { - return ( ((screenSelector != 0) || (buffer != NULL)) && (lineOfs != NULL)); -} // ogDisplay_VESA::Avail - -void -ogDisplay_VESA::GetModeInfo(uInt16 mode) { - __dpmi_regs regs; - memset(modeInfo, 0, sizeof(struct ogModeInfo)); - memset(®s, 0, sizeof(regs)); - dosmemput(modeInfo, sizeof(struct ogModeInfo), __tb); - - int ofs, seg; - - seg = __tb; // __tb is a buffer located in "dos memory". This buffer - ofs = __tb; // is used because the vesa driver cannot acces memory - // above 1 MB (your program is most likely to be located above 1MB). - - ofs &= 0xffff; // Make a real pointer (segment:offse = 16:16) - seg &= 0xffff0000; // from the address of the buffer. - seg >>= 4; - - regs.x.ax = 0x4f01; // Get the modeinfo of a certain vesa video mode, - // this is a structure which contains. - regs.x.cx = mode; // information needed by other functions below. - regs.x.es = seg; - regs.x.di = ofs; - __dpmi_int(0x10, ®s); - - /* This info is located in dos memory, so it has to be moved to your - * program's address space. - */ - dosmemget(__tb, sizeof(struct ogModeInfo), modeInfo); - return; - -} // ogDisplay_VESA::GetModeInfo - -void -ogDisplay_VESA::GetVESAInfo(void) { - unsigned int seg, ofs; - __dpmi_regs regs; - if (NULL == VESAInfo) VESAInfo = new ogVESAInfo; - if (NULL == VESAInfo) return; - - memset(VESAInfo, 0, sizeof(struct ogVESAInfo)); - memset(®s, 0, sizeof(regs)); - VESAInfo->VBESignature[0] = 'V'; // First off initialize the structure. - VESAInfo->VBESignature[1] = 'B'; - VESAInfo->VBESignature[2] = 'E'; - VESAInfo->VBESignature[3] = '2'; - - /* - - Because VBE funtions operate in real mode, we first have to move the - initialized structure to real-mode address space, so the structure can - be filled by the vesa function in real mode. - - */ - dosmemput(VESAInfo, sizeof(struct ogVESAInfo), __tb); - - - seg = __tb; // Calculate real mode address of the buffer. - ofs = __tb; - ofs &= 0xffff; - seg &= 0xffff0000; - seg >>= 4; - - regs.x.ax = 0x4F00; - regs.x.es = seg; - regs.x.di = ofs; - - __dpmi_int(0x10, ®s); // Get vesa info. - - // Move the structure back to - dosmemget(__tb, sizeof(struct ogVESAInfo), VESAInfo); - - VESAInfo->OEMStringPtr = (VESAInfo->OEMStringPtr & 0xFFFF) + - ((VESAInfo->OEMStringPtr & 0xFFFF0000) >> 12); - - VESAInfo->OEMVendorNamePtr= (VESAInfo->OEMVendorNamePtr& 0xFFFF) + - ((VESAInfo->OEMVendorNamePtr& 0xFFFF0000) >> 12); - - VESAInfo->OEMProductNamePtr= (VESAInfo->OEMProductNamePtr& 0xFFFF) + - ((VESAInfo->OEMProductNamePtr& 0xFFFF0000) >> 12); - - VESAInfo->OEMProductRevPtr= (VESAInfo->OEMProductRevPtr& 0xFFFF) + - ((VESAInfo->OEMProductRevPtr& 0xFFFF0000) >> 12); - - VESAInfo->videoModePtr = ((VESAInfo->videoModePtr & 0xFFFF0000) >> 12) + - (VESAInfo->videoModePtr & 0xFFFF); - - return; -} // ogDisplay_VESA::GetVESAInfo - -uInt16 -ogDisplay_VESA::FindMode(uInt32 _xRes, uInt32 _yRes, uInt32 _BPP) { - uInt16 mode; - - if ((320 == _xRes) && (200 == _yRes) && (8 == _BPP)) return 0x13; - -// if ((VESAInfo==NULL) || (VESAInfo->videoModePtr==NULL)) return 0; - if (NULL == modeInfo) return 0; - - for (mode = 0x100; mode < 0x1FF; mode++) { - GetModeInfo(mode); - if ((modeInfo->xRes >= _xRes) && (modeInfo->yRes >= _yRes) && - (modeInfo->bitsPerPixel == _BPP)) - return mode; - } - - return 0; -} // ogDisplay_VESA::FindMode - -void -ogDisplay_VESA::SetMode(uInt16 mode) { - uInt32 size, count; - __dpmi_meminfo mem_info; - - if (0x13 == mode) { - - xRes = 320; - yRes = 200; - maxX = 319; - maxY = 199; - BPP = 8; - bytesPerPix = 1; - - redFieldPosition = 0; - greenFieldPosition = 0; - blueFieldPosition = 0; - alphaFieldPosition = 0; - - redShifter = 0; - greenShifter = 0; - blueShifter = 0; - alphaFieldPosition = 0; - - mem_info.address = 0xA0000; - mem_info.size = 64000; - size = 63999; - buffer = NULL; - __dpmi_physical_address_mapping(&mem_info); - __dpmi_set_segment_base_address(screenSelector, mem_info.address); - __dpmi_set_segment_limit(screenSelector, size); - __dpmi_set_descriptor_access_rights(screenSelector, 0x40F3); - - } else { - buffer = NULL; - mode |= 0x4000; // attempt lfb - GetModeInfo(mode); - if (modeInfo->physBasePtr == 0) return; - size = modeInfo->yRes*modeInfo->bytesPerLine; - - xRes = modeInfo->bytesPerLine; - yRes = modeInfo->yRes; - maxX = modeInfo->xRes-1; - maxY = yRes-1; - - BPP = modeInfo->bitsPerPixel; - bytesPerPix = (BPP + 7) >> 3; - - redFieldPosition = modeInfo->redFieldPosition; - greenFieldPosition = modeInfo->greenFieldPosition; - blueFieldPosition = modeInfo->blueFieldPosition; - alphaFieldPosition = modeInfo->alphaFieldPosition; - - if (4 == bytesPerPix) { - modeInfo->alphaMaskSize = 8; - while ((alphaFieldPosition == redFieldPosition) || - (alphaFieldPosition == greenFieldPosition) || - (alphaFieldPosition == blueFieldPosition)) - alphaFieldPosition += 8; - } // if - - redShifter = 8-modeInfo->redMaskSize; - greenShifter = 8-modeInfo->greenMaskSize; - blueShifter = 8-modeInfo->blueMaskSize; - alphaShifter = 8-modeInfo->alphaMaskSize; - - if (modeInfo->alphaMaskSize != 0) - alphaMasker = ~(OG_MASKS[modeInfo->alphaMaskSize] << alphaFieldPosition); - else - alphaMasker = ~0; - - - mem_info.address = modeInfo->physBasePtr; - mem_info.size = size; - size = ((size+4095) >> 12); - __dpmi_physical_address_mapping(&mem_info); - __dpmi_set_segment_base_address(screenSelector, mem_info.address); - __dpmi_set_segment_limit(screenSelector,size); - __dpmi_set_descriptor_access_rights(screenSelector, 0xC0F3); - } // else - - owner = this; - dataState = ogAliasing; - inGraphics = true; - - if ((lineOfs!=NULL) && (lSize!=0)) delete [] lineOfs; - lSize = yRes*sizeof(uInt32); - lineOfs = new uInt32[yRes];; - if (lineOfs == NULL) return; - lineOfs[0] = 0; - for (count=1; count 8); -// antiAlias=(BPP>8); - if (8 == BPP) SetPal(); - Clear(Pack(0, 0, 0)); - return; -} // ogDisplay_VESA::SetMode - -void -ogDisplay_VESA::SetPal(void) { - if (bytesPerPix != 1) return; - outportb(0x3c8,0); - for (uInt32 c = 0; c < 256; c++) { - outportb(0x3c9, pal[c].red >> 2); - outportb(0x3c9, pal[c].green >> 2); - outportb(0x3c9, pal[c].blue >> 2); - } // for - return; -} // ogDisplay_VESA::SetPal - -void -ogDisplay_VESA::SetPalette(const ogRGBA8 newPal[256]) { - ogSurface::SetPalette(newPal); - SetPal(); - return; -} // ogDisplay_VESA::SetPalette; - -bool -ogDisplay_VESA::Alias(ogSurface& src, uInt32 x1, uInt32 y1, - uInt32 x2, uInt32 y2) { - - SetLastError(ogNoAliasing); - return false; -} // ogDisplay_VESA::Alias - -void -ogDisplay_VESA::Clear(uInt32 colour) { - uInt32 height = 0; - uInt32 xx, yy; - uInt8 r, g, b, a; - - if (!Avail()) return; - - do { - if (IsBlending()) { - Unpack(colour, r, g, b, a); - if (0 == a) return; - if (255 == a) break; - for (yy = 0; yy <= maxY; yy++) - for (xx = 0; xx <= maxX; xx++) - RawSetPixel(xx, yy, r, g, b, a); - } // if - } while (false); - - __asm__ __volatile__("cld\n"); - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - " push %%es \n" // push es - " mov %6, %%ax \n" // mov ax, screenSelector - " mov %%ax, %%es \n" // mov es, ax - " add (%%esi), %%edi \n" // add edi, [esi] - " mov %%ecx, %%esi \n" // mov esi, ecx - " inc %%edx \n" // inc edx (maxX) - " inc %%ebx \n" // inc ebx (maxY) - " mov %5, %%eax \n" // mov eax, colour - " mov %%edx, %%ecx \n" // mov ecx, edx - " shl $2, %%ecx \n" // shl ecx, 2 - " sub %%ecx, %%esi \n" // sub esi, ecx // adjust for pix size - "loop32: \n" - " mov %%edx, %%ecx \n" // mov ecx, edx - " rep \n" - " stosl \n" - " add %%esi, %%edi \n" // add edi, esi - " dec %%ebx \n" - " jnz loop32 \n" - " pop %%es \n" // pop es - : - : "D" (buffer), "S" (lineOfs), // %0, %1 - "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 - "m" (colour), "m" (screenSelector) // %5, %6 - ); - break; - case 3: - __asm__ __volatile__( - " push %%es \n" // push es - " mov %7, %%ax \n" // mov ax, screenSelector - " mov %%ax, %%es \n" // mov es, ax - " add (%%esi), %%edi \n" // add edi, [esi] - " mov %%ecx, %%esi \n" // mov esi, ecx - " inc %%edx \n" // inc edx (maxX) - " inc %%ebx \n" // inc ebx (maxY) - " mov %5, %%eax \n" // mov eax, colour - " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size - " mov %%ebx, %6 \n" // mov height, ebx - " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size - " mov %%eax, %%ebx \n" // mov ebx, eax - " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size - " shr $16, %%ebx \n" // shr ebx, 16 - "oloop24: \n" - " mov %%edx, %%ecx \n" // mov ecx, edx - "iloop24: \n" - " mov %%ax,(%%edi) \n" // mov [edi],ax - " movb %%bl,2(%%edi) \n" // mov [edi+2],bl - " add $3, %%edi \n" // add edi, 3 - " dec %%ecx \n" // dec ecx - " jnz iloop24 \n" - " add %%esi, %%edi \n" // add edi, esi - " decl %6 \n" // dec height - " jnz oloop24 \n" - " pop %%es \n" // pop es - : - : "D" (buffer), "S" (lineOfs), // %0, %1 - "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 - "m" (colour), "m" (height), // %5, %6 - "m" (screenSelector) // %7 - ); - break; - case 2: - __asm__ __volatile__( - " push %%es \n" // push es - " mov %6, %%ax \n" // mov ax, screenSelector - " mov %%ax, %%es \n" // mov es, ax - " add (%%esi), %%edi \n" // add edi, [esi] - " mov %%ecx, %%esi \n" // mov esi, ecx - " inc %%edx \n" // inc edx (maxX) - " inc %%ebx \n" // inc ebx (maxY) - " sub %%edx, %%esi \n" // sub esi, edx - " mov %5, %%eax \n" // mov eax, colour - " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size - " mov %%ax, %%cx \n" // mov cx, ax - " shl $16, %%eax \n" // shl eax, 16 - " mov %%cx, %%ax \n" // mov ax, cx - "loop16: \n" - " mov %%edx, %%ecx \n" // mov ecx, edx - " shr $1, %%ecx \n" // shr ecx, 1 - " rep \n" - " stosl \n" - " jnc noc16 \n" - " stosw \n" - "noc16: \n" - " add %%esi, %%edi \n" // add edi, esi - " dec %%ebx \n" - " jnz loop16 \n" - " pop %%es \n" - : - : "D" (buffer), "S" (lineOfs), // %0, %1 - "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 - "m" (colour), "m" (screenSelector) // %5, %6 - ); - break; - - case 1: - __asm__ __volatile__( - " push %%es \n" // push es - " mov %6, %%ax \n" // mov ax, screenSelector - " mov %%ax, %%es \n" // mov es, ax - " add (%%esi), %%edi \n" // add edi, [esi] - " mov %%ecx, %%esi \n" // mov esi, ecx - " inc %%edx \n" // inc edx (maxY) - " inc %%ebx \n" // inc ebx (maxX) - " mov %5, %%eax \n" // mov eax, colour - " sub %%edx, %%esi \n" // sub esi, edx - " mov %%al, %%ah \n" // mov ah, al - " mov %%ax, %%cx \n" // mov cx, ax - " shl $16, %%eax \n" // shl eax, 16 - " mov %%cx, %%ax \n" // mov ax, cx - "loop8: \n" - " push %%edx \n" - " mov %%edx, %%ecx \n" // mov ecx, edx - " and $3, %%edx \n" // and edx, 3 - " shr $2, %%ecx \n" // shr ecx, 2 - " rep \n" - " stosl \n" - " mov %%edx, %%ecx \n" // mov ecx, edx - " rep \n" - " stosb \n" - " pop %%edx \n" - " add %%esi, %%edi \n" // add edi, esi - " dec %%ebx \n" - " jnz loop8 \n" - " pop %%es \n" // pop es - : - : "D" (buffer), "S" (lineOfs), // %0, %1 - "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 - "m" (colour), "m" (screenSelector) // %5, %6 - ); - break; - } // switch - return; -} // ogDisplay_VESA::Clear - -void -ogDisplay_VESA::CopyLineTo(uInt32 dx, uInt32 dy, const void * src, - uInt32 size) { - /* - * CopyLineTo() - * - * Inputs: - * - * dx - Destination X of the target buffer - * dy - Destination Y of the target buffer - * src - buffer to copy - * size - size in bytes *NOT* pixels - * - * Copies a run of pixels (of the same format) to (x,y) of a buffer - * - * This method is required because of the different implementations of - * copying a run of pixels to a buffer - * - * WARNING!!! This does *NO* error checking. It is assumed that you've - * done all of that. CopyLineTo and CopyLineFrom are the only - * methods that don't check to make sure you're hosing things. Don't - * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!! - */ - movedata(_my_ds(),(uInt32)src, - screenSelector,(uInt32)((uInt8*)buffer+(lineOfs[dy]+dx*bytesPerPix) ), - size); - - return; -} // ogSurface::CopyLineTo - -void -ogDisplay_VESA::CopyLineFrom(uInt32 sx, uInt32 sy, void * dest, uInt32 size) { - /* - * CopyLineFrom() - * - * Inputs: - * - * sx - Source X of the target buffer - * sy - Source Y of the target buffer - * dest - where to put it - * size - size in bytes *NOT* pixels - * - * Copies a run of pixels (of the same format) to (x,y) of a buffer - * - * This method is required because of the different implementations of - * copying a run of pixels to a buffer - * - * WARNING!!! This does *NO* error checking. It is assumed that you've - * done all of that. CopyLineTo and CopyLineFrom are the only - * methods that don't check to make sure you're hosing things. Don't - * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!! - */ - movedata(screenSelector,(uInt32)((uInt8*)buffer+(lineOfs[sy]+sx*bytesPerPix ) ), - _my_ds(),(uInt32)dest, - size); - - return; -} // ogDisplay_VESA::CopyLineFrom - -bool -ogDisplay_VESA::Create(uInt32 _xRes, uInt32 _yRes, ogPixelFmt _pixFormat) { - uInt16 mode; - mode = FindMode(_xRes, _yRes, _pixFormat.BPP); - if ((mode == 0) && ((_pixFormat.BPP==24) || (_pixFormat.BPP==32))) { - if (_pixFormat.BPP==24) _pixFormat.BPP=32; else _pixFormat.BPP=24; - mode = FindMode(_xRes,_yRes,_pixFormat.BPP); - } // if - if (mode!=0) SetMode(mode); - return (mode!=0); -} // ogDisplay_VESA::Create - -bool -ogDisplay_VESA::Clone(ogSurface& src) { - SetLastError(ogNoCloning); - return false; -} // ogDisplay_VESA::Clone - -void -ogDisplay_VESA::CopyPalette(ogSurface& src) { - ogSurface::CopyPalette(src); - SetPal(); - return; -} // ogDisplay_VESA::CopyPalette - -uInt32 -ogDisplay_VESA::GetPixel(int32 x, int32 y) { - uInt32 result; - if (!Avail()) return GetTransparentColor(); - if (((uInt32)x>maxX) || ((uInt32)y>maxY)) - return GetTransparentColor(); - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) - " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} - // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - " mov (%%edi),%%eax \n" // eax, dword ptr [edi] - " mov %%eax, %4 \n" // mov result, eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 - ); - break; - case 3: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) - " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size - " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size - " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size - " add %%esi, %%edi \n" // add edi, esi - // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] - " add %%ecx, %%edi \n" // add edi, ecx - " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] - " xor %%eax, %%eax \n" - " mov 2(%%edi), %%al \n" // mov al, [edi+2] - " shl $16, %%eax \n" // shl eax, 16 - " mov (%%edi), %%ax \n" // mov ax, [edi] - " mov %%eax, %4 \n" // mov result, eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 - ); - break; - case 2: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} - " add %%ecx, %%edi \n" // add edi, ecx - " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] - " mov %%eax, %4 \n" // mov result, eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 - ); - break; - case 1: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] - " mov %%eax, %4 \n" // mov result, eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 - ); - break; - } // switch - return result; -} // ogDisplay_VESA::GetPixel - -void * -ogDisplay_VESA::GetPtr(uInt32 x, uInt32 y) { - return NULL; -} // ogDisplay_VESA::GetPtr - -void -ogDisplay_VESA::HLine(int32 x1, int32 x2, int32 y, uInt32 colour) { - int32 tmp; - uInt8 r, g, b, a; - - if (!Avail()) return; - if ((uInt32)y>maxY) return; - if (x1 > x2) { - tmp= x1; - x1 = x2; - x2 = tmp; - } // if - if (x1 < 0) x1 = 0; - if (x2 > (int32)maxX) x2 = maxX; - if (x2 < x1) return; - - if (IsBlending()) { - Unpack(colour, r, g, b, a); - if (0 == a) return; - if (255 == a) { - for (tmp = x1; tmp <= x2; tmp++) - RawSetPixel(tmp, y, r, g, b, a); - return; - } // if a == 255 - } // if blending - - __asm__ __volatile__("cld \n"); - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - " push %%es \n" // push es - " mov %%dx, %%es \n" // mov es, dx - " sub %%ebx, %%ecx \n" // sub ecx, ebx - " add %%esi, %%edi \n" // add edi, esi - " inc %%ecx \n" - " shl $2, %%ebx \n" // shl ebx, 2 - " add %%ebx, %%edi \n" // add edi, ebx - " rep \n" - " stosl \n" - " pop %%es \n" // pop es - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (colour), "b" (x1), // %2, %3 - "c" (x2), "d" (screenSelector) // %4, %5 - ); - break; - case 3: - __asm__ __volatile__( - " push %%es \n" // push es - " mov %%ax, %%es \n" // mov es, ax - " mov %2, %%eax \n" - " sub %%ebx, %%ecx \n" // sub ecx, ebx - " add %%esi, %%edi \n" // add edi, esi - " add %%ebx, %%ebx \n" // add ebx, ebx - pix size - " inc %%ecx \n" // inc ecx - " add %%edx, %%ebx \n" // add ebx, edx - pix size - " add %%ebx, %%edi \n" // add edi, ebx - " mov %%eax, %%ebx \n" // mov ebx, eax - " shr $16, %%ebx \n" // shr ebx, 16 - "hLlop24: \n" - " mov %%ax, (%%edi) \n" // mov [edi], ax - " mov %%bl, 2(%%edi)\n" // mov [edi+2], bl - " add $3, %%edi \n" // add edi, 3 - " dec %%ecx \n" // dec ecx - " jnz hLlop24 \n" - " pop %%es \n" // pop es - - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "m" (colour), "b" (x1), // %2, %3 - "c" (x2), "d" (x1), "a" (screenSelector) // %4, %5 - ); - break; - case 2: - __asm__ __volatile__( - " push %%es \n" - " mov %%dx, %%es \n" // mov es, dx - " sub %%ebx, %%ecx \n" // sub ecx, ebx - " add %%ebx, %%ebx \n" // add ebx, ebx - pix size - " inc %%ecx \n" // inc ecx - " add %%ebx, %%edi \n" // add edi, ebx - " add %%esi, %%edi \n" // add edi, esi - " xor %%edx, %%edx \n" // xor edx, edx - " mov %%ax, %%dx \n" // mov dx, ax - " shl $16, %%eax \n" // shl eax, 16 - " add %%edx, %%eax \n" // add eax, edx - - " shr $1, %%ecx \n" // shr ecx, 1 - " rep \n" - " stosl \n" - " jnc hLnoc16 \n" - " stosw \n" - "hLnoc16: \n" - " pop %%es \n" - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (colour), "b" (x1), // %2, %3 - "c" (x2), "d" (screenSelector) - ); - break; - case 1: - __asm__ __volatile__( - " push %%es \n" // push es - " mov %%dx, %%es \n" // mov es, dx - " add %%ebx, %%edi \n" // add edi, ebx - " add %%esi, %%edi \n" // add edi, esi - " and $0xff, %%eax \n" // and eax, 0ffh - " sub %%ebx, %%ecx \n" // sub ecx, ebx - " mov %%al, %%ah \n" // mov ah, al - " inc %%ecx \n" // inc ecx - " mov %%eax, %%ebx \n" // mov ebx, eax - " shl $16, %%ebx \n" // shl ebx, 16 - " add %%ebx, %%eax \n" // add eax, ebx - - " mov %%ecx, %%edx \n" // mov edx, ecx - " mov $4, %%ecx \n" // mov ecx, 4 - " sub %%edi, %%ecx \n" // sub ecx, edi - " and $3, %%ecx \n" // and ecx, 3 - " sub %%ecx, %%edx \n" // sub edx, ecx - " jle LEndBytes \n" - " rep \n" - " stosb \n" - " mov %%edx, %%ecx \n" // mov ecx, edx - " and $3, %%edx \n" // and edx, 3 - " shr $2, %%ecx \n" // shr ecx, 2 - " rep \n" - " stosl \n" - "LEndBytes: \n" - " add %%edx, %%ecx \n" // add ecx, edx - " rep \n" - " stosb \n" - " pop %%es \n" - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "a" (colour), "b" (x1), // %2, %3 - "c" (x2), "d" (screenSelector) - ); - break; - } // switch - return; -} // ogDisplay_VESA::HLine - -bool -ogDisplay_VESA::LoadPalette(const char *palfile) { - bool result; - if ((result = ogSurface::LoadPalette(palfile))==true) SetPal(); - return result; -} // ogDisplay_VESA::LoadPalette - -void -ogDisplay_VESA::SetPixel(int32 x, int32 y, uInt32 colour) { - uInt32 newR, newG, newB, inverseA; - uInt8 sR, sG, sB, sA; - uInt8 dR, dG, dB; - - if (!Avail()) return; - if (((uInt32)x > maxX) || ((uInt32)y > maxY)) return; - - do { - if (IsBlending()) { - Unpack(colour, sR, sG, sB, sA); - if (0 == sA) return; - if (255 == sA) break; - inverseA = 255 - sA; - Unpack(RawGetPixel(x, y), dR, dG, dB); - newR = (dR * inverseA + sR * sA) >> 8; - newG = (dG * inverseA + sG * sA) >> 8; - newB = (dB * inverseA + sB * sA) >> 8; - colour = Pack(newR, newG, newB, inverseA); - } // if - } while (false); - - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - " push %%ds \n" // push ds - " mov %4, %%dx \n" // mov dx, screenSelector - " mov %%dx, %%ds \n" // mov ds, dx - " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%eax, (%%edi)\n" // mov [edi], eax - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), "m" (screenSelector) // %2, %3, %4 - ); - break; - case 3: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - " push %%ds \n" // push ds - " mov %4, %%dx \n" // mov dx, screenSelector - " mov %%dx, %%ds \n" // mov ds, dx - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} - " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} - // { Draw the pixel } - " mov %%ax, (%%edi) \n" // mov [edi], ax - " shr $16, %%eax \n" // shr eax, 16 - " mov %%al, 2(%%edi)\n" // mov [edi+2],al - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), "m" (screenSelector) // %2, %3, %4 - ); - break; - case 2: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - " push %%ds \n" - " mov %4, %%dx \n" - " mov %%dx, %%ds \n" - - " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} - " add %%esi, %%edi \n" // add edi, esi - " mov %3, %%eax \n" // mov eax, colour - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%ax, (%%edi) \n" // mov [edi], al - " pop %%ds\n" - - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), "m" (screenSelector) // %2, %3, %4 - ); - break; - - case 1: - __asm__ __volatile__( - // { Calculate offset, prepare the pixel to be drawn } - " push %%ds \n" - " mov %4, %%dx \n" - " mov %%dx, %%ds \n" - " add %%esi, %%edi \n" // add edi, esi - " add %%ecx, %%edi \n" // add edi, ecx - // { Draw the pixel } - " mov %%al, (%%edi) \n" // mov [edi], al - " pop %%ds\n" - : - : "D" (buffer), "S" (lineOfs[y]), // %0, %1 - "c" (x), "a" (colour), "m" (screenSelector) // %2, %3, %4 - ); - break; - } // switch - return; -} // ogDisplay_VESA::SetPixel - -void -ogDisplay_VESA::SetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { - if (NULL == pal) return; - ogSurface::SetPalette(colour,red,green,blue); - outportb(0x3c8, colour); - outportb(0x3c9, red >> 2); - outportb(0x3c9, green >> 2); - outportb(0x3c9, blue >> 2); - - return; -} // ogDisplay_VESA::SetPalette - -void -ogDisplay_VESA::SetPalette(uInt8 colour, uInt8 red, uInt8 green, - uInt8 blue, uInt8 alpha) { - if (NULL == pal) return; - ogSurface::SetPalette(colour, red, green, blue, alpha); - outportb(0x3c8, colour); - outportb(0x3c9, red >> 2); - outportb(0x3c9, green >> 2); - outportb(0x3c9, blue >> 2); - - return; -} // ogDisplay_VESA::SetPalette - -void -ogDisplay_VESA::VFlip(void) { - if (!Avail()) return; - - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax - " add %%edi, %%esi \n" // add esi, edi - "vf32lop: \n" - " push %%esi \n" // push esi - " push %%edi \n" // push edi - "vf32lop2: \n" - " mov (%%edi),%%eax \n" // mov eax, [edi] - " mov (%%esi),%%ecx \n" // mov ecx, [esi] - " mov %%eax,(%%esi) \n" // mov [esi], eax - " mov %%ecx,(%%edi) \n" // mov [edi], ecx - " add $4, %%edi \n" // add edi, 4 - " sub $4, %%esi \n" // sub esi, 4 - " cmp %%esi, %%edi \n" // cmp edi, esi - " jbe vf32lop2 \n" - " pop %%edi \n" // pop edi - " pop %%esi \n" // pop esi - " add %%ebx, %%esi \n" // add esi, ebx - " add %%ebx, %%edi \n" // add edi, ebx - " dec %%edx \n" - " jnz vf32lop \n" - " pop %%ds \n" // pop ds - : - : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*4), // %0, %1 - "b" (xRes), "d" (maxY+1), "a" (screenSelector) // %2, %3, %4 - ); - break; - case 3: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax - " add %%edi, %%esi \n" // add esi, edi - "vf24lop: \n" - " push %%esi \n" // push esi - " push %%edi \n" // push edi - "vf24lop2: \n" - " mov (%%edi),%%ax \n" // mov ax, [edi] - " mov 2(%%edi),%%dl \n" // mov dl, [edi+2] - " mov (%%esi),%%cx \n" // mov cx, [esi] - " mov 2(%%esi),%%dh \n" // mov dh, [esi+2] - " mov %%ax,(%%esi) \n" // mov [esi], ax - " mov %%dl,2(%%esi) \n" // mov [esi+2], dl - " mov %%cx,(%%edi) \n" // mov [edi], cx - " mov %%dh,2(%%edi) \n" // mov [edi+2], dh - " add $3, %%edi \n" // add edi, 3 - " sub $3, %%esi \n" // sub esi, 3 - " cmp %%esi, %%edi \n" // cmp edi, esi - " jbe vf24lop2 \n" - " pop %%edi \n" // pop edi - " pop %%esi \n" // pop esi - " add %%ebx, %%esi \n" // add esi, ebx - " add %%ebx, %%edi \n" // add edi, ebx - " decl %3 \n" // dec height - " jnz vf24lop \n" - " pop %%ds \n" // pop ds - : - : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*3), // %0, %1 - "b" (xRes), "d" (maxY+1), "a" (screenSelector) // %2, %3, %4 - ); - break; - case 2: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax - " add %%edi, %%esi \n" // add esi, edi - "vf16lop: \n" - " push %%esi \n" // push esi - " push %%edi \n" // push edi - "vf16lop2: \n" - " mov (%%edi),%%ax \n" // mov ax, [edi] - " mov (%%esi),%%cx \n" // mov cx, [esi] - " mov %%ax,(%%esi) \n" // mov [esi], ax - " mov %%cx,(%%edi) \n" // mov [edi], cx - " add $2, %%edi \n" // add edi, 2 - " sub $2, %%esi \n" // sub esi, 2 - " cmp %%esi, %%edi \n" // cmp edi, esi - " jbe vf16lop2 \n" - " pop %%edi \n" // pop edi - " pop %%esi \n" // pop esi - " add %%ebx, %%esi \n" // add esi, ebx - " add %%ebx, %%edi \n" // add edi, ebx - " dec %%edx \n" - " jnz vf16lop \n" - " pop %%ds \n" // pop ds - : - : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*2), // %0, %1 - "b" (xRes), "d" (maxY+1), "a" (screenSelector) // %2, %3, %4 - ); - break; - case 1: - __asm__ __volatile__( - " push %%ds \n" // push ds - " mov %%ax, %%ds \n" // mov ds, ax - " add %%edi, %%esi \n" // add esi, edi - "vf8lop: \n" - " push %%esi \n" // push esi - " push %%edi \n" // push edi - "vf8lop2: \n" - " mov (%%edi),%%al \n" // mov al, [edi] - " mov (%%esi),%%ah \n" // mov ah, [esi] - " mov %%al,(%%esi) \n" // mov [esi], al - " mov %%ah,(%%edi) \n" // mov [edi], ah - " inc %%edi \n" // inc edi - " dec %%esi \n" // dec esi - " cmp %%esi, %%edi \n" // cmp edi, esi - " jbe vf8lop2 \n" - " pop %%edi \n" // pop edi - " pop %%esi \n" // pop esi - " add %%ebx, %%esi \n" // add esi, ebx - " add %%ebx, %%edi \n" // add edi, ebx - " dec %%edx \n" - " jnz vf8lop \n" - " pop %%ds \n" // pop ds - : - : "D" ((char *)buffer+lineOfs[0]), "S" (maxX), // %0, %1 - "b" (xRes), "d" (maxY+1), "a" (screenSelector) // %2, %3, %4 - ); - break; - } // switch - return; -} // ogDisplay_VESA::VFlip - -void -ogDisplay_VESA::VLine(int32 x, int32 y1, int32 y2, uInt32 colour) { - int32 tmp; - uInt8 r, g, b, a; - - if (!Avail()) return; - if ((uInt32)x > maxX) return; - - if (y1>y2) { - tmp= y1; - y1 = y2; - y2 = tmp; - } // if - - if (y1 < 0) y1 = 0; - if (y2 > (int32)maxY) y2 = maxY; - if (y2 < y1) return; - - if (IsBlending()) { - - Unpack(colour, r, g, b, a); - - if (0 == a) return; - - if (255 != a) { - for (tmp = y1; tmp <= y2; tmp++) - RawSetPixel(x, tmp, r, g, b, a); - return; - } // if - - } // if blending - - switch (bytesPerPix) { - case 4: - __asm__ __volatile__( - " push %%ds \n" // push ds - " add %%esi, %%edi \n" // add edi, esi - " shl $2, %%ebx \n" // shl ebx, 2 - pix size - " mov %7, %%si \n" // mov si, screenSelector - " mov %%si, %%ds \n" // mov ds, si - " mov %6, %%esi \n" // mov esi, y1 - " sub %%esi, %%ecx \n" // sub ecx, esi - " add %%ebx, %%edi \n" // add edi, ebx - " mov %2, %%eax \n" // mov eax, colour - " inc %%ecx \n" // inc ecx - "vLlop32: \n" - " mov %%eax, (%%edi)\n" // mov [edi], eax - " add %%edx, %%edi \n" // add edi, edx - " dec %%ecx \n" // dec ecx - " jnz vLlop32 \n" - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y1]), // %0, %1 - "m" (colour), "b" (x), // %2, %3 - "c" (y2), "d" (xRes), // %4, %5 - "m" (y1), "m" (screenSelector) // %6, %7 - ); - break; - case 3: - __asm__ __volatile__( - " push %%ds \n" // push ds - " add %%esi, %%edi \n" // add edi, esi - " mov %%ebx, %%esi \n" // mov esi, ebx - pix size - " add %%ebx, %%ebx \n" // add ebx, ebx - pix size - " add %%esi, %%ebx \n" // add ebx, esi - pix size - " mov %7, %%si \n" // mov si, screenSelector - " mov %%si, %%ds \n" // mov ds, si - " mov %6, %%esi \n" // mov esi, y1 - " sub %%esi, %%ecx \n" // sub ecx, esi - " add %%ebx, %%edi \n" // add edi, ebx - " mov %2, %%eax \n" // mov eax, colour - " inc %%ecx \n" // inc ecx - " mov %%eax, %%ebx \n" // mov ebx, eax - " shr $16, %%ebx \n" // shr ebx, 16 - "vLlop24: \n" - " mov %%ax, (%%edi) \n" // mov [edi], eax - " mov %%bl, 2(%%edi)\n" // mov [edi+2], bl - " add %%edx, %%edi \n" // add edi, edx - " dec %%ecx \n" // dec ecx - " jnz vLlop24 \n" - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y1]), // %0, %1 - "m" (colour), "b" (x), // %2, %3 - "c" (y2), "d" (xRes), // %4, %5 - "m" (y1), "m" (screenSelector) // %6, %7 - ); - break; - case 2: - __asm__ __volatile__( - " push %%ds \n" // push ds - " add %%esi, %%edi \n" // add edi, esi - " add %%ebx, %%ebx \n" // add ebx, ebx - pix size - " mov %7, %%si \n" // mov si, screenSelector - " mov %%si, %%ds \n" // mov ds, si - " mov %6, %%esi \n" // mov esi, y1 - " sub %%esi, %%ecx \n" // sub ecx, esi - " add %%ebx, %%edi \n" // add edi, ebx - " mov %2, %%eax \n" // mov eax, colour - " inc %%ecx \n" // inc ecx - "vLlop16: \n" - " mov %%ax, (%%edi) \n" // mov [edi], ax - " add %%edx, %%edi \n" // add edi, edx - " dec %%ecx \n" // dec ecx - " jnz vLlop16 \n" - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y1]), // %0, %1 - "m" (colour), "b" (x), // %2, %3 - "c" (y2), "d" (xRes), // %4, %5 - "m" (y1), "m" (screenSelector) // %6, %7 - ); - break; - case 1: - __asm__ __volatile__( - " push %%ds \n" // push ds - " add %%esi, %%edi \n" // add edi, esi - " mov %7, %%si \n" // mov si, screenSelector - " mov %%si, %%ds \n" // mov ds, si - " mov %6, %%esi \n" // mov esi, y1 - " sub %%esi, %%ecx \n" // sub ecx, esi - " add %%ebx, %%edi \n" // add edi, ebx - " mov %2, %%eax \n" // mov eax, colour - " inc %%ecx \n" // inc ecx - "vLlop8: \n" - " mov %%al, (%%edi) \n" // mov [edi], al - " add %%edx, %%edi \n" // add edi, edx - " dec %%ecx \n" // dec ecx - " jnz vLlop8 \n" - " pop %%ds \n" // pop ds - : - : "D" (buffer), "S" (lineOfs[y1]), // %0, %1 - "m" (colour), "b" (x), // %2, %3 - "c" (y2), "d" (xRes), // %4, %5 - "m" (y1), "m" (screenSelector) // %6, %7 - ); - break; - - } // switch - return; -} // ogDisplay_VESA::VLine - -ogDisplay_VESA::~ogDisplay_VESA(void) { - __dpmi_regs regs; - if (VESAInfo != NULL) delete VESAInfo; - if (modeInfo != NULL) delete modeInfo; - if (attributes != NULL) delete attributes; - if (inGraphics) { - regs.x.ax = 3; - __dpmi_int(0x10, ®s); - } // if inGraphics - - return; -} +#include "objgfx40.h" +#include "defpal.inc" +#include "ogDisplay_VESA.h" +#include // for __tb +#include +#include +#include +#include +#include + +/* + * + * ogDisplay methods + * + */ + +void +initVESAMode(uInt16 mode) { + __dpmi_regs regs; + regs.x.ax = 0x4f02; + regs.x.bx = mode; + __dpmi_int(0x10, ®s); + return; +} + +ogDisplay_VESA::ogDisplay_VESA(void) : ogSurface() { + pages[0] = pages[1] = NULL; + activePage = visualPage = 0; + inGraphics = false; + VESAInfo = new ogVESAInfo; + modeInfo = new ogModeInfo; + pal = new ogRGBA8[256]; + attributes = new ogAttributes(); + + GetVESAInfo(); + + screenSelector = __dpmi_allocate_ldt_descriptors(1); + + return; +} // ogDisplay_VESA::ogDisplay_VESA + +uInt32 +ogDisplay_VESA::RawGetPixel(uInt32 x, uInt32 y) { + uInt32 result; + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) + " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " mov (%%edi),%%eax \n" // eax,word ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 3: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) + " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size + " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size + " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size + " add %%esi, %%edi \n" // add edi, esi + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " xor %%eax, %%eax \n" + " mov 2(%%edi), %%al \n" // mov al, [edi+2] + " shl $16, %%eax \n" // shl eax, 16 + " mov (%%edi), %%ax \n" // mov ax, [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 2: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 1: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + } // switch + return result; +} // ogDisplay_VESA::RawGetPixel + +void +ogDisplay_VESA::RawSetPixel(uInt32 x, uInt32 y, uInt32 colour) { + uInt32 newR, newG, newB, inverseA; + uInt8 sR, sG, sB, sA; + uInt8 dR, dG, dB; + + do { + if (ogIsBlending()) { + ogUnpack(colour, sR, sG, sB, sA); + if (sA == 0) return; + if (sA == 255) break; + inverseA = 255 - sA; + ogUnpack(RawGetPixel(x, y), dR, dG, dB); + newR = (dR * inverseA + sR * sA) >> 8; + newG = (dG * inverseA + sG * sA) >> 8; + newB = (dB * inverseA + sB * sA) >> 8; + colour = ogPack(newR, newG, newB, inverseA); + } // if + } while (false); + + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi) \n" // mov [edi], eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (screenSelector) // %4 + ); + break; + case 3: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + // " add (%%esi,%%ebx,4),%%edi \n" // add edi, [esi + ebx * 4] + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (screenSelector) // %4 + ); + break; + case 2: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (screenSelector) // %4 + ); + break; + case 1: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4] + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (screenSelector) // %4 + ); + break; + } // switch + return; +} // ogDisplay_VESA::RawSetPixel + +void +ogDisplay_VESA::RawSetPixel(uInt32 x, uInt32 y, uInt8 r, uInt8 g, uInt8 b, uInt8 a) { + uInt32 newR, newG, newB, inverseA; + uInt8 dR, dG, dB; + uInt32 colour; + + do { + if (ogIsBlending()) { + if (a == 0) return; + if (a == 255) { + colour = ogPack(r, g, b, a); + break; + } // if a == 255 + + inverseA = 255 - a; + ogUnpack(RawGetPixel(x, y), dR, dG, dB); + newR = (dR * inverseA + r * a) >> 8; + newG = (dG * inverseA + g * a) >> 8; + newB = (dB * inverseA + b * a) >> 8; + colour = ogPack(newR, newG, newB, inverseA); + } else colour = ogPack(r, g, b, a); + } while (false); + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi) \n" // mov [edi], eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (screenSelector) // %4 + ); + break; + case 3: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + // " add (%%esi,%%ebx,4),%%edi \n" // add edi, [esi + ebx * 4] + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (screenSelector) // %4 + ); + break; + case 2: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (screenSelector) // %4 + ); + break; + case 1: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx * 4] + " push %%ds \n" // push ds + " mov %%dx, %%ds \n" // mov ds, dx + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), // %2, %3 + "d" (screenSelector) // %4 + ); + break; + } // switch + return; +} // ogDisplay_VESA::RawSetPixel + +bool +ogDisplay_VESA::ogAvail(void) { + return ( ((screenSelector != 0) || (buffer != NULL)) && (lineOfs != NULL)); +} // ogDisplay_VESA::Avail + +void +ogDisplay_VESA::GetModeInfo(uInt16 mode) { + __dpmi_regs regs; + memset(modeInfo, 0, sizeof(struct ogModeInfo)); + memset(®s, 0, sizeof(regs)); + dosmemput(modeInfo, sizeof(struct ogModeInfo), __tb); + + int ofs, seg; + + seg = __tb; // __tb is a buffer located in "dos memory". This buffer + ofs = __tb; // is used because the vesa driver cannot acces memory + // above 1 MB (your program is most likely to be located above 1MB). + + ofs &= 0xffff; // Make a real pointer (segment:offse = 16:16) + seg &= 0xffff0000; // from the address of the buffer. + seg >>= 4; + + regs.x.ax = 0x4f01; // Get the modeinfo of a certain vesa video mode, + // this is a structure which contains. + regs.x.cx = mode; // information needed by other functions below. + regs.x.es = seg; + regs.x.di = ofs; + __dpmi_int(0x10, ®s); + + /* This info is located in dos memory, so it has to be moved to your + * program's address space. + */ + dosmemget(__tb, sizeof(struct ogModeInfo), modeInfo); + return; + +} // ogDisplay_VESA::GetModeInfo + +void +ogDisplay_VESA::GetVESAInfo(void) { + unsigned int seg, ofs; + __dpmi_regs regs; + if (NULL == VESAInfo) VESAInfo = new ogVESAInfo; + if (NULL == VESAInfo) return; + + memset(VESAInfo, 0, sizeof(struct ogVESAInfo)); + memset(®s, 0, sizeof(regs)); + VESAInfo->VBESignature[0] = 'V'; // First off initialize the structure. + VESAInfo->VBESignature[1] = 'B'; + VESAInfo->VBESignature[2] = 'E'; + VESAInfo->VBESignature[3] = '2'; + + /* + + Because VBE funtions operate in real mode, we first have to move the + initialized structure to real-mode address space, so the structure can + be filled by the vesa function in real mode. + + */ + dosmemput(VESAInfo, sizeof(struct ogVESAInfo), __tb); + + + seg = __tb; // Calculate real mode address of the buffer. + ofs = __tb; + ofs &= 0xffff; + seg &= 0xffff0000; + seg >>= 4; + + regs.x.ax = 0x4F00; + regs.x.es = seg; + regs.x.di = ofs; + + __dpmi_int(0x10, ®s); // Get vesa info. + + // Move the structure back to + dosmemget(__tb, sizeof(struct ogVESAInfo), VESAInfo); + + VESAInfo->OEMStringPtr = (VESAInfo->OEMStringPtr & 0xFFFF) + + ((VESAInfo->OEMStringPtr & 0xFFFF0000) >> 12); + + VESAInfo->OEMVendorNamePtr= (VESAInfo->OEMVendorNamePtr& 0xFFFF) + + ((VESAInfo->OEMVendorNamePtr& 0xFFFF0000) >> 12); + + VESAInfo->OEMProductNamePtr= (VESAInfo->OEMProductNamePtr& 0xFFFF) + + ((VESAInfo->OEMProductNamePtr& 0xFFFF0000) >> 12); + + VESAInfo->OEMProductRevPtr= (VESAInfo->OEMProductRevPtr& 0xFFFF) + + ((VESAInfo->OEMProductRevPtr& 0xFFFF0000) >> 12); + + VESAInfo->videoModePtr = ((VESAInfo->videoModePtr & 0xFFFF0000) >> 12) + + (VESAInfo->videoModePtr & 0xFFFF); + + return; +} // ogDisplay_VESA::GetVESAInfo + +uInt16 +ogDisplay_VESA::FindMode(uInt32 _xRes, uInt32 _yRes, uInt32 _BPP) { + uInt16 mode; + + if ((_xRes == 320) && (_yRes == 200) && (_BPP == 8)) return 0x13; + +// if ((VESAInfo==NULL) || (VESAInfo->videoModePtr==NULL)) return 0; + if (modeInfo == NULL) return 0; + + for (mode = 0x100; mode < 0x1FF; mode++) { + GetModeInfo(mode); + if ((modeInfo->xRes >= _xRes) && (modeInfo->yRes >= _yRes) && + (modeInfo->bitsPerPixel == _BPP)) + return mode; + } + + return 0; +} // ogDisplay_VESA::FindMode + +void +ogDisplay_VESA::SetMode(uInt16 mode) { + uInt32 size, count; + __dpmi_meminfo mem_info; + + if (mode == 0x13) { + + xRes = 320; + yRes = 200; + maxX = 319; + maxY = 199; + BPP = 8; + bytesPerPix = 1; + + redFieldPosition = 0; + greenFieldPosition = 0; + blueFieldPosition = 0; + alphaFieldPosition = 0; + + redShifter = 0; + greenShifter = 0; + blueShifter = 0; + alphaFieldPosition = 0; + + mem_info.address = 0xA0000; + mem_info.size = 64000; + size = 63999; + buffer = NULL; + __dpmi_physical_address_mapping(&mem_info); + __dpmi_set_segment_base_address(screenSelector, mem_info.address); + __dpmi_set_segment_limit(screenSelector, size); + __dpmi_set_descriptor_access_rights(screenSelector, 0x40F3); + + } else { + buffer = NULL; + mode |= 0x4000; // attempt lfb + GetModeInfo(mode); + if (modeInfo->physBasePtr == 0) return; + size = modeInfo->yRes*modeInfo->bytesPerLine; + + xRes = modeInfo->bytesPerLine; + yRes = modeInfo->yRes; + maxX = modeInfo->xRes-1; + maxY = yRes-1; + + BPP = modeInfo->bitsPerPixel; + bytesPerPix = (BPP + 7) >> 3; + + redFieldPosition = modeInfo->redFieldPosition; + greenFieldPosition = modeInfo->greenFieldPosition; + blueFieldPosition = modeInfo->blueFieldPosition; + alphaFieldPosition = modeInfo->alphaFieldPosition; + + if (4 == bytesPerPix) { + modeInfo->alphaMaskSize = 8; + while ((alphaFieldPosition == redFieldPosition) || + (alphaFieldPosition == greenFieldPosition) || + (alphaFieldPosition == blueFieldPosition)) + alphaFieldPosition += 8; + } // if + + redShifter = 8-modeInfo->redMaskSize; + greenShifter = 8-modeInfo->greenMaskSize; + blueShifter = 8-modeInfo->blueMaskSize; + alphaShifter = 8-modeInfo->alphaMaskSize; + + if (modeInfo->alphaMaskSize != 0) + alphaMasker = ~(OG_MASKS[modeInfo->alphaMaskSize] << alphaFieldPosition); + else + alphaMasker = ~0; + + + mem_info.address = modeInfo->physBasePtr; + mem_info.size = size; + size = ((size+4095) >> 12); + __dpmi_physical_address_mapping(&mem_info); + __dpmi_set_segment_base_address(screenSelector, mem_info.address); + __dpmi_set_segment_limit(screenSelector,size); + __dpmi_set_descriptor_access_rights(screenSelector, 0xC0F3); + } // else + + owner = this; + dataState = ogAliasing; + inGraphics = true; + + if ((lineOfs != NULL) && (lSize != 0)) delete [] lineOfs; + lSize = yRes*sizeof(uInt32); + lineOfs = new uInt32[yRes];; + if (lineOfs == NULL) return; + lineOfs[0] = 0; + for (count=1; count 8); +// antiAlias=(BPP>8); + if (BPP == 8) SetPal(); + ogClear(ogPack(0, 0, 0)); + return; +} // ogDisplay_VESA::SetMode + +void +ogDisplay_VESA::SetPal(void) { + if (bytesPerPix != 1) return; + outportb(0x3c8,0); + for (uInt32 c = 0; c < 256; c++) { + outportb(0x3c9, pal[c].red >> 2); + outportb(0x3c9, pal[c].green >> 2); + outportb(0x3c9, pal[c].blue >> 2); + } // for + return; +} // ogDisplay_VESA::SetPal + +void +ogDisplay_VESA::ogSetPalette(const ogRGBA8 newPal[256]) { + ogSurface::ogSetPalette(newPal); + SetPal(); + return; +} // ogDisplay_VESA::SetPalette; + +bool +ogDisplay_VESA::ogAlias(ogSurface& src, uInt32 x1, uInt32 y1, + uInt32 x2, uInt32 y2) { + + ogSetLastError(ogNoAliasing); + return false; +} // ogDisplay_VESA::Alias + +void +ogDisplay_VESA::ogClear(uInt32 colour) { + uInt32 height = 0; + uInt32 xx, yy; + uInt8 r, g, b, a; + + if (!ogAvail()) return; + + do { + if (ogIsBlending()) { + ogUnpack(colour, r, g, b, a); + if (a == 0) return; + if (a == 255) break; + for (yy = 0; yy <= maxY; yy++) + for (xx = 0; xx <= maxX; xx++) + RawSetPixel(xx, yy, r, g, b, a); + } // if + } while (false); + + __asm__ __volatile__("cld\n"); + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %6, %%ax \n" // mov ax, screenSelector + " mov %%ax, %%es \n" // mov es, ax + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " mov %5, %%eax \n" // mov eax, colour + " mov %%edx, %%ecx \n" // mov ecx, edx + " shl $2, %%ecx \n" // shl ecx, 2 + " sub %%ecx, %%esi \n" // sub esi, ecx // adjust for pix size + "loop32: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " rep \n" + " stosl \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop32 \n" + " pop %%es \n" // pop es + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 + "m" (colour), "m" (screenSelector) // %5, %6 + ); + break; + case 3: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %7, %%ax \n" // mov ax, screenSelector + " mov %%ax, %%es \n" // mov es, ax + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " mov %5, %%eax \n" // mov eax, colour + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%ebx, %6 \n" // mov height, ebx + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%eax, %%ebx \n" // mov ebx, eax + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " shr $16, %%ebx \n" // shr ebx, 16 + "oloop24: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + "iloop24: \n" + " mov %%ax,(%%edi) \n" // mov [edi],ax + " movb %%bl,2(%%edi) \n" // mov [edi+2],bl + " add $3, %%edi \n" // add edi, 3 + " dec %%ecx \n" // dec ecx + " jnz iloop24 \n" + " add %%esi, %%edi \n" // add edi, esi + " decl %6 \n" // dec height + " jnz oloop24 \n" + " pop %%es \n" // pop es + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 + "m" (colour), "m" (height), // %5, %6 + "m" (screenSelector) // %7 + ); + break; + case 2: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %6, %%ax \n" // mov ax, screenSelector + " mov %%ax, %%es \n" // mov es, ax + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxX) + " inc %%ebx \n" // inc ebx (maxY) + " sub %%edx, %%esi \n" // sub esi, edx + " mov %5, %%eax \n" // mov eax, colour + " sub %%edx, %%esi \n" // sub esi, edx // adjust for pix size + " mov %%ax, %%cx \n" // mov cx, ax + " shl $16, %%eax \n" // shl eax, 16 + " mov %%cx, %%ax \n" // mov ax, cx + "loop16: \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " shr $1, %%ecx \n" // shr ecx, 1 + " rep \n" + " stosl \n" + " jnc noc16 \n" + " stosw \n" + "noc16: \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop16 \n" + " pop %%es \n" + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 + "m" (colour), "m" (screenSelector) // %5, %6 + ); + break; + + case 1: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %6, %%ax \n" // mov ax, screenSelector + " mov %%ax, %%es \n" // mov es, ax + " add (%%esi), %%edi \n" // add edi, [esi] + " mov %%ecx, %%esi \n" // mov esi, ecx + " inc %%edx \n" // inc edx (maxY) + " inc %%ebx \n" // inc ebx (maxX) + " mov %5, %%eax \n" // mov eax, colour + " sub %%edx, %%esi \n" // sub esi, edx + " mov %%al, %%ah \n" // mov ah, al + " mov %%ax, %%cx \n" // mov cx, ax + " shl $16, %%eax \n" // shl eax, 16 + " mov %%cx, %%ax \n" // mov ax, cx + "loop8: \n" + " push %%edx \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " and $3, %%edx \n" // and edx, 3 + " shr $2, %%ecx \n" // shr ecx, 2 + " rep \n" + " stosl \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " rep \n" + " stosb \n" + " pop %%edx \n" + " add %%esi, %%edi \n" // add edi, esi + " dec %%ebx \n" + " jnz loop8 \n" + " pop %%es \n" // pop es + : + : "D" (buffer), "S" (lineOfs), // %0, %1 + "b" (maxY), "c" (xRes), "d" (maxX), // %2, %3, %4 + "m" (colour), "m" (screenSelector) // %5, %6 + ); + break; + } // switch + return; +} // ogDisplay_VESA::Clear + +void +ogDisplay_VESA::ogCopyLineTo(uInt32 dx, uInt32 dy, const void * src, + uInt32 size) { + /* + * ogCopyLineTo() + * + * Inputs: + * + * dx - Destination X of the target buffer + * dy - Destination Y of the target buffer + * src - buffer to copy + * size - size in bytes *NOT* pixels + * + * Copies a run of pixels (of the same format) to (x,y) of a buffer + * + * This method is required because of the different implementations of + * copying a run of pixels to a buffer + * + * WARNING!!! This does *NO* error checking. It is assumed that you've + * done all of that. CopyLineTo and CopyLineFrom are the only + * methods that don't check to make sure you're hosing things. Don't + * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!! + */ + movedata(_my_ds(),(uInt32)src, + screenSelector,(uInt32)((uInt8*)buffer+(lineOfs[dy]+dx*bytesPerPix) ), + size); + + return; +} // ogSurface::ogCopyLineTo + +void +ogDisplay_VESA::ogCopyLineFrom(uInt32 sx, uInt32 sy, void * dest, uInt32 size) { + /* + * CopyLineFrom() + * + * Inputs: + * + * sx - Source X of the target buffer + * sy - Source Y of the target buffer + * dest - where to put it + * size - size in bytes *NOT* pixels + * + * Copies a run of pixels (of the same format) to (x,y) of a buffer + * + * This method is required because of the different implementations of + * copying a run of pixels to a buffer + * + * WARNING!!! This does *NO* error checking. It is assumed that you've + * done all of that. CopyLineTo and CopyLineFrom are the only + * methods that don't check to make sure you're hosing things. Don't + * use this method unless YOU KNOW WHAT YOU'RE DOING!!!!!!!!! + */ + movedata(screenSelector,(uInt32)((uInt8*)buffer+(lineOfs[sy]+sx*bytesPerPix ) ), + _my_ds(),(uInt32)dest, + size); + + return; +} // ogDisplay_VESA::ogCopyLineFrom + +bool +ogDisplay_VESA::ogCreate(uInt32 _xRes, uInt32 _yRes, ogPixelFmt _pixFormat) { + uInt16 mode; + mode = FindMode(_xRes, _yRes, _pixFormat.BPP); + if ((mode == 0) && ((_pixFormat.BPP==24) || (_pixFormat.BPP==32))) { + if (_pixFormat.BPP==24) _pixFormat.BPP=32; else _pixFormat.BPP=24; + mode = FindMode(_xRes,_yRes,_pixFormat.BPP); + } // if + if (mode!=0) SetMode(mode); + return (mode!=0); +} // ogDisplay_VESA::ogCreate + +bool +ogDisplay_VESA::ogClone(ogSurface& src) { + ogSetLastError(ogNoCloning); + return false; +} // ogDisplay_VESA::ogClone + +void +ogDisplay_VESA::ogCopyPalette(ogSurface& src) { + ogSurface::ogCopyPalette(src); + SetPal(); + return; +} // ogDisplay_VESA::ogCopyPalette + +uInt32 +ogDisplay_VESA::ogGetPixel(int32 x, int32 y) { + uInt32 result; + if (!ogAvail()) return ogGetTransparentColor(); + if (((uInt32)x>maxX) || ((uInt32)y>maxY)) + return ogGetTransparentColor(); + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) + " shl $2, %%ecx \n" // shl ecx, 2 {adjust for pixel size} + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " mov (%%edi),%%eax \n" // eax, dword ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 3: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) + " mov %%ecx, %%eax \n" // mov eax, ecx - adjust for pixel size + " add %%ecx, %%ecx \n" // add ecx, ecx - adjust for pixel size + " add %%eax, %%ecx \n" // add ecx, eax - adjust for pixel size + " add %%esi, %%edi \n" // add edi, esi + // " add (%%esi,%%ebx,4), %%edi \n" // add edi, [esi + ebx*4] + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " xor %%eax, %%eax \n" + " mov 2(%%edi), %%al \n" // mov al, [edi+2] + " shl $16, %%eax \n" // shl eax, 16 + " mov (%%edi), %%ax \n" // mov ax, [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 2: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx + " movzwl (%%edi),%%eax \n" // movzx edx,word ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + case 1: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax (screenSelector) + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " movzbl (%%edi),%%eax \n" // movzx edx,byte ptr [edi] + " mov %%eax, %4 \n" // mov result, eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (screenSelector), "c" (x), "m" (result) // %2, %3, %4 + ); + break; + } // switch + return result; +} // ogDisplay_VESA::ogGetPixel + +void * +ogDisplay_VESA::ogGetPtr(uInt32 x, uInt32 y) { + return NULL; +} // ogDisplay_VESA::ogGetPtr + +void +ogDisplay_VESA::ogHLine(int32 x1, int32 x2, int32 y, uInt32 colour) { + int32 tmp; + uInt8 r, g, b, a; + + if (!ogAvail()) return; + if ((uInt32)y>maxY) return; + if (x1 > x2) { + tmp= x1; + x1 = x2; + x2 = tmp; + } // if + if (x1 < 0) x1 = 0; + if (x2 > (int32)maxX) x2 = maxX; + if (x2 < x1) return; + + if (ogIsBlending()) { + ogUnpack(colour, r, g, b, a); + if (a == 0) return; + if (a == 255) { + for (tmp = x1; tmp <= x2; tmp++) + RawSetPixel(tmp, y, r, g, b, a); + return; + } // if a == 255 + } // if blending + + __asm__ __volatile__("cld \n"); + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %%dx, %%es \n" // mov es, dx + " sub %%ebx, %%ecx \n" // sub ecx, ebx + " add %%esi, %%edi \n" // add edi, esi + " inc %%ecx \n" + " shl $2, %%ebx \n" // shl ebx, 2 + " add %%ebx, %%edi \n" // add edi, ebx + " rep \n" + " stosl \n" + " pop %%es \n" // pop es + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (colour), "b" (x1), // %2, %3 + "c" (x2), "d" (screenSelector) // %4, %5 + ); + break; + case 3: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %%ax, %%es \n" // mov es, ax + " mov %2, %%eax \n" + " sub %%ebx, %%ecx \n" // sub ecx, ebx + " add %%esi, %%edi \n" // add edi, esi + " add %%ebx, %%ebx \n" // add ebx, ebx - pix size + " inc %%ecx \n" // inc ecx + " add %%edx, %%ebx \n" // add ebx, edx - pix size + " add %%ebx, %%edi \n" // add edi, ebx + " mov %%eax, %%ebx \n" // mov ebx, eax + " shr $16, %%ebx \n" // shr ebx, 16 + "hLlop24: \n" + " mov %%ax, (%%edi) \n" // mov [edi], ax + " mov %%bl, 2(%%edi)\n" // mov [edi+2], bl + " add $3, %%edi \n" // add edi, 3 + " dec %%ecx \n" // dec ecx + " jnz hLlop24 \n" + " pop %%es \n" // pop es + + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "m" (colour), "b" (x1), // %2, %3 + "c" (x2), "d" (x1), "a" (screenSelector) // %4, %5 + ); + break; + case 2: + __asm__ __volatile__( + " push %%es \n" + " mov %%dx, %%es \n" // mov es, dx + " sub %%ebx, %%ecx \n" // sub ecx, ebx + " add %%ebx, %%ebx \n" // add ebx, ebx - pix size + " inc %%ecx \n" // inc ecx + " add %%ebx, %%edi \n" // add edi, ebx + " add %%esi, %%edi \n" // add edi, esi + " xor %%edx, %%edx \n" // xor edx, edx + " mov %%ax, %%dx \n" // mov dx, ax + " shl $16, %%eax \n" // shl eax, 16 + " add %%edx, %%eax \n" // add eax, edx + + " shr $1, %%ecx \n" // shr ecx, 1 + " rep \n" + " stosl \n" + " jnc hLnoc16 \n" + " stosw \n" + "hLnoc16: \n" + " pop %%es \n" + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (colour), "b" (x1), // %2, %3 + "c" (x2), "d" (screenSelector) + ); + break; + case 1: + __asm__ __volatile__( + " push %%es \n" // push es + " mov %%dx, %%es \n" // mov es, dx + " add %%ebx, %%edi \n" // add edi, ebx + " add %%esi, %%edi \n" // add edi, esi + " and $0xff, %%eax \n" // and eax, 0ffh + " sub %%ebx, %%ecx \n" // sub ecx, ebx + " mov %%al, %%ah \n" // mov ah, al + " inc %%ecx \n" // inc ecx + " mov %%eax, %%ebx \n" // mov ebx, eax + " shl $16, %%ebx \n" // shl ebx, 16 + " add %%ebx, %%eax \n" // add eax, ebx + + " mov %%ecx, %%edx \n" // mov edx, ecx + " mov $4, %%ecx \n" // mov ecx, 4 + " sub %%edi, %%ecx \n" // sub ecx, edi + " and $3, %%ecx \n" // and ecx, 3 + " sub %%ecx, %%edx \n" // sub edx, ecx + " jle LEndBytes \n" + " rep \n" + " stosb \n" + " mov %%edx, %%ecx \n" // mov ecx, edx + " and $3, %%edx \n" // and edx, 3 + " shr $2, %%ecx \n" // shr ecx, 2 + " rep \n" + " stosl \n" + "LEndBytes: \n" + " add %%edx, %%ecx \n" // add ecx, edx + " rep \n" + " stosb \n" + " pop %%es \n" + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "a" (colour), "b" (x1), // %2, %3 + "c" (x2), "d" (screenSelector) + ); + break; + } // switch + return; +} // ogDisplay_VESA::ogHLine + +bool +ogDisplay_VESA::ogLoadPalette(const char *palfile) { + bool result; + if ((result = ogSurface::ogLoadPalette(palfile))==true) SetPal(); + return result; +} // ogDisplay_VESA::ogLoadPalette + +void +ogDisplay_VESA::ogSetPixel(int32 x, int32 y, uInt32 colour) { + uInt32 newR, newG, newB, inverseA; + uInt8 sR, sG, sB, sA; + uInt8 dR, dG, dB; + + if (!ogAvail()) return; + if (((uInt32)x > maxX) || ((uInt32)y > maxY)) return; + + do { + if (ogIsBlending()) { + ogUnpack(colour, sR, sG, sB, sA); + if (sA == 0) return; + if (sA == 255) break; + inverseA = 255 - sA; + ogUnpack(RawGetPixel(x, y), dR, dG, dB); + newR = (dR * inverseA + sR * sA) >> 8; + newG = (dG * inverseA + sG * sA) >> 8; + newB = (dB * inverseA + sB * sA) >> 8; + colour = ogPack(newR, newG, newB, inverseA); + } // if + } while (false); + + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %4, %%dx \n" // mov dx, screenSelector + " mov %%dx, %%ds \n" // mov ds, dx + " shl $2, %%ecx \n" // shl eax, 2 {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%eax, (%%edi)\n" // mov [edi], eax + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), "m" (screenSelector) // %2, %3, %4 + ); + break; + case 3: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" // push ds + " mov %4, %%dx \n" // mov dx, screenSelector + " mov %%dx, %%ds \n" // mov ds, dx + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + " add %%ecx, %%edi \n" // add edi, ecx {adjust for pixel size} + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], ax + " shr $16, %%eax \n" // shr eax, 16 + " mov %%al, 2(%%edi)\n" // mov [edi+2],al + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), "m" (screenSelector) // %2, %3, %4 + ); + break; + case 2: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" + " mov %4, %%dx \n" + " mov %%dx, %%ds \n" + + " add %%ecx, %%ecx \n" // add ecx, ecx {adjust for pixel size} + " add %%esi, %%edi \n" // add edi, esi + " mov %3, %%eax \n" // mov eax, colour + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%ax, (%%edi) \n" // mov [edi], al + " pop %%ds\n" + + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), "m" (screenSelector) // %2, %3, %4 + ); + break; + + case 1: + __asm__ __volatile__( + // { Calculate offset, prepare the pixel to be drawn } + " push %%ds \n" + " mov %4, %%dx \n" + " mov %%dx, %%ds \n" + " add %%esi, %%edi \n" // add edi, esi + " add %%ecx, %%edi \n" // add edi, ecx + // { Draw the pixel } + " mov %%al, (%%edi) \n" // mov [edi], al + " pop %%ds\n" + : + : "D" (buffer), "S" (lineOfs[y]), // %0, %1 + "c" (x), "a" (colour), "m" (screenSelector) // %2, %3, %4 + ); + break; + } // switch + return; +} // ogDisplay_VESA::ogSetPixel + +void +ogDisplay_VESA::ogSetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { + if (pal == NULL) return; + ogSurface::ogSetPalette(colour,red,green,blue); + outportb(0x3c8, colour); + outportb(0x3c9, red >> 2); + outportb(0x3c9, green >> 2); + outportb(0x3c9, blue >> 2); + + return; +} // ogDisplay_VESA::ogSetPalette + +void +ogDisplay_VESA::ogSetPalette(uInt8 colour, uInt8 red, uInt8 green, + uInt8 blue, uInt8 alpha) { + if (pal == NULL) return; + ogSurface::ogSetPalette(colour, red, green, blue, alpha); + outportb(0x3c8, colour); + outportb(0x3c9, red >> 2); + outportb(0x3c9, green >> 2); + outportb(0x3c9, blue >> 2); + + return; +} // ogDisplay_VESA::ogSetPalette + +void +ogDisplay_VESA::ogVFlip(void) { + if (!ogAvail()) return; + + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax + " add %%edi, %%esi \n" // add esi, edi + "vf32lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf32lop2: \n" + " mov (%%edi),%%eax \n" // mov eax, [edi] + " mov (%%esi),%%ecx \n" // mov ecx, [esi] + " mov %%eax,(%%esi) \n" // mov [esi], eax + " mov %%ecx,(%%edi) \n" // mov [edi], ecx + " add $4, %%edi \n" // add edi, 4 + " sub $4, %%esi \n" // sub esi, 4 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf32lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf32lop \n" + " pop %%ds \n" // pop ds + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*4), // %0, %1 + "b" (xRes), "d" (maxY+1), "a" (screenSelector) // %2, %3, %4 + ); + break; + case 3: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax + " add %%edi, %%esi \n" // add esi, edi + "vf24lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf24lop2: \n" + " mov (%%edi),%%ax \n" // mov ax, [edi] + " mov 2(%%edi),%%dl \n" // mov dl, [edi+2] + " mov (%%esi),%%cx \n" // mov cx, [esi] + " mov 2(%%esi),%%dh \n" // mov dh, [esi+2] + " mov %%ax,(%%esi) \n" // mov [esi], ax + " mov %%dl,2(%%esi) \n" // mov [esi+2], dl + " mov %%cx,(%%edi) \n" // mov [edi], cx + " mov %%dh,2(%%edi) \n" // mov [edi+2], dh + " add $3, %%edi \n" // add edi, 3 + " sub $3, %%esi \n" // sub esi, 3 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf24lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " decl %3 \n" // dec height + " jnz vf24lop \n" + " pop %%ds \n" // pop ds + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*3), // %0, %1 + "b" (xRes), "d" (maxY+1), "a" (screenSelector) // %2, %3, %4 + ); + break; + case 2: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax + " add %%edi, %%esi \n" // add esi, edi + "vf16lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf16lop2: \n" + " mov (%%edi),%%ax \n" // mov ax, [edi] + " mov (%%esi),%%cx \n" // mov cx, [esi] + " mov %%ax,(%%esi) \n" // mov [esi], ax + " mov %%cx,(%%edi) \n" // mov [edi], cx + " add $2, %%edi \n" // add edi, 2 + " sub $2, %%esi \n" // sub esi, 2 + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf16lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf16lop \n" + " pop %%ds \n" // pop ds + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX*2), // %0, %1 + "b" (xRes), "d" (maxY+1), "a" (screenSelector) // %2, %3, %4 + ); + break; + case 1: + __asm__ __volatile__( + " push %%ds \n" // push ds + " mov %%ax, %%ds \n" // mov ds, ax + " add %%edi, %%esi \n" // add esi, edi + "vf8lop: \n" + " push %%esi \n" // push esi + " push %%edi \n" // push edi + "vf8lop2: \n" + " mov (%%edi),%%al \n" // mov al, [edi] + " mov (%%esi),%%ah \n" // mov ah, [esi] + " mov %%al,(%%esi) \n" // mov [esi], al + " mov %%ah,(%%edi) \n" // mov [edi], ah + " inc %%edi \n" // inc edi + " dec %%esi \n" // dec esi + " cmp %%esi, %%edi \n" // cmp edi, esi + " jbe vf8lop2 \n" + " pop %%edi \n" // pop edi + " pop %%esi \n" // pop esi + " add %%ebx, %%esi \n" // add esi, ebx + " add %%ebx, %%edi \n" // add edi, ebx + " dec %%edx \n" + " jnz vf8lop \n" + " pop %%ds \n" // pop ds + : + : "D" ((char *)buffer+lineOfs[0]), "S" (maxX), // %0, %1 + "b" (xRes), "d" (maxY+1), "a" (screenSelector) // %2, %3, %4 + ); + break; + } // switch + return; +} // ogDisplay_VESA::ogVFlip + +void +ogDisplay_VESA::ogVLine(int32 x, int32 y1, int32 y2, uInt32 colour) { + int32 tmp; + uInt8 r, g, b, a; + + if (!ogAvail()) return; + if ((uInt32)x > maxX) return; + + if (y1 > y2) { + tmp= y1; + y1 = y2; + y2 = tmp; + } // if + + if (y1 < 0) y1 = 0; + if (y2 > (int32)maxY) y2 = maxY; + if (y2 < y1) return; + + if (ogIsBlending()) { + + ogUnpack(colour, r, g, b, a); + + if (a == 0) return; + + if (a != 255) { + for (tmp = y1; tmp <= y2; tmp++) + RawSetPixel(x, tmp, r, g, b, a); + return; + } // if + + } // if blending + + switch (bytesPerPix) { + case 4: + __asm__ __volatile__( + " push %%ds \n" // push ds + " add %%esi, %%edi \n" // add edi, esi + " shl $2, %%ebx \n" // shl ebx, 2 - pix size + " mov %7, %%si \n" // mov si, screenSelector + " mov %%si, %%ds \n" // mov ds, si + " mov %6, %%esi \n" // mov esi, y1 + " sub %%esi, %%ecx \n" // sub ecx, esi + " add %%ebx, %%edi \n" // add edi, ebx + " mov %2, %%eax \n" // mov eax, colour + " inc %%ecx \n" // inc ecx + "vLlop32: \n" + " mov %%eax, (%%edi)\n" // mov [edi], eax + " add %%edx, %%edi \n" // add edi, edx + " dec %%ecx \n" // dec ecx + " jnz vLlop32 \n" + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y1]), // %0, %1 + "m" (colour), "b" (x), // %2, %3 + "c" (y2), "d" (xRes), // %4, %5 + "m" (y1), "m" (screenSelector) // %6, %7 + ); + break; + case 3: + __asm__ __volatile__( + " push %%ds \n" // push ds + " add %%esi, %%edi \n" // add edi, esi + " mov %%ebx, %%esi \n" // mov esi, ebx - pix size + " add %%ebx, %%ebx \n" // add ebx, ebx - pix size + " add %%esi, %%ebx \n" // add ebx, esi - pix size + " mov %7, %%si \n" // mov si, screenSelector + " mov %%si, %%ds \n" // mov ds, si + " mov %6, %%esi \n" // mov esi, y1 + " sub %%esi, %%ecx \n" // sub ecx, esi + " add %%ebx, %%edi \n" // add edi, ebx + " mov %2, %%eax \n" // mov eax, colour + " inc %%ecx \n" // inc ecx + " mov %%eax, %%ebx \n" // mov ebx, eax + " shr $16, %%ebx \n" // shr ebx, 16 + "vLlop24: \n" + " mov %%ax, (%%edi) \n" // mov [edi], eax + " mov %%bl, 2(%%edi)\n" // mov [edi+2], bl + " add %%edx, %%edi \n" // add edi, edx + " dec %%ecx \n" // dec ecx + " jnz vLlop24 \n" + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y1]), // %0, %1 + "m" (colour), "b" (x), // %2, %3 + "c" (y2), "d" (xRes), // %4, %5 + "m" (y1), "m" (screenSelector) // %6, %7 + ); + break; + case 2: + __asm__ __volatile__( + " push %%ds \n" // push ds + " add %%esi, %%edi \n" // add edi, esi + " add %%ebx, %%ebx \n" // add ebx, ebx - pix size + " mov %7, %%si \n" // mov si, screenSelector + " mov %%si, %%ds \n" // mov ds, si + " mov %6, %%esi \n" // mov esi, y1 + " sub %%esi, %%ecx \n" // sub ecx, esi + " add %%ebx, %%edi \n" // add edi, ebx + " mov %2, %%eax \n" // mov eax, colour + " inc %%ecx \n" // inc ecx + "vLlop16: \n" + " mov %%ax, (%%edi) \n" // mov [edi], ax + " add %%edx, %%edi \n" // add edi, edx + " dec %%ecx \n" // dec ecx + " jnz vLlop16 \n" + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y1]), // %0, %1 + "m" (colour), "b" (x), // %2, %3 + "c" (y2), "d" (xRes), // %4, %5 + "m" (y1), "m" (screenSelector) // %6, %7 + ); + break; + case 1: + __asm__ __volatile__( + " push %%ds \n" // push ds + " add %%esi, %%edi \n" // add edi, esi + " mov %7, %%si \n" // mov si, screenSelector + " mov %%si, %%ds \n" // mov ds, si + " mov %6, %%esi \n" // mov esi, y1 + " sub %%esi, %%ecx \n" // sub ecx, esi + " add %%ebx, %%edi \n" // add edi, ebx + " mov %2, %%eax \n" // mov eax, colour + " inc %%ecx \n" // inc ecx + "vLlop8: \n" + " mov %%al, (%%edi) \n" // mov [edi], al + " add %%edx, %%edi \n" // add edi, edx + " dec %%ecx \n" // dec ecx + " jnz vLlop8 \n" + " pop %%ds \n" // pop ds + : + : "D" (buffer), "S" (lineOfs[y1]), // %0, %1 + "m" (colour), "b" (x), // %2, %3 + "c" (y2), "d" (xRes), // %4, %5 + "m" (y1), "m" (screenSelector) // %6, %7 + ); + break; + + } // switch + return; +} // ogDisplay_VESA::ogVLine + +ogDisplay_VESA::~ogDisplay_VESA(void) { + __dpmi_regs regs; + if (VESAInfo != NULL) delete VESAInfo; + if (modeInfo != NULL) delete modeInfo; + if (attributes != NULL) delete attributes; + if (inGraphics) { + regs.x.ax = 3; + __dpmi_int(0x10, ®s); + } // if inGraphics + + return; +} diff --git a/src/lib/objgfx40/ogFont.cpp b/src/lib/objgfx40/ogFont.cpp index d28e252..83bdea4 100644 --- a/src/lib/objgfx40/ogFont.cpp +++ b/src/lib/objgfx40/ogFont.cpp @@ -105,7 +105,7 @@ void ogBitFont::CenterTextX(ogSurface& dest, int32 y, const char * textString) { int32 x; - x = ((dest.GetMaxX()+1) - TextWidth(textString)) / 2; + x = ((dest.ogGetMaxX()+1) - TextWidth(textString)) / 2; PutString(dest, x, y, textString); return; } // ogBitFont::CenterTextX @@ -120,10 +120,10 @@ x = 0; break; case centerText: - x = ((dest.GetMaxX())-TextWidth(textString)) / 2; + x = ((dest.ogGetMaxX())-TextWidth(textString)) / 2; break; case rightText: - x = (dest.GetMaxX())-TextWidth(textString); + x = (dest.ogGetMaxX())-TextWidth(textString); break; default: return; @@ -134,10 +134,10 @@ y = 0; break; case centerText: - y = ((dest.GetMaxY())-TextHeight(textString)) / 2; + y = ((dest.ogGetMaxY())-TextHeight(textString)) / 2; break; case bottomText: - y = (dest.GetMaxY())-TextHeight(textString); + y = (dest.ogGetMaxY())-TextHeight(textString); default: return; } // switch @@ -166,7 +166,7 @@ width = header.width; height = header.height; numOfChars = header.numOfChars; - if (0 == numOfChars) numOfChars = 256; + if (numOfChars == 0) numOfChars = 256; startingChar = header.startingChar; #ifdef __UBIXOS_KERNEL__ @@ -251,23 +251,23 @@ uInt8 bits = 0; const unsigned char c = (const unsigned char)ch; - if (NULL == fontData) return; - if (!dest.Avail()) return; + if (fontData == NULL) return; + if (!dest.ogAvail()) return; if (charWidthTable[c] != 0) { - BGC = dest.Pack(BGColour.red, - BGColour.green, - BGColour.blue, - BGColour.alpha); + BGC = dest.ogPack(BGColour.red, + BGColour.green, + BGColour.blue, + BGColour.alpha); - BGC &= dest.GetAlphaMasker(); + BGC &= dest.ogGetAlphaMasker(); - tColour = dest.GetTransparentColor(); + tColour = dest.ogGetTransparentColor(); - FGC = dest.Pack(FGColour.red, - FGColour.green, - FGColour.blue, - FGColour.alpha); + FGC = dest.ogPack(FGColour.red, + FGColour.green, + FGColour.blue, + FGColour.alpha); offset = fontData; offset += fontDataIdx[c]; @@ -277,13 +277,13 @@ xx = 0; do { - if (0 == (xx & 7)) bits = *(offset++); + if ((xx & 7) == 0) bits = *(offset++); if ((bits & 128) != 0) - dest.SetPixel(x + xx, y+yCount , FGColour.red, FGColour.green, - FGColour.blue, FGColour.alpha); + dest.ogSetPixel(x + xx, y+yCount , FGColour.red, FGColour.green, + FGColour.blue, FGColour.alpha); else if (BGC != tColour) - dest.SetPixel(x + xx, y+yCount, BGC); + dest.ogSetPixel(x + xx, y+yCount, BGC); bits += bits; ++xx; @@ -300,13 +300,13 @@ const unsigned char *text; unsigned char ch; - if (NULL == textString) return; + if (textString == NULL) return; #ifdef __UBIXOS_KERNEL__ if (0 == kstrlen(textString)) return; #else if (0 == strlen(textString)) return; #endif - if (!dest.Avail()) return; + if (!dest.ogAvail()) return; text = (const unsigned char *)textString; diff --git a/src/lib/objgfx40/ogSprite.cpp b/src/lib/objgfx40/ogSprite.cpp index 53254aa..72c6434 100644 --- a/src/lib/objgfx40/ogSprite.cpp +++ b/src/lib/objgfx40/ogSprite.cpp @@ -36,11 +36,11 @@ bytesPerPixel = 0; dAlpha = 0; - if ((NULL == srcSprite.image) || (0 == srcSprite.imageSize)) return; + if ((srcSprite.image == NULL) || (srcSprite.imageSize == 0)) return; // allocate space for the sprite image = malloc(srcSprite.imageSize); - if (NULL == image) return; + if (image == NULL) return; // copy the image size imageSize = srcSprite.imageSize; @@ -93,7 +93,7 @@ ogSprite & ogSprite::operator=(ogSprite const & srcSprite) { - if ((NULL == srcSprite.image) || (0 == srcSprite.imageSize)) return *this; + if ((srcSprite.image == NULL) || (srcSprite.imageSize == NULL)) return *this; free(image); delete [] pal; @@ -102,7 +102,7 @@ image = malloc(srcSprite.imageSize); // this is such a bad case it should probably throw an exception - if (NULL == image) return *this; + if (image == NULL) return *this; // copy the image size imageSize = srcSprite.imageSize; @@ -138,15 +138,15 @@ void *p; uInt32 maxX, maxY; - if (!srcObject.Avail()) return; + if (!srcObject.ogAvail()) return; free(image); free(pal); - maxX = srcObject.GetMaxX(); - maxY = srcObject.GetMaxY(); + maxX = srcObject.ogGetMaxX(); + maxY = srcObject.ogGetMaxY(); - srcObject.GetPixFmt(pixfmt); + srcObject.ogGetPixFmt(pixfmt); bitDepth = pixfmt.BPP; RFP = pixfmt.redFieldPosition; @@ -158,17 +158,17 @@ bShift = 8-pixfmt.blueMaskSize; aShift = 8-pixfmt.alphaMaskSize; - pixelFmtID = srcObject.GetPixFmtID(); + pixelFmtID = srcObject.ogGetPixFmtID(); - dAlpha = srcObject.GetAlpha(); - tColour = srcObject.GetTransparentColor(); + dAlpha = srcObject.ogGetAlpha(); + tColour = srcObject.ogGetTransparentColor(); - bytesPerPixel = srcObject.GetBytesPerPix(); + bytesPerPixel = srcObject.ogGetBytesPerPix(); - if (1 == bytesPerPixel) { - if (NULL == pal) pal = new ogRGBA8[256]; - if (NULL == pal) return; - srcObject.GetPalette(pal); + if (bytesPerPixel == 1) { + if (pal == NULL) pal = new ogRGBA8[256]; + if (pal == NULL) return; + srcObject.ogGetPalette(pal); /* for (count = 0; count < 256; count++) srcObject.Unpack(count, pal[count].red, @@ -239,7 +239,7 @@ for (yy = 0; yy < yCount; yy++) { ( (uInt8 *)p ) += xOfs; - srcObject.CopyLineFrom(rx1, ry1+yy, p, xCount); + srcObject.ogCopyLineFrom(rx1, ry1+yy, p, xCount); ( (uInt8 *)p ) += xCount; } return; @@ -337,7 +337,7 @@ sizeof(dAlpha)+ // default alpha sizeof(imageSize)+ // image size in bytes imageSize; // actual image area in bytes - if (1 == bytesPerPixel) tmpsize += sizeof(uInt32)+sizeof(ogRGBA8)*256; + if (bytesPerPixel == 1) tmpsize += sizeof(uInt32)+sizeof(ogRGBA8)*256; return tmpsize; } // ogSprite::GetSize @@ -354,7 +354,7 @@ char headerIdent[4]; if (!fileExists(filename)) return false; - if (NULL == (infile = fopen(filename,"rb"))) return false; + if ((infile = fopen(filename,"rb")) == NULL) return false; fseek(infile, offset, SEEK_SET); // for now just free up the previous image. This will be changed @@ -432,7 +432,7 @@ tresult += lresult*sizeof(imageSize); image = malloc(imageSize); - if (NULL == image) { + if (image == NULL) { fclose(infile); return false; } @@ -442,10 +442,10 @@ lresult = fread(image, imageSize, 1, infile); tresult += lresult*imageSize; - if (1 == bytesPerPixel) { + if (bytesPerPixel == 1) { // 8bpp sprites have palettes - if (NULL == pal) pal = new ogRGBA8[256]; - if (NULL == pal) { + if (pal == NULL) pal = new ogRGBA8[256]; + if (pal == NULL) { fclose(infile); return false; } // if pal==NULL @@ -477,17 +477,18 @@ uInt8 r, g, b, a; ogPixelFmt pixfmt; - if (NULL == image) return; - if (!destObject.Avail()) return; + if (image == NULL) return; + if (!destObject.ogAvail()) return; - maxX = destObject.GetMaxX(); - maxY = destObject.GetMaxY(); + maxX = destObject.ogGetMaxX(); + maxY = destObject.ogGetMaxY(); xCount = width; yCount = height; // check to see if the image is totally off the screen - if ((x+xCount<0) || (y+yCount<0) || (x>(int32)maxX) || (y>(int32)maxY)) return; + if ((x+xCount < 0) || (y+yCount < 0) || + (x > (int32)maxX) || (y > (int32)maxY)) return; p = image; @@ -510,11 +511,11 @@ if ((y+yCount) > maxY) yCount = (maxY-y)+1; - destObject.GetPixFmt(pixfmt); + destObject.ogGetPixFmt(pixfmt); (uInt8 *)p += yOfs; - if ((destObject.GetPixFmtID() != pixelFmtID) || (destObject.IsBlending())) { + if ((destObject.ogGetPixFmtID() != pixelFmtID) || (destObject.ogIsBlending())) { for (yy = 0; yy < (uInt32)yCount; yy++) { (uInt8 *)p += xLeft; @@ -523,7 +524,7 @@ Unpack(GetPixel(p), r, g, b, a); (uInt8 *)p += bytesPerPixel; // this could probably be rawSetPixelRGBA instead - destObject.SetPixel(x+xx, y+yy, r, g, b, a); + destObject.ogSetPixel(x+xx, y+yy, r, g, b, a); } // for (uInt8 *)p += xRight; @@ -534,7 +535,7 @@ for (yy = 0; yy < (uInt32)yCount; yy++) { (uInt8 *)p += xLeft; - destObject.CopyLineTo(x, y+yy, p, xCount); + destObject.ogCopyLineTo(x, y+yy, p, xCount); (uInt8 *)p += xCount; (uInt8 *)p += xRight; } // for @@ -545,7 +546,7 @@ bool ogSprite::Save(const char * filename) { - return SaveTo(filename,0); + return SaveTo(filename, 0); } // ogSprite::Save bool @@ -565,19 +566,19 @@ char headerIdent[4]; uInt32 tmpSize; - if (NULL == image) return false; - if ((1 == bytesPerPixel) && (NULL == pal)) return false; + if (image == NULL) return false; + if ((bytesPerPixel == 1) && (pal == NULL)) return false; if (!fileExists(filename)) { // file doesn't exist if ((outfile = fopen(filename,"wb")) == NULL) return false; } else { // file exists. Now we check to see where we put it - if (offset==-1) { + if (offset == -1) { if ((outfile = fopen(filename, "ab")) == NULL) return false; } else { // we have an existing file and an offset to place the data if ((outfile = fopen(filename, "wb")) == NULL) return false; - if (offset!=0) fseek(outfile, offset, SEEK_SET); + if (offset != 0) fseek(outfile, offset, SEEK_SET); } // else } // else @@ -614,7 +615,7 @@ fwrite(&imageSize, sizeof(imageSize), 1, outfile); fwrite(image, imageSize, 1, outfile); - if (1 == bytesPerPixel) { + if (bytesPerPixel == 1) { tmpSize = sizeof(ogRGBA8)*256; fwrite(&tmpSize, sizeof(tmpSize), 1, outfile); fwrite(pal, sizeof(ogRGBA8), 256, outfile); @@ -644,9 +645,9 @@ red = (uInt8)(colour >> RFP) << rShift; green = (uInt8)(colour >> GFP) << gShift; blue = (uInt8)(colour >> BFP) << bShift; - if (red != 0) red += OG_MASKS[rShift]; + if (red != 0) red += OG_MASKS[rShift]; if (green != 0) green += OG_MASKS[gShift]; - if (blue != 0) blue += OG_MASKS[bShift]; + if (blue != 0) blue += OG_MASKS[bShift]; if (aShift != 8) { alpha = (uInt8)(colour >> AFP) << aShift; @@ -656,7 +657,7 @@ break; case 1: - if (NULL == pal) { + if (pal == NULL) { red = green = blue = alpha = 0; return; } // if diff --git a/src/sys/include/sde/ogDisplay_UbixOS.h b/src/sys/include/sde/ogDisplay_UbixOS.h index 74531a9..fa8022a 100755 --- a/src/sys/include/sde/ogDisplay_UbixOS.h +++ b/src/sys/include/sde/ogDisplay_UbixOS.h @@ -73,14 +73,14 @@ void SetPal(void); public: ogDisplay_UbixOS(void); - virtual bool Alias(ogSurface&, uInt32, uInt32, uInt32, uInt32); - virtual bool Clone(ogSurface&); - virtual void CopyPalette(ogSurface&); - virtual bool Create(uInt32, uInt32, ogPixelFmt); - virtual bool LoadPalette(const char *); - virtual void SetPalette(const ogRGBA8[]); - virtual void SetPalette(uInt8, uInt8, uInt8, uInt8); - virtual void SetPalette(uInt8, uInt8, uInt8, uInt8, uInt8); + virtual bool ogAlias(ogSurface&, uInt32, uInt32, uInt32, uInt32); + virtual bool ogClone(ogSurface&); + virtual void ogCopyPalette(ogSurface&); + virtual bool ogCreate(uInt32, uInt32, ogPixelFmt); + virtual bool ogLoadPalette(const char *); + virtual void ogSetPalette(const ogRGBA8[]); + virtual void ogSetPalette(uInt8, uInt8, uInt8, uInt8); + virtual void ogSetPalette(uInt8, uInt8, uInt8, uInt8, uInt8); virtual ~ogDisplay_UbixOS(void); }; // ogDisplay_UbixOS diff --git a/src/sys/lib/ogprintf.cc b/src/sys/lib/ogprintf.cc index 156f403..e930372 100644 --- a/src/sys/lib/ogprintf.cc +++ b/src/sys/lib/ogprintf.cc @@ -24,6 +24,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Log$ + Revision 1.2 2004/04/26 12:56:01 reddawg + Made src/sys/sde Copy and Make the ogPixelFormat.cpp + Revision 1.1.1.1 2004/04/15 12:07:10 reddawg UbixOS v1.0 @@ -63,17 +66,17 @@ case '\n': screenCol = 0; - bufHeight = ((screen->GetMaxY()+1) / font->GetHeight())-1; + bufHeight = ((screen->ogGetMaxY()+1) / font->GetHeight())-1; if (screenRow < bufHeight) ++screenRow; else { - screen->CopyBuf(0, 0, + screen->ogCopyBuf(0, 0, *screen, 0, font->GetHeight(), - screen->GetMaxX(), screen->GetMaxY()); - screen->FillRect(0, bufHeight * font->GetHeight()+1, - screen->GetMaxX(), screen->GetMaxY(), - screen->Pack(122, 140, 163)); + screen->ogGetMaxX(), screen->ogGetMaxY()); + screen->ogFillRect(0, bufHeight * font->GetHeight()+1, + screen->ogGetMaxX(), screen->ogGetMaxY(), + screen->ogPack(122, 140, 163)); } break; default: diff --git a/src/sys/sde/colours.cc b/src/sys/sde/colours.cc index 3f6b423..1c66341 100644 --- a/src/sys/sde/colours.cc +++ b/src/sys/sde/colours.cc @@ -24,6 +24,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Log$ + Revision 1.1.1.1 2004/04/15 12:07:16 reddawg + UbixOS v1.0 + Revision 1.23 2004/04/13 16:36:33 reddawg Changed our copyright, it is all now under a BSD-Style license @@ -58,15 +61,15 @@ while (screen == 0x0) { screen = (ogDisplay_UbixOS *)systemVitals->screen; } - while (!screen->Avail()); + while (!screen->ogAvail()); - points[0].x = screen->GetMaxX() - 150; + points[0].x = screen->ogGetMaxX() - 150; points[0].y = 0; - points[1].x = screen->GetMaxX(); + points[1].x = screen->ogGetMaxX(); points[1].y = 0; - points[2].x = screen->GetMaxX(); + points[2].x = screen->ogGetMaxX(); points[2].y = 150; - points[3].x = screen->GetMaxX() - 250; + points[3].x = screen->ogGetMaxX() - 250; points[3].y = 250; colours[0].red = 255; @@ -85,7 +88,7 @@ colours[3].green = 63; colours[3].blue = 63; colours[3].alpha = 255; - screen->SetAntiAliasing(true); + screen->ogSetAntiAliasing(true); while (true) { #if 0 @@ -104,7 +107,7 @@ b -= 8; } // for #endif - screen->FillGouraudPolygon(4, points, colours); + screen->ogFillGouraudPolygon(4, points, colours); //kprintf("colours(0)[0x%X]\n",colours[0]); colours[0].red -= 8; colours[0].green += 8; diff --git a/src/sys/sde/main.cc b/src/sys/sde/main.cc index 663316d..8c40e47 100644 --- a/src/sys/sde/main.cc +++ b/src/sys/sde/main.cc @@ -24,6 +24,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Log$ + Revision 1.1.1.1 2004/04/15 12:07:16 reddawg + UbixOS v1.0 + Revision 1.29 2004/04/13 16:36:33 reddawg Changed our copyright, it is all now under a BSD-Style license @@ -59,15 +62,15 @@ printOff = 0x1; - screen->Create(800,600,OG_PIXFMT_16BPP); - screen->Clear(screen->Pack(122,140,163)); + screen->ogCreate(800,600,OG_PIXFMT_16BPP); + screen->ogClear(screen->ogPack(122,140,163)); systemVitals->screen = screen; systemVitals->font = font; ogprintOff = (int)0x0; - screen->SetAntiAliasing(false); + screen->ogSetAntiAliasing(false); while (1) { for (tmp = windows;tmp;tmp=tmp->next) { @@ -89,9 +92,9 @@ break; case drawWindow: buf = (ogSurface *)tmp->buf; - screen->CopyBuf(screen->GetMaxX() - buf->GetMaxX(), - screen->GetMaxY() - buf->GetMaxY(), *buf,0, 0, - buf->GetMaxX(), buf->GetMaxY()); + screen->ogCopyBuf(screen->ogGetMaxX() - buf->ogGetMaxX(), + screen->ogGetMaxY() - buf->ogGetMaxY(), *buf,0, 0, + buf->ogGetMaxX(), buf->ogGetMaxY()); tmp->status = windowReady; //kprintf("Draw Window Routines Here\n"); break; diff --git a/src/sys/sde/ogDisplay_UbixOS.cc b/src/sys/sde/ogDisplay_UbixOS.cc index a325977..453e382 100755 --- a/src/sys/sde/ogDisplay_UbixOS.cc +++ b/src/sys/sde/ogDisplay_UbixOS.cc @@ -24,6 +24,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Log$ + Revision 1.1.1.1 2004/04/15 12:07:17 reddawg + UbixOS v1.0 + Revision 1.20 2004/04/13 16:36:33 reddawg Changed our copyright, it is all now under a BSD-Style license @@ -96,10 +99,10 @@ ogDisplay_UbixOS::FindMode(uInt32 _xRes, uInt32 _yRes, uInt32 _BPP) { uInt16 mode; - if ((320 == _xRes) && (200 == _yRes) && (8 == _BPP)) return 0x13; + if ((_xRes == 320) && (_yRes == 200) && (_BPP == 8)) return 0x13; // if ((VESAInfo==NULL) || (VESAInfo->videoModePtr==NULL)) return 0; - if (NULL == modeInfo) return 0; + if (modeInfo == NULL) return 0; for (mode = 0x100; mode < 0x1FF; mode++) { GetModeInfo(mode); @@ -115,7 +118,7 @@ uInt32 size = 0x0, count = 0x0, i = 0x0; - if (mode==0x13) { + if (mode == 0x13) { xRes = 320; yRes = 200; @@ -159,7 +162,7 @@ blueFieldPosition = modeInfo->blueFieldPosition; alphaFieldPosition = modeInfo->alphaFieldPosition; - if (4 == bytesPerPix) { + if (bytesPerPix == 4) { modeInfo->alphaMaskSize = 8; while ((alphaFieldPosition == redFieldPosition) || (alphaFieldPosition == greenFieldPosition) || @@ -190,10 +193,10 @@ initVESAMode(mode); - if ((lineOfs!=NULL) && (lSize!=0)) delete [] lineOfs; + if ((lineOfs != NULL) && (lSize != 0)) delete [] lineOfs; lSize = yRes*sizeof(uInt32); lineOfs = new uInt32[yRes];; - if (NULL == lineOfs) return; + if (lineOfs == NULL) return; lineOfs[0] = 0; for (count = 1; count < yRes; count++) @@ -208,19 +211,19 @@ (alphaFieldPosition << 24); } // else - SetAntiAliasing(BPP > 8); - if (NULL == pal) pal = new ogRGBA8[256]; - SetPalette(DEFAULT_PALETTE); + ogSetAntiAliasing(BPP > 8); + if (pal == NULL) pal = new ogRGBA8[256]; + ogSetPalette(DEFAULT_PALETTE); return; } // ogDisplay_UbixOS::SetMode void -ogDisplay_UbixOS::SetPalette(const ogRGBA8 newPal[256]) { - ogSurface::SetPalette(newPal); +ogDisplay_UbixOS::ogSetPalette(const ogRGBA8 newPal[256]) { + ogSurface::ogSetPalette(newPal); SetPal(); return; -} // ogDisplay_UbixOS::SetPalette +} // ogDisplay_UbixOS::ogSetPalette void ogDisplay_UbixOS::SetPal(void) { if (bytesPerPix != 1) return; @@ -234,14 +237,14 @@ } // ogDisplay_UbixOS::SetPal bool -ogDisplay_UbixOS::Alias(ogSurface& SrcObject, uInt32 x1, +ogDisplay_UbixOS::ogAlias(ogSurface& SrcObject, uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) { - SetLastError(ogNoAliasing); + ogSetLastError(ogNoAliasing); return false; -} // ogDisplay_UbixOS::Alias +} // ogDisplay_UbixOS::ogAlias bool -ogDisplay_UbixOS::Create(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixFormat) { +ogDisplay_UbixOS::ogCreate(uInt32 _xRes, uInt32 _yRes,ogPixelFmt _pixFormat) { uInt16 mode; mode = 0x114; // was 0x111 SetMode(mode); @@ -254,52 +257,52 @@ if (mode!=0) SetMode(mode); */ return (mode!=0); -} // ogDisplay_UbixOS::Create +} // ogDisplay_UbixOS::ogCreate bool -ogDisplay_UbixOS::Clone(ogSurface& SrcObject) { - SetLastError(ogNoCloning); +ogDisplay_UbixOS::ogClone(ogSurface& SrcObject) { + ogSetLastError(ogNoCloning); return false; -} // ogDisplay_UbixOS::Clone +} // ogDisplay_UbixOS::ogClone void -ogDisplay_UbixOS::CopyPalette(ogSurface& SrcObject) { - ogSurface::CopyPalette(SrcObject); +ogDisplay_UbixOS::ogCopyPalette(ogSurface& SrcObject) { + ogSurface::ogCopyPalette(SrcObject); SetPal(); return; -} // ogDisplay_UbixOS::CopyPalette +} // ogDisplay_UbixOS::ogCopyPalette bool -ogDisplay_UbixOS::LoadPalette(const char *palfile) { +ogDisplay_UbixOS::ogLoadPalette(const char *palfile) { bool result; - if ((result = ogSurface::LoadPalette(palfile))==true) SetPal(); + if ((result = ogSurface::ogLoadPalette(palfile))==true) SetPal(); return result; -} // ogDisplay_UbixOS::LoadPalette +} // ogDisplay_UbixOS::ogLoadPalette void -ogDisplay_UbixOS::SetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { - if (NULL == pal) return; - ogSurface::SetPalette(colour, red, green, blue); +ogDisplay_UbixOS::ogSetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue) { + if (pal == NULL) return; + ogSurface::ogSetPalette(colour, red, green, blue); outportByte(0x3c8, colour); outportByte(0x3c9, red >> 2); outportByte(0x3c9, green >> 2); outportByte(0x3c9, blue >> 2); return; -} // ogDisplay_UbixOS::SetPalette +} // ogDisplay_UbixOS::ogSetPalette void -ogDisplay_UbixOS::SetPalette(uInt8 colour, uInt8 red, uInt8 green, +ogDisplay_UbixOS::ogSetPalette(uInt8 colour, uInt8 red, uInt8 green, uInt8 blue, uInt8 alpha) { - if (NULL == pal) return; - ogSurface::SetPalette(colour, red, green, blue, alpha); + if (pal == NULL) return; + ogSurface::ogSetPalette(colour, red, green, blue, alpha); outportByte(0x3c8, colour); outportByte(0x3c9, red >> 2); outportByte(0x3c9, green >> 2); outportByte(0x3c9, blue >> 2); return; -} // ogDisplay_UbixOS::SetPalette +} // ogDisplay_UbixOS::ogSetPalette ogDisplay_UbixOS::~ogDisplay_UbixOS(void) { delete attributes;