•  Back 
  •  Emulators 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help page 
  •  Show info about hypertext 
  •  View a new file 
Topic       : TOS - The Operating System
Author      : 
Version     : tos.hyp (December 19, 2008)
Subject     : Programmieren/Atari
Nodes       : 3010
Index Size  : 93790
HCP-Version : 5
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Title
@help       : 
@options    : +g -i -s +x +zz -t4
@width      : 70
View Ref-File12.4  TOS2WIN                                                      TOS

Tos2Win Cookie

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.

DLL function

 $0000   LONG HoleOffset()

          Return value:  Returns in d0 the offset for recalculation

         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.

 $0001   LONG OpenLibrary(Name)

          Name :         Pointer to a NULL-terminated string that 
                         contains the name of the desired DLL, e.g. 
                         'GDI32.DLL' (the pointer must be corrected 
                         with the offset)
          Return value:  Returns in d0 a handle to the DLL

 $0002   VOID CloseLibrary(Handle)

          Handle :       Handle to the DLL to be closed; when the 
                         internal Windows counter has reached zero, 
                         the DLL is removed from memory

 $0003   LONG GetFunctionAdress(Handle,Name)

          Handle :       Handle for the DLL
          Name :         Pointer to a NULL-terminated string that 
                         contains the name of the function (pointer 
                         has to be corrected)
          Return value:  Address of the function in PC memory

 $0004   LONG CallLibraryFunction(Adr,Number,.....)

          Adr :          Address of the desired function
          Number :       Number of parameters passed to the PC 
                         function
          .... :         The corresponding parameters (pointers have 
                         to be corrected)
          Return value:  Possible return value of the PC function