Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!usc!apple!well!shf
From: shf@well.UUCP (Stuart H. Ferguson)
Newsgroups: comp.sys.amiga
Subject: Re: Help for a games programmer
Message-ID: <13155@well.UUCP>
Date: 16 Aug 89 07:23:49 GMT
References: <2267@jhunix.HCF.JHU.EDU>
Reply-To: shf@well.UUCP (Stuart H. Ferguson)
Organization: The Blue Planet
Lines: 37

+-- ins_adjb@jhunix.HCF.JHU.EDU (Daniel Jay Barrett) writes:
| arcade-type game like Lode Runner, and it takes input from the keyboard
| and the joystick.
| 	The problem?  It busy-waits.   [ ... ]
| 	Could someone please send me a code fragment how to do this in
| a multitasking-friendly way?  I know how to write Amiga programs that
| don't busy-wait, but I have never done it in a program that has a continuous
| animation running.  

Seems to me that if the program is actually doing something -- like
displaying some animation -- then it is not "busy-waiting," it's 
"busy-working." :-)  Busy-waiting refers to programs that have an input
loop like:
		forever {
			Check for user input.
			if something happened, respond.
		}

Such a program will burn CPU cycles just sitting doing nothing.  The correct
way to do this on the Amiga (just to make this an educational posting ;-)
is to have an input loop like this:

		forever {
			Check for user input.
			if something happened, respond,
			otherwise Wait() for some user input.
		}

A way to make the game multi-tasking friendly is to have a pause mode that
can be explicitly envoked.  This would cause the animation to stop playing
and put the program into the second type of input loop above, waiting for
the user to indicate that she wants to continue playing.  If you've 
followed all the other rules correctly (i.e. not disabled Exec) then other
tasks should be able to run normally while your game waits.
-- 
		Stuart Ferguson		(shf@well.UUCP)
		Action by HAVOC		(ferguson@metaphor.com)