**************************************************************************
*
*                  CURDIR  by Jim Locker, SofTech Inc.
*                          17 January, 1990
*
*                  called from AbSoft Fortran
*                  calls system CurrentDir routine
*                  Needed because Amiga.sub does it wrong.
*
*                  USAGE:
*
*                    OldDir = CURDIR(LOCK)
*
*                    where LOCK is a directory lock
*
***************************************************************************

AEXEC   EQU     -16                     * "exec_lib" pointer
DOS     EQU     AEXEC-4                 * "dos.library" pointer
STDIN   EQU     DOS-4                   * file handle for STDIN
STDOUT  EQU     STDIN-4                 * file handle for STDOUT
H.BASE  EQU     STDOUT-4                * base of heap
H.SIZE  EQU     H.BASE-4                * size of heap
WBSTAT  EQU     H.SIZE-2                * running from workbench?
WBMSG   EQU     WBSTAT-4                * loc of WB message
OURTSK  EQU     WBMSG-4                 * loc of our TCB
AMIGA   EQU     -OURTSK                 * size of Amiga global storage

_LVOCURRENTDIR  EQU  -126

CURDIR:
         MOVEA.L  4(A7),A1       *LOAD POINTER TO LOCK
         MOVE.L  (A1),D1         *LOAD LOCK
         MOVEM.L A0/A4-A6,-(A7)  *SAVE EVERYTHING WE NEED
         MOVEA.L  DOS(A0),A6      *MOVE IN DOS LIB POINTER

         JSR     _LVOCURRENTDIR(A6) *CHANGE THE DIRECTORY
         MOVEM.L (A7)+,A0/A4-A6  *RESTORE EVERYTHING
         RTS
