00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <dos.h>
00037
00038 #include <callback.h>
00039 #include <mytrace.h>
00040 #include <timeout.h>
00041
00042 #include "lptnote.h"
00043
00044
00045
00046 namespace Ut = Monitor::Utility;
00047
00048
00049
00050 int LptNote::busy = 0;
00051
00052
00053 LptNote::LptNote(int newPortNumber, int newPortBit)
00054 {
00055 _USEMYTRACE_("LptNote::LptNote(newPortNumber, newPortBit)")
00056
00057
00058 unsigned int *lptPortTable((unsigned int*)0x408);
00059
00060 lptPort = *(lptPortTable + (--newPortNumber));
00061
00062 originalControlPort = inportb(lptPort + 0x002);
00063 originalExtendedControlPort = inportb(lptPort + 0x402);
00064
00065
00066 outportb(lptPort, 0);
00067
00068
00069 if (0x3BC != lptPort)
00070 {
00071 outportb((lptPort + 0x402), 0);
00072 }
00073 outportb((lptPort + 0x002), 0);
00074
00075
00076 bitOn = 1 << newPortBit;
00077 bitOff = ~bitOn;
00078 }
00079
00080
00081
00082 LptNote::~LptNote()
00083 {
00084 _USEMYTRACE_("LptNote::~LptNote()")
00085
00086 outportb(lptPort, 0);
00087
00088
00089 outportb((lptPort + 0x002), originalControlPort);
00090 if (0x3BC != lptPort)
00091 {
00092 outportb((lptPort + 0x402), originalExtendedControlPort);
00093 }
00094 }
00095
00096
00097
00098 void
00099 LptNote::sound() const
00100 throw (Ut::Note::Busy)
00101 {
00102 _USEMYTRACE_("LptNote::sound()")
00103
00104 if (busy)
00105 {
00106 throw Ut::Note::Busy();
00107 }
00108 else
00109 {
00110 busy = !0;
00111
00112
00113 outportb(lptPort, (bitOn | inportb(lptPort)));
00114
00115
00116 new Ut::Timeout(Ut::ConstCallback< LptNote >(*this,
00117 &LptNote::switchOff),
00118 1,
00119 "energisation time");
00120 }
00121 }
00122
00123
00124
00125 void
00126 LptNote::switchOff() const
00127 {
00128 _USEMYTRACE_("LptNote::switchOff()")
00129
00130
00131 outportb(lptPort, (bitOff & inportb(lptPort)));
00132
00133 busy = 0;
00134 }