[comp.sys.amiga.tech] Pointer Initialization

kzyx@vax5.cit.cornell.edu (12/25/90)

       Hello there,

       What is the correct way to initialize a structure pointer to access
the hardware under ANSI (Aztec C 5.0d)


       say:
                #define ADDRESS (0xAAAAAAL) /* for the sake of example */

               struct myblitterstruct *myblitterpointer;

               main()
               $                       .
                                       .
                                       .
                       *myblitterpointer = ADDRESS; /* I get invalid
                                                       ptr/int conv... */

               

       Your help is extremely appreciated


       Thanks


       Edval

a976@mindlink.UUCP (Ron Tarrant) (12/26/90)

> kzyx@vax5.cit.cornell.edu writes:
> 
> Msg-ID: <1990Dec24.152533.1770@vax5.cit.cornell.edu>
> Posted: 24 Dec 90 19:25:33 GMT
> 
> 
>        Hello there,
> 
>        What is the correct way to initialize a structure pointer to access
> the hardware under ANSI (Aztec C 5.0d)
> 
>        Edval


It's not a good idea to access the hardware directly. It means you have to
update your code every time there is system software and makes it harder (if
I'm not mistaken) to go from one Amiga model to another.

> kzyx@vax5.cit.cornell.edu writes:
> 
>                struct myblitterstruct *myblitterpointer;
> 


This initializes your structure pointer. If you already have a structure of
this type defined, that is. If you also have an actual
structure of this type declared, then make your pointer point to it like this:

        myblitterstruct = &OriginalBlitterStruct

But when you point your pointer at something in the hardware you're asking for
trouble. In fact, I'm not sure it can even be done.
-Ron

dcl@ncsc1.ATT.COM (Dave Love) (12/28/90)

In article <4241@mindlink.UUCP> a976@mindlink.UUCP (Ron Tarrant) writes:
>> kzyx@vax5.cit.cornell.edu writes:
>>        What is the correct way to initialize a structure pointer to access
>> the hardware under ANSI (Aztec C 5.0d)
>>
>
>It's not a good idea to access the hardware directly. It means you have to
>update your code every time there is system software and makes it harder (if
>I'm not mistaken) to go from one Amiga model to another.
>
Agreed.

>>                struct myblitterstruct *myblitterpointer;
>> 
>
>This initializes your structure pointer. If you already have a structure of
>this type defined, that is. If you also have an actual
>structure of this type declared, then make your pointer point to it like this:
>
>        myblitterstruct = &OriginalBlitterStruct
>
>But when you point your pointer at something in the hardware you're asking for
>trouble. In fact, I'm not sure it can even be done.
>-Ron

To get to the hardware you need something like the following line
(assuming you want myblitterpointer to point to the actual blitter
registers):

	struct myblitterstruct *myblitterpointer = 
		(struct myblitterstruct *)(0x00000000L);

where 0x00000000 is replaced by the appropriate hardware address (Sorry,
I don't have my RKM's handy so I can't give the correct address).


DISCLAIMER:  Using techniques similar to this in production code
will probably result in the end of the world as we know it. :)
However, going straight to the hardware was, for me, the best way
to learn about the blitter.  Once I was comfortable with what the
blitter did (and why), it was fairly simple to find "approved" ways
to use it.

-- 
 Dave Love  
 UUCP: dcl@ncsc1.att.com  CI$: 75126,2223   bix: dlove  

 -- "MS-DOS... The ultimate PC virus." --