Blitz (22/119)

From:David McMinn
Date:8 Jun 2001 at 12:02:06
Subject:Re: Libraries again

Hi Demon

> Any ideas as to how to call functions within a library without converting
> them to blitzlibs??

Use assembler. Although there's not much you need to know about assembly
to do it. Just make up stub functions and statements and call the library
code from within, e.g.

DEFTYPE.Library *mhiBase

; Make up statements and functions for the library commands (obviously
; use a statement for commands that do not return a value). Give the
; statements, and functions the same parameters as the library commands
; (and use the same names for the parameters, it'll stop confusion).
; Make sure all the types are the same too.
Statement mhi_example1{par1.l, tags.l}
SHARED *mhiBase ; You need access to the library base

; All you need to do is put the correct parameters in the correct
; registers (which you get from the autodocs)...
GetReg d0,par1
GetReg a0,tags
GetReg a6,*mhiBase

; And then call the function using the correct offset (best to use
; constants, or even use fd2pragma or something).
JSR -30(a6)
AsmExit
End Statement

Function.l mhi_example2{mhi_handle.l, setting.l, tags.l}
SHARED *mhiBase

GetReg a0,mhi_handle
GetReg d0,setting
GetReg a1,tags
GetReg a6,*mhiBase

JSR -36(a6)

; You do not need to specify a return value, since Blitz
; automatically returns the value in d0 (which should
; be the result of the library call).
AsmExit
End Function

*mhiBase = OpenLibrary_("mhiwhatever.library", version_number)
If *mhiBase

; Safe to use the MHI functions here

CloseLibrary_ *mhiBase : *mhiBase = 0
; Do not use the functions again until you re-open the library
EndIf



|) /\ \/ ][ |) |\/| c |\/| ][ |\| |\| | dave@blitz-2000.co.uk
http://members.nbci.com/david_mcminn | ICQ=16827694
A TRUE Klingon Warrior does not comment his code!

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie