Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / rom / graphics / clonerastport.c
blob4728a6b4451f73531b63885ae44ad67f2bf47bb5
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function CloneRastPort()
6 Lang: english
7 */
8 #include "graphics_intern.h"
9 #include <exec/memory.h>
10 #include <graphics/rastport.h>
11 #include <proto/exec.h>
12 #include "gfxfuncsupport.h"
14 /*****************************************************************************
16 NAME */
17 #include <graphics/rastport.h>
18 #include <proto/graphics.h>
20 AROS_LH1(struct RastPort *, CloneRastPort,
22 /* SYNOPSIS */
23 AROS_LHA(struct RastPort *, rp, A1),
25 /* LOCATION */
26 struct GfxBase *, GfxBase, 178, Graphics)
28 /* FUNCTION
29 This function creates a copy of a RastPort.
31 INPUTS
32 rp - The RastPort to clone.
34 RESULT
35 A pointer to a RastPort with the same attributes as the RastPort
36 which was specified or NULL if there was not enough memory to perform
37 the operation.
39 NOTES
40 This function is AROS specific. For compatibility, there is a
41 function in aros.lib which does the same on Amiga.
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 CreateRastPort(), FreeRastPort()
50 INTERNALS
52 HISTORY
53 29-10-95 digulla automatically created from
54 graphics_lib.fd and clib/graphics_protos.h
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
60 struct RastPort * newRP;
62 newRP = AllocMem (sizeof (struct RastPort), MEMF_ANY);
64 if (newRP)
66 CopyMem (rp, newRP, sizeof (struct RastPort));
67 RP_BACKPOINTER(newRP) = newRP;
68 RP_DRIVERDATA(newRP) = NULL;
69 newRP->Flags |= RPF_SELF_CLEANUP;
71 if (!OBTAIN_DRIVERDATA(newRP, GfxBase))
73 FreeMem (newRP, sizeof (struct RastPort));
74 newRP = NULL;
76 else
78 /* copy rastports attributes */
79 SetFont(newRP, rp->Font);
80 SetABPenDrMd(newRP, GetAPen(rp), GetBPen(rp), GetDrMd(rp));
81 Move(newRP, rp->cp_x, rp->cp_y);
83 /* FIXME: Some attributes not copied */
85 RELEASE_DRIVERDATA(newRP, GfxBase);
89 return newRP;
91 AROS_LIBFUNC_EXIT
93 } /* CloneRastPort */