/*ProfiPacket - packet radio terminal program
  Copyright (C) 1999  Alexander Feigl

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Author:

  Alexander Feigl
  Burachstraße 51

  D-88250 Weingarten

  Mail : Alexander.Feigl@gmx.de
*/


.text
.even
.globl _newproc_code

_newproc_code:    move.l 0x4,A6
                  suba.l A1,A1
                  jsr A6@(-0x126)     /* LVO_FindTask */
                  move.l D0,A0
                  move.l A0@(88),A5   /* load TC_UserData*/
                  move.l A5@,A4       /* load global vector*/
                  move.l A5@(12),SP@-  /* load C lang parameter */
                  move.l A5@(4),A3    /* load _ForkFunc() */
                  cmp.l #0,a3
                  beq .newproc_code_nf
                  jsr A3@
.newproc_code_nf: addq.l #4,SP

                  move.l 0x4,A6
                  jsr A6@(-0x84)      /* LVO_Forbid */
 
                  move.l A5@(12),SP@-
                  move.l A5@(8),A3    /* load _DeinitFunc() */
                  cmp.l #0,A3
                  beq .newproc_code_nd
                  jsr A3@
.newproc_code_nd: addq.l #4,SP
                  move.l 0x4,A6
                  move.l A5@(12),A1
                  jsr A6@(-0x2b2)     /* LVO_FreeVec */
                  move.l A5,A1
                  jsr A6@(-0x2b2)     /* LVO_FreeVec */

                  rts


