On Fri, 30 Jul 2004, Luchezar Georgiev wrote:
void delay(unsigned milliseconds) /* 1 - 1985 */
{
unsigned i;
for (i = 0; i <= milliseconds * 33; i++)
{
while (inp(0x61 & 0x10) /* refresh bit toggles with each refresh */
; /* so we wait 30 µs but the first time */
while (inp(0x61 & 0x10)
;
}
}
Award BIOS uses this principle all the time, and most computers have exactly such a BIOS ;-)
"most" huh?
What about:
+ DOSemu,
+ WinNT DOSboxes,
+ weired IBM PCs,
+ Nokia (I don't remember the correct model ID that is running a derivate of DOS),
+ embedded systems, ...
The current idea to overcome the beep problem is this:
Have an extended ALIAS and BEEP functionality with:
ALIAS :BEEP_INFO=BEEP <<some values>> ALIAS :BEEP_ATTENTION=BEEP <<some values>> ALIAS :BEEP=BEEP <<values>>
BEEP [ {frequency duration} ] style #1: No argument: putchar('\a') style #2: foreach my ($frequency, $duration) { sound($frequency); delay($duration); } nosound();
And the file completion beep would be similiar to: if isalias :beep_info :beep_info else if isalias :beep :beep else BEEP
[[So, if the user does not do nothing, the BIOS acts on '\a']]
For delay() itself, there had been the suggestion to use *(unsigned far *)MK_FP(0x40,0x6c).
"inp()" and 0x40:0x6c are both CPU-heavy; isn't there some nicier method???
There was also the suggestion to hook INT-1C.
Actually, I wonder, I dimmly remember some DELAY BIOS API, but couldn't find it right now.
Bye,
--
Steffen Kaiser