[comp.sys.amiga.tech] A Few Questions

aman@xroads.UUCP (Chris Minshall) (07/31/90)

I have a few questions.....

1.  What would be the easiest (quick and dirty if necessary) way to get mouse
    button and movement events without using Intuition?  A code example would
    be of great help as well!

2.  How do you create tasks that will share common data structures within a  
    program (written in C).  Again, a code examples would be appreciated!

Thanks in advance for any answers!

Chris
-- 
\  /  C r o s s r o a d s  C o m m u n i c a t i o n s
 /\   (602) 941-2005 300|1200 Baud 24 hrs/day
/  \  hplabs!hp-sdd!crash!xroads!aman

markv@kuhub.cc.ukans.edu (08/01/90)

In article <1139@xroads.UUCP>, aman@xroads.UUCP (Chris Minshall) writes:
> I have a few questions.....
> 
> 1.  What would be the easiest (quick and dirty if necessary) way to get mouse
>     button and movement events without using Intuition?  A code example would
>     be of great help as well!

In increasing order of dirtirness, add an input handler in front of
intution (safe but actually more work than an IDCMP, but useful if you
want to *steal* events so Intution *doesn't* see them), access the
gameport.device directly, and read the registers.  Examples of the
first two are in the Libs & Devs RKMs, the last is in the Hardware
manual.
 
> 2.  How do you create tasks that will share common data structures within a  
>     program (written in C).  Again, a code examples would be appreciated!

In C it is pretty.  Make sure shared objects (or their pointers if
dynamically allocated) are global in scope and access them normally.  
Shared variables make great simple semaphores.  I find that the best
bet with these kinds of semaphores is to set all you subtasks at
different priorities, that way you know for sure which tasks can or
cant interrupt the current task.  Or wrap your semaphore test/set
operations with Forbid()/Permit().  Just remember, Forbid() and
Permit() nest.  Also, if one of your sharing data with an interrupt,
you need to use Disable()/Enable() instead.

Another "tricky" way to do things atomically is use software
interrupts since they only get interrupted by hardware interrupts, not
tasks.  So you can create an interrupt for each action and Cause() it.

If you are using base-relative addresses, any subtasks need to fetch the
global base at their initial entry.  In Lattice C this is easy.
CreateTask() a task with C function as its entry.  Then either declare
the function as __saveds, or call geta4(), or compile the module with
-y.

> Thanks in advance for any answers!
> 
> Chris
> -- 
> \  /  C r o s s r o a d s  C o m m u n i c a t i o n s
>  /\   (602) 941-2005 300|1200 Baud 24 hrs/day
> /  \  hplabs!hp-sdd!crash!xroads!aman
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Gooderum			Only...		\    Good Cheer !!!
Academic Computing Services	       ///	  \___________________________
University of Kansas		     ///  /|         __    _
Bix:	  markgood	      \\\  ///  /__| |\/| | | _   /_\  makes it
Bitnet:   MARKV@UKANVAX		\/\/  /    | |  | | |__| /   \ possible...
Internet: markv@kuhub.cc.ukans.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cmcmanis@stpeter.Eng.Sun.COM (Chuck McManis) (08/02/90)

In article <1139@xroads.UUCP> aman@xroads.UUCP (Chris Minshall) writes:
>1.  What would be the easiest (quick and dirty if necessary) way to get mouse
>    button and movement events without using Intuition?  A code example would
>    be of great help as well!

Don't know why you wouldn't use intution since it is pretty easy to use but
the answer is "replace intuition". (Don't worry, it's easier than it sounds)
Intuition is just an Input Handler on the input food chain. All input to the
Amiga (Mouse, Joystick, Keyboard, timer ticks, etc) come down this food 
chain. You install an input handler "in front" (which means with a higher
priority than intuition) of intuition and the handler then sends you the
events. I caution you that this is _not_ as easy as opening a borderless
backdrop window (uses no memory) to get events from.

>2.  How do you create tasks that will share common data structures within a  
>    program (written in C).  Again, a code examples would be appreciated!

You want to create two tasks that share a common piece of memory? The 
easiest way to do this is to use Message ports as a rendesvous(sp?)
protocol. Create a message port with the shared memory attached in
one of the tasks. Then give it a unique name and add it to the 
public port list with AddPort(). Now you second task can find it with
FindPort(). The other advantage to doing this is that you can also
use the message port to communicate if you want.

>Thanks in advance for any answers!

I would be interested to know _why_ you want to do #1. Clearly I suspect
you don't realize how easy and efficient it is to use intuition but I
can be easily convinced that this is not the case.

--
--Chuck McManis						    Sun Microsystems
uucp: {anywhere}!sun!cmcmanis   BIX: <none>   Internet: cmcmanis@Eng.Sun.COM
These opinions are my own and no one elses, but you knew that didn't you.
"I tell you this parrot is bleeding deceased!"