oops .. forgot to offset from objects bounds
[AROS.git] / rom / intuition / changescreenbuffer.c
blobbea7622517f6ec3b7f1247db963b81e89fbd7f5c
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 Desc: Intuition function ChangeScreenBuffer()
7 Lang: english
8 */
9 #include <proto/graphics.h>
10 #include "intuition_intern.h"
11 #include "inputhandler.h"
12 #include "menus.h"
14 /*****************************************************************************
16 NAME */
17 #include <intuition/screens.h>
18 #include <proto/intuition.h>
20 AROS_LH2(ULONG, ChangeScreenBuffer,
22 /* SYNOPSIS */
23 AROS_LHA(struct Screen * , screen, A0),
24 AROS_LHA(struct ScreenBuffer *, screenbuffer, A1),
26 /* LOCATION */
27 struct IntuitionBase *, IntuitionBase, 130, Intuition)
29 /* FUNCTION
30 Do double or multiple buffering on an intuition screen in an
31 intuition-cooperative way.
32 The ScreenBuffer's BitMap will be installed on the specifies screen,
33 if possible.
34 After a signal from graphics.library, the previously installed
35 BitMap will be available for re-use.
36 Consult graphics.library/AllocDBufInfo() and
37 graphics.library/ChangeVPBitMap() for further information.
39 INPUTS
40 screen - The screen this screenbuffer belongs to
41 screenbuffer - The screenbuffer obtained by AllocScreenBuffer()
43 RESULT
44 Non-zero if fuction succeeded, or zero if operation could not be
45 performed, eg. if user selects menus or gadgets.
47 NOTES
48 You need not re-install the original ScreenBuffer before closing
49 a screen. Just FreeScreenBuffer() all buffers used for that screen.
51 EXAMPLE
53 BUGS
55 SEE ALSO
56 AllocScreenBuffer(), FreeScreenBuffer(),
57 graphics.library/ChangeVPBitMap()
59 INTERNALS
61 HISTORY
63 *****************************************************************************/
65 AROS_LIBFUNC_INIT
67 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
68 //struct IIHData *iihdata;
69 ULONG lock;
71 if (!screen) return 0;
72 if (!screenbuffer) return 0;
74 #if 0
75 if (MENUS_ACTIVE) return 0;
76 iihdata = (struct IIHData *)((struct IntIntuitionBase *)(IntuitionBase))->InputHandler->is_Data;
77 if (iihdata->ActiveGadget) return 0;
78 #endif
80 lock = LockIBase(0);
82 ChangeVPBitMap(&screen->ViewPort,screenbuffer->sb_BitMap,screenbuffer->sb_DBufInfo);
84 screen->RastPort.BitMap = screenbuffer->sb_BitMap;
85 UpdateScreenBitMap(screen, IntuitionBase);
87 UnlockIBase(lock);
89 return TRUE;
91 AROS_LIBFUNC_EXIT
92 } /* ChangeScreenBuffer */
94 void UpdateScreenBitMap(struct Screen *screen, struct IntuitionBase *IntuitionBase)
96 int i;
97 struct BitMap *bm = screen->RastPort.BitMap;
98 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
100 /* Patch up the obsolete screen bitmap as best we can for old programs
102 screen->BitMap_OBSOLETE.BytesPerRow = GetBitMapAttr(bm, BMA_WIDTH) / 8;
103 screen->BitMap_OBSOLETE.Rows = GetBitMapAttr(bm, BMA_HEIGHT);
104 screen->BitMap_OBSOLETE.Flags = BMF_INVALID | (GetBitMapAttr(bm, BMA_FLAGS) & BMF_STANDARD);
105 screen->BitMap_OBSOLETE.pad = 0;
106 screen->BitMap_OBSOLETE.Depth = GetBitMapAttr(bm, BMA_DEPTH);
107 for (i = 0; i < 8; i++) {
108 /* And for *really* old programs, copy the plane pointers,
109 * if possible
111 if (screen->BitMap_OBSOLETE.Flags & BMF_STANDARD)
112 screen->BitMap_OBSOLETE.Planes[i] = bm->Planes[i];
113 else
114 screen->BitMap_OBSOLETE.Planes[i] = NULL;