Browse Source

Amiga: Syscallified last units, Open Library in initialization, Close Library in Finalization

git-svn-id: trunk@33149 -
marcus 9 years ago
parent
commit
d3b8483cef
43 changed files with 553 additions and 7777 deletions
  1. 6 94
      packages/amunits/src/coreunits/agraphics.pas
  2. 6 94
      packages/amunits/src/coreunits/amigaguide.pas
  3. 6 94
      packages/amunits/src/coreunits/asl.pas
  4. 5 95
      packages/amunits/src/coreunits/bullet.pas
  5. 6 40
      packages/amunits/src/coreunits/colorwheel.pas
  6. 6 38
      packages/amunits/src/coreunits/commodities.pas
  7. 6 96
      packages/amunits/src/coreunits/datatypes.pas
  8. 6 98
      packages/amunits/src/coreunits/diskfont.pas
  9. 6 94
      packages/amunits/src/coreunits/expansion.pas
  10. 6 94
      packages/amunits/src/coreunits/gadtools.pas
  11. 6 96
      packages/amunits/src/coreunits/icon.pas
  12. 6 95
      packages/amunits/src/coreunits/iffparse.pas
  13. 4 1
      packages/amunits/src/coreunits/intuition.pas
  14. 6 40
      packages/amunits/src/coreunits/keymap.pas
  15. 6 94
      packages/amunits/src/coreunits/layers.pas
  16. 6 96
      packages/amunits/src/coreunits/locale.pas
  17. 6 92
      packages/amunits/src/coreunits/lowlevel.pas
  18. 6 94
      packages/amunits/src/coreunits/nonvolatile.pas
  19. 6 93
      packages/amunits/src/coreunits/realtime.pas
  20. 6 94
      packages/amunits/src/coreunits/rexx.pas
  21. 6 93
      packages/amunits/src/coreunits/translator.pas
  22. 5 1
      packages/amunits/src/coreunits/utility.pas
  23. 6 94
      packages/amunits/src/coreunits/workbench.pas
  24. 6 89
      packages/amunits/src/otherlibs/ahi.pas
  25. 21 314
      packages/amunits/src/otherlibs/ahi_sub.pas
  26. 51 712
      packages/amunits/src/otherlibs/amarquee.pas
  27. 7 93
      packages/amunits/src/otherlibs/cybergraphics.pas
  28. 47 658
      packages/amunits/src/otherlibs/gtlayout.pas
  29. 32 493
      packages/amunits/src/otherlibs/guigfx.pas
  30. 15 208
      packages/amunits/src/otherlibs/identify.pas
  31. 20 269
      packages/amunits/src/otherlibs/lucyplay.pas
  32. 6 82
      packages/amunits/src/otherlibs/mui.pas
  33. 16 220
      packages/amunits/src/otherlibs/mysticview.pas
  34. 7 95
      packages/amunits/src/otherlibs/picasso96api.pas
  35. 16 249
      packages/amunits/src/otherlibs/preferences.pas
  36. 6 94
      packages/amunits/src/otherlibs/ptreplay.pas
  37. 53 800
      packages/amunits/src/otherlibs/render.pas
  38. 7 94
      packages/amunits/src/otherlibs/reqtools.pas
  39. 47 625
      packages/amunits/src/otherlibs/triton.pas
  40. 0 4
      packages/amunits/src/otherlibs/tritonmacros.pas
  41. 22 310
      packages/amunits/src/otherlibs/ttengine.pas
  42. 34 457
      packages/amunits/src/otherlibs/xadmaster.pas
  43. 6 91
      packages/amunits/src/otherlibs/zlib.pas

+ 6 - 94
packages/amunits/src/coreunits/agraphics.pas

@@ -2234,7 +2234,7 @@ const
 
 
 var
-    GfxBase : pLibrary;
+    GfxBase : pLibrary = nil;
 
 PROCEDURE AddAnimOb(anOb : pAnimOb location 'a0'; anKey : ppAnimOb location 'a1'; rp : pRastPort location 'a2'); syscall GfxBase 156;
 PROCEDURE AddBob(bob : pBob location 'a0'; rp : pRastPort location 'a1'); syscall GfxBase 096;
@@ -2424,24 +2424,8 @@ function AreaCircle(Rp: PRastPort; xCenter, yCenter, r: SmallInt): LongWord; inl
 
 function RasSize(w, h: Word): Integer;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitGRAPHICSLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    GRAPHICSIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-uses
-{$ifndef dont_use_openlib}
-amsgbox;
-{$endif dont_use_openlib}
-
 PROCEDURE BNDRYOFF (w: pRastPort);
 BEGIN
     WITH w^ DO BEGIN
@@ -2554,86 +2538,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of graphics.library}
-  {$Info don't forget to use InitGRAPHICSLibrary in the beginning of your program}
-
-var
-    graphics_exit : Pointer;
-
-procedure ClosegraphicsLibrary;
-begin
-    ExitProc := graphics_exit;
-    if GfxBase <> nil then begin
-        CloseLibrary(GfxBase);
-        GfxBase := nil;
-    end;
-end;
-
-procedure InitGRAPHICSLibrary;
-begin
-    GfxBase := nil;
-    GfxBase := OpenLibrary(GRAPHICSNAME,LIBVERSION);
-    if GfxBase <> nil then begin
-        graphics_exit := ExitProc;
-        ExitProc := @ClosegraphicsLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open graphics.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    GRAPHICSIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of graphics.library}
-
-var
-    graphics_exit : Pointer;
-
-procedure ClosegraphicsLibrary;
-begin
-    ExitProc := graphics_exit;
-    if GfxBase <> nil then begin
-        CloseLibrary(GfxBase);
-        GfxBase := nil;
-    end;
-end;
-
-begin
-    GfxBase := nil;
-    GfxBase := OpenLibrary(GRAPHICSNAME,LIBVERSION);
-    if GfxBase <> nil then begin
-        graphics_exit := ExitProc;
-        ExitProc := @ClosegraphicsLibrary;
-        GRAPHICSIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open graphics.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    GRAPHICSIsCompiledHow := 3;
-   {$Warning No autoopening of graphics.library compiled}
-   {$Warning Make sure you open graphics.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  GfxBase := OpenLibrary(GRAPHICSNAME,LIBVERSION);
+finalization
+  if Assigned(GfxBase) then
+    CloseLibrary(GfxBase);
 END. (* UNIT GRAPHICS *)
 
 

+ 6 - 94
packages/amunits/src/coreunits/amigaguide.pas

@@ -239,7 +239,7 @@ Type
     oen_Attrs : pTagItem;          {  R: Additional attributes }
   END;
 
-VAR AmigaGuideBase : pLibrary;
+VAR AmigaGuideBase : pLibrary = nil;
 
 const
     AMIGAGUIDENAME : Pchar = 'amigaguide.library';
@@ -263,106 +263,18 @@ FUNCTION SetAmigaGuideAttrsA(cl : POINTER location 'a0'; attrs : pTagItem locati
 FUNCTION SetAmigaGuideContextA(cl : POINTER location 'a0'; id : ULONG location 'd0'; attrs : pTagItem location 'd1') : LONGINT; syscall AmigaGuideBase 090;
 PROCEDURE UnlockAmigaGuideBase(key : LONGINT location 'd0'); syscall AmigaGuideBase 042;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitAMIGAGUIDELibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    AMIGAGUIDEIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of amigaguide.library}
-  {$Info don't forget to use InitAMIGAGUIDELibrary in the beginning of your program}
-
-var
-    amigaguide_exit : Pointer;
-
-procedure CloseamigaguideLibrary;
-begin
-    ExitProc := amigaguide_exit;
-    if AmigaGuideBase <> nil then begin
-        CloseLibrary(AmigaGuideBase);
-        AmigaGuideBase := nil;
-    end;
-end;
-
-procedure InitAMIGAGUIDELibrary;
-begin
-    AmigaGuideBase := nil;
-    AmigaGuideBase := OpenLibrary(AMIGAGUIDENAME,LIBVERSION);
-    if AmigaGuideBase <> nil then begin
-        amigaguide_exit := ExitProc;
-        ExitProc := @CloseamigaguideLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open amigaguide.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    AMIGAGUIDEIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of amigaguide.library}
-
-var
-    amigaguide_exit : Pointer;
-
-procedure CloseamigaguideLibrary;
-begin
-    ExitProc := amigaguide_exit;
-    if AmigaGuideBase <> nil then begin
-        CloseLibrary(AmigaGuideBase);
-        AmigaGuideBase := nil;
-    end;
-end;
-
-begin
-    AmigaGuideBase := nil;
-    AmigaGuideBase := OpenLibrary(AMIGAGUIDENAME,LIBVERSION);
-    if AmigaGuideBase <> nil then begin
-        amigaguide_exit := ExitProc;
-        ExitProc := @CloseamigaguideLibrary;
-        AMIGAGUIDEIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open amigaguide.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    AMIGAGUIDEIsCompiledHow := 3;
-   {$Warning No autoopening of amigaguide.library compiled}
-   {$Warning Make sure you open amigaguide.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  AmigaGuideBase := OpenLibrary(AMIGAGUIDENAME,LIBVERSION);
+finalization
+  if Assigned(AmigaGuideBase) then
+    CloseLibrary(AmigaGuideBase);
 END. (* UNIT AMIGAGUIDE *)
 
 

+ 6 - 94
packages/amunits/src/coreunits/asl.pas

@@ -546,7 +546,7 @@ Const
   FONF_DOWILDFUNC  = 128;
 {$endif ASL_V38_NAMES_ONLY}
 
-VAR AslBase : pLibrary;
+VAR AslBase : pLibrary = nil;
 
 
 FUNCTION AllocAslRequest(reqType : ULONG location 'd0'; tagList : pTagItem location 'a0') : POINTER; syscall AslBase 048;
@@ -559,106 +559,18 @@ FUNCTION RequestFile(fileReq : pFileRequester location 'a0') : LongInt; syscall
 PROCEDURE AbortAslRequest(requester : POINTER location 'a0'); syscall AslBase 078;
 PROCEDURE ActivateAslRequest(requester : POINTER location 'a0'); syscall AslBase 084;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitASLLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    ASLIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of asl.library}
-  {$Info don't forget to use InitASLLibrary in the beginning of your program}
-
-var
-    asl_exit : Pointer;
-
-procedure CloseaslLibrary;
-begin
-    ExitProc := asl_exit;
-    if AslBase <> nil then begin
-        CloseLibrary(AslBase);
-        AslBase := nil;
-    end;
-end;
-
-procedure InitASLLibrary;
-begin
-    AslBase := nil;
-    AslBase := OpenLibrary(ASLNAME,LIBVERSION);
-    if AslBase <> nil then begin
-        asl_exit := ExitProc;
-        ExitProc := @CloseaslLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open asl.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    ASLIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of asl.library}
-
-var
-    asl_exit : Pointer;
-
-procedure CloseaslLibrary;
-begin
-    ExitProc := asl_exit;
-    if AslBase <> nil then begin
-        CloseLibrary(AslBase);
-        AslBase := nil;
-    end;
-end;
-
-begin
-    AslBase := nil;
-    AslBase := OpenLibrary(ASLNAME,LIBVERSION);
-    if AslBase <> nil then begin
-        asl_exit := ExitProc;
-        ExitProc := @CloseaslLibrary;
-        ASLIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open asl.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    ASLIsCompiledHow := 3;
-   {$Warning No autoopening of asl.library compiled}
-   {$Warning Make sure you open asl.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  AslBase := OpenLibrary(ASLNAME,LIBVERSION);
+finalization
+  if Assigned(AslBase) then
+    CloseLibrary(AslBase);
 END. (* UNIT ASL *)
 
 

+ 5 - 95
packages/amunits/src/coreunits/bullet.pas

@@ -380,107 +380,17 @@ FUNCTION OpenEngine : pGlyphEngine; syscall BulletBase 030;
 FUNCTION ReleaseInfoA(glyphEngine : pGlyphEngine location 'a0'; tagList : pTagItem location 'a1') : ULONG; syscall BulletBase 054;
 FUNCTION SetInfoA(glyphEngine : pGlyphEngine location 'a0'; tagList : pTagItem location 'a1') : ULONG; syscall BulletBase 042;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitBULLETLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    BULLETIsCompiledHow : longint;
 
 IMPLEMENTATION
 
-{
- If you don't use array of const then just remove tagsarray
-}
-uses
-{$ifndef dont_use_openlib}
-amsgbox;
-{$endif dont_use_openlib}
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of bullet.library}
-  {$Info don't forget to use InitBULLETLibrary in the beginning of your program}
-
-var
-    bullet_exit : Pointer;
-
-procedure ClosebulletLibrary;
-begin
-    ExitProc := bullet_exit;
-    if BulletBase <> nil then begin
-        CloseLibrary(BulletBase);
-        BulletBase := nil;
-    end;
-end;
-
-procedure InitBULLETLibrary;
-begin
-    BulletBase := nil;
-    BulletBase := OpenLibrary(BULLETNAME,LIBVERSION);
-    if BulletBase <> nil then begin
-        bullet_exit := ExitProc;
-        ExitProc := @ClosebulletLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open bullet.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    BULLETIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of bullet.library}
-
-var
-    bullet_exit : Pointer;
-
-procedure ClosebulletLibrary;
-begin
-    ExitProc := bullet_exit;
-    if BulletBase <> nil then begin
-        CloseLibrary(BulletBase);
-        BulletBase := nil;
-    end;
-end;
-
-begin
-    BulletBase := nil;
-    BulletBase := OpenLibrary(BULLETNAME,LIBVERSION);
-    if BulletBase <> nil then begin
-        bullet_exit := ExitProc;
-        ExitProc := @ClosebulletLibrary;
-        BULLETIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open bullet.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    BULLETIsCompiledHow := 3;
-   {$Warning No autoopening of bullet.library compiled}
-   {$Warning Make sure you open bullet.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  BulletBase := OpenLibrary(BULLETNAME,LIBVERSION);
+finalization
+  if Assigned(BulletBase) then
+    CloseLibrary(BulletBase);
 END. (* UNIT BULLET *)

+ 6 - 40
packages/amunits/src/coreunits/colorwheel.pas

@@ -75,7 +75,7 @@ const
 
 {--- functions in V39 or higher (Release 3) ---}
 
-VAR ColorWheelBase : pLibrary;
+VAR ColorWheelBase : pLibrary = nil;
 
 const
     COLORWHEELNAME : Pchar = 'colorwheel.library';
@@ -85,50 +85,16 @@ PROCEDURE ConvertRGBToHSB(rgb : pColorWheelRGB location 'a0'; hsb : pColorWheelH
 
 IMPLEMENTATION
 
-uses amsgbox;
-
-
-{$I useautoopenlib.inc}
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of colorwheel.library}
-
-var
-    colorwheel_exit : Pointer;
-
-procedure ClosecolorwheelLibrary;
-begin
-    ExitProc := colorwheel_exit;
-    if ColorWheelBase <> nil then begin
-        CloseLibrary(ColorWheelBase);
-        ColorWheelBase := nil;
-    end;
-end;
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-begin
-    ColorWheelBase := nil;
-    ColorWheelBase := OpenLibrary(COLORWHEELNAME,LIBVERSION);
-    if ColorWheelBase <> nil then begin
-        colorwheel_exit := ExitProc;
-        ExitProc := @ClosecolorwheelLibrary
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open colorwheel.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$else}
-   {$Warning No autoopening of colorwheel.library compiled}
-   {$Info Make sure you open colorwheel.library yourself}
-{$endif use_auto_openlib}
-
+initialization
+  ColorWheelBase := OpenLibrary(COLORWHEELNAME,LIBVERSION);
+finalization
+  if Assigned(ColorWheelBase) then
+    CloseLibrary(ColorWheelBase);
 END. (* UNIT COLORWHEEL *)
 
 

+ 6 - 38
packages/amunits/src/coreunits/commodities.pas

@@ -224,7 +224,7 @@ CONST
       IX_NORMALQUALS  = $7FFF;   {     for QualMask field: avoid RELATIVEMOUSE }
 
 
-VAR CxBase : pLibrary;
+VAR CxBase : pLibrary = nil;
 
 const
     COMMODITIESNAME : PChar = 'commodities.library';
@@ -265,7 +265,6 @@ PROCEDURE SetFilter(filter : pCxObj; text : rawbytestring);
 
 IMPLEMENTATION
 
-uses amsgbox;
 
 FUNCTION ParseIX(description : rawbytestring; ix : pInputXpression) : LONGINT;
 begin
@@ -277,47 +276,16 @@ begin
   SetFilter(filter,pchar(text));
 end;
 
-{$I useautoopenlib.inc}
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of commodities.library}
-
-var
-    commodities_exit : Pointer;
-
-procedure ClosecommoditiesLibrary;
-begin
-    ExitProc := commodities_exit;
-    if CxBase <> nil then begin
-        CloseLibrary(CxBase);
-        CxBase := nil;
-    end;
-end;
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-begin
-    CxBase := nil;
-    CxBase := OpenLibrary(COMMODITIESNAME,LIBVERSION);
-    if CxBase <> nil then begin
-        commodities_exit := ExitProc;
-        ExitProc := @ClosecommoditiesLibrary
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open commodities.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$else}
-   {$Warning No autoopening of commodities.library compiled}
-   {$Info Make sure you open commodities.library yourself}
-{$endif use_auto_openlib}
-
+initialization
+  CxBase := OpenLibrary(COMMODITIESNAME,LIBVERSION);
+finalization
+  if Assigned(CxBase) then
+    CloseLibrary(CxBase);
 END. (* UNIT COMMODITIES *)
 
 

+ 6 - 96
packages/amunits/src/coreunits/datatypes.pas

@@ -1260,7 +1260,7 @@ Type
 
 { ***************************************************************************}
 
-VAR DataTypesBase : pLibrary;
+VAR DataTypesBase : pLibrary = nil;
 
 const
     DATATYPESNAME : PChar = 'datatypes.library';
