reformat
This commit is contained in:
@ -15,12 +15,10 @@
|
|||||||
#include "devices/LFBgraphics.h"
|
#include "devices/LFBgraphics.h"
|
||||||
#include "kernel/Globals.h"
|
#include "kernel/Globals.h"
|
||||||
|
|
||||||
|
|
||||||
/* Hilfsfunktionen */
|
/* Hilfsfunktionen */
|
||||||
void swap(unsigned int* a, unsigned int* b);
|
void swap(unsigned int* a, unsigned int* b);
|
||||||
int abs(int a);
|
int abs(int a);
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: LFBgraphics::drawMonoBitmap *
|
* Methode: LFBgraphics::drawMonoBitmap *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -61,7 +59,6 @@ inline void LFBgraphics::drawMonoBitmap( unsigned int x, unsigned int y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: LFBgraphics::drawString *
|
* Methode: LFBgraphics::drawString *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -76,16 +73,13 @@ inline void LFBgraphics::drawMonoBitmap( unsigned int x, unsigned int y,
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
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 col, char* str, unsigned int len) {
|
||||||
unsigned int i;
|
for (unsigned int i = 0; i < len; ++i) {
|
||||||
|
|
||||||
for(i = 0; i < len; ++i) {
|
|
||||||
drawMonoBitmap(x, y, fnt.get_char_width(), fnt.get_char_height(),
|
drawMonoBitmap(x, y, fnt.get_char_width(), fnt.get_char_height(),
|
||||||
fnt.getChar(*(str + i)), col);
|
fnt.getChar(*(str + i)), col);
|
||||||
x += fnt.get_char_width();
|
x += fnt.get_char_width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: LFBgraphics::drawPixel *
|
* Methode: LFBgraphics::drawPixel *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -97,13 +91,16 @@ void LFBgraphics::drawString(Font &fnt, unsigned int x, unsigned int y,
|
|||||||
void LFBgraphics::drawPixel(unsigned int x, unsigned int y, unsigned int col) {
|
void LFBgraphics::drawPixel(unsigned int x, unsigned int y, unsigned int col) {
|
||||||
unsigned char* ptr = (unsigned char*)lfb;
|
unsigned char* ptr = (unsigned char*)lfb;
|
||||||
|
|
||||||
if (hfb == 0 || lfb == 0) return ;
|
if (hfb == 0 || lfb == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == 0) ptr = (unsigned char*)hfb;
|
if (mode == 0) ptr = (unsigned char*)hfb;
|
||||||
|
|
||||||
// Pixel ausserhalb des sichtbaren Bereichs?
|
// Pixel ausserhalb des sichtbaren Bereichs?
|
||||||
if (x<0 || x>=xres || y<0 || y>yres)
|
if (x < 0 || x >= xres || y < 0 || y > yres) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Adresse des Pixels berechnen und Inhalt schreiben
|
// Adresse des Pixels berechnen und Inhalt schreiben
|
||||||
switch (bpp) {
|
switch (bpp) {
|
||||||
@ -118,20 +115,25 @@ void LFBgraphics::drawPixel(unsigned int x, unsigned int y,unsigned int col) {
|
|||||||
return;
|
return;
|
||||||
case 24:
|
case 24:
|
||||||
ptr += (3 * x + 3 * y * xres);
|
ptr += (3 * x + 3 * y * xres);
|
||||||
*ptr = (col & 0xFF); ptr++;
|
*ptr = (col & 0xFF);
|
||||||
*ptr = ((col>>8) & 0xFF); ptr++;
|
ptr++;
|
||||||
*ptr = ((col>>16) & 0xFF); ptr++;
|
*ptr = ((col >> 8) & 0xFF);
|
||||||
|
ptr++;
|
||||||
|
*ptr = ((col >> 16) & 0xFF);
|
||||||
|
ptr++;
|
||||||
return;
|
return;
|
||||||
case 32:
|
case 32:
|
||||||
ptr += (4 * x + 4 * y * xres);
|
ptr += (4 * x + 4 * y * xres);
|
||||||
*ptr = (col & 0xFF); ptr++;
|
*ptr = (col & 0xFF);
|
||||||
*ptr = ((col>>8) & 0xFF); ptr++;
|
ptr++;
|
||||||
*ptr = ((col>>16) & 0xFF); ptr++;
|
*ptr = ((col >> 8) & 0xFF);
|
||||||
|
ptr++;
|
||||||
|
*ptr = ((col >> 16) & 0xFF);
|
||||||
|
ptr++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: LFBgraphics::clear *
|
* Methode: LFBgraphics::clear *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -141,44 +143,48 @@ void LFBgraphics::clear() {
|
|||||||
unsigned int* ptr = (unsigned int*)lfb;
|
unsigned int* ptr = (unsigned int*)lfb;
|
||||||
unsigned int i;
|
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) {
|
switch (bpp) {
|
||||||
case 8:
|
case 8:
|
||||||
for (i=0; i < ((xres/4)*yres); i++)
|
for (i = 0; i < ((xres / 4) * yres); i++) {
|
||||||
*(ptr++) = 0;
|
*(ptr++) = 0;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case 15:
|
case 15:
|
||||||
case 16:
|
case 16:
|
||||||
for (i=0; i < (2*(xres/4)*yres); i++)
|
for (i = 0; i < (2 * (xres / 4) * yres); i++) {
|
||||||
*(ptr++) = 0;
|
*(ptr++) = 0;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case 24:
|
case 24:
|
||||||
for (i=0; i < (3*(xres/4)*yres); i++)
|
for (i = 0; i < (3 * (xres / 4) * yres); i++) {
|
||||||
*(ptr++) = 0;
|
*(ptr++) = 0;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case 32:
|
case 32:
|
||||||
for (i=0; i < (4*(xres/4)*yres); i++)
|
for (i = 0; i < (4 * (xres / 4) * yres); i++) {
|
||||||
*(ptr++) = 0;
|
*(ptr++) = 0;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: LFBgraphics::setDrawingBuff *
|
* Methode: LFBgraphics::setDrawingBuff *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
* Beschreibung: Stellt ein, ob in den sichtbaren Puffer gezeichnet wird. *
|
* Beschreibung: Stellt ein, ob in den sichtbaren Puffer gezeichnet wird. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void LFBgraphics::setDrawingBuff(int v)
|
void LFBgraphics::setDrawingBuff(int v) {
|
||||||
{
|
|
||||||
mode = v;
|
mode = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: LFBgraphics::copyHiddenToVisible *
|
* Methode: LFBgraphics::copyHiddenToVisible *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -193,37 +199,39 @@ void LFBgraphics::copyHiddenToVisible() {
|
|||||||
|
|
||||||
switch (bpp) {
|
switch (bpp) {
|
||||||
case 8:
|
case 8:
|
||||||
for (i=0; i < ((xres/4)*yres); i++)
|
for (i = 0; i < ((xres / 4) * yres); i++) {
|
||||||
*(dptr++) = *(sptr++);
|
*(dptr++) = *(sptr++);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case 15:
|
case 15:
|
||||||
case 16:
|
case 16:
|
||||||
for (i=0; i < (2*(xres/4)*yres); i++)
|
for (i = 0; i < (2 * (xres / 4) * yres); i++) {
|
||||||
*(dptr++) = *(sptr++);
|
*(dptr++) = *(sptr++);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case 24:
|
case 24:
|
||||||
for (i=0; i < (3*(xres/4)*yres); i++)
|
for (i = 0; i < (3 * (xres / 4) * yres); i++) {
|
||||||
*(dptr++) = *(sptr++);
|
*(dptr++) = *(sptr++);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case 32:
|
case 32:
|
||||||
for (i=0; i < (4*(xres/4)*yres); i++)
|
for (i = 0; i < (4 * (xres / 4) * yres); i++) {
|
||||||
*(dptr++) = *(sptr++);
|
*(dptr++) = *(sptr++);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void swap(unsigned int* a, unsigned int* b) {
|
void swap(unsigned int* a, unsigned int* b) {
|
||||||
int h;
|
int h = *a;
|
||||||
|
|
||||||
h = *a;
|
|
||||||
|
|
||||||
*a = *b;
|
*a = *b;
|
||||||
*b = h;
|
*b = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
int abs(int a) {
|
int abs(int a) {
|
||||||
if (a<0) return -a;
|
if (a < 0) {
|
||||||
|
return -a;
|
||||||
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "devices/fonts/Fonts.h"
|
#include "devices/fonts/Fonts.h"
|
||||||
|
|
||||||
|
|
||||||
// Hilfsfunktionen um Farbwerte fuer einen Pixel zu erzeugen
|
// 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)
|
||||||
|
|
||||||
@ -27,7 +26,7 @@
|
|||||||
class LFBgraphics {
|
class LFBgraphics {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LFBgraphics (const LFBgraphics ©); // Verhindere Kopieren
|
LFBgraphics(const LFBgraphics& copy) = delete; // Verhindere Kopieren
|
||||||
|
|
||||||
// Hilfsfunktion fuer drawString
|
// Hilfsfunktion fuer drawString
|
||||||
void drawMonoBitmap(unsigned int x, unsigned int y,
|
void drawMonoBitmap(unsigned int x, unsigned int y,
|
||||||
@ -41,7 +40,7 @@ public:
|
|||||||
unsigned int hfb; // Adresse des versteckten Buffers (optional, fuer Animationen)
|
unsigned int hfb; // Adresse des versteckten Buffers (optional, fuer Animationen)
|
||||||
unsigned int mode; // Zeichnen im sichtbaren = 1 oder unsichtbaren = 0 Puffer
|
unsigned int mode; // Zeichnen im sichtbaren = 1 oder unsichtbaren = 0 Puffer
|
||||||
|
|
||||||
LFBgraphics () { mode = BUFFER_VISIBLE; };
|
LFBgraphics() : mode(BUFFER_VISIBLE) {};
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void drawPixel(unsigned int x, unsigned int y, unsigned int col);
|
void drawPixel(unsigned int x, unsigned int y, unsigned int col);
|
||||||
@ -54,7 +53,6 @@ public:
|
|||||||
|
|
||||||
// kopiert 'hfb' nach 'lfb'
|
// kopiert 'hfb' nach 'lfb'
|
||||||
void copyHiddenToVisible();
|
void copyHiddenToVisible();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include "kernel/Globals.h"
|
#include "kernel/Globals.h"
|
||||||
#include "user/CoopThreadDemo.h"
|
#include "user/CoopThreadDemo.h"
|
||||||
#include "user/HelloWorldThread.h"
|
#include "user/HelloWorldThread.h"
|
||||||
|
#include "user/VBEdemo.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
kout.clear();
|
kout.clear();
|
||||||
@ -25,7 +26,7 @@ int main() {
|
|||||||
|
|
||||||
// Startmeldung
|
// Startmeldung
|
||||||
if constexpr (!DEBUG) {
|
if constexpr (!DEBUG) {
|
||||||
kout << "HHUos 0.6\n"
|
kout << "HHUos 0.7\n"
|
||||||
<< "=========\n"
|
<< "=========\n"
|
||||||
<< "Unterstuetzte Funktionen:\n"
|
<< "Unterstuetzte Funktionen:\n"
|
||||||
<< " - Bildschirmausgaben\n"
|
<< " - Bildschirmausgaben\n"
|
||||||
@ -34,6 +35,7 @@ int main() {
|
|||||||
<< " - Einfache Heap verwaltung\n"
|
<< " - Einfache Heap verwaltung\n"
|
||||||
<< " - Tastatureingaben per Interrupt\n"
|
<< " - Tastatureingaben per Interrupt\n"
|
||||||
<< " - Kooperative Threads\n"
|
<< " - Kooperative Threads\n"
|
||||||
|
<< " - VESA Graphics Mode\n"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +56,9 @@ int main() {
|
|||||||
|
|
||||||
// Threads anlegen
|
// Threads anlegen
|
||||||
// scheduler.ready(new HelloWorldThread());
|
// scheduler.ready(new HelloWorldThread());
|
||||||
scheduler.ready(new CoopThreadDemo());
|
// scheduler.ready(new CoopThreadDemo());
|
||||||
|
|
||||||
|
scheduler.ready(new VBEdemo());
|
||||||
|
|
||||||
// Scheduler starten (schedule() erzeugt den Idle-Thread)
|
// Scheduler starten (schedule() erzeugt den Idle-Thread)
|
||||||
scheduler.schedule();
|
scheduler.schedule();
|
||||||
|
|||||||
@ -8,26 +8,22 @@
|
|||||||
* Autor: Michael Schoettner, HHU, 26.12.2016 *
|
* Autor: Michael Schoettner, HHU, 26.12.2016 *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "kernel/Globals.h"
|
|
||||||
#include "user/VBEdemo.h"
|
#include "user/VBEdemo.h"
|
||||||
#include "devices/fonts/Fonts.h"
|
#include "devices/fonts/Fonts.h"
|
||||||
|
#include "kernel/Globals.h"
|
||||||
|
|
||||||
// Bitmap
|
// Bitmap
|
||||||
#include "bmp_hhu.cc"
|
#include "bmp_hhu.cc"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: VBEdemo::linInterPol1D *
|
* Methode: VBEdemo::linInterPol1D *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
* Beschreibung: Farbwert in einer Dimension interpoliert berechnen. *
|
* Beschreibung: Farbwert in einer Dimension interpoliert berechnen. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int VBEdemo::linInterPol1D(int x, int xr, int l, int r) {
|
int VBEdemo::linInterPol1D(int x, int xr, int l, int r) {
|
||||||
return ((((l>>16)*(xr-x)+(r>>16)*x)/xr)<<16)
|
return ((((l >> 16) * (xr - x) + (r >> 16) * x) / xr) << 16) | (((((l >> 8) & 0xFF) * (xr - x) + ((r >> 8) & 0xFF) * x) / xr) << 8) | (((l & 0xFF) * (xr - x) + (r & 0xFF) * x) / xr);
|
||||||
|(((((l>>8)&0xFF)*(xr-x)+((r>>8)&0xFF)*x)/xr)<<8)
|
|
||||||
|(((l&0xFF)*(xr-x)+(r&0xFF)*x)/xr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: VBEdemo::linInterPol2D *
|
* Methode: VBEdemo::linInterPol2D *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -39,14 +35,14 @@ int VBEdemo::linInterPol2D(int x, int y, int lt, int rt, int lb, int rb) {
|
|||||||
linInterPol1D(x, vesa.xres, lb, rb));
|
linInterPol1D(x, vesa.xres, lb, rb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: VBEdemo::drawColors *
|
* Methode: VBEdemo::drawColors *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
* Beschreibung: Pixel-Demo. *
|
* Beschreibung: Pixel-Demo. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void VBEdemo::drawColors() {
|
void VBEdemo::drawColors() {
|
||||||
int x_res=640, y_res=480;
|
int x_res = 640;
|
||||||
|
int y_res = 480;
|
||||||
|
|
||||||
for (int y = 0; y < y_res; y++) {
|
for (int y = 0; y < y_res; y++) {
|
||||||
for (int x = 0; x < x_res; x++) {
|
for (int x = 0; x < x_res; x++) {
|
||||||
@ -55,7 +51,6 @@ void VBEdemo::drawColors () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: VBEdemo::drawBitmap *
|
* Methode: VBEdemo::drawBitmap *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -68,10 +63,8 @@ void VBEdemo::drawBitmap () {
|
|||||||
unsigned char* sprite_pixel = (unsigned char*)hhu.pixel_data;
|
unsigned char* sprite_pixel = (unsigned char*)hhu.pixel_data;
|
||||||
|
|
||||||
/* Hier muss Code eingefuegt werden */
|
/* Hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: VBEdemo::drawFonts *
|
* Methode: VBEdemo::drawFonts *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -80,10 +73,8 @@ void VBEdemo::drawBitmap () {
|
|||||||
void VBEdemo::drawFonts() {
|
void VBEdemo::drawFonts() {
|
||||||
|
|
||||||
/* Hier muss Code eingefuegt werden */
|
/* Hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: VBEdemo::run *
|
* Methode: VBEdemo::run *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
|
|||||||
@ -10,14 +10,12 @@
|
|||||||
#ifndef __VBEdemo_include__
|
#ifndef __VBEdemo_include__
|
||||||
#define __VBEdemo_include__
|
#define __VBEdemo_include__
|
||||||
|
|
||||||
|
|
||||||
#include "kernel/threads/Thread.h"
|
#include "kernel/threads/Thread.h"
|
||||||
|
|
||||||
|
|
||||||
class VBEdemo : public Thread {
|
class VBEdemo : public Thread {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VBEdemo (const VBEdemo ©); // Verhindere Kopieren
|
VBEdemo(const VBEdemo& copy) = delete; // Verhindere Kopieren
|
||||||
|
|
||||||
// Hilfsfunktionen fuer drawColors()
|
// Hilfsfunktionen fuer drawColors()
|
||||||
int linInterPol1D(int x, int xr, int l, int r);
|
int linInterPol1D(int x, int xr, int l, int r);
|
||||||
@ -25,10 +23,10 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Gib dem Anwendungsthread einen Stack.
|
// Gib dem Anwendungsthread einen Stack.
|
||||||
VBEdemo () : Thread () { }
|
VBEdemo() {}
|
||||||
|
|
||||||
// Thread-Startmethode
|
// Thread-Startmethode
|
||||||
void run ();
|
void run() override;
|
||||||
|
|
||||||
// Farbraum ausgeben
|
// Farbraum ausgeben
|
||||||
void drawColors();
|
void drawColors();
|
||||||
|
|||||||
Reference in New Issue
Block a user