bryce@COGSCI.BERKELEY.EDU.UUCP (05/29/87)
Recently there was a discussion about absolute hardware address. The
conclusion was -> don't pollute the Amiga software base with them <-.
If you need to use a hardware address think about why. Now think again.
And when your are done with that try to get your job done another way.
If you still need to use the hardware take a look at using the resources.
Now think again. Still need to use the hardware? Well don't count on
it being at the same address.
-> In all your Amiga programming you should be using ONE absolute address,
-> location 4, _AbsExecBase, the pointer to the exec.library.
To derive the location of CIAA or CIAB ($BFF001, BFD000 on an Amiga 1000)
use this code:
------- 68000 ---------
move.l 4,a6 ;exec library
lea.l CIAAName(pc),a1
jsr _LVOOpenResource(a6)
tst.l d0 ;grrr... bah, humbug gritch gripe.
beq.s e_nociaa
move.l d0,a1
move.l CR_HWADDR(a1),CIAABASE ;This is it!
jsr _LVOCloseLibrary(a6)
tst.l CIAABASE
beq.s e_nociaa ;no cia? incompatible machine...
...
CIAAName dc.b 'ciaa.resource',0
-------- C -----------
struct Library *MyCIAbase
MyCIAbase=(struct Library*)OpenResouce("ciaa.resource");
if(MyCIAbase==NULL) goto diehorribly;
ciaaaddr=MyCIAbase->CR_HWADDR;
CloseLibrary(myCIAbase);
if(ciaaaddr==NULL) goto croak;
----------------------
This only has to be done once. (unless someone removes/adds a CIA while
the machine in running :-) :-) :-) :-)
Now if you tried to assemble/compile this you would get a undefined symbol
on CR_HWADDR. You need a structure, (68000 flavor only):
STRUCTURE CIAR,LIB_SIZE
APTR CR_HWADDR ;Hardware address
UWORD CR_IntMask
UBYTE CR_IEnable
UBYTE CR_IActive
STRUCT CR_INTNODE,IS_SIZE
STRUCT CR_ITVA,IS_SIZE
STRUCT CR_ITVB,IS_SIZE
STRUCT CR_IVALRM,IS_SIZE
STRUCT CR_IVFLAG,IS_SIZE
LABEL CR_SIZE
(Or just replace CR_HWADDR in the examples with LIB_SIZE, they are the same)
--- Documentation bug #1 ---
This structure IS NOT on any of the Gamma 1 include files disks. It was
probably an accident that it was printed out on page E-72 of the RKM.
--- Documentation bug #2 ---
The autodocs for the OpenResource function direct ones attention to the
CloseResource function. 'Taint so, there is no such beast.
--- Documentation bug #3 ---
How to derive the base address of CIAA, CIAB and CUSTOM is NOT documented
ANYWHERE. ^^^^^^
--- Documentation bug #4 ---
Include file exec/memory.i. "APTR MC_SIZE" should read "LABEL MC_SIZE".
-------------
Ack! (NAK,EOT,SOH)
|\ /| .
{o O} . bryce@cogsci.berkeley.EDU -or- ucbvax!cogsci!bryce
( " )
U Single tasking? Just say *NO!*