[comp.sys.amiga.tech] double buffering via interrupts

collins@pnet02.cts.com (Steven Collins) (08/29/88)

Is it cool to put some blank lines up here for some reason??


I am trying to set up a double buffered screen that uses a 
vertical interrupt handler to do the flip. It works fine until
I try to depth arrange or slide the screen down, then I get a bomb
that looks like:

                         00000003.00c04fd0   or
                         00000004.00c04fd0     (always at this address...)

Here's what I try to do:

         Open a hi res custom screen
         find the view with ViewAddress()
         find the rastport for the screen
         allocate a second bitmap 
         create a rastport for the second bitmap

      then I insert a Vertical blanking interval interrupt server
      in the server chain at a priority of 1. This server
      switches the bitmaps like this:

    Scrn->ViewPort.RasInfo->BitMap=   (one of the bitmap pointers)
    MakeScreen(Scrn)
    MrgCop(view)
    LoadView(view)

This whole think works... until I try to move the screen or depth arrange.
do I need to find the view using ViewAddress within the server?
(It doesn't seem to matter...)
Is this a reasonable way to do this sort of thing? How come I always
bomb to the exact same address? Should I go back to my C64?

One last clue: if I set up the server to only do the buffer fliping
every 10 V-blanks or so, I can slide the screen down as long as I don't
go too fast, and depth arranging seems to work (at least most of the time...)

What is happening when I'm moving the screen anyway?


                  thanks in advance...       steve collins

   Don't be shy... Roast me alive...


UUCP: {ames!elroy, <backbone>}!gryphon!pnet02!collins
INET: collins@pnet02.cts.com

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (08/30/88)

In article <6015@gryphon.CTS.COM> collins@pnet02.cts.com (Steven Collins) writes:
>I am trying to set up a double buffered screen that uses a 
>vertical interrupt handler to do the flip. It works fine until
>I try to depth arrange or slide the screen down [ ... ]

	Depth arranging or dragging screens while double buffering is
problematic at best, because of the overhead in using screens.  If you want
inexpensive double buffering, you really should be using ViewPorts and Views
directly.

>This server switches the bitmaps like this:
>    Scrn->ViewPort.RasInfo->BitMap=   (one of the bitmap pointers)
>    MakeScreen(Scrn)
>    MrgCop(view)
>    LoadView(view)
>
	OOOP!  ACK!!  PFBBTPHBFPHBFHTBTTT!!!

	When you call MrgCop(), you are effectively invoking an assembler
for the copper, which assembles a new list of instructions for the copper to
control the display with.  This is a *very* expensive operation, and really
has no business being inside an interrupt server.  The most you can do is to
use LoadView() in your server.

	If I were you, I wouldn't be doing this in an interrupt server at
all; at worst, I'd signal a task from the interrupt to do it.  However, I'd
look for other methods to flip buffers around.  ScrollVPort() is useful for
this, if you must run on an Intuition screen.  An example of this can be
found in one of my *real* old hacks called "Ing."

	Unfortunately, all current methods of page-flipping within
Intuition's constraints are terribly expensive computationally, so you may
wish to explore Views and ViewPorts.

>Should I go back to my C64?
>
	Nah.  You'll get used to the new stuff.

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	INET: well!ewhac@ucbvax.Berkeley.EDU
 \_ -_		Recumbent Bikes:	UUCP: pacbell > !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

haitex@pnet01.cts.com (Wade Bickel) (09/02/88)

        LoadView() works fine inside an interrupt server.  Howerever I think
it is considered unsafe to do so because, while processing the interrupt, the
68000 is in Supervisor mode, and calls to the graphics library are supposed
to be made from the User mode.

        I also believe that LoadView() takes effect durring the VBlank, as
one of the servers on the chain (empirical evidence only).  Thus if your
server sits behind the LoadView() server then the swap will not actually
take effect until the next VBlank.

        As Leo pointed out, you should probably send a message, and have
a software interrupt (soft interrupts are in User mode) handler do the
LoadView().  However, soft interrupts are much slower than hardware
interrupts (if my tests were not flawed in some way), so it's up to you
which way to do it.


                                                Good Luck,


                                                        Wade.

PS:  I hope this information is valid, but please experiment to confirm this.
   Much of my picture of what is going on is built upon the results of 
   repeated attemts to achieve a goal.  Through these attempts I gain
   information, but rarely have time to confirm it rigorously.  So please
   take all this with a grain of salt.  -W.

UUCP: {cbosgd, hplabs!hp-sdd, sdcsvax, nosc}!crash!pnet01!haitex
ARPA: crash!pnet01!haitex@nosc.mil
INET: haitex@pnet01.CTS.COM
Opionions expressed are mine, and not necessarily those of my employer.