Amiga-C (35/157)

From:Gunther Nikl
Date:10 Sep 2001 at 10:04:22
Subject:[amiga-c] Re: VB int problem (was Re: Help needed with random crashing problem)

On Sun, Sep 09, 2001 at 12:55:06PM +0100, Paul Qureshi wrote:
> The latest code is:

It would have been helpful to know which type your variables have.

> int __interrupt __saveds MPCV(VOID)
> {
> db++;
> if (db > prefs.volspd)
> db = 0;
>
> if (db == 0)
> {
> db++;
> // no pot so max out volume
> // mojo = cust->pot1dat >> 8;
> mojo=180;
> tempvol = mojo * 0.8;

This looks like floating point math. This is a bad idea to use in an
interrupt.

> if (tempvol > 100)
> tempvol = 100;
> if ( abs(tempvol - intvolume) > prefs.volacc || (tempvol == 100 && intvolume != 100) )
> {
> intvolume = tempvol;
> Signal(mytask, intsigmask);
> }
> }
> else
> {
> cust->potgo = 1;
> }
> return(0);
> }

Looks ok.

> Oh, and is there any way I can make sure that the 1 written to potgo is
> a byte write?

Hm? If potgo is a pointer to a char then it will write a byte if its
a pointer to a word then it will write a word.

> > Basically keep the routine small and tight and don't do anything
> > fancy. Plus VERTB servers should return with the Z condition code set
> > (this is mentioned in the AddIntServer() autodoc).
>
> Is there any reliable way to do this from C?

Yes, keep the work in the code as small as possible. You should do only
the really necessary work in the interrupt. What is necessary depends
on you.
Furthermore, you should pass a pointer to a structure with all data your
function needs (don't forget SysBase!) to avoid accessing global data.
Then you could get rid of __saveds.

BTW, you shouldn't use the VERTB interrupt in the first place. Did you
consider using a PA_SOFTINT port together with the timer.device? This
will give you constant timing on every amiga.

Gunther

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Secure your servers with 128-bit SSL encryption! Grab your copy of VeriSign's FREE Guide: "Securing Your Web Site for Business." Get it Now!
http://us.click.yahoo.com/n7RbFC/zhwCAA/yigFAA/dpFolB/TM
---------------------------------------------------------------------~->

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/