home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_oth / amigalib.lzh / AMIGALIB / AMIGALIB.LZH / asm_source / stdopn.asm < prev    next >
Encoding:
Assembly Source File  |  1990-01-17  |  4.0 KB  |  103 lines

  1. **********************************************************************
  2. *
  3. *   STDOPN version 1.1
  4. *
  5. *   Open a console device and attach it as the standard I/O channel for
  6. *   Fortran.  For use with Amiga AbSoft Fortran v 2.3, the Fortran 
  7. *   startup module WBINIT.ASM, and the Fortran-Workbench shutdown module
  8. *   WBEND.ASM (WBEND.SUB).  Compatible with normal CLI startup, but does
  9. *   not open a separate window when run from CLI.
  10. *
  11. *   Author:  Jim Locker, SofTech Inc.  Published in Amazing Computing.
  12. *
  13. *   This program is placed in the public domain.  Use as you see fit, but
  14. *   the author accepts no liability for anything.
  15. *
  16. *   Usage:
  17. *
  18. *          CALL STDOPN('CON:Lside/Top/Rside/Bot/my window name')
  19. *          where Lside is the pixel location of the left hand side of 
  20. *          the window, Top is the pixel location of the top, Rside
  21. *          is the width of the window, Bot is the height of the window,
  22. *          and "my window name" is self explanatory.  Be careful not to set
  23. *          the size of the window larger than the screen...the Guru will
  24. *          come calling
  25. *
  26. *          This call should precede any attempts to access the standard 
  27. *          Fortran console device from within your Fortran program.
  28. *
  29. *   This routine should be present if a Fortran program is to be started
  30. *   from Workbench.  A bug in Workbench prevents the ToolWindow in the icon
  31. *   from being passed to the application.  As a result, the WBINIT.ASM 
  32. *   startup code will not open a default window for a program started from
  33. *   Workbench.  Such a window is not always needed, but if it is, use this
  34. *   function.
  35. *
  36. *   As an unexpected benefit, this program will enable you to close the 
  37. *   default window that you started with and open a new one.  I am not sure
  38. *   why you would want to do this, but the possibility is there.
  39. *
  40. *    CHANGE HISTORY
  41. *     8 June 1989    Added capability to accept arguments in call
  42. *
  43. *****************************************************************************
  44.  
  45.    INCLUDE "exec/types.i"
  46.    INCLUDE "exec/alerts.i"
  47.    INCLUDE "exec/nodes.i"
  48.    INCLUDE "exec/lists.i"
  49.    INCLUDE "exec/ports.i"
  50.    INCLUDE "exec/libraries.i"
  51.    INCLUDE "exec/tasks.i"
  52.    INCLUDE "libraries/dos.i"
  53.    INCLUDE "libraries/dosextens.i"
  54.    INCLUDE "workbench/startup.i"
  55.  
  56. AEXEC   EQU     -16                     * "exec_lib" pointer
  57. DOS     EQU     AEXEC-4                 * "dos.library" pointer
  58. STDIN   EQU     DOS-4                   * file handle for STDIN
  59. STDOUT  EQU     STDIN-4                 * file handle for STDOUT
  60. H.BASE  EQU     STDOUT-4                * base of heap
  61. H.SIZE  EQU     H.BASE-4                * size of heap
  62. WBSTAT  EQU     H.SIZE-2                * running from workbench?
  63. WBMSG   EQU     WBSTAT-4                * loc of WB message
  64. OURTSK  EQU     WBMSG-4                 * loc of our TCB
  65. AMIGA   EQU     -OURTSK                 * size of Amiga global storage
  66.  
  67. * - from "dos.library"
  68.  
  69. _LVOOpen         EQU     -30
  70. _LVOClose        EQU     -36
  71.  
  72. STDOPEN:
  73.          tst.w WBSTAT(A0)                   * did we start from workbench?
  74.          bne.s contnu                       * no.
  75.          rts
  76.  
  77. contnu:
  78.          move.l   4(A7),A3                  * move in window pointer
  79.          movem.l  A0/A4/A6,-(A7)            * save some stuff
  80.          movea.l  DOS(A0),A6                * get the DOS lib pointer
  81.          move.l   STDIN(A0),D1              * get the old stdio file handle
  82.          jsr      _LVOClose(A6)             * and close it
  83.          movea.l  (A7),A0
  84.          move.l   A3,D1
  85.          move.l   #MODE_OLDFILE,D2
  86.          jsr      _LVOOpen(A6)              * open the new window
  87.          movem.l  (A7)+,A0
  88.          move.l   D0,STDIN(A0)              * stick the file handles where
  89.          move.l   D0,STDOUT(A0)             * they are needed
  90.          move.l   STDIN(A0),$9B0(A0)
  91.          move.l   STDOUT(A0),$AF6(A0)
  92. *
  93. * - set the console task (so Open("*",mode) will work)
  94. *
  95.          movea.l OURTSK(A0),A4 
  96.          lsl.l   #2,d0
  97.          move.l  d0,a0
  98.          move.l  fh_Type(a0),pr_ConsoleTask(A4)
  99.          movem.l (A7)+,A4/A6
  100.          rts
  101.  
  102.          
  103.