[comp.sys.amiga] Beep Bug Fix For Dave Wecker's VT100 Program

carl@umd5 (Carl Symborski) (12/13/86)

/*

Well all this talk about bugs in Dave Wecker's VT100 program which don't
happen under MANX and do happen under LATTICE has got me started.  Darnit
why dosn't the beep thing work when VT100 is compiled under LATTICE!
I just had to look.  Sure enough I found it.... I'll list the bug (?) fix
first, compiler flames later....

Fix to Dave's VT100 program to allow audible beep is a modification to the
include file VT100.H  Edit this file and search for a line which looks like:

         extern UBYTE Audio_AllocMap[];

change this to:

         extern UBYTE Audio_AllocMap[4];

Recompile the file INIT.C and relink.  End of fix!

Now the real sweat is why does this fix work?  I mean why does LATTICE need
this and MANX dosn't.  Well looking at the code, we have in VT100.H something
of the form:

$ifdef MODULE_MAIN
    .
    .
UBYTE Audio_AllocMap[4] = {1, 8, 2, 4};
    .
    .
$else
    .
    .
extern UBYTE Audio_AllocMap[];
    .
    .

OK so far.  The problem is in file INIT.C where the I/O request block is
initialized prior to opening the audio device.  The address and length of
Audio_AllocMap is passed to the audio device in the I/O block.  The code is
using the "sizeof()" compile-time unary operator.  The symbol "MODULE_MAIN"
is not defined in INIT.C so when you compile under LATTICE, (read C compiler),
the "else" part in VT100.H is looked at and understood.  So then; all that 
INIT.C should know about the symbol "Audio_AllocMap" is that it is an
external array of type UBYTE.  We DON'T know how long it is, so when we say
"sizeof(Audio_AllocMap)" we should expect zero maby one... but not four!!!!

Honestly folks, I just don't know how this works under MANX!  It can only
be that the MANX compiler is cheeting a bit by peeking into the "then"
part of the conditional compile in VT100.H.  To me this is really scary.
It's like the old "do what i mean, not what i say" compiler option we all
dreamed of back in school.  I would go on but heck, I stopped watching MANX
and Hawaii Five-0 a long time ago.

            - Carl


 

acs@amdahl.UUCP (Tony Sumrall) (12/17/86)

In article <1391@umd5> carl@umd5.umd.edu.UUCP (Carl Symborski) writes:

> Now the real sweat is why does this fix work?  I mean why does LATTICE need
> this and MANX dosn't.

The problem is that DBW's makefile creates a pre-compiled header file via
+H when he compiles vt100.c.  When the header file is created, MODULE_MAIN
*is* defined so a cc +Iwhatever init.c will cause MODULE_MAIN *and*
MODULE_INIT to be defined.  This will cause sizeof(Audio_AllocMap) to
yield a 4 instead of a zero.  If Manx folks had compiled without +H/+I
they would've seen the problem too.
-- 
Tony Sumrall                    ...!{ihnp4,hplabs,seismo,sun}!amdahl!acs

[ Opinions expressed herein are the author's and should not be construed
  to reflect the views of Amdahl Corp. ]