diff --git a/src/sys/graphics/Makefile b/src/sys/graphics/Makefile index 1150069..5b15b0f 100755 --- a/src/sys/graphics/Makefile +++ b/src/sys/graphics/Makefile @@ -24,7 +24,7 @@ # Compile the source files .cpp.o: - $(G++) -Wall -I./ -g -c -o $@ $< + $(G++) -Wall -I./ -I../include -g -c -o $@ $< .cc.s: $(G++) -Wall -fomit-frame-pointer -O -I../../lib/libc/include -S -o $@ $< diff --git a/src/sys/graphics/objfont.cpp b/src/sys/graphics/objfont.cpp index 148b717..ec36bff 100755 --- a/src/sys/graphics/objfont.cpp +++ b/src/sys/graphics/objfont.cpp @@ -2,14 +2,16 @@ #include "objgfx30.h" #include #include +#include +#include TFont::TFont(TGfx0* buffer) { Buf = buffer; - FontDataSize = 0; memset(FontDataIdx,0,sizeof(FontDataIdx)); memset(CharWidthTable,0,sizeof(CharWidthTable)); memset(CharHeightTable,0,sizeof(CharHeightTable)); FontData = 0; + FontDataSize = 0; return; } // TFont::TFont @@ -102,13 +104,14 @@ UInt8 pix; char ch; if (!FontData) return; + if (!TextString) return; while (*TextString) { - ch = *TextString; + ch = *TextString++; if ((CharWidthTable[ch]) && (ch!=' ')) { offset=(UInt8 *)((UInt32)FontData+(UInt32)FontDataIdx[ch]); for (yy=0; yy<=(UInt32)(CharHeightTable[ch]-1); yy++) for (xx=0; xx<=(UInt32)(CharWidthTable[ch]-1); xx++) { - pix = *offset; + pix = *offset++; if (pix) Buf->putpixel(x+xx,y+yy,ColourTable[pix]); } // for xx x+=CharWidthTable[ch]; @@ -116,3 +119,42 @@ } // while return; } // TBMFont::PutText + +/* TDPFont methods */ + +void TDPFont::PutText(UInt32 x, UInt32 y, const char * TextString) { + UInt32 xx, xcount, ycount; + UInt8 * offset; + UInt8 bits; + char ch; + if (!FontData) return; + if (TextString) return; + while (*TextString) { + ch = *TextString++; + if ((CharWidthTable[ch]) && (ch!=' ')) + offset=(UInt8 *)((UInt32)FontData+(UInt32)FontDataIdx[ch]); + for (ycount = 0; ycount<=(UInt32)(Height-1); ycount++) { + xcount = CharWidthTable[ch]; + xx = 0; + do { + if (xx & 7==0) bits = *offset++; + if (bits & 128) + Buf->putpixel(x+ xx++,y+ycount,ColourTable[1]); + bits+=bits; + } while (xcount--); + } // for + x+=CharWidthTable[ch]; + } // while +} // TDPFont::PutText + +bool TDPFont::LoadFrom(const char * FontFile, UInt32 Offset) { + int infile; +// TDPFHeader header; +// UInt32 lresult; + if (FontData) free(FontData); + infile = fopen(FontFile,1); +// fseek(infile,Offset,SEEK_SET); + fclose(infile); + + return TRUE; +} // TDPFont::LoadFrom diff --git a/src/sys/graphics/objfont.h b/src/sys/graphics/objfont.h index fb24637..3eb4ccc 100755 --- a/src/sys/graphics/objfont.h +++ b/src/sys/graphics/objfont.h @@ -55,11 +55,26 @@ public: TBMFont(TGfx0 *Buffer): TFont(Buffer) { for (UInt32 tmp=0; tmp<=255; tmp++) ColourTable[tmp]=tmp; - } + } void SetColor(UInt32); void SetIdxColor(UInt8, UInt32); void PutText(UInt32, UInt32, const char *); }; +class TDPFont : public TBMFont { + UInt8 Width, Height; + UInt16 NumOfChars; + UInt8 StartingChar; + TDPFont(TGfx0 * Buffer) : TBMFont(Buffer) { + Width = 0; + Height = 0; + NumOfChars = 0; + StartingChar = 0; + } + void PutText(UInt32, UInt32, const char *); + bool LoadFrom(const char *, UInt32); +}; + + #endif diff --git a/src/sys/graphics/objgfx30.cpp b/src/sys/graphics/objgfx30.cpp index 4774adf..1ac049f 100755 --- a/src/sys/graphics/objgfx30.cpp +++ b/src/sys/graphics/objgfx30.cpp @@ -5,7 +5,7 @@ #include "objgfx30.h" #include #include - +#include // TGfx0 constructor TGfx0::TGfx0(void) { @@ -362,7 +362,7 @@ } // TGfx0::RGB void TGfx0::setRGBPalette(UInt8 colour, UInt8 red, UInt8 green, UInt8 blue) { - colour = colour & 255; + if (!pal) return; pal[colour].red = red; pal[colour].green = green; pal[colour].blue = blue; @@ -372,6 +372,12 @@ void TGfx0::unpackRGB(UInt32 colour, UInt8* red, UInt8* green, UInt8* blue) { switch (BPP) { case 8: + if (!pal) { + *red = 0; + *green = 0; + *blue = 0; + return; + } if (colour>255) colour=colour & 255; *red = pal[colour].red; *green = pal[colour].green; diff --git a/src/sys/graphics/objgfx30.h b/src/sys/graphics/objgfx30.h index 4f1b7f7..4a3e83c 100755 --- a/src/sys/graphics/objgfx30.h +++ b/src/sys/graphics/objgfx30.h @@ -5,13 +5,6 @@ #ifndef OBJGFX30_H #define OBJGFX30_H -#ifndef TRUE - #define TRUE 1 -#endif -#ifndef FALSE - #define FALSE 0 -#endif - #define gm320x200x256 0x13 #define gm640x480x256 0x101 #define gm800x600x256 0x103