1

initial reformat, still has misformats

This commit is contained in:
churl
2022-04-25 14:24:56 +02:00
parent 67fce9ff2d
commit 263563c105
20 changed files with 295 additions and 317 deletions

View File

@ -13,13 +13,12 @@
*****************************************************************************/
#include "devices/CGA.h"
/*****************************************************************************
* Methode: CGA::setpos *
*---------------------------------------------------------------------------*
* Beschreibung: Setzen des Cursors in Spalte x und Zeile y. *
*****************************************************************************/
void CGA::setpos (int x, int y) {
void CGA::setpos(int x, int y) {
/* Hier muess Code eingefuegt werden */
@ -33,10 +32,8 @@ void CGA::setpos (int x, int y) {
index_port.outb(0xE); // Cursor(high)
data_port.outb(cursor_high);
}
/*****************************************************************************
* Methode: CGA::getpos *
*---------------------------------------------------------------------------*
@ -44,7 +41,7 @@ void CGA::setpos (int x, int y) {
* *
* Rückgabewerte: x und y *
*****************************************************************************/
void CGA::getpos (int &x, int &y) {
void CGA::getpos(int& x, int& y) {
/* Hier muess Code eingefuegt werden */
@ -55,15 +52,12 @@ void CGA::getpos (int &x, int &y) {
unsigned char cursor_high = data_port.inb();
unsigned short cursor =
(cursor_low & 0xFF)
| ((cursor_high << 8) & 0xFF00);
(cursor_low & 0xFF) | ((cursor_high << 8) & 0xFF00);
x = cursor % 80;
y = (int)(cursor / 80);
}
/*****************************************************************************
* Methode: CGA::show *
*---------------------------------------------------------------------------*
@ -75,7 +69,7 @@ void CGA::getpos (int &x, int &y) {
* character Das auszugebende Zeichen *
* attrib Attributbyte fuer das Zeichen *
*****************************************************************************/
void CGA::show (int x, int y, char character, unsigned char attrib) {
void CGA::show(int x, int y, char character, unsigned char attrib) {
/* Hier muess Code eingefuegt werden */
@ -84,10 +78,8 @@ void CGA::show (int x, int y, char character, unsigned char attrib) {
*(pos + 1) = attrib;
// TODO: screen border check
}
/*****************************************************************************
* Methode: CGA::print *
*---------------------------------------------------------------------------*
@ -99,7 +91,7 @@ void CGA::show (int x, int y, char character, unsigned char attrib) {
* n Laenger der Zeichenkette *
* attrib Attributbyte fuer alle Zeichen der Zeichenkette *
*****************************************************************************/
void CGA::print (char* string, int n, unsigned char attrib) {
void CGA::print(char* string, int n, unsigned char attrib) {
/* Hier muess Code eingefuegt werden */
@ -126,10 +118,8 @@ void CGA::print (char* string, int n, unsigned char attrib) {
// TODO: automatic line breaking, automatic scrolling
// TODO: printing doesn't work after first newline character
}
/*****************************************************************************
* Methode: CGA::scrollup *
*---------------------------------------------------------------------------*
@ -137,7 +127,7 @@ void CGA::print (char* string, int n, unsigned char attrib) {
* Die neue Zeile am unteren Bildrand wird mit Leerzeichen *
* gefuellt. *
*****************************************************************************/
void CGA::scrollup () {
void CGA::scrollup() {
/* Hier muess Code eingefuegt werden */
@ -150,16 +140,14 @@ void CGA::scrollup () {
for (unsigned short byte = 2 * 80 * 24; byte < 2 * 80 * 25; ++byte) {
*((char*)(CGA_START + byte)) = '\0';
}
}
/*****************************************************************************
* Methode: CGA::clear *
*---------------------------------------------------------------------------*
* Beschreibung: Lösche den Textbildschirm. *
*****************************************************************************/
void CGA::clear () {
void CGA::clear() {
/* Hier muess Code eingefuegt werden */
@ -168,10 +156,8 @@ void CGA::clear () {
}
this->setpos(0, 0);
}
/*****************************************************************************
* Methode: CGA::attribute *
*---------------------------------------------------------------------------*
@ -184,8 +170,7 @@ void CGA::clear () {
* fg Foreground color *
* blink ywa/no *
*****************************************************************************/
unsigned char CGA::attribute (CGA::color bg, CGA::color fg, bool blink) {
unsigned char CGA::attribute(CGA::color bg, CGA::color fg, bool blink) {
/* Hier muess Code eingefuegt werden */
}

View File

@ -23,13 +23,13 @@ private:
IOport data_port; // Lese-/Schreib-Zugriff auf Register der Grafikk.
// Copy Konstrutkor unterbinden
CGA(const CGA &copy);
CGA(const CGA& copy);
public:
const char *CGA_START; // Startadresse des Buldschirmspeichers
const char* CGA_START; // Startadresse des Buldschirmspeichers
// Konstruktur mit Initialisierung der Ports
CGA () : index_port (0x3d4), data_port (0x3d5) {
CGA() : index_port(0x3d4), data_port(0x3d5) {
CGA_START = (const char*)0xb8000;
// NOTE: I added this
@ -38,39 +38,52 @@ public:
// Konstanten fuer die moeglichen Farben im Attribut-Byte.
typedef enum {
BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHT_GREY,
DARK_GREY, LIGHT_BLUE, LIGHT_GREEN, LIGHT_CYAN, LIGHT_RED,
LIGHT_MAGENTA, YELLOW, WHITE
BLACK,
BLUE,
GREEN,
CYAN,
RED,
MAGENTA,
BROWN,
LIGHT_GREY,
DARK_GREY,
LIGHT_BLUE,
LIGHT_GREEN,
LIGHT_CYAN,
LIGHT_RED,
LIGHT_MAGENTA,
YELLOW,
WHITE
} color;
// Standardzeichenfarbe
enum { STD_ATTR = BLACK << 4 | LIGHT_GREY };
// Groesse des Bildschirms (25 Zeilen, 80 Spalten)
enum { ROWS = 25, COLUMNS = 80 };
enum { ROWS = 25,
COLUMNS = 80 };
// Setzen des Cursors in Spalte x und Zeile y.
void setpos (int x, int y);
void setpos(int x, int y);
// Abfragen der Cursorpostion
void getpos (int& x, int& y);
void getpos(int& x, int& y);
// Anzeige eines Zeichens mit Attribut an einer bestimmten Stelle
void show (int x, int y, char character, unsigned char attrib = STD_ATTR);
void show(int x, int y, char character, unsigned char attrib = STD_ATTR);
// Anzeige mehrerer Zeichen ab der aktuellen Cursorposition
void print (char* string, int n, unsigned char attrib = STD_ATTR);
void print(char* string, int n, unsigned char attrib = STD_ATTR);
// Verschiebt den Bildschirminhalt um eine Zeile nach oben.
// Neue Zeile am unteren Bildrand mit Leerzeichen fuellen
void scrollup ();
void scrollup();
// Lösche den Textbildschirm
void clear ();
void clear();
// Hilfsfunktion zur Erzeugung eines Attribut-Bytes
unsigned char attribute (CGA::color bg, CGA::color fg, bool blink);
unsigned char attribute(CGA::color bg, CGA::color fg, bool blink);
};
#endif

View File

@ -15,7 +15,6 @@
#include "devices/CGA_Stream.h"
/*****************************************************************************
* Methode: CGA_Stream::flush *
*---------------------------------------------------------------------------*
@ -24,8 +23,7 @@
* sobald der Puffer voll ist, kann aber auch explizit *
* verwendet werden, um eine Ausgabe zu erzwingen. *
*****************************************************************************/
void CGA_Stream::flush () {
print (buffer, pos);
void CGA_Stream::flush() {
print(buffer, pos);
pos = 0;
}

View File

@ -21,13 +21,13 @@
class CGA_Stream : public OutStream, public CGA {
private:
CGA_Stream(CGA_Stream &copy); // Verhindere Kopieren
CGA_Stream(CGA_Stream& copy); // Verhindere Kopieren
public:
CGA_Stream () : OutStream(), CGA() { flush(); }
CGA_Stream() : OutStream(), CGA() { flush(); }
// Methode zur Ausgabe des Pufferinhalts der Basisklasse StringBuffer.
void flush () override;
void flush() override;
};
#endif

View File

@ -15,7 +15,6 @@
#include "devices/PCSPK.h"
#include "kernel/Globals.h"
/*****************************************************************************
* Methode: PCSPK::play *
*---------------------------------------------------------------------------*
@ -24,42 +23,39 @@
* Rückgabewerte: f: Frequenz des Tons *
* len: Laenge des Tons in ms *
*****************************************************************************/
void PCSPK::play (float f, int len) {
void PCSPK::play(float f, int len) {
int freq = (int)f;
int cntStart = 1193180 / freq;
int status;
// Zaehler laden
control.outb (0xB6); // Zaehler-2 konfigurieren
data2.outb (cntStart%256); // Zaehler-2 laden (Lobyte)
data2.outb (cntStart/256); // Zaehler-2 laden (Hibyte)
control.outb(0xB6); // Zaehler-2 konfigurieren
data2.outb(cntStart % 256); // Zaehler-2 laden (Lobyte)
data2.outb(cntStart / 256); // Zaehler-2 laden (Hibyte)
// Lautsprecher einschalten
status = (int)ppi.inb (); // Status-Register des PPI auslesen
ppi.outb ( status|3 ); // Lautpsrecher Einschalten
status = (int)ppi.inb(); // Status-Register des PPI auslesen
ppi.outb(status | 3); // Lautpsrecher Einschalten
// Pause
delay(len);
// Lautsprecher ausschalten
off ();
off();
}
/*****************************************************************************
* Methode: PCSPK::off *
*---------------------------------------------------------------------------*
* Beschreibung: Lautsprecher ausschalten. *
*****************************************************************************/
void PCSPK::off () {
void PCSPK::off() {
int status;
status = (int)ppi.inb (); // Status-Register des PPI auslesen
ppi.outb ( (status>>2)<<2 ); // Lautsprecher ausschalten
status = (int)ppi.inb(); // Status-Register des PPI auslesen
ppi.outb((status >> 2) << 2); // Lautsprecher ausschalten
}
/*****************************************************************************
* Methode: PCSPK::readCounter *
*---------------------------------------------------------------------------*
@ -71,13 +67,12 @@ void PCSPK::off () {
inline unsigned int PCSPK::readCounter() {
unsigned char lo, hi;
control.outb (0x0); // Latch Command
lo = data0.inb (); // Lobyte des Counters auslesen
hi = data0.inb (); // Hibyte des Counters auslesen
control.outb(0x0); // Latch Command
lo = data0.inb(); // Lobyte des Counters auslesen
hi = data0.inb(); // Hibyte des Counters auslesen
return (hi << 8) | lo;
}
/*****************************************************************************
* Methode: PCSPK::delay *
*---------------------------------------------------------------------------*
@ -85,7 +80,7 @@ inline unsigned int PCSPK::readCounter() {
* *
* Parameter: time (delay in ms) *
*****************************************************************************/
inline void PCSPK::delay (int time) {
inline void PCSPK::delay(int time) {
/* Hier muess Code eingefuegt werden */
@ -103,26 +98,23 @@ inline void PCSPK::delay (int time) {
int initial_count, current_count;
for (int i = 0; i < time; ++i) {
initial_count = readCounter();
while(1) {
while (1) {
current_count = readCounter();
if (current_count > initial_count) break; // The counter has already been reset
initial_count = current_count;
}
}
}
/*****************************************************************************
* Methode: PCSPK::tetris *
*---------------------------------------------------------------------------*
* Beschreibung: Tetris Sound, Kévin Rapaille, August 2013 *
* https://gist.github.com/XeeX/6220067 *
*****************************************************************************/
void PCSPK::tetris () {
void PCSPK::tetris() {
play(658, 125);
play(1320, 500);
play(990, 250);
@ -238,10 +230,9 @@ void PCSPK::tetris () {
play(660, 500);
play(880, 1000);
play(838, 2000);
off ();
off();
}
/*****************************************************************************
* Methode: PCSPK::tetris *
*---------------------------------------------------------------------------*
@ -881,5 +872,5 @@ void PCSPK::aerodynamic() {
play(880.0, 122);
play(1108.7, 122);
play(880.0, 122);
off ();
off();
}

View File

@ -58,7 +58,6 @@
#define B2 987.77
#define C3 1046.50
class PCSPK {
private:
@ -67,28 +66,27 @@ private:
IOport data2; // Zaehler-2 Datenregister
IOport ppi; // Status-Register des PPI
PCSPK (const PCSPK &copy); // Verhindere Kopieren
PCSPK(const PCSPK& copy); // Verhindere Kopieren
// Verzoegerung um X ms (in 1ms Schritten; Min. 1ms)
inline void delay (int time);
inline void delay(int time);
// Zaehler von PIT Channel 0 auslesen (wird fuer delay benoetigt)
inline unsigned int readCounter ();
inline unsigned int readCounter();
public:
// Konstruktor. Initialisieren der Ports.
PCSPK () : control(0x43), data0(0x40), data2(0x42), ppi(0x61) {}
PCSPK() : control(0x43), data0(0x40), data2(0x42), ppi(0x61) {}
// Demo Sounds
void tetris ();
void aerodynamic ();
void tetris();
void aerodynamic();
// Ton abspielen
void play (float f, int len);
void play(float f, int len);
// Lautsprecher ausschalten
void off ();
void off();
};
#endif

View File

@ -10,11 +10,10 @@
#ifndef __CPU_include__
#define __CPU_include__
class CPU {
private:
CPU(const CPU &copy); // Verhindere Kopieren
CPU(const CPU& copy); // Verhindere Kopieren
public:
CPU() {}
@ -22,7 +21,8 @@ public:
// Time-Stamp-Counter auslesen
inline unsigned long long int rdtsc() {
unsigned long long int ret;
asm volatile ( "rdtsc" : "=A"(ret) );
asm volatile("rdtsc"
: "=A"(ret));
return ret;
}
};

View File

@ -10,8 +10,6 @@
#include "kernel/Globals.h"
CPU cpu; // CPU-spezifische Funktionen
PCSPK pcspk; // PC-Lautsprecher
CGA_Stream kout; // Ausgabe-Strom fuer Kernel

View File

@ -10,9 +10,9 @@
#ifndef __Globals_include__
#define __Globals_include__
#include "kernel/CPU.h"
#include "devices/PCSPK.h"
#include "devices/CGA_Stream.h"
#include "devices/PCSPK.h"
#include "kernel/CPU.h"
extern CPU cpu; // CPU-spezifische Funktionen
extern PCSPK pcspk; // PC-Lautsprecher

View File

@ -16,7 +16,6 @@
#ifndef __IOport_include__
#define __IOport_include__
class IOport {
// Kopieren erlaubt!
@ -25,50 +24,56 @@ class IOport {
public:
// Konstruktor, speichert Port-Adresse
IOport (unsigned short a) : address (a) { };
IOport(unsigned short a) : address(a) {};
// Byteweise Ausgabe eines Wertes ueber einen I/O-Port.
void outb (unsigned char val) const {
asm volatile ( "outb %0, %1" : : "a"(val), "Nd"(address) );
void outb(unsigned char val) const {
asm volatile("outb %0, %1"
:
: "a"(val), "Nd"(address));
}
// Wortweise Ausgabe eines Wertes ueber einen I/O-Port.
void outw (unsigned short val) const {
asm volatile ( "outw %0, %1" : : "a"(val), "Nd"(address) );
void outw(unsigned short val) const {
asm volatile("outw %0, %1"
:
: "a"(val), "Nd"(address));
}
// 32-Bit Ausgabe eines Wertes ueber einen I/O-Port.
void outdw (unsigned int val) const {
asm volatile ( "outl %0, %1" : : "a"(val), "Nd"(address) );
void outdw(unsigned int val) const {
asm volatile("outl %0, %1"
:
: "a"(val), "Nd"(address));
}
// Byteweises Einlesen eines Wertes ueber einen I/O-Port.
unsigned char inb () const {
unsigned char inb() const {
unsigned char ret;
asm volatile ( "inb %1, %0"
asm volatile("inb %1, %0"
: "=a"(ret)
: "Nd"(address) );
: "Nd"(address));
return ret;
}
// Wortweises Einlesen eines Wertes ueber einen I/O-Port.
unsigned short inw () const {
unsigned short inw() const {
unsigned short ret;
asm volatile ( "inw %1, %0"
asm volatile("inw %1, %0"
: "=a"(ret)
: "Nd"(address) );
: "Nd"(address));
return ret;
}
// 32-Bit Einlesen eines Wertes ueber einen I/O-Port.
unsigned int indw () const {
unsigned int indw() const {
unsigned int ret;
asm volatile ( "inl %1, %0"
asm volatile("inl %1, %0"
: "=a"(ret)
: "Nd"(address) );
: "Nd"(address));
return ret;
}
};

View File

@ -11,11 +11,8 @@
* Autor: Michael Schoettner, 30.7.16 *
*****************************************************************************/
extern "C" void int_disp (unsigned int slot);
extern "C" void int_disp(unsigned int slot);
// Low-Level Interrupt-Behandlung. (Die Funktion wird spaeter noch erweitert)
void int_disp (unsigned int slot) {
void int_disp(unsigned int slot) {
}

View File

@ -23,11 +23,11 @@
#include "lib/OutStream.h"
// NOTE: I added this, stream manipulators with arg
OutStream& OutStream::operator << (const fillw& w) {
OutStream& OutStream::operator<<(const fillw& w) {
this->fill_width = w.w;
return *this;
}
OutStream& OutStream::operator << (const fillc& c) {
OutStream& OutStream::operator<<(const fillc& c) {
this->fill_char = c.c;
return *this;
}
@ -70,7 +70,7 @@ void OutStream::fill_use_char() {
//
// Zeichen und Zeichenketten in Stream ausgeben
//
OutStream& OutStream::operator << (char c) {
OutStream& OutStream::operator<<(char c) {
put(c);
if (c != '\n') {
// endl() doesn't has access to StringBuffer::put(), so ignore \n here
@ -80,14 +80,14 @@ OutStream& OutStream::operator << (char c) {
}
// TODO: shouldn't this be printed as number?
OutStream& OutStream::operator << (unsigned char c) {
return *this << (char) c;
OutStream& OutStream::operator<<(unsigned char c) {
return *this << (char)c;
}
OutStream& OutStream::operator << (char* string) {
OutStream& OutStream::operator<<(char* string) {
char* pos = string;
while (*pos) {
put (*pos);
put(*pos);
pos++;
}
this->fill_finalize(); // NOTE: I added this
@ -98,56 +98,57 @@ OutStream& OutStream::operator << (char* string) {
// Ganzer Zahlen im Zahlensystem zur Basis base in Stream ausgeveb
// Alle vorzeichenbehafteten Datentypen werden als long dargestellt,
// Alle vorzeichenlosen als unsigned long.
OutStream& OutStream::operator << (short ival) {
return *this << (long) ival;
OutStream& OutStream::operator<<(short ival) {
return *this << (long)ival;
}
OutStream& OutStream::operator << (unsigned short ival) {
return *this << (unsigned long) ival;
OutStream& OutStream::operator<<(unsigned short ival) {
return *this << (unsigned long)ival;
}
OutStream& OutStream::operator << (int ival) {
return *this << (long) ival;
OutStream& OutStream::operator<<(int ival) {
return *this << (long)ival;
}
OutStream& OutStream::operator << (unsigned int ival) {
return *this << (unsigned long) ival;
OutStream& OutStream::operator<<(unsigned int ival) {
return *this << (unsigned long)ival;
}
// Darstellung eine vorzeichenbehafteten ganzen Zahl.
OutStream& OutStream::operator << (long ival) {
OutStream& OutStream::operator<<(long ival) {
// Bei negativen Werten wird ein Minuszeichen ausgegeben.
if (ival < 0) {
put ('-');
put('-');
ival = -ival;
}
// Dann wird der Absolutwert als vorzeichenlose Zahl ausgegeben.
return *this << (unsigned long) ival;
return *this << (unsigned long)ival;
}
// Darstellung einer vorzeichenlosen ganzen Zahl.
OutStream& OutStream::operator << (unsigned long ival) {
OutStream& OutStream::operator<<(unsigned long ival) {
unsigned long div;
char digit;
if (base == 8) {
put ('0'); // oktale Zahlen erhalten eine fuehrende Null
put('0'); // oktale Zahlen erhalten eine fuehrende Null
} else if (base == 16) {
put ('0'); // hexadezimale Zahlen ein "0x"
put ('x');
put('0'); // hexadezimale Zahlen ein "0x"
put('x');
}
// Bestimmung der groessten Potenz der gewaehlten Zahlenbasis, die
// noch kleiner als die darzustellende Zahl ist.
for (div = 1; ival/div >= (unsigned long) base; div *= base);
for (div = 1; ival / div >= (unsigned long)base; div *= base)
;
// ziffernweise Ausgabe der Zahl
for (; div > 0; div /= (unsigned long) base) {
for (; div > 0; div /= (unsigned long)base) {
digit = ival / div;
if (digit < 10) {
put ('0' + digit);
put('0' + digit);
} else {
put ('a' + digit - 10);
put('a' + digit - 10);
}
ival %= div;
}
@ -156,16 +157,16 @@ OutStream& OutStream::operator << (unsigned long ival) {
}
// Darstellung eines Zeigers als hexadezimale ganze Zahl
OutStream& OutStream::operator << (void* ptr) {
OutStream& OutStream::operator<<(void* ptr) {
int oldbase = base;
base = 16;
*this << (unsigned long) ptr;
*this << (unsigned long)ptr;
base = oldbase;
return *this;
}
}
// Aufruf einer Manipulatorfunktion
OutStream& OutStream::operator << (OutStream& (*f) (OutStream&)) {
OutStream& OutStream::operator<<(OutStream& (*f)(OutStream&)) {
return f(*this);
}
@ -180,33 +181,32 @@ OutStream& OutStream::operator << (OutStream& (*f) (OutStream&)) {
// zu beeinflussen, z.B durch die Wahl des Zahlensystems.
// Fuege einen Zeilenumbruch in die Ausgabe ein.
OutStream& endl (OutStream& os) {
OutStream& endl(OutStream& os) {
os << '\n';
os.flush();
return os;
}
// Waehlt das binaere Zahlensystem aus.
OutStream& bin (OutStream& os) {
OutStream& bin(OutStream& os) {
os.base = 2;
return os;
}
// Waehlt das oktale Zahlensystem aus.
OutStream& oct (OutStream& os) {
OutStream& oct(OutStream& os) {
os.base = 8;
return os;
}
// Waehlt das dezimale Zahlensystem aus.
OutStream& dec (OutStream& os) {
OutStream& dec(OutStream& os) {
os.base = 10;
return os;
}
// Waehlt das hexadezimale Zahlensystem aus.
OutStream& hex (OutStream& os) {
OutStream& hex(OutStream& os) {
os.base = 16;
return os;
}

View File

@ -40,11 +40,10 @@ public:
char c;
};
class OutStream : public StringBuffer {
private:
OutStream(const OutStream &copy); // Verhindere Kopieren
OutStream(const OutStream& copy); // Verhindere Kopieren
// NOTE: I added this
unsigned char fill_used; // indicates how many characters are already used by the text internally
@ -58,7 +57,7 @@ public:
unsigned char fill_width;
char fill_char; // fill character for fixed width
OutStream () : StringBuffer () {
OutStream() : StringBuffer() {
base = 10; // initial Dezimalsystem
fill_width = 0; // no fixed width
fill_used = 0;
@ -74,32 +73,31 @@ public:
// Zeichenkette.
// Darstellung eines Zeichens (trivial)
OutStream& operator << (char c);
OutStream& operator << (unsigned char c);
OutStream& operator<<(char c);
OutStream& operator<<(unsigned char c);
// Darstellung einer nullterminierten Zeichenkette
OutStream& operator << (char* string);
OutStream& operator<<(char* string);
// Darstellung ganzer Zahlen im Zahlensystem zur Basis base
OutStream& operator << (short ival);
OutStream& operator << (unsigned short ival);
OutStream& operator << (int ival);
OutStream& operator << (unsigned int ival);
OutStream& operator << (long ival);
OutStream& operator << (unsigned long ival);
OutStream& operator<<(short ival);
OutStream& operator<<(unsigned short ival);
OutStream& operator<<(int ival);
OutStream& operator<<(unsigned int ival);
OutStream& operator<<(long ival);
OutStream& operator<<(unsigned long ival);
// Darstellung eines Zeigers als hexadezimale ganze Zahl
OutStream& operator << (void* ptr);
OutStream& operator<<(void* ptr);
// NOTE: I added this, set fixed output width
OutStream &operator << (const fillw &w);
OutStream &operator << (const fillc &c);
OutStream& operator<<(const fillw& w);
OutStream& operator<<(const fillc& c);
// Aufruf einer Manipulatorfunktion
OutStream& operator << (OutStream& (*f) (OutStream&));
OutStream& operator<<(OutStream& (*f)(OutStream&));
};
//
// Manipulatorfunktionen
//
@ -111,18 +109,18 @@ public:
// zu beeinflussen, z.B durch die Wahl des Zahlensystems.
// Zeilenumbruch in Ausgabe einfuegen.
OutStream& endl (OutStream& os);
OutStream& endl(OutStream& os);
// Waehle binaeres Zahlensystem aus.
OutStream& bin (OutStream& os);
OutStream& bin(OutStream& os);
// Waehle oktales Zahlensystem aus.
OutStream& oct (OutStream& os);
OutStream& oct(OutStream& os);
// Waehle dezimales Zahlensystem aus.
OutStream& dec (OutStream& os);
OutStream& dec(OutStream& os);
// Waehle hexadezimales Zahlensystem aus.
OutStream& hex (OutStream& os);
OutStream& hex(OutStream& os);
#endif

View File

@ -18,7 +18,6 @@
#include "lib/StringBuffer.h"
/*****************************************************************************
* Methode: StringBuffer::put *
*---------------------------------------------------------------------------*
@ -29,10 +28,9 @@
* Parameter: *
* c: Einzufuegendes Zeichen. *
*****************************************************************************/
void StringBuffer::put (char c) {
void StringBuffer::put(char c) {
buffer[pos] = c;
pos++;
if (pos == sizeof (buffer))
flush ();
}
if (pos == sizeof(buffer))
flush();
}

View File

@ -21,7 +21,7 @@
class StringBuffer {
private:
StringBuffer(const StringBuffer &copy); // Verhindere Kopieren
StringBuffer(const StringBuffer& copy); // Verhindere Kopieren
// Alle Variablen und Methoden dieser Klasse sind "protected",
// da die abgeleiteten Klassen einen direkten Zugriff auf den
@ -34,15 +34,14 @@ protected:
int pos;
// StringBuffer: Im Konstruktor wird der Puffer als leer markiert.
StringBuffer () : pos(0) {}
StringBuffer() : pos(0) {}
// NOTE: I changed this
// Fuegt ein Zeichen in den Puffer ein. Wenn der Puffer
virtual void put (char c);
virtual void put(char c);
// Methode zur Ausgabe des Pufferinhalts
virtual void flush () = 0;
virtual void flush() = 0;
};
#endif

View File

@ -11,9 +11,8 @@
*****************************************************************************/
#include "kernel/Globals.h"
#include "user/TextDemo.h"
#include "user/SoundDemo.h"
#include "user/TextDemo.h"
int main() {
/* Hier muess Code eingefuegt werden */
@ -23,10 +22,10 @@ int main() {
// TODO: Startmeldung ausgeben
text_demo();
// sound_demo();
while (1);
while (1)
;
return 0;
}
}

View File

@ -15,5 +15,4 @@ void sound_demo() {
/* Hier muess Code eingefuegt werden */
pcspk.tetris();
// pcspk.play(440, 1000);
}

View File

@ -10,11 +10,11 @@
#include "kernel/Globals.h"
void text_demo() {
/* Hier muess Code eingefuegt werden */
kout << "Test der Zahlenausgabefunktion:" << endl << endl;
kout << "Test der Zahlenausgabefunktion:" << endl;
kout << endl;
kout << "| dec | hex | bin |" << endl;
kout << "+-------+-------+-------+" << endl;