Vorgabe01 Aufgabe01
This commit is contained in:
121
devices/CGA.cc
Executable file
121
devices/CGA.cc
Executable file
@ -0,0 +1,121 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C G A *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Mit Hilfe dieser Klasse kann man auf den Bildschirm des *
|
||||
* PCs zugreifen. Der Zugriff erfolgt direkt auf der Hard- *
|
||||
* wareebene, d.h. ueber den Bildschirmspeicher und den *
|
||||
* I/O-Ports der Grafikkarte. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 21.8.2016 *
|
||||
*****************************************************************************/
|
||||
#include "devices/CGA.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::setpos *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Setzen des Cursors in Spalte x und Zeile y. *
|
||||
*****************************************************************************/
|
||||
void CGA::setpos (int x, int y) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::getpos *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Abfragem der Cursorposition *
|
||||
* *
|
||||
* Rückgabewerte: x und y *
|
||||
*****************************************************************************/
|
||||
void CGA::getpos (int &x, int &y) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::show *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Anzeige eines Zeichens mit Attribut an einer bestimmten *
|
||||
* Stelle auf dem Bildschirm. *
|
||||
* *
|
||||
* Parameter: *
|
||||
* x,y Position des Zeichens *
|
||||
* character Das auszugebende Zeichen *
|
||||
* attrib Attributbyte fuer das Zeichen *
|
||||
*****************************************************************************/
|
||||
void CGA::show (int x, int y, char character, unsigned char attrib) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::print *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Anzeige mehrerer Zeichen ab der aktuellen Cursorposition *
|
||||
* '\n' fuer Zeilenvorschub. *
|
||||
* *
|
||||
* Parameter: *
|
||||
* string Auszugebende Zeichenkette *
|
||||
* n Laenger der Zeichenkette *
|
||||
* attrib Attributbyte fuer alle Zeichen der Zeichenkette *
|
||||
*****************************************************************************/
|
||||
void CGA::print (char* string, int n, unsigned char attrib) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::scrollup *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Verschiebt den Bildschirminhalt um eine Zeile nach oben. *
|
||||
* Die neue Zeile am unteren Bildrand wird mit Leerzeichen *
|
||||
* gefuellt. *
|
||||
*****************************************************************************/
|
||||
void CGA::scrollup () {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::clear *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Lösche den Textbildschirm. *
|
||||
*****************************************************************************/
|
||||
void CGA::clear () {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::attribute *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Hilfsfunktion zur Erzeugung eines Attribut-Bytes aus *
|
||||
* Hintergrund- und Vordergrundfarbe und der Angabe, ob das *
|
||||
* Zeichen blinkend darzustellen ist. *
|
||||
* *
|
||||
* Parameter: *
|
||||
* bg Background color *
|
||||
* fg Foreground color *
|
||||
* blink ywa/no *
|
||||
*****************************************************************************/
|
||||
unsigned char CGA::attribute (CGA::color bg, CGA::color fg, bool blink) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
73
devices/CGA.h
Executable file
73
devices/CGA.h
Executable file
@ -0,0 +1,73 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C G A *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Mit Hilfe dieser Klasse kann man auf den Bildschirm des *
|
||||
* PCs zugreifen. Der Zugriff erfolgt direkt auf der Hard- *
|
||||
* wareebene, d.h. ueber den Bildschirmspeicher und den *
|
||||
* I/O-Ports der Grafikkarte. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 21.8.2016 *
|
||||
*****************************************************************************/
|
||||
#ifndef __CGA_include__
|
||||
#define __CGA_include__
|
||||
|
||||
#include "kernel/IOport.h"
|
||||
|
||||
class CGA {
|
||||
|
||||
private:
|
||||
IOport index_port; // Auswahl eines Register der Grafikkarte
|
||||
IOport data_port; // Lese-/Schreib-Zugriff auf Register der Grafikk.
|
||||
|
||||
// Copy Konstrutkor unterbinden
|
||||
CGA(const CGA ©);
|
||||
|
||||
public:
|
||||
const char *CGA_START; // Startadresse des Buldschirmspeichers
|
||||
|
||||
// Konstruktur mit Initialisierung der Ports
|
||||
CGA () : index_port (0x3d4), data_port (0x3d5) {
|
||||
CGA_START = (const char*)0xb8000;
|
||||
}
|
||||
|
||||
// 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
|
||||
} color;
|
||||
|
||||
// Standardzeichenfarbe
|
||||
enum { STD_ATTR = BLACK << 4 | LIGHT_GREY };
|
||||
|
||||
// Groesse des Bildschirms (25 Zeilen, 80 Spalten)
|
||||
enum { ROWS = 25, COLUMNS = 80 };
|
||||
|
||||
// Setzen des Cursors in Spalte x und Zeile y.
|
||||
void setpos (int x, int y);
|
||||
|
||||
// Abfragen der Cursorpostion
|
||||
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);
|
||||
|
||||
// Anzeige mehrerer Zeichen ab der aktuellen Cursorposition
|
||||
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 ();
|
||||
|
||||
// Lösche den Textbildschirm
|
||||
void clear ();
|
||||
|
||||
// Hilfsfunktion zur Erzeugung eines Attribut-Bytes
|
||||
unsigned char attribute (CGA::color bg, CGA::color fg, bool blink);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
31
devices/CGA_Stream.cc
Executable file
31
devices/CGA_Stream.cc
Executable file
@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C G A _ S T R E A M *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Die Klasse CGA_Stream ermoeglicht die Ausgabe verschied. *
|
||||
* Datentypen als Zeichenketten auf dem CGA-Bildschirm eines*
|
||||
* PCs. Fuer weitergehende Formatierung oder spezielle *
|
||||
* Effekte stehen die Methoden der Klasse CGA_Stream zur *
|
||||
* Verfuegung. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 1.8.16 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "devices/CGA_Stream.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA_Stream::flush *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Methode zur Ausgabe des Pufferinhalts der Basisklasse *
|
||||
* StringBuffer. Die Methode wird implizit aufgerufen, *
|
||||
* sobald der Puffer voll ist, kann aber auch explizit *
|
||||
* verwendet werden, um eine Ausgabe zu erzwingen. *
|
||||
*****************************************************************************/
|
||||
void CGA_Stream::flush () {
|
||||
print (buffer, pos);
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
33
devices/CGA_Stream.h
Executable file
33
devices/CGA_Stream.h
Executable file
@ -0,0 +1,33 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C G A _ S T R E A M *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Die Klasse CGA_Stream ermoeglicht die Ausgabe verschied. *
|
||||
* Datentypen als Zeichenketten auf dem CGA-Bildschirm eines*
|
||||
* PCs. Fuer weitergehende Formatierung oder spezielle *
|
||||
* Effekte stehen die Methoden der Klasse CGA zur *
|
||||
* Verfuegung. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 06.04.20 *
|
||||
*****************************************************************************/
|
||||
#ifndef __CGA_Stream_include__
|
||||
#define __CGA_Stream_include__
|
||||
|
||||
#include "devices/CGA.h"
|
||||
#include "lib/OutStream.h"
|
||||
|
||||
class CGA_Stream : public OutStream, public CGA {
|
||||
|
||||
private:
|
||||
CGA_Stream(CGA_Stream ©); // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
CGA_Stream () : OutStream(), CGA () { flush(); }
|
||||
|
||||
// Methode zur Ausgabe des Pufferinhalts der Basisklasse StringBuffer.
|
||||
virtual void flush ();
|
||||
};
|
||||
|
||||
#endif
|
||||
861
devices/PCSPK.cc
Executable file
861
devices/PCSPK.cc
Executable file
@ -0,0 +1,861 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* P C S P K *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Mit Hilfe dieser Klasse kann man Toene auf dem *
|
||||
* PC-Lautsprecher ausgeben. *
|
||||
* *
|
||||
* Achtung: Qemu muss mit dem Parameter -soundhw pcspk aufgerufen *
|
||||
* werden. Ansonsten kann man nichts hoeren. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 22.9.2016 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "devices/PCSPK.h"
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::play *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Ton abspielen. *
|
||||
* *
|
||||
* Rückgabewerte: f: Frequenz des Tons *
|
||||
* len: Laenge des Tons in ms *
|
||||
*****************************************************************************/
|
||||
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)
|
||||
|
||||
// Lautsprecher einschalten
|
||||
status = (int)ppi.inb (); // Status-Register des PPI auslesen
|
||||
ppi.outb ( status|3 ); // Lautpsrecher Einschalten
|
||||
|
||||
// Pause
|
||||
delay(len);
|
||||
|
||||
// Lautsprecher ausschalten
|
||||
off ();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::off *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Lautsprecher ausschalten. *
|
||||
*****************************************************************************/
|
||||
void PCSPK::off () {
|
||||
int status;
|
||||
|
||||
status = (int)ppi.inb (); // Status-Register des PPI auslesen
|
||||
ppi.outb ( (status>>2)<<2 ); // Lautsprecher ausschalten
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::readCounter *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Zaehler von PIT Channel 0 auslesen. *
|
||||
* (wird fuer delay benoetigt). *
|
||||
* *
|
||||
* Rückgabewerte: counter *
|
||||
*****************************************************************************/
|
||||
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
|
||||
return (hi << 8) | lo;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::delay *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Verzoegerung um X ms (in 1ms Schritten; Min. 1ms). *
|
||||
* *
|
||||
* Parameter: time (delay in ms) *
|
||||
*****************************************************************************/
|
||||
inline void PCSPK::delay (int time) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::tetris *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Tetris Sound, Kévin Rapaille, August 2013 *
|
||||
* https://gist.github.com/XeeX/6220067 *
|
||||
*****************************************************************************/
|
||||
void PCSPK::tetris () {
|
||||
play(658, 125);
|
||||
play(1320, 500);
|
||||
play(990, 250);
|
||||
play(1056, 250);
|
||||
play(1188, 250);
|
||||
play(1320, 125);
|
||||
play(1188, 125);
|
||||
play(1056, 250);
|
||||
play(990, 250);
|
||||
play(880, 500);
|
||||
play(880, 250);
|
||||
play(1056, 250);
|
||||
play(1320, 500);
|
||||
play(1188, 250);
|
||||
play(1056, 250);
|
||||
play(990, 750);
|
||||
play(1056, 250);
|
||||
play(1188, 500);
|
||||
play(1320, 500);
|
||||
play(1056, 500);
|
||||
play(880, 500);
|
||||
play(880, 500);
|
||||
delay(250);
|
||||
play(1188, 500);
|
||||
play(1408, 250);
|
||||
play(1760, 500);
|
||||
play(1584, 250);
|
||||
play(1408, 250);
|
||||
play(1320, 750);
|
||||
play(1056, 250);
|
||||
play(1320, 500);
|
||||
play(1188, 250);
|
||||
play(1056, 250);
|
||||
play(990, 500);
|
||||
play(990, 250);
|
||||
play(1056, 250);
|
||||
play(1188, 500);
|
||||
play(1320, 500);
|
||||
play(1056, 500);
|
||||
play(880, 500);
|
||||
play(880, 500);
|
||||
delay(500);
|
||||
play(1320, 500);
|
||||
play(990, 250);
|
||||
play(1056, 250);
|
||||
play(1188, 250);
|
||||
play(1320, 125);
|
||||
play(1188, 125);
|
||||
play(1056, 250);
|
||||
play(990, 250);
|
||||
play(880, 500);
|
||||
play(880, 250);
|
||||
play(1056, 250);
|
||||
play(1320, 500);
|
||||
play(1188, 250);
|
||||
play(1056, 250);
|
||||
play(990, 750);
|
||||
play(1056, 250);
|
||||
play(1188, 500);
|
||||
play(1320, 500);
|
||||
play(1056, 500);
|
||||
play(880, 500);
|
||||
play(880, 500);
|
||||
delay(250);
|
||||
play(1188, 500);
|
||||
play(1408, 250);
|
||||
play(1760, 500);
|
||||
play(1584, 250);
|
||||
play(1408, 250);
|
||||
play(1320, 750);
|
||||
play(1056, 250);
|
||||
play(1320, 500);
|
||||
play(1188, 250);
|
||||
play(1056, 250);
|
||||
play(990, 500);
|
||||
play(990, 250);
|
||||
play(1056, 250);
|
||||
play(1188, 500);
|
||||
play(1320, 500);
|
||||
play(1056, 500);
|
||||
play(880, 500);
|
||||
play(880, 500);
|
||||
delay(500);
|
||||
play(660, 1000);
|
||||
play(528, 1000);
|
||||
play(594, 1000);
|
||||
play(495, 1000);
|
||||
play(528, 1000);
|
||||
play(440, 1000);
|
||||
play(419, 1000);
|
||||
play(495, 1000);
|
||||
play(660, 1000);
|
||||
play(528, 1000);
|
||||
play(594, 1000);
|
||||
play(495, 1000);
|
||||
play(528, 500);
|
||||
play(660, 500);
|
||||
play(880, 1000);
|
||||
play(838, 2000);
|
||||
play(660, 1000);
|
||||
play(528, 1000);
|
||||
play(594, 1000);
|
||||
play(495, 1000);
|
||||
play(528, 1000);
|
||||
play(440, 1000);
|
||||
play(419, 1000);
|
||||
play(495, 1000);
|
||||
play(660, 1000);
|
||||
play(528, 1000);
|
||||
play(594, 1000);
|
||||
play(495, 1000);
|
||||
play(528, 500);
|
||||
play(660, 500);
|
||||
play(880, 1000);
|
||||
play(838, 2000);
|
||||
off ();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::tetris *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Clint, Part of Daft Punk’s Aerodynamic *
|
||||
* https://www.kirrus.co.uk/2010/09/linux-beep-music/ *
|
||||
*****************************************************************************/
|
||||
void PCSPK::aerodynamic() {
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
off ();
|
||||
}
|
||||
94
devices/PCSPK.h
Executable file
94
devices/PCSPK.h
Executable file
@ -0,0 +1,94 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* P C S P K *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Mit Hilfe dieser Klasse kann man Toene auf dem *
|
||||
* PC-Lautsprecher ausgeben. *
|
||||
* *
|
||||
* Achtung: Qemu muss mit dem Parameter -soundhw pcspk aufgerufen *
|
||||
* werden. Ansonsten kann man nichts hoeren. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 22.9.2016 *
|
||||
*****************************************************************************/
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
|
||||
class PCSPK {
|
||||
|
||||
private:
|
||||
IOport control; // Steuerregister (write only)
|
||||
IOport data0; // Zaehler-0 Datenregister (read/write)
|
||||
IOport data2; // Zaehler-2 Datenregister
|
||||
IOport ppi; // Status-Register des PPI
|
||||
|
||||
PCSPK (const PCSPK ©); // Verhindere Kopieren
|
||||
|
||||
// Verzoegerung um X ms (in 1ms Schritten; Min. 1ms)
|
||||
inline void delay (int time);
|
||||
|
||||
// Zaehler von PIT Channel 0 auslesen (wird fuer delay benoetigt)
|
||||
inline unsigned int readCounter ();
|
||||
|
||||
public:
|
||||
|
||||
// Konstruktor. Initialisieren der Ports.
|
||||
PCSPK () : control(0x43), data0(0x40), data2(0x42), ppi(0x61) {}
|
||||
|
||||
// Demo Sounds
|
||||
void tetris ();
|
||||
void aerodynamic ();
|
||||
|
||||
// Ton abspielen
|
||||
void play (float f, int len);
|
||||
|
||||
// Lautsprecher ausschalten
|
||||
void off ();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user