@@ -1297,108 +1297,18 @@ FUNCTION ObtainDTDrawInfoA( o : pObject_ location 'a0'; attrs : pTagItem locatio
 FUNCTION DrawDTObjectA(rp : pRastPort location 'a0';  o : pObject_ location 'a1'; x : LONGINT location 'd0'; y : LONGINT location 'd1'; w : LONGINT location 'd2'; h : LONGINT location 'd3'; th : LONGINT location 'd4'; tv : LONGINT location 'd5'; attrs : pTagItem location 'a2') : LONGINT; syscall DataTypesBase 126;
 PROCEDURE ReleaseDTDrawInfo( o : pObject_ location 'a0'; handle : POINTER location 'a1'); syscall DataTypesBase 132;
 
-
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitDATATYPESLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    DATATYPESIsCompiledHow : longint;
-
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of datatypes.library}
-  {$Info don't forget to use InitDATATYPESLibrary in the beginning of your program}
-
-var
-    datatypes_exit : Pointer;
-
-procedure ClosedatatypesLibrary;
-begin
-    ExitProc := datatypes_exit;
-    if DataTypesBase <> nil then begin
-        CloseLibrary(DataTypesBase);
-        DataTypesBase := nil;
-    end;
-end;
-
-procedure InitDATATYPESLibrary;
-begin
-    DataTypesBase := nil;
-    DataTypesBase := OpenLibrary(DATATYPESNAME,LIBVERSION);
-    if DataTypesBase <> nil then begin
-        datatypes_exit := ExitProc;
-        ExitProc := @ClosedatatypesLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open datatypes.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    DATATYPESIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of datatypes.library}
-
-var
-    datatypes_exit : Pointer;
-
-procedure ClosedatatypesLibrary;
-begin
-    ExitProc := datatypes_exit;
-    if DataTypesBase <> nil then begin
-        CloseLibrary(DataTypesBase);
-        DataTypesBase := nil;
-    end;
-end;
-
-begin
-    DataTypesBase := nil;
-    DataTypesBase := OpenLibrary(DATATYPESNAME,LIBVERSION);
-    if DataTypesBase <> nil then begin
-        datatypes_exit := ExitProc;
-        ExitProc := @ClosedatatypesLibrary;
-        DATATYPESIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open datatypes.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    DATATYPESIsCompiledHow := 3;
-   {$Warning No autoopening of datatypes.library compiled}
-   {$Warning Make sure you open datatypes.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  DataTypesBase := OpenLibrary(DATATYPESNAME,LIBVERSION);
+finalization
+  if Assigned(DataTypesBase) then
+    CloseLibrary(DataTypesBase);
 END. (* UNIT DATATYPES *)
 
 

+ 6 - 98
packages/amunits/src/coreunits/diskfont.pas

@@ -137,7 +137,7 @@ Type
 const
     DISKFONTNAME : PChar = 'diskfont.library';
 
-VAR DiskfontBase : pLibrary;
+VAR DiskfontBase : pLibrary = nil;
 
 FUNCTION AvailFonts(buffer : pCHAR location 'a0'; bufBytes : LONGINT location 'd0'; flags : LONGINT location 'd1') : LONGINT; syscall DiskfontBase 036;
 PROCEDURE DisposeFontContents(fontContentsHeader : pFontContentsHeader location 'a1'); syscall DiskfontBase 048;
@@ -147,110 +147,18 @@ FUNCTION OpenDiskFont(textAttr : pTextAttr location 'a0') : pTextFont; syscall D
 FUNCTION GetDiskFontCtrl(tagid : LONGINT location 'd0') : LONGINT; syscall DiskfontBase 060;
 PROCEDURE SetDiskFontCtrlA(taglist : pTagItem location 'a0'); syscall DiskfontBase 066;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitDISKFONTLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    DISKFONTIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{
- If you don't use array of const then just remove tagsarray
-}
-uses
-{$ifndef dont_use_openlib}
-amsgbox;
-{$endif dont_use_openlib}
-
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of diskfont.library}
-  {$Info don't forget to use InitDISKFONTLibrary in the beginning of your program}
-
-var
-    diskfont_exit : Pointer;
-
-procedure ClosediskfontLibrary;
-begin
-    ExitProc := diskfont_exit;
-    if DiskfontBase <> nil then begin
-        CloseLibrary(DiskfontBase);
-        DiskfontBase := nil;
-    end;
-end;
-
-procedure InitDISKFONTLibrary;
-begin
-    DiskfontBase := nil;
-    DiskfontBase := OpenLibrary(DISKFONTNAME,LIBVERSION);
-    if DiskfontBase <> nil then begin
-        diskfont_exit := ExitProc;
-        ExitProc := @ClosediskfontLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open diskfont.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    DISKFONTIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of diskfont.library}
-
-var
-    diskfont_exit : Pointer;
-
-procedure ClosediskfontLibrary;
-begin
-    ExitProc := diskfont_exit;
-    if DiskfontBase <> nil then begin
-        CloseLibrary(DiskfontBase);
-        DiskfontBase := nil;
-    end;
-end;
-
-begin
-    DiskfontBase := nil;
-    DiskfontBase := OpenLibrary(DISKFONTNAME,LIBVERSION);
-    if DiskfontBase <> nil then begin
-        diskfont_exit := ExitProc;
-        ExitProc := @ClosediskfontLibrary;
-        DISKFONTIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open diskfont.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    DISKFONTIsCompiledHow := 3;
-   {$Warning No autoopening of diskfont.library compiled}
-   {$Warning Make sure you open diskfont.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  DiskfontBase := OpenLibrary(DISKFONTNAME,LIBVERSION);
+finalization
+  if Assigned(DiskfontBase) then
+    CloseLibrary(DiskfontBase);
 END. (* UNIT DISKFONT *)
 
 

+ 6 - 94
packages/amunits/src/coreunits/expansion.pas

@@ -44,7 +44,7 @@ Const
 
     ADNF_STARTPROC      = 1;
 
-VAR ExpansionBase : pLibrary;
+VAR ExpansionBase : pLibrary = nil;
 
 
 FUNCTION AddBootNode(bootPri : LONGINT location 'd0'; flags : ULONG location 'd1'; deviceNode : pDeviceNode location 'a0'; configDev : pConfigDev location 'a1') : wordbool; syscall ExpansionBase 036;
@@ -69,106 +69,18 @@ PROCEDURE RemConfigDev(configDev : pConfigDev location 'a0'); syscall ExpansionB
 PROCEDURE SetCurrentBinding(currentBinding : pCurrentBinding location 'a0'; bindingSize : ULONG location 'd0'); syscall ExpansionBase 132;
 PROCEDURE WriteExpansionByte(board : POINTER location 'a0'; offset : ULONG location 'd0'; byte : ULONG location 'd1'); syscall ExpansionBase 114;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitEXPANSIONLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    EXPANSIONIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-uses
-{$ifndef dont_use_openlib}
-amsgbox;
-{$endif dont_use_openlib}
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of expansion.library}
-  {$Info don't forget to use InitEXPANSIONLibrary in the beginning of your program}
-
-var
-    expansion_exit : Pointer;
-
-procedure CloseexpansionLibrary;
-begin
-    ExitProc := expansion_exit;
-    if ExpansionBase <> nil then begin
-        CloseLibrary(ExpansionBase);
-        ExpansionBase := nil;
-    end;
-end;
-
-procedure InitEXPANSIONLibrary;
-begin
-    ExpansionBase := nil;
-    ExpansionBase := OpenLibrary(EXPANSIONNAME,LIBVERSION);
-    if ExpansionBase <> nil then begin
-        expansion_exit := ExitProc;
-        ExitProc := @CloseexpansionLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open expansion.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    EXPANSIONIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of expansion.library}
-
-var
-    expansion_exit : Pointer;
-
-procedure CloseexpansionLibrary;
-begin
-    ExitProc := expansion_exit;
-    if ExpansionBase <> nil then begin
-        CloseLibrary(ExpansionBase);
-        ExpansionBase := nil;
-    end;
-end;
-
-begin
-    ExpansionBase := nil;
-    ExpansionBase := OpenLibrary(EXPANSIONNAME,LIBVERSION);
-    if ExpansionBase <> nil then begin
-        expansion_exit := ExitProc;
-        ExitProc := @CloseexpansionLibrary;
-        EXPANSIONIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open expansion.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    EXPANSIONIsCompiledHow := 3;
-   {$Warning No autoopening of expansion.library compiled}
-   {$Warning Make sure you open expansion.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  ExpansionBase := OpenLibrary(EXPANSIONNAME,LIBVERSION);
+finalization
+  if Assigned(ExpansionBase) then
+    CloseLibrary(ExpansionBase);
 END. (* UNIT EXPANSION *)
 
 

+ 6 - 94
packages/amunits/src/coreunits/gadtools.pas

@@ -465,7 +465,7 @@ Type
 
 
 VAR
-    GadToolsBase : pLibrary;
+    GadToolsBase : pLibrary = nil;
 
 FUNCTION CreateContext(glistptr : pGadget location 'a0'): pGadget; syscall GadToolsBase 114;
 FUNCTION CreateGadgetA(kind : ULONG location 'd0'; gad : pGadget location 'a0'; const ng : pNewGadget location 'a1'; const taglist : pTagItem location 'a2') : pGadget; syscall GadToolsBase 030;
@@ -490,24 +490,8 @@ FUNCTION LayoutMenusA(firstmenu : pMenu location 'a0'; vi : POINTER location 'a1
 function GTMENUITEM_USERDATA(menuitem : pMenuItem): pointer;
 function GTMENU_USERDATA(menu : pMenu): pointer;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitGADTOOLSLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    GADTOOLSIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-uses
-{$ifndef dont_use_openlib}
-amsgbox;
-{$endif dont_use_openlib}
-
 function GTMENUITEM_USERDATA(menuitem : pMenuItem): pointer;
 begin
     GTMENUITEM_USERDATA := pointer((pMenuItem(menuitem)+1));
@@ -520,86 +504,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of gadtools.library}
-  {$Info don't forget to use InitGADTOOLSLibrary in the beginning of your program}
-
-var
-    gadtools_exit : Pointer;
-
-procedure ClosegadtoolsLibrary;
-begin
-    ExitProc := gadtools_exit;
-    if GadToolsBase <> nil then begin
-        CloseLibrary(GadToolsBase);
-        GadToolsBase := nil;
-    end;
-end;
-
-procedure InitGADTOOLSLibrary;
-begin
-    GadToolsBase := nil;
-    GadToolsBase := OpenLibrary(GADTOOLSNAME,LIBVERSION);
-    if GadToolsBase <> nil then begin
-        gadtools_exit := ExitProc;
-        ExitProc := @ClosegadtoolsLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open gadtools.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    GADTOOLSIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of gadtools.library}
-
-var
-    gadtools_exit : Pointer;
-
-procedure ClosegadtoolsLibrary;
-begin
-    ExitProc := gadtools_exit;
-    if GadToolsBase <> nil then begin
-        CloseLibrary(GadToolsBase);
-        GadToolsBase := nil;
-    end;
-end;
-
-begin
-    GadToolsBase := nil;
-    GadToolsBase := OpenLibrary(GADTOOLSNAME,LIBVERSION);
-    if GadToolsBase <> nil then begin
-        gadtools_exit := ExitProc;
-        ExitProc := @ClosegadtoolsLibrary;
-        GADTOOLSIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open gadtools.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    GADTOOLSIsCompiledHow := 3;
-   {$Warning No autoopening of gadtools.library compiled}
-   {$Warning Make sure you open gadtools.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  GadToolsBase := OpenLibrary(GADTOOLSNAME,LIBVERSION);
+finalization
+  if Assigned(GadToolsBase) then
+    CloseLibrary(GadToolsBase);
 END. (* UNIT GADTOOLS *)
 
 

+ 6 - 96
packages/amunits/src/coreunits/icon.pas

@@ -346,7 +346,7 @@ Const
 
     ICONNAME    : PChar = 'icon.library';
 
-VAR IconBase : pLibrary;
+VAR IconBase : pLibrary = nil;
 
 FUNCTION AddFreeList(freelist : pFreeList location 'a0'; const mem : POINTER location 'a1'; size : ULONG location 'a2') : LongBool; syscall IconBase 072;
 FUNCTION BumpRevision(newname : pCHAR location 'a0'; const oldname : pCHAR location 'a1') : pCHAR; syscall IconBase 108;
@@ -390,26 +390,8 @@ FUNCTION PutIconTagList(CONST name : RawByteString; CONST icon : pDiskObject; CO
 {macros}
 function PACK_ICON_ASPECT_RATIO(num,den : longint) : longint;
 
-
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitICONLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    ICONIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses
-  amsgbox;
-{$endif dont_use_openlib}
-
-
 function PACK_ICON_ASPECT_RATIO(num,den : longint) : longint;
 begin
     PACK_ICON_ASPECT_RATIO:=(num shl 4) or den;
@@ -473,86 +455,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of icon.library}
-  {$Info don't forget to use InitICONLibrary in the beginning of your program}
-
-var
-    icon_exit : Pointer;
-
-procedure CloseiconLibrary;
-begin
-    ExitProc := icon_exit;
-    if IconBase <> nil then begin
-        CloseLibrary(IconBase);
-        IconBase := nil;
-    end;
-end;
-
-procedure InitICONLibrary;
-begin
-    IconBase := nil;
-    IconBase := OpenLibrary(ICONNAME,LIBVERSION);
-    if IconBase <> nil then begin
-        icon_exit := ExitProc;
-        ExitProc := @CloseiconLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open icon.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    ICONIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of icon.library}
-
-var
-    icon_exit : Pointer;
-
-procedure CloseiconLibrary;
-begin
-    ExitProc := icon_exit;
-    if IconBase <> nil then begin
-        CloseLibrary(IconBase);
-        IconBase := nil;
-    end;
-end;
-
-begin
-    IconBase := nil;
-    IconBase := OpenLibrary(ICONNAME,LIBVERSION);
-    if IconBase <> nil then begin
-        icon_exit := ExitProc;
-        ExitProc := @CloseiconLibrary;
-        ICONIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open icon.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    ICONIsCompiledHow := 3;
-   {$Warning No autoopening of icon.library compiled}
-   {$Warning Make sure you open icon.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  IconBase := OpenLibrary(ICONNAME,LIBVERSION);
+finalization
+  if Assigned(IconBase) then
+    CloseLibrary(IconBase);
 END. (* UNIT ICON *)
 
 

+ 6 - 95
packages/amunits/src/coreunits/iffparse.pas

@@ -233,7 +233,7 @@ CONST
  IFFSCC_WRITE   = IFFCMD_WRITE;
  IFFSCC_SEEK    = IFFCMD_SEEK;
 
-VAR IFFParseBase : pLibrary;
+VAR IFFParseBase : pLibrary = nil;
 
 FUNCTION AllocIFF : pIFFHandle; syscall IFFParseBase 030;
 FUNCTION AllocLocalItem(typ : LONGINT location 'd0'; id : LONGINT location 'd1'; ident : LONGINT location 'd2'; dataSize : LONGINT location 'd3') : pLocalContextItem; syscall IFFParseBase 186;
@@ -278,25 +278,8 @@ FUNCTION WriteChunkRecords(iff : pIFFHandle location 'a0'; const buf : POINTER l
 
 Function Make_ID(str : String) : LONGINT;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitIFFPARSELibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    IFFPARSEIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-uses
-{$ifndef dont_use_openlib}
-amsgbox;
-{$endif dont_use_openlib}
-
-
 Function Make_ID(str : String) : LONGINT;
 begin
         Make_ID := (LONGINT(Ord(Str[1])) shl 24) or
@@ -306,86 +289,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of iffparse.library}
-  {$Info don't forget to use InitIFFPARSELibrary in the beginning of your program}
-
-var
-    iffparse_exit : Pointer;
-
-procedure CloseiffparseLibrary;
-begin
-    ExitProc := iffparse_exit;
-    if IFFParseBase <> nil then begin
-        CloseLibrary(IFFParseBase);
-        IFFParseBase := nil;
-    end;
-end;
-
-procedure InitIFFPARSELibrary;
-begin
-    IFFParseBase := nil;
-    IFFParseBase := OpenLibrary(IFFPARSENAME,LIBVERSION);
-    if IFFParseBase <> nil then begin
-        iffparse_exit := ExitProc;
-        ExitProc := @CloseiffparseLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open iffparse.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    IFFPARSEIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of iffparse.library}
-
-var
-    iffparse_exit : Pointer;
-
-procedure CloseiffparseLibrary;
-begin
-    ExitProc := iffparse_exit;
-    if IFFParseBase <> nil then begin
-        CloseLibrary(IFFParseBase);
-        IFFParseBase := nil;
-    end;
-end;
-
-begin
-    IFFParseBase := nil;
-    IFFParseBase := OpenLibrary(IFFPARSENAME,LIBVERSION);
-    if IFFParseBase <> nil then begin
-        iffparse_exit := ExitProc;
-        ExitProc := @CloseiffparseLibrary;
-        IFFPARSEIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open iffparse.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    IFFPARSEIsCompiledHow := 3;
-   {$Warning No autoopening of iffparse.library compiled}
-   {$Warning Make sure you open iffparse.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  IFFParseBase := OpenLibrary(IFFPARSENAME,LIBVERSION);
+finalization
+  if Assigned(IFFParseBase) then
+    CloseLibrary(IFFParseBase);
 END. (* UNIT IFFPARSE *)
 
 

+ 4 - 1
packages/amunits/src/coreunits/intuition.pas

@@ -4061,6 +4061,8 @@ CONST
  *      You should always leave the SGA_REDISPLAY flag set, since Intuition
  *      uses this processing when activating a string gadget.
  }
+var
+  IntuitionBase: PLibrary;
 
 FUNCTION ActivateGadget(gadgets : pGadget location 'a0'; window : pWindow location 'a1'; requester : pRequester location 'a2') : LongBool syscall _IntuitionBase 462;
 PROCEDURE ActivateWindow(window : pWindow location 'a0'); syscall _IntuitionBase 450;
@@ -4361,7 +4363,8 @@ begin
       UnlockPubScreen(PChar(RawByteString(name)),screen);
 end;
 
-
+initialization
+  IntuitionBase := _IntuitionBase;
 END. (* UNIT INTUITION *)
 
 

+ 6 - 40
packages/amunits/src/coreunits/keymap.pas

@@ -105,7 +105,7 @@ Const
     DP_2DINDEXMASK      = $0f;  { mask for index for 1st of two dead keys }
     DP_2DFACSHIFT       = 4;    { shift for factor for 1st of two dead keys }
 
-VAR KeymapBase : pLibrary;
+VAR KeymapBase : pLibrary = nil;
 
 const
     KEYMAPNAME : PChar = 'keymap.library';
@@ -117,50 +117,16 @@ PROCEDURE SetKeyMapDefault(keyMap : pKeyMap location 'a0'); syscall KeymapBase 0
 
 IMPLEMENTATION
 
-uses amsgbox;
-
-{$I useautoopenlib.inc}
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of keymap.library}
-
-var
-    keymap_exit : Pointer;
-
-procedure ClosekeymapLibrary;
-begin
-    ExitProc := keymap_exit;
-    if KeymapBase <> nil then begin
-        CloseLibrary(KeymapBase);
-        KeymapBase := nil;
-    end;
-end;
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-begin
-    KeymapBase := nil;
-    KeymapBase := OpenLibrary(KEYMAPNAME,LIBVERSION);
-    if KeymapBase <> nil then begin
-        keymap_exit := ExitProc;
-        ExitProc := @ClosekeymapLibrary
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open keymap.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$else}
-   {$Warning No autoopening of keymap.library compiled}
-   {$Info Make sure you open keymap.library yourself}
-{$endif use_auto_openlib}
-
-
+initialization
+  KeymapBase := OpenLibrary(KEYMAPNAME,LIBVERSION);
+finalization
+  if Assigned(KeymapBase) then
+    CloseLibrary(KeymapBase);
 END. (* UNIT KEYMAP *)
 
 

+ 6 - 94
packages/amunits/src/coreunits/layers.pas

@@ -84,7 +84,7 @@ const
 
  LAYERSNAME : PChar = 'layers.library';
 
-VAR LayersBase : pLibrary;
+VAR LayersBase : pLibrary = nil;
 
 FUNCTION BeginUpdate(l : pLayer location 'a0') : LONGINT; syscall LayersBase 078;
 FUNCTION BehindLayer(dummy : LONGINT location 'a0'; layer : pLayer location 'a1') : LONGINT; syscall LayersBase 054;
@@ -119,106 +119,18 @@ PROCEDURE UnlockLayers(li : pLayer_Info location 'a0'); syscall LayersBase 114;
 FUNCTION UpfrontLayer(dummy : LONGINT location 'a0'; layer : pLayer location 'a1') : LONGINT; syscall LayersBase 048;
 FUNCTION WhichLayer(li : pLayer_Info location 'a0'; x : LONGINT location 'd0'; y : LONGINT location 'd1') : pLayer; syscall LayersBase 132;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitLAYERSLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    LAYERSIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-uses
-{$ifndef dont_use_openlib}
-amsgbox;
-{$endif dont_use_openlib}
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of layers.library}
-  {$Info don't forget to use InitLAYERSLibrary in the beginning of your program}
-
-var
-    layers_exit : Pointer;
-
-procedure CloselayersLibrary;
-begin
-    ExitProc := layers_exit;
-    if LayersBase <> nil then begin
-        CloseLibrary(LayersBase);
-        LayersBase := nil;
-    end;
-end;
-
-procedure InitLAYERSLibrary;
-begin
-    LayersBase := nil;
-    LayersBase := OpenLibrary(LAYERSNAME,LIBVERSION);
-    if LayersBase <> nil then begin
-        layers_exit := ExitProc;
-        ExitProc := @CloselayersLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open layers.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    LAYERSIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of layers.library}
-
-var
-    layers_exit : Pointer;
-
-procedure CloselayersLibrary;
-begin
-    ExitProc := layers_exit;
-    if LayersBase <> nil then begin
-        CloseLibrary(LayersBase);
-        LayersBase := nil;
-    end;
-end;
-
-begin
-    LayersBase := nil;
-    LayersBase := OpenLibrary(LAYERSNAME,LIBVERSION);
-    if LayersBase <> nil then begin
-        layers_exit := ExitProc;
-        ExitProc := @CloselayersLibrary;
-        LAYERSIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open layers.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    LAYERSIsCompiledHow := 3;
-   {$Warning No autoopening of layers.library compiled}
-   {$Warning Make sure you open layers.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  LayersBase := OpenLibrary(LAYERSNAME,LIBVERSION);
+finalization
+  if Assigned(LayersBase) then
+    CloseLibrary(LayersBase);
 END. (* UNIT LAYERS *)
 
 

+ 6 - 96
packages/amunits/src/coreunits/locale.pas

@@ -262,7 +262,7 @@ Type
 
 { --- functions in V38 or higher (Release 2.1) --- }
 
-VAR LocaleBase : pLocaleBase;
+VAR LocaleBase : pLocaleBase = nil;
 
 const
     LOCALENAME : PChar = 'locale.library';
@@ -292,108 +292,18 @@ FUNCTION ParseDate(locale : pLocale location 'a0'; date : pDateStamp location 'a
 FUNCTION StrConvert(locale : pLocale location 'a0'; string1 : pCHAR location 'a1'; buffer : POINTER location 'a2'; bufferSize : ULONG location 'd0'; typ : ULONG location 'd1') : ULONG; syscall LocaleBase 174;
 FUNCTION StrnCmp(locale : pLocale location 'a0'; string1 : pCHAR location 'a1'; string2 : pCHAR location 'a2'; length : LONGINT location 'd0'; typ : ULONG location 'd1') : LONGINT; syscall LocaleBase 180;
 
-
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitLOCALELibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    LOCALEIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-uses
-{$ifndef dont_use_openlib}
-amsgbox;
-{$endif dont_use_openlib}
-
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of locale.library}
-  {$Info don't forget to use InitLOCALELibrary in the beginning of your program}
-
-var
-    locale_exit : Pointer;
-
-procedure CloselocaleLibrary;
-begin
-    ExitProc := locale_exit;
-    if LocaleBase <> nil then begin
-        CloseLibrary(pLibrary(LocaleBase));
-        LocaleBase := nil;
-    end;
-end;
-
-procedure InitLOCALELibrary;
-begin
-    LocaleBase := nil;
-    LocaleBase := pLocaleBase(OpenLibrary(LOCALENAME,LIBVERSION));
-    if LocaleBase <> nil then begin
-        locale_exit := ExitProc;
-        ExitProc := @CloselocaleLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open locale.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    LOCALEIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of locale.library}
-
-var
-    locale_exit : Pointer;
-
-procedure CloselocaleLibrary;
-begin
-    ExitProc := locale_exit;
-    if LocaleBase <> nil then begin
-        CloseLibrary(pLibrary(LocaleBase));
-        LocaleBase := nil;
-    end;
-end;
-
-begin
-    LocaleBase := nil;
-    LocaleBase := pLocaleBase(OpenLibrary(LOCALENAME,LIBVERSION));
-    if LocaleBase <> nil then begin
-        locale_exit := ExitProc;
-        ExitProc := @CloselocaleLibrary;
-        LOCALEIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open locale.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    LOCALEIsCompiledHow := 3;
-   {$Warning No autoopening of locale.library compiled}
-   {$Warning Make sure you open locale.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  LocaleBase := pLocaleBase(OpenLibrary(LOCALENAME,LIBVERSION));
+finalization
+  if Assigned(LocaleBase) then
+    CloseLibrary(pLibrary(LocaleBase));
 END. (* UNIT LOCALE *)
 
 

+ 6 - 92
packages/amunits/src/coreunits/lowlevel.pas

@@ -261,7 +261,7 @@ Const
 
 { --- functions in V40 or higher (Release 3.1) --- }
 
-VAR LowLevelBase : pLibrary;
+VAR LowLevelBase : pLibrary = nil;
 
 FUNCTION AddKBInt(const intRoutine : POINTER location 'a0'; const intData : POINTER location 'a1') : POINTER; syscall LowLevelBase 060;
 FUNCTION AddTimerInt(const intRoutine : POINTER location 'a0'; const  intData : POINTER location 'a1') : POINTER; syscall LowLevelBase 078;
@@ -279,104 +279,18 @@ PROCEDURE StartTimerInt(intHandle : POINTER location 'a1'; timeInterval : ULONG
 PROCEDURE StopTimerInt(intHandle : POINTER location 'a1'); syscall LowLevelBase 090;
 FUNCTION SystemControlA(const tagList : pTagItem location 'a1') : ULONG; syscall LowLevelBase 072;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitLOWLEVELLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    LOWLEVELIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of lowlevel.library}
-  {$Info don't forget to use InitLOWLEVELLibrary in the beginning of your program}
-
-var
-    lowlevel_exit : Pointer;
-
-procedure CloselowlevelLibrary;
-begin
-    ExitProc := lowlevel_exit;
-    if LowLevelBase <> nil then begin
-        CloseLibrary(LowLevelBase);
-        LowLevelBase := nil;
-    end;
-end;
-
-procedure InitLOWLEVELLibrary;
-begin
-    LowLevelBase := nil;
-    LowLevelBase := OpenLibrary(LOWLEVELNAME,LIBVERSION);
-    if LowLevelBase <> nil then begin
-        lowlevel_exit := ExitProc;
-        ExitProc := @CloselowlevelLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open lowlevel.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    LOWLEVELIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of lowlevel.library}
-
-var
-    lowlevel_exit : Pointer;
-
-procedure CloselowlevelLibrary;
-begin
-    ExitProc := lowlevel_exit;
-    if LowLevelBase <> nil then begin
-        CloseLibrary(LowLevelBase);
-        LowLevelBase := nil;
-    end;
-end;
-
-begin
-    LowLevelBase := nil;
-    LowLevelBase := OpenLibrary(LOWLEVELNAME,LIBVERSION);
-    if LowLevelBase <> nil then begin
-        lowlevel_exit := ExitProc;
-        ExitProc := @CloselowlevelLibrary;
-        LOWLEVELIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open lowlevel.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    LOWLEVELIsCompiledHow := 3;
-   {$Warning No autoopening of lowlevel.library compiled}
-   {$Warning Make sure you open lowlevel.library yourself}
-{$endif dont_use_openlib}
-
+initialization
+  LowLevelBase := OpenLibrary(LOWLEVELNAME,LIBVERSION);
+finalization
+  if Assigned(LowLevelBase) then
+    CloseLibrary(LowLevelBase);
 END. (* UNIT LOWLEVEL *)
 
 

+ 6 - 94
packages/amunits/src/coreunits/nonvolatile.pas

@@ -77,7 +77,7 @@ const
 
 { --- functions in V40 or higher (Release 3.1) --- }
 
-VAR NVBase : pLibrary;
+VAR NVBase : pLibrary = nil;
 
 const
     NONVOLATILENAME : PChar = 'nonvolatile.library';
@@ -90,104 +90,16 @@ FUNCTION GetNVList(const appName : pCHAR location 'a0'; killRequesters : LONGINT
 FUNCTION SetNVProtection(const appName : pCHAR location 'a0'; const itemName : pCHAR location 'a1'; mask : LONGINT location 'd2'; killRequesters : LONGINT location 'd1') : LongBool; syscall NVBase 066;
 FUNCTION StoreNV(const appName : pCHAR location 'a0'; const itemName : pCHAR location 'a1'; const data : POINTER location 'a2'; length : ULONG location 'd0'; killRequesters : LONGINT location 'd1') : WORD; syscall NVBase 042;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitNONVOLATILELibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    NONVOLATILEIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of nonvolatile.library}
-  {$Info don't forget to use InitNONVOLATILELibrary in the beginning of your program}
-
-var
-    nonvolatile_exit : Pointer;
-
-procedure ClosenonvolatileLibrary;
-begin
-    ExitProc := nonvolatile_exit;
-    if NVBase <> nil then begin
-        CloseLibrary(NVBase);
-        NVBase := nil;
-    end;
-end;
-
-procedure InitNONVOLATILELibrary;
-begin
-    NVBase := nil;
-    NVBase := OpenLibrary(NONVOLATILENAME,LIBVERSION);
-    if NVBase <> nil then begin
-        nonvolatile_exit := ExitProc;
-        ExitProc := @ClosenonvolatileLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open nonvolatile.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    NONVOLATILEIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of nonvolatile.library}
-
-var
-    nonvolatile_exit : Pointer;
-
-procedure ClosenonvolatileLibrary;
-begin
-    ExitProc := nonvolatile_exit;
-    if NVBase <> nil then begin
-        CloseLibrary(NVBase);
-        NVBase := nil;
-    end;
-end;
-
-begin
-    NVBase := nil;
-    NVBase := OpenLibrary(NONVOLATILENAME,LIBVERSION);
-    if NVBase <> nil then begin
-        nonvolatile_exit := ExitProc;
-        ExitProc := @ClosenonvolatileLibrary;
-        NONVOLATILEIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open nonvolatile.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    NONVOLATILEIsCompiledHow := 3;
-   {$Warning No autoopening of nonvolatile.library compiled}
-   {$Warning Make sure you open nonvolatile.library yourself}
-{$endif dont_use_openlib}
-
-
-
+initialization
+  NVBase := OpenLibrary(NONVOLATILENAME,LIBVERSION);
+finalization
+  if Assigned(NVBase) then
+    CloseLibrary(NVBase);
 END. (* UNIT NONVOLATILE *)

+ 6 - 93
packages/amunits/src/coreunits/realtime.pas

@@ -232,7 +232,7 @@ const
 
 {*--- functions in V37 or higher (Release 2.04) ---*}
 
-VAR RealTimeBase : pRealTimeBase;
+VAR RealTimeBase : pRealTimeBase = nil;
 
 const
     REALTIMENAME : PChar = 'realtime.library';
@@ -248,103 +248,16 @@ FUNCTION SetConductorState(player : pPlayer location 'a0'; state : ULONG locatio
 FUNCTION SetPlayerAttrsA(player : pPlayer location 'a0'; const tagList : pTagItem location 'a1') : WordBool; syscall RealTimeBase 054;
 PROCEDURE UnlockRealTime(lock : POINTER location 'a0'); syscall RealTimeBase 036;
 
-
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitREALTIMELibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    REALTIMEIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of realtime.library}
-  {$Info don't forget to use InitREALTIMELibrary in the beginning of your program}
-
-var
-    realtime_exit : Pointer;
-
-procedure CloserealtimeLibrary;
-begin
-    ExitProc := realtime_exit;
-    if RealTimeBase <> nil then begin
-        CloseLibrary(pLibrary(RealTimeBase));
-        RealTimeBase := nil;
-    end;
-end;
-
-procedure InitREALTIMELibrary;
-begin
-    RealTimeBase := nil;
-    RealTimeBase := pRealTimeBase(OpenLibrary(REALTIMENAME,LIBVERSION));
-    if RealTimeBase <> nil then begin
-        realtime_exit := ExitProc;
-        ExitProc := @CloserealtimeLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open realtime.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    REALTIMEIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of realtime.library}
-
-var
-    realtime_exit : Pointer;
-
-procedure CloserealtimeLibrary;
-begin
-    ExitProc := realtime_exit;
-    if RealTimeBase <> nil then begin
-        CloseLibrary(pLibrary(RealTimeBase));
-        RealTimeBase := nil;
-    end;
-end;
-
-begin
-    RealTimeBase := nil;
-    RealTimeBase := pRealTimeBase(OpenLibrary(REALTIMENAME,LIBVERSION));
-    if RealTimeBase <> nil then begin
-        realtime_exit := ExitProc;
-        ExitProc := @CloserealtimeLibrary;
-        REALTIMEIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open realtime.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    REALTIMEIsCompiledHow := 3;
-   {$Warning No autoopening of realtime.library compiled}
-   {$Warning Make sure you open realtime.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  RealTimeBase := pRealTimeBase(OpenLibrary(REALTIMENAME,LIBVERSION));
+finalization
+  if Assigned(RealTimeBase) then
+    CloseLibrary(pLibrary(RealTimeBase));
 END. (* UNIT REALTIME *)

+ 6 - 94
packages/amunits/src/coreunits/rexx.pas

@@ -478,7 +478,7 @@ Const
     CTF_LOWER   = 128;
 
 
-VAR RexxSysBase : pLibrary;
+VAR RexxSysBase : pLibrary = nil;
 
 const
     REXXSYSLIBNAME : PChar = 'rexxsyslib.library';
@@ -496,24 +496,8 @@ PROCEDURE UnlockRexxBase(resource : ULONG location 'd0'); syscall RexxSysBase 45
 
 FUNCTION CreateArgstring(const argstring : string; length : ULONG) : pCHAR;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitREXXSYSLIBLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    REXXSYSLIBIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses
-  amsgbox;
-{$endif dont_use_openlib}
-
 FUNCTION CreateArgstring(const argstring : string; length : ULONG) : pCHAR;
 begin
        CreateArgstring := CreateArgstring(PChar(RawByteString(argstring)),length);
@@ -521,86 +505,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of rexxsyslib.library}
-  {$Info don't forget to use InitREXXSYSLIBLibrary in the beginning of your program}
-
-var
-    rexxsyslib_exit : Pointer;
-
-procedure CloserexxsyslibLibrary;
-begin
-    ExitProc := rexxsyslib_exit;
-    if RexxSysBase <> nil then begin
-        CloseLibrary(RexxSysBase);
-        RexxSysBase := nil;
-    end;
-end;
-
-procedure InitREXXSYSLIBLibrary;
-begin
-    RexxSysBase := nil;
-    RexxSysBase := OpenLibrary(REXXSYSLIBNAME,LIBVERSION);
-    if RexxSysBase <> nil then begin
-        rexxsyslib_exit := ExitProc;
-        ExitProc := @CloserexxsyslibLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open rexxsyslib.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    REXXSYSLIBIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of rexxsyslib.library}
-
-var
-    rexxsyslib_exit : Pointer;
-
-procedure CloserexxsyslibLibrary;
-begin
-    ExitProc := rexxsyslib_exit;
-    if RexxSysBase <> nil then begin
-        CloseLibrary(RexxSysBase);
-        RexxSysBase := nil;
-    end;
-end;
-
-begin
-    RexxSysBase := nil;
-    RexxSysBase := OpenLibrary(REXXSYSLIBNAME,LIBVERSION);
-    if RexxSysBase <> nil then begin
-        rexxsyslib_exit := ExitProc;
-        ExitProc := @CloserexxsyslibLibrary;
-        REXXSYSLIBIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open rexxsyslib.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    REXXSYSLIBIsCompiledHow := 3;
-   {$Warning No autoopening of rexxsyslib.library compiled}
-   {$Warning Make sure you open rexxsyslib.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  RexxSysBase := OpenLibrary(REXXSYSLIBNAME,LIBVERSION);
+finalization
+  if Assigned(RexxSysBase) then
+    CloseLibrary(RexxSysBase);
 END. (* UNIT REXXSYSLIB *)
 
 

+ 6 - 93
packages/amunits/src/coreunits/translator.pas

@@ -36,110 +36,23 @@ Const
     TR_NoMem            = -2;   { Can't allocate memory }
     TR_MakeBad          = -4;   { Error in MakeLibrary call }
 
-VAR TranslatorBase : pLibrary;
+VAR TranslatorBase : pLibrary = nil;
 
 const
     TRANSLATORNAME : PChar = 'translator.library';
 
 FUNCTION Translate(const inputString : pCHAR location 'a0'; inputLength : LONGINT location 'd0'; outputBuffer : pCHAR location 'a1'; bufferSize : LONGINT location 'd1') : LONGINT; syscall TranslatorBase 030;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitTRANSLATORLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    TRANSLATORIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of translator.library}
-  {$Info don't forget to use InitTRANSLATORLibrary in the beginning of your program}
-
-var
-    translator_exit : Pointer;
-
-procedure ClosetranslatorLibrary;
-begin
-    ExitProc := translator_exit;
-    if TranslatorBase <> nil then begin
-        CloseLibrary(TranslatorBase);
-        TranslatorBase := nil;
-    end;
-end;
-
-procedure InitTRANSLATORLibrary;
-begin
-    TranslatorBase := nil;
-    TranslatorBase := OpenLibrary(TRANSLATORNAME,LIBVERSION);
-    if TranslatorBase <> nil then begin
-        translator_exit := ExitProc;
-        ExitProc := @ClosetranslatorLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open translator.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    TRANSLATORIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of translator.library}
-
-var
-    translator_exit : Pointer;
-
-procedure ClosetranslatorLibrary;
-begin
-    ExitProc := translator_exit;
-    if TranslatorBase <> nil then begin
-        CloseLibrary(TranslatorBase);
-        TranslatorBase := nil;
-    end;
-end;
-
-begin
-    TranslatorBase := nil;
-    TranslatorBase := OpenLibrary(TRANSLATORNAME,LIBVERSION);
-    if TranslatorBase <> nil then begin
-        translator_exit := ExitProc;
-        ExitProc := @ClosetranslatorLibrary;
-        TRANSLATORIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open translator.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    TRANSLATORIsCompiledHow := 3;
-   {$Warning No autoopening of translator.library compiled}
-   {$Warning Make sure you open translator.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  TranslatorBase := OpenLibrary(TRANSLATORNAME,LIBVERSION);
+finalization
+  if Assigned(TranslatorBase) then
+    CloseLibrary(TranslatorBase);
 END. (* UNIT TRANSLATOR *)

+ 5 - 1
packages/amunits/src/coreunits/utility.pas

@@ -336,6 +336,9 @@ Type
     ub_Reserved  : Byte;
  END;
 
+var
+  UtilityBase: pUtilityBase;
+
 function AddNamedObject(nameSpace : pNamedObject location 'a0';obj : pNamedObject location 'a1') : LongBool; syscall _UtilityBase 222;
 function AllocateTagItems(num : ULONG location 'd0') : pTagItem; syscall _UtilityBase 066;
 function AllocNamedObjectA(const name : STRPTR location 'a0';const TagList : pTagItem location 'a1') : pNamedObject; syscall _UtilityBase 228;
@@ -429,5 +432,6 @@ begin
        Strnicmp := Strnicmp(PChar(RawbyteString(string1)),PChar(RawbyteString(string2)),length);
 end;
 
-
+initialization
+  UtilityBase := _UtilityBase;
 end.

+ 6 - 94
packages/amunits/src/coreunits/workbench.pas

@@ -848,7 +848,7 @@ type
     WORKBENCHNAME : PChar  = 'workbench.library';
 
 VAR
-    WorkbenchBase : pLibrary;
+    WorkbenchBase : pLibrary = nil;
 
 FUNCTION AddAppIconA(id : ULONG location 'd0'; userdata : ULONG location 'd1'; text_ : pCHAR location 'a0'; msgport : pMsgPort location 'a1'; lock : pFileLock location 'a2'; diskobj : pDiskObject location 'a3'; const taglist : pTagItem location 'a4') : pAppIcon; syscall WorkbenchBase 060;
 FUNCTION AddAppMenuItemA(id : ULONG location 'd0'; userdata : ULONG location 'd1'; text_ : pCHAR location 'a0'; msgport : pMsgPort location 'a1'; const taglist : pTagItem location 'a2') : pAppMenuItem; syscall WorkbenchBase 072;
@@ -877,24 +877,8 @@ FUNCTION MakeWorkbenchObjectVisibleA(const name : RawByteString;const tags : pTa
 FUNCTION OpenWorkbenchObjectA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
 FUNCTION WorkbenchControlA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
 
-{Here we read how to compile this unit}
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitWBLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    WBIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses
-  amsgbox;
-{$endif dont_use_openlib}
-
 FUNCTION AddAppIconA(id : ULONG; userdata : ULONG; const text_ : RawByteString; msgport : pMsgPort; lock : pFileLock; diskobj : pDiskObject;const taglist : pTagItem) : pAppIcon;
 begin
        AddAppIconA := AddAppIconA(id,userdata,PChar(text_),msgport,lock,diskobj,taglist);
@@ -937,84 +921,12 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of workbench.library}
-  {$Info don't forget to use InitWBLibrary in the beginning of your program}
-
-var
-    wb_exit : Pointer;
-
-procedure ClosewbLibrary;
-begin
-    ExitProc := wb_exit;
-    if WorkbenchBase <> nil then begin
-        CloseLibrary(WorkbenchBase);
-        WorkbenchBase := nil;
-    end;
-end;
-
-procedure InitWBLibrary;
-begin
-    WorkbenchBase := nil;
-    WorkbenchBase := OpenLibrary(WORKBENCHNAME,LIBVERSION);
-    if WorkbenchBase <> nil then begin
-        wb_exit := ExitProc;
-        ExitProc := @ClosewbLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open workbench.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    WBIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of workbench.library}
-
-var
-    wb_exit : Pointer;
-
-procedure ClosewbLibrary;
-begin
-    ExitProc := wb_exit;
-    if WorkbenchBase <> nil then begin
-        CloseLibrary(WorkbenchBase);
-        WorkbenchBase := nil;
-    end;
-end;
-
-begin
-    WorkbenchBase := nil;
-    WorkbenchBase := OpenLibrary(WORKBENCHNAME,LIBVERSION);
-    if WorkbenchBase <> nil then begin
-        wb_exit := ExitProc;
-        ExitProc := @ClosewbLibrary;
-        WBIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open workbench.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    WBIsCompiledHow := 3;
-   {$Warning No autoopening of workbench.library compiled}
-   {$Warning Make sure you open workbench.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  WorkbenchBase := OpenLibrary(WORKBENCHNAME,LIBVERSION);
+finalization
+  if Assigned(WorkbenchBase) then
+    CloseLibrary(WorkbenchBase);
 END. (* UNIT WB *)

+ 6 - 89
packages/amunits/src/otherlibs/ahi.pas

@@ -37,7 +37,7 @@ INTERFACE
 
 USES Exec,utility;
 
-VAR AHIBase : pLibrary;
+VAR AHIBase : pLibrary = nil;
 
 {
         $VER: ahi.h 4.2 (27.4.97)
@@ -532,21 +532,9 @@ FUNCTION AHI_ControlAudio(AudioCtrl : pAHIAudioCtrl; const tagList : Array Of Co
 FUNCTION AHI_GetAudioAttrs(ID : longword; Audioctrl : pAHIAudioCtrl; const tagList : Array Of Const) : BOOLEAN;
 PROCEDURE AHI_Play(Audioctrl : pAHIAudioCtrl; const tagList : Array Of Const);
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitAHILibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    AHIIsCompiledHow : longint;
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
 tagsarray;
 
 {
@@ -589,85 +577,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of ahi.library}
-  {$Info don't forget to use InitAHILibrary in the beginning of your program}
-
-var
-    ahi_exit : Pointer;
-
-procedure CloseahiLibrary;
-begin
-    ExitProc := ahi_exit;
-    if AHIBase <> nil then begin
-        CloseLibrary(AHIBase);
-        AHIBase := nil;
-    end;
-end;
-
-procedure InitAHILibrary;
-begin
-    AHIBase := nil;
-    AHIBase := OpenLibrary(AHINAME,LIBVERSION);
-    if AHIBase <> nil then begin
-        ahi_exit := ExitProc;
-        ExitProc := @CloseahiLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open ahi.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    AHIIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of ahi.library}
-
-var
-    ahi_exit : Pointer;
-
-procedure CloseahiLibrary;
-begin
-    ExitProc := ahi_exit;
-    if AHIBase <> nil then begin
-        CloseLibrary(AHIBase);
-        AHIBase := nil;
-    end;
-end;
-
-begin
-    AHIBase := nil;
-    AHIBase := OpenLibrary(AHINAME,LIBVERSION);
-    if AHIBase <> nil then begin
-        ahi_exit := ExitProc;
-        ExitProc := @CloseahiLibrary;
-        AHIIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open ahi.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    AHIIsCompiledHow := 3;
-   {$Warning No autoopening of ahi.library compiled}
-   {$Warning Make sure you open ahi.library yourself}
-{$endif dont_use_openlib}
-
+initialization
+  AHIBase := OpenLibrary(AHINAME,LIBVERSION);
+finalization
+  if Assigned(AHIBase) then
+    CloseLibrary(AHIBase);
 END. (* UNIT AHI *)
 
 

+ 21 - 314
packages/amunits/src/otherlibs/ahi_sub.pas

@@ -136,333 +136,40 @@ USES Exec, ahi, utility;
 
 
 
-VAR AHIsubBase : pLibrary;
+VAR AHIsubBase : pLibrary = nil;
 
 const
     AHI_SUBNAME : PChar = 'ahi_sub.library';
 
 
-FUNCTION AHIsub_AllocAudio(tagList : pTagItem; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-PROCEDURE AHIsub_Disable(AudioCtrl : pAHIAudioCtrlDrv);
-PROCEDURE AHIsub_Enable(AudioCtrl : pAHIAudioCtrlDrv);
-PROCEDURE AHIsub_FreeAudio(AudioCtrl : pAHIAudioCtrlDrv);
-FUNCTION AHIsub_GetAttr(Attribute : longword; Argument : LONGINT; d2arg : LONGINT; tagList : pTagItem; AudioCtrl : pAHIAudioCtrlDrv) : LONGINT;
-FUNCTION AHIsub_HardwareControl(Attribute : longword; Argument : LONGINT; AudioCtrl : pAHIAudioCtrlDrv) : LONGINT;
-FUNCTION AHIsub_LoadSound(Sound : WORD; _Type : longword; Info : POINTER; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-FUNCTION AHIsub_SetEffect(Effect : POINTER; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-FUNCTION AHIsub_SetFreq(Channel : WORD; Freq : longword; AudioCtrl : pAHIAudioCtrlDrv; Flags : longword) : longword;
-FUNCTION AHIsub_SetSound(Channel : WORD; Sound : WORD; Offset : longword; Length : LONGINT; AudioCtrl : pAHIAudioCtrlDrv; Flags : longword) : longword;
-FUNCTION AHIsub_SetVol(Channel : WORD; Volume : LONGINT; Pan : LONGINT; AudioCtrl : pAHIAudioCtrlDrv; Flags : longword) : longword;
-FUNCTION AHIsub_Start(Flags : longword; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-FUNCTION AHIsub_Stop(Flags : longword; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-FUNCTION AHIsub_UnloadSound(Sound : WORD; Audioctrl : pAHIAudioCtrlDrv) : longword;
-FUNCTION AHIsub_Update(Flags : longword; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitAHI_SUBLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    AHI_SUBIsCompiledHow : longint;
+FUNCTION AHIsub_AllocAudio(tagList : pTagItem location 'a1'; AudioCtrl : pAHIAudioCtrlDrv location 'a2') : longword; syscall AHIsubBase 30;
+PROCEDURE AHIsub_Disable(AudioCtrl : pAHIAudioCtrlDrv location 'a2'); syscall AHIsubBase 42;
+PROCEDURE AHIsub_Enable(AudioCtrl : pAHIAudioCtrlDrv location 'a2'); syscall AHIsubBase 48;
+PROCEDURE AHIsub_FreeAudio(AudioCtrl : pAHIAudioCtrlDrv location 'a2'); syscall AHIsubBase 36;
+FUNCTION AHIsub_GetAttr(Attribute : longword location 'd0'; Argument : LONGINT location 'd1'; d2arg : LONGINT location 'd2'; tagList : pTagItem location 'a1'; AudioCtrl : pAHIAudioCtrlDrv location 'a2') : LONGINT; syscall AHIsubBase 108;
+FUNCTION AHIsub_HardwareControl(Attribute : longword location 'd0'; Argument : LONGINT location 'd1'; AudioCtrl : pAHIAudioCtrlDrv location 'a2') : LONGINT; syscall AHIsubBase 114;
+FUNCTION AHIsub_LoadSound(Sound : WORD location 'd0'; _Type : longword location 'd1'; Info : POINTER location 'a0'; AudioCtrl : pAHIAudioCtrlDrv location 'a2') : longword; syscall AHIsubBase 96;
+FUNCTION AHIsub_SetEffect(Effect : POINTER location 'a0'; AudioCtrl : pAHIAudioCtrlDrv location 'a2') : longword; syscall AHIsubBase 90;
+FUNCTION AHIsub_SetFreq(Channel : WORD location 'd0'; Freq : longword location 'd1'; AudioCtrl : pAHIAudioCtrlDrv location 'a2'; Flags : longword location 'd2') : longword; syscall AHIsubBase 78;
+FUNCTION AHIsub_SetSound(Channel : WORD location 'd0'; Sound : WORD location 'd1'; Offset : longword location 'd2'; Length : LONGINT location 'd3'; AudioCtrl : pAHIAudioCtrlDrv location 'a2'; Flags : longword location 'd4') : longword; syscall AHIsubBase 84;
+FUNCTION AHIsub_SetVol(Channel : WORD location 'd0'; Volume : LONGINT location 'd1'; Pan : LONGINT location 'd2'; AudioCtrl : pAHIAudioCtrlDrv location 'a2'; Flags : longword location 'd3') : longword; syscall AHIsubBase 72;
+FUNCTION AHIsub_Start(Flags : longword location 'd0'; AudioCtrl : pAHIAudioCtrlDrv location 'a2') : longword; syscall AHIsubBase 54;
+FUNCTION AHIsub_Stop(Flags : longword location 'd0'; AudioCtrl : pAHIAudioCtrlDrv location 'a2') : longword; syscall AHIsubBase 66;
+FUNCTION AHIsub_UnloadSound(Sound : WORD location 'd0'; Audioctrl : pAHIAudioCtrlDrv location 'a2') : longword; syscall AHIsubBase 102;
+FUNCTION AHIsub_Update(Flags : longword location 'd0'; AudioCtrl : pAHIAudioCtrlDrv location 'a2') : longword; syscall AHIsubBase 60;
 
 IMPLEMENTATION
 
-uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
-
-
-FUNCTION AHIsub_AllocAudio(tagList : pTagItem; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L tagList,A1
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE AHIsub_Disable(AudioCtrl : pAHIAudioCtrlDrv);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE AHIsub_Enable(AudioCtrl : pAHIAudioCtrlDrv);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE AHIsub_FreeAudio(AudioCtrl : pAHIAudioCtrlDrv);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION AHIsub_GetAttr(Attribute : longword; Argument : LONGINT; d2arg : LONGINT; tagList : pTagItem; AudioCtrl : pAHIAudioCtrlDrv) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Attribute,D0
-        MOVE.L  Argument,D1
-        MOVE.L  d2arg,D2
-        MOVEA.L tagList,A1
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -108(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_HardwareControl(Attribute : longword; Argument : LONGINT; AudioCtrl : pAHIAudioCtrlDrv) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Attribute,D0
-        MOVE.L  Argument,D1
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -114(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_LoadSound(Sound : WORD; _Type : longword; Info : POINTER; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Sound,D0
-        MOVE.L  _Type,D1
-        MOVEA.L Info,A0
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -096(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_SetEffect(Effect : POINTER; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L Effect,A0
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -090(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_SetFreq(Channel : WORD; Freq : longword; AudioCtrl : pAHIAudioCtrlDrv; Flags : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Channel,D0
-        MOVE.L  Freq,D1
-        MOVEA.L AudioCtrl,A2
-        MOVE.L  Flags,D2
-        MOVEA.L AHIsubBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_SetSound(Channel : WORD; Sound : WORD; Offset : longword; Length : LONGINT; AudioCtrl : pAHIAudioCtrlDrv; Flags : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Channel,D0
-        MOVE.L  Sound,D1
-        MOVE.L  Offset,D2
-        MOVE.L  Length,D3
-        MOVEA.L AudioCtrl,A2
-        MOVE.L  Flags,D4
-        MOVEA.L AHIsubBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_SetVol(Channel : WORD; Volume : LONGINT; Pan : LONGINT; AudioCtrl : pAHIAudioCtrlDrv; Flags : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Channel,D0
-        MOVE.L  Volume,D1
-        MOVE.L  Pan,D2
-        MOVEA.L AudioCtrl,A2
-        MOVE.L  Flags,D3
-        MOVEA.L AHIsubBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_Start(Flags : longword; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Flags,D0
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_Stop(Flags : longword; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Flags,D0
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_UnloadSound(Sound : WORD; Audioctrl : pAHIAudioCtrlDrv) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Sound,D0
-        MOVEA.L Audioctrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -102(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AHIsub_Update(Flags : longword; AudioCtrl : pAHIAudioCtrlDrv) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Flags,D0
-        MOVEA.L AudioCtrl,A2
-        MOVEA.L AHIsubBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of ahi_sub.library}
-  {$Info don't forget to use InitAHI_SUBLibrary in the beginning of your program}
-
-var
-    ahi_sub_exit : Pointer;
-
-procedure Closeahi_subLibrary;
-begin
-    ExitProc := ahi_sub_exit;
-    if AHIsubBase <> nil then begin
-        CloseLibrary(AHIsubBase);
-        AHIsubBase := nil;
-    end;
-end;
-
-procedure InitAHI_SUBLibrary;
-begin
-    AHIsubBase := nil;
-    AHIsubBase := OpenLibrary(AHI_SUBNAME,LIBVERSION);
-    if AHIsubBase <> nil then begin
-        ahi_sub_exit := ExitProc;
-        ExitProc := @Closeahi_subLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open ahi_sub.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    AHI_SUBIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of ahi_sub.library}
-
-var
-    ahi_sub_exit : Pointer;
-
-procedure Closeahi_subLibrary;
-begin
-    ExitProc := ahi_sub_exit;
-    if AHIsubBase <> nil then begin
-        CloseLibrary(AHIsubBase);
-        AHIsubBase := nil;
-    end;
-end;
-
-begin
-    AHIsubBase := nil;
-    AHIsubBase := OpenLibrary(AHI_SUBNAME,LIBVERSION);
-    if AHIsubBase <> nil then begin
-        ahi_sub_exit := ExitProc;
-        ExitProc := @Closeahi_subLibrary;
-        AHI_SUBIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open ahi_sub.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    AHI_SUBIsCompiledHow := 3;
-   {$Warning No autoopening of ahi_sub.library compiled}
-   {$Warning Make sure you open ahi_sub.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  AHIsubBase := OpenLibrary(AHI_SUBNAME,LIBVERSION);
+finalization
+  if Assigned(AHIsubBase) then
+    CloseLibrary(AHIsubBase);
 END. (* UNIT AHI_SUB *)
 
 

+ 51 - 712
packages/amunits/src/otherlibs/amarquee.pas

@@ -202,51 +202,51 @@ uses exec, utility;
   { (struct QSharedMessagePort  mp) A shared message port created with QCreateSharedMessagePort()  }
      QSESSION_SHAREDMSGPORT = $b0000002;
 
-VAR AMarqueeBase : pLibrary;
-
-FUNCTION QFreeSession(session : pQSession) : LONGINT;
-FUNCTION QDebugOp(session : pQSession; string_ : pCHar) : LONGINT;
-FUNCTION QGetOp(session : pQSession; path : pCHar; maxBytes : LONGINT) : LONGINT;
-FUNCTION QDeleteOp(session : pQSession; path : pCHar) : LONGINT;
-FUNCTION QRenameOp(session : pQSession; path : pCHar; label_ : pCHar) : LONGINT;
-FUNCTION QSubscribeOp(session : pQSession; path : pCHar; maxBytes : LONGINT) : LONGINT;
-FUNCTION QSetOp(session : pQSession; path : pCHar; buf : POINTER; len : ULONG) : LONGINT;
-FUNCTION QClearSubscriptionsOp(session : pQSession; which : LONGINT) : LONGINT;
-FUNCTION QPingOp(session : pQSession) : LONGINT;
-FUNCTION QInfoOp(session : pQSession) : LONGINT;
-FUNCTION QSetAccessOp(session : pQSession; hosts : pCHar) : LONGINT;
-PROCEDURE FreeQMessage(session : pQSession; qmsg : pQMessage);
-FUNCTION QGo(session : pQSession; sync : ULONG) : LONGINT;
-FUNCTION QStreamOp(session : pQSession; path : pCHar; buf : POINTER; len : ULONG) : LONGINT;
-FUNCTION QSetMessageAccessOp(session : pQSession; access : pCHar; maxbytes : LONGINT) : LONGINT;
-FUNCTION QMessageOp(session : pQSession; hosts : pCHar; buffer : POINTER; len : ULONG) : LONGINT;
-FUNCTION QNumQueuedPackets(session : pQSession) : ULONG;
-FUNCTION QNumQueuedBytes(session : pQSession) : ULONG;
-FUNCTION QErrorName(session : LONGINT) : pCHar;
-FUNCTION QRequestPrivilegesOp(session : pQSession; privBits : ULONG) : LONGINT;
-FUNCTION QReleasePrivilegesOp(session : pQSession; privBits : ULONG) : LONGINT;
-FUNCTION QKillClientsOp(session : pQSession; hosts : pCHar) : LONGINT;
-FUNCTION QSetParameterOp(session : pQSession; paramName : pCHar; newValue : pCHar) : LONGINT;
-FUNCTION QGetParameterOp(session : pQSession; paramName : pCHar) : LONGINT;
-FUNCTION QSysMessageOp(session : pQSession; hosts : pCHar; message : pCHar) : LONGINT;
-FUNCTION QGetAndSubscribeOp(session : pQSession; path : pCHar; maxBytes : LONGINT) : LONGINT;
-FUNCTION QDetachSession(session : pQSession; flags : ULONG) : BOOLEAN;
-FUNCTION QReattachSession(session : pQSession; flags : ULONG) : BOOLEAN;
-FUNCTION QNewSocketSession(host : pCHar; port : LONGINT; tags : pTagItem) : pQSession;
-FUNCTION QSendRawOp(session : pQSession; buf : POINTER; len : ULONG) : LONGINT;
-FUNCTION QNewSocketSessionAsync(host : pCHar; port : LONGINT; tags : pTagItem) : pQSession;
-FUNCTION QNewSocketServerSession( port : pLONGINT; tags : pTagItem) : pQSession;
-FUNCTION QSetKeyAccessOp(session : pQSession; path : pCHar; hosts : pCHar) : LONGINT;
-FUNCTION QGetHostName(session : pQSession) : pCHar;
-FUNCTION QGetProgName(session : pQSession) : pCHar;
-PROCEDURE QSetMaxRawBufSize(session : pQSession; maxBufSize : ULONG);
-FUNCTION QNewSession(host : pCHar; port : LONGINT; name : pCHar; taglist : pTagItem) : pQSession;
-FUNCTION QNewSessionAsync(host : pCHar; port : LONGINT; name : pCHar; taglist : pTagItem) : pQSession;
-FUNCTION QNewHostSession(hostnames : pCHar; port : pLONGINT; names : pCHar; taglist : pTagItem) : pQSession;
-FUNCTION QNewServerSession(hostNames : pCHar; progNames : pCHar; taglist : pTagItem) : pQSession;
-FUNCTION QCreateSharedMessagePort : pQSharedMessagePort;
-PROCEDURE QDeleteSharedMessagePort(mp : pQSharedMessagePort);
-FUNCTION QGetLocalIP(session : pQSession) : pCHAR;
+VAR AMarqueeBase : pLibrary = nil;
+
+FUNCTION QFreeSession(session : pQSession location 'a0') : LONGINT; syscall AMarqueeBase 36;
+FUNCTION QDebugOp(session : pQSession location 'a0'; string_ : pCHar location 'a1') : LONGINT; syscall AMarqueeBase 42;
+FUNCTION QGetOp(session : pQSession location 'a0'; path : pCHar location 'a1'; maxBytes : LONGINT location 'd0') : LONGINT; syscall AMarqueeBase 48;
+FUNCTION QDeleteOp(session : pQSession location 'a0'; path : pCHar location 'a1') : LONGINT; syscall AMarqueeBase 54;
+FUNCTION QRenameOp(session : pQSession location 'a0'; path : pCHar location 'a1'; label_ : pCHar location 'd0') : LONGINT; syscall AMarqueeBase 60;
+FUNCTION QSubscribeOp(session : pQSession location 'a0'; path : pCHar location 'a1'; maxBytes : LONGINT location 'd0') : LONGINT; syscall AMarqueeBase 66;
+FUNCTION QSetOp(session : pQSession location 'a0'; path : pCHar location 'a1'; buf : POINTER location 'd0'; len : ULONG location 'd1') : LONGINT; syscall AMarqueeBase 72;
+FUNCTION QClearSubscriptionsOp(session : pQSession location 'a0'; which : LONGINT location 'd0') : LONGINT; syscall AMarqueeBase 78;
+FUNCTION QPingOp(session : pQSession location 'a0') : LONGINT; syscall AMarqueeBase 84;
+FUNCTION QInfoOp(session : pQSession location 'a0') : LONGINT; syscall AMarqueeBase 90;
+FUNCTION QSetAccessOp(session : pQSession location 'a0'; hosts : pCHar location 'a1') : LONGINT; syscall AMarqueeBase 96;
+PROCEDURE FreeQMessage(session : pQSession location 'a0'; qmsg : pQMessage location 'a1'); syscall AMarqueeBase 102;
+FUNCTION QGo(session : pQSession location 'a0'; sync : ULONG location 'd0') : LONGINT; syscall AMarqueeBase 108;
+FUNCTION QStreamOp(session : pQSession location 'a0'; path : pCHar location 'a1'; buf : POINTER location 'd0'; len : ULONG location 'd1') : LONGINT; syscall AMarqueeBase 120;
+FUNCTION QSetMessageAccessOp(session : pQSession location 'a0'; access : pCHar location 'a1'; maxbytes : LONGINT location 'd0') : LONGINT; syscall AMarqueeBase 132;
+FUNCTION QMessageOp(session : pQSession location 'a0'; hosts : pCHar location 'a1'; buffer : POINTER location 'd0'; len : ULONG location 'd1') : LONGINT; syscall AMarqueeBase 138;
+FUNCTION QNumQueuedPackets(session : pQSession location 'a0') : ULONG; syscall AMarqueeBase 150;
+FUNCTION QNumQueuedBytes(session : pQSession location 'a0') : ULONG; syscall AMarqueeBase 156;
+FUNCTION QErrorName(session : LONGINT location 'd0') : pCHar; syscall AMarqueeBase 162;
+FUNCTION QRequestPrivilegesOp(session : pQSession location 'a0'; privBits : ULONG location 'd0') : LONGINT; syscall AMarqueeBase 168;
+FUNCTION QReleasePrivilegesOp(session : pQSession location 'a0'; privBits : ULONG location 'd0') : LONGINT; syscall AMarqueeBase 174;
+FUNCTION QKillClientsOp(session : pQSession location 'a0'; hosts : pCHar location 'a1') : LONGINT; syscall AMarqueeBase 180;
+FUNCTION QSetParameterOp(session : pQSession location 'a0'; paramName : pCHar location 'a1'; newValue : pCHar location 'd0') : LONGINT; syscall AMarqueeBase 186;
+FUNCTION QGetParameterOp(session : pQSession location 'a0'; paramName : pCHar location 'a1') : LONGINT; syscall AMarqueeBase 192;
+FUNCTION QSysMessageOp(session : pQSession location 'a0'; hosts : pCHar location 'a1'; message : pCHar location 'd0') : LONGINT; syscall AMarqueeBase 198;
+FUNCTION QGetAndSubscribeOp(session : pQSession location 'a0'; path : pCHar location 'a1'; maxBytes : LONGINT location 'd0') : LONGINT; syscall AMarqueeBase 210;
+FUNCTION QDetachSession(session : pQSession location 'a0'; flags : ULONG location 'd0') : BOOLEAN; syscall AMarqueeBase 216;
+FUNCTION QReattachSession(session : pQSession location 'a0'; flags : ULONG location 'd0') : BOOLEAN; syscall AMarqueeBase 222;
+FUNCTION QNewSocketSession(host : pCHar location 'a0'; port : LONGINT location 'd0'; tags : pTagItem location 'a1') : pQSession; syscall AMarqueeBase 228;
+FUNCTION QSendRawOp(session : pQSession location 'a0'; buf : POINTER location 'a1'; len : ULONG location 'd0') : LONGINT; syscall AMarqueeBase 234;
+FUNCTION QNewSocketSessionAsync(host : pCHar location 'a0'; port : LONGINT location 'd0'; tags : pTagItem location 'a1') : pQSession; syscall AMarqueeBase 240;
+FUNCTION QNewSocketServerSession( port : pLONGINT location 'a0'; tags : pTagItem location 'a1') : pQSession; syscall AMarqueeBase 246;
+FUNCTION QSetKeyAccessOp(session : pQSession location 'a0'; path : pCHar location 'a1'; hosts : pCHar location 'd0') : LONGINT; syscall AMarqueeBase 252;
+FUNCTION QGetHostName(session : pQSession location 'a0') : pCHar; syscall AMarqueeBase 258;
+FUNCTION QGetProgName(session : pQSession location 'a0') : pCHar; syscall AMarqueeBase 264;
+PROCEDURE QSetMaxRawBufSize(session : pQSession location 'a0'; maxBufSize : ULONG location 'd0'); syscall AMarqueeBase 270;
+FUNCTION QNewSession(host : pCHar location 'a0'; port : LONGINT location 'd0'; name : pCHar location 'a1'; taglist : pTagItem location 'd1') : pQSession; syscall AMarqueeBase 276;
+FUNCTION QNewSessionAsync(host : pCHar location 'a0'; port : LONGINT location 'd0'; name : pCHar location 'a1'; taglist : pTagItem location 'd1') : pQSession; syscall AMarqueeBase 282;
+FUNCTION QNewHostSession(hostnames : pCHar location 'a0'; port : pLONGINT location 'a1'; names : pCHar location 'd0'; taglist : pTagItem location 'd1') : pQSession; syscall AMarqueeBase 288;
+FUNCTION QNewServerSession(hostNames : pCHar location 'a0'; progNames : pCHar location 'a1'; taglist : pTagItem location 'd0') : pQSession; syscall AMarqueeBase 294;
+FUNCTION QCreateSharedMessagePort : pQSharedMessagePort; syscall AMarqueeBase 300;
+PROCEDURE QDeleteSharedMessagePort(mp : pQSharedMessagePort location 'a0'); syscall AMarqueeBase 306;
+FUNCTION QGetLocalIP(session : pQSession location 'a0') : pCHAR; syscall AMarqueeBase 312;
 
 {
      This is functions and procedures with array of const.
@@ -297,600 +297,10 @@ FUNCTION QNewSessionAsyncTags(host : string; port : LONGINT; name : string; cons
 FUNCTION QNewHostSessionTags(hostnames : string; port : pLONGINT; names : string; const argv : Array Of Const) : pQSession;
 FUNCTION QNewServerSessionTags(hostNames : string; progNames : string; const argv : Array Of Const) : pQSession;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitAMARQUEELibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    AMARQUEEIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-pastoc,tagsarray;
-
-
-FUNCTION QFreeSession(session : pQSession) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QDebugOp(session : pQSession; string_ : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L string_,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QGetOp(session : pQSession; path : pCHar; maxBytes : LONGINT) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L path,A1
-        MOVE.L  maxBytes,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QDeleteOp(session : pQSession; path : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L path,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QRenameOp(session : pQSession; path : pCHar; label_ : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L path,A1
-        MOVE.L  label_,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QSubscribeOp(session : pQSession; path : pCHar; maxBytes : LONGINT) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L path,A1
-        MOVE.L  maxBytes,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QSetOp(session : pQSession; path : pCHar; buf : POINTER; len : ULONG) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L path,A1
-        MOVE.L  buf,D0
-        MOVE.L  len,D1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QClearSubscriptionsOp(session : pQSession; which : LONGINT) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVE.L  which,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QPingOp(session : pQSession) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QInfoOp(session : pQSession) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -090(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QSetAccessOp(session : pQSession; hosts : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L hosts,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -096(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE FreeQMessage(session : pQSession; qmsg : pQMessage);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L qmsg,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -102(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION QGo(session : pQSession; sync : ULONG) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVE.L  sync,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -108(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QStreamOp(session : pQSession; path : pCHar; buf : POINTER; len : ULONG) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L path,A1
-        MOVE.L  buf,D0
-        MOVE.L  len,D1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -120(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QSetMessageAccessOp(session : pQSession; access : pCHar; maxbytes : LONGINT) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L access,A1
-        MOVE.L  maxbytes,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -132(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QMessageOp(session : pQSession; hosts : pCHar; buffer : POINTER; len : ULONG) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L hosts,A1
-        MOVE.L  buffer,D0
-        MOVE.L  len,D1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -138(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QNumQueuedPackets(session : pQSession) : ULONG;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -150(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QNumQueuedBytes(session : pQSession) : ULONG;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -156(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QErrorName(session : LONGINT) : pCHar;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  session,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -162(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QRequestPrivilegesOp(session : pQSession; privBits : ULONG) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVE.L  privBits,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -168(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QReleasePrivilegesOp(session : pQSession; privBits : ULONG) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVE.L  privBits,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -174(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QKillClientsOp(session : pQSession; hosts : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L hosts,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -180(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QSetParameterOp(session : pQSession; paramName : pCHar; newValue : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L paramName,A1
-        MOVE.L  newValue,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -186(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QGetParameterOp(session : pQSession; paramName : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L paramName,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -192(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QSysMessageOp(session : pQSession; hosts : pCHar; message : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L hosts,A1
-        MOVE.L  message,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -198(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QGetAndSubscribeOp(session : pQSession; path : pCHar; maxBytes : LONGINT) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L path,A1
-        MOVE.L  maxBytes,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -210(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QDetachSession(session : pQSession; flags : ULONG) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVE.L  flags,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -216(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-FUNCTION QReattachSession(session : pQSession; flags : ULONG) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVE.L  flags,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -222(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-FUNCTION QNewSocketSession(host : pCHar; port : LONGINT; tags : pTagItem) : pQSession;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L host,A0
-        MOVE.L  port,D0
-        MOVEA.L tags,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -228(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QSendRawOp(session : pQSession; buf : POINTER; len : ULONG) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L buf,A1
-        MOVE.L  len,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -234(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QNewSocketSessionAsync(host : pCHar; port : LONGINT; tags : pTagItem) : pQSession;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L host,A0
-        MOVE.L  port,D0
-        MOVEA.L tags,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -240(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QNewSocketServerSession(port : pLONGINT; tags : pTagItem) : pQSession;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L port,A0
-        MOVEA.L tags,A1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -246(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QSetKeyAccessOp(session : pQSession; path : pCHar; hosts : pCHar) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L path,A1
-        MOVE.L  hosts,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -252(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QGetHostName(session : pQSession) : pCHar;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -258(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QGetProgName(session : pQSession) : pCHar;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -264(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE QSetMaxRawBufSize(session : pQSession; maxBufSize : ULONG);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVE.L  maxBufSize,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -270(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION QNewSession(host : pCHar; port : LONGINT; name : pCHar; taglist : pTagItem) : pQSession;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L host,A0
-        MOVE.L  port,D0
-        MOVEA.L name,A1
-        MOVE.L  taglist,D1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -276(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QNewSessionAsync(host : pCHar; port : LONGINT; name : pCHar; taglist : pTagItem) : pQSession;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L host,A0
-        MOVE.L  port,D0
-        MOVEA.L name,A1
-        MOVE.L  taglist,D1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -282(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QNewHostSession(hostnames : pCHar; port : pLONGINT; names : pCHar; taglist : pTagItem) : pQSession;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L hostnames,A0
-        MOVEA.L port,A1
-        MOVE.L  names,D0
-        MOVE.L  taglist,D1
-        MOVEA.L AMarqueeBase,A6
-        JSR     -288(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QNewServerSession(hostNames : pCHar; progNames : pCHar; taglist : pTagItem) : pQSession;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L hostNames,A0
-        MOVEA.L progNames,A1
-        MOVE.L  taglist,D0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -294(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION QCreateSharedMessagePort : pQSharedMessagePort;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L AMarqueeBase,A6
-        JSR     -300(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE QDeleteSharedMessagePort(mp : pQSharedMessagePort);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mp,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -306(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-
-FUNCTION QGetLocalIP(session : pQSession) : pCHAR;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L session,A0
-        MOVEA.L AMarqueeBase,A6
-        JSR     -312(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
+  pastoc,tagsarray;
 
 FUNCTION QDebugOp(session : pQSession; string_ : string) : LONGINT;
 begin
@@ -1070,85 +480,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of amarquee.library}
-  {$Info don't forget to use InitAMARQUEELibrary in the beginning of your program}
-
-var
-    amarquee_exit : Pointer;
-
-procedure CloseamarqueeLibrary;
-begin
-    ExitProc := amarquee_exit;
-    if AMarqueeBase <> nil then begin
-        CloseLibrary(AMarqueeBase);
-        AMarqueeBase := nil;
-    end;
-end;
-
-procedure InitAMARQUEELibrary;
-begin
-    AMarqueeBase := nil;
-    AMarqueeBase := OpenLibrary(AMARQUEENAME,LIBVERSION);
-    if AMarqueeBase <> nil then begin
-        amarquee_exit := ExitProc;
-        ExitProc := @CloseamarqueeLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open amarquee.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    AMARQUEEIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of amarquee.library}
-
-var
-    amarquee_exit : Pointer;
-
-procedure CloseamarqueeLibrary;
-begin
-    ExitProc := amarquee_exit;
-    if AMarqueeBase <> nil then begin
-        CloseLibrary(AMarqueeBase);
-        AMarqueeBase := nil;
-    end;
-end;
-
-begin
-    AMarqueeBase := nil;
-    AMarqueeBase := OpenLibrary(AMARQUEENAME,LIBVERSION);
-    if AMarqueeBase <> nil then begin
-        amarquee_exit := ExitProc;
-        ExitProc := @CloseamarqueeLibrary;
-        AMARQUEEIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open amarquee.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    AMARQUEEIsCompiledHow := 3;
-   {$Warning No autoopening of amarquee.library compiled}
-   {$Warning Make sure you open amarquee.library yourself}
-{$endif dont_use_openlib}
-
+initialization
+  AMarqueeBase := OpenLibrary(AMARQUEENAME,LIBVERSION);
+finalization
+  if Assigned(AMarqueeBase) then
+    CloseLibrary(AMarqueeBase);
 END. (* UNIT AMARQUEE *)
 
 

+ 7 - 93
packages/amunits/src/otherlibs/cybergraphics.pas

@@ -35,7 +35,7 @@ UNIT CYBERGRAPHICS;
 INTERFACE
 USES Exec,agraphics,utility;
 
-VAR CyberGfxBase : pLibrary;
+VAR CyberGfxBase : pLibrary = nil;
 
 const
     CYBERGRAPHICSNAME : PChar = 'cybergraphics.library';
@@ -255,23 +255,10 @@ PROCEDURE UnLockBitMapTags(Handle : POINTER; const TagList : Array Of Const);
 
 function SHIFT_PIXFMT(fmt : longint) : longint;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitCYBERGRAPHICSLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    CYBERGRAPHICSIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
+  tagsarray;
 
 {
  Functions and procedures with array of const go here
@@ -316,89 +303,16 @@ begin
     SHIFT_PIXFMT:=(ULONG(fmt)) shl 24;
 end;
 
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of cybergraphics.library}
-  {$Info don't forget to use InitCYBERGRAPHICSLibrary in the beginning of your program}
-
-var
-    cybergraphics_exit : Pointer;
-
-procedure ClosecybergraphicsLibrary;
-begin
-    ExitProc := cybergraphics_exit;
-    if CyberGfxBase <> nil then begin
-        CloseLibrary(CyberGfxBase);
-        CyberGfxBase := nil;
-    end;
-end;
-
-procedure InitCYBERGRAPHICSLibrary;
-begin
-    CyberGfxBase := nil;
-    CyberGfxBase := OpenLibrary(CYBERGRAPHICSNAME,LIBVERSION);
-    if CyberGfxBase <> nil then begin
-        cybergraphics_exit := ExitProc;
-        ExitProc := @ClosecybergraphicsLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open cybergraphics.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    CYBERGRAPHICSIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of cybergraphics.library}
-
-var
-    cybergraphics_exit : Pointer;
-
-procedure ClosecybergraphicsLibrary;
-begin
-    ExitProc := cybergraphics_exit;
-    if CyberGfxBase <> nil then begin
-        CloseLibrary(CyberGfxBase);
-        CyberGfxBase := nil;
-    end;
-end;
-
-begin
-    CyberGfxBase := nil;
-    CyberGfxBase := OpenLibrary(CYBERGRAPHICSNAME,LIBVERSION);
-    if CyberGfxBase <> nil then begin
-        cybergraphics_exit := ExitProc;
-        ExitProc := @ClosecybergraphicsLibrary;
-        CYBERGRAPHICSIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open cybergraphics.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    CYBERGRAPHICSIsCompiledHow := 3;
-   {$Warning No autoopening of cybergraphics.library compiled}
-   {$Warning Make sure you open cybergraphics.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  CyberGfxBase := OpenLibrary(CYBERGRAPHICSNAME,LIBVERSION);
+finalization
+  if Assigned(CyberGfxBase) then
+    CloseLibrary(CyberGfxBase);
 END. (* UNIT CYBERGRAPHICS *)
 
 

+ 47 - 658
packages/amunits/src/otherlibs/gtlayout.pas

@@ -40,11 +40,6 @@
 }
 {$mode objfpc}
 
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-    {$smartlink on}
-{$endif use_amiga_smartlink}
-
 
 UNIT GTLAYOUT;
 
@@ -561,45 +556,47 @@ const
        ppGadget = ^pGadget;
        pUWORD   = ^UWORD;
 
-PROCEDURE LT_LevelWidth(par1 : pLayoutHandle; par2 : pCHAR; par3 : POINTER; par4 : LONGINT; par5 : LONGINT; par6 : pLONGINT; par7 : pLONGINT; last : LONGINT);
-PROCEDURE LT_DeleteHandle(last : pLayoutHandle);
-FUNCTION LT_CreateHandle(par1 : pScreen; last : pTextAttr) : pLayoutHandle;
-FUNCTION LT_CreateHandleTagList(par1 : pScreen; tags : pTagItem) : pLayoutHandle;
-FUNCTION LT_Rebuild(par1 : pLayoutHandle; par2 : pIBox; par3 : LONGINT; par4 : LONGINT; last : LONGINT) : BOOLEAN;
-PROCEDURE LT_HandleInput(par1 : pLayoutHandle; par2 : ulong; par3 : pulong; par4 : pUWORD; last :ppGadget);
-PROCEDURE LT_BeginRefresh(last : pLayoutHandle);
-PROCEDURE LT_EndRefresh(par1 : pLayoutHandle; last : LONGINT);
-FUNCTION LT_GetAttributesA(par1 : pLayoutHandle; par2 : LONGINT; tags : pTagItem) : LONGINT;
-PROCEDURE LT_SetAttributesA(par1 : pLayoutHandle; par2 : LONGINT; tags : pTagItem);
-PROCEDURE LT_AddA(par1 : pLayoutHandle; par2 : LONGINT; par3 : pCHAR; par4 : LONGINT; tags : pTagItem);
-PROCEDURE LT_NewA(par1 : pLayoutHandle; tags : pTagItem);
-PROCEDURE LT_EndGroup(last : pLayoutHandle);
-FUNCTION LT_LayoutA(par1 : pLayoutHandle; par2 : pCHAR; par3 : pIBox; par4 : LONGINT; par5 : LONGINT; par6 : ulong; par7 : LONGINT; tags : pTagItem) : pWindow;
-FUNCTION LT_LayoutMenusA(par1 : pLayoutHandle; par2 : pNewMenu; tags : pTagItem) : pMenu;
-FUNCTION LT_LabelWidth(par1 : pLayoutHandle; last : pCHAR) : LONGINT;
-FUNCTION LT_LabelChars(par1 : pLayoutHandle; last : pCHAR) : LONGINT;
-PROCEDURE LT_LockWindow(last : pWindow);
-PROCEDURE LT_UnlockWindow(last : pWindow);
-PROCEDURE LT_DeleteWindowLock(last : pWindow);
-PROCEDURE LT_ShowWindow(par1 : pLayoutHandle; last : LONGINT);
-PROCEDURE LT_Activate(par1 : pLayoutHandle; last : LONGINT);
-FUNCTION LT_PressButton(par1 : pLayoutHandle; last : LONGINT) : BOOLEAN;
-FUNCTION LT_GetCode(par1 : ulong; par2 : ulong; par3 : ulong; last : pGadget) : LONGINT;
-FUNCTION LT_GetIMsg(last : pLayoutHandle) : pIntuiMessage;
-PROCEDURE LT_ReplyIMsg(last : pIntuiMessage);
-FUNCTION LT_BuildA(par1 : pLayoutHandle; tags : pTagItem) : pWindow;
-FUNCTION LT_RebuildTagList(par1 : pLayoutHandle; par2 : LONGINT; tags : pTagItem) : BOOLEAN;
-PROCEDURE LT_UpdateStrings(last : pLayoutHandle);
-PROCEDURE LT_DisposeMenu(last : pMenu);
-FUNCTION LT_NewMenuTemplate(par1 : pScreen; par2 : pTextAttr; par3 : pImage; par4 : pImage; par5 : pLONGINT; last : pNewMenu) : pMenu;
-FUNCTION LT_NewMenuTagList(tags : pTagItem) : pMenu;
-PROCEDURE LT_MenuControlTagList(par1 : pWindow; par2 : pMenu; tags : pTagItem);
-FUNCTION LT_GetMenuItem(par1 : pMenu; last : ulong) : pMenuItem;
-FUNCTION LT_FindMenuCommand(par1 : pMenu; par2 : ulong; par3 : ulong; last : pGadget) : pMenuItem;
-PROCEDURE LT_NewLevelWidth(par1 : pLayoutHandle; par2 : pCHAR; par3 : POINTER; par4 : LONGINT; par5 : LONGINT; par6 : pLONGINT; par7 : pLONGINT; last : LONGINT);
-PROCEDURE LT_Refresh(last : pLayoutHandle);
-PROCEDURE LT_CatchUpRefresh(last : pLayoutHandle);
-FUNCTION LT_GetWindowUserData(par1 : pWindow; last : POINTER) : POINTER;
+VAR GTLayoutBase : pLibrary = nil;
+
+PROCEDURE LT_LevelWidth(par1 : pLayoutHandle location 'a0'; par2 : pCHAR location 'a1'; par3 : POINTER location 'a2'; par4 : LONGINT location 'd0'; par5 : LONGINT location 'd1'; par6 : pLONGINT location 'a3'; par7 : pLONGINT location 'a5'; last : LONGINT location 'd2'); syscall GTLayoutBase 30;
+PROCEDURE LT_DeleteHandle(last : pLayoutHandle location 'a0'); syscall GTLayoutBase 36;
+FUNCTION LT_CreateHandle(par1 : pScreen location 'a0'; last : pTextAttr location 'a1') : pLayoutHandle; syscall GTLayoutBase 42;
+FUNCTION LT_CreateHandleTagList(par1 : pScreen location 'a0'; tags : pTagItem location 'a1') : pLayoutHandle; syscall GTLayoutBase 48;
+FUNCTION LT_Rebuild(par1 : pLayoutHandle location 'a0'; par2 : pIBox location 'a1'; par3 : LONGINT location 'a2'; par4 : LONGINT location 'd0'; last : LONGINT location 'd1') : BOOLEAN; syscall GTLayoutBase 54;
+PROCEDURE LT_HandleInput(par1 : pLayoutHandle location 'a0'; par2 : ulong location 'd0'; par3 : pulong location 'a1'; par4 : pUWORD location 'a2'; last :ppGadget location 'a3'); syscall GTLayoutBase 60;
+PROCEDURE LT_BeginRefresh(last : pLayoutHandle location 'a0'); syscall GTLayoutBase 66;
+PROCEDURE LT_EndRefresh(par1 : pLayoutHandle location 'a0'; last : LONGINT location 'd0'); syscall GTLayoutBase 72;
+FUNCTION LT_GetAttributesA(par1 : pLayoutHandle location 'a0'; par2 : LONGINT location 'd0'; tags : pTagItem location 'a1') : LONGINT; syscall GTLayoutBase 78;
+PROCEDURE LT_SetAttributesA(par1 : pLayoutHandle location 'a0'; par2 : LONGINT location 'd0'; tags : pTagItem location 'a1'); syscall GTLayoutBase 84;
+PROCEDURE LT_AddA(par1 : pLayoutHandle location 'a0'; par2 : LONGINT location 'd0'; par3 : pCHAR location 'd1'; par4 : LONGINT location 'd2'; tags : pTagItem location 'a1'); syscall GTLayoutBase 90;
+PROCEDURE LT_NewA(par1 : pLayoutHandle location 'a0'; tags : pTagItem location 'a1'); syscall GTLayoutBase 96;
+PROCEDURE LT_EndGroup(last : pLayoutHandle location 'a0'); syscall GTLayoutBase 102;
+FUNCTION LT_LayoutA(par1 : pLayoutHandle location 'a0'; par2 : pCHAR location 'a1'; par3 : pIBox location 'a2'; par4 : LONGINT location 'd0'; par5 : LONGINT location 'd1'; par6 : ulong location 'd2'; par7 : LONGINT location 'd3'; tags : pTagItem location 'A3') : pWindow; syscall GTLayoutBase 108;
+FUNCTION LT_LayoutMenusA(par1 : pLayoutHandle location 'a0'; par2 : pNewMenu location 'a1'; tags : pTagItem location 'a2') : pMenu; syscall GTLayoutBase 114;
+FUNCTION LT_LabelWidth(par1 : pLayoutHandle location 'a0'; last : pCHAR location 'a1') : LONGINT; syscall GTLayoutBase 138;
+FUNCTION LT_LabelChars(par1 : pLayoutHandle location 'a0'; last : pCHAR location 'a1') : LONGINT; syscall GTLayoutBase 144;
+PROCEDURE LT_LockWindow(last : pWindow location 'a0'); syscall GTLayoutBase 150;
+PROCEDURE LT_UnlockWindow(last : pWindow location 'a0'); syscall GTLayoutBase 156;
+PROCEDURE LT_DeleteWindowLock(last : pWindow location 'a0'); syscall GTLayoutBase 162;
+PROCEDURE LT_ShowWindow(par1 : pLayoutHandle location 'a0'; last : LONGINT location 'a1'); syscall GTLayoutBase 168;
+PROCEDURE LT_Activate(par1 : pLayoutHandle location 'a0'; last : LONGINT location 'd0'); syscall GTLayoutBase 174;
+FUNCTION LT_PressButton(par1 : pLayoutHandle location 'a0'; last : LONGINT location 'd0') : BOOLEAN; syscall GTLayoutBase 180;
+FUNCTION LT_GetCode(par1 : ulong location 'd0'; par2 : ulong location 'd1'; par3 : ulong location 'd2'; last : pGadget location 'a0') : LONGINT; syscall GTLayoutBase 186;
+FUNCTION LT_GetIMsg(last : pLayoutHandle location 'a0') : pIntuiMessage; syscall GTLayoutBase 192;
+PROCEDURE LT_ReplyIMsg(last : pIntuiMessage location 'a0'); syscall GTLayoutBase 198;
+FUNCTION LT_BuildA(par1 : pLayoutHandle location 'a0'; tags : pTagItem location 'a1') : pWindow; syscall GTLayoutBase 204;
+FUNCTION LT_RebuildTagList(par1 : pLayoutHandle location 'a0'; par2 : LONGINT location 'd0'; tags : pTagItem location 'a1') : BOOLEAN; syscall GTLayoutBase 210;
+PROCEDURE LT_UpdateStrings(last : pLayoutHandle location 'a0'); syscall GTLayoutBase 216;
+PROCEDURE LT_DisposeMenu(last : pMenu location 'a0'); syscall GTLayoutBase 222;
+FUNCTION LT_NewMenuTemplate(par1 : pScreen location 'a0'; par2 : pTextAttr location 'a1'; par3 : pImage location 'a2'; par4 : pImage location 'a3'; par5 : pLONGINT location 'd0'; last : pNewMenu location 'd1') : pMenu; syscall GTLayoutBase 228;
+FUNCTION LT_NewMenuTagList(tags : pTagItem location 'a0') : pMenu; syscall GTLayoutBase 234;
+PROCEDURE LT_MenuControlTagList(par1 : pWindow location 'a0'; par2 : pMenu location 'a1'; tags : pTagItem location 'a2'); syscall GTLayoutBase 240;
+FUNCTION LT_GetMenuItem(par1 : pMenu location 'a0'; last : ulong location 'd0') : pMenuItem; syscall GTLayoutBase 246;
+FUNCTION LT_FindMenuCommand(par1 : pMenu location 'a0'; par2 : ulong location 'd0'; par3 : ulong location 'd1'; last : pGadget location 'a1') : pMenuItem; syscall GTLayoutBase 252;
+PROCEDURE LT_NewLevelWidth(par1 : pLayoutHandle location 'a0'; par2 : pCHAR location 'a1'; par3 : POINTER location 'a2'; par4 : LONGINT location 'd0'; par5 : LONGINT location 'd1'; par6 : pLONGINT location 'a3'; par7 : pLONGINT location 'd3'; last : LONGINT location 'd2'); syscall GTLayoutBase 258;
+PROCEDURE LT_Refresh(last : pLayoutHandle location 'a0'); syscall GTLayoutBase 264;
+PROCEDURE LT_CatchUpRefresh(last : pLayoutHandle location 'a0'); syscall GTLayoutBase 270;
+FUNCTION LT_GetWindowUserData(par1 : pWindow location 'a0'; last : POINTER location 'a1') : POINTER; syscall GTLayoutBase 276;
 
 {
      This is functions and procedures with array of const.
@@ -619,548 +616,12 @@ FUNCTION LT_NewMenuTags(const tagList : Array Of Const) : pMenu;
 PROCEDURE LT_MenuControlTags(window : pWindow; intuitionMenu : pMenu; const tags : Array Of Const);
 
 
-VAR GTLayoutBase : pLibrary;
-
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitGTLAYOUTLibrary;
-{$endif use_init_openlib}
 
-{This is a variable that knows how the unit is compiled}
-var
-    GTLAYOUTIsCompiledHow : longint;
 
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
-
-PROCEDURE LT_LevelWidth(par1 : pLayoutHandle; par2 : pCHAR; par3 : POINTER; par4 : LONGINT; par5 : LONGINT;  par6 : pLONGINT;  par7 : pLONGINT; last : LONGINT);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L par2,A1
-        MOVEA.L par3,A2
-        MOVE.L  par4,D0
-        MOVE.L  par5,D1
-        MOVEA.L par6,A3
-        MOVEA.L par7,A5
-        MOVE.L  last,D2
-        MOVEA.L GTLayoutBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_DeleteHandle(last : pLayoutHandle);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION LT_CreateHandle(par1 : pScreen; last : pTextAttr) : pLayoutHandle;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L last,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_CreateHandleTagList(par1 : pScreen; tags : pTagItem) : pLayoutHandle;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L tags,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_Rebuild(par1 : pLayoutHandle; par2 : pIBox; par3 : LONGINT; par4 : LONGINT; last : LONGINT) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L par2,A1
-        MOVEA.L par3,A2
-        MOVE.L  par4,D0
-        MOVE.L  last,D1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-PROCEDURE LT_HandleInput(par1 : pLayoutHandle; par2 : ulong; par3 : pulong;par4 : pUWORD; last : ppGadget);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  par2,D0
-        MOVEA.L par3,A1
-        MOVEA.L par4,A2
-        MOVEA.L last,A3
-        MOVEA.L GTLayoutBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_BeginRefresh(last : pLayoutHandle);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_EndRefresh(par1 : pLayoutHandle; last : LONGINT);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  last,D0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION LT_GetAttributesA(par1 : pLayoutHandle; par2 : LONGINT; tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  par2,D0
-        MOVEA.L tags,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE LT_SetAttributesA(par1 : pLayoutHandle; par2 : LONGINT; tags : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  par2,D0
-        MOVEA.L tags,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_AddA(par1 : pLayoutHandle; par2 : LONGINT; par3 : pCHAR; par4 : LONGINT; tags : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  par2,D0
-        MOVE.L  par3,D1
-        MOVE.L  par4,D2
-        MOVEA.L tags,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -090(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_NewA(par1 : pLayoutHandle; tags : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L tags,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -096(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_EndGroup(last : pLayoutHandle);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -102(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION LT_LayoutA(par1 : pLayoutHandle; par2 : pCHAR; par3 : pIBox; par4 : LONGINT; par5 : LONGINT; par6 : ulong; par7 : LONGINT; tags : pTagItem) : pWindow;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L par2,A1
-        MOVEA.L par3,A2
-        MOVE.L  par4,D0
-        MOVE.L  par5,D1
-        MOVE.L  par6,D2
-        MOVE.L  par7,D3
-        MOVEA.L tags,A3
-        MOVEA.L GTLayoutBase,A6
-        JSR     -108(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_LayoutMenusA(par1 : pLayoutHandle; par2 : pNewMenu; tags : pTagItem) : pMenu;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L par2,A1
-        MOVEA.L tags,A2
-        MOVEA.L GTLayoutBase,A6
-        JSR     -114(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_LabelWidth(par1 : pLayoutHandle; last : pCHAR) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L last,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -138(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_LabelChars(par1 : pLayoutHandle; last : pCHAR) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L last,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -144(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE LT_LockWindow(last : pWindow);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -150(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_UnlockWindow(last : pWindow);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -156(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_DeleteWindowLock(last : pWindow);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -162(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_ShowWindow(par1 : pLayoutHandle; last : LONGINT);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L last,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -168(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_Activate(par1 : pLayoutHandle; last : LONGINT);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  last,D0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -174(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION LT_PressButton(par1 : pLayoutHandle; last : LONGINT) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  last,D0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -180(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_GetCode(par1 : ulong; par2 : ulong; par3 : ulong; last : pGadget) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  par1,D0
-        MOVE.L  par2,D1
-        MOVE.L  par3,D2
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -186(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_GetIMsg(last : pLayoutHandle) : pIntuiMessage;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -192(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE LT_ReplyIMsg(last : pIntuiMessage);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -198(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION LT_BuildA(par1 : pLayoutHandle; tags : pTagItem) : pWindow;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L tags,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -204(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_RebuildTagList(par1 : pLayoutHandle; par2 : LONGINT; tags : pTagItem) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  par2,D0
-        MOVEA.L tags,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -210(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-PROCEDURE LT_UpdateStrings(last : pLayoutHandle);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -216(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_DisposeMenu(last : pMenu);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -222(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION LT_NewMenuTemplate(par1 : pScreen; par2 : pTextAttr; par3 : pImage; par4 : pImage; par5 : pLONGINT; last : pNewMenu) : pMenu;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L par2,A1
-        MOVEA.L par3,A2
-        MOVEA.L par4,A3
-        MOVE.L  par5,D0
-        MOVE.L  last,D1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -228(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_NewMenuTagList(tags : pTagItem) : pMenu;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L tags,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -234(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE LT_MenuControlTagList(par1 : pWindow; par2 : pMenu; tags : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L par2,A1
-        MOVEA.L tags,A2
-        MOVEA.L GTLayoutBase,A6
-        JSR     -240(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION LT_GetMenuItem(par1 : pMenu; last : ulong) : pMenuItem;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  last,D0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -246(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LT_FindMenuCommand(par1 : pMenu; par2 : ulong; par3 : ulong; last : pGadget) : pMenuItem;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVE.L  par2,D0
-        MOVE.L  par3,D1
-        MOVEA.L last,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -252(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE LT_NewLevelWidth(par1 : pLayoutHandle; par2 : pCHAR; par3 : POINTER; par4 : LONGINT; par5 : LONGINT;  par6 : pLONGINT;  par7 : pLONGINT; last : LONGINT);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L par2,A1
-        MOVEA.L par3,A2
-        MOVE.L  par4,D0
-        MOVE.L  par5,D1
-        MOVEA.L par6,A3
-        MOVE.L  par7,D3
-        MOVE.L  last,D2
-        MOVEA.L GTLayoutBase,A6
-        JSR     -258(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_Refresh(last : pLayoutHandle);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -264(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE LT_CatchUpRefresh(last : pLayoutHandle);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L last,A0
-        MOVEA.L GTLayoutBase,A6
-        JSR     -270(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION LT_GetWindowUserData(par1 : pWindow; last : POINTER) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L par1,A0
-        MOVEA.L last,A1
-        MOVEA.L GTLayoutBase,A6
-        JSR     -276(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
+  tagsarray;
 
 {
  Functions and procedures with array of const go here
@@ -1222,86 +683,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : Cardinal = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of gtlayout.library}
-  {$Info don't forget to use InitGTLAYOUTLibrary in the beginning of your program}
-
-var
-    gtlayout_exit : Pointer;
-
-procedure ClosegtlayoutLibrary;
-begin
-    ExitProc := gtlayout_exit;
-    if GTLayoutBase <> nil then begin
-        CloseLibrary(GTLayoutBase);
-        GTLayoutBase := nil;
-    end;
-end;
-
-procedure InitGTLAYOUTLibrary;
-begin
-    GTLayoutBase := nil;
-    GTLayoutBase := OpenLibrary(GTLAYOUTNAME,LIBVERSION);
-    if GTLayoutBase <> nil then begin
-        gtlayout_exit := ExitProc;
-        ExitProc := @ClosegtlayoutLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open gtlayout.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    GTLAYOUTIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of gtlayout.library}
-
-var
-    gtlayout_exit : Pointer;
-
-procedure ClosegtlayoutLibrary;
-begin
-    ExitProc := gtlayout_exit;
-    if GTLayoutBase <> nil then begin
-        CloseLibrary(GTLayoutBase);
-        GTLayoutBase := nil;
-    end;
-end;
-
-begin
-    GTLayoutBase := nil;
-    GTLayoutBase := OpenLibrary(GTLAYOUTNAME,LIBVERSION);
-    if GTLayoutBase <> nil then begin
-        gtlayout_exit := ExitProc;
-        ExitProc := @ClosegtlayoutLibrary;
-        GTLAYOUTIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open gtlayout.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    GTLAYOUTIsCompiledHow := 3;
-   {$Warning No autoopening of gtlayout.library compiled}
-   {$Warning Make sure you open gtlayout.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  GTLayoutBase := OpenLibrary(GTLAYOUTNAME,LIBVERSION);
+finalization
+  if Assigned(GTLayoutBase) then
+    CloseLibrary(GTLayoutBase);
 END. (* UNIT GTLAYOUT *)
 
 

+ 32 - 493
packages/amunits/src/otherlibs/guigfx.pas

@@ -29,10 +29,6 @@
 }
 
 {$mode objfpc}
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-   {$smartlink on}
-{$endif use_amiga_smartlink}
 
 UNIT GUIGFX;
 
@@ -156,32 +152,32 @@ const
      BMAPATTR_Flags = 6 + TAG_USER;
 
 
-FUNCTION AddPaletteA(psm : POINTER; palette : POINTER; tags : pTagItem) : POINTER;
-FUNCTION AddPictureA(psm : POINTER; pic : POINTER; tags : pTagItem) : POINTER;
-FUNCTION AddPixelArrayA(psm : POINTER; _array : POINTER; width : WORD; height : WORD; tags : pTagItem) : POINTER;
-FUNCTION ClonePictureA(pic : POINTER; tags : pTagItem) : POINTER;
-FUNCTION CreateDirectDrawHandleA(drawhandle : POINTER; sw : WORD; sh : WORD; dw : WORD; dh : WORD; tags : pTagItem) : POINTER;
-FUNCTION CreatePenShareMapA(tags : pTagItem) : POINTER;
-FUNCTION CreatePictureBitMapA(drawhandle : POINTER; pic : POINTER; tags : pTagItem) : pBitMap;
-FUNCTION CreatePictureMaskA(pic : POINTER; mask : pCHAR; maskwidth : WORD; tags : pTagItem) : BOOLEAN;
-PROCEDURE DeleteDirectDrawHandle(ddh : POINTER);
-PROCEDURE DeletePenShareMap(psm : POINTER);
-PROCEDURE DeletePicture(pic : POINTER);
-FUNCTION DirectDrawTrueColorA(ddh : POINTER; _array : pULONG; x : WORD; y : WORD; tags : pTagItem) : BOOLEAN;
-FUNCTION DoPictureMethodA(pic : POINTER; method : longword; arguments : pULONG) : longword;
-FUNCTION DrawPictureA(drawhandle : POINTER; pic : POINTER; x : WORD; y : WORD; tags : pTagItem) : BOOLEAN;
-FUNCTION GetPictureAttrsA(pic : POINTER; tags : pTagItem) : longword;
-FUNCTION IsPictureA(filename : pCHAR; tags : pTagItem) : BOOLEAN;
-FUNCTION LoadPictureA(filename : pCHAR; tags : pTagItem) : POINTER;
-FUNCTION LockPictureA(pic : POINTER; mode : longword; args : pULONG) : longword;
-FUNCTION MakePictureA(_array : POINTER; width : WORD; height : WORD; tags : pTagItem) : POINTER;
-FUNCTION MapPaletteA(drawhandle : POINTER; palette : POINTER; pentab : pCHAR; tags : pTagItem) : BOOLEAN;
-FUNCTION MapPenA(drawhandle : POINTER; rgb : longword; tags : pTagItem) : LONGINT;
-FUNCTION ObtainDrawHandleA(psm : POINTER; a1arg : pRastPort; cm : pColorMap; tags : pTagItem) : POINTER;
-FUNCTION ReadPictureA(a0arg : pRastPort; colormap : pColorMap; x : WORD; y : WORD; width : WORD; height : WORD; tags : pTagItem) : POINTER;
-PROCEDURE ReleaseDrawHandle(drawhandle : POINTER);
-PROCEDURE RemColorHandle(colorhandle : POINTER);
-PROCEDURE UnLockPicture(pic : POINTER; mode : longword);
+FUNCTION AddPaletteA(psm : POINTER location 'a0'; palette : POINTER location 'a1'; tags : pTagItem location 'a2') : POINTER; syscall GuiGFXBase 72;
+FUNCTION AddPictureA(psm : POINTER location 'a0'; pic : POINTER location 'a1'; tags : pTagItem location 'a2') : POINTER; syscall GuiGFXBase 66;
+FUNCTION AddPixelArrayA(psm : POINTER location 'a0'; _array : POINTER location 'a1'; width : WORD location 'd0'; height : WORD location 'd1'; tags : pTagItem location 'a2') : POINTER; syscall GuiGFXBase 78;
+FUNCTION ClonePictureA(pic : POINTER location 'a0'; tags : pTagItem location 'a1') : POINTER; syscall GuiGFXBase 48;
+FUNCTION CreateDirectDrawHandleA(drawhandle : POINTER location 'a0'; sw : WORD location 'd0'; sh : WORD location 'd1'; dw : WORD location 'd2'; dh : WORD location 'd3'; tags : pTagItem location 'a1') : POINTER; syscall GuiGFXBase 168;
+FUNCTION CreatePenShareMapA(tags : pTagItem location 'a0') : POINTER; syscall GuiGFXBase 90;
+FUNCTION CreatePictureBitMapA(drawhandle : POINTER location 'a0'; pic : POINTER location 'a1'; tags : pTagItem location 'a2') : pBitMap; syscall GuiGFXBase 132;
+FUNCTION CreatePictureMaskA(pic : POINTER location 'a0'; mask : pCHAR location 'a1'; maskwidth : WORD location 'd0'; tags : pTagItem location 'a2') : BOOLEAN; syscall GuiGFXBase 186;
+PROCEDURE DeleteDirectDrawHandle(ddh : POINTER location 'a0'); syscall GuiGFXBase 174;
+PROCEDURE DeletePenShareMap(psm : POINTER location 'a0'); syscall GuiGFXBase 96;
+PROCEDURE DeletePicture(pic : POINTER location 'a0'); syscall GuiGFXBase 54;
+FUNCTION DirectDrawTrueColorA(ddh : POINTER location 'a0'; _array : pULONG location 'a1'; x : WORD location 'd0'; y : WORD location 'd1'; tags : pTagItem location 'a2') : BOOLEAN; syscall GuiGFXBase 180;
+FUNCTION DoPictureMethodA(pic : POINTER location 'a0'; method : longword location 'd0'; arguments : pULONG location 'a1') : longword; syscall GuiGFXBase 138;
+FUNCTION DrawPictureA(drawhandle : POINTER location 'a0'; pic : POINTER location 'a1'; x : WORD location 'd0'; y : WORD location 'd1'; tags : pTagItem location 'a2') : BOOLEAN; syscall GuiGFXBase 114;
+FUNCTION GetPictureAttrsA(pic : POINTER location 'a0'; tags : pTagItem location 'a1') : longword; syscall GuiGFXBase 144;
+FUNCTION IsPictureA(filename : pCHAR location 'a0'; tags : pTagItem location 'a1') : BOOLEAN; syscall GuiGFXBase 162;
+FUNCTION LoadPictureA(filename : pCHAR location 'a0'; tags : pTagItem location 'a1') : POINTER; syscall GuiGFXBase 36;
+FUNCTION LockPictureA(pic : POINTER location 'a0'; mode : longword location 'd0'; args : pULONG location 'a1') : longword; syscall GuiGFXBase 150;
+FUNCTION MakePictureA(_array : POINTER location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; tags : pTagItem location 'a1') : POINTER; syscall GuiGFXBase 30;
+FUNCTION MapPaletteA(drawhandle : POINTER location 'a0'; palette : POINTER location 'a1'; pentab : pCHAR location 'a2'; tags : pTagItem location 'a3') : BOOLEAN; syscall GuiGFXBase 120;
+FUNCTION MapPenA(drawhandle : POINTER location 'a0'; rgb : longword location 'a1'; tags : pTagItem location 'a2') : LONGINT; syscall GuiGFXBase 126;
+FUNCTION ObtainDrawHandleA(psm : POINTER location 'a0'; a1arg : pRastPort location 'a1'; cm : pColorMap location 'a2'; tags : pTagItem location 'a3') : POINTER; syscall GuiGFXBase 102;
+FUNCTION ReadPictureA(a0arg : pRastPort location 'a0'; colormap : pColorMap location 'a1'; x : WORD location 'd0'; y : WORD location 'd1'; width : WORD location 'd2'; height : WORD location 'd3'; tags : pTagItem location 'a2') : POINTER; syscall GuiGFXBase 42;
+PROCEDURE ReleaseDrawHandle(drawhandle : POINTER location 'a0'); syscall GuiGFXBase 108;
+PROCEDURE RemColorHandle(colorhandle : POINTER location 'a0'); syscall GuiGFXBase 84;
+PROCEDURE UnLockPicture(pic : POINTER location 'a0'; mode : longword location 'd0'); syscall GuiGFXBase 156;
 {
  Functions and procedures with array of const go here
 }
@@ -206,396 +202,10 @@ FUNCTION MapPen(drawhandle : POINTER; rgb : longword; const tags : Array Of Cons
 FUNCTION ObtainDrawHandle(psm : POINTER; a1arg : pRastPort; cm : pColorMap; const tags : Array Of Const) : POINTER;
 FUNCTION ReadPicture(a0arg : pRastPort; colormap : pColorMap; x : WORD; y : WORD; width : WORD; height : WORD; const tags : Array Of Const) : POINTER;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitGUIGFXLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    GUIGFXIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray,longarray;
-
-FUNCTION AddPaletteA(psm : POINTER; palette : POINTER; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L psm,A0
-        MOVEA.L palette,A1
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AddPictureA(psm : POINTER; pic : POINTER; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L psm,A0
-        MOVEA.L pic,A1
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AddPixelArrayA(psm : POINTER; _array : POINTER; width : WORD; height : WORD; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L psm,A0
-        MOVEA.L _array,A1
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION ClonePictureA(pic : POINTER; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L pic,A0
-        MOVEA.L tags,A1
-        MOVEA.L GuiGFXBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION CreateDirectDrawHandleA(drawhandle : POINTER; sw : WORD; sh : WORD; dw : WORD; dh : WORD; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L drawhandle,A0
-        MOVE.L  sw,D0
-        MOVE.L  sh,D1
-        MOVE.L  dw,D2
-        MOVE.L  dh,D3
-        MOVEA.L tags,A1
-        MOVEA.L GuiGFXBase,A6
-        JSR     -168(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION CreatePenShareMapA(tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L tags,A0
-        MOVEA.L GuiGFXBase,A6
-        JSR     -090(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION CreatePictureBitMapA(drawhandle : POINTER; pic : POINTER; tags : pTagItem) : pBitMap;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L drawhandle,A0
-        MOVEA.L pic,A1
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -132(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION CreatePictureMaskA(pic : POINTER; mask : pCHAR; maskwidth : WORD; tags : pTagItem) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L pic,A0
-        MOVEA.L mask,A1
-        MOVE.L  maskwidth,D0
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -186(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-PROCEDURE DeleteDirectDrawHandle(ddh : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ddh,A0
-        MOVEA.L GuiGFXBase,A6
-        JSR     -174(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE DeletePenShareMap(psm : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L psm,A0
-        MOVEA.L GuiGFXBase,A6
-        JSR     -096(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE DeletePicture(pic : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L pic,A0
-        MOVEA.L GuiGFXBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION DirectDrawTrueColorA(ddh : POINTER; _array : pULONG; x : WORD; y : WORD; tags : pTagItem) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ddh,A0
-        MOVEA.L _array,A1
-        MOVE.L  x,D0
-        MOVE.L  y,D1
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -180(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-FUNCTION DoPictureMethodA(pic : POINTER; method : longword; arguments : pULONG) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L pic,A0
-        MOVE.L  method,D0
-        MOVEA.L arguments,A1
-        MOVEA.L GuiGFXBase,A6
-        JSR     -138(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION DrawPictureA(drawhandle : POINTER; pic : POINTER; x : WORD; y : WORD; tags : pTagItem) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L drawhandle,A0
-        MOVEA.L pic,A1
-        MOVE.L  x,D0
-        MOVE.L  y,D1
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -114(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-FUNCTION GetPictureAttrsA(pic : POINTER; tags : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L pic,A0
-        MOVEA.L tags,A1
-        MOVEA.L GuiGFXBase,A6
-        JSR     -144(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION IsPictureA(filename : pCHAR; tags : pTagItem) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L filename,A0
-        MOVEA.L tags,A1
-        MOVEA.L GuiGFXBase,A6
-        JSR     -162(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-FUNCTION LoadPictureA(filename : pCHAR; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L filename,A0
-        MOVEA.L tags,A1
-        MOVEA.L GuiGFXBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION LockPictureA(pic : POINTER; mode : longword; args : pULONG) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L pic,A0
-        MOVE.L  mode,D0
-        MOVEA.L args,A1
-        MOVEA.L GuiGFXBase,A6
-        JSR     -150(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION MakePictureA(_array : POINTER; width : WORD; height : WORD; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L _array,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L tags,A1
-        MOVEA.L GuiGFXBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION MapPaletteA(drawhandle : POINTER; palette : POINTER; pentab : pCHAR; tags : pTagItem) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L drawhandle,A0
-        MOVEA.L palette,A1
-        MOVEA.L pentab,A2
-        MOVEA.L tags,A3
-        MOVEA.L GuiGFXBase,A6
-        JSR     -120(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-FUNCTION MapPenA(drawhandle : POINTER; rgb : longword; tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L drawhandle,A0
-        MOVEA.L rgb,A1
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -126(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION ObtainDrawHandleA(psm : POINTER; a1arg : pRastPort; cm : pColorMap; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L psm,A0
-        MOVEA.L a1arg,A1
-        MOVEA.L cm,A2
-        MOVEA.L tags,A3
-        MOVEA.L GuiGFXBase,A6
-        JSR     -102(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION ReadPictureA(a0arg : pRastPort; colormap : pColorMap; x : WORD; y : WORD; width : WORD; height : WORD; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L a0arg,A0
-        MOVEA.L colormap,A1
-        MOVE.L  x,D0
-        MOVE.L  y,D1
-        MOVE.L  width,D2
-        MOVE.L  height,D3
-        MOVEA.L tags,A2
-        MOVEA.L GuiGFXBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE ReleaseDrawHandle(drawhandle : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L drawhandle,A0
-        MOVEA.L GuiGFXBase,A6
-        JSR     -108(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE RemColorHandle(colorhandle : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L colorhandle,A0
-        MOVEA.L GuiGFXBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE UnLockPicture(pic : POINTER; mode : longword);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L pic,A0
-        MOVE.L  mode,D0
-        MOVEA.L GuiGFXBase,A6
-        JSR     -156(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
+  tagsarray,longarray;
 
 {
  Functions and procedures with array of const go here
@@ -702,85 +312,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of guigfx.library}
-  {$Info don't forget to use InitGUIGFXLibrary in the beginning of your program}
-
-var
-    guigfx_exit : Pointer;
-
-procedure CloseguigfxLibrary;
-begin
-    ExitProc := guigfx_exit;
-    if GuiGFXBase <> nil then begin
-        CloseLibrary(GuiGFXBase);
-        GuiGFXBase := nil;
-    end;
-end;
-
-procedure InitGUIGFXLibrary;
-begin
-    GuiGFXBase := nil;
-    GuiGFXBase := OpenLibrary(GUIGFXNAME,LIBVERSION);
-    if GuiGFXBase <> nil then begin
-        guigfx_exit := ExitProc;
-        ExitProc := @CloseguigfxLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open guigfx.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    GUIGFXIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of guigfx.library}
-
-var
-    guigfx_exit : Pointer;
-
-procedure CloseguigfxLibrary;
-begin
-    ExitProc := guigfx_exit;
-    if GuiGFXBase <> nil then begin
-        CloseLibrary(GuiGFXBase);
-        GuiGFXBase := nil;
-    end;
-end;
-
-begin
-    GuiGFXBase := nil;
-    GuiGFXBase := OpenLibrary(GUIGFXNAME,LIBVERSION);
-    if GuiGFXBase <> nil then begin
-        guigfx_exit := ExitProc;
-        ExitProc := @CloseguigfxLibrary;
-        GUIGFXIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open guigfx.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    GUIGFXIsCompiledHow := 3;
-   {$Warning No autoopening of guigfx.library compiled}
-   {$Warning Make sure you open guigfx.library yourself}
-{$endif dont_use_openlib}
-
+initialization
+  GuiGFXBase := OpenLibrary(GUIGFXNAME,LIBVERSION);
+finalization
+  if Assigned(GuiGFXBase) then
+    CloseLibrary(GuiGFXBase);
 END. (* UNIT GUIGFX *)
 
 

+ 15 - 208
packages/amunits/src/otherlibs/identify.pas

@@ -38,11 +38,6 @@
 
 {$mode objfpc}
 
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-    {$smartlink on}
-{$endif use_amiga_smartlink}
-
 UNIT IDENTIFY;
 
 INTERFACE
@@ -410,16 +405,16 @@ CONST  IDENTIFYBUFLEN = 50;  { default buffer length }
 
 
 
-VAR IdentifyBase : pLibrary;
+VAR IdentifyBase : pLibrary = nil;
 
-FUNCTION IdExpansion(TagList : pTagItem) : LONGINT;
-FUNCTION IdHardware(Type_ : Ulong; TagList : pTagItem) : pCHAR;
-FUNCTION IdAlert(ID : Ulong; TagList : pTagItem) : LONGINT;
-FUNCTION IdFunction(LibName : pCHAR; Offset : LONGINT; TagList : pTagItem) : LONGINT;
-FUNCTION IdHardwareNum(Type_ : Ulong; TagList : pTagItem) : Ulong;
-PROCEDURE IdHardwareUpdate;
-FUNCTION IdFormatString(String_ : pCHAR; Buffer : pCHAR; Length : Ulong; Tags : pTagItem) : Ulong;
-FUNCTION IdEstimateFormatSize(String_ : pCHAR; Tags : pTagItem) : Ulong;
+FUNCTION IdExpansion(TagList : pTagItem location 'a0') : LONGINT; syscall IdentifyBase 30;
+FUNCTION IdHardware(Type_ : Ulong location 'd0'; TagList : pTagItem location 'a0') : pCHAR; syscall IdentifyBase 36;
+FUNCTION IdAlert(ID : Ulong location 'd0'; TagList : pTagItem location 'a0') : LONGINT; syscall IdentifyBase 42;
+FUNCTION IdFunction(LibName : pCHAR location 'a0'; Offset : LONGINT location 'd0'; TagList : pTagItem location 'a1') : LONGINT; syscall IdentifyBase 48;
+FUNCTION IdHardwareNum(Type_ : Ulong location 'd0'; TagList : pTagItem location 'a0') : Ulong; syscall IdentifyBase 54;
+PROCEDURE IdHardwareUpdate; syscall IdentifyBase 60;
+FUNCTION IdFormatString(String_ : pCHAR location 'a0'; Buffer : pCHAR location 'a1'; Length : Ulong location 'd0'; Tags : pTagItem location 'a2') : Ulong; syscall IdentifyBase 66;
+FUNCTION IdEstimateFormatSize(String_ : pCHAR location 'a0'; Tags : pTagItem location 'a1') : Ulong; syscall IdentifyBase 72;
 
 {
      This is functions and procedures with array of const.
@@ -445,126 +440,10 @@ FUNCTION IdFunctionTags(LibName : string; Offset : LONGINT; const TagList : Arra
 FUNCTION IdFormatStringTags(String_ : string; Buffer : pCHAR; Length : longword; const Tags : Array Of Const) : longword;
 FUNCTION IdEstimateFormatSizeTags(String_ : string; const Tags : Array Of Const) : longword;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitIDENTIFYLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    IDENTIFYIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray,pastoc;
-
-FUNCTION IdExpansion(TagList : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L TagList,A0
-        MOVEA.L IdentifyBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION IdHardware(Type_ : Ulong; TagList : pTagItem) : pCHAR;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Type_,D0
-        MOVEA.L TagList,A0
-        MOVEA.L IdentifyBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION IdAlert(ID : Ulong; TagList : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  ID,D0
-        MOVEA.L TagList,A0
-        MOVEA.L IdentifyBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION IdFunction(LibName : pCHAR; Offset : LONGINT; TagList : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LibName,A0
-        MOVE.L  Offset,D0
-        MOVEA.L TagList,A1
-        MOVEA.L IdentifyBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION IdHardwareNum(Type_ : Ulong; TagList : pTagItem) : Ulong;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  Type_,D0
-        MOVEA.L TagList,A0
-        MOVEA.L IdentifyBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE IdHardwareUpdate;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L IdentifyBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION IdFormatString(String_ : pCHAR; Buffer : pCHAR; Length : Ulong; Tags : pTagItem) : Ulong;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L String_,A0
-        MOVEA.L Buffer,A1
-        MOVE.L  Length,D0
-        MOVEA.L Tags,A2
-        MOVEA.L IdentifyBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION IdEstimateFormatSize(String_ : pCHAR; Tags : pTagItem) : Ulong;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L String_,A0
-        MOVEA.L Tags,A1
-        MOVEA.L IdentifyBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
+  tagsarray,pastoc;
 
 {
  Functions and procedures with array of const go here
@@ -640,86 +519,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of identify.library}
-  {$Info don't forget to use InitIDENTIFYLibrary in the beginning of your program}
-
-var
-    identify_exit : Pointer;
-
-procedure CloseidentifyLibrary;
-begin
-    ExitProc := identify_exit;
-    if IdentifyBase <> nil then begin
-        CloseLibrary(IdentifyBase);
-        IdentifyBase := nil;
-    end;
-end;
-
-procedure InitIDENTIFYLibrary;
-begin
-    IdentifyBase := nil;
-    IdentifyBase := OpenLibrary(IDENTIFYNAME,LIBVERSION);
-    if IdentifyBase <> nil then begin
-        identify_exit := ExitProc;
-        ExitProc := @CloseidentifyLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open identify.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    IDENTIFYIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of identify.library}
-
-var
-    identify_exit : Pointer;
-
-procedure CloseidentifyLibrary;
-begin
-    ExitProc := identify_exit;
-    if IdentifyBase <> nil then begin
-        CloseLibrary(IdentifyBase);
-        IdentifyBase := nil;
-    end;
-end;
-
-begin
-    IdentifyBase := nil;
-    IdentifyBase := OpenLibrary(IDENTIFYNAME,LIBVERSION);
-    if IdentifyBase <> nil then begin
-        identify_exit := ExitProc;
-        ExitProc := @CloseidentifyLibrary;
-        IDENTIFYIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open identify.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    IDENTIFYIsCompiledHow := 3;
-   {$Warning No autoopening of identify.library compiled}
-   {$Warning Make sure you open identify.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  IdentifyBase := OpenLibrary(IDENTIFYNAME,LIBVERSION);
+finalization
+  if Assigned(IdentifyBase) then
+    CloseLibrary(IdentifyBase);
 END. (* UNIT IDENTIFY *)
 
 

+ 20 - 269
packages/amunits/src/otherlibs/lucyplay.pas

@@ -28,18 +28,12 @@
   [email protected] Nils Sjoholm
 }
 
-
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-   {$smartlink on}
-{$endif use_amiga_smartlink}
-
 UNIT LUCYPLAY;
 
 INTERFACE
 USES Exec;
 
-VAR LucyPlayBase : pLibrary;
+VAR LucyPlayBase : pLibrary = nil;
 
 const
     LUCYPLAYNAME : PChar = 'lucyplay.library';
@@ -96,276 +90,33 @@ const
      LUC_ERR_READJOYPORT = 9;
      LUC_ERR_DOIO = 10;
 
-
-
-
-PROCEDURE lucAudioFree(smp : pLucyPlaySample);
-FUNCTION lucAudioInit : LONGINT;
-PROCEDURE lucAudioKill;
-FUNCTION lucAudioLoad(fname : pCHAR) : pLucyPlaySample;
-PROCEDURE lucAudioPlay(smp : pLucyPlaySample);
-PROCEDURE lucAudioStop;
-PROCEDURE lucAudioWait;
-FUNCTION lucBestModeID(w : longword; h : longword; d : longword) : longword;
-FUNCTION lucError : longword;
-FUNCTION lucJoyInit : pLucyPlayJoystick;
-FUNCTION lucJoyInitForce : pLucyPlayJoystick;
-PROCEDURE lucJoyKill(joy : pLucyPlayJoystick);
-PROCEDURE lucJoyRead(joy : pLucyPlayJoystick);
-FUNCTION lucJoyReadBool : longword;
-
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitLUCYPLAYLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    LUCYPLAYIsCompiledHow : longint;
+PROCEDURE lucAudioFree(smp : pLucyPlaySample location 'a0'); syscall LucyPlayBase 48;
+FUNCTION lucAudioInit : LONGINT; syscall LucyPlayBase 30;
+PROCEDURE lucAudioKill; syscall LucyPlayBase 36;
+FUNCTION lucAudioLoad(fname : pCHAR location 'a0') : pLucyPlaySample; syscall LucyPlayBase 42;
+PROCEDURE lucAudioPlay(smp : pLucyPlaySample location 'a0'); syscall LucyPlayBase 54;
+PROCEDURE lucAudioStop; syscall LucyPlayBase 60;
+PROCEDURE lucAudioWait; syscall LucyPlayBase 66;
+FUNCTION lucBestModeID(w : longword location 'd0'; h : longword location 'd1'; d : longword location 'd2') : longword; syscall LucyPlayBase 96;
+FUNCTION lucError : longword; syscall LucyPlayBase 108;
+FUNCTION lucJoyInit : pLucyPlayJoystick; syscall LucyPlayBase 72;
+FUNCTION lucJoyInitForce : pLucyPlayJoystick; syscall LucyPlayBase 102;
+PROCEDURE lucJoyKill(joy : pLucyPlayJoystick location 'a0'); syscall LucyPlayBase 78;
+PROCEDURE lucJoyRead(joy : pLucyPlayJoystick location 'a0'); syscall LucyPlayBase 84;
+FUNCTION lucJoyReadBool : longword; syscall LucyPlayBase 90;
 
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
-PROCEDURE lucAudioFree(smp : pLucyPlaySample);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L smp,A0
-        MOVEA.L LucyPlayBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION lucAudioInit : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LucyPlayBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE lucAudioKill;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LucyPlayBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION lucAudioLoad(fname : pCHAR) : pLucyPlaySample;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L fname,A0
-        MOVEA.L LucyPlayBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE lucAudioPlay(smp : pLucyPlaySample);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L smp,A0
-        MOVEA.L LucyPlayBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE lucAudioStop;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LucyPlayBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE lucAudioWait;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LucyPlayBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION lucBestModeID(w : longword; h : longword; d : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  w,D0
-        MOVE.L  h,D1
-        MOVE.L  d,D2
-        MOVEA.L LucyPlayBase,A6
-        JSR     -096(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION lucError : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LucyPlayBase,A6
-        JSR     -108(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION lucJoyInit : pLucyPlayJoystick;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LucyPlayBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION lucJoyInitForce : pLucyPlayJoystick;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LucyPlayBase,A6
-        JSR     -102(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE lucJoyKill(joy : pLucyPlayJoystick);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L joy,A0
-        MOVEA.L LucyPlayBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE lucJoyRead(joy : pLucyPlayJoystick);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L joy,A0
-        MOVEA.L LucyPlayBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION lucJoyReadBool : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L LucyPlayBase,A6
-        JSR     -090(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of lucyplay.library}
-  {$Info don't forget to use InitLUCYPLAYLibrary in the beginning of your program}
-
-var
-    lucyplay_exit : Pointer;
-
-procedure CloselucyplayLibrary;
-begin
-    ExitProc := lucyplay_exit;
-    if LucyPlayBase <> nil then begin
-        CloseLibrary(LucyPlayBase);
-        LucyPlayBase := nil;
-    end;
-end;
-
-procedure InitLUCYPLAYLibrary;
-begin
-    LucyPlayBase := nil;
-    LucyPlayBase := OpenLibrary(LUCYPLAYNAME,LIBVERSION);
-    if LucyPlayBase <> nil then begin
-        lucyplay_exit := ExitProc;
-        ExitProc := @CloselucyplayLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open lucyplay.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    LUCYPLAYIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of lucyplay.library}
-
-var
-    lucyplay_exit : Pointer;
-
-procedure CloselucyplayLibrary;
-begin
-    ExitProc := lucyplay_exit;
-    if LucyPlayBase <> nil then begin
-        CloseLibrary(LucyPlayBase);
-        LucyPlayBase := nil;
-    end;
-end;
-
-begin
-    LucyPlayBase := nil;
-    LucyPlayBase := OpenLibrary(LUCYPLAYNAME,LIBVERSION);
-    if LucyPlayBase <> nil then begin
-        lucyplay_exit := ExitProc;
-        ExitProc := @CloselucyplayLibrary;
-        LUCYPLAYIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open lucyplay.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    LUCYPLAYIsCompiledHow := 3;
-   {$Warning No autoopening of lucyplay.library compiled}
-   {$Warning Make sure you open lucyplay.library yourself}
-{$endif dont_use_openlib}
-
+initialization
+  LucyPlayBase := OpenLibrary(LUCYPLAYNAME,LIBVERSION);
+finalization
+  if Assigned(LucyPlayBase) then
+    CloseLibrary(LucyPlayBase);
 END. (* UNIT LUCYPLAY *)
 
 

+ 6 - 82
packages/amunits/src/otherlibs/mui.pas

@@ -34,10 +34,6 @@
     [email protected]
 }
 {$mode objfpc}
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-    {$smartlink on}
-{$endif use_amiga_smartlink}
 
 unit mui;
 
@@ -3473,7 +3469,7 @@ uses exec, intuition,utility,agraphics,iffparse;
          end;
        pMUI_CustomClass = ^tMUI_CustomClass;
 
-VAR MUIMasterBase : pLibrary;
+VAR MUIMasterBase : pLibrary = nil;
 
 FUNCTION MUI_NewObjectA(class_ : pCHar location 'a0'; tags : pTagItem location 'a1') : pObject_; syscall MUIMasterBase 030;
 PROCEDURE MUI_DisposeObject(obj : pObject_ location 'a0'); syscall MUIMasterBase 036;
@@ -3897,84 +3893,12 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of muimaster.library}
-  {$Info don't forget to use InitMUIMASTERLibrary in the beginning of your program}
-
-var
-    muimaster_exit : Pointer;
-
-procedure ClosemuimasterLibrary;
-begin
-    ExitProc := muimaster_exit;
-    if MUIMasterBase <> nil then begin
-        CloseLibrary(MUIMasterBase);
-        MUIMasterBase := nil;
-    end;
-end;
-
-procedure InitMUIMASTERLibrary;
-begin
-    MUIMasterBase := nil;
-    MUIMasterBase := OpenLibrary(MUIMASTER_NAME,LIBVERSION);
-    if MUIMasterBase <> nil then begin
-        muimaster_exit := ExitProc;
-        ExitProc := @ClosemuimasterLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open muimaster.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    MUIMASTERIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of muimaster.library}
-
-var
-    muimaster_exit : Pointer;
-
-procedure ClosemuimasterLibrary;
-begin
-    ExitProc := muimaster_exit;
-    if MUIMasterBase <> nil then begin
-        CloseLibrary(MUIMasterBase);
-        MUIMasterBase := nil;
-    end;
-end;
-
-begin
-    MUIMasterBase := nil;
-    MUIMasterBase := OpenLibrary(MUIMASTER_NAME,LIBVERSION);
-    if MUIMasterBase <> nil then begin
-        muimaster_exit := ExitProc;
-        ExitProc := @ClosemuimasterLibrary;
-        MUIMASTERIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open muimaster.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    MUIMASTERIsCompiledHow := 3;
-   {$Warning No autoopening of muimaster.library compiled}
-   {$Warning Make sure you open muimaster.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  MUIMasterBase := OpenLibrary(MUIMASTER_NAME,LIBVERSION);
+finalization
+  if Assigned(MUIMasterBase) then
+    CloseLibrary(MUIMasterBase);
 end.

+ 16 - 220
packages/amunits/src/otherlibs/mysticview.pas

@@ -28,17 +28,13 @@
 }
 
 {$mode objfpc}
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-   {$smartlink on}
-{$endif use_amiga_smartlink}
 
 UNIT MYSTICVIEW;
 
 INTERFACE
 USES Exec,agraphics,utility,intuition;
 
-VAR MysticBase : pLibrary;
+VAR MysticBase : pLibrary = nil;
 
 const
     MYSTICVIEWNAME : PChar = 'mysticview.library';
@@ -149,19 +145,15 @@ const
   { auto dithering  }
      MVDITHERMODE_AUTO = 2;
 
-
-
-
-
-FUNCTION MV_CreateA(screen : pScreen; a1arg : pRastPort; tags : pTagItem) : POINTER;
-PROCEDURE MV_Delete(mview : POINTER);
-PROCEDURE MV_DrawOff(mview : POINTER);
-FUNCTION MV_DrawOn(mview : POINTER) : BOOLEAN;
-PROCEDURE MV_GetAttrsA(mview : POINTER; tags : pTagItem);
-PROCEDURE MV_Refresh(mview : POINTER);
-PROCEDURE MV_SetAttrsA(mview : POINTER; tags : pTagItem);
-PROCEDURE MV_SetViewRelative(mview : POINTER; x : LONGINT; y : LONGINT);
-PROCEDURE MV_SetViewStart(mview : POINTER; x : LONGINT; y : LONGINT);
+FUNCTION MV_CreateA(screen : pScreen location 'a0'; a1arg : pRastPort location 'a1'; tags : pTagItem location 'a2') : POINTER; syscall MysticBase 30;
+PROCEDURE MV_Delete(mview : POINTER location 'a0'); syscall MysticBase 36;
+PROCEDURE MV_DrawOff(mview : POINTER location 'a0'); syscall MysticBase 54;
+FUNCTION MV_DrawOn(mview : POINTER location 'a0') : BOOLEAN; syscall MysticBase 48;
+PROCEDURE MV_GetAttrsA(mview : POINTER location 'a0'; tags : pTagItem location 'a1'); syscall MysticBase 66;
+PROCEDURE MV_Refresh(mview : POINTER location 'a0'); syscall MysticBase 60;
+PROCEDURE MV_SetAttrsA(mview : POINTER location 'a0'; tags : pTagItem location 'a1'); syscall MysticBase 42;
+PROCEDURE MV_SetViewRelative(mview : POINTER location 'a0'; x : LONGINT location 'd0'; y : LONGINT location 'd1'); syscall MysticBase 78;
+PROCEDURE MV_SetViewStart(mview : POINTER location 'a0'; x : LONGINT location 'd0'; y : LONGINT location 'd1'); syscall MysticBase 72;
 {
  Functions and procedures with array of const go here
 }
@@ -169,135 +161,10 @@ FUNCTION MV_Create(screen : pScreen; a1arg : pRastPort; const tags : Array Of Co
 PROCEDURE MV_GetAttrs(mview : POINTER; const tags : Array Of Const);
 PROCEDURE MV_SetAttrs(mview : POINTER; const tags : Array Of Const);
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitMYSTICVIEWLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    MYSTICVIEWIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
-
-FUNCTION MV_CreateA(screen : pScreen; a1arg : pRastPort; tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L screen,A0
-        MOVEA.L a1arg,A1
-        MOVEA.L tags,A2
-        MOVEA.L MysticBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE MV_Delete(mview : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mview,A0
-        MOVEA.L MysticBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE MV_DrawOff(mview : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mview,A0
-        MOVEA.L MysticBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION MV_DrawOn(mview : POINTER) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mview,A0
-        MOVEA.L MysticBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-PROCEDURE MV_GetAttrsA(mview : POINTER; tags : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mview,A0
-        MOVEA.L tags,A1
-        MOVEA.L MysticBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE MV_Refresh(mview : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mview,A0
-        MOVEA.L MysticBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE MV_SetAttrsA(mview : POINTER; tags : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mview,A0
-        MOVEA.L tags,A1
-        MOVEA.L MysticBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE MV_SetViewRelative(mview : POINTER; x : LONGINT; y : LONGINT);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mview,A0
-        MOVE.L  x,D0
-        MOVE.L  y,D1
-        MOVEA.L MysticBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE MV_SetViewStart(mview : POINTER; x : LONGINT; y : LONGINT);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mview,A0
-        MOVE.L  x,D0
-        MOVE.L  y,D1
-        MOVEA.L MysticBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
+  tagsarray;
 
 {
  Functions and procedures with array of const go here
@@ -319,85 +186,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of mysticview.library}
-  {$Info don't forget to use InitMYSTICVIEWLibrary in the beginning of your program}
-
-var
-    mysticview_exit : Pointer;
-
-procedure ClosemysticviewLibrary;
-begin
-    ExitProc := mysticview_exit;
-    if MysticBase <> nil then begin
-        CloseLibrary(MysticBase);
-        MysticBase := nil;
-    end;
-end;
-
-procedure InitMYSTICVIEWLibrary;
-begin
-    MysticBase := nil;
-    MysticBase := OpenLibrary(MYSTICVIEWNAME,LIBVERSION);
-    if MysticBase <> nil then begin
-        mysticview_exit := ExitProc;
-        ExitProc := @ClosemysticviewLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open mysticview.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    MYSTICVIEWIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of mysticview.library}
-
-var
-    mysticview_exit : Pointer;
-
-procedure ClosemysticviewLibrary;
-begin
-    ExitProc := mysticview_exit;
-    if MysticBase <> nil then begin
-        CloseLibrary(MysticBase);
-        MysticBase := nil;
-    end;
-end;
-
-begin
-    MysticBase := nil;
-    MysticBase := OpenLibrary(MYSTICVIEWNAME,LIBVERSION);
-    if MysticBase <> nil then begin
-        mysticview_exit := ExitProc;
-        ExitProc := @ClosemysticviewLibrary;
-        MYSTICVIEWIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open mysticview.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    MYSTICVIEWIsCompiledHow := 3;
-   {$Warning No autoopening of mysticview.library compiled}
-   {$Warning Make sure you open mysticview.library yourself}
-{$endif dont_use_openlib}
-
+initialization
+  MysticBase := OpenLibrary(MYSTICVIEWNAME,LIBVERSION);
+finalization
+  if Assigned(MysticBase) then
+    CloseLibrary(MysticBase);
 END. (* UNIT MYSTICVIEW *)
 
 

+ 7 - 95
packages/amunits/src/otherlibs/picasso96api.pas

@@ -401,7 +401,7 @@ USES Exec, utility, agraphics, intuition;
      {                                                                       }
 
 
-VAR P96Base : pLibrary;
+VAR P96Base : pLibrary = nil;
 
 FUNCTION p96AllocBitMap(SizeX : Ulong location 'd0'; SizeY : Ulong location 'd1'; Depth : Ulong location 'd2'; Flags : Ulong location 'd3'; Friend : pBitMap location 'a0'; RGBFormat : RGBFTYPE location 'd7') : pBitMap; syscall P96Base 030;
 PROCEDURE p96FreeBitMap(BitMap : pBitMap location 'a0'); syscall P96Base 036;
@@ -442,26 +442,10 @@ FUNCTION p96PIP_GetTags(Window : pWindow; const Tags : Array Of Const) : LONGINT
 FUNCTION p96GetRTGDataTags(const Tags : Array Of Const) : LONGINT;
 FUNCTION p96GetBoardDataTags(Board : longword; const Tags : Array Of Const) : LONGINT;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitPICASSO96APILibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    PICASSO96APIIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
-
-
-
+  tagsarray;
 
 {
  Functions and procedures with array of const go here
@@ -513,86 +497,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of picasso96api.library}
-  {$Info don't forget to use InitPICASSO96APILibrary in the beginning of your program}
-
-var
-    picasso96api_exit : Pointer;
-
-procedure Closepicasso96apiLibrary;
-begin
-    ExitProc := picasso96api_exit;
-    if P96Base <> nil then begin
-        CloseLibrary(P96Base);
-        P96Base := nil;
-    end;
-end;
-
-procedure InitPICASSO96APILibrary;
-begin
-    P96Base := nil;
-    P96Base := OpenLibrary(PICASSO96APINAME,LIBVERSION);
-    if P96Base <> nil then begin
-        picasso96api_exit := ExitProc;
-        ExitProc := @Closepicasso96apiLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open picasso96api.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    PICASSO96APIIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of picasso96api.library}
-
-var
-    picasso96api_exit : Pointer;
-
-procedure Closepicasso96apiLibrary;
-begin
-    ExitProc := picasso96api_exit;
-    if P96Base <> nil then begin
-        CloseLibrary(P96Base);
-        P96Base := nil;
-    end;
-end;
-
-begin
-    P96Base := nil;
-    P96Base := OpenLibrary(PICASSO96APINAME,LIBVERSION);
-    if P96Base <> nil then begin
-        picasso96api_exit := ExitProc;
-        ExitProc := @Closepicasso96apiLibrary;
-        PICASSO96APIIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open picasso96api.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    PICASSO96APIIsCompiledHow := 3;
-   {$Warning No autoopening of picasso96api.library compiled}
-   {$Warning Make sure you open picasso96api.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  P96Base := OpenLibrary(PICASSO96APINAME,LIBVERSION);
+finalization
+  if Assigned(P96Base) then
+    CloseLibrary(P96Base);
 END. (* UNIT PICASSO96API *)
 
 

+ 16 - 249
packages/amunits/src/otherlibs/preferences.pas

@@ -28,17 +28,12 @@
   [email protected] Nils Sjoholm
 }
 
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-   {$smartlink on}
-{$endif use_amiga_smartlink}
-
 UNIT PREFERENCES;
 
 INTERFACE
 USES Exec;
 
-VAR PreferencesBase : pLibrary;
+VAR PreferencesBase : pLibrary = nil;
 
 const
     PREFERENCESNAME : PChar = 'preferences.library';
@@ -134,257 +129,29 @@ const
      SCP_PlugInList = $80000035;
 
 
-
-FUNCTION AllocPrefsHandle(name : pCHAR) : POINTER;
-FUNCTION FindPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword) : pPrefsStruct;
-PROCEDURE FreePrefsHandle(PrefsHandle : POINTER);
-FUNCTION GetEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD; Entry : longword) : longword;
-FUNCTION GetPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD) : longword;
-PROCEDURE ReadPrefsHandle(PrefsHandle : POINTER; Filename : pCHAR);
-FUNCTION RemEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; Entry : longword) : longword;
-PROCEDURE SetEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD; Entry : longword);
-PROCEDURE SetPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD);
-PROCEDURE WritePrefsHandle(PrefsHandle : POINTER; Filename : pCHAR);
-
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitPREFERENCESLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    PREFERENCESIsCompiledHow : longint;
-
+FUNCTION AllocPrefsHandle(name : pCHAR location 'a0') : POINTER; syscall PreferencesBase 30;
+FUNCTION FindPreferences(PrefsHandle : POINTER location 'a0'; ID : longword location 'd0'; d1arg : longword location 'd1') : pPrefsStruct; syscall PreferencesBase 66;
+PROCEDURE FreePrefsHandle(PrefsHandle : POINTER location 'a0'); syscall PreferencesBase 36;
+FUNCTION GetEntry(PrefsHandle : POINTER location 'a0'; ID : longword location 'd0'; d1arg : longword location 'd1'; a1arg : POINTER location 'a1'; Struct_Size : WORD location 'd2'; Entry : longword location 'd3') : longword; syscall PreferencesBase 78;
+FUNCTION GetPreferences(PrefsHandle : POINTER location 'a0'; ID : longword location 'd0'; d1arg : longword location 'd1'; a1arg : POINTER location 'a1'; Struct_Size : WORD location 'd2') : longword; syscall PreferencesBase 48;
+PROCEDURE ReadPrefsHandle(PrefsHandle : POINTER location 'a0'; Filename : pCHAR location 'a1'); syscall PreferencesBase 54;
+FUNCTION RemEntry(PrefsHandle : POINTER location 'a0'; ID : longword location 'd0'; d1arg : longword location 'd1'; Entry : longword location 'd2') : longword; syscall PreferencesBase 84;
+PROCEDURE SetEntry(PrefsHandle : POINTER location 'a0'; ID : longword location 'd0'; d1arg : longword location 'd1'; a1arg : POINTER location 'a1'; Struct_Size : WORD location 'd2'; Entry : longword location 'd3'); syscall PreferencesBase 72;
+PROCEDURE SetPreferences(PrefsHandle : POINTER location 'a0'; ID : longword location 'd0'; d1arg : longword location 'd1'; a1arg : POINTER location 'a1'; Struct_Size : WORD location 'd2'); syscall PreferencesBase 42;
+PROCEDURE WritePrefsHandle(PrefsHandle : POINTER location 'a0'; Filename : pCHAR location 'a1'); syscall PreferencesBase 60;
 
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
-FUNCTION AllocPrefsHandle(name : pCHAR) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L name,A0
-        MOVEA.L PreferencesBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION FindPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword) : pPrefsStruct;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVE.L  ID,D0
-        MOVE.L  d1arg,D1
-        MOVEA.L PreferencesBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE FreePrefsHandle(PrefsHandle : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVEA.L PreferencesBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION GetEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD; Entry : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVE.L  ID,D0
-        MOVE.L  d1arg,D1
-        MOVEA.L a1arg,A1
-        MOVE.L  Struct_Size,D2
-        MOVE.L  Entry,D3
-        MOVEA.L PreferencesBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION GetPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVE.L  ID,D0
-        MOVE.L  d1arg,D1
-        MOVEA.L a1arg,A1
-        MOVE.L  Struct_Size,D2
-        MOVEA.L PreferencesBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE ReadPrefsHandle(PrefsHandle : POINTER; Filename : pCHAR);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVEA.L Filename,A1
-        MOVEA.L PreferencesBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION RemEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; Entry : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVE.L  ID,D0
-        MOVE.L  d1arg,D1
-        MOVE.L  Entry,D2
-        MOVEA.L PreferencesBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE SetEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD; Entry : longword);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVE.L  ID,D0
-        MOVE.L  d1arg,D1
-        MOVEA.L a1arg,A1
-        MOVE.L  Struct_Size,D2
-        MOVE.L  Entry,D3
-        MOVEA.L PreferencesBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE SetPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVE.L  ID,D0
-        MOVE.L  d1arg,D1
-        MOVEA.L a1arg,A1
-        MOVE.L  Struct_Size,D2
-        MOVEA.L PreferencesBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE WritePrefsHandle(PrefsHandle : POINTER; Filename : pCHAR);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L PrefsHandle,A0
-        MOVEA.L Filename,A1
-        MOVEA.L PreferencesBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of preferences.library}
-  {$Info don't forget to use InitPREFERENCESLibrary in the beginning of your program}
-
-var
-    preferences_exit : Pointer;
-
-procedure ClosepreferencesLibrary;
-begin
-    ExitProc := preferences_exit;
-    if PreferencesBase <> nil then begin
-        CloseLibrary(PreferencesBase);
-        PreferencesBase := nil;
-    end;
-end;
-
-procedure InitPREFERENCESLibrary;
-begin
-    PreferencesBase := nil;
-    PreferencesBase := OpenLibrary(PREFERENCESNAME,LIBVERSION);
-    if PreferencesBase <> nil then begin
-        preferences_exit := ExitProc;
-        ExitProc := @ClosepreferencesLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open preferences.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    PREFERENCESIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of preferences.library}
-
-var
-    preferences_exit : Pointer;
-
-procedure ClosepreferencesLibrary;
-begin
-    ExitProc := preferences_exit;
-    if PreferencesBase <> nil then begin
-        CloseLibrary(PreferencesBase);
-        PreferencesBase := nil;
-    end;
-end;
-
-begin
-    PreferencesBase := nil;
-    PreferencesBase := OpenLibrary(PREFERENCESNAME,LIBVERSION);
-    if PreferencesBase <> nil then begin
-        preferences_exit := ExitProc;
-        ExitProc := @ClosepreferencesLibrary;
-        PREFERENCESIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open preferences.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    PREFERENCESIsCompiledHow := 3;
-   {$Warning No autoopening of preferences.library compiled}
-   {$Warning Make sure you open preferences.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  PreferencesBase := OpenLibrary(PREFERENCESNAME,LIBVERSION);
+finalization
+  if Assigned(PreferencesBase) then
+    CloseLibrary(PreferencesBase);
 END. (* UNIT PREFERENCES *)
 
 

+ 6 - 94
packages/amunits/src/otherlibs/ptreplay.pas

@@ -59,7 +59,7 @@ USES Exec;
           Replen   : WORD;                 { Repeat length in number of words  }
        end;
 
-VAR PTReplayBase : pLibrary;
+VAR PTReplayBase : pLibrary = nil;
 
 FUNCTION PTLoadModule(name : pCHAR location 'a0') : pModule; syscall PTReplayBase 030;
 PROCEDURE PTUnloadModule(module : pModule location 'a0'); syscall PTReplayBase 036;
@@ -88,24 +88,8 @@ FUNCTION PTGetSample(Module : pModule location 'a0'; Nr : smallint location 'd0'
 
 FUNCTION PTLoadModule(const name : String) : pModule;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitPTREPLAYLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    PTREPLAYIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses
-  amsgbox;
-{$endif dont_use_openlib}
-
-
 FUNCTION PTLoadModule(const name : string) : pModule;
 var
   s: RawByteString;
@@ -116,84 +100,12 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of ptreplay.library}
-  {$Info don't forget to use InitPTREPLAYLibrary in the beginning of your program}
-
-var
-    ptreplay_exit : Pointer;
-
-procedure CloseptreplayLibrary;
-begin
-    ExitProc := ptreplay_exit;
-    if PTReplayBase <> nil then begin
-        CloseLibrary(PTReplayBase);
-        PTReplayBase := nil;
-    end;
-end;
-
-procedure InitPTREPLAYLibrary;
-begin
-    PTReplayBase := nil;
-    PTReplayBase := OpenLibrary(PTREPLAYNAME,LIBVERSION);
-    if PTReplayBase <> nil then begin
-        ptreplay_exit := ExitProc;
-        ExitProc := @CloseptreplayLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open ptreplay.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    PTREPLAYIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of ptreplay.library}
-
-var
-    ptreplay_exit : Pointer;
-
-procedure CloseptreplayLibrary;
-begin
-    ExitProc := ptreplay_exit;
-    if PTReplayBase <> nil then begin
-        CloseLibrary(PTReplayBase);
-        PTReplayBase := nil;
-    end;
-end;
-
-begin
-    PTReplayBase := nil;
-    PTReplayBase := OpenLibrary(PTREPLAYNAME,LIBVERSION);
-    if PTReplayBase <> nil then begin
-        ptreplay_exit := ExitProc;
-        ExitProc := @CloseptreplayLibrary;
-        PTREPLAYIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open ptreplay.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    PTREPLAYIsCompiledHow := 3;
-   {$Warning No autoopening of ptreplay.library compiled}
-   {$Warning Make sure you open ptreplay.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  PTReplayBase := OpenLibrary(PTREPLAYNAME,LIBVERSION);
+finalization
+  if Assigned(PTReplayBase) then
+    CloseLibrary(PTReplayBase);
 END. (* UNIT PTREPLAY *)

+ 53 - 800
packages/amunits/src/otherlibs/render.pas

@@ -29,17 +29,13 @@
 }
 
 {$mode objfpc}
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-   {$smartlink on}
-{$endif use_amiga_smartlink}
 
 UNIT RENDER;
 
 INTERFACE
 USES Exec,utility,agraphics;
 
-VAR RenderBase : pLibrary;
+VAR RenderBase : pLibrary = nil;
 
 type
     pPLANEPTR = ^TPLANEPTR;
@@ -354,52 +350,52 @@ const
 
 
 
-FUNCTION AddChunkyImageA(histogram : POINTER; chunky : pByte; width : WORD; height : WORD; palette : POINTER; taglist : pTagItem) : longword;
-FUNCTION AddHistogramA(histogram1 : POINTER; histogram2 : POINTER; taglist : pTagItem) : longword;
-FUNCTION AddRGB(histogram : POINTER; RGB : longword; count : longword) : longword;
-FUNCTION AddRGBImageA(histogram : POINTER; rgb : pULONG; width : WORD; height : WORD; taglist : pTagItem) : longword;
-FUNCTION AllocRenderMem(rendermemhandler : POINTER; size : longword) : POINTER;
-FUNCTION AllocRenderVec(rendermemhandler : POINTER; size : longword) : POINTER;
-FUNCTION AllocRenderVecClear(rendermemhandler : POINTER; size : longword) : POINTER;
-PROCEDURE ApplyAlphaChannelA(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; taglist : pTagItem);
-FUNCTION BestPen(palette : POINTER; rgb : longword) : LONGINT;
-PROCEDURE Chunky2BitMapA(chunky : pByte; sx : WORD; sy : WORD; width : WORD; height : WORD; bitmap : pBitMap; dx : WORD; dy : WORD; taglist : pTagItem);
-FUNCTION Chunky2RGBA(chunky : pByte; width : WORD; height : WORD; rgb : pULONG; palette : POINTER; taglist : pTagItem) : longword;
-FUNCTION ChunkyArrayDiversityA(chunky : pByte; palette : POINTER; width : WORD; height : WORD; taglist : pTagItem) : LONGINT;
-FUNCTION ConvertChunkyA(source : pByte; oldpalette : POINTER; width : WORD; height : WORD; dest : pByte; newpalette : POINTER; taglist : pTagItem) : longword;
-FUNCTION CountRGB(histogram : POINTER; rgb : longword) : longword;
-PROCEDURE CreateAlphaArrayA(rgbarray : pULONG; width : WORD; height : WORD; taglist : pTagItem);
-FUNCTION CreateHistogramA(taglist : pTagItem) : POINTER;
-FUNCTION CreateMapEngineA(palette : POINTER; taglist : pTagItem) : POINTER;
-FUNCTION CreatePaletteA(taglist : pTagItem) : POINTER;
-PROCEDURE CreatePenTableA(chunky : pByte; oldpalette : POINTER; width : WORD; height : WORD; newpalette : POINTER; convtab : pByte; taglist : pTagItem);
-FUNCTION CreateRMHandlerA(taglist : pTagItem) : POINTER;
-FUNCTION CreateScaleEngineA(sourcewidth : WORD; sourceheight : WORD; destwidth : WORD; destheight : WORD; taglist : pTagItem) : POINTER;
-PROCEDURE DeleteHistogram(histogram : POINTER);
-PROCEDURE DeleteMapEngine(engine : POINTER);
-PROCEDURE DeletePalette(palette : POINTER);
-PROCEDURE DeleteRMHandler(rmh : POINTER);
-PROCEDURE DeleteScaleEngine(engine : POINTER);
-PROCEDURE ExportPaletteA(palette : POINTER; coltab : POINTER; taglist : pTagItem);
-PROCEDURE ExtractAlphaChannelA(rgbarray : pULONG; width : WORD; height : WORD; chunkyarray : pByte; taglist : pTagItem);
-FUNCTION ExtractPaletteA(histogram : POINTER; palette : pULONG; numcolors : WORD; taglist : pTagItem) : longword;
-PROCEDURE FlushPalette(palette : POINTER);
-PROCEDURE FreeRenderMem(rendermemhandler : POINTER; mem : POINTER; size : longword);
-PROCEDURE FreeRenderVec(mem : POINTER);
-PROCEDURE ImportPaletteA(palette : POINTER; coltab : POINTER; numcols : WORD; taglist : pTagItem);
-PROCEDURE InsertAlphaChannelA(maskarray : pByte; width : WORD; height : WORD; rgbarray : pULONG; taglist : pTagItem);
-FUNCTION MapChunkyArrayA(engine : POINTER; source : pByte; palette : POINTER; width : WORD; height : WORD; dest : pByte; taglist : pTagItem) : longword;
-FUNCTION MapRGBArrayA(engine : POINTER; rgb : pULONG; width : WORD; height : WORD; chunky : pByte; taglist : pTagItem) : longword;
-PROCEDURE MixAlphaChannelA(source1 : pULONG; source2 : pULONG; width : WORD; height : WORD; dest : pULONG; taglist : pTagItem);
-PROCEDURE MixRGBArrayA(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; ratio : WORD; taglist : pTagItem);
-PROCEDURE Planar2ChunkyA(planetab : pPLANEPTR; bytewidth : WORD; height : WORD; depth : WORD; bytesperrow : WORD; chunky : pByte; taglist : pTagItem);
-FUNCTION QueryHistogram(histogram : POINTER; d0arg : longword) : longword;
-FUNCTION RenderA(rgb : pULONG; width : WORD; height : WORD; chunky : pByte; palette : POINTER; taglist : pTagItem) : longword;
-FUNCTION RGBArrayDiversityA(rgb : pULONG; width : WORD; height : WORD; taglist : pTagItem) : LONGINT;
-FUNCTION ScaleA(engine : POINTER; source : POINTER; dest : POINTER; taglist : pTagItem) : longword;
-FUNCTION ScaleOrdinate(source : WORD; dest : WORD; ordinate : WORD) : WORD;
-FUNCTION SortPaletteA(palette : POINTER; mode : longword; taglist : pTagItem) : longword;
-PROCEDURE TintRGBArrayA(source : pULONG; width : WORD; height : WORD; RGB : longword; ratio : WORD; dest : pULONG; taglist : pTagItem);
+FUNCTION AddChunkyImageA(histogram : POINTER location 'a0'; chunky : pByte location 'a1'; width : WORD location 'd0'; height : WORD location 'd1'; palette : POINTER location 'a2'; taglist : pTagItem location 'a3') : longword; syscall RenderBase 108;
+FUNCTION AddHistogramA(histogram1 : POINTER location 'a0'; histogram2 : POINTER location 'a1'; taglist : pTagItem location 'a2') : longword; syscall RenderBase 222;
+FUNCTION AddRGB(histogram : POINTER location 'a0'; RGB : longword location 'd0'; count : longword location 'd1') : longword; syscall RenderBase 96;
+FUNCTION AddRGBImageA(histogram : POINTER location 'a0'; rgb : pULONG location 'a1'; width : WORD location 'd0'; height : WORD location 'd1'; taglist : pTagItem location 'a2') : longword; syscall RenderBase 102;
+FUNCTION AllocRenderMem(rendermemhandler : POINTER location 'a0'; size : longword location 'd0') : POINTER; syscall RenderBase 54;
+FUNCTION AllocRenderVec(rendermemhandler : POINTER location 'a0'; size : longword location 'd0') : POINTER; syscall RenderBase 66;
+FUNCTION AllocRenderVecClear(rendermemhandler : POINTER location 'a0'; size : longword location 'd0') : POINTER; syscall RenderBase 306;
+PROCEDURE ApplyAlphaChannelA(sourcearray : pULONG location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; destarray : pULONG location 'a1'; taglist : pTagItem location 'a2'); syscall RenderBase 294;
+FUNCTION BestPen(palette : POINTER location 'a0'; rgb : longword location 'd0') : LONGINT; syscall RenderBase 204;
+PROCEDURE Chunky2BitMapA(chunky : pByte location 'a0'; sx : WORD location 'd0'; sy : WORD location 'd1'; width : WORD location 'd2'; height : WORD location 'd3'; bitmap : pBitMap location 'a1'; dx : WORD location 'd4'; dy : WORD location 'd5'; taglist : pTagItem location 'a2'); syscall RenderBase 138;
+FUNCTION Chunky2RGBA(chunky : pByte location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; rgb : pULONG location 'a1'; palette : POINTER location 'a2'; taglist : pTagItem location 'a3') : longword; syscall RenderBase 132;
+FUNCTION ChunkyArrayDiversityA(chunky : pByte location 'a0'; palette : POINTER location 'a1'; width : WORD location 'd0'; height : WORD location 'd1'; taglist : pTagItem location 'a2') : LONGINT; syscall RenderBase 270;
+FUNCTION ConvertChunkyA(source : pByte location 'a0'; oldpalette : POINTER location 'a1'; width : WORD location 'd0'; height : WORD location 'd1'; dest : pByte location 'a2'; newpalette : POINTER location 'a3'; taglist : pTagItem location 'a4') : longword; syscall RenderBase 162;
+FUNCTION CountRGB(histogram : POINTER location 'a0'; rgb : longword location 'd0') : longword; syscall RenderBase 198;
+PROCEDURE CreateAlphaArrayA(rgbarray : pULONG location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; taglist : pTagItem location 'a1'); syscall RenderBase 312;
+FUNCTION CreateHistogramA(taglist : pTagItem location 'a1') : POINTER; syscall RenderBase 78;
+FUNCTION CreateMapEngineA(palette : POINTER location 'a0'; taglist : pTagItem location 'a1') : POINTER; syscall RenderBase 246;
+FUNCTION CreatePaletteA(taglist : pTagItem location 'a1') : POINTER; syscall RenderBase 174;
+PROCEDURE CreatePenTableA(chunky : pByte location 'a0'; oldpalette : POINTER location 'a1'; width : WORD location 'd0'; height : WORD location 'd1'; newpalette : POINTER location 'a2'; convtab : pByte location 'a3'; taglist : pTagItem location 'a4'); syscall RenderBase 168;
+FUNCTION CreateRMHandlerA(taglist : pTagItem location 'a1') : POINTER; syscall RenderBase 42;
+FUNCTION CreateScaleEngineA(sourcewidth : WORD location 'd0'; sourceheight : WORD location 'd1'; destwidth : WORD location 'd2'; destheight : WORD location 'd3'; taglist : pTagItem location 'a1') : POINTER; syscall RenderBase 144;
+PROCEDURE DeleteHistogram(histogram : POINTER location 'a0'); syscall RenderBase 84;
+PROCEDURE DeleteMapEngine(engine : POINTER location 'a0'); syscall RenderBase 252;
+PROCEDURE DeletePalette(palette : POINTER location 'a0'); syscall RenderBase 180;
+PROCEDURE DeleteRMHandler(rmh : POINTER location 'a0'); syscall RenderBase 48;
+PROCEDURE DeleteScaleEngine(engine : POINTER location 'a0'); syscall RenderBase 150;
+PROCEDURE ExportPaletteA(palette : POINTER location 'a0'; coltab : POINTER location 'a1'; taglist : pTagItem location 'a2'); syscall RenderBase 192;
+PROCEDURE ExtractAlphaChannelA(rgbarray : pULONG location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; chunkyarray : pByte location 'a1'; taglist : pTagItem location 'a2'); syscall RenderBase 288;
+FUNCTION ExtractPaletteA(histogram : POINTER location 'a0'; palette : pULONG location 'a1'; numcolors : WORD location 'd0'; taglist : pTagItem location 'a2') : longword; syscall RenderBase 114;
+PROCEDURE FlushPalette(palette : POINTER location 'a0'); syscall RenderBase 210;
+PROCEDURE FreeRenderMem(rendermemhandler : POINTER location 'a0'; mem : POINTER location 'a1'; size : longword location 'd0'); syscall RenderBase 60;
+PROCEDURE FreeRenderVec(mem : POINTER location 'a0'); syscall RenderBase 72;
+PROCEDURE ImportPaletteA(palette : POINTER location 'a0'; coltab : POINTER location 'a1'; numcols : WORD location 'd0'; taglist : pTagItem location 'a2'); syscall RenderBase 186;
+PROCEDURE InsertAlphaChannelA(maskarray : pByte location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; rgbarray : pULONG location 'a1'; taglist : pTagItem location 'a2'); syscall RenderBase 282;
+FUNCTION MapChunkyArrayA(engine : POINTER location 'a0'; source : pByte location 'a1'; palette : POINTER location 'a2'; width : WORD location 'd0'; height : WORD location 'd1'; dest : pByte location 'a3'; taglist : pTagItem location 'a4') : longword; syscall RenderBase 276;
+FUNCTION MapRGBArrayA(engine : POINTER location 'a0'; rgb : pULONG location 'a1'; width : WORD location 'd0'; height : WORD location 'd1'; chunky : pByte location 'a2'; taglist : pTagItem location 'a3') : longword; syscall RenderBase 258;
+PROCEDURE MixAlphaChannelA(source1 : pULONG location 'a0'; source2 : pULONG location 'a1'; width : WORD location 'd0'; height : WORD location 'd1'; dest : pULONG location 'a2'; taglist : pTagItem location 'a3'); syscall RenderBase 318;
+PROCEDURE MixRGBArrayA(sourcearray : pULONG location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; destarray : pULONG location 'a1'; ratio : WORD location 'd2'; taglist : pTagItem location 'a2'); syscall RenderBase 300;
+PROCEDURE Planar2ChunkyA(planetab : pPLANEPTR location 'a0'; bytewidth : WORD location 'd0'; height : WORD location 'd1'; depth : WORD location 'd2'; bytesperrow : WORD location 'd3'; chunky : pByte location 'a1'; taglist : pTagItem location 'a2'); syscall RenderBase 126;
+FUNCTION QueryHistogram(histogram : POINTER location 'a0'; d0arg : longword location 'd0') : longword; syscall RenderBase 90;
+FUNCTION RenderA(rgb : pULONG location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; chunky : pByte location 'a1'; palette : POINTER location 'a2'; taglist : pTagItem location 'a3') : longword; syscall RenderBase 120;
+FUNCTION RGBArrayDiversityA(rgb : pULONG location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; taglist : pTagItem location 'a1') : LONGINT; syscall RenderBase 264;
+FUNCTION ScaleA(engine : POINTER location 'a0'; source : POINTER location 'a1'; dest : POINTER location 'a2'; taglist : pTagItem location 'a3') : longword; syscall RenderBase 156;
+FUNCTION ScaleOrdinate(source : WORD location 'd0'; dest : WORD location 'd1'; ordinate : WORD location 'd2') : WORD; syscall RenderBase 228;
+FUNCTION SortPaletteA(palette : POINTER location 'a0'; mode : longword location 'd0'; taglist : pTagItem location 'a1') : longword; syscall RenderBase 216;
+PROCEDURE TintRGBArrayA(source : pULONG location 'a0'; width : WORD location 'd0'; height : WORD location 'd1'; RGB : longword location 'd2'; ratio : WORD location 'd3'; dest : pULONG location 'a1'; taglist : pTagItem location 'a2'); syscall RenderBase 324;
 {
  Functions and procedures with array of const go here
 }
@@ -434,681 +430,10 @@ FUNCTION Scale(engine : POINTER; source : POINTER; dest : POINTER; const taglist
 FUNCTION SortPalette(palette : POINTER; mode : longword; const taglist : Array Of Const) : longword;
 PROCEDURE TintRGBArray(source : pULONG; width : WORD; height : WORD; RGB : longword; ratio : WORD; dest : pULONG; const taglist : Array Of Const);
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitRENDERLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    RENDERIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
-
-FUNCTION AddChunkyImageA(histogram : POINTER; chunky : pByte; width : WORD; height : WORD; palette : POINTER; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L histogram,A0
-        MOVEA.L chunky,A1
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L palette,A2
-        MOVEA.L taglist,A3
-        MOVEA.L RenderBase,A6
-        JSR     -108(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AddHistogramA(histogram1 : POINTER; histogram2 : POINTER; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L histogram1,A0
-        MOVEA.L histogram2,A1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -222(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AddRGB(histogram : POINTER; RGB : longword; count : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L histogram,A0
-        MOVE.L  RGB,D0
-        MOVE.L  count,D1
-        MOVEA.L RenderBase,A6
-        JSR     -096(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AddRGBImageA(histogram : POINTER; rgb : pULONG; width : WORD; height : WORD; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L histogram,A0
-        MOVEA.L rgb,A1
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -102(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AllocRenderMem(rendermemhandler : POINTER; size : longword) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rendermemhandler,A0
-        MOVE.L  size,D0
-        MOVEA.L RenderBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AllocRenderVec(rendermemhandler : POINTER; size : longword) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rendermemhandler,A0
-        MOVE.L  size,D0
-        MOVEA.L RenderBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION AllocRenderVecClear(rendermemhandler : POINTER; size : longword) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rendermemhandler,A0
-        MOVE.L  size,D0
-        MOVEA.L RenderBase,A6
-        JSR     -306(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE ApplyAlphaChannelA(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L sourcearray,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L destarray,A1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -294(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION BestPen(palette : POINTER; rgb : longword) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L palette,A0
-        MOVE.L  rgb,D0
-        MOVEA.L RenderBase,A6
-        JSR     -204(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE Chunky2BitMapA(chunky : pByte; sx : WORD; sy : WORD; width : WORD; height : WORD; bitmap : pBitMap; dx : WORD; dy : WORD; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L chunky,A0
-        MOVE.L  sx,D0
-        MOVE.L  sy,D1
-        MOVE.L  width,D2
-        MOVE.L  height,D3
-        MOVEA.L bitmap,A1
-        MOVE.L  dx,D4
-        MOVE.L  dy,D5
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -138(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION Chunky2RGBA(chunky : pByte; width : WORD; height : WORD; rgb : pULONG; palette : POINTER; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L chunky,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L rgb,A1
-        MOVEA.L palette,A2
-        MOVEA.L taglist,A3
-        MOVEA.L RenderBase,A6
-        JSR     -132(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION ChunkyArrayDiversityA(chunky : pByte; palette : POINTER; width : WORD; height : WORD; taglist : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L chunky,A0
-        MOVEA.L palette,A1
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -270(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION ConvertChunkyA(source : pByte; oldpalette : POINTER; width : WORD; height : WORD; dest : pByte; newpalette : POINTER; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L source,A0
-        MOVEA.L oldpalette,A1
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L dest,A2
-        MOVEA.L newpalette,A3
-        MOVEA.L taglist,A4
-        MOVEA.L RenderBase,A6
-        JSR     -162(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION CountRGB(histogram : POINTER; rgb : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L histogram,A0
-        MOVE.L  rgb,D0
-        MOVEA.L RenderBase,A6
-        JSR     -198(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE CreateAlphaArrayA(rgbarray : pULONG; width : WORD; height : WORD; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rgbarray,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L taglist,A1
-        MOVEA.L RenderBase,A6
-        JSR     -312(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION CreateHistogramA(taglist : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L taglist,A1
-        MOVEA.L RenderBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION CreateMapEngineA(palette : POINTER; taglist : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L palette,A0
-        MOVEA.L taglist,A1
-        MOVEA.L RenderBase,A6
-        JSR     -246(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION CreatePaletteA(taglist : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L taglist,A1
-        MOVEA.L RenderBase,A6
-        JSR     -174(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE CreatePenTableA(chunky : pByte; oldpalette : POINTER; width : WORD; height : WORD; newpalette : POINTER; convtab : pByte; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L chunky,A0
-        MOVEA.L oldpalette,A1
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L newpalette,A2
-        MOVEA.L convtab,A3
-        MOVEA.L taglist,A4
-        MOVEA.L RenderBase,A6
-        JSR     -168(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION CreateRMHandlerA(taglist : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L taglist,A1
-        MOVEA.L RenderBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION CreateScaleEngineA(sourcewidth : WORD; sourceheight : WORD; destwidth : WORD; destheight : WORD; taglist : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  sourcewidth,D0
-        MOVE.L  sourceheight,D1
-        MOVE.L  destwidth,D2
-        MOVE.L  destheight,D3
-        MOVEA.L taglist,A1
-        MOVEA.L RenderBase,A6
-        JSR     -144(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE DeleteHistogram(histogram : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L histogram,A0
-        MOVEA.L RenderBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE DeleteMapEngine(engine : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L engine,A0
-        MOVEA.L RenderBase,A6
-        JSR     -252(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE DeletePalette(palette : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L palette,A0
-        MOVEA.L RenderBase,A6
-        JSR     -180(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE DeleteRMHandler(rmh : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rmh,A0
-        MOVEA.L RenderBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE DeleteScaleEngine(engine : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L engine,A0
-        MOVEA.L RenderBase,A6
-        JSR     -150(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE ExportPaletteA(palette : POINTER; coltab : POINTER; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L palette,A0
-        MOVEA.L coltab,A1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -192(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE ExtractAlphaChannelA(rgbarray : pULONG; width : WORD; height : WORD; chunkyarray : pByte; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rgbarray,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L chunkyarray,A1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -288(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION ExtractPaletteA(histogram : POINTER; palette : pULONG; numcolors : WORD; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L histogram,A0
-        MOVEA.L palette,A1
-        MOVE.L  numcolors,D0
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -114(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE FlushPalette(palette : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L palette,A0
-        MOVEA.L RenderBase,A6
-        JSR     -210(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE FreeRenderMem(rendermemhandler : POINTER; mem : POINTER; size : longword);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rendermemhandler,A0
-        MOVEA.L mem,A1
-        MOVE.L  size,D0
-        MOVEA.L RenderBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE FreeRenderVec(mem : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L mem,A0
-        MOVEA.L RenderBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE ImportPaletteA(palette : POINTER; coltab : POINTER; numcols : WORD; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L palette,A0
-        MOVEA.L coltab,A1
-        MOVE.L  numcols,D0
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -186(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE InsertAlphaChannelA(maskarray : pByte; width : WORD; height : WORD; rgbarray : pULONG; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L maskarray,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L rgbarray,A1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -282(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION MapChunkyArrayA(engine : POINTER; source : pByte; palette : POINTER; width : WORD; height : WORD; dest : pByte; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L engine,A0
-        MOVEA.L source,A1
-        MOVEA.L palette,A2
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L dest,A3
-        MOVEA.L taglist,A4
-        MOVEA.L RenderBase,A6
-        JSR     -276(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION MapRGBArrayA(engine : POINTER; rgb : pULONG; width : WORD; height : WORD; chunky : pByte; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L engine,A0
-        MOVEA.L rgb,A1
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L chunky,A2
-        MOVEA.L taglist,A3
-        MOVEA.L RenderBase,A6
-        JSR     -258(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE MixAlphaChannelA(source1 : pULONG; source2 : pULONG; width : WORD; height : WORD; dest : pULONG; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L source1,A0
-        MOVEA.L source2,A1
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L dest,A2
-        MOVEA.L taglist,A3
-        MOVEA.L RenderBase,A6
-        JSR     -318(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE MixRGBArrayA(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; ratio : WORD; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L sourcearray,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L destarray,A1
-        MOVE.L  ratio,D2
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -300(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE Planar2ChunkyA(planetab : pPLANEPTR; bytewidth : WORD; height : WORD; depth : WORD; bytesperrow : WORD; chunky : pByte; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L planetab,A0
-        MOVE.L  bytewidth,D0
-        MOVE.L  height,D1
-        MOVE.L  depth,D2
-        MOVE.L  bytesperrow,D3
-        MOVEA.L chunky,A1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -126(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION QueryHistogram(histogram : POINTER; d0arg : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L histogram,A0
-        MOVE.L  d0arg,D0
-        MOVEA.L RenderBase,A6
-        JSR     -090(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION RenderA(rgb : pULONG; width : WORD; height : WORD; chunky : pByte; palette : POINTER; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rgb,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L chunky,A1
-        MOVEA.L palette,A2
-        MOVEA.L taglist,A3
-        MOVEA.L RenderBase,A6
-        JSR     -120(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION RGBArrayDiversityA(rgb : pULONG; width : WORD; height : WORD; taglist : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rgb,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVEA.L taglist,A1
-        MOVEA.L RenderBase,A6
-        JSR     -264(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION ScaleA(engine : POINTER; source : POINTER; dest : POINTER; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L engine,A0
-        MOVEA.L source,A1
-        MOVEA.L dest,A2
-        MOVEA.L taglist,A3
-        MOVEA.L RenderBase,A6
-        JSR     -156(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION ScaleOrdinate(source : WORD; dest : WORD; ordinate : WORD) : WORD;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  source,D0
-        MOVE.L  dest,D1
-        MOVE.L  ordinate,D2
-        MOVEA.L RenderBase,A6
-        JSR     -228(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION SortPaletteA(palette : POINTER; mode : longword; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L palette,A0
-        MOVE.L  mode,D0
-        MOVEA.L taglist,A1
-        MOVEA.L RenderBase,A6
-        JSR     -216(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TintRGBArrayA(source : pULONG; width : WORD; height : WORD; RGB : longword; ratio : WORD; dest : pULONG; taglist : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L source,A0
-        MOVE.L  width,D0
-        MOVE.L  height,D1
-        MOVE.L  RGB,D2
-        MOVE.L  ratio,D3
-        MOVEA.L dest,A1
-        MOVEA.L taglist,A2
-        MOVEA.L RenderBase,A6
-        JSR     -324(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
+  tagsarray;
 
 {
  Functions and procedures with array of const go here
@@ -1265,86 +590,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of render.library}
-  {$Info don't forget to use InitRENDERLibrary in the beginning of your program}
-
-var
-    render_exit : Pointer;
-
-procedure CloserenderLibrary;
-begin
-    ExitProc := render_exit;
-    if RenderBase <> nil then begin
-        CloseLibrary(RenderBase);
-        RenderBase := nil;
-    end;
-end;
-
-procedure InitRENDERLibrary;
-begin
-    RenderBase := nil;
-    RenderBase := OpenLibrary(RENDERNAME,LIBVERSION);
-    if RenderBase <> nil then begin
-        render_exit := ExitProc;
-        ExitProc := @CloserenderLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open render.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    RENDERIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of render.library}
-
-var
-    render_exit : Pointer;
-
-procedure CloserenderLibrary;
-begin
-    ExitProc := render_exit;
-    if RenderBase <> nil then begin
-        CloseLibrary(RenderBase);
-        RenderBase := nil;
-    end;
-end;
-
-begin
-    RenderBase := nil;
-    RenderBase := OpenLibrary(RENDERNAME,LIBVERSION);
-    if RenderBase <> nil then begin
-        render_exit := ExitProc;
-        ExitProc := @CloserenderLibrary;
-        RENDERIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open render.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    RENDERIsCompiledHow := 3;
-   {$Warning No autoopening of render.library compiled}
-   {$Warning Make sure you open render.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  RenderBase := OpenLibrary(RENDERNAME,LIBVERSION);
+finalization
+  if Assigned(RenderBase) then
+    CloseLibrary(RenderBase);
 END. (* UNIT RENDER *)
 
 

+ 7 - 94
packages/amunits/src/otherlibs/reqtools.pas

@@ -602,7 +602,7 @@ RTSC_AutoScroll = $80000056;{ (V38) screenmode requester - set autoscroll }
     FREQB_DOWILDFUNC  = 11  deprecated;
     FREQF_DOWILDFUNC  = 2048  deprecated;
 
-VAR ReqToolsBase : pLibrary;
+VAR ReqToolsBase : pLibrary = nil;
 
 FUNCTION rtAllocRequestA(typ : ULONG location 'd0'; taglist : pTagItem location 'a0') : POINTER; syscall ReqToolsBase 030;
 FUNCTION rtChangeReqAttrA(req : POINTER location 'a1'; taglist : pTagItem location 'a0') : LONGINT; syscall ReqToolsBase 048;
@@ -669,25 +669,10 @@ FUNCTION rtGetString(buffer : pCHAR; maxchars : ULONG; const title : RawByteStri
 FUNCTION rtPaletteRequest(const title : RawByteString; reqinfo : prtReqInfo; const argv : Array Of Const) : LONGINT;
 FUNCTION rtScreenModeRequest(screenmodereq : prtScreenModeRequester; const title : RawByteString; const argv : Array Of Const) : ULONG;
 
-
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitREQTOOLSLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    REQTOOLSIsCompiledHow : longint;
-
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
+  tagsarray;
 
 
 FUNCTION rtEZRequestA(bodyfmt : PChar; const gadfmt : RawByteString; reqinfo : prtReqInfo; argarray: POINTER; taglist : pTagItem) : ULONG;
@@ -833,84 +818,12 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of reqtools.library}
-  {$Info don't forget to use InitREQTOOLSLibrary in the beginning of your program}
-
-var
-    reqtools_exit : Pointer;
-
-procedure ClosereqtoolsLibrary;
-begin
-    ExitProc := reqtools_exit;
-    if ReqToolsBase <> nil then begin
-        CloseLibrary(ReqToolsBase);
-        ReqToolsBase := nil;
-    end;
-end;
-
-procedure InitREQTOOLSLibrary;
-begin
-    ReqToolsBase := nil;
-    ReqToolsBase := OpenLibrary(REQTOOLSNAME,LIBVERSION);
-    if ReqToolsBase <> nil then begin
-        reqtools_exit := ExitProc;
-        ExitProc := @ClosereqtoolsLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open reqtools.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    REQTOOLSIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of reqtools.library}
-
-var
-    reqtools_exit : Pointer;
-
-procedure ClosereqtoolsLibrary;
-begin
-    ExitProc := reqtools_exit;
-    if ReqToolsBase <> nil then begin
-        CloseLibrary(ReqToolsBase);
-        ReqToolsBase := nil;
-    end;
-end;
-
-begin
-    ReqToolsBase := nil;
-    ReqToolsBase := OpenLibrary(REQTOOLSNAME,LIBVERSION);
-    if ReqToolsBase <> nil then begin
-        reqtools_exit := ExitProc;
-        ExitProc := @ClosereqtoolsLibrary;
-        REQTOOLSIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open reqtools.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    REQTOOLSIsCompiledHow := 3;
-   {$Warning No autoopening of reqtools.library compiled}
-   {$Warning Make sure you open reqtools.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  ReqToolsBase := OpenLibrary(REQTOOLSNAME,LIBVERSION);
+finalization
+  if Assigned(ReqToolsBase) then
+    CloseLibrary(ReqToolsBase);
 END. (* UNIT REQTOOLS *)

+ 47 - 625
packages/amunits/src/otherlibs/triton.pas

@@ -34,10 +34,6 @@
 }
 
 {$mode objfpc}
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-    {$smartlink on}
-{$endif use_amiga_smartlink}
 
 UNIT TRITON;
 
@@ -685,65 +681,51 @@ surrounding array *}
         TRFB_TEXT               = $00000004;     {* A text container *}
 
 
-VAR TritonBase : pLibrary;
-
-FUNCTION TR_AddClass(app : pTR_App; d0arg : longword; supertag : longword; defaultmethod : LONGINT;
-datasize : longword; tags : pTagItem) : BOOLEAN;
-PROCEDURE TR_AreaFill(project : pTR_Project; rp : pRastPort; left : ULONG; top :
-ULONG; right : ULONG; bottom : ULONG; typ : ULONG; dummy : POINTER);
-FUNCTION TR_AutoRequest(app : pTR_App; lockproject : pTR_Project; wintags : pTagItem)
-: ULONG;
-PROCEDURE TR_CloseProject(project : pTR_Project);
-PROCEDURE TR_CloseWindowSafely(window : pWindow);
-FUNCTION TR_CreateApp(apptags : pTagItem) : pTR_App;
-FUNCTION TR_CreateMsg(app : pTR_App) : pTR_Message;
-PROCEDURE TR_DeleteApp(app : pTR_App);
-FUNCTION TR_DoMethod(obj : pTROD_Object; messageid : ULONG; data : POINTER) : ULONG;
-FUNCTION TR_DoMethodClass(obj : pTROD_Object; messageid : ULONG; data : POINTER;
-trclass : pTR_Class) : ULONG;
-PROCEDURE TR_DrawFrame(project : pTR_Project; rp : pRastPort; left : WORD; top : WORD;
-width : WORD; height : WORD; typ : WORD; inverted : BOOLEAN);
-FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : pCHAR; gadfmt : pCHAR; taglist :
-pTagItem) : ULONG;
-FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : pCHAR; gadfmt : String; taglist :
-pTagItem) : ULONG;
-FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : String; gadfmt : pCHAR; taglist :
-pTagItem) : ULONG;
-FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : String; gadfmt : String; taglist :
-pTagItem) : ULONG;
-FUNCTION TR_FirstOccurance(ch : BYTE; str : pCHAR) : LONGINT;
+VAR TritonBase : pLibrary = nil;
+
+FUNCTION TR_AddClass(app : pTR_App location 'a1'; d0arg : longword location 'd0'; supertag : longword location 'd1'; defaultmethod : LONGINT location 'a2'; datasize : longword location 'd2'; tags : pTagItem location 'a0') : BOOLEAN; syscall TritonBase 168;
+PROCEDURE TR_AreaFill(project : pTR_Project location 'a0'; rp : pRastPort location 'a1'; left : ULONG location 'd0'; top :ULONG location 'd1'; right : ULONG location 'd2'; bottom : ULONG location 'd3'; typ : ULONG location 'd4'; dummy : POINTER location 'a2'); syscall TritonBase 228;
+FUNCTION TR_AutoRequest(app : pTR_App location 'a1'; lockproject : pTR_Project location 'a0'; wintags : pTagItem location 'a2'): ULONG; syscall TritonBase 84;
+PROCEDURE TR_CloseProject(project : pTR_Project location 'a0'); syscall TritonBase 36;
+PROCEDURE TR_CloseWindowSafely(window : pWindow location 'a0'); syscall TritonBase 126;
+FUNCTION TR_CreateApp(apptags : pTagItem location 'a1') : pTR_App; syscall TritonBase 96;
+FUNCTION TR_CreateMsg(app : pTR_App location 'a1') : pTR_Message; syscall TritonBase 234;
+PROCEDURE TR_DeleteApp(app : pTR_App location 'a1'); syscall TritonBase 102;
+FUNCTION TR_DoMethod(obj : pTROD_Object location 'a0'; messageid : ULONG location 'd0'; data : POINTER location 'a1') : ULONG; syscall TritonBase 216;
+FUNCTION TR_DoMethodClass(obj : pTROD_Object location 'a0'; messageid : ULONG location 'd0'; data : POINTER location 'a1'; trclass : pTR_Class location 'a2') : ULONG; syscall TritonBase 222;
+PROCEDURE TR_DrawFrame(project : pTR_Project location 'a0'; rp : pRastPort location 'a1'; left : WORD location 'd1'; top : WORD location 'd2'; width : WORD location 'd3'; height : WORD location 'd4'; typ : WORD location 'd0'; inverted : BOOLEAN location 'd5'); syscall TritonBase 174;
+FUNCTION TR_EasyRequest(app : pTR_App location 'a1'; bodyfmt : pCHAR location 'a2'; gadfmt : pCHAR location 'a3'; taglist : pTagItem location 'a0') : ULONG; syscall TritonBase 90;
+FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : pCHAR; gadfmt : String; taglist : pTagItem) : ULONG;
+FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : String; gadfmt : pCHAR; taglist : pTagItem) : ULONG;
+FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : String; gadfmt : String; taglist : pTagItem) : ULONG;
+FUNCTION TR_FirstOccurance(ch : BYTE location 'd0'; str : pCHAR location 'a0') : LONGINT; syscall TritonBase 42;
 FUNCTION TR_FirstOccurance(ch : BYTE; str : String) : LONGINT;
-FUNCTION TR_FrameBorderHeight(project : pTR_Project; typ : WORD) : ULONG;
-FUNCTION TR_FrameBorderWidth(project : pTR_Project; typ : WORD) : ULONG;
-FUNCTION TR_GetAttribute(project : pTR_Project; ID : ULONG; attribute : ULONG) :
-ULONG;
-FUNCTION TR_GetErrorString(num : WORD) : pCHAR;
-FUNCTION TR_GetLastError(app : pTR_App) : WORD;
-FUNCTION TR_GetMsg(app : pTR_App) : pTR_Message;
-FUNCTION TR_GetPen(project : pTR_Project; pentype : ULONG; pendata : ULONG) : ULONG;
-PROCEDURE TR_LockProject(project : pTR_Project);
-FUNCTION TR_LockScreen(project : pTR_Project) : pScreen;
-FUNCTION TR_NumOccurances(ch : BYTE; str : pCHAR) : LONGINT;
+FUNCTION TR_FrameBorderHeight(project : pTR_Project location 'a0'; typ : WORD location 'd0') : ULONG; syscall TritonBase 186;
+FUNCTION TR_FrameBorderWidth(project : pTR_Project location 'a0'; typ : WORD location 'd0') : ULONG; syscall TritonBase 180;
+FUNCTION TR_GetAttribute(project : pTR_Project location 'a0'; ID : ULONG location 'd0'; attribute : ULONG location 'd1') : ULONG; syscall TritonBase 66;
+FUNCTION TR_GetErrorString(num : WORD location 'd0') : pCHAR; syscall TritonBase 54;
+FUNCTION TR_GetLastError(app : pTR_App location 'a1') : WORD; syscall TritonBase 132;
+FUNCTION TR_GetMsg(app : pTR_App location 'a1') : pTR_Message; syscall TritonBase 108;
+FUNCTION TR_GetPen(project : pTR_Project location 'a0'; pentype : ULONG location 'd0'; pendata : ULONG location 'd1') : ULONG; syscall TritonBase 210;
+PROCEDURE TR_LockProject(project : pTR_Project location 'a0'); syscall TritonBase 72;
+FUNCTION TR_LockScreen(project : pTR_Project location 'a0') : pScreen; syscall TritonBase 138;
+FUNCTION TR_NumOccurances(ch : BYTE location 'd0'; str : pCHAR location 'a0') : LONGINT; syscall TritonBase 48;
 FUNCTION TR_NumOccurances(ch : BYTE; str : String) : LONGINT;
-FUNCTION TR_ObtainWindow(project : pTR_Project) : pWindow;
-FUNCTION TR_OpenProject(app : pTR_App; taglist : pTagItem) : pTR_Project;
-PROCEDURE TR_PrintText(project : pTR_Project; rp : pRastPort; txt : pCHAR; x : ULONG;
-y : ULONG; width : ULONG; flags : ULONG);
-PROCEDURE TR_PrintText(project : pTR_Project; rp : pRastPort; txt : String; x : ULONG;
-y : ULONG; width : ULONG; flags : ULONG);
-PROCEDURE TR_ReleaseWindow(window : pWindow);
-PROCEDURE TR_ReplyMsg(message : pTR_Message);
-FUNCTION TR_SendMessage(project : pTR_Project; objectid : ULONG; messageid : ULONG;
-messagedata : POINTER) : ULONG;
-PROCEDURE TR_SetAttribute(project : pTR_Project; ID : ULONG; attribute : ULONG; value
-: ULONG);
-FUNCTION TR_TextHeight(project : pTR_Project; txt : pCHAR; flags : ULONG) : ULONG;
+FUNCTION TR_ObtainWindow(project : pTR_Project location 'a0') : pWindow; syscall TritonBase 150;
+FUNCTION TR_OpenProject(app : pTR_App location 'a1'; taglist : pTagItem location 'a0') : pTR_Project; syscall TritonBase 30;
+PROCEDURE TR_PrintText(project : pTR_Project location 'a0'; rp : pRastPort location 'a1'; txt : pCHAR location 'a2'; x : ULONG location 'd1'; y : ULONG location 'd2'; width : ULONG location 'd3'; flags : ULONG location 'd0'); syscall TritonBase 204;
+PROCEDURE TR_PrintText(project : pTR_Project; rp : pRastPort; txt : String; x : ULONG; y : ULONG; width : ULONG; flags : ULONG);
+PROCEDURE TR_ReleaseWindow(window : pWindow location 'a0'); syscall TritonBase 156;
+PROCEDURE TR_ReplyMsg(message : pTR_Message location 'a1'); syscall TritonBase 114;
+FUNCTION TR_SendMessage(project : pTR_Project location 'a0'; objectid : ULONG location 'd0'; messageid : ULONG location 'd1'; messagedata : POINTER location 'a1') : ULONG; syscall TritonBase 162;
+PROCEDURE TR_SetAttribute(project : pTR_Project location 'a0'; ID : ULONG location 'd0'; attribute : ULONG location 'd1'; value: ULONG location 'd2'); syscall TritonBase 60;
+FUNCTION TR_TextHeight(project : pTR_Project location 'a0'; txt : pCHAR location 'a2'; flags : ULONG location 'd0') : ULONG; syscall TritonBase 198;
 FUNCTION TR_TextHeight(project : pTR_Project; txt : String; flags : ULONG) : ULONG;
-FUNCTION TR_TextWidth(project : pTR_Project; txt : pCHAR; flags : ULONG) : ULONG;
+FUNCTION TR_TextWidth(project : pTR_Project location 'a0'; txt : pCHAR location 'a2'; flags : ULONG location 'd0') : ULONG; syscall TritonBase 192;
 FUNCTION TR_TextWidth(project : pTR_Project; txt : String; flags : ULONG) : ULONG;
-PROCEDURE TR_UnlockProject(project : pTR_Project);
-PROCEDURE TR_UnlockScreen(screen : pScreen);
-FUNCTION TR_Wait(app : pTR_App; otherbits : ULONG) : ULONG;
+PROCEDURE TR_UnlockProject(project : pTR_Project location 'a0'); syscall TritonBase 78;
+PROCEDURE TR_UnlockScreen(screen : pScreen location 'a0'); syscall TritonBase 144;
+FUNCTION TR_Wait(app : pTR_App location 'a1'; otherbits : ULONG location 'd0') : ULONG; syscall TritonBase 120;
 
 {
    Functions with array of const
@@ -778,23 +760,10 @@ procedure TR_SetWindowTitle(p : pTR_Project; thetitle : string);
 procedure TR_SetWindowTitle(p : pTR_Project; thetitle : PChar);
 procedure TR_UpdateListView(p : pTR_Project; gadid : Longint; thelist: pList);
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitTRITONLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    TRITONIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray,pastoc;
+  tagsarray,pastoc;
 
 procedure TR_Disable(p : pTR_Project; id : Longint);
 begin
@@ -881,182 +850,6 @@ begin
     TR_SetAttribute(p,gadid,0,Longint(thelist));
 end;
 
-FUNCTION TR_AddClass(app : pTR_App; d0arg : longword; supertag : longword; defaultmethod : LONGINT; datasize : longword; tags : pTagItem) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L app,A1
-        MOVE.L  d0arg,D0
-        MOVE.L  supertag,D1
-        MOVEA.L defaultmethod,A2
-        MOVE.L  datasize,D2
-        MOVEA.L tags,A0
-        MOVEA.L TritonBase,A6
-        JSR     -168(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-
-PROCEDURE TR_AreaFill(project : pTR_Project; rp : pRastPort; left : ULONG; top :
-ULONG; right : ULONG; bottom : ULONG; typ : ULONG; dummy : POINTER);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L rp,A1
-    MOVE.L  left,D0
-    MOVE.L  top,D1
-    MOVE.L  right,D2
-    MOVE.L  bottom,D3
-    MOVE.L  typ,D4
-    MOVEA.L dummy,A2
-    MOVEA.L TritonBase,A6
-    JSR -228(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TR_AutoRequest(app : pTR_App; lockproject : pTR_Project; wintags : pTagItem)
-: ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L app,A1
-    MOVEA.L lockproject,A0
-    MOVEA.L wintags,A2
-    MOVEA.L TritonBase,A6
-    JSR -084(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TR_CloseProject(project : pTR_Project);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L TritonBase,A6
-    JSR -036(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE TR_CloseWindowSafely(window : pWindow);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L window,A0
-    MOVEA.L TritonBase,A6
-    JSR -126(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TR_CreateApp(apptags : pTagItem) : pTR_App;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L apptags,A1
-    MOVEA.L TritonBase,A6
-    JSR -096(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_CreateMsg(app : pTR_App) : pTR_Message;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L app,A1
-    MOVEA.L TritonBase,A6
-    JSR -234(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TR_DeleteApp(app : pTR_App);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L app,A1
-    MOVEA.L TritonBase,A6
-    JSR -102(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TR_DoMethod(obj : pTROD_Object; messageid : ULONG; data : POINTER) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L obj,A0
-    MOVE.L  messageid,D0
-    MOVEA.L data,A1
-    MOVEA.L TritonBase,A6
-    JSR -216(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_DoMethodClass(obj : pTROD_Object; messageid : ULONG; data : POINTER;
-trclass : pTR_Class) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L obj,A0
-    MOVE.L  messageid,D0
-    MOVEA.L data,A1
-    MOVEA.L trclass,A2
-    MOVEA.L TritonBase,A6
-    JSR -222(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TR_DrawFrame(project : pTR_Project; rp : pRastPort; left : WORD; top : WORD;
-width : WORD; height : WORD; typ : WORD; inverted : BOOLEAN);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L rp,A1
-    MOVE.L  left,D1
-    MOVE.L  top,D2
-    MOVE.L  width,D3
-    MOVE.L  height,D4
-    MOVE.L  typ,D0
-    MOVE.L  inverted,D5
-    MOVEA.L TritonBase,A6
-    JSR -174(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : pCHAR; gadfmt : pCHAR; taglist :
-pTagItem) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L app,A1
-    MOVEA.L bodyfmt,A2
-    MOVEA.L gadfmt,A3
-    MOVEA.L taglist,A0
-    MOVEA.L TritonBase,A6
-    JSR -090(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
 
 FUNCTION TR_EasyRequest(app : pTR_App; bodyfmt : PChar; gadfmt : String; taglist :
 pTagItem) : ULONG;
@@ -1076,331 +869,32 @@ begin
     TR_EasyRequest := TR_EasyRequest(app,pas2c(bodyfmt),pas2c(gadfmt),taglist);
 end;
 
-FUNCTION TR_FirstOccurance(ch : BYTE; str : pCHAR) : LONGINT;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVE.L  ch,D0
-    MOVEA.L str,A0
-    MOVEA.L TritonBase,A6
-    JSR -042(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
 FUNCTION TR_FirstOccurance(ch : BYTE; str : String) : LONGINT;
 BEGIN
     TR_FirstOccurance := TR_FirstOccurance(ch, pas2c(str));
 END;
 
-FUNCTION TR_FrameBorderHeight(project : pTR_Project; typ : WORD) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVE.L  typ,D0
-    MOVEA.L TritonBase,A6
-    JSR -186(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_FrameBorderWidth(project : pTR_Project; typ : WORD) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVE.L  typ,D0
-    MOVEA.L TritonBase,A6
-    JSR -180(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_GetAttribute(project : pTR_Project; ID : ULONG; attribute : ULONG) :
-ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVE.L  ID,D0
-    MOVE.L  attribute,D1
-    MOVEA.L TritonBase,A6
-    JSR -066(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_GetErrorString(num : WORD) : pCHAR;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVE.L  num,D0
-    MOVEA.L TritonBase,A6
-    JSR -054(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_GetLastError(app : pTR_App) : WORD;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L app,A1
-    MOVEA.L TritonBase,A6
-    JSR -132(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_GetMsg(app : pTR_App) : pTR_Message;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L app,A1
-    MOVEA.L TritonBase,A6
-    JSR -108(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_GetPen(project : pTR_Project; pentype : ULONG; pendata : ULONG) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVE.L  pentype,D0
-    MOVE.L  pendata,D1
-    MOVEA.L TritonBase,A6
-    JSR -210(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TR_LockProject(project : pTR_Project);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L TritonBase,A6
-    JSR -072(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TR_LockScreen(project : pTR_Project) : pScreen;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L TritonBase,A6
-    JSR -138(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_NumOccurances(ch : BYTE; str : pCHAR) : LONGINT;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVE.L  ch,D0
-    MOVEA.L str,A0
-    MOVEA.L TritonBase,A6
-    JSR -048(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
 FUNCTION TR_NumOccurances(ch : BYTE; str : String) : LONGINT;
 BEGIN
     TR_NumOccurances := TR_NumOccurances(ch, pas2c(str));
 END;
 
-FUNCTION TR_ObtainWindow(project : pTR_Project) : pWindow;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L TritonBase,A6
-    JSR -150(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TR_OpenProject(app : pTR_App; taglist : pTagItem) : pTR_Project;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L app,A1
-    MOVEA.L taglist,A0
-    MOVEA.L TritonBase,A6
-    JSR -030(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TR_PrintText(project : pTR_Project; rp : pRastPort; txt : pCHAR; x : ULONG;
-y : ULONG; width : ULONG; flags : ULONG);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L rp,A1
-    MOVEA.L txt,A2
-    MOVE.L  x,D1
-    MOVE.L  y,D2
-    MOVE.L  width,D3
-    MOVE.L  flags,D0
-    MOVEA.L TritonBase,A6
-    JSR -204(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
 PROCEDURE TR_PrintText(project : pTR_Project; rp : pRastPort; txt : String; x : ULONG;
 y : ULONG; width : ULONG; flags : ULONG);
 BEGIN
     TR_PrintText(project,rp,pas2c(txt),x,y,width,flags);
 END;
 
-PROCEDURE TR_ReleaseWindow(window : pWindow);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L window,A0
-    MOVEA.L TritonBase,A6
-    JSR -156(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE TR_ReplyMsg(message : pTR_Message);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L message,A1
-    MOVEA.L TritonBase,A6
-    JSR -114(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TR_SendMessage(project : pTR_Project; objectid : ULONG; messageid : ULONG;
-messagedata : POINTER) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVE.L  objectid,D0
-    MOVE.L  messageid,D1
-    MOVEA.L messagedata,A1
-    MOVEA.L TritonBase,A6
-    JSR -162(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TR_SetAttribute(project : pTR_Project; ID : ULONG; attribute : ULONG; value
-: ULONG);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVE.L  ID,D0
-    MOVE.L  attribute,D1
-    MOVE.L  value,D2
-    MOVEA.L TritonBase,A6
-    JSR -060(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TR_TextHeight(project : pTR_Project; txt : pCHAR; flags : ULONG) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L txt,A2
-    MOVE.L  flags,D0
-    MOVEA.L TritonBase,A6
-    JSR -198(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
 FUNCTION TR_TextHeight(project : pTR_Project; txt : String; flags : ULONG) : ULONG;
 BEGIN
     TR_TextHeight :=  TR_TextHeight(project,pas2c(txt),flags);
 END;
 
-FUNCTION TR_TextWidth(project : pTR_Project; txt : pCHAR; flags : ULONG) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L txt,A2
-    MOVE.L  flags,D0
-    MOVEA.L TritonBase,A6
-    JSR -192(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
 FUNCTION TR_TextWidth(project : pTR_Project; txt : String; flags : ULONG) : ULONG;
 BEGIN
     TR_TextWidth := TR_TextWidth(project,pas2c(txt),flags);
 END;
 
-PROCEDURE TR_UnlockProject(project : pTR_Project);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L project,A0
-    MOVEA.L TritonBase,A6
-    JSR -078(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE TR_UnlockScreen(screen : pScreen);
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L screen,A0
-    MOVEA.L TritonBase,A6
-    JSR -144(A6)
-    MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TR_Wait(app : pTR_App; otherbits : ULONG) : ULONG;
-BEGIN
-  ASM
-    MOVE.L  A6,-(A7)
-    MOVEA.L app,A1
-    MOVE.L  otherbits,D0
-    MOVEA.L TritonBase,A6
-    JSR -120(A6)
-    MOVEA.L (A7)+,A6
-    MOVE.L  D0,@RESULT
-  END;
-END;
-
 {
    Functions with array of const
 }
@@ -1449,86 +943,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of triton.library}
-  {$Info don't forget to use InitTRITONLibrary in the beginning of your program}
-
-var
-    triton_exit : Pointer;
-
-procedure ClosetritonLibrary;
-begin
-    ExitProc := triton_exit;
-    if TritonBase <> nil then begin
-        CloseLibrary(TritonBase);
-        TritonBase := nil;
-    end;
-end;
-
-procedure InitTRITONLibrary;
-begin
-    TritonBase := nil;
-    TritonBase := OpenLibrary(TRITONNAME,LIBVERSION);
-    if TritonBase <> nil then begin
-        triton_exit := ExitProc;
-        ExitProc := @ClosetritonLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open triton.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    TRITONIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of triton.library}
-
-var
-    triton_exit : Pointer;
-
-procedure ClosetritonLibrary;
-begin
-    ExitProc := triton_exit;
-    if TritonBase <> nil then begin
-        CloseLibrary(TritonBase);
-        TritonBase := nil;
-    end;
-end;
-
-begin
-    TritonBase := nil;
-    TritonBase := OpenLibrary(TRITONNAME,LIBVERSION);
-    if TritonBase <> nil then begin
-        triton_exit := ExitProc;
-        ExitProc := @ClosetritonLibrary;
-        TRITONIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open triton.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    TRITONIsCompiledHow := 3;
-   {$Warning No autoopening of triton.library compiled}
-   {$Warning Make sure you open triton.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  TritonBase := OpenLibrary(TRITONNAME,LIBVERSION);
+finalization
+  if Assigned(TritonBase) then
+    CloseLibrary(TritonBase);
 END. (* UNIT TRITON *)
 
 

+ 0 - 4
packages/amunits/src/otherlibs/tritonmacros.pas

@@ -37,10 +37,6 @@
     [email protected]
 }
 
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-    {$smartlink on}
-{$endif use_amiga_smartlink}
 unit tritonmacros;
 
 interface

+ 22 - 310
packages/amunits/src/otherlibs/ttengine.pas

@@ -29,17 +29,13 @@
 }
 
 {$mode objfpc}
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-   {$smartlink on}
-{$endif use_amiga_smartlink}
 
 UNIT TTENGINE;
 
 INTERFACE
 USES Exec,utility,agraphics;
 
-VAR TTEngineBase : pLibrary;
+VAR TTEngineBase : pLibrary = nil;
 
 const
     TTENGINENAME : PChar = 'ttengine.library';
@@ -195,23 +191,21 @@ const
   { BOOL,             TRUE               }
      TTRQ_DoSizes = $6EDA2000;
 
-
-
-FUNCTION TT_AllocRequest : POINTER;
-PROCEDURE TT_CloseFont(font : POINTER);
-PROCEDURE TT_DoneRastPort(rp : pRastPort);
-PROCEDURE TT_FreePixmap(pixmap : pTT_Pixmap);
-PROCEDURE TT_FreeRequest(request : POINTER);
-FUNCTION TT_GetAttrsA(rp : pRastPort; taglist : pTagItem) : longword;
-FUNCTION TT_GetPixmapA(font : POINTER; _string : POINTER; count : longword; taglist : pTagItem) : pTT_Pixmap;
-FUNCTION TT_OpenFontA(taglist : pTagItem) : POINTER;
-FUNCTION TT_RequestA(request : POINTER; taglist : pTagItem) : pTagItem;
-FUNCTION TT_SetAttrsA(rp : pRastPort; taglist : pTagItem) : longword;
-FUNCTION TT_SetFont(rp : pRastPort; font : POINTER) : BOOLEAN;
-PROCEDURE TT_Text(rp : pRastPort; _string : POINTER; count : longword);
-PROCEDURE TT_TextExtent(rp : pRastPort; _string : POINTER; count : LONGINT; te : pTextExtent);
-FUNCTION TT_TextFit(rp : pRastPort; _string : POINTER; count : longword; te : pTextExtent; tec : pTextExtent; dir : LONGINT; cwidth : longword; cheight : longword) : longword;
-FUNCTION TT_TextLength(rp : pRastPort; _string : POINTER; count : longword) : longword;
+FUNCTION TT_AllocRequest : POINTER; syscall TTEngineBase 102;
+PROCEDURE TT_CloseFont(font : POINTER location 'a0'); syscall TTEngineBase 42;
+PROCEDURE TT_DoneRastPort(rp : pRastPort location 'a1'); syscall TTEngineBase 96;
+PROCEDURE TT_FreePixmap(pixmap : pTT_Pixmap location 'a0'); syscall TTEngineBase 90;
+PROCEDURE TT_FreeRequest(request : POINTER location 'a0'); syscall TTEngineBase 114;
+FUNCTION TT_GetAttrsA(rp : pRastPort location 'a1'; taglist : pTagItem location 'a0') : longword; syscall TTEngineBase 60;
+FUNCTION TT_GetPixmapA(font : POINTER location 'a1'; _string : POINTER location 'a2'; count : longword location 'd0'; taglist : pTagItem location 'a0') : pTT_Pixmap; syscall TTEngineBase 84;
+FUNCTION TT_OpenFontA(taglist : pTagItem location 'a0') : POINTER; syscall TTEngineBase 30;
+FUNCTION TT_RequestA(request : POINTER location 'a0'; taglist : pTagItem location 'a1') : pTagItem; syscall TTEngineBase 108;
+FUNCTION TT_SetAttrsA(rp : pRastPort location 'a1'; taglist : pTagItem location 'a0') : longword; syscall TTEngineBase 54;
+FUNCTION TT_SetFont(rp : pRastPort location 'a1'; font : POINTER location 'a0') : BOOLEAN; syscall TTEngineBase 36;
+PROCEDURE TT_Text(rp : pRastPort location 'a1'; _string : POINTER location 'a0'; count : longword location 'd0'); syscall TTEngineBase 48;
+PROCEDURE TT_TextExtent(rp : pRastPort location 'a1'; _string : POINTER location 'a0'; count : LONGINT location 'd0'; te : pTextExtent location 'a2'); syscall TTEngineBase 72;
+FUNCTION TT_TextFit(rp : pRastPort location 'a1'; _string : POINTER location 'a0'; count : longword location 'd0'; te : pTextExtent location 'a2'; tec : pTextExtent location 'a3'; dir : LONGINT location 'd1'; cwidth : longword location 'd2'; cheight : longword location 'd3') : longword; syscall TTEngineBase 78;
+FUNCTION TT_TextLength(rp : pRastPort location 'a1'; _string : POINTER location 'a0'; count : longword location 'd0') : longword; syscall TTEngineBase 66;
 {
  Functions and procedures with array of const go here
 }
@@ -221,220 +215,10 @@ FUNCTION TT_OpenFont(const taglist : Array Of Const) : POINTER;
 FUNCTION TT_Request(request : POINTER; const taglist : Array Of Const) : pTagItem;
 FUNCTION TT_SetAttrs(rp : pRastPort; const taglist : Array Of Const) : longword;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitTTENGINELibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    TTENGINEIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
-
-FUNCTION TT_AllocRequest : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L TTEngineBase,A6
-        JSR     -102(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TT_CloseFont(font : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L font,A0
-        MOVEA.L TTEngineBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE TT_DoneRastPort(rp : pRastPort);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rp,A1
-        MOVEA.L TTEngineBase,A6
-        JSR     -096(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE TT_FreePixmap(pixmap : pTT_Pixmap);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L pixmap,A0
-        MOVEA.L TTEngineBase,A6
-        JSR     -090(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE TT_FreeRequest(request : POINTER);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L request,A0
-        MOVEA.L TTEngineBase,A6
-        JSR     -114(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TT_GetAttrsA(rp : pRastPort; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rp,A1
-        MOVEA.L taglist,A0
-        MOVEA.L TTEngineBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TT_GetPixmapA(font : POINTER; _string : POINTER; count : longword; taglist : pTagItem) : pTT_Pixmap;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L font,A1
-        MOVEA.L _string,A2
-        MOVE.L  count,D0
-        MOVEA.L taglist,A0
-        MOVEA.L TTEngineBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TT_OpenFontA(taglist : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L taglist,A0
-        MOVEA.L TTEngineBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TT_RequestA(request : POINTER; taglist : pTagItem) : pTagItem;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L request,A0
-        MOVEA.L taglist,A1
-        MOVEA.L TTEngineBase,A6
-        JSR     -108(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TT_SetAttrsA(rp : pRastPort; taglist : pTagItem) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rp,A1
-        MOVEA.L taglist,A0
-        MOVEA.L TTEngineBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TT_SetFont(rp : pRastPort; font : POINTER) : BOOLEAN;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rp,A1
-        MOVEA.L font,A0
-        MOVEA.L TTEngineBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-        TST.W   D0
-        BEQ.B   @end
-        MOVEQ   #1,D0
-  @end: MOVE.B  D0,@RESULT
-  END;
-END;
-
-PROCEDURE TT_Text(rp : pRastPort; _string : POINTER; count : longword);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rp,A1
-        MOVEA.L _string,A0
-        MOVE.L  count,D0
-        MOVEA.L TTEngineBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE TT_TextExtent(rp : pRastPort; _string : POINTER; count : LONGINT; te : pTextExtent);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rp,A1
-        MOVEA.L _string,A0
-        MOVE.L  count,D0
-        MOVEA.L te,A2
-        MOVEA.L TTEngineBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION TT_TextFit(rp : pRastPort; _string : POINTER; count : longword; te : pTextExtent; tec : pTextExtent; dir : LONGINT; cwidth : longword; cheight : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rp,A1
-        MOVEA.L _string,A0
-        MOVE.L  count,D0
-        MOVEA.L te,A2
-        MOVEA.L tec,A3
-        MOVE.L  dir,D1
-        MOVE.L  cwidth,D2
-        MOVE.L  cheight,D3
-        MOVEA.L TTEngineBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION TT_TextLength(rp : pRastPort; _string : POINTER; count : longword) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L rp,A1
-        MOVEA.L _string,A0
-        MOVE.L  count,D0
-        MOVEA.L TTEngineBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
+  tagsarray;
 
 {
  Functions and procedures with array of const go here
@@ -466,86 +250,14 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of ttengine.library}
-  {$Info don't forget to use InitTTENGINELibrary in the beginning of your program}
-
-var
-    ttengine_exit : Pointer;
-
-procedure ClosettengineLibrary;
-begin
-    ExitProc := ttengine_exit;
-    if TTEngineBase <> nil then begin
-        CloseLibrary(TTEngineBase);
-        TTEngineBase := nil;
-    end;
-end;
-
-procedure InitTTENGINELibrary;
-begin
-    TTEngineBase := nil;
-    TTEngineBase := OpenLibrary(TTENGINENAME,LIBVERSION);
-    if TTEngineBase <> nil then begin
-        ttengine_exit := ExitProc;
-        ExitProc := @ClosettengineLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open ttengine.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    TTENGINEIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of ttengine.library}
-
-var
-    ttengine_exit : Pointer;
-
-procedure ClosettengineLibrary;
-begin
-    ExitProc := ttengine_exit;
-    if TTEngineBase <> nil then begin
-        CloseLibrary(TTEngineBase);
-        TTEngineBase := nil;
-    end;
-end;
-
-begin
-    TTEngineBase := nil;
-    TTEngineBase := OpenLibrary(TTENGINENAME,LIBVERSION);
-    if TTEngineBase <> nil then begin
-        ttengine_exit := ExitProc;
-        ExitProc := @ClosettengineLibrary;
-        TTENGINEIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open ttengine.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    TTENGINEIsCompiledHow := 3;
-   {$Warning No autoopening of ttengine.library compiled}
-   {$Warning Make sure you open ttengine.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  TTEngineBase := OpenLibrary(TTENGINENAME,LIBVERSION);
+finalization
+  if Assigned(TTEngineBase) then
+    CloseLibrary(TTEngineBase);
 END. (* UNIT TTENGINE *)
 
 

+ 34 - 457
packages/amunits/src/otherlibs/xadmaster.pas

@@ -23,10 +23,6 @@
 }
 
 {$mode objfpc}
-{$I useamigasmartlink.inc}
-{$ifdef use_amiga_smartlink}
-   {$smartlink on}
-{$endif use_amiga_smartlink}
 
 UNIT XADMASTER;
 
@@ -1182,34 +1178,34 @@ const
      XADCID_DMS = 9000;
      XADCID_DMSSFX = 9001;
 
-VAR xadMasterBase : pxadMasterBase;
-
-
-FUNCTION xadAddDiskEntryA(di : pxadDiskInfo; ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadAddFileEntryA(fi : pxadFileInfo; ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadAllocObjectA(_type : LONGINT; CONST tags : pTagItem) : POINTER;
-FUNCTION xadAllocVec(size : longword; flags : longword) : POINTER;
-FUNCTION xadCalcCRC16(id : longword; init : longword; size : longword; buffer : pCHAR) : WORD;
-FUNCTION xadCalcCRC32(id : longword; init : longword; size : longword; buffer : pCHAR) : longword;
-FUNCTION xadConvertDatesA(CONST tags : pTagItem) : LONGINT;
-FUNCTION xadConvertNameA(charset : longword; CONST tags : pTagItem) : pCHAR;
-FUNCTION xadConvertProtectionA(CONST tags : pTagItem) : LONGINT;
-PROCEDURE xadCopyMem(src : POINTER; dest : POINTER; size : longword);
-FUNCTION xadDiskFileUnArcA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadDiskUnArcA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadFileUnArcA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadFreeHookAccessA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-PROCEDURE xadFreeInfo(ai : pxadArchiveInfo);
-PROCEDURE xadFreeObjectA(obj : POINTER; CONST tags : pTagItem);
-FUNCTION xadGetClientInfo : pxadClient;
-FUNCTION xadGetDiskInfoA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadGetErrorText(errnum : longword) : pCHAR;
-FUNCTION xadGetFilenameA(buffersize : longword; buffer : pCHAR; path : pCHAR; name : pCHAR; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadGetHookAccessA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadGetInfoA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadHookAccess(command : longword; data : LONGINT; buffer : POINTER; ai : pxadArchiveInfo) : LONGINT;
-FUNCTION xadHookTagAccessA(command : longword; data : LONGINT; buffer : POINTER; ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-FUNCTION xadRecogFileA(size : longword; memory : POINTER; CONST tags : pTagItem) : pxadClient;
+VAR xadMasterBase : pxadMasterBase = nil;
+
+
+FUNCTION xadAddDiskEntryA(di : pxadDiskInfo location 'a0'; ai : pxadArchiveInfo location 'a1'; CONST tags : pTagItem location 'a2') : LONGINT; syscall xadMasterBase 162;
+FUNCTION xadAddFileEntryA(fi : pxadFileInfo location 'a0'; ai : pxadArchiveInfo location 'a1'; CONST tags : pTagItem location 'a2') : LONGINT; syscall xadMasterBase 156;
+FUNCTION xadAllocObjectA(_type : LONGINT location 'd0'; CONST tags : pTagItem location 'a0') : POINTER; syscall xadMasterBase 30;
+FUNCTION xadAllocVec(size : longword location 'd0'; flags : longword location 'd1') : POINTER; syscall xadMasterBase 108;
+FUNCTION xadCalcCRC16(id : longword location 'd0'; init : longword location 'd1'; size : longword location 'd2'; buffer : pCHAR location 'a0') : WORD; syscall xadMasterBase 96;
+FUNCTION xadCalcCRC32(id : longword location 'd0'; init : longword location 'd1'; size : longword location 'd2'; buffer : pCHAR location 'a0') : longword; syscall xadMasterBase 102;
+FUNCTION xadConvertDatesA(CONST tags : pTagItem location 'a0') : LONGINT; syscall xadMasterBase 90;
+FUNCTION xadConvertNameA(charset : longword location 'd0'; CONST tags : pTagItem location 'a0') : pCHAR; syscall xadMasterBase 174;
+FUNCTION xadConvertProtectionA(CONST tags : pTagItem location 'a0') : LONGINT; syscall xadMasterBase 126;
+PROCEDURE xadCopyMem(src : POINTER location 'a0'; dest : POINTER location 'a1'; size : longword location 'd0'); syscall xadMasterBase 114;
+FUNCTION xadDiskFileUnArcA(ai : pxadArchiveInfo location 'a0'; CONST tags : pTagItem location 'a1') : LONGINT; syscall xadMasterBase 138;
+FUNCTION xadDiskUnArcA(ai : pxadArchiveInfo location 'a0'; CONST tags : pTagItem location 'a1') : LONGINT; syscall xadMasterBase 66;
+FUNCTION xadFileUnArcA(ai : pxadArchiveInfo location 'a0'; CONST tags : pTagItem location 'a1') : LONGINT; syscall xadMasterBase 60;
+FUNCTION xadFreeHookAccessA(ai : pxadArchiveInfo location 'a0'; CONST tags : pTagItem location 'a1') : LONGINT; syscall xadMasterBase 150;
+PROCEDURE xadFreeInfo(ai : pxadArchiveInfo location 'a0'); syscall xadMasterBase 54;
+PROCEDURE xadFreeObjectA(obj : POINTER location 'a0'; CONST tags : pTagItem location 'a1'); syscall xadMasterBase 36;
+FUNCTION xadGetClientInfo : pxadClient; syscall xadMasterBase 78;
+FUNCTION xadGetDiskInfoA(ai : pxadArchiveInfo location 'a0'; CONST tags : pTagItem location 'a1') : LONGINT; syscall xadMasterBase 132;
+FUNCTION xadGetErrorText(errnum : longword location 'd0') : pCHAR; syscall xadMasterBase 72;
+FUNCTION xadGetFilenameA(buffersize : longword location 'd0'; buffer : pCHAR location 'a0'; path : pCHAR location 'a1'; name : pCHAR location 'a2'; CONST tags : pTagItem location 'a3') : LONGINT; syscall xadMasterBase 168;
+FUNCTION xadGetHookAccessA(ai : pxadArchiveInfo location 'a0'; CONST tags : pTagItem location 'a1') : LONGINT; syscall xadMasterBase 144;
+FUNCTION xadGetInfoA(ai : pxadArchiveInfo location 'a0'; CONST tags : pTagItem location 'a1') : LONGINT; syscall xadMasterBase 48;
+FUNCTION xadHookAccess(command : longword location 'd0'; data : LONGINT location 'd1'; buffer : POINTER location 'a0'; ai : pxadArchiveInfo location 'a1') : LONGINT; syscall xadMasterBase 84;
+FUNCTION xadHookTagAccessA(command : longword location 'd0'; data : LONGINT location 'd1'; buffer : POINTER location 'a0'; ai : pxadArchiveInfo location 'a1'; CONST tags : pTagItem location 'a2') : LONGINT; syscall xadMasterBase 120;
+FUNCTION xadRecogFileA(size : longword location 'd0'; memory : POINTER location 'a0'; CONST tags : pTagItem location 'a1') : pxadClient; syscall xadMasterBase 42;
 {
  Functions and procedures with array of const go here
 }
@@ -1231,357 +1227,10 @@ FUNCTION xadGetInfo(ai : pxadArchiveInfo; const tags : Array Of Const) : LONGINT
 FUNCTION xadHookTagAccess(command : longword; data : LONGINT; buffer : POINTER; ai : pxadArchiveInfo; const tags : Array Of Const) : LONGINT;
 FUNCTION xadRecogFile(size : longword; memory : POINTER; const tags : Array Of Const) : pxadClient;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitXADMASTERLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    XADMASTERIsCompiledHow : longint;
-
 IMPLEMENTATION
 
 uses
-{$ifndef dont_use_openlib}
-amsgbox,
-{$endif dont_use_openlib}
-tagsarray;
-
-
-
-FUNCTION xadAddDiskEntryA(di : pxadDiskInfo; ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L di,A0
-        MOVEA.L ai,A1
-        MOVEA.L tags,A2
-        MOVEA.L xadMasterBase,A6
-        JSR     -162(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadAddFileEntryA(fi : pxadFileInfo; ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L fi,A0
-        MOVEA.L ai,A1
-        MOVEA.L tags,A2
-        MOVEA.L xadMasterBase,A6
-        JSR     -156(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadAllocObjectA(_type : LONGINT; CONST tags : pTagItem) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  _type,D0
-        MOVEA.L tags,A0
-        MOVEA.L xadMasterBase,A6
-        JSR     -030(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadAllocVec(size : longword; flags : longword) : POINTER;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  size,D0
-        MOVE.L  flags,D1
-        MOVEA.L xadMasterBase,A6
-        JSR     -108(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadCalcCRC16(id : longword; init : longword; size : longword; buffer : pCHAR) : WORD;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  id,D0
-        MOVE.L  init,D1
-        MOVE.L  size,D2
-        MOVEA.L buffer,A0
-        MOVEA.L xadMasterBase,A6
-        JSR     -096(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadCalcCRC32(id : longword; init : longword; size : longword; buffer : pCHAR) : longword;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  id,D0
-        MOVE.L  init,D1
-        MOVE.L  size,D2
-        MOVEA.L buffer,A0
-        MOVEA.L xadMasterBase,A6
-        JSR     -102(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadConvertDatesA(CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L tags,A0
-        MOVEA.L xadMasterBase,A6
-        JSR     -090(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadConvertNameA(charset : longword; CONST tags : pTagItem) : pCHAR;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  charset,D0
-        MOVEA.L tags,A0
-        MOVEA.L xadMasterBase,A6
-        JSR     -174(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadConvertProtectionA(CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L tags,A0
-        MOVEA.L xadMasterBase,A6
-        JSR     -126(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE xadCopyMem(src : POINTER; dest : POINTER; size : longword);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L src,A0
-        MOVEA.L dest,A1
-        MOVE.L  size,D0
-        MOVEA.L xadMasterBase,A6
-        JSR     -114(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION xadDiskFileUnArcA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ai,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -138(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadDiskUnArcA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ai,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -066(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadFileUnArcA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ai,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -060(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadFreeHookAccessA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ai,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -150(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-PROCEDURE xadFreeInfo(ai : pxadArchiveInfo);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ai,A0
-        MOVEA.L xadMasterBase,A6
-        JSR     -054(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-PROCEDURE xadFreeObjectA(obj : POINTER; CONST tags : pTagItem);
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L obj,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -036(A6)
-        MOVEA.L (A7)+,A6
-  END;
-END;
-
-FUNCTION xadGetClientInfo : pxadClient;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L xadMasterBase,A6
-        JSR     -078(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadGetDiskInfoA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ai,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -132(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadGetErrorText(errnum : longword) : pCHAR;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  errnum,D0
-        MOVEA.L xadMasterBase,A6
-        JSR     -072(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadGetFilenameA(buffersize : longword; buffer : pCHAR; path : pCHAR; name : pCHAR; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  buffersize,D0
-        MOVEA.L buffer,A0
-        MOVEA.L path,A1
-        MOVEA.L name,A2
-        MOVEA.L tags,A3
-        MOVEA.L xadMasterBase,A6
-        JSR     -168(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadGetHookAccessA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ai,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -144(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadGetInfoA(ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVEA.L ai,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -048(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadHookAccess(command : longword; data : LONGINT; buffer : POINTER; ai : pxadArchiveInfo) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  command,D0
-        MOVE.L  data,D1
-        MOVEA.L buffer,A0
-        MOVEA.L ai,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -084(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadHookTagAccessA(command : longword; data : LONGINT; buffer : POINTER; ai : pxadArchiveInfo; CONST tags : pTagItem) : LONGINT;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  command,D0
-        MOVE.L  data,D1
-        MOVEA.L buffer,A0
-        MOVEA.L ai,A1
-        MOVEA.L tags,A2
-        MOVEA.L xadMasterBase,A6
-        JSR     -120(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
-
-FUNCTION xadRecogFileA(size : longword; memory : POINTER; CONST tags : pTagItem) : pxadClient;
-BEGIN
-  ASM
-        MOVE.L  A6,-(A7)
-        MOVE.L  size,D0
-        MOVEA.L memory,A0
-        MOVEA.L tags,A1
-        MOVEA.L xadMasterBase,A6
-        JSR     -042(A6)
-        MOVEA.L (A7)+,A6
-        MOVE.L  D0,@RESULT
-  END;
-END;
+  tagsarray;
 
 {
  Functions and procedures with array of const go here
@@ -1673,84 +1322,12 @@ end;
 
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of xadmaster.library}
-  {$Info don't forget to use InitXADMASTERLibrary in the beginning of your program}
-
-var
-    xadmaster_exit : Pointer;
-
-procedure ClosexadmasterLibrary;
-begin
-    ExitProc := xadmaster_exit;
-    if xadMasterBase <> nil then begin
-        CloseLibrary(pLibrary(xadMasterBase));
-        xadMasterBase := nil;
-    end;
-end;
-
-procedure InitXADMASTERLibrary;
-begin
-    xadMasterBase := nil;
-    xadMasterBase := pxadMasterBase(OpenLibrary(XADMASTERNAME,LIBVERSION));
-    if xadMasterBase <> nil then begin
-        xadmaster_exit := ExitProc;
-        ExitProc := @ClosexadmasterLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open xadmaster.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    XADMASTERIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of xadmaster.library}
-
-var
-    xadmaster_exit : Pointer;
-
-procedure ClosexadmasterLibrary;
-begin
-    ExitProc := xadmaster_exit;
-    if xadMasterBase <> nil then begin
-        CloseLibrary(pLibrary(xadMasterBase));
-        xadMasterBase := nil;
-    end;
-end;
-
-begin
-    xadMasterBase := nil;
-    xadMasterBase := pxadMasterBase(OpenLibrary(XADMASTERNAME,LIBVERSION));
-    if xadMasterBase <> nil then begin
-        xadmaster_exit := ExitProc;
-        ExitProc := @ClosexadmasterLibrary;
-        XADMASTERIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open xadmaster.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    XADMASTERIsCompiledHow := 3;
-   {$Warning No autoopening of xadmaster.library compiled}
-   {$Warning Make sure you open xadmaster.library yourself}
-{$endif dont_use_openlib}
-
-
+initialization
+  xadMasterBase := pxadMasterBase(OpenLibrary(XADMASTERNAME,LIBVERSION));
+finalization
+  if Assigned(xadMasterBase) then
+    CloseLibrary(pLibrary(xadMasterBase));
 END. (* UNIT XADMASTER *)

+ 6 - 91
packages/amunits/src/otherlibs/zlib.pas

@@ -33,7 +33,7 @@ UNIT ZLIB;
 INTERFACE
 USES Exec;
 
-VAR ZLibBase : pLibrary;
+VAR ZLibBase : pLibrary = nil;
 
 const
     ZLIBNAME : PChar = 'zlib.library';
@@ -61,103 +61,18 @@ FUNCTION GZ_OpenFromFH(fh : LONGINT location 'a0'; openmode : longword location
 FUNCTION GZ_Read(handle : POINTER location 'a0'; buf : POINTER location 'a1'; len : longword location 'd0') : LONGINT; syscall ZLibBase 048;
 FUNCTION GZ_Write(handle : POINTER location 'a0'; buf : POINTER location 'a1'; len : longword location 'd0') : LONGINT; syscall ZLibBase 066;
 
-{You can remove this include and use a define instead}
-{$I useautoopenlib.inc}
-{$ifdef use_init_openlib}
-procedure InitZLIBLibrary;
-{$endif use_init_openlib}
-
-{This is a variable that knows how the unit is compiled}
-var
-    ZLIBIsCompiledHow : longint;
-
 IMPLEMENTATION
 
-{$ifndef dont_use_openlib}
-uses amsgbox;
-{$endif dont_use_openlib}
-
 const
     { Change VERSION and LIBVERSION to proper values }
-
     VERSION : string[2] = '0';
     LIBVERSION : longword = 0;
 
-{$ifdef use_init_openlib}
-  {$Info Compiling initopening of zlib.library}
-  {$Info don't forget to use InitZLIBLibrary in the beginning of your program}
-
-var
-    zlib_exit : Pointer;
-
-procedure ClosezlibLibrary;
-begin
-    ExitProc := zlib_exit;
-    if ZLibBase <> nil then begin
-        CloseLibrary(ZLibBase);
-        ZLibBase := nil;
-    end;
-end;
-
-procedure InitZLIBLibrary;
-begin
-    ZLibBase := nil;
-    ZLibBase := OpenLibrary(ZLIBNAME,LIBVERSION);
-    if ZLibBase <> nil then begin
-        zlib_exit := ExitProc;
-        ExitProc := @ClosezlibLibrary;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open zlib.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-end;
-
-begin
-    ZLIBIsCompiledHow := 2;
-{$endif use_init_openlib}
-
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of zlib.library}
-
-var
-    zlib_exit : Pointer;
-
-procedure ClosezlibLibrary;
-begin
-    ExitProc := zlib_exit;
-    if ZLibBase <> nil then begin
-        CloseLibrary(ZLibBase);
-        ZLibBase := nil;
-    end;
-end;
-
-begin
-    ZLibBase := nil;
-    ZLibBase := OpenLibrary(ZLIBNAME,LIBVERSION);
-    if ZLibBase <> nil then begin
-        zlib_exit := ExitProc;
-        ExitProc := @ClosezlibLibrary;
-        ZLIBIsCompiledHow := 1;
-    end else begin
-        MessageBox('FPC Pascal Error',
-        'Can''t open zlib.library version ' + VERSION + #10 +
-        'Deallocating resources and closing down',
-        'Oops');
-        halt(20);
-    end;
-
-{$endif use_auto_openlib}
-
-{$ifdef dont_use_openlib}
-begin
-    ZLIBIsCompiledHow := 3;
-   {$Warning No autoopening of zlib.library compiled}
-   {$Warning Make sure you open zlib.library yourself}
-{$endif dont_use_openlib}
-
+initialization
+  ZLibBase := OpenLibrary(ZLIBNAME,LIBVERSION);
+finalization
+  if Assigned(ZLibBase) then
+    CloseLibrary(ZLibBase);
 END. (* UNIT ZLIB *)