To ascertain which Tos2Win version and which features are present, as of Version 1.19 a cookie '_T2W' exists with a pointer to the following data structure:
|1 x Word||Length of the structure|
|1 x Word||Version in BCD i.e. $0119 = Version 1.19|
|1 x Long||Offset of the Atari memory in PC memory for recalculation of pointers|
|4 x Long||Bit-fields for individual T2W features|
Call PC-DLLs as of Version 1.19J
In TOS2WIN all PC calls are introduced with the sequence $4858, which is followed by the group code (e.g. $5043) for the DLL functions, and is terminated with the function number (e.g. $0000).
So a call of a DLL function would look as follows:
Function start . . . $4858 $5043 $0000 . . . Function end RTS
The parameters for the function lie from a7 + 4 onwards. This means placing all required parameters on the stack (always only LONGwords) and then a bsr to function start.
All pointers passed to the PC function to values in Atari memory have to be corrected with an offset. Atari address + offset = PC address. One can get the offset either via the Tos2Win cookie or via the DLL function $0000. The offset does not alter during the runtime of the program.
This function can also be used to ascertain whether the following functions are present. Just load register d0 with zero and call the function. If there is still zero in d0, then the functions are not implemented.