1

merged cleanup

This commit is contained in:
2022-07-24 21:12:31 +02:00
parent 5ff3d72bfd
commit 6481bae5f6
92 changed files with 663 additions and 755 deletions

View File

@ -59,7 +59,7 @@ void CGA::getpos(unsigned int& x, unsigned int& y) {
(cursor_low & 0xFF) | ((cursor_high << 8) & 0xFF00);
x = cursor % COLUMNS;
y = (int)(cursor / COLUMNS);
y = (cursor / COLUMNS);
}
/*****************************************************************************
@ -146,11 +146,11 @@ void CGA::print(const char* string, unsigned int n, unsigned char attrib) const
}
void CGA::print(const bse::string& string, const unsigned int n, const unsigned char attrib) const {
print((const char*)string, n, attrib);
print(static_cast<const char*>(string), n, attrib);
}
void CGA::print(const bse::string& string, const unsigned char attrib) const {
print((const char*)string, string.size(), attrib);
print(static_cast<const char*>(string), string.size(), attrib);
}
/*****************************************************************************
@ -202,7 +202,7 @@ unsigned char CGA::attribute(CGA::color bg, CGA::color fg, bool blink) {
/* Hier muess Code eingefuegt werden */
return (int)blink << 7 // B0000000
return static_cast<int>(blink) << 7 // B0000000
| (bg & 0x7) << 4 // 0HHH0000 (Hintergrund)
| (fg & 0xF); // 0000VVVV (Vordergrund)
}

View File

@ -11,8 +11,8 @@
* Autor: Olaf Spinczyk, TU Dortmund *
* Aenderungen von Michael Schoettner, HHU, 21.8.2016 *
*****************************************************************************/
#ifndef __CGA_include__
#define __CGA_include__
#ifndef CGA_include_H_
#define CGA_include_H_
#include "kernel/IOport.h"
#include "user/lib/Array.h"
@ -29,9 +29,11 @@ public:
// Konstruktur mit Initialisierung der Ports
CGA() {
this->setpos(0, 0);
CGA::setpos(0, 0);
}
// virtual ~CGA() = default;
static const unsigned int CGA_START = 0xb8000U;
// Konstanten fuer die moeglichen Farben im Attribut-Byte.

View File

