[comp.sys.mac.programmer] Vertical Retrace Queue Problem

newton@mtund.ATT.COM (Newton Lee) (06/02/88)

I've written a program that "VInstall" a function onto the vertical
retrace queue. The function does simple "PlotIcon". It works. Now
disabling VInstall, the main program calls "MacinTalk". It also works.
However, enabling VInstall, the whole thing suddenly stops working!
Why? I know there is a sound manager VBL problem in old System files.
But I'm using System File 4.2 that supposedly has fixed that problem.

Thanks for your help.

Newton Lee, ihnp4!mtund!newton, 201-576-3541

lazarus@athena.mit.edu (Michael Friedman) (06/09/88)

In article <953@mtund.ATT.COM> newton@mtund.ATT.COM (Newton Lee) writes:


>I've written a program that "VInstall" a function onto the vertical
>retrace queue. The function does simple "PlotIcon". It works. Now
>disabling VInstall, the main program calls "MacinTalk". It also works.
>However, enabling VInstall, the whole thing suddenly stops working!
>Why? I know there is a sound manager VBL problem in old System files.
>But I'm using System File 4.2 that supposedly has fixed that problem.

I've also got a problem with the Vertical Retrace Interrupt Queue.
I've included Mr. Lee's posting in case they are related.

I've written a program that installs a short program into the vertical
retrace queue.

The installed program is about ten lines long. It reads a value from a
board, nots it, writes it to another location on the board, updates
the counter in its queue entry, and leaves.

This is a SHORT program. It only uses A0 and D0.

Both programs were written with LightSpeed C. The installation program
contains liberal amounts of assembly. The program I install is totally
inline assembly.

The queue entry is allocated with NewPtr from the system heap. I have
tried using ResEdit to place my installed program in both the system
and the application heap. (One at a time, of course.)

The program works beautifully. When I hook up an oscilloscope I can
see the expected 30 herz square wave.

The problem comes when I run it on a MAC II and move windows around.
To make it show easily I run it with the stdio library and use a gets
at the end.

If I move the stdio window it crashes about three quarters of the
time. Sometimes you can move it once. Then it crashes the second time.

As far as I can tell, it always crashes if you use the control panel
to change to colors.

I also managed to crash it once by changing the time of the alarm of
the alarm clock.

If you don't touch it it runs for hours without a problem.

I'm using TMON to debug. I always end up in trap AB05. I assume that
this is the result of a jump rather than an actual trap call because
TMON can't catch it.

I have not been able to make it crash while stepping through using
TMON.

If TMON leaves the VBL Queue running then the square wave continues to
be output while it runs. If it stops the VBL Queue but I reboot from
TMON then the square wave comes back for a few seconds while TMON
exits.

My code is not being trashed. Somehow it is trashing other code.

This afternoon I ran a clock program that installs itself in the
interrupt queue. Then I used TMON to replace it with my code. It
worked and would not crash. I have no idea why.

This problem can not be duplicated on a Macintosh SE.

Does anyone have any suggestions whatsoever?

If I get no help then I will take some installation code that does
work and slowly modify it until it installs my code. Hopefully this
will work.

Even if it does I won't be too happy - this code is going to go in a
real program that will be sold for a lot of money. We don't want a bug
to pop up out of the woodwork.

HELP!!!






How can a man die better     | Than facing fearful odds     |||Mike Friedman
For the ashes of his fathers | And the temples of his gods? |||Quoting Macaulay

newton@mtund.ATT.COM (Newton Lee) (06/11/88)

The problem to my vertical retrace queue program was caused by
the improper setup of the A5 register. SetUpA5() and RestoreA5()
were used to fix that problem. (ref: Chapter 13, Inside Mac Vol. II)

- Newton Lee, AT&T Advanced WorkGroup Systems