cleanup some vbe stuff
This commit is contained in:
@ -38,7 +38,7 @@ int abs(int a);
|
||||
*****************************************************************************/
|
||||
inline void LFBgraphics::drawMonoBitmap(unsigned int x, unsigned int y,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned char* bitmap, unsigned int color) {
|
||||
const unsigned char* bitmap, unsigned int color) const {
|
||||
// Breite in Bytes
|
||||
unsigned short width_byte = width / 8 + ((width % 8 != 0) ? 1 : 0);
|
||||
|
||||
@ -69,11 +69,10 @@ 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,
|
||||
unsigned int col, char* str, unsigned int len) {
|
||||
void LFBgraphics::drawString(const Font& fnt, unsigned int x, unsigned int y,
|
||||
unsigned int col, const char* str, unsigned int len) const {
|
||||
for (unsigned int i = 0; i < len; ++i) {
|
||||
drawMonoBitmap(x, y, fnt.get_char_width(), fnt.get_char_height(),
|
||||
fnt.getChar(*(str + i)), col);
|
||||
drawMonoBitmap(x, y, fnt.get_char_width(), fnt.get_char_height(), fnt.getChar(*(str + i)), col);
|
||||
x += fnt.get_char_width();
|
||||
}
|
||||
}
|
||||
@ -86,7 +85,7 @@ 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) {
|
||||
void LFBgraphics::drawPixel(unsigned int x, unsigned int y, unsigned int col) const {
|
||||
unsigned char* ptr = (unsigned char*)lfb;
|
||||
|
||||
if (hfb == 0 || lfb == 0) {
|
||||
@ -134,7 +133,7 @@ void LFBgraphics::drawPixel(unsigned int x, unsigned int y, unsigned int col) {
|
||||
}
|
||||
}
|
||||
|
||||
void LFBgraphics::drawStraightLine(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int col) {
|
||||
void LFBgraphics::drawStraightLine(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int col) const {
|
||||
// Don't set mode inside the drawing function to use them in animations
|
||||
|
||||
if (x1 == x2 && y2 > y1) {
|
||||
@ -155,18 +154,18 @@ void LFBgraphics::drawStraightLine(unsigned int x1, unsigned int y1, unsigned in
|
||||
// (x1, y1)---(x2, y1)
|
||||
// | |
|
||||
// (x1, y2)---(x2, y2)
|
||||
void LFBgraphics::drawRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int col) {
|
||||
void LFBgraphics::drawRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int col) const {
|
||||
this->drawStraightLine(x1, y1, x2, y1, col);
|
||||
this->drawStraightLine(x2, y1, x2, y2, col);
|
||||
this->drawStraightLine(x1, y2, x2, y2, col);
|
||||
this->drawStraightLine(x1, y1, x1, y2, col);
|
||||
}
|
||||
|
||||
void LFBgraphics::drawCircle(unsigned int x, unsigned int y, unsigned int rad, unsigned int col) {
|
||||
void LFBgraphics::drawCircle(unsigned int x, unsigned int y, unsigned int rad, unsigned int col) const {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void LFBgraphics::drawSprite(unsigned int width, unsigned int height, unsigned int bytes_pp, unsigned char* pixel_data) {
|
||||
void LFBgraphics::drawSprite(unsigned int width, unsigned int height, unsigned int bytes_pp, unsigned char* pixel_data) const {
|
||||
unsigned char* ptr;
|
||||
for (unsigned int x = 0; x < width; ++x) {
|
||||
for (unsigned int y = 0; y < height; ++y) {
|
||||
@ -193,7 +192,7 @@ void LFBgraphics::drawSprite(unsigned int width, unsigned int height, unsigned i
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Bildschirm loeschen. *
|
||||
*****************************************************************************/
|
||||
void LFBgraphics::clear() {
|
||||
void LFBgraphics::clear() const {
|
||||
unsigned int* ptr = (unsigned int*)lfb;
|
||||
unsigned int i;
|
||||
|
||||
@ -244,7 +243,7 @@ void LFBgraphics::setDrawingBuff(int v) {
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Kopiert den versteckten Puffer in den sichtbaren LFB. *
|
||||
*****************************************************************************/
|
||||
void LFBgraphics::copyHiddenToVisible() {
|
||||
void LFBgraphics::copyHiddenToVisible() const {
|
||||
unsigned int* sptr = (unsigned int*)hfb;
|
||||
unsigned int* dptr = (unsigned int*)lfb;
|
||||
unsigned int i;
|
||||
|
@ -25,40 +25,38 @@
|
||||
|
||||
class LFBgraphics {
|
||||
private:
|
||||
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);
|
||||
const unsigned char* bitmap, unsigned int col) const;
|
||||
|
||||
public:
|
||||
LFBgraphics(const LFBgraphics& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
LFBgraphics() : mode(BUFFER_VISIBLE) {};
|
||||
|
||||
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() const;
|
||||
void drawPixel(unsigned int x, unsigned int y, unsigned int col) const;
|
||||
|
||||
void clear();
|
||||
void drawPixel(unsigned int x, unsigned int y, unsigned int col);
|
||||
void drawString(const Font& fnt, unsigned int x, unsigned int y, unsigned int col, const char* str, unsigned int len) const;
|
||||
|
||||
void drawString(Font& fnt, unsigned int x, unsigned int y,
|
||||
unsigned int col, char* str, unsigned int len);
|
||||
void drawCircle(unsigned int x, unsigned int y, unsigned int rad, unsigned int col) const;
|
||||
void drawStraightLine(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int col) const;
|
||||
void drawRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int col) const;
|
||||
|
||||
// TODO: Filled shapes
|
||||
void drawCircle(unsigned int x, unsigned int y, unsigned int rad, unsigned int col);
|
||||
void drawStraightLine(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int col);
|
||||
void drawRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int col);
|
||||
|
||||
void drawSprite(unsigned int width, unsigned int height, unsigned int bytes_pp, unsigned char* pixel_data);
|
||||
void drawSprite(unsigned int width, unsigned int height, unsigned int bytes_pp, unsigned char* pixel_data) const;
|
||||
|
||||
// stellt ein, ob in den sichtbaren Puffer gezeichnet wird
|
||||
void setDrawingBuff(int v);
|
||||
|
||||
// kopiert 'hfb' nach 'lfb'
|
||||
void copyHiddenToVisible();
|
||||
void copyHiddenToVisible() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
|
||||
/* Acorn-like font definition, with PC graphics characters */
|
||||
|
||||
unsigned char acorndata_8x8[] = {
|
||||
constexpr const unsigned char acorndata_8x8[] = {
|
||||
/* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
|
||||
/* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */
|
||||
/* 02 */ 0x7e, 0xff, 0xbd, 0xff, 0xc3, 0xe7, 0xff, 0x7e, /* ^B */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
|
||||
#define FONTDATAMAX_SUN_12x22 11264
|
||||
|
||||
unsigned char fontdata_sun_12x22[FONTDATAMAX_SUN_12x22] = {
|
||||
constexpr const unsigned char fontdata_sun_12x22[FONTDATAMAX_SUN_12x22] = {
|
||||
|
||||
/* 0 0x00 '^@' */
|
||||
0x00, 0x00, /* 000000000000 */
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#define FONTDATAMAX_SUN8x16 4096
|
||||
|
||||
unsigned char fontdata_sun_8x16[FONTDATAMAX_SUN8x16] = {
|
||||
constexpr const unsigned char fontdata_sun_8x16[FONTDATAMAX_SUN8x16] = {
|
||||
/* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
/* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,
|
||||
/* */ 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00,
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "devices/fonts/Font_sun_12x22.h"
|
||||
#include "devices/fonts/Font_sun_8x16.h"
|
||||
|
||||
Font_8x16 std_font_8x16;
|
||||
Font_8x8 std_font_8x8;
|
||||
Font_acorn_8x8 acorn_font_8x8;
|
||||
Font_pearl_8x8 pearl_font_8x8;
|
||||
Font_sun_12x22 sun_font_12x22;
|
||||
Font_sun_8x16 sun_font_8x16;
|
||||
const Font_8x16 std_font_8x16;
|
||||
const Font_8x8 std_font_8x8;
|
||||
const Font_acorn_8x8 acorn_font_8x8;
|
||||
const Font_pearl_8x8 pearl_font_8x8;
|
||||
const Font_sun_12x22 sun_font_12x22;
|
||||
const Font_sun_8x16 sun_font_8x16;
|
||||
|
@ -13,37 +13,38 @@
|
||||
|
||||
class Font {
|
||||
public:
|
||||
virtual unsigned char* getChar(int c) const = 0;
|
||||
virtual const unsigned char* getChar(int c) const = 0;
|
||||
virtual unsigned int get_char_width() const = 0;
|
||||
virtual unsigned int get_char_height() const = 0;
|
||||
};
|
||||
|
||||
template<unsigned int width, unsigned int height, unsigned char* data>
|
||||
template<unsigned int width, unsigned int height, const unsigned char* data>
|
||||
class FontInstance : public Font {
|
||||
const unsigned int char_width;
|
||||
const unsigned int char_height;
|
||||
const unsigned int char_mem_size;
|
||||
unsigned char* font_data;
|
||||
const unsigned char* font_data;
|
||||
|
||||
public:
|
||||
FontInstance() : char_width(width), char_height(height), char_mem_size((((char_width + (8 >> 1)) / 8) * char_height)), font_data(data) {}
|
||||
inline unsigned char* getChar(int c) const {
|
||||
|
||||
inline const unsigned char* getChar(int c) const override {
|
||||
return &font_data[char_mem_size * c];
|
||||
}
|
||||
inline unsigned int get_char_width() const {
|
||||
inline unsigned int get_char_width() const override {
|
||||
return char_width;
|
||||
}
|
||||
inline unsigned int get_char_height() const {
|
||||
inline unsigned int get_char_height() const override {
|
||||
return char_height;
|
||||
}
|
||||
};
|
||||
|
||||
extern unsigned char fontdata_8x16[];
|
||||
extern unsigned char fontdata_8x8[];
|
||||
extern unsigned char acorndata_8x8[];
|
||||
extern unsigned char fontdata_pearl_8x8[];
|
||||
extern unsigned char fontdata_sun_12x22[];
|
||||
extern unsigned char fontdata_sun_8x16[];
|
||||
extern const unsigned char fontdata_8x16[];
|
||||
extern const unsigned char fontdata_8x8[];
|
||||
extern const unsigned char acorndata_8x8[];
|
||||
extern const unsigned char fontdata_pearl_8x8[];
|
||||
extern const unsigned char fontdata_sun_12x22[];
|
||||
extern const unsigned char fontdata_sun_8x16[];
|
||||
|
||||
typedef FontInstance<8, 16, fontdata_8x16> Font_8x16;
|
||||
typedef FontInstance<8, 8, fontdata_8x8> Font_8x8;
|
||||
@ -52,11 +53,11 @@ typedef FontInstance<8, 8, fontdata_pearl_8x8> Font_pearl_8x8;
|
||||
typedef FontInstance<12, 22, fontdata_sun_12x22> Font_sun_12x22;
|
||||
typedef FontInstance<8, 16, fontdata_sun_8x16> Font_sun_8x16;
|
||||
|
||||
extern Font_8x16 std_font_8x16;
|
||||
extern Font_8x8 std_font_8x8;
|
||||
extern Font_acorn_8x8 acorn_font_8x8;
|
||||
extern Font_pearl_8x8 pearl_font_8x8;
|
||||
extern Font_sun_12x22 sun_font_12x22;
|
||||
extern Font_sun_8x16 sun_font_8x16;
|
||||
extern const Font_8x16 std_font_8x16;
|
||||
extern const Font_8x8 std_font_8x8;
|
||||
extern const Font_acorn_8x8 acorn_font_8x8;
|
||||
extern const Font_pearl_8x8 pearl_font_8x8;
|
||||
extern const Font_sun_12x22 sun_font_12x22;
|
||||
extern const Font_sun_8x16 sun_font_8x16;
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* GIMP RGB C-Source image dump (hhulogo.c) */
|
||||
|
||||
static const struct {
|
||||
static constexpr const struct {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
|
||||
|
Reference in New Issue
Block a user