@ -24,11 +24,11 @@
* verwendet werden, um eine Ausgabe zu erzwingen. *
*****************************************************************************/
void CGA_Stream::flush() {
print(&buffer, pos, attribute(color_bg, color_fg, blink)); // print(buffer...) would work syntactically
print(buffer.data(), pos, attribute(color_bg, color_fg, blink)); // print(buffer...) would work syntactically
// but the system wouldn't start, as the bse::array
// would be implicitly converted to bse::string and
// that is dynamically allocated.
// print(&buffer...) just uses the stack location of
// print(buffer.data()...) just uses the stack location of
// the internal buffer of bse::array
// Flushing resets attributes

View File

@ -12,8 +12,8 @@
* Autor: Olaf Spinczyk, TU Dortmund *
* Aenderungen von Michael Schoettner, HHU, 06.04.20 *
*****************************************************************************/
#ifndef __CGA_Stream_include__
#define __CGA_Stream_include__
#ifndef CGA_Stream_include_H_
#define CGA_Stream_include_H_
#include "devices/CGA.h"
#include "lib/OutStream.h"
@ -42,7 +42,7 @@ class CGA_Stream : public OutStream, public CGA {
private:
// Allow for synchronization of output text, needed when running something in parallel to
// the PreemptiveThreadDemo for example
// NOTE: Should only be used by threads (like the demos) to not deadlock the system
// NOTE: Should only be used by threads (like the demos) to not lock the system
Semaphore sem;
CGA::color color_fg;
@ -58,6 +58,8 @@ public:
pos = 0;
}
// ~CGA_Stream() override = default;
void lock() { sem.p(); }
void unlock() { sem.v(); }

View File

@ -7,8 +7,8 @@
* *
* Autor: Olaf Spinczyk, TU Dortmund *
*****************************************************************************/
#ifndef __Key_include__
#define __Key_include__
#ifndef Key_include__
#define Key_include__
class Key {
// Kopieren erlaubt!
@ -98,7 +98,7 @@ public:
bool alt() const { return alt_left() || alt_right(); }
bool ctrl() const { return ctrl_left() || ctrl_right(); }
operator char() const { return (char)asc; }
operator char() const { return static_cast<char>(asc); }
// Scan-Codes einiger spezieller Tasten
struct scan {

View File

@ -16,7 +16,7 @@ const IOport Keyboard::data_port(0x60);
/* Tabellen fuer ASCII-Codes (Klassenvariablen) intiialisieren */
constexpr unsigned char Keyboard::normal_tab[] = {
constexpr const unsigned char Keyboard::normal_tab[] = {
0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 225, 39, '\b',
0, 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 129, '+', '\n',
0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 148, 132, '^', 0, '#',
@ -24,7 +24,7 @@ constexpr unsigned char Keyboard::normal_tab[] = {
'*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-',
0, 0, 0, '+', 0, 0, 0, 0, 0, 0, 0, '<', 0, 0};
constexpr unsigned char Keyboard::shift_tab[] = {
constexpr const unsigned char Keyboard::shift_tab[] = {
0, 0, '!', '"', 21, '$', '%', '&', '/', '(', ')', '=', '?', 96, 0,
0, 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 154, '*', 0,
0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 153, 142, 248, 0, 39,
@ -32,7 +32,7 @@ constexpr unsigned char Keyboard::shift_tab[] = {
0, 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '>', 0, 0};
constexpr unsigned char Keyboard::alt_tab[] = {
constexpr const unsigned char Keyboard::alt_tab[] = {
0, 0, 0, 253, 0, 0, 0, 0, '{', '[', ']', '}', '\\', 0, 0,
0, '@', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '~', 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -40,10 +40,10 @@ constexpr unsigned char Keyboard::alt_tab[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '|', 0, 0};
constexpr unsigned char Keyboard::asc_num_tab[] = {
constexpr const unsigned char Keyboard::asc_num_tab[] = {
'7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', ','};
constexpr unsigned char Keyboard::scan_num_tab[] = {
constexpr const unsigned char Keyboard::scan_num_tab[] = {
8, 9, 10, 53, 5, 6, 7, 27, 2, 3, 4, 11, 51};
/*****************************************************************************
@ -269,7 +269,7 @@ Key Keyboard::key_hit() {
return invalid;
}
code = (unsigned char)data_port.inb();
code = data_port.inb();
if (key_decoded()) {
return gather;
}
@ -287,7 +287,7 @@ void Keyboard::reboot() {
// Dem BIOS mitteilen, dass das Reset beabsichtigt war
// und kein Speichertest durchgefuehrt werden muss.
*(unsigned short*)0x472 = 0x1234;
*reinterpret_cast<unsigned short*>(0x472) = 0x1234;
// Der Tastaturcontroller soll das Reset ausloesen.
do {
@ -332,17 +332,17 @@ void Keyboard::set_led(char led, bool on) {
// und erlaubt den keyboard interrupt im PIC
void Keyboard::plugin() {
intdis.assign(IntDispatcher::keyboard, *this);
pic.allow(PIC::keyboard);
PIC::allow(PIC::keyboard);
}
void Keyboard::trigger() {
Key key = this->key_hit();
this->lastkey = key.ascii();
Key key = key_hit();
// lastkey = key.ascii();
// NOTE: My keyboard has no delete key...
if (key.ctrl_left() && key.alt_left() && (char)key == 'r') {
this->reboot();
if (key.ctrl_left() && key.alt_left() && static_cast<char>(key) == 'r') {
reboot();
} else if (key != 0) {
kevman.broadcast(key);
kevman.broadcast(key); // Send key to all subscribed threads
}
}

View File

@ -8,8 +8,8 @@
* Autor: Olaf Spinczyk, TU Dortmund *
* Modifikationen, Michael Schoettner, 2.6.2022 *
*****************************************************************************/
#ifndef __Keyboard_include__
#define __Keyboard_include__
#ifndef Keyboard_include__
#define Keyboard_include__
#include "devices/Key.h"
#include "kernel/interrupts/ISR.h"
@ -74,13 +74,15 @@ private:
public:
Keyboard(const Keyboard& copy) = delete; // Verhindere Kopieren
unsigned int lastkey; // speichert den ASCII-Code der zuletzt gedrückten Taste
// Initialisierung der Tastatur.
Keyboard();
// ~Keyboard() override = default;
// unsigned int lastkey; // speichert den ASCII-Code der zuletzt gedrückten Taste
// Fuehrt einen Neustart des Rechners durch.
void reboot();
static void reboot();
// Einstellen der Wiederholungsrate der Tastatur.
void set_repeat_rate(int speed, int delay);

View File

@ -13,7 +13,6 @@
*****************************************************************************/
#include "devices/LFBgraphics.h"
#include "kernel/Globals.h"
/* Hilfsfunktionen */
void swap(unsigned int* a, unsigned int* b);
@ -43,8 +42,8 @@ inline void LFBgraphics::drawMonoBitmap(unsigned int x, unsigned int y,
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;
unsigned int xpos = x;
unsigned int ypos = y + yoff;
for (unsigned int xb = 0; xb < width_byte; ++xb) {
for (int src = 7; src >= 0; --src) {
if ((1 << src) & *bitmap) {
@ -86,14 +85,14 @@ void LFBgraphics::drawString(const Font& fnt, unsigned int x, unsigned int y,
* Beschreibung: Zeichnen eines Pixels. *
*****************************************************************************/
void LFBgraphics::drawPixel(unsigned int x, unsigned int y, unsigned int col) const {
unsigned char* ptr = (unsigned char*)lfb;
unsigned char* ptr = reinterpret_cast<unsigned char*>(lfb);
if (hfb == 0 || lfb == 0) {
return;
}
if (mode == BUFFER_INVISIBLE) {
ptr = (unsigned char*)hfb;
ptr = reinterpret_cast<unsigned char*>(hfb);
}
// Pixel ausserhalb des sichtbaren Bereichs?
@ -119,7 +118,7 @@ void LFBgraphics::drawPixel(unsigned int x, unsigned int y, unsigned int col) co
*ptr = ((col >> 8) & 0xFF);
ptr++;
*ptr = ((col >> 16) & 0xFF);
ptr++;
ptr;
return;
case 32:
ptr += (4 * x + 4 * y * xres);
@ -128,7 +127,7 @@ void LFBgraphics::drawPixel(unsigned int x, unsigned int y, unsigned int col) co
*ptr = ((col >> 8) & 0xFF);
ptr++;
*ptr = ((col >> 16) & 0xFF);
ptr++;
ptr;
return;
}
}
@ -139,12 +138,12 @@ void LFBgraphics::drawStraightLine(unsigned int x1, unsigned int y1, unsigned in
if (x1 == x2 && y2 > y1) {
// Vertical line
for (unsigned int i = y1; i <= y2; ++i) {
this->drawPixel(x1, i, col);
drawPixel(x1, i, col);
}
} else if (y1 == y2 && x2 > x1) {
// Horizontal line
for (unsigned int i = x1; i <= x2; ++i) {
this->drawPixel(i, y1, col);
drawPixel(i, y1, col);
}
} else {
// Not straight
@ -155,32 +154,32 @@ void LFBgraphics::drawStraightLine(unsigned int x1, unsigned int y1, unsigned in
// | |
// (x1, y2)---(x2, y2)
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);
drawStraightLine(x1, y1, x2, y1, col);
drawStraightLine(x2, y1, x2, y2, col);
drawStraightLine(x1, y2, x2, y2, col);
drawStraightLine(x1, y1, x1, y2, 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) const {
unsigned char* ptr;
void LFBgraphics::drawSprite(unsigned int width, unsigned int height, unsigned int bytes_pp, const unsigned char* pixel_data) const {
const unsigned char* ptr;
for (unsigned int x = 0; x < width; ++x) {
for (unsigned int y = 0; y < height; ++y) {
ptr = (unsigned char*)pixel_data + (x + y * width) * bytes_pp;
ptr = pixel_data + (x + y * width) * bytes_pp;
switch (bytes_pp) {
case 2:
// TODO: Never tested, probably doesn't work
this->drawPixel(x, y, RGB_24(*ptr & 0b11111000, ((*ptr & 0b111) << 3) | (*(ptr + 1) >> 5),
drawPixel(x, y, RGB_24(*ptr & 0b11111000, ((*ptr & 0b111) << 3) | (*(ptr + 1) >> 5),
*(ptr + 1) & 0b11111)); // RGB 565
break;
case 3:
case 4:
// Alpha gets ignored anyway
this->drawPixel(x, y, RGB_24(*ptr, *(ptr + 1), *(ptr + 2)));
drawPixel(x, y, RGB_24(*ptr, *(ptr + 1), *(ptr + 2)));
break;
}
}
@ -193,7 +192,7 @@ void LFBgraphics::drawSprite(unsigned int width, unsigned int height, unsigned i
* Beschreibung: Bildschirm loeschen. *
*****************************************************************************/
void LFBgraphics::clear() const {
unsigned int* ptr = (unsigned int*)lfb;
unsigned int* ptr = reinterpret_cast<unsigned int*>(lfb);
unsigned int i;
if (hfb == 0 || lfb == 0) {
@ -201,7 +200,7 @@ void LFBgraphics::clear() const {
}
if (mode == 0) {
ptr = (unsigned int*)hfb;
ptr = reinterpret_cast<unsigned int*>(hfb);
}
switch (bpp) {
@ -244,8 +243,8 @@ void LFBgraphics::setDrawingBuff(int v) {
* Beschreibung: Kopiert den versteckten Puffer in den sichtbaren LFB. *
*****************************************************************************/
void LFBgraphics::copyHiddenToVisible() const {
unsigned int* sptr = (unsigned int*)hfb;
unsigned int* dptr = (unsigned int*)lfb;
unsigned int* sptr = reinterpret_cast<unsigned int*>(hfb);
unsigned int* dptr = reinterpret_cast<unsigned int*>(lfb);
unsigned int i;
if (hfb == 0 || lfb == 0) {
@ -278,7 +277,7 @@ void LFBgraphics::copyHiddenToVisible() const {
}
void swap(unsigned int* a, unsigned int* b) {
int h = *a;
unsigned int h = *a;
*a = *b;
*b = h;

View File

@ -12,16 +12,18 @@
* https://blog.demofox.org/2015/01/17/bresenhams-drawing-algorithms *
*****************************************************************************/
#ifndef __LFBgraphics_include__
#define __LFBgraphics_include__
#ifndef LFBgraphics_include__
#define LFBgraphics_include__
#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)
constexpr unsigned int RGB_24(unsigned int r, unsigned int g, unsigned int b) {
return ((r << 16) + (g << 8) + b);
}
#define BUFFER_INVISIBLE 0
#define BUFFER_VISIBLE 1
constexpr const bool BUFFER_INVISIBLE = false;
constexpr const bool BUFFER_VISIBLE = true;
class LFBgraphics {
private:
@ -50,7 +52,7 @@ public:
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;
void drawSprite(unsigned int width, unsigned int height, unsigned int bytes_pp, unsigned char* pixel_data) const;
void drawSprite(unsigned int width, unsigned int height, unsigned int bytes_pp, const unsigned char* pixel_data) const;
// stellt ein, ob in den sichtbaren Puffer gezeichnet wird
void setDrawingBuff(int v);

View File

@ -16,7 +16,6 @@
#include "kernel/Globals.h"
const IOport PCSPK::control(0x43);
const IOport PCSPK::data0(0x40);
const IOport PCSPK::data2(0x42);
const IOport PCSPK::ppi(0x61);
@ -29,7 +28,7 @@ const IOport PCSPK::ppi(0x61);
* len: Laenge des Tons in ms *
*****************************************************************************/
void PCSPK::play(float f, int len) {
int freq = (int)f;
int freq = static_cast<int>(f);
int cntStart = 1193180 / freq;
int status;
@ -39,7 +38,7 @@ void PCSPK::play(float f, int len) {
data2.outb(cntStart / 256); // Zaehler-2 laden (Hibyte)
// Lautsprecher einschalten
status = (int)ppi.inb(); // Status-Register des PPI auslesen
status = static_cast<int>(ppi.inb()); // Status-Register des PPI auslesen
ppi.outb(status | 3); // Lautpsrecher Einschalten
// Pause
@ -57,7 +56,7 @@ void PCSPK::play(float f, int len) {
void PCSPK::off() {
int status;
status = (int)ppi.inb(); // Status-Register des PPI auslesen
status = static_cast<int>(ppi.inb()); // Status-Register des PPI auslesen
ppi.outb((status >> 2) << 2); // Lautsprecher ausschalten
}

View File

@ -12,67 +12,66 @@
* Autor: Michael Schoettner, HHU, 22.9.2016 *
*****************************************************************************/
#ifndef __PCSPK_include__
#define __PCSPK_include__
#ifndef PCSPK_include__
#define PCSPK_include__
#include "kernel/IOport.h"
// Note, Frequenz
#define C0 130.81
#define C0X 138.59
#define D0 146.83
#define D0X 155.56
#define E0 164.81
#define F0 174.61
#define F0X 185.00
#define G0 196.00
#define G0X 207.65
#define A0 220.00
#define A0X 233.08
#define B0 246.94
constexpr const float C0 = 130.81;
constexpr const float C0X = 138.59;
constexpr const float D0 = 146.83;
constexpr const float D0X = 155.56;
constexpr const float E0 = 164.81;
constexpr const float F0 = 174.61;
constexpr const float F0X = 185.00;
constexpr const float G0 = 196.00;
constexpr const float G0X = 207.65;
constexpr const float A0 = 220.00;
constexpr const float A0X = 233.08;
constexpr const float B0 = 246.94;
#define C1 261.63
#define C1X 277.18
#define D1 293.66
#define D1X 311.13
#define E1 329.63
#define F1 349.23
#define F1X 369.99
#define G1 391.00
#define G1X 415.30
#define A1 440.00
#define A1X 466.16
#define B1 493.88
constexpr const float C1 = 261.63;
constexpr const float C1X = 277.18;
constexpr const float D1 = 293.66;
constexpr const float D1X = 311.13;
constexpr const float E1 = 329.63;
constexpr const float F1 = 349.23;
constexpr const float F1X = 369.99;
constexpr const float G1 = 391.00;
constexpr const float G1X = 415.30;
constexpr const float A1 = 440.00;
constexpr const float A1X = 466.16;
constexpr const float B1 = 493.88;
#define C2 523.25
#define C2X 554.37
#define D2 587.33
#define D2X 622.25
#define E2 659.26
#define F2 698.46
#define F2X 739.99
#define G2 783.99
#define G2X 830.61
#define A2 880.00
#define A2X 923.33
#define B2 987.77
#define C3 1046.50
constexpr const float C2 = 523.25;
constexpr const float C2X = 554.37;
constexpr const float D2 = 587.33;
constexpr const float D2X = 622.25;
constexpr const float E2 = 659.26;
constexpr const float F2 = 698.46;
constexpr const float F2X = 739.99;
constexpr const float G2 = 783.99;
constexpr const float G2X = 830.61;
constexpr const float A2 = 880.00;
constexpr const float A2X = 923.33;
constexpr const float B2 = 987.77;
constexpr const float C3 = 1046.50;
class PCSPK {
private:
static const IOport control; // Steuerregister (write only)
static const IOport data0; // Zaehler-0 Datenregister (read/write)
static const IOport data2; // Zaehler-2 Datenregister
static const IOport ppi; // Status-Register des PPI
// Verzoegerung um X ms (in 1ms Schritten; Min. 1ms)
inline void delay(int time);
static inline void delay(int time);
public:
PCSPK(const PCSPK& copy) = delete; // Verhindere Kopieren
// Konstruktor. Initialisieren der Ports.
PCSPK() {}
PCSPK() = default;
// Demo Sounds
void tetris();
@ -82,7 +81,7 @@ public:
void play(float f, int len);
// Lautsprecher ausschalten
void off();
static void off();
};
#endif

View File

@ -30,7 +30,7 @@ void PIT::interval(int us) {
control.outb(0x36); // Zähler 0 Mode 3
unsigned int cntStart = (1193180.0 / 1000000.0) * us; // 1.19Mhz PIT
unsigned int cntStart = static_cast<unsigned int>((1193180.0 / 1000000.0) * us); // 1.19Mhz PIT
data0.outb(cntStart & 0xFF); // Zaehler-0 laden (Lobyte)
data0.outb(cntStart >> 8); // Zaehler-0 laden (Hibyte)
@ -75,10 +75,10 @@ void PIT::trigger() {
/* hier muss Code eingefuegt werden */
// Indicator
if (systime - this->last_indicator_refresh >= 10) {
this->indicator_pos = (this->indicator_pos + 1) % 4;
CGA::show(79, 0, this->indicator[this->indicator_pos]);
this->last_indicator_refresh = systime;
if (systime - last_indicator_refresh >= 10) {
indicator_pos = (indicator_pos + 1) % 4;
CGA::show(79, 0, indicator[indicator_pos]);
last_indicator_refresh = systime;
}
// Preemption

View File

@ -8,11 +8,12 @@
* Autor: Michael Schoettner, 23.8.2016 *
*****************************************************************************/
#ifndef __PIT_include__
#define __PIT_include__
#ifndef PIT_include__
#define PIT_include__
#include "kernel/interrupts/ISR.h"
#include "kernel/IOport.h"
#include "user/lib/Array.h"
class PIT : public ISR {
private:
@ -22,13 +23,15 @@ private:
enum { time_base = 838 }; /* ns */
int timer_interval;
const char indicator[4] = {'|', '/', '-', '\\'};
const bse::array<char, 4> indicator{'|', '/', '-', '\\'};
unsigned int indicator_pos = 0;
unsigned long last_indicator_refresh = 0;
public:
PIT(const PIT& copy) = delete; // Verhindere Kopieren
// ~PIT() override = default;
// Zeitgeber initialisieren.
explicit PIT(int us) {
PIT::interval(us);

View File

@ -56,10 +56,9 @@ struct VbeInfoBlock {
* Beschreibung: Schalter in den Text-Modus 80x25 Zeichen. *
*****************************************************************************/
void VESA::initTextMode() {
allocator.free((void*)hfb); // Memory is allocated after every start and never deleted, so add that
BC_params->AX = 0x4f02; // SVFA BIOS, init mode
BC_params->BX = 0x4003; // 80x25
bios.Int(0x10);
BIOS::Int(0x10);
}
/*****************************************************************************
@ -76,9 +75,9 @@ bool VESA::initGraphicMode(unsigned short mode) {
BC_params->AX = 0x4F00;
BC_params->ES = RETURN_MEM >> 4;
BC_params->DI = RETURN_MEM & 0xF;
bios.Int(0x10);
BIOS::Int(0x10);
struct VbeInfoBlock* ib = (struct VbeInfoBlock*)RETURN_MEM;
VbeInfoBlock* ib = reinterpret_cast<VbeInfoBlock*>(RETURN_MEM);
// Signaturen pruefen
if (BC_params->AX != 0x004F) {
@ -94,18 +93,18 @@ bool VESA::initGraphicMode(unsigned short mode) {
// kout << "TotalVideoMemory: " << ((ib->TotalMemory*65536) / (1024*1024)) << " MB" << endl;
// Gewuenschten Grafikmodus aus Antwort suchen
unsigned short* modePtr = (unsigned short*)((ib->VideoModePtr[1] << 4) + ib->VideoModePtr[0]);
unsigned short* modePtr = reinterpret_cast<unsigned short*>((ib->VideoModePtr[1] << 4) + ib->VideoModePtr[0]);
for (int i = 0; modePtr[i] != 0xFFFF; ++i) {
// Gewuenschter Grafikmodus gefunden?
if (modePtr[i] == mode) {
struct VbeModeInfoBlock* minf = (struct VbeModeInfoBlock*)RETURN_MEM;
VbeModeInfoBlock* minf = reinterpret_cast<VbeModeInfoBlock*>(RETURN_MEM);
// Weitere Infos ueber diesen Grafikmodus abfragen
BC_params->AX = 0x4F01;
BC_params->CX = mode;
BC_params->ES = RETURN_MEM >> 4;
BC_params->DI = RETURN_MEM & 0xF;
bios.Int(0x10);
BIOS::Int(0x10);
// Text-Modi 0-3 haben keinen LFB
if (mode > 3 && (minf->attributes & 0x90) == 0) {
@ -116,15 +115,15 @@ bool VESA::initGraphicMode(unsigned short mode) {
mode_nr = mode;
xres = minf->Xres;
yres = minf->Yres;
bpp = (int)minf->bpp;
bpp = static_cast<int>(minf->bpp);
lfb = minf->physbase;
hfb = (unsigned int)new char[xres * yres * bpp / 8];
hfb = reinterpret_cast<unsigned int>(new char[xres * yres * bpp / 8]);
// Grafikmodus einschalten
BC_params->AX = 0x4f02; // SVFA BIOS, init mode
BC_params->BX = mode;
bios.Int(0x10);
BIOS::Int(0x10);
return true;
}
}

View File

@ -8,19 +8,19 @@
* Autor: Michael Schoettner, HHU, 19.5.2022 *
*****************************************************************************/
#ifndef __VESA_include__
#define __VESA_include__
#ifndef VESA_include__
#define VESA_include__
#include "devices/LFBgraphics.h"
#include "user/lib/Logger.h"
// Ausgewaehlte Grafikmodi mit Mode-Nummer
#define MODE_640_480_16BITS 0x111
#define MODE_640_480_24BITS 0x112
#define MODE_800_600_16BITS 0x114
#define MODE_800_600_24BITS 0x115
#define MODE_1024_768_16BITS 0x117
#define MODE_1024_768_24BITS 0x118
constexpr const unsigned int MODE_640_480_16BITS = 0x111;
constexpr const unsigned int MODE_640_480_24BITS = 0x112;
constexpr const unsigned int MODE_800_600_16BITS = 0x114;
constexpr const unsigned int MODE_800_600_24BITS = 0x115;
constexpr const unsigned int MODE_1024_768_16BITS = 0x117;
constexpr const unsigned int MODE_1024_768_24BITS = 0x118;
class VESA : public LFBgraphics {
private:
@ -34,7 +34,7 @@ public:
// Bestimmten Grafikmodus einschalten
bool initGraphicMode(unsigned short mode);
void initTextMode();
static void initTextMode();
};
#endif

View File

@ -6,7 +6,7 @@
/* */
/**********************************************/
#define FONTDATAMAX_8x16 4096
constexpr unsigned int FONTDATAMAX_8x16 = 4096;
constexpr unsigned char fontdata_8x16[FONTDATAMAX_8x16] = {

View File

@ -6,7 +6,7 @@
/* */
/**********************************************/
#define FONTDATAMAX_8x8 2048
constexpr unsigned int FONTDATAMAX_8x8 = 2048;
constexpr unsigned char fontdata_8x8[FONTDATAMAX_8x8] = {

View File

@ -10,9 +10,10 @@
/* linux-m86k) by John Shifflett */
/* */
/**********************************************/
#define FONTDATAMAX_PEARL_8x8 2048
constexpr unsigned char fontdata_pearl_8x8[FONTDATAMAX_PEARL_8x8] = {
constexpr const unsigned int FONTDATAMAX_PEARL_8x8 = 2048;
constexpr const unsigned char fontdata_pearl_8x8[FONTDATAMAX_PEARL_8x8] = {
/* 0 0x00 '^@' */
0x00, /* 00000000 */

View File

@ -1,8 +1,8 @@
// vim: set et ts=4 sw=4:
#define FONTDATAMAX_SUN_12x22 11264
constexpr const unsigned int FONTDATAMAX_SUN_12x22 = 11264;
constexpr unsigned char fontdata_sun_12x22[FONTDATAMAX_SUN_12x22] = {
constexpr const unsigned char fontdata_sun_12x22[FONTDATAMAX_SUN_12x22] = {
/* 0 0x00 '^@' */
0x00, 0x00, /* 000000000000 */

View File

@ -1,8 +1,8 @@
// vim: set et ts=4 sw=4:
#define FONTDATAMAX_SUN8x16 4096
constexpr const unsigned int FONTDATAMAX_SUN8x16 = 4096;
constexpr 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,

View File

@ -8,11 +8,13 @@
// Je nach Breite wird auf Bytegrenzen aufgerundet:
// 8 Pixel -> 1 Byte; 12 Pixel -> 2 Byte
#ifndef __FONTS_H__
#define __FONTS_H__
#ifndef FONTS_H__
#define FONTS_H__
class Font {
public:
virtual ~Font() = default;
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;