rogeriodec
msmcleod
1. Write an external DLL that exposes these functions for you that you can call from CAL
Based in the CAL "DLL" syntax:
(DLL <”filename”> <procedurename> <argument1> .. <argumentN>)
How can I get the RESULT of a DLL function?
That, I'm not sure of. The documentation on CAL in this area is pretty sparse.
At one point, I'm sure I came across some examples, but I've been unable to find them again - so many of these old CAL sites are no longer there, and internet archives such as the wayback machine only store so much.
If the DLL can't return a value, one (horrible hacky) way of doing it would be to get the DLL to write out the values to it's own CAL script, assigning the values to variables, and save this as a known filename to disk. The next line of your CAL program could include that file and use those variables.
rogeriodec
Also, do you know some DLL for triconometric operations?
I don't, but even if there was one it's unlikely it would help. All the documentation I've read on CAL DLL calls goes on about how fussy CAL is with regard to the "signature" of the DLL function - i.e. the parameter types have to be exactly as CAL expects/supports, else it'll crash CbB/SONAR.
By far the easiest approach would be to write a bunch of CAL "sub programs" that do the trig calculations, and use them as includes, within your scripts. This could be in the form of lookup tables (be careful of the 32K limit of CAL programs though), or as I said in an earlier post, you could look at other ways of approximating the functions (e.g. Chebsyshev polynomials, Bhaskara I)
I was lucky to find that CAL example in my previous post that shows how to do a SIN wave using Bhaskara's approximation, but my earlier post regarding 8-bit computers doing math without a math co-processor is still valid.
For example, the Sinclair ZX81 (a 1K z80 machine released in UK in 1981) used Chebyshev:
see:
https://www.tablix.org/~avian/spectrum/rom/zx81.htm and search for "TRIGONOMETRIC" and also "SERIES GENERATOR"