home *** CD-ROM | disk | FTP | other *** search
- NAME
- CallFunction - call a library function via base/offset
-
- SYNOPSIS
- #include <exec/types.h>
- #include <exec/libraries.h>
-
- result = CallFunction(base, offset, d0, d1, d2, d3, d4,
- d5, d6, d7, a0, a1, a2, a3, a4);
-
- LONG CallFunction(struct Library *, LONG, LONG, LONG,
- LONG, LONG, LONG, LONG, LONG, LONG,
- APTR, APTR, APTR, APTR, APTR);
-
- FUNCTION
- CallFunction allows you to call almost any library function via
- its LVO (Library Vector Offset).
- Library functions that take arguments in A5 or on the stack cannot
- be called by CallFunction (i.e. SuperVisor(), #?LockLayerRom()).
-
- INPUTS
- base Pointer to the library base, as returned from OpenLibrary()
- offset The (NEGATIVE!) offset from the base for calling the desired
- function. This value can usually be taken from:
- 1) FD file of the library, the negative bias
- 2) Assembler header file, usually prefixed by _LVO
- 3) SAS/C or DICE "#pragma libcall" instruction
- d0 ... d7 Values to be passed to the library function in registers
- D0 to D7.
- a0 ... a4 Values to be passed to the library function in registers
- A0 to A4.
-
- RESULT
- result Value returned as result by the called library function.
- This is only valid if the library function actually returns
- a result. CallFunction actually returns the registers
- D0, D1, A0 and A1 from the library function. Usually only D0
- contains the result and the other three are trashed, unless
- the Autodocs of the library function states otherwise.
-
- EXAMPLE
- #include <exec/types.h>
- #include <exec/libraries.h>
- #include <intuition/intuition.h>
- #include <clib/exec_protos.h>
-
- extern __stkargs LONG CallFunction(APTR *base, LONG offset,
- LONG d0, LONG d1, LONG d2, LONG d3,
- LONG d4, LONG d5, LONG d6, LONG d7,
- APTR a0, APTR a1, APTR a2, APTR a3,
- APTR a4);
-
-
- main()
- {
- LONG rc;
- struct Library *demoBase;
- struct EasyStruct demoES = {
- sizeof (struct EasyStruct),
- 0,
- "CallFunction Demo",
- "DisplayBeep() and EasyRequestArgs() called by CallFunction()",
- "Great! Do it again!|Oh no! Stop it!",
- };
-
- if( demoBase = OpenLibrary("intuition.library", 37) ) {
- do {
- CallFunction( demoBase, -0x60, /* DisplayBeep */
- 0, 0, 0, 0, 0, 0, 0, 0, /* dummy values for D0-D7 */
- NULL, 0, 0, 0, 0); /* dummy values for A1-A4 */
- rc = CallFunction( demoBase, -0x24c, /* EasyRequestArgs */
- 0, 0, 0, 0, 0, 0, 0, 0, /* dummy values for D0-D7 */
- NULL, (APTR)&demoES, NULL, NULL, 0);/* dummy value for A4 */
- }
- while( rc );
- CloseLibrary(demoBase);
- }
- return 0;
- }
-
- SEE ALSO
- exec.library/OpenLibrary, exec/library/CloseLibrary
-
-