reformat
This commit is contained in:
@ -15,12 +15,10 @@
|
||||
#include "devices/LFBgraphics.h"
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
|
||||
/* Hilfsfunktionen */
|
||||
void swap(unsigned int *a, unsigned int *b);
|
||||
void swap(unsigned int* a, unsigned int* b);
|
||||
int abs(int a);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: LFBgraphics::drawMonoBitmap *
|
||||
*---------------------------------------------------------------------------*
|
||||
@ -38,21 +36,21 @@ int abs(int a);
|
||||
* mit cpi2fnt (AmigaOS) erzeugt wurden. Das Format erklaert*
|
||||
* sich in den C-Dateien in fonts/ von selbst. *
|
||||
*****************************************************************************/
|
||||
inline void LFBgraphics::drawMonoBitmap( unsigned int x, unsigned int y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
unsigned char* bitmap,
|
||||
unsigned int color) {
|
||||
inline void LFBgraphics::drawMonoBitmap(unsigned int x, unsigned int y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
unsigned char* bitmap,
|
||||
unsigned int color) {
|
||||
// Breite in Bytes
|
||||
unsigned short width_byte = width/8 + ((width%8 != 0) ? 1 : 0);
|
||||
|
||||
for(unsigned int yoff=0; yoff<height; ++yoff) {
|
||||
int xpos=x;
|
||||
int ypos=y+yoff;
|
||||
for(unsigned int xb=0; xb < width_byte; ++xb) {
|
||||
for( int src=7; src>=0; --src) {
|
||||
if ((1 << src) & *bitmap) {
|
||||
drawPixel(xpos, ypos, color);
|
||||
unsigned short width_byte = width / 8 + ((width % 8 != 0) ? 1 : 0);
|
||||
|
||||
for (unsigned int yoff = 0; yoff < height; ++yoff) {
|
||||
int xpos = x;
|
||||
int ypos = y + yoff;
|
||||
for (unsigned int xb = 0; xb < width_byte; ++xb) {
|
||||
for (int src = 7; src >= 0; --src) {
|
||||
if ((1 << src) & *bitmap) {
|
||||
drawPixel(xpos, ypos, color);
|
||||
}
|
||||
xpos++;
|
||||
}
|
||||
@ -61,7 +59,6 @@ inline void LFBgraphics::drawMonoBitmap( unsigned int x, unsigned int y,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: LFBgraphics::drawString *
|
||||
*---------------------------------------------------------------------------*
|
||||
@ -74,18 +71,15 @@ inline void LFBgraphics::drawMonoBitmap( unsigned int x, unsigned int y,
|
||||
* Beschreibung: Gibt eine Zeichenkette mit gewaehlter Schrift an der *
|
||||
* Position x,y aus. *
|
||||
*****************************************************************************/
|
||||
void LFBgraphics::drawString(Font &fnt, unsigned int x, unsigned int y,
|
||||
void LFBgraphics::drawString(Font& fnt, unsigned int x, unsigned int y,
|
||||
unsigned int col, char* str, unsigned int len) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < len; ++i) {
|
||||
drawMonoBitmap(x, y, fnt.get_char_width(), fnt.get_char_height(),
|
||||
fnt.getChar( *(str+i) ), col);
|
||||
for (unsigned int i = 0; i < len; ++i) {
|
||||
drawMonoBitmap(x, y, fnt.get_char_width(), fnt.get_char_height(),
|
||||
fnt.getChar(*(str + i)), col);
|
||||
x += fnt.get_char_width();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: LFBgraphics::drawPixel *
|
||||
*---------------------------------------------------------------------------*
|
||||
@ -94,136 +88,150 @@ void LFBgraphics::drawString(Font &fnt, unsigned int x, unsigned int y,
|
||||
* *
|
||||
* Beschreibung: Zeichnen eines Pixels. *
|
||||
*****************************************************************************/
|
||||
void LFBgraphics::drawPixel(unsigned int x, unsigned int y,unsigned int col) {
|
||||
unsigned char *ptr = (unsigned char *) lfb;
|
||||
|
||||
if (hfb == 0 || lfb == 0) return ;
|
||||
void LFBgraphics::drawPixel(unsigned int x, unsigned int y, unsigned int col) {
|
||||
unsigned char* ptr = (unsigned char*)lfb;
|
||||
|
||||
if (mode == 0) ptr = (unsigned char *) hfb;
|
||||
|
||||
// Pixel ausserhalb des sichtbaren Bereichs?
|
||||
if (x<0 || x>=xres || y<0 || y>yres)
|
||||
if (hfb == 0 || lfb == 0) {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (mode == 0) ptr = (unsigned char*)hfb;
|
||||
|
||||
// Pixel ausserhalb des sichtbaren Bereichs?
|
||||
if (x < 0 || x >= xres || y < 0 || y > yres) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Adresse des Pixels berechnen und Inhalt schreiben
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
ptr += (x+y*xres);
|
||||
*ptr = col;
|
||||
return;
|
||||
case 15:
|
||||
case 16:
|
||||
ptr += (2*x+2*y*xres);
|
||||
*ptr = col;
|
||||
return;
|
||||
case 24:
|
||||
ptr += (3*x+3*y*xres);
|
||||
*ptr = (col & 0xFF); ptr++;
|
||||
*ptr = ((col>>8) & 0xFF); ptr++;
|
||||
*ptr = ((col>>16) & 0xFF); ptr++;
|
||||
return;
|
||||
case 32:
|
||||
ptr += (4*x+4*y*xres);
|
||||
*ptr = (col & 0xFF); ptr++;
|
||||
*ptr = ((col>>8) & 0xFF); ptr++;
|
||||
*ptr = ((col>>16) & 0xFF); ptr++;
|
||||
return;
|
||||
case 8:
|
||||
ptr += (x + y * xres);
|
||||
*ptr = col;
|
||||
return;
|
||||
case 15:
|
||||
case 16:
|
||||
ptr += (2 * x + 2 * y * xres);
|
||||
*ptr = col;
|
||||
return;
|
||||
case 24:
|
||||
ptr += (3 * x + 3 * y * xres);
|
||||
*ptr = (col & 0xFF);
|
||||
ptr++;
|
||||
*ptr = ((col >> 8) & 0xFF);
|
||||
ptr++;
|
||||
*ptr = ((col >> 16) & 0xFF);
|
||||
ptr++;
|
||||
return;
|
||||
case 32:
|
||||
ptr += (4 * x + 4 * y * xres);
|
||||
*ptr = (col & 0xFF);
|
||||
ptr++;
|
||||
*ptr = ((col >> 8) & 0xFF);
|
||||
ptr++;
|
||||
*ptr = ((col >> 16) & 0xFF);
|
||||
ptr++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: LFBgraphics::clear *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Bildschirm loeschen. *
|
||||
*****************************************************************************/
|
||||
void LFBgraphics::clear() {
|
||||
unsigned int *ptr = (unsigned int *)lfb;
|
||||
unsigned int* ptr = (unsigned int*)lfb;
|
||||
unsigned int i;
|
||||
|
||||
|
||||
if (hfb == 0 || lfb == 0) return ;
|
||||
if (hfb == 0 || lfb == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
ptr = (unsigned int*)hfb;
|
||||
}
|
||||
|
||||
if (mode == 0) ptr = (unsigned int *) hfb;
|
||||
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
for (i=0; i < ((xres/4)*yres); i++)
|
||||
*(ptr++) = 0;
|
||||
return;
|
||||
case 15:
|
||||
case 16:
|
||||
for (i=0; i < (2*(xres/4)*yres); i++)
|
||||
*(ptr++) = 0;
|
||||
return;
|
||||
case 24:
|
||||
for (i=0; i < (3*(xres/4)*yres); i++)
|
||||
*(ptr++) = 0;
|
||||
return;
|
||||
case 32:
|
||||
for (i=0; i < (4*(xres/4)*yres); i++)
|
||||
*(ptr++) = 0;
|
||||
return;
|
||||
case 8:
|
||||
for (i = 0; i < ((xres / 4) * yres); i++) {
|
||||
*(ptr++) = 0;
|
||||
}
|
||||
return;
|
||||
case 15:
|
||||
case 16:
|
||||
for (i = 0; i < (2 * (xres / 4) * yres); i++) {
|
||||
*(ptr++) = 0;
|
||||
}
|
||||
return;
|
||||
case 24:
|
||||
for (i = 0; i < (3 * (xres / 4) * yres); i++) {
|
||||
*(ptr++) = 0;
|
||||
}
|
||||
return;
|
||||
case 32:
|
||||
for (i = 0; i < (4 * (xres / 4) * yres); i++) {
|
||||
*(ptr++) = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: LFBgraphics::setDrawingBuff *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Stellt ein, ob in den sichtbaren Puffer gezeichnet wird. *
|
||||
*****************************************************************************/
|
||||
void LFBgraphics::setDrawingBuff(int v)
|
||||
{
|
||||
mode = v;
|
||||
void LFBgraphics::setDrawingBuff(int v) {
|
||||
mode = v;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: LFBgraphics::copyHiddenToVisible *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Kopiert den versteckten Puffer in den sichtbaren LFB. *
|
||||
*****************************************************************************/
|
||||
void LFBgraphics::copyHiddenToVisible() {
|
||||
unsigned int *sptr = (unsigned int *)hfb;
|
||||
unsigned int *dptr = (unsigned int *)lfb;
|
||||
unsigned int* sptr = (unsigned int*)hfb;
|
||||
unsigned int* dptr = (unsigned int*)lfb;
|
||||
unsigned int i;
|
||||
|
||||
if (hfb == 0 || lfb == 0) return ;
|
||||
|
||||
if (hfb == 0 || lfb == 0) return;
|
||||
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
for (i=0; i < ((xres/4)*yres); i++)
|
||||
*(dptr++) = *(sptr++);
|
||||
return;
|
||||
case 15:
|
||||
case 16:
|
||||
for (i=0; i < (2*(xres/4)*yres); i++)
|
||||
*(dptr++) = *(sptr++);
|
||||
return;
|
||||
case 24:
|
||||
for (i=0; i < (3*(xres/4)*yres); i++)
|
||||
*(dptr++) = *(sptr++);
|
||||
return;
|
||||
case 32:
|
||||
for (i=0; i < (4*(xres/4)*yres); i++)
|
||||
*(dptr++) = *(sptr++);
|
||||
return;
|
||||
case 8:
|
||||
for (i = 0; i < ((xres / 4) * yres); i++) {
|
||||
*(dptr++) = *(sptr++);
|
||||
}
|
||||
return;
|
||||
case 15:
|
||||
case 16:
|
||||
for (i = 0; i < (2 * (xres / 4) * yres); i++) {
|
||||
*(dptr++) = *(sptr++);
|
||||
}
|
||||
return;
|
||||
case 24:
|
||||
for (i = 0; i < (3 * (xres / 4) * yres); i++) {
|
||||
*(dptr++) = *(sptr++);
|
||||
}
|
||||
return;
|
||||
case 32:
|
||||
for (i = 0; i < (4 * (xres / 4) * yres); i++) {
|
||||
*(dptr++) = *(sptr++);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void swap(unsigned int* a, unsigned int* b) {
|
||||
int h = *a;
|
||||
|
||||
|
||||
void swap(unsigned int *a, unsigned int *b) {
|
||||
int h;
|
||||
|
||||
h = *a;
|
||||
|
||||
*a = *b;
|
||||
*b = h;
|
||||
*a = *b;
|
||||
*b = h;
|
||||
}
|
||||
|
||||
int abs(int a) {
|
||||
if (a<0) return -a;
|
||||
return a;
|
||||
if (a < 0) {
|
||||
return -a;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@ -17,44 +17,42 @@
|
||||
|
||||
#include "devices/fonts/Fonts.h"
|
||||
|
||||
|
||||
// Hilfsfunktionen um Farbwerte fuer einen Pixel zu erzeugen
|
||||
#define RGB_24(r,g,b) (unsigned int) ((r << 16) + (g << 8) + b )
|
||||
#define RGB_24(r, g, b) (unsigned int)((r << 16) + (g << 8) + b)
|
||||
|
||||
#define BUFFER_INVISIBLE 0
|
||||
#define BUFFER_VISIBLE 1
|
||||
#define BUFFER_VISIBLE 1
|
||||
|
||||
class LFBgraphics {
|
||||
|
||||
|
||||
private:
|
||||
LFBgraphics (const LFBgraphics ©); // Verhindere Kopieren
|
||||
LFBgraphics(const LFBgraphics& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
// Hilfsfunktion fuer drawString
|
||||
void drawMonoBitmap ( unsigned int x, unsigned int y,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned char* bitmap, unsigned int col);
|
||||
void drawMonoBitmap(unsigned int x, unsigned int y,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned char* bitmap, unsigned int col);
|
||||
|
||||
public:
|
||||
unsigned int xres, yres; // Aufloesung in Pixel
|
||||
unsigned int bpp; // Farbtiefe (Bits per Pixel)
|
||||
unsigned int lfb; // Adresse des Linearen Framebuffers
|
||||
unsigned int hfb; // Adresse des versteckten Buffers (optional, fuer Animationen)
|
||||
unsigned int mode; // Zeichnen im sichtbaren = 1 oder unsichtbaren = 0 Puffer
|
||||
|
||||
LFBgraphics () { mode = BUFFER_VISIBLE; };
|
||||
|
||||
void clear ();
|
||||
void drawPixel ( unsigned int x, unsigned int y, unsigned int col);
|
||||
|
||||
void drawString (Font &fnt, unsigned int x, unsigned int y,
|
||||
unsigned int col, char* str, unsigned int len);
|
||||
|
||||
unsigned int xres, yres; // Aufloesung in Pixel
|
||||
unsigned int bpp; // Farbtiefe (Bits per Pixel)
|
||||
unsigned int lfb; // Adresse des Linearen Framebuffers
|
||||
unsigned int hfb; // Adresse des versteckten Buffers (optional, fuer Animationen)
|
||||
unsigned int mode; // Zeichnen im sichtbaren = 1 oder unsichtbaren = 0 Puffer
|
||||
|
||||
LFBgraphics() : mode(BUFFER_VISIBLE) {};
|
||||
|
||||
void clear();
|
||||
void drawPixel(unsigned int x, unsigned int y, unsigned int col);
|
||||
|
||||
void drawString(Font& fnt, unsigned int x, unsigned int y,
|
||||
unsigned int col, char* str, unsigned int len);
|
||||
|
||||
// stellt ein, ob in den sichtbaren Puffer gezeichnet wird
|
||||
void setDrawingBuff( int v);
|
||||
|
||||
void setDrawingBuff(int v);
|
||||
|
||||
// kopiert 'hfb' nach 'lfb'
|
||||
void copyHiddenToVisible();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user